mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 23:18:01 +02:00
IDE: started code help hint window
git-svn-id: trunk@12766 -
This commit is contained in:
parent
859fbcbdf6
commit
dbf55b433f
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1720,6 +1720,7 @@ ide/codeexplopts.pas svneol=native#text/pascal
|
||||
ide/codeexplorer.lfm svneol=native#text/plain
|
||||
ide/codeexplorer.lrs svneol=native#text/pascal
|
||||
ide/codeexplorer.pas svneol=native#text/pascal
|
||||
ide/codehelpform.pas svneol=native#text/plain
|
||||
ide/codemacroprompt.lfm svneol=native#text/plain
|
||||
ide/codemacroprompt.lrs svneol=native#text/plain
|
||||
ide/codemacroprompt.pas svneol=native#text/plain
|
||||
|
@ -149,6 +149,7 @@ type
|
||||
Bitmap: TBitmap; // used for drawing
|
||||
fCurrentEditor: TComponent;
|
||||
FOnMeasureItem: TSynBaseCompletionMeasureItem;
|
||||
FOnPositionChanged: TNotifyEvent;
|
||||
public
|
||||
constructor Create(AOwner: Tcomponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -178,9 +179,10 @@ type
|
||||
property FontHeight:integer read FFontHeight write SetFontHeight;
|
||||
property OnSearchPosition:TSynBaseCompletionSearchPosition
|
||||
read FOnSearchPosition write FOnSearchPosition;
|
||||
property OnKeyCompletePrefix: TNotifyEvent read FOnKeyCompletePrefix write FOnKeyCompletePrefix;
|
||||
property OnKeyNextChar: TNotifyEvent read FOnKeyNextChar write FOnKeyNextChar;
|
||||
property OnKeyPrevChar: TNotifyEvent read FOnKeyPrevChar write FOnKeyPrevChar;
|
||||
property OnKeyCompletePrefix: TNotifyEvent read FOnKeyCompletePrefix write FOnKeyCompletePrefix;// e.g. Tab
|
||||
property OnKeyNextChar: TNotifyEvent read FOnKeyNextChar write FOnKeyNextChar;// e.g. arrow right
|
||||
property OnKeyPrevChar: TNotifyEvent read FOnKeyPrevChar write FOnKeyPrevChar;// e.g. arrow left
|
||||
property OnPositionChanged: TNotifyEvent read FOnPositionChanged write FOnPositionChanged;
|
||||
property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor;
|
||||
property TextColor: TColor read FTextColor write FTextColor;
|
||||
property TextSelectedColor: TColor
|
||||
@ -201,6 +203,7 @@ type
|
||||
function GetClSelect: TColor;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
function GetOnMeasureItem: TSynBaseCompletionMeasureItem;
|
||||
function GetOnPositionChanged: TNotifyEvent;
|
||||
{$ENDIF}
|
||||
procedure SetClSelect(const Value: TColor);
|
||||
function GetCurrentString: string;
|
||||
@ -218,6 +221,7 @@ type
|
||||
procedure SetOnKeyPress(const Value: TKeyPressEvent);
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
procedure SetOnMeasureItem(const AValue: TSynBaseCompletionMeasureItem);
|
||||
procedure SetOnPositionChanged(const AValue: TNotifyEvent);
|
||||
{$ENDIF}
|
||||
procedure SetOnPaintItem(const Value: TSynBaseCompletionPaintItem);
|
||||
procedure SetPosition(const Value: Integer);
|
||||
@ -272,11 +276,13 @@ type
|
||||
property OnSearchPosition: TSynBaseCompletionSearchPosition
|
||||
read GetOnSearchPosition write SetOnSearchPosition;
|
||||
property OnKeyCompletePrefix: TNotifyEvent read GetOnKeyCompletePrefix
|
||||
write SetOnKeyCompletePrefix;
|
||||
write SetOnKeyCompletePrefix;// e.g. Tab
|
||||
property OnKeyNextChar: TNotifyEvent read GetOnKeyNextChar
|
||||
write SetOnKeyNextChar;
|
||||
write SetOnKeyNextChar;// e.g. arrow right
|
||||
property OnKeyPrevChar: TNotifyEvent read GetOnKeyPrevChar
|
||||
write SetOnKeyPrevChar;
|
||||
write SetOnKeyPrevChar;// e.g. arrow left
|
||||
property OnPositionChanged: TNotifyEvent read GetOnPositionChanged
|
||||
write SetOnPositionChanged;
|
||||
{$ENDIF}
|
||||
property ClSelect: TColor read GetClSelect write SetClSelect;
|
||||
property AnsiStrings: boolean read SFAnsi write RFAnsi;
|
||||
@ -872,6 +878,7 @@ begin
|
||||
else if Scroll.Position < Position - NbLinesInWindow + 1 then
|
||||
Scroll.Position := Position - NbLinesInWindow + 1;
|
||||
Invalidate;
|
||||
if Assigned(OnPositionChanged) then OnPositionChanged(Self);
|
||||
end;
|
||||
end;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
@ -1077,6 +1084,11 @@ procedure TSynBaseCompletion.SetOnMeasureItem(
|
||||
begin
|
||||
Form.OnMeasureItem := AValue;
|
||||
end;
|
||||
|
||||
procedure TSynBaseCompletion.SetOnPositionChanged(const AValue: TNotifyEvent);
|
||||
begin
|
||||
Form.OnPositionChanged := AValue;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TSynBaseCompletion.SetOnPaintItem(const Value:
|
||||
@ -1105,6 +1117,11 @@ function TSynBaseCompletion.GetOnMeasureItem: TSynBaseCompletionMeasureItem;
|
||||
begin
|
||||
Result := Form.OnMeasureItem;
|
||||
end;
|
||||
|
||||
function TSynBaseCompletion.GetOnPositionChanged: TNotifyEvent;
|
||||
begin
|
||||
Result := Form.OnPositionChanged;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TSynBaseCompletion.SetClSelect(const Value: TColor);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
Abstract:
|
||||
The popup tooltip window for the source editor.
|
||||
For example for the parameter hints.
|
||||
}
|
||||
unit CodeContextForm;
|
||||
|
||||
@ -60,6 +61,7 @@ type
|
||||
FLastParameterIndex: integer;
|
||||
FParamListBracketOpenCodeXYPos: TCodeXYPosition;
|
||||
FProcNameCodeXYPos: TCodeXYPosition;
|
||||
FSourceEditorTopIndex: integer;
|
||||
procedure CreateHints(const CodeContexts: TCodeContextInfo);
|
||||
procedure ClearMarksInHints;
|
||||
procedure MarkCurrentParameterInHints(ParameterIndex: integer); // 0 based
|
||||
@ -75,12 +77,13 @@ type
|
||||
property ProcNameCodeXYPos: TCodeXYPosition read FProcNameCodeXYPos;
|
||||
property ParamListBracketOpenCodeXYPos: TCodeXYPosition
|
||||
read FParamListBracketOpenCodeXYPos;
|
||||
property SourceEditorTopIndex: integer read FSourceEditorTopIndex;
|
||||
property LastParameterIndex: integer read FLastParameterIndex;
|
||||
end;
|
||||
|
||||
var
|
||||
CodeContextFrm: TCodeContextFrm = nil;
|
||||
|
||||
|
||||
function ShowCodeContext(Code: TCodeBuffer): boolean;
|
||||
|
||||
implementation
|
||||
@ -151,8 +154,8 @@ var
|
||||
DrawWidth: LongInt;
|
||||
DrawHeight: LongInt;
|
||||
begin
|
||||
DrawWidth:=Self.ClientWidth;
|
||||
DrawHeight:=Self.ClientHeight;
|
||||
DrawWidth:=ClientWidth;
|
||||
DrawHeight:=ClientHeight;
|
||||
DrawHints(DrawWidth,DrawHeight,true);
|
||||
end;
|
||||
|
||||
@ -220,6 +223,7 @@ begin
|
||||
SrcEdit:=SourceEditorWindow.ActiveEditor;
|
||||
if (SrcEdit=nil) or (SrcEdit.CodeToolsBuffer<>ProcNameCodeXYPos.Code) then
|
||||
exit;
|
||||
if SrcEdit.TopLine<>FSourceEditorTopIndex then exit;
|
||||
|
||||
CurTextXY:=SrcEdit.CursorTextXY;
|
||||
BracketPos:=Point(ParamListBracketOpenCodeXYPos.X,
|
||||
@ -247,7 +251,7 @@ begin
|
||||
SetLength(Code,length(Code)-length(Line)+CurTextXY.X-1);
|
||||
end;
|
||||
//DebugLn('TCodeContextFrm.UpdateHints Code="',DbgStr(Code),'"');
|
||||
|
||||
|
||||
// parse the code
|
||||
TokenEnd:=BracketPos.X;
|
||||
BracketLevel:=0;
|
||||
@ -496,6 +500,7 @@ begin
|
||||
// calculate screen position
|
||||
ScreenTextXY:=SrcEdit.TextToScreenPosition(CursorTextXY);
|
||||
ClientXY:=SrcEdit.ScreenToPixelPosition(ScreenTextXY);
|
||||
FSourceEditorTopIndex:=SrcEdit.TopLine;
|
||||
|
||||
// calculate size of hints
|
||||
DrawWidth:=SourceEditorWindow.ClientWidth;
|
||||
|
359
ide/codehelpform.pas
Normal file
359
ide/codehelpform.pas
Normal file
@ -0,0 +1,359 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
CodeContextForm.pas
|
||||
-------------------
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
The base class for hint windows for the source editor for the online help.
|
||||
For example for the fpdoc and comment help.
|
||||
}
|
||||
unit CodeHelpForm;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Math, SysUtils, LCLProc, LCLType, LCLIntf, Forms, Controls, Graphics,
|
||||
SynEdit, SynEditKeyCmds,
|
||||
SrcEditorIntf;
|
||||
|
||||
type
|
||||
|
||||
{ TCodeHintProvider }
|
||||
|
||||
TCodeHintProvider = class(TComponent)
|
||||
public
|
||||
procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer); virtual;
|
||||
procedure Paint(Canvas: TCanvas; const ARect: TRect); virtual; abstract;
|
||||
end;
|
||||
|
||||
{ TCodeHelpFrm }
|
||||
|
||||
TCodeHelpFrm = class(THintWindow)
|
||||
procedure ApplicationIdle(Sender: TObject; var Done: Boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
procedure FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||
private
|
||||
FAnchorForm: TCustomForm;
|
||||
FHelpEnabled: boolean;
|
||||
FPreferredHeight: integer;
|
||||
FPreferredWidth: integer;
|
||||
FProvider: TCodeHintProvider;
|
||||
FSrcEditCaret: TPoint;
|
||||
procedure SetAnchorForm(const AValue: TCustomForm);
|
||||
procedure OnAnchorFormChangeBounds(Sender: TObject);
|
||||
procedure SetHelpEnabled(const AValue: boolean);
|
||||
procedure SetPreferredHeight(const AValue: integer);
|
||||
procedure SetPreferredWidth(const AValue: integer);
|
||||
procedure SetProvider(const AValue: TCodeHintProvider);
|
||||
procedure SetSrcEditCaret(const AValue: TPoint);
|
||||
procedure UpdatePosition;
|
||||
protected
|
||||
procedure Paint; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure UpdateHints;// update content
|
||||
function NeedVisible: boolean;
|
||||
property AnchorForm: TCustomForm read FAnchorForm write SetAnchorForm;
|
||||
property HelpEnabled: boolean read FHelpEnabled write SetHelpEnabled;
|
||||
property SrcEditCaret: TPoint read FSrcEditCaret write SetSrcEditCaret;// 0,0 means use current position, should be ScreenXY, not TextXY
|
||||
property PreferredWidth: integer read FPreferredWidth write SetPreferredWidth;
|
||||
property PreferredHeight: integer read FPreferredHeight write SetPreferredHeight;
|
||||
property Provider: TCodeHintProvider read FProvider write SetProvider;
|
||||
end;
|
||||
|
||||
var
|
||||
CodeHelpFrm: TCodeHelpFrm = nil;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCodeHelpFrm }
|
||||
|
||||
procedure TCodeHelpFrm.ApplicationIdle(Sender: TObject; var Done: Boolean);
|
||||
begin
|
||||
//DebugLn(['TCodeHelpFrm.ApplicationIdle NeedVisible=',NeedVisible]);
|
||||
if not NeedVisible then begin
|
||||
Hide;
|
||||
exit;
|
||||
end;
|
||||
UpdatePosition;
|
||||
UpdateHints;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Application.AddOnIdleHandler(@ApplicationIdle);
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.FormKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
var
|
||||
SrcEdit: TSourceEditorInterface;
|
||||
begin
|
||||
if (Key=VK_ESCAPE) and (Shift=[]) then
|
||||
Hide
|
||||
else if SourceEditorWindow<>nil then begin
|
||||
SrcEdit:=SourceEditorWindow.ActiveEditor;
|
||||
if SrcEdit=nil then
|
||||
Hide
|
||||
else begin
|
||||
// redirect keys
|
||||
SrcEdit.EditorControl.KeyDown(Key,Shift);
|
||||
SetActiveWindow(SourceEditorWindow.Handle);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.FormPaint(Sender: TObject);
|
||||
begin
|
||||
if Provider<>nil then begin
|
||||
Provider.Paint(Canvas,Rect(0,0,ClientWidth,ClientHeight));
|
||||
end else begin
|
||||
with Canvas do begin
|
||||
Font.SetDefault;
|
||||
TextOut(6,20,'No help available (missing provider)');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char
|
||||
);
|
||||
var
|
||||
SrcEdit: TSourceEditorInterface;
|
||||
ASynEdit: TCustomSynEdit;
|
||||
begin
|
||||
SrcEdit:=SourceEditorWindow.ActiveEditor;
|
||||
if SrcEdit=nil then begin
|
||||
Hide;
|
||||
end else begin
|
||||
ASynEdit:=(SrcEdit.EditorControl as TCustomSynEdit);
|
||||
ASynEdit.CommandProcessor(ecChar,UTF8Key,nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.SetAnchorForm(const AValue: TCustomForm);
|
||||
begin
|
||||
if FAnchorForm=AValue then exit;
|
||||
if FAnchorForm<>nil then
|
||||
FAnchorForm.RemoveAllHandlersOfObject(Self);
|
||||
FAnchorForm:=AValue;
|
||||
if FAnchorForm<>nil then
|
||||
FAnchorForm.AddHandlerOnChangeBounds(@OnAnchorFormChangeBounds);
|
||||
UpdatePosition;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.OnAnchorFormChangeBounds(Sender: TObject);
|
||||
begin
|
||||
//DebugLn(['TCodeHelpFrm.OnAnchorFormChangeBounds ',dbgs(BoundsRect),' Sender=',dbgsName(Sender),' SenderVisible=',TControl(Sender).Visible,' SenderBounds=',dbgs(TControl(Sender).BoundsRect)]);
|
||||
UpdatePosition;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.SetHelpEnabled(const AValue: boolean);
|
||||
begin
|
||||
if FHelpEnabled=AValue then exit;
|
||||
FHelpEnabled:=AValue;
|
||||
UpdatePosition;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.SetPreferredHeight(const AValue: integer);
|
||||
begin
|
||||
if FPreferredHeight=AValue then exit;
|
||||
FPreferredHeight:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.SetPreferredWidth(const AValue: integer);
|
||||
begin
|
||||
if FPreferredWidth=AValue then exit;
|
||||
FPreferredWidth:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.SetProvider(const AValue: TCodeHintProvider);
|
||||
begin
|
||||
if FProvider=AValue then exit;
|
||||
FProvider:=AValue;
|
||||
if FProvider<>nil then begin
|
||||
FProvider.GetPreferredSize(FPreferredWidth,FPreferredHeight);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.SetSrcEditCaret(const AValue: TPoint);
|
||||
begin
|
||||
if ComparePoints(FSrcEditCaret,AValue)=0 then exit;
|
||||
FSrcEditCaret:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.UpdatePosition;
|
||||
var
|
||||
NewBounds: TRect;
|
||||
DesktopBounds: TRect;
|
||||
|
||||
procedure TryPosition(TryBounds: TRect; TheAnchors: TAnchors);
|
||||
begin
|
||||
TryBounds.Right:=Max(TryBounds.Left,TryBounds.Right);
|
||||
TryBounds.Bottom:=Max(TryBounds.Top,TryBounds.Bottom);
|
||||
if TryBounds.Right>DesktopBounds.Right then begin
|
||||
if not (akLeft in TheAnchors) then begin
|
||||
// move to the left
|
||||
dec(TryBounds.Left,TryBounds.Right-DesktopBounds.Right);
|
||||
TryBounds.Left:=Max(TryBounds.Left,DesktopBounds.Left);
|
||||
end;
|
||||
TryBounds.Right:=DesktopBounds.Right;
|
||||
end;
|
||||
if TryBounds.Left<DesktopBounds.Left then begin
|
||||
if not (akRight in TheAnchors) then begin
|
||||
// move to the right
|
||||
inc(TryBounds.Right,DesktopBounds.Left-TryBounds.Left);
|
||||
TryBounds.Left:=Min(TryBounds.Right,DesktopBounds.Right);
|
||||
end;
|
||||
TryBounds.Left:=DesktopBounds.Left;
|
||||
end;
|
||||
if TryBounds.Bottom>DesktopBounds.Bottom then begin
|
||||
if not (akTop in TheAnchors) then begin
|
||||
// move to the top
|
||||
dec(TryBounds.Top,TryBounds.Bottom-DesktopBounds.Bottom);
|
||||
TryBounds.Top:=Max(TryBounds.Top,DesktopBounds.Top);
|
||||
end;
|
||||
TryBounds.Bottom:=DesktopBounds.Bottom;
|
||||
end;
|
||||
if TryBounds.Top<DesktopBounds.Top then begin
|
||||
if not (akBottom in TheAnchors) then begin
|
||||
// move to the bottom
|
||||
inc(TryBounds.Bottom,DesktopBounds.Top-TryBounds.Top);
|
||||
TryBounds.Bottom:=Min(TryBounds.Bottom,DesktopBounds.Bottom);
|
||||
end;
|
||||
TryBounds.Top:=DesktopBounds.Top;
|
||||
end;
|
||||
// check if TryBounds are better than NewBounds
|
||||
if (TryBounds.Right-TryBounds.Left)*(TryBounds.Bottom-TryBounds.Top)
|
||||
> (NewBounds.Right-NewBounds.Left)*(NewBounds.Bottom-NewBounds.Top)
|
||||
then
|
||||
NewBounds:=TryBounds;
|
||||
end;
|
||||
|
||||
var
|
||||
CurCaret: TPoint;
|
||||
SrcEdit: TSourceEditorInterface;
|
||||
AnchorBounds: TRect;
|
||||
begin
|
||||
if not NeedVisible then exit;
|
||||
DesktopBounds:=Rect(30,30,Screen.DesktopWidth-30,Screen.DesktopHeight-50);
|
||||
NewBounds:=Bounds(DesktopBounds.Left,DesktopBounds.Top,30,30);
|
||||
|
||||
if AnchorForm<>nil then begin
|
||||
// place near the AnchorForm
|
||||
AnchorBounds:=AnchorForm.BoundsRect;
|
||||
// try right of AnchorForm
|
||||
TryPosition(Bounds(AnchorBounds.Right+6,AnchorBounds.Top,
|
||||
PreferredWidth,PreferredHeight),[akLeft,akTop]);
|
||||
// try left of AnchorForm
|
||||
TryPosition(Bounds(AnchorBounds.Left-6-PreferredWidth,AnchorBounds.Top,
|
||||
PreferredWidth,PreferredHeight),[akRight,akTop]);
|
||||
// try below
|
||||
TryPosition(Bounds(AnchorBounds.Left,AnchorBounds.Bottom+6,
|
||||
PreferredWidth,PreferredHeight),[akTop]);
|
||||
end else begin
|
||||
// place near the source editor caret
|
||||
CurCaret:=SrcEditCaret;
|
||||
SrcEdit:=SourceEditorWindow.ActiveEditor;
|
||||
if CurCaret.Y<1 then
|
||||
CurCaret:=SrcEdit.CursorScreenXY;
|
||||
CurCaret:=SrcEdit.EditorControl.ClientToScreen(SrcEdit.ScreenToPixelPosition(CurCaret));
|
||||
|
||||
// try below
|
||||
TryPosition(Bounds(CurCaret.X-(PreferredWidth div 2),CurCaret.Y+6,
|
||||
PreferredWidth,PreferredHeight),[akTop]);
|
||||
// try above
|
||||
TryPosition(Bounds(CurCaret.X-(PreferredWidth div 2),
|
||||
CurCaret.Y-6-PreferredHeight,
|
||||
PreferredWidth,PreferredHeight),[akBottom]);
|
||||
end;
|
||||
|
||||
//DebugLn(['TCodeHelpFrm.UpdatePosition NewBounds=',dbgs(NewBounds),' BoundsRect=',dbgs(BoundsRect)]);
|
||||
BoundsRect:=NewBounds;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.Paint;
|
||||
begin
|
||||
FormPaint(Self);
|
||||
end;
|
||||
|
||||
constructor TCodeHelpFrm.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
OnDestroy:=@FormDestroy;
|
||||
OnKeyDown:=@FormKeyDown;
|
||||
OnUTF8KeyPress:=@FormUTF8KeyPress;
|
||||
FPreferredWidth:=300;
|
||||
FPreferredHeight:=200;
|
||||
FormCreate(Self);
|
||||
end;
|
||||
|
||||
destructor TCodeHelpFrm.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
if CodeHelpFrm=Self then
|
||||
CodeHelpFrm:=nil;
|
||||
end;
|
||||
|
||||
procedure TCodeHelpFrm.UpdateHints;
|
||||
begin
|
||||
if not Visible then exit;
|
||||
//DebugLn(['TCodeHelpFrm.UpdateHints ']);
|
||||
|
||||
end;
|
||||
|
||||
function TCodeHelpFrm.NeedVisible: boolean;
|
||||
begin
|
||||
if not HelpEnabled then exit(false);
|
||||
if (AnchorForm<>nil) then begin
|
||||
Result:=AnchorForm.Visible;
|
||||
end else begin
|
||||
Result:=(SourceEditorWindow<>nil)
|
||||
and (SourceEditorWindow.ActiveEditor<>nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TCodeHintProvider }
|
||||
|
||||
procedure TCodeHintProvider.GetPreferredSize(var PreferredWidth,
|
||||
PreferredHeight: integer);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -55,7 +55,7 @@ uses
|
||||
// IDE units
|
||||
LazarusIDEStrConsts, LazConf, IDECommands, EditorOptions, KeyMapping, Project,
|
||||
WordCompletion, FindReplaceDialog, FindInFilesDlg, IDEProcs, IDEOptionDefs,
|
||||
MacroPromptDlg, TransferMacros, CodeContextForm,
|
||||
MacroPromptDlg, TransferMacros, CodeContextForm, CodeHelpForm,
|
||||
EnvironmentOpts, MsgView, SearchResultView, InputHistory, CodeMacroPrompt,
|
||||
CodeTemplatesDlg,
|
||||
SortSelectionDlg, EncloseSelectionDlg, DiffDialog, ConDef, InvertAssignTool,
|
||||
@ -552,6 +552,7 @@ type
|
||||
procedure OnSynCompletionPrevChar(Sender: TObject);
|
||||
procedure OnSynCompletionKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure OnSynCompletionUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||
procedure OnSynCompletionPositionChanged(Sender: TObject);
|
||||
procedure DeactivateCompletionForm;
|
||||
procedure InitIdentCompletion(S: TStrings);
|
||||
|
||||
@ -687,12 +688,15 @@ type
|
||||
procedure ActivateHint(const ScreenPos: TPoint; const TheHint: string);
|
||||
procedure HideHint;
|
||||
procedure StartShowCodeContext(JumpToError: boolean);
|
||||
procedure StartShowCodeHelp;
|
||||
|
||||
Procedure NewFile(const NewShortName: String; ASource: TCodeBuffer;
|
||||
// new, close, focus
|
||||
procedure NewFile(const NewShortName: String; ASource: TCodeBuffer;
|
||||
FocusIt: boolean);
|
||||
Procedure CloseFile(PageIndex:integer);
|
||||
procedure CloseFile(PageIndex:integer);
|
||||
procedure FocusEditor;
|
||||
|
||||
// paste and copy
|
||||
procedure CutClicked(Sender: TObject);
|
||||
procedure CopyClicked(Sender: TObject);
|
||||
procedure PasteClicked(Sender: TObject);
|
||||
@ -1346,6 +1350,8 @@ begin
|
||||
// close hint windows
|
||||
if (CodeContextFrm<>nil) then
|
||||
CodeContextFrm.Hide;
|
||||
if (CodeHelpFrm<>nil) then
|
||||
CodeHelpFrm.Hide;
|
||||
end;
|
||||
|
||||
if (FSourceNoteBook<>nil)
|
||||
@ -3000,6 +3006,7 @@ begin
|
||||
FreeAndNil(Gotodialog);
|
||||
|
||||
FreeThenNil(CodeContextFrm);
|
||||
FreeThenNil(CodeHelpFrm);
|
||||
FreeThenNil(aCompletion);
|
||||
FreeThenNil(FHintTimer);
|
||||
FreeThenNil(FHintWindow);
|
||||
@ -3045,6 +3052,7 @@ begin
|
||||
OnKeyPrevChar:=@OnSynCompletionPrevChar;
|
||||
OnKeyPress:=@OnSynCompletionKeyPress;
|
||||
OnUTF8KeyPress:=@OnSynCompletionUTF8KeyPress;
|
||||
OnPositionChanged:=@OnSynCompletionPositionChanged;
|
||||
ShortCut:=Menus.ShortCut(VK_UNKNOWN,[]);
|
||||
end;
|
||||
|
||||
@ -3434,6 +3442,12 @@ begin
|
||||
//debugln('TSourceNotebook.OnSynCompletionKeyPress B UTF8Key=',dbgstr(UTF8Key));
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.OnSynCompletionPositionChanged(Sender: TObject);
|
||||
begin
|
||||
if CodeHelpFrm<>nil then
|
||||
CodeHelpFrm.UpdateHints;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.DeactivateCompletionForm;
|
||||
var
|
||||
ActSE: TSourceEditor;
|
||||
@ -3637,6 +3651,10 @@ Begin
|
||||
// ' TextSelectedColor=',DbgS(TextSelectedColor),
|
||||
// '');
|
||||
end;
|
||||
if CurrentCompletionType=ctIdentCompletion then
|
||||
StartShowCodeHelp
|
||||
else if CodeHelpFrm<>nil then
|
||||
CodeHelpFrm.HelpEnabled:=false;
|
||||
end;
|
||||
End;
|
||||
|
||||
@ -4736,7 +4754,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TSourceNotebook.BookMarkSetClicked(Sender: TObject);
|
||||
procedure TSourceNotebook.StartShowCodeHelp;
|
||||
begin
|
||||
if CodeHelpFrm=nil then begin
|
||||
CodeHelpFrm:=TCodeHelpFrm.Create(Self);
|
||||
CodeHelpFrm.Name:='TSourceNotebook_CodeHelpFrm';
|
||||
end;
|
||||
CodeHelpFrm.AnchorForm:=CurCompletionControl.TheForm;
|
||||
{$IFDEF EnableCodeHelp}
|
||||
CodeHelpFrm.HelpEnabled:=true;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.BookMarkSetClicked(Sender: TObject);
|
||||
// popup menu: set bookmark clicked
|
||||
var
|
||||
MenuItem: TIDEMenuItem;
|
||||
|
@ -94,7 +94,10 @@ type
|
||||
function HeightInLines: Integer; virtual; abstract;
|
||||
function CharWidth: integer; virtual; abstract;
|
||||
function CursorInPixel: TPoint; virtual; abstract;
|
||||
function ScreenToPixelPosition(const Position: TPoint): TPoint; virtual; abstract;
|
||||
function ScreenToPixelPosition(const Position: TPoint): TPoint; virtual; abstract;// ScreenXY to pixel in EditorControl.
|
||||
// To get the desktop pixel coords use:
|
||||
// with SourceEditorWindow.ActiveEditor do
|
||||
// DesktopXY:=EditorControl.ClientToScreen(ScreenToPixelPosition(ScreenXY));
|
||||
|
||||
// update
|
||||
procedure BeginUndoBlock; virtual; abstract;
|
||||
|
@ -502,6 +502,7 @@ type
|
||||
procedure EndUpdate;
|
||||
function HandleAllocated: boolean;
|
||||
function IsDefault: boolean;
|
||||
procedure SetDefault;
|
||||
property Handle: HFONT read GetHandle write SetHandle;
|
||||
property PixelsPerInch: Integer read FPixelsPerInch write FPixelsPerInch;
|
||||
property CanUTF8: boolean read GetCanUTF8;
|
||||
|
@ -322,22 +322,22 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
TCustomForm SetVisible
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TCustomForm.SetVisible(Value : boolean);
|
||||
Begin
|
||||
procedure TCustomForm.SetVisible(Value : boolean);
|
||||
begin
|
||||
if (Value=(fsVisible in FFormState)) and (Visible=Value) then exit;
|
||||
//DebugLn('[TCustomForm.SetVisible] START ',Name,':',ClassName,' Old=',Visible,' New=',Value,' ',(fsCreating in FFormState),' ',FormUpdating);
|
||||
//DebugLn(['[TCustomForm.SetVisible] START ',Name,':',ClassName,' Old=',Visible,' New=',Value,' ',(fsCreating in FFormState)]);
|
||||
if Value then
|
||||
Include(FFormState, fsVisible)
|
||||
else
|
||||
Exclude(FFormState, fsVisible);
|
||||
//DebugLn('TCustomForm.SetVisible ',Name,':',ClassName,' FormUpdating=',FormUpdating,' fsCreating=',fsCreating in FFormState);
|
||||
//DebugLn(['TCustomForm.SetVisible ',Name,':',ClassName,' fsCreating=',fsCreating in FFormState]);
|
||||
if (fsCreating in FFormState) {or FormUpdating} then
|
||||
// will be done when finished loading
|
||||
else
|
||||
begin
|
||||
inherited Visible:=Value;
|
||||
end;
|
||||
//DebugLn('[TCustomForm.SetVisible] END ',Name,':',ClassName,' ',Value,' ',(fsCreating in FFormState),' ',FormUpdating,' ',Visible);
|
||||
//DebugLn(['[TCustomForm.SetVisible] END ',Name,':',ClassName,' ',Value,' ',(fsCreating in FFormState),' ',Visible]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -738,6 +738,26 @@ begin
|
||||
and (Style=[]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TFont.SetDefault;
|
||||
|
||||
Set Font properties to default.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TFont.SetDefault;
|
||||
begin
|
||||
BeginUpdate;
|
||||
try
|
||||
Name:=DefFontData.Name;
|
||||
Charset:=DefFontData.CharSet;
|
||||
Height:=DefFontData.Height;
|
||||
Pitch:=DefFontData.Pitch;
|
||||
Style:=DefFontData.Style;
|
||||
Color:=clWindowText;
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TFont.SetSize
|
||||
Params: AValue: the new value
|
||||
|
Loading…
Reference in New Issue
Block a user