IDE, IDEIntf: allow no mouse offset in hint window manager

git-svn-id: trunk@53367 -
This commit is contained in:
ondrej 2016-11-15 09:01:41 +00:00
parent c49f1ff869
commit cf080374cd
2 changed files with 27 additions and 20 deletions

View File

@ -181,7 +181,7 @@ type
constructor Create; overload;
destructor Destroy; override;
function HintIsVisible: boolean;
function ShowHint(ScreenPos: TPoint; TheHint: string): boolean;
function ShowHint(ScreenPos: TPoint; TheHint: string; const MouseOffset: Boolean = True): boolean;
procedure HideHint;
procedure HideIfVisible;
public
@ -352,7 +352,8 @@ begin
Result := FHtmlHelpProvider;
end;
function THintWindowManager.ShowHint(ScreenPos: TPoint; TheHint: string): boolean;
function THintWindowManager.ShowHint(ScreenPos: TPoint; TheHint: string;
const MouseOffset: Boolean): boolean;
var
ms: TMemoryStream;
NewWidth, NewHeight: integer;
@ -363,7 +364,10 @@ var
begin
HintWinRect := HintTextWindow.CalcHintRect(Screen.Width, TheHint, Nil);
HintTextWindow.HintRect := HintWinRect; // Adds borders.
HintTextWindow.OffsetHintRect(ScreenPos);
if MouseOffset then
HintTextWindow.OffsetHintRect(ScreenPos)
else
HintTextWindow.OffsetHintRect(ScreenPos, 0);
HintTextWindow.ActivateHint(TheHint);
end;
@ -385,7 +389,10 @@ var
if NewHeight <= 0 then
NewHeight := 200;
HintRenderWindow.HintRectAdjust := Rect(0, 0, NewWidth, NewHeight);
HintRenderWindow.OffsetHintRect(ScreenPos);
if MouseOffset then
HintRenderWindow.OffsetHintRect(ScreenPos)
else
HintRenderWindow.OffsetHintRect(ScreenPos, 0);
HintRenderWindow.ActivateRendered;
end;

View File

@ -378,7 +378,7 @@ type
procedure ActivateHint(const ClientPos: TPoint; const ABaseURL, AHint: string;
AAutoShown: Boolean = True); overload;
procedure ActivateHint(ClientRect: TRect; const ABaseURL, AHint: string;
AAutoShown: Boolean); overload;
AAutoShown: Boolean; AMouseOffset: Boolean = True); overload;
// selections
function SelectionAvailable: boolean; override;
@ -1007,9 +1007,9 @@ type
procedure HideHintTimer(Sender: TObject);
public
procedure ActivateHint(const ScreenRect: TRect; const ABaseURL, AHint: string;
AAutoShown: Boolean = True); overload;
AAutoShown: Boolean = True; AMouseOffset: Boolean = True); overload;
procedure ActivateHint(const ScreenPos: TPoint; const ABaseURL, AHint: string;
AAutoShown: Boolean = True); overload;
AAutoShown: Boolean = True; AMouseOffset: Boolean = True); overload;
procedure HideAutoHintAfterMouseMoved;
procedure HideAutoHint;
procedure UpdateHintTimer;
@ -1146,9 +1146,9 @@ type
// Hints
FHints: TSourceEditorHintWindowManager;
procedure ActivateHint(const ScreenRect: TRect; const BaseURL, TheHint: string;
AutoShown: Boolean = True); overload;
AutoShown: Boolean = True; AMouseOffset: Boolean = True); overload;
procedure ActivateHint(const ScreenPos: TPoint; const BaseURL, TheHint: string;
AutoShown: Boolean = True); overload;
AutoShown: Boolean = True; AMouseOffset: Boolean = True); overload;
private
FCodeTemplateModul: TSynEditAutoComplete;
FGotoDialog: TfrmGoto;
@ -1896,13 +1896,13 @@ end;
{ TSourceEditorHintWindowManager }
procedure TSourceEditorHintWindowManager.ActivateHint(const ScreenPos: TPoint;
const ABaseURL, AHint: string; AAutoShown: Boolean);
const ABaseURL, AHint: string; AAutoShown: Boolean; AMouseOffset: Boolean);
begin
ActivateHint(Rect(ScreenPos.x, ScreenPos.y, ScreenPos.x, ScreenPos.y), ABaseURL, AHint, AAutoShown);
ActivateHint(Rect(ScreenPos.x, ScreenPos.y, ScreenPos.x, ScreenPos.y), ABaseURL, AHint, AAutoShown, AMouseOffset);
end;
procedure TSourceEditorHintWindowManager.ActivateHint(const ScreenRect: TRect;
const ABaseURL, AHint: string; AAutoShown: Boolean);
const ABaseURL, AHint: string; AAutoShown: Boolean; AMouseOffset: Boolean);
begin
FAutoShown := AAutoShown;
BaseURL := ABaseURL;
@ -1912,13 +1912,13 @@ begin
begin
FAutoHintMousePos := Mouse.CursorPos;
if not(HintIsVisible and (FLastHint = AHint)) then
ShowHint(ScreenRect.TopLeft,AHint);
ShowHint(ScreenRect.TopLeft,AHint,AMouseOffset);
end else
begin
if HintIsVisible and (FLastHint = AHint) then
HideIfVisible
else
ShowHint(ScreenRect.TopLeft,AHint);
ShowHint(ScreenRect.TopLeft,AHint,AMouseOffset);
end;
FAutoHideHintTimer.Enabled := AAutoShown;
end;
@ -3303,14 +3303,14 @@ begin
end;
procedure TSourceEditor.ActivateHint(ClientRect: TRect; const ABaseURL,
AHint: string; AAutoShown: Boolean);
AHint: string; AAutoShown: Boolean; AMouseOffset: Boolean);
var
ScreenRect: TRect;
begin
if SourceNotebook=nil then exit;
ScreenRect.TopLeft:=EditorComponent.ClientToScreen(ClientRect.TopLeft);
ScreenRect.BottomRight:=EditorComponent.ClientToScreen(ClientRect.BottomRight);
Manager.ActivateHint(ScreenRect,ABaseURL,AHint,AAutoShown);
Manager.ActivateHint(ScreenRect,ABaseURL,AHint,AAutoShown,AMouseOffset);
end;
{------------------------------S T A R T F I N D-----------------------------}
@ -10736,19 +10736,19 @@ begin
end;
procedure TSourceEditorManager.ActivateHint(const ScreenPos: TPoint;
const BaseURL, TheHint: string; AutoShown: Boolean);
const BaseURL, TheHint: string; AutoShown: Boolean; AMouseOffset: Boolean);
begin
if csDestroying in ComponentState then exit;
FHints.ActivateHint(ScreenPos, BaseURL, TheHint, AutoShown);
FHints.ActivateHint(ScreenPos, BaseURL, TheHint, AutoShown, AMouseOffset);
end;
procedure TSourceEditorManager.ActivateHint(const ScreenRect: TRect;
const BaseURL, TheHint: string; AutoShown: Boolean);
const BaseURL, TheHint: string; AutoShown: Boolean; AMouseOffset: Boolean);
begin
if csDestroying in ComponentState then exit;
FHints.ActivateHint(ScreenRect, BaseURL, TheHint, AutoShown);
FHints.ActivateHint(ScreenRect, BaseURL, TheHint, AutoShown, AMouseOffset);
end;
procedure TSourceEditorManager.OnCodeTemplateTokenNotFound(Sender: TObject;