LCL: Revert some of THintWindow changes because of Delphi compatibility. Issue #26516

git-svn-id: trunk@45973 -
This commit is contained in:
juha 2014-07-25 16:56:19 +00:00
parent d9c5dee4f6
commit b189500498
9 changed files with 35 additions and 22 deletions

View File

@ -327,10 +327,10 @@ var
var
HintWinRect: TRect;
begin
HintWinRect := HintTextWindow.CalcHintRect(Screen.Width, TheHint);
HintWinRect := HintTextWindow.CalcHintRect(Screen.Width, TheHint, Nil);
HintTextWindow.HintRectAdjust := HintWinRect; // Adds borders.
HintTextWindow.OffsetHintRect(ScreenPos);
HintTextWindow.ActivateText(TheHint);
HintTextWindow.ActivateHint(TheHint);
end;
procedure DoHtml;

View File

@ -77,7 +77,8 @@ type
FIndex: Integer;
public
constructor Create(AOwner: TComponent); override;
function CalcHintRect(MaxWidth: Integer; const AHint: string): TRect; override;
function CalcHintRect(MaxWidth: Integer; const AHint: string;
AData: pointer): TRect; override;
procedure Paint; override;
property Index: Integer read FIndex write FIndex;
end;
@ -685,7 +686,7 @@ begin
// CalcHintRect uses the current index
FHint.Index := AIndex;
// calculate the size
R := FHint.CalcHintRect(Monitor.Width, ItemList[AIndex]);
R := FHint.CalcHintRect(Monitor.Width, ItemList[AIndex], nil);
if (R.Right <= Scroll.Left) then begin
FHint.Hide;
@ -726,7 +727,7 @@ end;
procedure TSynBaseCompletionForm.OnHintTimer(Sender: TObject);
begin
FHintTimer.Enabled := False;
FHint.ActivateText(ItemList[FHint.Index]);
FHint.ActivateHint(ItemList[FHint.Index]);
end;
procedure TSynBaseCompletionForm.KeyDown(var Key: Word; Shift: TShiftState);
@ -2154,7 +2155,8 @@ begin
Visible := False;
end;
function TSynBaseCompletionHint.CalcHintRect(MaxWidth: Integer; const AHint: string): TRect;
function TSynBaseCompletionHint.CalcHintRect(MaxWidth: Integer; const AHint: string;
AData: pointer): TRect;
var
P: TPoint;
begin

View File

@ -4747,7 +4747,7 @@ begin
ScrollHint.Visible := TRUE;
end;
s := Format('line %d', [TopLine]);
rc := ScrollHint.CalcHintRect(200, s);
rc := ScrollHint.CalcHintRect(200, s, Nil);
pt := ClientToScreen(Point(ClientWidth-ScrollBarWidth - rc.Right - 4, 10));
if eoScrollHintFollows in fOptions then
pt.y := Mouse.CursorPos.y - (rc.Bottom div 2);

View File

@ -1799,7 +1799,7 @@ begin
if FHintWindow = nil then
FHintWindow := THintWindow.Create(nil);
if h = '' then exit;
r := FHintWindow.CalcHintRect(FChart.Width, h);
r := FHintWindow.CalcHintRect(FChart.Width, h, Nil);
OffsetRect(r, APoint.X, APoint.Y);
FHintWindow.ActivateWithBounds(r, h);
end;

View File

@ -4244,14 +4244,14 @@ begin
AHint := GetSelectionPosHintText;
end;
Rect := FHintWindow.CalcHintRect(0, AHint); //no maxwidth
Rect := FHintWindow.CalcHintRect(0, AHint, Nil); //no maxwidth
Rect.Left := Position.X + 15;
Rect.Top := Position.Y + 15;
Rect.Right := Rect.Left + Rect.Right;
Rect.Bottom := Rect.Top + Rect.Bottom;
FHintWindow.HintRectAdjust := Rect;
FHintWindow.ActivateText(AHint);
FHintWindow.ActivateHint(AHint);
end;
procedure TDesigner.SetSnapToGrid(const AValue: boolean);

