IDE: completion form is now created on demand and the internal double buffer bitmap is resized correct

git-svn-id: trunk@11130 -
This commit is contained in:
mattias 2007-05-12 09:39:20 +00:00
parent 385b95d4f5
commit 8d7812da86
4 changed files with 40 additions and 28 deletions

View File

@ -642,6 +642,8 @@ begin
{$ENDIF} {$ENDIF}
Scroll.LargeChange := NbLinesInWindow; Scroll.LargeChange := NbLinesInWindow;
bitmap.Width:=ClientWidth;
bitmap.Height:=ClientHeight;
with bitmap do begin with bitmap do begin
{$IFNDEF SYN_LAZARUS} {$IFNDEF SYN_LAZARUS}
canvas.pen.color := fbcolor; canvas.pen.color := fbcolor;

View File

@ -599,6 +599,7 @@ type
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure InitMacros(AMacroList: TTransferMacroList); procedure InitMacros(AMacroList: TTransferMacroList);
procedure CreateCompletionForm;
procedure ShowLazDoc; procedure ShowLazDoc;
procedure UpdateLazDoc; procedure UpdateLazDoc;
@ -1450,6 +1451,7 @@ Begin
ecWordCompletion : ecWordCompletion :
if not TCustomSynEdit(Sender).ReadOnly then begin if not TCustomSynEdit(Sender).ReadOnly then begin
SourceNotebook.CreateCompletionForm;
CurrentCompletionType:=ctWordCompletion; CurrentCompletionType:=ctWordCompletion;
TextS := FEditor.LineText; TextS := FEditor.LineText;
LogCaret:=FEditor.LogicalCaretXY; LogCaret:=FEditor.LogicalCaretXY;
@ -2118,7 +2120,8 @@ Begin
end; end;
if FCodeTemplates<>nil then if FCodeTemplates<>nil then
FCodeTemplates.AddEditor(FEditor); FCodeTemplates.AddEditor(FEditor);
aCompletion.AddEditor(FEditor); if aCompletion<>nil then
aCompletion.AddEditor(FEditor);
RefreshEditorSettings; RefreshEditorSettings;
FEditor.EndUpdate; FEditor.EndUpdate;
end else begin end else begin
@ -2246,7 +2249,7 @@ begin
//debugln('TSourceEditor.StartIdentCompletion'); //debugln('TSourceEditor.StartIdentCompletion');
if (FEditor.ReadOnly) or (CurrentCompletionType<>ctNone) then exit; if (FEditor.ReadOnly) or (CurrentCompletionType<>ctNone) then exit;
SourceNotebook.fIdentCompletionJumpToError:=JumpToError; SourceNotebook.fIdentCompletionJumpToError:=JumpToError;
SourceNotebook.CreateCompletionForm;
CurrentCompletionType:=ctIdentCompletion; CurrentCompletionType:=ctIdentCompletion;
TextS := FEditor.LineText; TextS := FEditor.LineText;
LogCaret:=FEditor.LogicalCaretXY; LogCaret:=FEditor.LogicalCaretXY;
@ -2414,7 +2417,8 @@ Begin
FOnBeforeClose(Self); FOnBeforeClose(Self);
Visible := False; Visible := False;
aCompletion.RemoveEditor(FEditor); if aCompletion<>nil then
aCompletion.RemoveEditor(FEditor);
SourceEditorMarks.DeleteAllForEditor(FEditor); SourceEditorMarks.DeleteAllForEditor(FEditor);
FEditor.Parent:=nil; FEditor.Parent:=nil;
CodeBuffer := nil; CodeBuffer := nil;
@ -2903,26 +2907,6 @@ begin
// popup menu // popup menu
BuildPopupMenu; BuildPopupMenu;
// completion form
aCompletion := TSynCompletion.Create(Self);
with aCompletion do
Begin
EndOfTokenChr:='()[].,;:-+=^*<>/';
Width:=400;
OnExecute := @ccExecute;
OnCancel := @ccCancel;
OnCodeCompletion := @ccComplete;
OnPaintItem:=@OnSynCompletionPaintItem;
OnMeasureItem := @OnSynCompletionMeasureItem;
OnSearchPosition:=@OnSynCompletionSearchPosition;
OnKeyCompletePrefix:=@OnSynCompletionCompletePrefix;
OnKeyNextChar:=@OnSynCompletionNextChar;
OnKeyPrevChar:=@OnSynCompletionPrevChar;
OnKeyPress:=@OnSynCompletionKeyPress;
OnUTF8KeyPress:=@OnSynCompletionUTF8KeyPress;
ShortCut:=Menus.ShortCut(VK_UNKNOWN,[]);
end;
// HintTimer // HintTimer
FHintTimer := TTimer.Create(Self); FHintTimer := TTimer.Create(Self);
with FHintTimer do begin with FHintTimer do begin
@ -2985,6 +2969,34 @@ begin
lisPromptForValue,@MacroFuncPrompt,[tmfInteractive])); lisPromptForValue,@MacroFuncPrompt,[tmfInteractive]));
end; end;
procedure TSourceNotebook.CreateCompletionForm;
var
i: Integer;
begin
// completion form
aCompletion := TSynCompletion.Create(Self);
with aCompletion do
Begin
EndOfTokenChr:='()[].,;:-+=^*<>/';
Width:=400;
OnExecute := @ccExecute;
OnCancel := @ccCancel;
OnCodeCompletion := @ccComplete;
OnPaintItem:=@OnSynCompletionPaintItem;
OnMeasureItem := @OnSynCompletionMeasureItem;
OnSearchPosition:=@OnSynCompletionSearchPosition;
OnKeyCompletePrefix:=@OnSynCompletionCompletePrefix;
OnKeyNextChar:=@OnSynCompletionNextChar;
OnKeyPrevChar:=@OnSynCompletionPrevChar;
OnKeyPress:=@OnSynCompletionKeyPress;
OnUTF8KeyPress:=@OnSynCompletionUTF8KeyPress;
ShortCut:=Menus.ShortCut(VK_UNKNOWN,[]);
end;
for i:=0 to EditorCount-1 do
aCompletion.AddEditor(Editors[i].FEditor);
end;
procedure TSourceNotebook.ShowLazDoc; procedure TSourceNotebook.ShowLazDoc;
begin begin
DoShowLazDoc; DoShowLazDoc;
@ -3096,6 +3108,7 @@ var P:TPoint;
begin begin
//writeln('TSourceNotebook.OnCodeTemplateTokenNotFound ',AToken,',',AnEditor.ReadOnly,',',CurrentCompletionType=ctNone); //writeln('TSourceNotebook.OnCodeTemplateTokenNotFound ',AToken,',',AnEditor.ReadOnly,',',CurrentCompletionType=ctNone);
if (AnEditor.ReadOnly=false) and (CurrentCompletionType=ctNone) then begin if (AnEditor.ReadOnly=false) and (CurrentCompletionType=ctNone) then begin
SourceNotebook.CreateCompletionForm;
CurrentCompletionType:=ctTemplateCompletion; CurrentCompletionType:=ctTemplateCompletion;
with AnEditor do begin with AnEditor do begin
P := Point(CaretXPix - length(AToken)*CharWidth,CaretYPix + LineHeight); P := Point(CaretXPix - length(AToken)*CharWidth,CaretYPix + LineHeight);

