IDE: Add filter to the component list of Object Inspector

git-svn-id: trunk@37341 -
This commit is contained in:
juha 2012-05-19 07:26:10 +00:00
parent dbf2cdf4d3
commit fdce65fa2e
3 changed files with 98 additions and 48 deletions

View File

@ -307,7 +307,7 @@
<OutDir Value="languages"/> <OutDir Value="languages"/>
</i18n> </i18n>
<Type Value="RunAndDesignTime"/> <Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2"> <RequiredPkgs Count="3">
<Item1> <Item1>
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item1> </Item1>
@ -315,6 +315,9 @@
<PackageName Value="FCL"/> <PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/> <MinVersion Major="1" Valid="True"/>
</Item2> </Item2>
<Item3>
<PackageName Value="LazControls"/>
</Item3>
</RequiredPkgs> </RequiredPkgs>
<UsageOptions> <UsageOptions>
<UnitPath Value="$(PkgOutDir)"/> <UnitPath Value="$(PkgOutDir)"/>
@ -322,5 +325,8 @@
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
</PublishOptions> </PublishOptions>
<CustomOptions Items="ExternHelp" Version="2">
<_ExternHelp Items="Count"/>
</CustomOptions>
</Package> </Package>
</CONFIG> </CONFIG>

View File

@ -1,19 +1,19 @@
object ObjectInspectorDlg: TObjectInspectorDlg object ObjectInspectorDlg: TObjectInspectorDlg
Left = 292 Left = 338
Height = 669 Height = 669
Top = 175 Top = 162
Width = 275 Width = 300
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'ObjectInspectorDlg' Caption = 'ObjectInspectorDlg'
ClientHeight = 669 ClientHeight = 669
ClientWidth = 275 ClientWidth = 300
KeyPreview = True KeyPreview = True
LCLVersion = '0.9.31' LCLVersion = '1.1'
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 23 Height = 22
Top = 646 Top = 647
Width = 275 Width = 300
Panels = < Panels = <
item item
Width = 100 Width = 100
@ -25,18 +25,51 @@ object ObjectInspectorDlg: TObjectInspectorDlg
end end
object AvailPersistentComboBox: TComboBox object AvailPersistentComboBox: TComboBox
Left = 0 Left = 0
Height = 23 Height = 24
Top = 0 Top = 0
Width = 275 Width = 300
Align = alTop Align = alTop
ItemHeight = 15 ItemHeight = 0
OnCloseUp = AvailComboBoxCloseUp OnCloseUp = AvailComboBoxCloseUp
Style = csDropDownList Style = csDropDownList
TabOrder = 0 TabOrder = 0
end end
object ComponentPanel: TPanel
Left = 0
Height = 184
Top = 24
Width = 300
Align = alTop
ClientHeight = 184
ClientWidth = 300
TabOrder = 2
object CompFilterEdit: TTreeFilterEdit
AnchorSideLeft.Control = FilterLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FilterLabel
AnchorSideTop.Side = asrCenter
Left = 71
Height = 24
Top = 2
Width = 128
ButtonWidth = 23
NumGlyphs = 0
BorderSpacing.Left = 5
MaxLength = 0
TabOrder = 0
end
object FilterLabel: TLabel
Left = 3
Height = 15
Top = 7
Width = 63
Caption = 'Components'
ParentColor = False
end
end
object MainPopupMenu: TPopupMenu object MainPopupMenu: TPopupMenu
OnPopup = OnMainPopupMenuPopup OnPopup = OnMainPopupMenuPopup
left = 8 left = 32
top = 11 top = 64
end end
end end

View File

