📄 syncompletionproposal.pas
字号:
begin
Canvas.Brush.Color := FClTitleBackground;
TmpRect := Rect(0, 0, ClientWidth+1, FHeightBuffer); //GBN
Canvas.FillRect(TmpRect);
Canvas.Pen.Color := clBtnShadow;
dec(TmpRect.Bottom, 1);
Canvas.PenPos := TmpRect.BottomRight;
Canvas.LineTo(TmpRect.Left-1,TmpRect.Bottom);
Canvas.Pen.Color := clBtnFace;
Canvas.Font.Assign(FTitleFont);
if CenterTitle then
begin
TmpX := (Width - Canvas.TextWidth(Title)) div 2;
if TmpX < TitleMargin then
TmpX := TitleMargin; //We still want to be able to read it, even if it does go over the edge
end else
begin
TmpX := TitleMargin;
end;
Canvas.TextRect(TmpRect, TmpX, TitleMargin-1, FTitle); // -1 because TmpRect.Top is already 1
end;
Canvas.Draw(0, 0, TitleBitmap);
end;
end else
if (FDisplayKind = ctHint) or (FDisplayKind = ctParams) then
begin
with Bitmap do
begin
ResetCanvas;
tmpRect := Rect(0, 0, ClientWidth, ClientHeight);
Canvas.FillRect(tmpRect);
Frame3D(Canvas, tmpRect, cl3DLight, cl3DDkShadow, 1);
//GBN 10/11/2001
for i := 0 to FAssignedList.Count - 1 do
begin
AlreadyDrawn := False;
if Assigned(OnPaintItem) then
OnPaintItem(Self, i, Canvas, Rect(0, FEffectiveItemHeight* i +FMargin,
ClientWidth, FEffectiveItemHeight* (i+1)+FMargin), AlreadyDrawn);
if AlreadyDrawn then
ResetCanvas
else
begin
if FDisplayKind = ctParams then
TmpString := FormatParamList(FAssignedList[i], CurrentIndex)
else
TmpString := FAssignedList[i];
FormattedTextOut(Canvas, Rect(FMargin+1,
FEffectiveItemHeight*i+((FEffectiveItemHeight-FFontHeight) div 2)+FMargin,
Bitmap.Width-1, FEffectiveItemHeight*(i+1)+FMargin), TmpString,
False, nil, FImages);
end;
end;
//End GBN 10/11/2001
end;
Canvas.Draw(0, 0, Bitmap);
end;
end;
procedure TSynBaseCompletionProposalForm.ScrollbarOnChange(Sender: TObject);
begin
if Position < FScrollbar.Position then
Position := FScrollbar.Position
else
if Position > FScrollbar.Position + FLinesInWindow - 1 then
Position := FScrollbar.Position + FLinesInWindow - 1
else
Repaint;
end;
procedure TSynBaseCompletionProposalForm.ScrollbarOnScroll(Sender: TObject;
ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
with CurrentEditor as TCustomSynEdit do
begin
SetFocus;
//This tricks the caret into showing itself again.
AlwaysShowCaret := False;
AlwaysShowCaret := True;
// UpdateCaret;
end;
end;
procedure TSynBaseCompletionProposalForm.ScrollbarOnEnter(Sender: TObject);
begin
ActiveControl := nil;
end;
procedure TSynBaseCompletionProposalForm.MoveLine(cnt: Integer);
begin
if (cnt > 0) then begin
if (Position < (FAssignedList.Count - cnt)) then
Position := Position + cnt
else
Position := FAssignedList.Count - 1;
end else begin
if (Position + cnt) > 0 then
Position := Position + cnt
else
Position := 0;
end;
end;
function TSynBaseCompletionProposalForm.LogicalToPhysicalIndex(Index: Integer): Integer;
begin
if FMatchText and (Index >= 0) and (Index < FAssignedList.Count) then
Result := Integer(FAssignedList.Objects[Index])
else
Result := Index;
end;
procedure TSynBaseCompletionProposalForm.SetCurrentString(const Value: string);
function MatchItem(AIndex: Integer; UseItemList: Boolean): Boolean;
var
CompareString: String;
begin
{ if UseInsertList then
CompareString := FInsertList[AIndex]
else
begin
CompareString := FItemList[AIndex];
if UsePrettyText then
CompareString := StripFormatCommands(CompareString);
end;}
if UseInsertList then
CompareString := FInsertList[aIndex]
else
begin
if (FMatchText) and (not UseItemList) then
CompareString := FAssignedList[aIndex]
else
CompareString := FItemList[aIndex]; //GBN 29/08/2002 Fix for when match text is not active
if UsePrettyText then
CompareString := StripFormatCommands(CompareString);
end;
CompareString := Copy(CompareString, 1, Length(Value));
if FAnsi then
begin
if FCase then
Result := AnsiCompareStr(CompareString, Value) = 0
else
Result := AnsiCompareText(CompareString, Value) = 0;
end else
begin
if FCase then
Result := CompareStr(CompareString, Value) = 0
else
Result := CompareText(CompareString, Value) = 0;
end;
end;
procedure RecalcList;
var
i: Integer;
begin
FAssignedList.Clear;
for i := 0 to FItemList.Count -1 do
begin
if MatchItem(i, True) then
FAssignedList.AddObject(FItemList[i], TObject(i));
end;
end;
var
i: Integer;
begin
FCurrentString := Value;
if DisplayType <> ctCode then
exit;
if FMatchText then
begin
RecalcList;
AdjustScrollBarPosition;
Position := 0;
end else
begin
i := 0;
while (i < ItemList.Count) and (not MatchItem(i, True)) do
inc(i);
if i < ItemList.Count then
Position := i
else
Position := 0;
end;
end;
procedure TSynBaseCompletionProposalForm.SetItemList(const Value: TStrings);
begin
FItemList.Assign(Value);
FAssignedList.Assign(Value);
CurrentString := CurrentString;
end;
procedure TSynBaseCompletionProposalForm.SetInsertList(const Value: TStrings);
begin
FInsertList.Assign(Value);
end;
procedure TSynBaseCompletionProposalForm.DoDoubleClick(Sender: TObject);
begin
//we need to do the same as the enter key;
if DisplayType = ctCode then
if Assigned(OnValidate) then OnValidate(Self, [], #0); //GBN 15/11/2001
end;
procedure TSynBaseCompletionProposalForm.SetPosition(const Value: Integer);
begin
if ((Value <= 0) and (FPosition = 0)) or (FPosition = Value) then
exit;
if Value <= FAssignedList.Count - 1 then
begin
FPosition := Value;
if Position < FScrollbar.Position then
FScrollbar.Position := Position else
if FScrollbar.Position < (Position - FLinesInWindow + 1) then
FScrollbar.Position := Position - FLinesInWindow + 1;
if Visible and Assigned(FOnChangePosition) and (DisplayType = ctCode) then
FOnChangePosition(Owner as TSynBaseCompletionProposal,
LogicalToPhysicalIndex(FPosition));
Repaint;
end;
end;
procedure TSynBaseCompletionProposalForm.SetResizeable(const Value: Boolean);
begin
FResizeable := Value;
{$IFDEF SYN_CLX}
{$ELSE}
RecreateWnd;
{$ENDIF}
end;
procedure TSynBaseCompletionProposalForm.SetItemHeight(const Value: Integer);
begin
if Value <> FItemHeight then
begin
FItemHeight := Value;
RecalcItemHeight;
end;
end;
procedure TSynBaseCompletionProposalForm.SetImages(const Value: TImageList);
begin
if FImages <> Value then
begin
{$IFDEF SYN_COMPILER_5_UP}
if Assigned(FImages) then
FImages.RemoveFreeNotification(Self);
{$ENDIF SYN_COMPILER_5_UP}
FImages := Value;
if Assigned(FImages) then
FImages.FreeNotification(Self);
end;
end;
procedure TSynBaseCompletionProposalForm.RecalcItemHeight;
begin
Canvas.Font.Assign(FFont);
FFontHeight := Canvas.TextHeight(TextHeightString);
if FItemHeight > 0 then
FEffectiveItemHeight := FItemHeight
else
begin
FEffectiveItemHeight := FFontHeight;
end;
end;
procedure TSynBaseCompletionProposalForm.StringListChange(Sender: TObject);
begin
FScrollbar.Position := Position;
end;
{$IFDEF SYN_CLX}
{$ELSE}
procedure TSynBaseCompletionProposalForm.WMMouseWheel(var Msg: TMessage);
var
nDelta: integer;
nWheelClicks: integer;
{$IFNDEF SYN_COMPILER_4_UP}
const
LinesToScroll = 3;
WHEEL_DELTA = 120;
WHEEL_PAGESCROLL = MAXDWORD;
{$IFNDEF SYN_COMPILER_3_UP}
SPI_GETWHEELSCROLLLINES = 104;
{$ENDIF}
{$ENDIF}
begin
if csDesigning in ComponentState then exit;
{$IFDEF SYN_COMPILER_4_UP}
if GetKeyState(VK_CONTROL) >= 0 then nDelta := Mouse.WheelScrollLines
{$ELSE}
if GetKeyState(VK_CONTROL) >= 0 then
{$IFDEF SYN_CLX}
nDelta := LinesToScroll
{$ELSE}
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, @nDelta, 0)
{$ENDIF}
{$ENDIF}
else nDelta := FLinesInWindow;
Inc(fMouseWheelAccumulator, SmallInt(Msg.wParamHi));
nWheelClicks := fMouseWheelAccumulator div WHEEL_DELTA;
fMouseWheelAccumulator := fMouseWheelAccumulator mod WHEEL_DELTA;
if (nDelta = integer(WHEEL_PAGESCROLL)) or (nDelta > FLinesInWindow) then
nDelta := FLinesInWindow;
Position := Position - (nDelta * nWheelClicks);
// (CurrentEditor as TCustomSynEdit).UpdateCaret;
end;
{$ENDIF}
function GetMDIParent (const Form: TSynForm): TSynForm;
{ Returns the parent of the specified MDI child form. But, if Form isn't a
MDI child, it simply returns Form. }
var
I, J: Integer;
begin
Result := Form;
if Form = nil then
exit;
if (Form is TSynForm) and
((Form as TForm).FormStyle = fsMDIChild) then
for I := 0 to Screen.FormCount-1 do
with Screen.Forms[I] do
begin
if FormStyle <> fsMDIForm then Continue;
for J := 0 to MDIChildCount-1 do
if MDIChildren[J] = Form then
begin
Result := Screen.Forms[I];
exit;
end;
end;
end;
{$IFDEF SYN_CLX}
{$ELSE}
procedure TSynBaseCompletionProposalForm.WMActivate(var Message: TWMActivate);
var
ParentForm: TSynForm;
begin
if csDesigning in ComponentState then begin
inherited;
Exit;
end;
{Owner of the component that created me}
if Owner.Owner is TSynForm then
ParentForm := GetMDIParent(Owner.Owner as TSynForm)
else
ParentForm := nil;
if Assigned(ParentForm) and ParentForm.HandleAllocated then
SendMessage(ParentForm.Handle, WM_NCACTIVATE, Ord(Message.Active <> WA_INACTIVE), 0);
end;
{$ENDIF}
procedure TSynBaseCompletionProposalForm.DoFormHide(Sender: TObject);
begin
if CurrentEditor <> nil then
begin
(CurrentEditor as TCustomSynEdit).AlwaysShowCaret := OldShowCaret;
// (CurrentEditor as TCustomSynEdit).UpdateCaret;
if DisplayType = ctCode then
begin
(Owner as TSynBaseCompletionProposal).FWidth := Width;
(Owner as TSynBaseCompletionProposal).FNbLinesInWindow := FLinesInWindow;
end;
end;
//GBN 28/08/2002
if Assigned((Owner as TSynBaseCompletionProposal).OnClose) then
TSynBaseCompletionProposal(Owner).OnClose(Self);
end;
procedure TSynBaseCompletionProposalForm.DoFormShow(Sender: TObject);
begin
if Assigned(CurrentEditor) then
begin
with CurrentEditor as TCustomSynEdit do
begin
OldShowCaret := AlwaysShowCaret;
Always
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -