mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 12:59:11 +02:00
IDE: improve View Unit dialog with images
git-svn-id: trunk@31545 -
This commit is contained in:
parent
52c2f1237a
commit
6ec341b0c1
@ -114,6 +114,7 @@ type
|
||||
procedure MapShortToFullFilename(ShortFilename, FullFilename: string);
|
||||
procedure ApplyFilter(Immediately: Boolean = False);
|
||||
procedure InvalidateFilter;
|
||||
procedure StoreSelection; // Calls the ViewControlWrapper method
|
||||
public
|
||||
property Filter: string read fFilter write SetFilter;
|
||||
property ImageIndexDirectory: integer read fImageIndexDirectory write fImageIndexDirectory;
|
||||
@ -322,6 +323,7 @@ procedure TViewControlTreeview.StoreSelection;
|
||||
var
|
||||
ANode: TTreeNode;
|
||||
begin
|
||||
fOwner.fSelectionList.Clear;
|
||||
ANode:=fTreeview.Selected;
|
||||
while ANode<>nil do begin
|
||||
fOwner.fSelectionList.Insert(0,ANode.Text);
|
||||
@ -349,7 +351,6 @@ begin
|
||||
end;
|
||||
if ANode<>nil then
|
||||
fTreeview.Selected:=ANode;
|
||||
fSelectionList.Clear;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -478,6 +479,7 @@ procedure TViewControlListbox.StoreSelection;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
fOwner.fSelectionList.Clear;
|
||||
for i := 0 to fListbox.Count-1 do begin
|
||||
if fListbox.Selected[i] then
|
||||
fOwner.fSelectionList.Add(fListbox.Items[i]);
|
||||
@ -683,5 +685,10 @@ begin
|
||||
IdleConnected:=true;
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.StoreSelection;
|
||||
begin
|
||||
fViewControlWrapper.StoreSelection;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
21
ide/main.pp
21
ide/main.pp
@ -9549,11 +9549,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
case ItemType of
|
||||
piUnit: DlgCaption := dlgMainViewUnits;
|
||||
piComponent: DlgCaption := dlgMainViewForms;
|
||||
piFrame: DlgCaption := dlgMainViewFrames;
|
||||
piUnit: begin
|
||||
DlgCaption := dlgMainViewUnits;
|
||||
i := IDEImages.LoadImage(16, 'item_unit');
|
||||
end;
|
||||
piComponent: begin
|
||||
DlgCaption := dlgMainViewForms;
|
||||
i := IDEImages.LoadImage(16, 'item_form');
|
||||
end;
|
||||
piFrame: begin
|
||||
DlgCaption := dlgMainViewFrames;
|
||||
i := IDEImages.LoadImage(16, 'tpanel');
|
||||
end;
|
||||
end;
|
||||
Result := ShowViewUnitsDlg(ItemList, MultiSelect, MultiSelectCheckedState, DlgCaption);
|
||||
Result := ShowViewUnitsDlg(ItemList, MultiSelect, MultiSelectCheckedState, DlgCaption, i);
|
||||
end;
|
||||
|
||||
function TMainIDE.DoSelectFrame: TComponentClass;
|
||||
@ -11158,7 +11167,6 @@ Begin
|
||||
ViewUnitEntries := TStringList.Create;
|
||||
ViewUnitEntries.Sorted := True;
|
||||
UnitInfos:=nil;
|
||||
|
||||
try
|
||||
for i := 0 to Project1.UnitCount-1 do
|
||||
begin
|
||||
@ -11169,7 +11177,8 @@ Begin
|
||||
ViewUnitEntries.AddObject(AName, TViewUnitsEntry.Create(AName,i,false));
|
||||
end;
|
||||
end;
|
||||
if ShowViewUnitsDlg(ViewUnitEntries, true, MultiSelectCheckedState, lisRemoveFromProject) <> mrOk then
|
||||
if ShowViewUnitsDlg(ViewUnitEntries, true, MultiSelectCheckedState,
|
||||
lisRemoveFromProject, IDEImages.LoadImage(16, 'item_unit')) <> mrOk then
|
||||
exit(mrOk);
|
||||
{ This is where we check what the user selected. }
|
||||
UnitInfos:=TFPList.Create;
|
||||
|
@ -25,6 +25,7 @@ object ViewUnitDialog: TViewUnitDialog
|
||||
OnDblClick = OKButtonClick
|
||||
OnKeyDown = ListboxKeyDown
|
||||
PopupMenu = popListBox
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 0
|
||||
end
|
||||
object ButtonPanel: TButtonPanel
|
||||
|
@ -40,8 +40,8 @@ interface
|
||||
uses
|
||||
SysUtils, Classes, Math, Controls, Forms, Dialogs, Buttons, StdCtrls,
|
||||
LazarusIdeStrConsts, LCLType, LCLIntf, LMessages,
|
||||
ExtCtrls, ButtonPanel, Menus, StrUtils,
|
||||
IDEWindowIntf, IDEHelpIntf, ListFilterEdit;
|
||||
ExtCtrls, ButtonPanel, Menus, StrUtils, ImgList,
|
||||
IDEWindowIntf, IDEHelpIntf, IDEImagesIntf, ListFilterEdit;
|
||||
|
||||
type
|
||||
TViewUnitsEntry = class
|
||||
@ -73,14 +73,16 @@ type
|
||||
procedure MultiselectCheckBoxClick(Sender :TObject);
|
||||
private
|
||||
FSortAlphabetically: boolean;
|
||||
FImageIndex: Integer;
|
||||
procedure SetSortAlphabetically(const AValue: boolean);
|
||||
function ChooseImageIndex(Str: String; Data: TObject; var IsEnabled: Boolean): Integer;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
property SortAlphabetically: boolean read FSortAlphabetically write SetSortAlphabetically;
|
||||
end;
|
||||
|
||||
function ShowViewUnitsDlg(Entries: TStringList; AllowMultiSelect: boolean;
|
||||
var CheckMultiSelect: Boolean; const Caption: string): TModalResult;
|
||||
var CheckMultiSelect: Boolean; const aCaption: string; aImageIndex: Integer): TModalResult;
|
||||
// Entries is a list of TViewUnitsEntry(s)
|
||||
|
||||
implementation
|
||||
@ -88,25 +90,30 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
function ShowViewUnitsDlg(Entries: TStringList; AllowMultiSelect: boolean;
|
||||
var CheckMultiSelect: Boolean; const Caption: string): TModalResult;
|
||||
var CheckMultiSelect: Boolean; const aCaption: string; aImageIndex: Integer): TModalResult;
|
||||
var
|
||||
ViewUnitDialog: TViewUnitDialog;
|
||||
UEntry: TViewUnitsEntry;
|
||||
TmpList: TStringList;
|
||||
i: integer;
|
||||
begin
|
||||
IDEImages.Images_16;
|
||||
ViewUnitDialog:=TViewUnitDialog.Create(nil);
|
||||
with ViewUnitDialog do
|
||||
try
|
||||
Caption:=Caption;
|
||||
Caption:=aCaption;
|
||||
mniMultiselect.Enabled := AllowMultiSelect;
|
||||
mniMultiselect.Checked := CheckMultiSelect;
|
||||
ListBox.MultiSelect := mniMultiselect.Enabled;
|
||||
if aImageIndex > -1 then begin
|
||||
FImageIndex:=aImageIndex;
|
||||
FilterEdit.Images4Listbox:=IDEImages.Images_16;
|
||||
FilterEdit.OnGetImageIndex:=@ChooseImageIndex;
|
||||
end;
|
||||
// Data items
|
||||
for i:=0 to Entries.Count-1 do begin
|
||||
UEntry:=TViewUnitsEntry(Entries.Objects[i]);
|
||||
FilterEdit.Data.Add(UEntry.Name);
|
||||
end;
|
||||
for i:=0 to Entries.Count-1 do begin
|
||||
UEntry:=TViewUnitsEntry(Entries.Objects[i]);
|
||||
FilterEdit.Data.Add(UEntry.Name);
|
||||
end;
|
||||
FilterEdit.InvalidateFilter;
|
||||
// Initial selection
|
||||
for i:=0 to Entries.Count-1 do
|
||||
@ -118,18 +125,10 @@ begin
|
||||
Result:=ShowModal;
|
||||
if Result=mrOk then begin
|
||||
// Return new selections from the dialog
|
||||
TmpList:=TStringList.Create;
|
||||
try
|
||||
for i:=0 to ListBox.Count-1 do begin
|
||||
if ListBox.Selected[i] then
|
||||
TmpList.Add(ListBox.Items[i]);
|
||||
end;
|
||||
for i:=0 to Entries.Count-1 do begin
|
||||
UEntry:=TViewUnitsEntry(Entries.Objects[i]);
|
||||
UEntry.Selected:=TmpList.IndexOf(UEntry.Name)>-1;
|
||||
end;
|
||||
finally
|
||||
TmpList.Free;
|
||||
FilterEdit.StoreSelection;
|
||||
for i:=0 to Entries.Count-1 do begin
|
||||
UEntry:=TViewUnitsEntry(Entries.Objects[i]);
|
||||
UEntry.Selected:=FilterEdit.SelectionList.IndexOf(UEntry.Name)>-1;
|
||||
end;
|
||||
CheckMultiSelect := mniMultiselect.Checked;
|
||||
end;
|
||||
@ -207,6 +206,12 @@ begin
|
||||
FilterEdit.InvalidateFilter;
|
||||
end;
|
||||
|
||||
function TViewUnitDialog.ChooseImageIndex(Str: String; Data: TObject;
|
||||
var IsEnabled: Boolean): Integer;
|
||||
begin
|
||||
Result:=FImageIndex;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user