View File

@ -151,10 +151,7 @@ end;
function TBitmap.GetCanvas: TCanvas; function TBitmap.GetCanvas: TCanvas;
begin begin
if FCanvas = nil then if FCanvas = nil then
begin
HandleNeeded;
CreateCanvas; CreateCanvas;
end;
Result := FCanvas; Result := FCanvas;
end; end;

View File

@ -7974,8 +7974,8 @@ begin
Drawable := nil; Drawable := nil;
end; end;
if Drawable<>nil then begin if Drawable<>nil then begin
//DebugLn('TGtkWidgetSet.SelectObject DC=',DbgS(DC),8),' GDIBitmap=',DbgS(Cardinal(CurrentBitmap), //DebugLn(['TGtkWidgetSet.SelectObject DC=',DbgS(Pointer(DC)),' GDIBitmap=',DbgS(CurrentBitmap),
//' GDIBitmapType=',ord(CurrentBitmap^.GDIBitmapType),' Drawable=',DbgS(Drawable)); //' GDIBitmapType=',ord(CurrentBitmap^.GDIBitmapType),' Drawable=',DbgS(Drawable)]);
if GC <> nil then begin if GC <> nil then begin
gdk_gc_unref(GC); gdk_gc_unref(GC);
GC:=nil; GC:=nil;