mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 05:36:10 +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.lfm svneol=native#text/plain
|
||||||
ide/findinfilesdlg.lrs svneol=native#text/plain
|
ide/findinfilesdlg.lrs svneol=native#text/plain
|
||||||
ide/findinfilesdlg.pas svneol=native#text/pascal
|
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.lfm svneol=native#text/plain
|
||||||
ide/findrenameidentifier.lrs svneol=native#text/pascal
|
ide/findrenameidentifier.lrs svneol=native#text/pascal
|
||||||
ide/findrenameidentifier.pas svneol=native#text/pascal
|
ide/findrenameidentifier.pas svneol=native#text/pascal
|
||||||
|
@ -2003,11 +2003,11 @@ procedure TDesigner.ValidateRename(AComponent: TComponent;
|
|||||||
lisDesThereIsAlreadyAnotherComponentWithTheName, ['"',
|
lisDesThereIsAlreadyAnotherComponentWithTheName, ['"',
|
||||||
ConflictComponent.Name, '"']));
|
ConflictComponent.Name, '"']));
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
CurComponent: TComponent;
|
CurComponent: TComponent;
|
||||||
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
// check if component is initialized
|
// check if component is initialized
|
||||||
if (CurName='') or (NewName='')
|
if (CurName='') or (NewName='')
|
||||||
|
@ -7,24 +7,32 @@ object MainForm: TMainForm
|
|||||||
VertScrollBar.Page = 299
|
VertScrollBar.Page = 299
|
||||||
ActiveControl = CreateNewFormButton
|
ActiveControl = CreateNewFormButton
|
||||||
Caption = 'MainForm'
|
Caption = 'MainForm'
|
||||||
ClientHeight = 300
|
|
||||||
ClientWidth = 400
|
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
OnPaint = FormPaint
|
OnPaint = FormPaint
|
||||||
PixelsPerInch = 95
|
|
||||||
PopupMenu = MainPopupMenu
|
PopupMenu = MainPopupMenu
|
||||||
object CreateNewFormButton: TButton
|
object CreateNewFormButton: TButton
|
||||||
Left = 56
|
Left = 30
|
||||||
Height = 26
|
Height = 26
|
||||||
Top = 34
|
Top = 15
|
||||||
Width = 135
|
Width = 116
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
|
BorderSpacing.InnerBorder = 4
|
||||||
Caption = 'CreateNewFormButton'
|
Caption = 'Create a new form'
|
||||||
OnClick = CreateNewFormButtonClick
|
OnClick = CreateNewFormButtonClick
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
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
|
object MainPopupMenu: TPopupMenu
|
||||||
left = 142
|
left = 142
|
||||||
top = 141
|
top = 141
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
|
{ This is an automatically generated lazarus resource file }
|
||||||
|
|
||||||
LazarusResources.Add('TMainForm','FORMDATA',[
|
LazarusResources.Add('TMainForm','FORMDATA',[
|
||||||
'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3'$'#1#6'Height'#3','#1#3'Top'#3#209#0
|
'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'+'
|
+#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'
|
+#1#13'ActiveControl'#7#19'CreateNewFormButton'#7'Caption'#6#8'MainForm'#8'On'
|
||||||
+'lientHeight'#3','#1#11'ClientWidth'#3#144#1#8'OnCreate'#7#10'FormCreate'#9
|
+'Create'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'Form'
|
||||||
+'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'FormPaint'#13'PixelsPerInch'#2
|
+'Paint'#9'PopupMenu'#7#13'MainPopupMenu'#0#7'TButton'#19'CreateNewFormButton'
|
||||||
+'_'#9'PopupMenu'#7#13'MainPopupMenu'#0#7'TButton'#19'CreateNewFormButton'#4
|
+#4'Left'#2#30#6'Height'#2#26#3'Top'#2#15#5'Width'#2't'#8'AutoSize'#9#25'Bord'
|
||||||
+'Left'#2'8'#6'Height'#2#26#3'Top'#2'"'#5'Width'#3#135#0#8'AutoSize'#9#7'Capt'
|
+'erSpacing.InnerBorder'#2#4#7'Caption'#6#17'Create a new form'#7'OnClick'#7
|
||||||
+'ion'#6#19'CreateNewFormButton'#7'OnClick'#7#24'CreateNewFormButtonClick'#8
|
+#24'CreateNewFormButtonClick'#8'TabOrder'#2#0#0#0#7'TButton'#16'SaveLayoutBu'
|
||||||
+'TabOrder'#2#0#0#0#10'TPopupMenu'#13'MainPopupMenu'#4'left'#3#142#0#3'top'#3
|
+'tton'#4'Left'#2#30#6'Height'#2#26#3'Top'#2'<'#5'Width'#3#158#0#8'AutoSize'#9
|
||||||
+#141#0#0#0#0
|
+#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
|
uses
|
||||||
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
DockForm2Unit, Buttons, Menus, LDockCtrl;
|
XMLCfg, DockForm2Unit, Buttons, Menus, LDockCtrl;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TMainForm }
|
{ TMainForm }
|
||||||
|
|
||||||
TMainForm = class(TForm)
|
TMainForm = class(TForm)
|
||||||
|
SaveLayoutButton: TButton;
|
||||||
CreateNewFormButton: TButton;
|
CreateNewFormButton: TButton;
|
||||||
MainPopupMenu: TPopupMenu;
|
MainPopupMenu: TPopupMenu;
|
||||||
procedure CreateNewFormButtonClick(Sender: TObject);
|
procedure CreateNewFormButtonClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure FormPaint(Sender: TObject);
|
procedure FormPaint(Sender: TObject);
|
||||||
|
procedure SaveLayoutButtonClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
function CreateNewForm: TCustomForm;
|
function CreateNewForm: TCustomForm;
|
||||||
public
|
public
|
||||||
@ -39,6 +41,11 @@ begin
|
|||||||
PaintBoundaries(Self,clBlue);
|
PaintBoundaries(Self,clBlue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.SaveLayoutButtonClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DockingManager.SaveToStream();
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainForm.CreateNewForm: TCustomForm;
|
function TMainForm.CreateNewForm: TCustomForm;
|
||||||
var
|
var
|
||||||
DockForm: TDockFormX;
|
DockForm: TDockFormX;
|
||||||
|
@ -49,9 +49,6 @@
|
|||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="5"/>
|
<Version Value="5"/>
|
||||||
<SearchPaths>
|
|
||||||
<SrcPath Value="$(LazarusDir)/lcl/;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)/"/>
|
|
||||||
</SearchPaths>
|
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
<Generate Value="Faster"/>
|
<Generate Value="Faster"/>
|
||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
Author: Mattias Gaertner
|
Author: Mattias Gaertner
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
The implementation of the component palette.
|
||||||
}
|
}
|
||||||
unit ComponentPalette;
|
unit ComponentPalette;
|
||||||
|
|
||||||
@ -44,7 +44,8 @@ uses
|
|||||||
{$IFDEF CustomIDEComps}
|
{$IFDEF CustomIDEComps}
|
||||||
CustomIDEComps,
|
CustomIDEComps,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
LazarusIDEStrConsts, ComponentReg, DesignerProcs, IDEProcs, PackageDefs;
|
LazarusIDEStrConsts, ComponentReg, DesignerProcs, IDEProcs, PackageDefs,
|
||||||
|
FindPaletteComp;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TComponentPalette }
|
{ TComponentPalette }
|
||||||
@ -53,9 +54,11 @@ type
|
|||||||
PopupMenu: TPopupMenu;
|
PopupMenu: TPopupMenu;
|
||||||
OpenPackageMenuItem: TMenuItem;
|
OpenPackageMenuItem: TMenuItem;
|
||||||
OpenUnitMenuItem: TMenuItem;
|
OpenUnitMenuItem: TMenuItem;
|
||||||
|
FindComponentMenuItem: TMenuItem;
|
||||||
procedure ActivePageChanged(Sender: TObject);
|
procedure ActivePageChanged(Sender: TObject);
|
||||||
procedure OpenPackageClicked(Sender: TObject);
|
procedure OpenPackageClicked(Sender: TObject);
|
||||||
procedure OpenUnitClicked(Sender: TObject);
|
procedure OpenUnitClicked(Sender: TObject);
|
||||||
|
procedure FindComponentClicked(Sender: TObject);
|
||||||
procedure PopupMenuPopup(Sender: TObject);
|
procedure PopupMenuPopup(Sender: TObject);
|
||||||
private
|
private
|
||||||
fComponents: TAVLTree; // tree of TRegisteredComponent sorted for componentclass
|
fComponents: TAVLTree; // tree of TRegisteredComponent sorted for componentclass
|
||||||
@ -111,7 +114,7 @@ var
|
|||||||
begin
|
begin
|
||||||
RegComp1:=TRegisteredComponent(Data1);
|
RegComp1:=TRegisteredComponent(Data1);
|
||||||
RegComp2:=TRegisteredComponent(Data2);
|
RegComp2:=TRegisteredComponent(Data2);
|
||||||
Result:=AnsiCompareText(RegComp1.ComponentClass.ClassName,
|
Result:=CompareText(RegComp1.ComponentClass.ClassName,
|
||||||
RegComp2.ComponentClass.ClassName);
|
RegComp2.ComponentClass.ClassName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -122,7 +125,7 @@ var
|
|||||||
begin
|
begin
|
||||||
AClassName:=String(Key);
|
AClassName:=String(Key);
|
||||||
RegComp:=TRegisteredComponent(Data);
|
RegComp:=TRegisteredComponent(Data);
|
||||||
Result:=AnsiCompareText(AClassName,RegComp.ComponentClass.ClassName);
|
Result:=CompareText(AClassName,RegComp.ComponentClass.ClassName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TComponentPalette }
|
{ TComponentPalette }
|
||||||
@ -158,6 +161,14 @@ begin
|
|||||||
OnOpenUnit(PkgComponent);
|
OnOpenUnit(PkgComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TComponentPalette.FindComponentClicked(Sender: TObject);
|
||||||
|
var
|
||||||
|
AComponent: TRegisteredComponent;
|
||||||
|
begin
|
||||||
|
if ShowFindPaletteComponentDlg(AComponent)<>mrOk then exit;
|
||||||
|
Selected:=AComponent;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TComponentPalette.PopupMenuPopup(Sender: TObject);
|
procedure TComponentPalette.PopupMenuPopup(Sender: TObject);
|
||||||
var
|
var
|
||||||
PkgComponent: TPkgComponent;
|
PkgComponent: TPkgComponent;
|
||||||
@ -288,6 +299,14 @@ begin
|
|||||||
OnClick:=@OpenUnitClicked;
|
OnClick:=@OpenUnitClicked;
|
||||||
end;
|
end;
|
||||||
PopupMenu.Items.Add(OpenUnitMenuItem);
|
PopupMenu.Items.Add(OpenUnitMenuItem);
|
||||||
|
|
||||||
|
FindComponentMenuItem:=TMenuItem.Create(PopupMenu);
|
||||||
|
with FindComponentMenuItem do begin
|
||||||
|
Name:='FindComponentMenuItem';
|
||||||
|
Caption:=lisCompPalFindComponent;
|
||||||
|
OnClick:=@FindComponentClicked;
|
||||||
|
end;
|
||||||
|
PopupMenu.Items.Add(FindComponentMenuItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentPalette.DoEndUpdate(Changed: boolean);
|
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
|
// component palette
|
||||||
lisCompPalOpenPackage = 'Open package';
|
lisCompPalOpenPackage = 'Open package';
|
||||||
lisCompPalOpenUnit = 'Open unit';
|
lisCompPalOpenUnit = 'Open unit';
|
||||||
|
lisCompPalFindComponent = 'Find component';
|
||||||
|
|
||||||
// macro promp dialog
|
// macro promp dialog
|
||||||
lisMacroPromptEnterData = 'Enter data';
|
lisMacroPromptEnterData = 'Enter data';
|
||||||
|
@ -37,7 +37,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, TypInfo, LCLProc, Controls, Forms, Menus, LCLStrConsts,
|
Classes, SysUtils, TypInfo, LCLProc, Controls, Forms, Menus, LCLStrConsts,
|
||||||
StringHashList, LDockCtrlEdit, LDockTree;
|
StringHashList, LazConfigStorage, LDockCtrlEdit, LDockTree;
|
||||||
|
|
||||||
type
|
type
|
||||||
TNonDockConfigNames = (
|
TNonDockConfigNames = (
|
||||||
|
@ -40,7 +40,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, LResources,
|
Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, LResources,
|
||||||
Graphics, LCLType, LCLProc, Menus, Dialogs, FileUtil,
|
Graphics, LCLType, LCLProc, Menus, Dialogs, FileUtil,
|
||||||
AVL_Tree, Laz_XMLCfg, LazIDEIntf, ProjectIntf,
|
AVL_Tree, Laz_XMLCfg, LazIDEIntf, ProjectIntf, FormEditingIntf,
|
||||||
IDEProcs, LazConf, LazarusIDEStrConsts, IDEOptionDefs, IDEDefs,
|
IDEProcs, LazConf, LazarusIDEStrConsts, IDEOptionDefs, IDEDefs,
|
||||||
CompilerOptions, CompilerOptionsDlg, ComponentReg, PackageDefs, PkgOptionsDlg,
|
CompilerOptions, CompilerOptionsDlg, ComponentReg, PackageDefs, PkgOptionsDlg,
|
||||||
AddToPackageDlg, PkgVirtualUnitEditor, PackageSystem;
|
AddToPackageDlg, PkgVirtualUnitEditor, PackageSystem;
|
||||||
@ -1448,7 +1448,7 @@ begin
|
|||||||
with RegisteredListBox do begin
|
with RegisteredListBox do begin
|
||||||
Name:='RegisteredListBox';
|
Name:='RegisteredListBox';
|
||||||
Align:=alClient;
|
Align:=alClient;
|
||||||
ItemHeight:=23;
|
ItemHeight:=ComponentPaletteBtnWidth-2;
|
||||||
OnDrawItem:=@RegisteredListBoxDrawItem;
|
OnDrawItem:=@RegisteredListBoxDrawItem;
|
||||||
Style:= lbOwnerDrawFixed;
|
Style:= lbOwnerDrawFixed;
|
||||||
Parent:=RegisteredPluginsGroupBox;
|
Parent:=RegisteredPluginsGroupBox;
|
||||||
|
Loading…
Reference in New Issue
Block a user