@ -42,7 +42,7 @@ uses
InterfaceBase, Forms, Buttons, Graphics, GraphType, LCLProc, InterfaceBase, Forms, Buttons, Graphics, GraphType, LCLProc,
StdCtrls, LCLType, LCLIntf, Controls, ComCtrls, ExtCtrls, StdCtrls, LCLType, LCLIntf, Controls, ComCtrls, ExtCtrls,
LMessages, LResources, LazConfigStorage, Menus, Dialogs, Themes, LMessages, LResources, LazConfigStorage, Menus, Dialogs, Themes,
ObjInspStrConsts, TreeFilterEdit, ObjInspStrConsts,
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor, PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
ComponentTreeView, ComponentEditors, IDEImagesIntf, OIFavouriteProperties; ComponentTreeView, ComponentEditors, IDEImagesIntf, OIFavouriteProperties;
@ -577,9 +577,12 @@ type
TObjectInspectorDlg = class(TForm) TObjectInspectorDlg = class(TForm)
AddToFavoritesPopupMenuItem: TMenuItem; AddToFavoritesPopupMenuItem: TMenuItem;
ComponentPanel: TPanel;
FilterLabel: TLabel;
CompFilterEdit: TTreeFilterEdit;
ComponentTree: TComponentTreeView;
ViewRestrictedPropertiesPopupMenuItem: TMenuItem; ViewRestrictedPropertiesPopupMenuItem: TMenuItem;
AvailPersistentComboBox: TComboBox; AvailPersistentComboBox: TComboBox;
ComponentTree: TComponentTreeView;
InfoPanel: TPanel; InfoPanel: TPanel;
CopyPopupmenuItem: TMenuItem; CopyPopupmenuItem: TMenuItem;
CutPopupmenuItem: TMenuItem; CutPopupmenuItem: TMenuItem;
@ -3549,7 +3552,7 @@ begin
FGridSplitterX[p]:=110; FGridSplitterX[p]:=110;
FDefaultItemHeight:=20; FDefaultItemHeight:=20;
FShowComponentTree:=true; FShowComponentTree:=true;
FComponentTreeHeight:=100; FComponentTreeHeight:=160;
FInfoBoxHeight:=80; FInfoBoxHeight:=80;
FGridBackgroundColor := DefBackgroundColor; FGridBackgroundColor := DefBackgroundColor;
@ -3611,7 +3614,7 @@ begin
FShowComponentTree:=ConfigStore.GetValue( FShowComponentTree:=ConfigStore.GetValue(
Path+'ComponentTree/Show/Value',true); Path+'ComponentTree/Show/Value',true);
FComponentTreeHeight:=ConfigStore.GetValue( FComponentTreeHeight:=ConfigStore.GetValue(
Path+'ComponentTree/Height/Value',100); Path+'ComponentTree/Height/Value',160);
FGridBackgroundColor:=ConfigStore.GetValue( FGridBackgroundColor:=ConfigStore.GetValue(
Path+'Color/GridBackground',DefBackgroundColor); Path+'Color/GridBackground',DefBackgroundColor);
@ -3692,7 +3695,7 @@ begin
ConfigStore.SetDeleteValue(Path+'ComponentTree/Show/Value', ConfigStore.SetDeleteValue(Path+'ComponentTree/Show/Value',
FShowComponentTree,true); FShowComponentTree,true);
ConfigStore.SetDeleteValue(Path+'ComponentTree/Height/Value', ConfigStore.SetDeleteValue(Path+'ComponentTree/Height/Value',
FComponentTreeHeight,100); FComponentTreeHeight,160);
ConfigStore.SetDeleteValue(Path+'Color/GridBackground', ConfigStore.SetDeleteValue(Path+'Color/GridBackground',
FGridBackgroundColor,DefBackgroundColor); FGridBackgroundColor,DefBackgroundColor);
@ -3875,7 +3878,7 @@ begin
FAutoShow := True; FAutoShow := True;
FUpdatingAvailComboBox:=false; FUpdatingAvailComboBox:=false;
FDefaultItemHeight := 22; FDefaultItemHeight := 22;
FComponentTreeHeight:=100; FComponentTreeHeight:=160;
FShowComponentTree := True; FShowComponentTree := True;
FShowFavorites := False; FShowFavorites := False;
FShowRestricted := False; FShowRestricted := False;
@ -3951,22 +3954,36 @@ begin
begin begin
Name := 'ComponentTree'; Name := 'ComponentTree';
Constraints.MinHeight := 16; Constraints.MinHeight := 16;
Height := ComponentTreeHeight; Parent := ComponentPanel;
Parent := Self; AnchorSideTop.Control := CompFilterEdit;
Align := alTop; AnchorSideTop.Side := asrBottom;
AnchorSideBottom.Control := ComponentPanel;
AnchorSideBottom.Side := asrBottom;
BorderSpacing.Top := 3;
BorderSpacing.Bottom := 3;
Left := 3;
Height := ComponentPanel.Height - BorderSpacing.Top
- CompFilterEdit.Top - CompFilterEdit.Height;
Width := ComponentPanel.Width-6;
Anchors := [akTop, akLeft, akRight, akBottom];
OnDblClick := @ComponentTreeDblClick; OnDblClick := @ComponentTreeDblClick;
OnKeyDown := @ComponentTreeKeyDown; OnKeyDown := @ComponentTreeKeyDown;
OnSelectionChanged := @ComponentTreeSelectionChanged; OnSelectionChanged := @ComponentTreeSelectionChanged;
OnModified := @DoModified; OnModified := @DoModified;
Visible := FShowComponentTree;
Scrollbars := ssAutoBoth; Scrollbars := ssAutoBoth;
PopupMenu := MainPopupMenu; PopupMenu := MainPopupMenu;
end; end;
// ComponentPanel encapsulates TreeFilterEdit and ComponentTree
ComponentPanel.Height := ComponentTreeHeight;
ComponentPanel.Visible := FShowComponentTree;
CompFilterEdit.FilteredTreeview:=ComponentTree;
InfoPanel := TPanel.Create(Self); InfoPanel := TPanel.Create(Self);
with InfoPanel do with InfoPanel do
begin begin
Name := 'InfoPanel'; Name := 'InfoPanel';
// Constraints.MinHeight := 16; Should there be MinHeight?
Caption := ''; Caption := '';
Height := InfoBoxHeight; Height := InfoBoxHeight;
Parent := Self; Parent := Self;
@ -3978,7 +3995,6 @@ begin
if ShowComponentTree then if ShowComponentTree then
CreateSplitter(True); CreateSplitter(True);
if ShowInfoBox then if ShowInfoBox then
CreateSplitter(False); CreateSplitter(False);
@ -4035,8 +4051,8 @@ begin
if FComponentTreeHeight <> AValue then if FComponentTreeHeight <> AValue then
begin begin
FComponentTreeHeight := AValue; FComponentTreeHeight := AValue;
if Assigned(ComponentTree) then Assert(Assigned(ComponentTree), 'TObjectInspectorDlg.SetComponentTreeHeight: ComponentTree=nil');
ComponentTree.Height := AValue; ComponentPanel.Height := AValue;
end; end;
end; end;
@ -4066,7 +4082,7 @@ begin
if FInfoBoxHeight <> AValue then if FInfoBoxHeight <> AValue then
begin begin
FInfoBoxHeight := AValue; FInfoBoxHeight := AValue;
if Assigned(InfoPanel) then Assert(Assigned(InfoPanel), 'TObjectInspectorDlg.SetInfoBoxHeight: InfoPanel=nil');
InfoPanel.Height := AValue; InfoPanel.Height := AValue;
end; end;
end; end;
@ -4120,8 +4136,9 @@ begin
//,' ',FPropertyEditorHook<>nil,' ',FPropertyEditorHook.LookupRoot<>nil); //,' ',FPropertyEditorHook<>nil,' ',FPropertyEditorHook.LookupRoot<>nil);
if FUpdatingAvailComboBox then exit; if FUpdatingAvailComboBox then exit;
FUpdatingAvailComboBox:=true; FUpdatingAvailComboBox:=true;
if ComponentTree<>nil then Assert(Assigned(ComponentTree), 'TObjectInspectorDlg.FillPersistentComboBox: ComponentTree=nil');
ComponentTree.RebuildComponentNodes; ComponentTree.RebuildComponentNodes; // if ComponentTree<>nil then
CompFilterEdit.InvalidateFilter;
NewList:=TStringList.Create; NewList:=TStringList.Create;
try try
if (FPropertyEditorHook<>nil) if (FPropertyEditorHook<>nil)
@ -4308,7 +4325,6 @@ var NewComponent,Root:TComponent;
FOnSelectPersistentsInOI(Self); FOnSelectPersistentsInOI(Self);
end; end;
// AvailComboBoxChange
begin begin
if FUpdatingAvailComboBox then exit; if FUpdatingAvailComboBox then exit;
if (FPropertyEditorHook=nil) or (FPropertyEditorHook.LookupRoot=nil) then if (FPropertyEditorHook=nil) or (FPropertyEditorHook.LookupRoot=nil) then
@ -4610,20 +4626,16 @@ begin
// hide controls while rebuilding // hide controls while rebuilding
if Splitter1 <> nil then if Splitter1 <> nil then
Splitter1.Visible := False; Splitter1.Visible := False;
ComponentTree.Visible := False; ComponentPanel.Visible := False;
AvailPersistentComboBox.Visible := False; AvailPersistentComboBox.Visible := False;
// rebuild controls // rebuild controls
ComponentTree.Parent := Self; ComponentPanel.Height := ComponentTreeHeight;
ComponentTree.Align := alTop;
if FShowComponentTree then if FShowComponentTree then
CreateSplitter(True) CreateSplitter(True)
else else
begin
ComponentTree.Height := ComponentTreeHeight;
FreeAndNil(Splitter1); FreeAndNil(Splitter1);
end;
ComponentTree.Visible := FShowComponentTree;
AvailPersistentComboBox.Visible := not FShowComponentTree; AvailPersistentComboBox.Visible := not FShowComponentTree;
ComponentPanel.Visible := FShowComponentTree;
finally finally
EndUpdate; EndUpdate;
end; end;
@ -4640,9 +4652,7 @@ procedure TObjectInspectorDlg.SetShowInfoBox(const AValue: Boolean);
begin begin
if FShowInfoBox = AValue then exit; if FShowInfoBox = AValue then exit;
FShowInfoBox := AValue; FShowInfoBox := AValue;
InfoPanel.Visible := AValue; InfoPanel.Visible := AValue;
if AValue then if AValue then
CreateSplitter(False) CreateSplitter(False)
else else
@ -5231,17 +5241,19 @@ end;
function TObjectInspectorDlg.GetComponentTreeHeight: integer; function TObjectInspectorDlg.GetComponentTreeHeight: integer;
begin begin
if Assigned(ComponentTree) then if Assigned(ComponentTree) then
Result := ComponentTree.Height Result := ComponentPanel.Height
else else // Will never happen, remove later. JuMa
Result := FComponentTreeHeight; raise Exception.Create('ComponentTree=nil in TObjectInspectorDlg.GetComponentTreeHeight');
//Result := FComponentTreeHeight;
end; end;
function TObjectInspectorDlg.GetInfoBoxHeight: integer; function TObjectInspectorDlg.GetInfoBoxHeight: integer;
begin begin
if Assigned(InfoPanel) then if Assigned(InfoPanel) then
Result := InfoPanel.Height Result := InfoPanel.Height
else else // Will never happen, remove later. JuMa
Result := FInfoBoxHeight; raise Exception.Create('InfoPanel=nil in TObjectInspectorDlg.GetInfoBoxHeight');
//Result := FInfoBoxHeight;
end; end;
procedure TObjectInspectorDlg.HookRefreshPropertyValues; procedure TObjectInspectorDlg.HookRefreshPropertyValues;
@ -5285,8 +5297,7 @@ begin
end; end;
end; end;
procedure TObjectInspectorDlg.SetComponentEditor( procedure TObjectInspectorDlg.SetComponentEditor(const AValue: TBaseComponentEditor);
const AValue: TBaseComponentEditor);
begin begin
if FComponentEditor <> AValue then if FComponentEditor <> AValue then
begin begin