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 var
HintWinRect: TRect; HintWinRect: TRect;
begin begin
HintWinRect := HintTextWindow.CalcHintRect(Screen.Width, TheHint); HintWinRect := HintTextWindow.CalcHintRect(Screen.Width, TheHint, Nil);
HintTextWindow.HintRectAdjust := HintWinRect; // Adds borders. HintTextWindow.HintRectAdjust := HintWinRect; // Adds borders.
HintTextWindow.OffsetHintRect(ScreenPos); HintTextWindow.OffsetHintRect(ScreenPos);
HintTextWindow.ActivateText(TheHint); HintTextWindow.ActivateHint(TheHint);
end; end;
procedure DoHtml; procedure DoHtml;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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