mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 18:38:26 +02:00
implemented a dialog to find components in the palette
git-svn-id: trunk@9434 -
This commit is contained in:
parent
5b814f9fcb
commit
63dd31ff22
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1164,6 +1164,9 @@ ide/filereferencelist.pas svneol=native#text/pascal
|
||||
ide/findinfilesdlg.lfm svneol=native#text/plain
|
||||
ide/findinfilesdlg.lrs svneol=native#text/plain
|
||||
ide/findinfilesdlg.pas svneol=native#text/pascal
|
||||
ide/findpalettecomp.lfm svneol=native#text/plain
|
||||
ide/findpalettecomp.lrs svneol=native#text/plain
|
||||
ide/findpalettecomp.pas svneol=native#text/plain
|
||||
ide/findrenameidentifier.lfm svneol=native#text/plain
|
||||
ide/findrenameidentifier.lrs svneol=native#text/pascal
|
||||
ide/findrenameidentifier.pas svneol=native#text/pascal
|
||||
|
@ -2003,11 +2003,11 @@ procedure TDesigner.ValidateRename(AComponent: TComponent;
|
||||
lisDesThereIsAlreadyAnotherComponentWithTheName, ['"',
|
||||
ConflictComponent.Name, '"']));
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
CurComponent: TComponent;
|
||||
{$ENDIF}
|
||||
begin
|
||||
// check if component is initialized
|
||||
if (CurName='') or (NewName='')
|
||||
|
@ -7,24 +7,32 @@ object MainForm: TMainForm
|
||||
VertScrollBar.Page = 299
|
||||
ActiveControl = CreateNewFormButton
|
||||
Caption = 'MainForm'
|
||||
ClientHeight = 300
|
||||
ClientWidth = 400
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnPaint = FormPaint
|
||||
PixelsPerInch = 95
|
||||
PopupMenu = MainPopupMenu
|
||||
object CreateNewFormButton: TButton
|
||||
Left = 56
|
||||
Left = 30
|
||||
Height = 26
|
||||
Top = 34
|
||||
Width = 135
|
||||
Top = 15
|
||||
Width = 116
|
||||
AutoSize = True
|
||||
|
||||
Caption = 'CreateNewFormButton'
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Create a new form'
|
||||
OnClick = CreateNewFormButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object SaveLayoutButton: TButton
|
||||
Left = 30
|
||||
Height = 26
|
||||
Top = 60
|
||||
Width = 158
|
||||
AutoSize = True
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Save Layout to config.xml'
|
||||
OnClick = SaveLayoutButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object MainPopupMenu: TPopupMenu
|
||||
left = 142
|
||||
top = 141
|
||||
|
@ -1,12 +1,16 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TMainForm','FORMDATA',[
|
||||
'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3'$'#1#6'Height'#3','#1#3'Top'#3#209#0
|
||||
+#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'#3'+'
|
||||
+#1#13'ActiveControl'#7#19'CreateNewFormButton'#7'Caption'#6#8'MainForm'#12'C'
|
||||
+'lientHeight'#3','#1#11'ClientWidth'#3#144#1#8'OnCreate'#7#10'FormCreate'#9
|
||||
+'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'FormPaint'#13'PixelsPerInch'#2
|
||||
+'_'#9'PopupMenu'#7#13'MainPopupMenu'#0#7'TButton'#19'CreateNewFormButton'#4
|
||||
+'Left'#2'8'#6'Height'#2#26#3'Top'#2'"'#5'Width'#3#135#0#8'AutoSize'#9#7'Capt'
|
||||
+'ion'#6#19'CreateNewFormButton'#7'OnClick'#7#24'CreateNewFormButtonClick'#8
|
||||
+'TabOrder'#2#0#0#0#10'TPopupMenu'#13'MainPopupMenu'#4'left'#3#142#0#3'top'#3
|
||||
+#141#0#0#0#0
|
||||
+#1#13'ActiveControl'#7#19'CreateNewFormButton'#7'Caption'#6#8'MainForm'#8'On'
|
||||
+'Create'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'Form'
|
||||
+'Paint'#9'PopupMenu'#7#13'MainPopupMenu'#0#7'TButton'#19'CreateNewFormButton'
|
||||
+#4'Left'#2#30#6'Height'#2#26#3'Top'#2#15#5'Width'#2't'#8'AutoSize'#9#25'Bord'
|
||||
+'erSpacing.InnerBorder'#2#4#7'Caption'#6#17'Create a new form'#7'OnClick'#7
|
||||
+#24'CreateNewFormButtonClick'#8'TabOrder'#2#0#0#0#7'TButton'#16'SaveLayoutBu'
|
||||
+'tton'#4'Left'#2#30#6'Height'#2#26#3'Top'#2'<'#5'Width'#3#158#0#8'AutoSize'#9
|
||||
+#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#25'Save Layout to config.xml'
|
||||
+#7'OnClick'#7#21'SaveLayoutButtonClick'#8'TabOrder'#2#1#0#0#10'TPopupMenu'#13
|
||||
+'MainPopupMenu'#4'left'#3#142#0#3'top'#3#141#0#0#0#0
|
||||
]);
|
||||
|
@ -6,19 +6,21 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
DockForm2Unit, Buttons, Menus, LDockCtrl;
|
||||
XMLCfg, DockForm2Unit, Buttons, Menus, LDockCtrl;
|
||||
|
||||
type
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
TMainForm = class(TForm)
|
||||
SaveLayoutButton: TButton;
|
||||
CreateNewFormButton: TButton;
|
||||
MainPopupMenu: TPopupMenu;
|
||||
procedure CreateNewFormButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
procedure SaveLayoutButtonClick(Sender: TObject);
|
||||
private
|
||||
function CreateNewForm: TCustomForm;
|
||||
public
|
||||
@ -39,6 +41,11 @@ begin
|
||||
PaintBoundaries(Self,clBlue);
|
||||
end;
|
||||
|
||||
procedure TMainForm.SaveLayoutButtonClick(Sender: TObject);
|
||||
begin
|
||||
DockingManager.SaveToStream();
|
||||
end;
|
||||
|
||||
function TMainForm.CreateNewForm: TCustomForm;
|
||||
var
|
||||
DockForm: TDockFormX;
|
||||
|
@ -49,9 +49,6 @@
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<SearchPaths>
|
||||
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)/"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
|
@ -29,7 +29,7 @@
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
|
||||
The implementation of the component palette.
|
||||
}
|
||||
unit ComponentPalette;
|
||||
|
||||
@ -44,7 +44,8 @@ uses
|
||||
{$IFDEF CustomIDEComps}
|
||||
CustomIDEComps,
|
||||
{$ENDIF}
|
||||
LazarusIDEStrConsts, ComponentReg, DesignerProcs, IDEProcs, PackageDefs;
|
||||
LazarusIDEStrConsts, ComponentReg, DesignerProcs, IDEProcs, PackageDefs,
|
||||
FindPaletteComp;
|
||||
|
||||
type
|
||||
{ TComponentPalette }
|
||||
@ -53,9 +54,11 @@ type
|
||||
PopupMenu: TPopupMenu;
|
||||
OpenPackageMenuItem: TMenuItem;
|
||||
OpenUnitMenuItem: TMenuItem;
|
||||
FindComponentMenuItem: TMenuItem;
|
||||
procedure ActivePageChanged(Sender: TObject);
|
||||
procedure OpenPackageClicked(Sender: TObject);
|
||||
procedure OpenUnitClicked(Sender: TObject);
|
||||
procedure FindComponentClicked(Sender: TObject);
|
||||
procedure PopupMenuPopup(Sender: TObject);
|
||||
private
|
||||
fComponents: TAVLTree; // tree of TRegisteredComponent sorted for componentclass
|
||||
@ -111,8 +114,8 @@ var
|
||||
begin
|
||||
RegComp1:=TRegisteredComponent(Data1);
|
||||
RegComp2:=TRegisteredComponent(Data2);
|
||||
Result:=AnsiCompareText(RegComp1.ComponentClass.ClassName,
|
||||
RegComp2.ComponentClass.ClassName);
|
||||
Result:=CompareText(RegComp1.ComponentClass.ClassName,
|
||||
RegComp2.ComponentClass.ClassName);
|
||||
end;
|
||||
|
||||
function CompareClassNameWithRegisteredComponent(Key, Data: Pointer): integer;
|
||||
@ -122,7 +125,7 @@ var
|
||||
begin
|
||||
AClassName:=String(Key);
|
||||
RegComp:=TRegisteredComponent(Data);
|
||||
Result:=AnsiCompareText(AClassName,RegComp.ComponentClass.ClassName);
|
||||
Result:=CompareText(AClassName,RegComp.ComponentClass.ClassName);
|
||||
end;
|
||||
|
||||
{ TComponentPalette }
|
||||
@ -158,6 +161,14 @@ begin
|
||||
OnOpenUnit(PkgComponent);
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.FindComponentClicked(Sender: TObject);
|
||||
var
|
||||
AComponent: TRegisteredComponent;
|
||||
begin
|
||||
if ShowFindPaletteComponentDlg(AComponent)<>mrOk then exit;
|
||||
Selected:=AComponent;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.PopupMenuPopup(Sender: TObject);
|
||||
var
|
||||
PkgComponent: TPkgComponent;
|
||||
@ -288,6 +299,14 @@ begin
|
||||
OnClick:=@OpenUnitClicked;
|
||||
end;
|
||||
PopupMenu.Items.Add(OpenUnitMenuItem);
|
||||
|
||||
FindComponentMenuItem:=TMenuItem.Create(PopupMenu);
|
||||
with FindComponentMenuItem do begin
|
||||
Name:='FindComponentMenuItem';
|
||||
Caption:=lisCompPalFindComponent;
|
||||
OnClick:=@FindComponentClicked;
|
||||
end;
|
||||
PopupMenu.Items.Add(FindComponentMenuItem);
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.DoEndUpdate(Changed: boolean);
|
||||
|
77
ide/findpalettecomp.lfm
Normal file
77
ide/findpalettecomp.lfm
Normal file
@ -0,0 +1,77 @@
|
||||
object FindPaletteComponentDlg: TFindPaletteComponentDlg
|
||||
Left = 290
|
||||
Height = 300
|
||||
Top = 163
|
||||
Width = 400
|
||||
HorzScrollBar.Page = 399
|
||||
VertScrollBar.Page = 299
|
||||
ActiveControl = PatternEdit
|
||||
Caption = 'FindPaletteComponentDlg'
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
object SearchPatternGroupBox: TGroupBox
|
||||
Left = 10
|
||||
Height = 55
|
||||
Top = 5
|
||||
Width = 380
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
Caption = 'SearchPatternGroupBox'
|
||||
TabOrder = 0
|
||||
object PatternEdit: TEdit
|
||||
Left = 8
|
||||
Height = 23
|
||||
Top = 4
|
||||
Width = 357
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
OnChange = PatternEditChange
|
||||
TabOrder = 0
|
||||
Text = 'PatternEdit'
|
||||
end
|
||||
end
|
||||
object SelectButton: TButton
|
||||
AnchorSideRight.Control = CancelButton
|
||||
Left = 196
|
||||
Height = 26
|
||||
Top = 260
|
||||
Width = 84
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 15
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'SelectButton'
|
||||
ModalResult = 1
|
||||
TabOrder = 1
|
||||
end
|
||||
object CancelButton: TButton
|
||||
Left = 295
|
||||
Height = 26
|
||||
Top = 260
|
||||
Width = 89
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Cancel = True
|
||||
Caption = 'CancelButton'
|
||||
ModalResult = 2
|
||||
TabOrder = 2
|
||||
end
|
||||
object ComponentsGroupBox: TGroupBox
|
||||
Left = 10
|
||||
Height = 180
|
||||
Top = 65
|
||||
Width = 380
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Caption = 'ComponentsGroupBox'
|
||||
TabOrder = 3
|
||||
object ComponentsListBox: TListBox
|
||||
Height = 163
|
||||
Width = 376
|
||||
Align = alClient
|
||||
OnDblClick = ComponentsListBoxDblClick
|
||||
OnDrawItem = ComponentsListBoxDrawItem
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 0
|
||||
TopIndex = -1
|
||||
end
|
||||
end
|
||||
end
|
28
ide/findpalettecomp.lrs
Normal file
28
ide/findpalettecomp.lrs
Normal file
@ -0,0 +1,28 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TFindPaletteComponentDlg','FORMDATA',[
|
||||
'TPF0'#24'TFindPaletteComponentDlg'#23'FindPaletteComponentDlg'#4'Left'#3'"'#1
|
||||
+#6'Height'#3','#1#3'Top'#3#163#0#5'Width'#3#144#1#18'HorzScrollBar.Page'#3
|
||||
+#143#1#18'VertScrollBar.Page'#3'+'#1#13'ActiveControl'#7#11'PatternEdit'#7'C'
|
||||
+'aption'#6#23'FindPaletteComponentDlg'#8'OnCreate'#7#10'FormCreate'#9'OnDest'
|
||||
+'roy'#7#11'FormDestroy'#0#9'TGroupBox'#21'SearchPatternGroupBox'#4'Left'#2#10
|
||||
+#6'Height'#2'7'#3'Top'#2#5#5'Width'#3'|'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7
|
||||
+'akRight'#0#7'Caption'#6#21'SearchPatternGroupBox'#8'TabOrder'#2#0#0#5'TEdit'
|
||||
+#11'PatternEdit'#4'Left'#2#8#6'Height'#2#23#3'Top'#2#4#5'Width'#3'e'#1#7'Anc'
|
||||
+'hors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'OnChange'#7#17'PatternEditChange'
|
||||
+#8'TabOrder'#2#0#4'Text'#6#11'PatternEdit'#0#0#0#7'TButton'#12'SelectButton'
|
||||
+#23'AnchorSideRight.Control'#7#12'CancelButton'#4'Left'#3#196#0#6'Height'#2
|
||||
+#26#3'Top'#3#4#1#5'Width'#2'T'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'Auto'
|
||||
+'Size'#9#19'BorderSpacing.Right'#2#15#25'BorderSpacing.InnerBorder'#2#4#7'Ca'
|
||||
+'ption'#6#12'SelectButton'#11'ModalResult'#2#1#8'TabOrder'#2#1#0#0#7'TButton'
|
||||
+#12'CancelButton'#4'Left'#3''''#1#6'Height'#2#26#3'Top'#3#4#1#5'Width'#2'Y'#7
|
||||
+'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#25'BorderSpacing.InnerBo'
|
||||
+'rder'#2#4#6'Cancel'#9#7'Caption'#6#12'CancelButton'#11'ModalResult'#2#2#8'T'
|
||||
+'abOrder'#2#2#0#0#9'TGroupBox'#18'ComponentsGroupBox'#4'Left'#2#10#6'Height'
|
||||
+#3#180#0#3'Top'#2'A'#5'Width'#3'|'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRi'
|
||||
+'ght'#8'akBottom'#0#7'Caption'#6#18'ComponentsGroupBox'#8'TabOrder'#2#3#0#8
|
||||
+'TListBox'#17'ComponentsListBox'#6'Height'#3#163#0#5'Width'#3'x'#1#5'Align'#7
|
||||
+#8'alClient'#10'OnDblClick'#7#25'ComponentsListBoxDblClick'#10'OnDrawItem'#7
|
||||
+#25'ComponentsListBoxDrawItem'#5'Style'#7#16'lbOwnerDrawFixed'#8'TabOrder'#2
|
||||
+#0#8'TopIndex'#2#255#0#0#0#0
|
||||
]);
|
203
ide/findpalettecomp.pas
Normal file
203
ide/findpalettecomp.pas
Normal file
@ -0,0 +1,203 @@
|
||||
{ $Id: componentpalette.pas 9311 2006-05-19 21:56:07Z mattias $ }
|
||||
{
|
||||
/***************************************************************************
|
||||
componentpalette.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:
|
||||
A dialog to search a component.
|
||||
}
|
||||
unit FindPaletteComp;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Buttons, FormEditingIntf,
|
||||
LazarusIDEStrConsts, ComponentReg, PackageDefs;
|
||||
|
||||
type
|
||||
|
||||
{ TFindPaletteComponentDlg }
|
||||
|
||||
TFindPaletteComponentDlg = class(TForm)
|
||||
ComponentsGroupBox: TGroupBox;
|
||||
ComponentsListBox: TListBox;
|
||||
SelectButton: TButton;
|
||||
CancelButton: TButton;
|
||||
PatternEdit: TEdit;
|
||||
SearchPatternGroupBox: TGroupBox;
|
||||
procedure ComponentsListBoxDblClick(Sender: TObject);
|
||||
procedure ComponentsListBoxDrawItem(Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; State: TOwnerDrawState);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure PatternEditChange(Sender: TObject);
|
||||
private
|
||||
fSelectedComponents: TFPList;// list of TRegisteredComponent
|
||||
procedure UpdateComponentSelection;
|
||||
public
|
||||
function GetSelectedComponent: TRegisteredComponent;
|
||||
end;
|
||||
|
||||
function ShowFindPaletteComponentDlg(
|
||||
out AComponent: TRegisteredComponent): TModalResult;
|
||||
|
||||
implementation
|
||||
|
||||
function ShowFindPaletteComponentDlg(out AComponent: TRegisteredComponent
|
||||
): TModalResult;
|
||||
var
|
||||
FindPaletteComponentDlg: TFindPaletteComponentDlg;
|
||||
begin
|
||||
FindPaletteComponentDlg:=TFindPaletteComponentDlg.Create(nil);
|
||||
Result:=FindPaletteComponentDlg.ShowModal;
|
||||
AComponent:=FindPaletteComponentDlg.GetSelectedComponent;
|
||||
if AComponent=nil then Result:=mrCancel;
|
||||
FindPaletteComponentDlg.Free;
|
||||
end;
|
||||
|
||||
{ TFindPaletteComponentDlg }
|
||||
|
||||
procedure TFindPaletteComponentDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
ComponentsGroupBox.Caption:='Components';
|
||||
SelectButton.Caption:='Select';
|
||||
CancelButton.Caption:='Cancel';
|
||||
PatternEdit.Text:='';
|
||||
SearchPatternGroupBox.Caption:='Find';
|
||||
ComponentsListBox.ItemHeight:=ComponentPaletteBtnWidth;
|
||||
|
||||
UpdateComponentSelection;
|
||||
end;
|
||||
|
||||
procedure TFindPaletteComponentDlg.ComponentsListBoxDrawItem(
|
||||
Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
||||
var
|
||||
CurComponent: TRegisteredComponent;
|
||||
CurStr: string;
|
||||
TxtH: Integer;
|
||||
CurIcon: TBitmap;
|
||||
IconWidth: Integer;
|
||||
IconHeight: Integer;
|
||||
CurRect: TRect;
|
||||
begin
|
||||
if fSelectedComponents=nil then exit;
|
||||
if (Index<0) or (Index>=fSelectedComponents.Count) then exit;
|
||||
// draw registered component
|
||||
CurComponent:=TRegisteredComponent(fSelectedComponents[Index]);
|
||||
with ComponentsListBox.Canvas do begin
|
||||
CurStr:=Format(lisPckEditPage, [CurComponent.ComponentClass.ClassName,
|
||||
CurComponent.Page.PageName]);
|
||||
TxtH:=TextHeight(CurStr);
|
||||
CurRect:=ARect;
|
||||
inc(CurRect.Left,25);
|
||||
FillRect(CurRect);
|
||||
Brush.Color:=clLtGray;
|
||||
CurRect:=ARect;
|
||||
CurRect.Right:=ARect.Left+25;
|
||||
FillRect(CurRect);
|
||||
CurIcon:=nil;
|
||||
if CurComponent is TPkgComponent then
|
||||
CurIcon:=TPkgComponent(CurComponent).Icon;
|
||||
if CurIcon<>nil then begin
|
||||
IconWidth:=CurIcon.Width;
|
||||
IconHeight:=CurIcon.Height;
|
||||
Draw(ARect.Left+(25-IconWidth) div 2,
|
||||
ARect.Top+(ARect.Bottom-ARect.Top-IconHeight) div 2,
|
||||
CurIcon);
|
||||
end;
|
||||
TextOut(ARect.Left+25,
|
||||
ARect.Top+(ARect.Bottom-ARect.Top-TxtH) div 2,
|
||||
CurStr);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFindPaletteComponentDlg.ComponentsListBoxDblClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TFindPaletteComponentDlg.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
fSelectedComponents.Free;
|
||||
end;
|
||||
|
||||
procedure TFindPaletteComponentDlg.PatternEditChange(Sender: TObject);
|
||||
begin
|
||||
UpdateComponentSelection;
|
||||
end;
|
||||
|
||||
procedure TFindPaletteComponentDlg.UpdateComponentSelection;
|
||||
var
|
||||
p: Integer;
|
||||
Page: TBaseComponentPage;
|
||||
c: Integer;
|
||||
AComponent: TRegisteredComponent;
|
||||
begin
|
||||
if fSelectedComponents=nil then
|
||||
fSelectedComponents:=TFPList.Create;
|
||||
fSelectedComponents.Clear;
|
||||
if IDEComponentPalette=nil then exit;
|
||||
for p:=0 to IDEComponentPalette.Count-1 do begin
|
||||
Page:=IDEComponentPalette.Pages[p];
|
||||
if not Page.Visible then continue;
|
||||
for c:=0 to Page.Count-1 do begin
|
||||
AComponent:=Page.Items[c];
|
||||
if not AComponent.Visible then continue;
|
||||
if (PatternEdit.Text='')
|
||||
or (System.Pos(UpperCase(PatternEdit.Text),
|
||||
UpperCase(AComponent.ComponentClass.ClassName))>0)
|
||||
then
|
||||
fSelectedComponents.Add(AComponent);
|
||||
end;
|
||||
end;
|
||||
while ComponentsListBox.Items.Count<fSelectedComponents.Count do
|
||||
ComponentsListBox.Items.Add('');
|
||||
while ComponentsListBox.Items.Count>fSelectedComponents.Count do
|
||||
ComponentsListBox.Items.Delete(ComponentsListBox.Items.Count-1);
|
||||
ComponentsListBox.Invalidate;
|
||||
end;
|
||||
|
||||
function TFindPaletteComponentDlg.GetSelectedComponent: TRegisteredComponent;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if (fSelectedComponents=nil) or (fSelectedComponents.Count=0) then exit(nil);
|
||||
i:=ComponentsListBox.ItemIndex;
|
||||
if (i>=fSelectedComponents.Count) or (i<0) then
|
||||
i:=0;
|
||||
Result:=TRegisteredComponent(fSelectedComponents[i]);
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I findpalettecomp.lrs}
|
||||
|
||||
end.
|
||||
|
@ -2084,6 +2084,7 @@ resourcestring
|
||||
// component palette
|
||||
lisCompPalOpenPackage = 'Open package';
|
||||
lisCompPalOpenUnit = 'Open unit';
|
||||
lisCompPalFindComponent = 'Find component';
|
||||
|
||||
// macro promp dialog
|
||||
lisMacroPromptEnterData = 'Enter data';
|
||||
|
@ -37,7 +37,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, TypInfo, LCLProc, Controls, Forms, Menus, LCLStrConsts,
|
||||
StringHashList, LDockCtrlEdit, LDockTree;
|
||||
StringHashList, LazConfigStorage, LDockCtrlEdit, LDockTree;
|
||||
|
||||
type
|
||||
TNonDockConfigNames = (
|
||||
|
@ -40,7 +40,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, LResources,
|
||||
Graphics, LCLType, LCLProc, Menus, Dialogs, FileUtil,
|
||||
AVL_Tree, Laz_XMLCfg, LazIDEIntf, ProjectIntf,
|
||||
AVL_Tree, Laz_XMLCfg, LazIDEIntf, ProjectIntf, FormEditingIntf,
|
||||
IDEProcs, LazConf, LazarusIDEStrConsts, IDEOptionDefs, IDEDefs,
|
||||
CompilerOptions, CompilerOptionsDlg, ComponentReg, PackageDefs, PkgOptionsDlg,
|
||||
AddToPackageDlg, PkgVirtualUnitEditor, PackageSystem;
|
||||
@ -1448,7 +1448,7 @@ begin
|
||||
with RegisteredListBox do begin
|
||||
Name:='RegisteredListBox';
|
||||
Align:=alClient;
|
||||
ItemHeight:=23;
|
||||
ItemHeight:=ComponentPaletteBtnWidth-2;
|
||||
OnDrawItem:=@RegisteredListBoxDrawItem;
|
||||
Style:= lbOwnerDrawFixed;
|
||||
Parent:=RegisteredPluginsGroupBox;
|
||||
|
Loading…
Reference in New Issue
Block a user