View File

@ -1678,7 +1678,7 @@ begin
HintWinRect := Rect(0, 0, NewWidth, NewHeight);
TheHint:='';
end else begin
HintWinRect := aHintWindow.CalcHintRect(Screen.Width, TheHint);
HintWinRect := aHintWindow.CalcHintRect(Screen.Width, TheHint, Nil);
aHintWindow.HintRectAdjust := HintWinRect; // Adds borders.
end;
OffsetRect(HintWinRect, ScreenPos.X, ScreenPos.Y+30);

View File

@ -860,11 +860,13 @@ type
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure ActivateText(const AHint: String);
procedure ActivateHint(const AHint: String);
procedure ActivateHint(ARect: TRect; const AHint: String); virtual;
procedure ActivateWithBounds(ARect: TRect; const AHint: String);
procedure ActivateWithData(ARect: TRect; const AHint: String; AData: pointer);
deprecated 'Set HintData explicitly';
function CalcHintRect(MaxWidth: Integer; const AHint: String): TRect; virtual;
procedure ActivateHintData(ARect: TRect; const AHint: String;
AData: pointer); virtual;
function CalcHintRect(MaxWidth: Integer; const AHint: String;
AData: pointer): TRect; virtual;
function OffsetHintRect(NewPos: TPoint; dy: Integer = 30): Boolean;
procedure InitializeWnd; override;
procedure ReleaseHandle;

View File

@ -847,7 +847,8 @@ begin
// make the hint have the same BiDiMode as the activating control
FHintWindow.BiDiMode := FHintControl.BiDiMode;
// calculate the width of the hint based on HintStr and MaxWidth
HintWinRect := FHintWindow.CalcHintRect(HintInfo.HintMaxWidth, HintInfo.HintStr);
with HintInfo do
HintWinRect := FHintWindow.CalcHintRect(HintMaxWidth, HintStr, HintData);
//Position HintWindow depending on LTR/RTL
if FHintWindow.UseRightToLeftAlignment then
OffsetRect(HintWinRect, HintInfo.HintPos.X - (HintWinRect.Right - HintWinRect.Left), HintInfo.HintPos.Y)
@ -860,7 +861,7 @@ begin
//debugln('TApplication.ShowHintWindow B HintWinRect=',dbgs(HintWinRect),' HintStr="',DbgStr(HintInfo.HintStr),'"');
FHintWindow.HintRectAdjust := HintWinRect;
FHintWindow.ActivateText(HintInfo.HintStr);
FHintWindow.ActivateHint(HintInfo.HintStr);
FHintRect := HintInfo.CursorRect;
// start hide timer
StartHintTimer(HintInfo.HideTimeout,ahttHideHint);

View File

@ -213,7 +213,7 @@ begin
Invalidate;
end;
procedure THintWindow.ActivateText(const AHint: String);
procedure THintWindow.ActivateHint(const AHint: String);
// Shows simple text hint.
begin
if FActivating then exit;
@ -227,19 +227,27 @@ begin
end;
end;
procedure THintWindow.ActivateHint(ARect: TRect; const AHint: String);
begin
HintRect := ARect;
AdjustBoundsForMonitor;
ActivateHint(AHint);
end;
procedure THintWindow.ActivateWithBounds(ARect: TRect; const AHint: String);
begin
HintRect := ARect;
ActivateText(AHint);
ActivateHint(AHint);
end;
procedure THintWindow.ActivateWithData(ARect: TRect; const AHint: String; AData: pointer);
procedure THintWindow.ActivateHintData(ARect: TRect; const AHint: String; AData: pointer);
begin
HintRectAdjust := ARect;
ActivateText(AHint); // AData is not used now.
ActivateHint(AHint); // AData is not used now.
end;
function THintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String): TRect;
function THintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String;
AData: pointer): TRect;
var
Flags: Cardinal;
uh: HDC;