mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 05:39:17 +02:00
IDE: Unit list dialog improvements (TUseUnitDialog and TViewUnitDialog). Issue #40280, patch by n7800.
This commit is contained in:
parent
5c6dac2372
commit
e8aeeb4f18
@ -9,9 +9,11 @@ object UseUnitDialog: TUseUnitDialog
|
|||||||
ClientWidth = 363
|
ClientWidth = 363
|
||||||
Constraints.MinHeight = 150
|
Constraints.MinHeight = 150
|
||||||
Constraints.MinWidth = 200
|
Constraints.MinWidth = 200
|
||||||
|
KeyPreview = True
|
||||||
OnClose = FormClose
|
OnClose = FormClose
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
|
OnKeyDown = FormKeyDown
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
@ -84,8 +86,6 @@ object UseUnitDialog: TUseUnitDialog
|
|||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
OnDblClick = UnitsListBoxDblClick
|
OnDblClick = UnitsListBoxDblClick
|
||||||
OnDrawItem = UnitsListBoxDrawItem
|
OnDrawItem = UnitsListBoxDrawItem
|
||||||
OnKeyDown = UnitsListBoxKeyDown
|
|
||||||
OnMeasureItem = UnitsListBoxMeasureItem
|
|
||||||
Style = lbOwnerDrawFixed
|
Style = lbOwnerDrawFixed
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
@ -112,6 +112,7 @@ object UseUnitDialog: TUseUnitDialog
|
|||||||
Top = 6
|
Top = 6
|
||||||
Width = 351
|
Width = 351
|
||||||
OnAfterFilter = FilterEditAfterFilter
|
OnAfterFilter = FilterEditAfterFilter
|
||||||
|
OnFilterItemEx = FilterEditFilterItemEx
|
||||||
ButtonWidth = 23
|
ButtonWidth = 23
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
@ -119,6 +120,7 @@ object UseUnitDialog: TUseUnitDialog
|
|||||||
MaxLength = 0
|
MaxLength = 0
|
||||||
ParentFont = False
|
ParentFont = False
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
OnKeyDown = FilterEditKeyDown
|
||||||
FilteredListbox = UnitsListBox
|
FilteredListbox = UnitsListBox
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
// LCL
|
// LCL
|
||||||
LCLType, Forms, Controls, StdCtrls, ExtCtrls, ButtonPanel, Dialogs, Graphics,
|
LCLType, LCLProc, Forms, Controls, StdCtrls, ExtCtrls, ButtonPanel, Dialogs, Graphics,
|
||||||
// LazControls
|
// LazControls
|
||||||
ListFilterEdit,
|
ListFilterEdit,
|
||||||
// LazUtils
|
// LazUtils
|
||||||
@ -42,7 +42,7 @@ uses
|
|||||||
// BuildIntf
|
// BuildIntf
|
||||||
ProjectIntf,
|
ProjectIntf,
|
||||||
// IdeIntf
|
// IdeIntf
|
||||||
IdeIntfStrConsts, LazIDEIntf, IDEImagesIntf, IDEWindowIntf,
|
IdeIntfStrConsts, LazIDEIntf, IDEImagesIntf, IDEWindowIntf, TextTools,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, SourceEditor, Project, EnvironmentOpts, MainIntf;
|
LazarusIDEStrConsts, SourceEditor, Project, EnvironmentOpts, MainIntf;
|
||||||
|
|
||||||
@ -60,17 +60,18 @@ type
|
|||||||
SectionRadioGroup: TRadioGroup;
|
SectionRadioGroup: TRadioGroup;
|
||||||
procedure AllUnitsCheckBoxChange(Sender: TObject);
|
procedure AllUnitsCheckBoxChange(Sender: TObject);
|
||||||
procedure FilterEditAfterFilter(Sender: TObject);
|
procedure FilterEditAfterFilter(Sender: TObject);
|
||||||
|
function FilterEditFilterItemEx(const ACaption: string; ItemData: Pointer;
|
||||||
|
out Done: Boolean): Boolean;
|
||||||
|
procedure FilterEditKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure SectionRadioGroupClick(Sender: TObject);
|
procedure SectionRadioGroupClick(Sender: TObject);
|
||||||
procedure UnitsListBoxDblClick(Sender: TObject);
|
procedure UnitsListBoxDblClick(Sender: TObject);
|
||||||
procedure UnitsListBoxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
procedure UnitsListBoxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||||
ARect: TRect; State: TOwnerDrawState);
|
ARect: TRect; State: TOwnerDrawState);
|
||||||
procedure UnitsListBoxKeyDown(Sender: TObject; var Key: Word;
|
|
||||||
Shift: TShiftState);
|
|
||||||
procedure UnitsListBoxMeasureItem({%H-}Control: TWinControl; {%H-}Index: Integer;
|
|
||||||
var AHeight: Integer);
|
|
||||||
private
|
private
|
||||||
UnitImgInd: Integer;
|
UnitImgInd: Integer;
|
||||||
FMainUsedUnits, FImplUsedUnits: TStringList;
|
FMainUsedUnits, FImplUsedUnits: TStringList;
|
||||||
@ -204,14 +205,33 @@ begin
|
|||||||
ButtonPanel1.CancelButton.Caption:=lisCancel;
|
ButtonPanel1.CancelButton.Caption:=lisCancel;
|
||||||
UnitImgInd := IDEImages.LoadImage('item_unit');
|
UnitImgInd := IDEImages.LoadImage('item_unit');
|
||||||
FProjUnits:=TStringListUTF8Fast.Create;
|
FProjUnits:=TStringListUTF8Fast.Create;
|
||||||
|
UnitsListBox.ItemHeight := IDEImages.Images_16.Height + 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUseUnitDialog.FormDestroy(Sender: TObject);
|
procedure TUseUnitDialog.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FOtherUnits.Free;
|
FreeThenNil(FOtherUnits);
|
||||||
FProjUnits.Free;
|
FreeThenNil(FProjUnits);
|
||||||
FImplUsedUnits.Free;
|
FreeThenNil(FImplUsedUnits);
|
||||||
FMainUsedUnits.Free;
|
FreeThenNil(FMainUsedUnits);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUseUnitDialog.FormKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
if (Key = VK_A) and (Shift = [ssAlt]) then
|
||||||
|
begin
|
||||||
|
with AllUnitsCheckBox do
|
||||||
|
Checked := not Checked;
|
||||||
|
Key := 0;
|
||||||
|
end;
|
||||||
|
if (Key = VK_S) and (Shift = [ssAlt]) then
|
||||||
|
begin
|
||||||
|
with SectionRadioGroup do
|
||||||
|
if Enabled then
|
||||||
|
ItemIndex := (ItemIndex + 1) mod Items.Count;
|
||||||
|
Key := 0;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUseUnitDialog.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure TUseUnitDialog.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
@ -288,22 +308,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUseUnitDialog.UnitsListBoxKeyDown(Sender: TObject; var Key: Word;
|
|
||||||
Shift: TShiftState);
|
|
||||||
begin
|
|
||||||
// A hack to prevent 'O' working as shortcut for OK-button.
|
|
||||||
// Should be removed when issue #20599 is resolved.
|
|
||||||
if (Key = VK_O) and (Shift = []) then
|
|
||||||
Key:=VK_UNKNOWN;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUseUnitDialog.UnitsListBoxMeasureItem(Control: TWinControl;
|
|
||||||
Index: Integer; var AHeight: Integer);
|
|
||||||
begin
|
|
||||||
if (AHeight <= IDEImages.Images_16.Height) then
|
|
||||||
AHeight := IDEImages.Images_16.Height + 2;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUseUnitDialog.AddImplUsedUnits;
|
procedure TUseUnitDialog.AddImplUsedUnits;
|
||||||
var
|
var
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
@ -349,8 +353,8 @@ var
|
|||||||
x: Integer;
|
x: Integer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
FreeAndNil(FMainUsedUnits);
|
FreeThenNil(FMainUsedUnits);
|
||||||
FreeAndNil(FImplUsedUnits);
|
FreeThenNil(FImplUsedUnits);
|
||||||
if SrcEdit = nil then Exit;
|
if SrcEdit = nil then Exit;
|
||||||
Assert(Assigned(SrcEdit.CodeBuffer));
|
Assert(Assigned(SrcEdit.CodeBuffer));
|
||||||
if DlgType=udUseUnit then
|
if DlgType=udUseUnit then
|
||||||
@ -513,9 +517,25 @@ end;
|
|||||||
|
|
||||||
procedure TUseUnitDialog.FilterEditAfterFilter(Sender: TObject);
|
procedure TUseUnitDialog.FilterEditAfterFilter(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if (UnitsListBox.Count > 0) and (UnitsListBox.ItemIndex = -1) then
|
if (UnitsListBox.Count > 0) and (UnitsListBox.ItemIndex < 0) then
|
||||||
UnitsListBox.ItemIndex := 0;
|
UnitsListBox.ItemIndex := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TUseUnitDialog.FilterEditFilterItemEx(const ACaption: string;
|
||||||
|
ItemData: Pointer; out Done: Boolean): Boolean;
|
||||||
|
begin
|
||||||
|
Done := true;
|
||||||
|
result := MultiWordSearch(FilterEdit.Text, ACaption);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUseUnitDialog.FilterEditKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
var
|
||||||
|
c: char;
|
||||||
|
begin
|
||||||
|
if KeyToQWERTY(Key, Shift, c, true) then
|
||||||
|
FilterEdit.SelText := c;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ object ViewUnitDialog: TViewUnitDialog
|
|||||||
OnDblClick = OKButtonClick
|
OnDblClick = OKButtonClick
|
||||||
OnDrawItem = ListboxDrawItem
|
OnDrawItem = ListboxDrawItem
|
||||||
OnKeyPress = ListboxKeyPress
|
OnKeyPress = ListboxKeyPress
|
||||||
OnMeasureItem = ListboxMeasureItem
|
|
||||||
PopupMenu = popListBox
|
PopupMenu = popListBox
|
||||||
Style = lbOwnerDrawFixed
|
Style = lbOwnerDrawFixed
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
@ -85,6 +84,7 @@ object ViewUnitDialog: TViewUnitDialog
|
|||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 335
|
Width = 335
|
||||||
|
OnFilterItemEx = FilterEditFilterItemEx
|
||||||
ButtonHint = 'Clear Filter'
|
ButtonHint = 'Clear Filter'
|
||||||
ButtonWidth = 23
|
ButtonWidth = 23
|
||||||
Align = alClient
|
Align = alClient
|
||||||
@ -95,6 +95,7 @@ object ViewUnitDialog: TViewUnitDialog
|
|||||||
ParentShowHint = False
|
ParentShowHint = False
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
OnKeyDown = FilterEditKeyDown
|
||||||
FilteredListbox = Listbox
|
FilteredListbox = Listbox
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,7 @@ uses
|
|||||||
// LazControls
|
// LazControls
|
||||||
ListFilterEdit,
|
ListFilterEdit,
|
||||||
// IdeIntf
|
// IdeIntf
|
||||||
IdeIntfStrConsts, IDEWindowIntf, IDEHelpIntf, IDEImagesIntf,
|
IdeIntfStrConsts, IDEWindowIntf, IDEHelpIntf, IDEImagesIntf, TextTools,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIdeStrConsts, IDEProcs, CustomFormEditor, SearchPathProcs, PackageDefs;
|
LazarusIdeStrConsts, IDEProcs, CustomFormEditor, SearchPathProcs, PackageDefs;
|
||||||
|
|
||||||
@ -120,14 +120,16 @@ type
|
|||||||
ProgressBar1: TProgressBar;
|
ProgressBar1: TProgressBar;
|
||||||
RemoveBitBtn: TSpeedButton;
|
RemoveBitBtn: TSpeedButton;
|
||||||
SortAlphabeticallySpeedButton: TSpeedButton;
|
SortAlphabeticallySpeedButton: TSpeedButton;
|
||||||
|
function FilterEditFilterItemEx(const ACaption: string; ItemData: Pointer;
|
||||||
|
out Done: Boolean): Boolean;
|
||||||
|
procedure FilterEditKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure ListboxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
procedure ListboxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||||
procedure ListboxKeyPress(Sender: TObject; var Key: char);
|
procedure ListboxKeyPress(Sender: TObject; var Key: char);
|
||||||
procedure ListboxMeasureItem({%H-}Control: TWinControl; {%H-}Index: Integer;
|
|
||||||
var AHeight: Integer);
|
|
||||||
procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
|
procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
|
||||||
procedure SortAlphabeticallySpeedButtonClick(Sender: TObject);
|
procedure SortAlphabeticallySpeedButtonClick(Sender: TObject);
|
||||||
procedure OKButtonClick(Sender :TObject);
|
procedure OKButtonClick(Sender :TObject);
|
||||||
@ -321,6 +323,8 @@ begin
|
|||||||
SortAlphabeticallySpeedButton.Hint:=lisPESortFilesAlphabetically;
|
SortAlphabeticallySpeedButton.Hint:=lisPESortFilesAlphabetically;
|
||||||
FilterEdit.ButtonHint:=lisClearFilter;
|
FilterEdit.ButtonHint:=lisClearFilter;
|
||||||
IDEImages.AssignImage(SortAlphabeticallySpeedButton, 'pkg_sortalphabetically');
|
IDEImages.AssignImage(SortAlphabeticallySpeedButton, 'pkg_sortalphabetically');
|
||||||
|
|
||||||
|
ListBox.ItemHeight := IDEImages.Images_16.Height + 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TViewUnitDialog.FormDestroy(Sender: TObject);
|
procedure TViewUnitDialog.FormDestroy(Sender: TObject);
|
||||||
@ -336,6 +340,22 @@ begin
|
|||||||
IDEDialogLayoutList.SaveLayout(Self);
|
IDEDialogLayoutList.SaveLayout(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TViewUnitDialog.FilterEditKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
var
|
||||||
|
c: char;
|
||||||
|
begin
|
||||||
|
if KeyToQWERTY(Key, Shift, c, true) then
|
||||||
|
FilterEdit.SelText := c;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TViewUnitDialog.FilterEditFilterItemEx(const ACaption: string;
|
||||||
|
ItemData: Pointer; out Done: Boolean): Boolean;
|
||||||
|
begin
|
||||||
|
Done := true;
|
||||||
|
result := MultiWordSearch(FilterEdit.Text, ACaption);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TViewUnitDialog.Init(const aCaption: string;
|
procedure TViewUnitDialog.Init(const aCaption: string;
|
||||||
EnableMultiSelect: Boolean; aItemType: TIDEProjectItem;
|
EnableMultiSelect: Boolean; aItemType: TIDEProjectItem;
|
||||||
TheEntries: TViewUnitEntries; aStartFilename: string);
|
TheEntries: TViewUnitEntries; aStartFilename: string);
|
||||||
@ -501,13 +521,6 @@ begin
|
|||||||
OKButtonClick(nil);
|
OKButtonClick(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TViewUnitDialog.ListboxMeasureItem(Control: TWinControl;
|
|
||||||
Index: Integer; var AHeight: Integer);
|
|
||||||
begin
|
|
||||||
if AHeight <= IDEImages.Images_16.Height then
|
|
||||||
AHeight := IDEImages.Images_16.Height + 2;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TViewUnitDialog.MultiselectCheckBoxClick(Sender :TObject);
|
procedure TViewUnitDialog.MultiselectCheckBoxClick(Sender :TObject);
|
||||||
begin
|
begin
|
||||||
ListBox.Multiselect := mniMultiSelect.Checked;
|
ListBox.Multiselect := mniMultiSelect.Checked;
|
||||||
|
Loading…
Reference in New Issue
Block a user