mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 18:18:02 +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
|
||||
Constraints.MinHeight = 150
|
||||
Constraints.MinWidth = 200
|
||||
KeyPreview = True
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnKeyDown = FormKeyDown
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object ButtonPanel1: TButtonPanel
|
||||
@ -84,8 +86,6 @@ object UseUnitDialog: TUseUnitDialog
|
||||
ItemHeight = 0
|
||||
OnDblClick = UnitsListBoxDblClick
|
||||
OnDrawItem = UnitsListBoxDrawItem
|
||||
OnKeyDown = UnitsListBoxKeyDown
|
||||
OnMeasureItem = UnitsListBoxMeasureItem
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 1
|
||||
end
|
||||
@ -112,6 +112,7 @@ object UseUnitDialog: TUseUnitDialog
|
||||
Top = 6
|
||||
Width = 351
|
||||
OnAfterFilter = FilterEditAfterFilter
|
||||
OnFilterItemEx = FilterEditFilterItemEx
|
||||
ButtonWidth = 23
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
@ -119,6 +120,7 @@ object UseUnitDialog: TUseUnitDialog
|
||||
MaxLength = 0
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
OnKeyDown = FilterEditKeyDown
|
||||
FilteredListbox = UnitsListBox
|
||||
end
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
// LCL
|
||||
LCLType, Forms, Controls, StdCtrls, ExtCtrls, ButtonPanel, Dialogs, Graphics,
|
||||
LCLType, LCLProc, Forms, Controls, StdCtrls, ExtCtrls, ButtonPanel, Dialogs, Graphics,
|
||||
// LazControls
|
||||
ListFilterEdit,
|
||||
// LazUtils
|
||||
@ -42,7 +42,7 @@ uses
|
||||
// BuildIntf
|
||||
ProjectIntf,
|
||||
// IdeIntf
|
||||
IdeIntfStrConsts, LazIDEIntf, IDEImagesIntf, IDEWindowIntf,
|
||||
IdeIntfStrConsts, LazIDEIntf, IDEImagesIntf, IDEWindowIntf, TextTools,
|
||||
// IDE
|
||||
LazarusIDEStrConsts, SourceEditor, Project, EnvironmentOpts, MainIntf;
|
||||
|
||||
@ -60,17 +60,18 @@ type
|
||||
SectionRadioGroup: TRadioGroup;
|
||||
procedure AllUnitsCheckBoxChange(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 FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
procedure SectionRadioGroupClick(Sender: TObject);
|
||||
procedure UnitsListBoxDblClick(Sender: TObject);
|
||||
procedure UnitsListBoxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||
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
|
||||
UnitImgInd: Integer;
|
||||
FMainUsedUnits, FImplUsedUnits: TStringList;
|
||||
@ -204,14 +205,33 @@ begin
|
||||
ButtonPanel1.CancelButton.Caption:=lisCancel;
|
||||
UnitImgInd := IDEImages.LoadImage('item_unit');
|
||||
FProjUnits:=TStringListUTF8Fast.Create;
|
||||
UnitsListBox.ItemHeight := IDEImages.Images_16.Height + 2;
|
||||
end;
|
||||
|
||||
procedure TUseUnitDialog.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FOtherUnits.Free;
|
||||
FProjUnits.Free;
|
||||
FImplUsedUnits.Free;
|
||||
FMainUsedUnits.Free;
|
||||
FreeThenNil(FOtherUnits);
|
||||
FreeThenNil(FProjUnits);
|
||||
FreeThenNil(FImplUsedUnits);
|
||||
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;
|
||||
|
||||
procedure TUseUnitDialog.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
@ -288,22 +308,6 @@ begin
|
||||
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;
|
||||
var
|
||||
i, j: Integer;
|
||||
@ -349,8 +353,8 @@ var
|
||||
x: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
FreeAndNil(FMainUsedUnits);
|
||||
FreeAndNil(FImplUsedUnits);
|
||||
FreeThenNil(FMainUsedUnits);
|
||||
FreeThenNil(FImplUsedUnits);
|
||||
if SrcEdit = nil then Exit;
|
||||
Assert(Assigned(SrcEdit.CodeBuffer));
|
||||
if DlgType=udUseUnit then
|
||||
@ -513,9 +517,25 @@ end;
|
||||
|
||||
procedure TUseUnitDialog.FilterEditAfterFilter(Sender: TObject);
|
||||
begin
|
||||
if (UnitsListBox.Count > 0) and (UnitsListBox.ItemIndex = -1) then
|
||||
if (UnitsListBox.Count > 0) and (UnitsListBox.ItemIndex < 0) then
|
||||
UnitsListBox.ItemIndex := 0;
|
||||
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.
|
||||
|
||||
|
@ -29,7 +29,6 @@ object ViewUnitDialog: TViewUnitDialog
|
||||
OnDblClick = OKButtonClick
|
||||
OnDrawItem = ListboxDrawItem
|
||||
OnKeyPress = ListboxKeyPress
|
||||
OnMeasureItem = ListboxMeasureItem
|
||||
PopupMenu = popListBox
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 1
|
||||
@ -85,6 +84,7 @@ object ViewUnitDialog: TViewUnitDialog
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 335
|
||||
OnFilterItemEx = FilterEditFilterItemEx
|
||||
ButtonHint = 'Clear Filter'
|
||||
ButtonWidth = 23
|
||||
Align = alClient
|
||||
@ -95,6 +95,7 @@ object ViewUnitDialog: TViewUnitDialog
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 0
|
||||
OnKeyDown = FilterEditKeyDown
|
||||
FilteredListbox = Listbox
|
||||
end
|
||||
end
|
||||
|
@ -51,7 +51,7 @@ uses
|
||||
// LazControls
|
||||
ListFilterEdit,
|
||||
// IdeIntf
|
||||
IdeIntfStrConsts, IDEWindowIntf, IDEHelpIntf, IDEImagesIntf,
|
||||
IdeIntfStrConsts, IDEWindowIntf, IDEHelpIntf, IDEImagesIntf, TextTools,
|
||||
// IDE
|
||||
LazarusIdeStrConsts, IDEProcs, CustomFormEditor, SearchPathProcs, PackageDefs;
|
||||
|
||||
@ -120,14 +120,16 @@ type
|
||||
ProgressBar1: TProgressBar;
|
||||
RemoveBitBtn: 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 FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure ListboxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||
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 SortAlphabeticallySpeedButtonClick(Sender: TObject);
|
||||
procedure OKButtonClick(Sender :TObject);
|
||||
@ -321,6 +323,8 @@ begin
|
||||
SortAlphabeticallySpeedButton.Hint:=lisPESortFilesAlphabetically;
|
||||
FilterEdit.ButtonHint:=lisClearFilter;
|
||||
IDEImages.AssignImage(SortAlphabeticallySpeedButton, 'pkg_sortalphabetically');
|
||||
|
||||
ListBox.ItemHeight := IDEImages.Images_16.Height + 2;
|
||||
end;
|
||||
|
||||
procedure TViewUnitDialog.FormDestroy(Sender: TObject);
|
||||
@ -336,6 +340,22 @@ begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
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;
|
||||
EnableMultiSelect: Boolean; aItemType: TIDEProjectItem;
|
||||
TheEntries: TViewUnitEntries; aStartFilename: string);
|
||||
@ -501,13 +521,6 @@ begin
|
||||
OKButtonClick(nil);
|
||||
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);
|
||||
begin
|
||||
ListBox.Multiselect := mniMultiSelect.Checked;
|
||||
|
Loading…
Reference in New Issue
Block a user