IDE: Improve GUI layout in EditorFileManager and add sorting feature

git-svn-id: trunk@35443 -
This commit is contained in:
juha 2012-02-18 14:04:32 +00:00
parent b5744efb18
commit 9ec7f6d914
2 changed files with 137 additions and 72 deletions

View File

@ -1,7 +1,7 @@
object EditorFileManagerForm: TEditorFileManagerForm object EditorFileManagerForm: TEditorFileManagerForm
Left = 364 Left = 338
Height = 380 Height = 380
Top = 266 Top = 126
Width = 722 Width = 722
Caption = 'EditorFileManagerForm' Caption = 'EditorFileManagerForm'
ClientHeight = 380 ClientHeight = 380
@ -10,16 +10,16 @@ object EditorFileManagerForm: TEditorFileManagerForm
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.31' LCLVersion = '0.9.31'
object CheckListBox1: TCheckListBox object CheckListBox1: TCheckListBox
AnchorSideLeft.Control = FilterEdit AnchorSideTop.Control = FilterPanel
AnchorSideTop.Control = FilterEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Panel1
AnchorSideBottom.Control = ButtonPanel1 AnchorSideBottom.Control = ButtonPanel1
Left = 6 Left = 3
Height = 304 Height = 298
Top = 30 Top = 29
Width = 530 Width = 533
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 1
ItemHeight = 0 ItemHeight = 0
OnClick = CheckListBox1Click OnClick = CheckListBox1Click
OnDblClick = CheckListBox1DblClick OnDblClick = CheckListBox1DblClick
@ -29,21 +29,10 @@ object EditorFileManagerForm: TEditorFileManagerForm
PopupMenu = PopupMenu1 PopupMenu = PopupMenu1
TabOrder = 0 TabOrder = 0
end end
object FilterEdit: TListFilterEdit
Left = 6
Height = 22
Top = 8
Width = 224
ButtonWidth = 23
NumGlyphs = 0
MaxLength = 0
TabOrder = 1
FilteredListbox = CheckListBox1
end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 34 Height = 41
Top = 340 Top = 333
Width = 710 Width = 710
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
@ -53,7 +42,7 @@ object EditorFileManagerForm: TEditorFileManagerForm
CloseButton.DefaultCaption = True CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton' CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True CancelButton.DefaultCaption = True
TabOrder = 2 TabOrder = 1
ShowButtons = [pbClose, pbHelp] ShowButtons = [pbClose, pbHelp]
end end
object Panel1: TPanel object Panel1: TPanel
@ -61,59 +50,42 @@ object EditorFileManagerForm: TEditorFileManagerForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1 AnchorSideBottom.Control = ButtonPanel1
Left = 536 Left = 536
Height = 334 Height = 327
Top = 0 Top = 0
Width = 186 Width = 186
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
ClientHeight = 334 ClientHeight = 327
ClientWidth = 186 ClientWidth = 186
TabOrder = 3 TabOrder = 2
object ActivateButton: TBitBtn
AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Panel1
Left = 53
Height = 24
Top = 33
Width = 81
AutoSize = True
BorderSpacing.Top = 21
BorderSpacing.Around = 11
Caption = 'Make Active'
Enabled = False
OnClick = ActivateButtonClick
TabOrder = 0
end
object SelectAllCheckBox: TCheckBox object SelectAllCheckBox: TCheckBox
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ActivateButton
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 29 Left = 29
Height = 21 Height = 20
Top = 89 Top = 40
Width = 129 Width = 128
BorderSpacing.Top = 21 BorderSpacing.Top = 21
BorderSpacing.Around = 11 BorderSpacing.Around = 11
Caption = 'SelectAllCheckBox' Caption = 'SelectAllCheckBox'
OnClick = SelectAllCheckBoxClick OnClick = SelectAllCheckBoxClick
TabOrder = 1 TabOrder = 0
end end
object SaveCheckedButton: TBitBtn object SaveCheckedButton: TBitBtn
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SelectAllCheckBox AnchorSideTop.Control = SelectAllCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 47 Left = 46
Height = 24 Height = 25
Top = 121 Top = 71
Width = 93 Width = 94
AutoSize = True AutoSize = True
BorderSpacing.Around = 11 BorderSpacing.Around = 11
Caption = 'Save Checked' Caption = 'Save Checked'
Enabled = False Enabled = False
OnClick = SaveCheckedButtonClick OnClick = SaveCheckedButtonClick
TabOrder = 2 TabOrder = 1
end end
object CloseCheckedButton: TBitBtn object CloseCheckedButton: TBitBtn
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
@ -121,15 +93,15 @@ object EditorFileManagerForm: TEditorFileManagerForm
AnchorSideTop.Control = SaveCheckedButton AnchorSideTop.Control = SaveCheckedButton
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 45 Left = 45
Height = 24 Height = 25
Top = 156 Top = 107
Width = 96 Width = 97
AutoSize = True AutoSize = True
BorderSpacing.Around = 11 BorderSpacing.Around = 11
Caption = 'Close Checked' Caption = 'Close Checked'
Enabled = False Enabled = False
OnClick = CloseCheckedButtonClick OnClick = CloseCheckedButtonClick
TabOrder = 3 TabOrder = 2
end end
object MoveUpBtn: TSpeedButton object MoveUpBtn: TSpeedButton
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
@ -138,7 +110,7 @@ object EditorFileManagerForm: TEditorFileManagerForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 82 Left = 82
Height = 26 Height = 26
Top = 204 Top = 156
Width = 22 Width = 22
BorderSpacing.Top = 24 BorderSpacing.Top = 24
Enabled = False Enabled = False
@ -153,7 +125,7 @@ object EditorFileManagerForm: TEditorFileManagerForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 82 Left = 82
Height = 26 Height = 26
Top = 237 Top = 189
Width = 22 Width = 22
BorderSpacing.Top = 7 BorderSpacing.Top = 7
Enabled = False Enabled = False
@ -163,10 +135,78 @@ object EditorFileManagerForm: TEditorFileManagerForm
ParentShowHint = False ParentShowHint = False
end end
end end
object FilterPanel: TPanel
AnchorSideRight.Control = Panel1
Left = 0
Height = 28
Top = 0
Width = 536
Anchors = [akTop, akLeft, akRight]
ClientHeight = 28
ClientWidth = 536
TabOrder = 3
object FilterEdit: TListFilterEdit
AnchorSideLeft.Control = SortAlphabeticallyButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = SortAlphabeticallyButton
AnchorSideTop.Side = asrCenter
Left = 76
Height = 24
Top = 2
Width = 224
ButtonWidth = 23
NumGlyphs = 0
BorderSpacing.Left = 11
MaxLength = 0
TabOrder = 0
FilteredListbox = CheckListBox1
end
object OpenButton: TSpeedButton
AnchorSideLeft.Control = FilterPanel
AnchorSideTop.Control = FilterPanel
AnchorSideTop.Side = asrCenter
AnchorSideBottom.Side = asrBottom
Left = 4
Height = 25
Top = 2
Width = 25
AllowAllUp = True
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 3
Constraints.MinHeight = 25
Constraints.MinWidth = 25
NumGlyphs = 0
OnClick = ActivateButtonClick
ShowHint = True
ParentShowHint = False
end
object SortAlphabeticallyButton: TSpeedButton
AnchorSideLeft.Control = OpenButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OpenButton
AnchorSideTop.Side = asrCenter
AnchorSideBottom.Side = asrBottom
Left = 40
Height = 25
Top = 2
Width = 25
AllowAllUp = True
AutoSize = True
BorderSpacing.Left = 11
Constraints.MinHeight = 25
Constraints.MinWidth = 25
GroupIndex = 2
NumGlyphs = 0
OnClick = SortAlphabeticallyButtonClick
ShowHint = True
ParentShowHint = False
end
end
object PopupMenu1: TPopupMenu object PopupMenu1: TPopupMenu
OnPopup = PopupMenu1Popup OnPopup = PopupMenu1Popup
left = 304 left = 312
top = 8 top = 336
object ActivateMenuItem: TMenuItem object ActivateMenuItem: TMenuItem
Caption = 'Activate' Caption = 'Activate'
OnClick = ActivateMenuItemClick OnClick = ActivateMenuItemClick

View File

@ -15,9 +15,10 @@ type
TEditorFileManagerForm = class(TForm) TEditorFileManagerForm = class(TForm)
ActivateMenuItem: TMenuItem; ActivateMenuItem: TMenuItem;
ActivateButton: TBitBtn;
MoveDownBtn: TSpeedButton; MoveDownBtn: TSpeedButton;
MoveUpBtn: TSpeedButton; MoveUpBtn: TSpeedButton;
FilterPanel: TPanel;
OpenButton: TSpeedButton;
SaveCheckedButton: TBitBtn; SaveCheckedButton: TBitBtn;
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
CloseCheckedButton: TBitBtn; CloseCheckedButton: TBitBtn;
@ -27,6 +28,7 @@ type
SelectAllCheckBox: TCheckBox; SelectAllCheckBox: TCheckBox;
CheckListBox1: TCheckListBox; CheckListBox1: TCheckListBox;
FilterEdit: TListFilterEdit; FilterEdit: TListFilterEdit;
SortAlphabeticallyButton: TSpeedButton;
procedure ActivateMenuItemClick(Sender: TObject); procedure ActivateMenuItemClick(Sender: TObject);
procedure CheckListBox1DblClick(Sender: TObject); procedure CheckListBox1DblClick(Sender: TObject);
procedure CheckListBox1KeyDown(Sender: TObject; var Key: Word; procedure CheckListBox1KeyDown(Sender: TObject; var Key: Word;
@ -43,12 +45,15 @@ type
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure ActivateButtonClick(Sender: TObject); procedure ActivateButtonClick(Sender: TObject);
procedure SelectAllCheckBoxClick(Sender: TObject); procedure SelectAllCheckBoxClick(Sender: TObject);
procedure SortAlphabeticallyButtonClick(Sender: TObject);
private private
FSortAlphabetically: boolean;
procedure CloseListItem(ListIndex: integer); procedure CloseListItem(ListIndex: integer);
procedure SetSortAlphabetically(AValue: boolean);
procedure UpdateButtons; procedure UpdateButtons;
procedure UpdateMoveButtons(ListIndex: integer); procedure UpdateMoveButtons(ListIndex: integer);
public public
property SortAlphabetically: boolean read FSortAlphabetically write SetSortAlphabetically;
end; end;
function ShowEditorFileManagerForm: TModalResult; function ShowEditorFileManagerForm: TModalResult;
@ -88,7 +93,6 @@ begin
ActivateMenuItem.Caption:=lisActivate; ActivateMenuItem.Caption:=lisActivate;
CloseMenuItem.Caption:=lisMenuClose; CloseMenuItem.Caption:=lisMenuClose;
SelectAllCheckBox.Caption:=lisCheckAll; SelectAllCheckBox.Caption:=lisCheckAll;
ActivateButton.Caption:=lisActivateSelected;
SaveCheckedButton.Caption:=lisSaveAllChecked; SaveCheckedButton.Caption:=lisSaveAllChecked;
CloseCheckedButton.Caption:=lisCloseAllChecked; CloseCheckedButton.Caption:=lisCloseAllChecked;
MoveUpBtn.Hint:=lisMoveSelectedUp; MoveUpBtn.Hint:=lisMoveSelectedUp;
@ -97,11 +101,15 @@ begin
PopupMenu1.Images:=IDEImages.Images_16; PopupMenu1.Images:=IDEImages.Images_16;
ActivateMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'laz_open'); ActivateMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'laz_open');
CloseMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'menu_close'); CloseMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'menu_close');
ActivateButton.LoadGlyphFromLazarusResource('laz_open');
CloseCheckedButton.LoadGlyphFromLazarusResource('menu_close_all'); CloseCheckedButton.LoadGlyphFromLazarusResource('menu_close_all');
SaveCheckedButton.LoadGlyphFromLazarusResource('menu_save_all'); SaveCheckedButton.LoadGlyphFromLazarusResource('menu_save_all');
MoveUpBtn.LoadGlyphFromLazarusResource('arrow_up'); MoveUpBtn.LoadGlyphFromLazarusResource('arrow_up');
MoveDownBtn.LoadGlyphFromLazarusResource('arrow_down'); MoveDownBtn.LoadGlyphFromLazarusResource('arrow_down');
// Buttons on FilterPanel
OpenButton.LoadGlyphFromLazarusResource('laz_open');
OpenButton.Hint:=lisActivateSelected;
SortAlphabeticallyButton.Hint:=lisPESortFilesAlphabetically;
SortAlphabeticallyButton.LoadGlyphFromLazarusResource('pkg_sortalphabetically');
end; end;
procedure TEditorFileManagerForm.CheckListBox1Click(Sender: TObject); procedure TEditorFileManagerForm.CheckListBox1Click(Sender: TObject);
@ -109,8 +117,8 @@ var
clb: TCheckListBox; clb: TCheckListBox;
begin begin
clb:=Sender as TCheckListBox; clb:=Sender as TCheckListBox;
// Enable ActivateButton when there is a selected item. // Enable Activate when there is a selected item.
ActivateButton.Enabled:=clb.SelCount>0; OpenButton.Enabled:=clb.SelCount>0;
UpdateMoveButtons(clb.ItemIndex); UpdateMoveButtons(clb.ItemIndex);
end; end;
@ -158,6 +166,11 @@ begin
CheckListBox1ItemClick(CheckListBox1, 0); CheckListBox1ItemClick(CheckListBox1, 0);
end; end;
procedure TEditorFileManagerForm.SortAlphabeticallyButtonClick(Sender: TObject);
begin
SortAlphabetically:=SortAlphabeticallyButton.Down;
end;
procedure TEditorFileManagerForm.SaveCheckedButtonClick(Sender: TObject); procedure TEditorFileManagerForm.SaveCheckedButtonClick(Sender: TObject);
var var
i: Integer; i: Integer;
@ -220,7 +233,7 @@ end;
procedure TEditorFileManagerForm.CheckListBox1KeyPress(Sender: TObject; var Key: char); procedure TEditorFileManagerForm.CheckListBox1KeyPress(Sender: TObject; var Key: char);
begin begin
if Key = #13 then if Key = char(VK_RETURN) then
ActivateButtonClick(nil); ActivateButtonClick(nil);
end; end;
@ -230,8 +243,9 @@ var
ANoteBook: TSourceNotebook; ANoteBook: TSourceNotebook;
i: Integer; i: Integer;
begin begin
i := CheckListBox1.ItemIndex; i:=CheckListBox1.ItemIndex;
if (i > -1) and (i < CheckListBox1.Items.Count-1) and (FilterEdit.Filter='') then begin if (i>-1) and (i<CheckListBox1.Items.Count-1)
and (FilterEdit.Filter='') and not SortAlphabetically then begin
// First move the source editor tab // First move the source editor tab
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]); SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]);
ANoteBook:=SrcEdit.SourceNotebook; ANoteBook:=SrcEdit.SourceNotebook;
@ -250,7 +264,7 @@ var
i: Integer; i: Integer;
begin begin
i := CheckListBox1.ItemIndex; i := CheckListBox1.ItemIndex;
if (i > 0) and (FilterEdit.Filter='') then begin if (i > 0) and (FilterEdit.Filter='') and not SortAlphabetically then begin
// First move the source editor tab // First move the source editor tab
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]); SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]);
ANoteBook:=SrcEdit.SourceNotebook; ANoteBook:=SrcEdit.SourceNotebook;
@ -292,6 +306,15 @@ begin
end; end;
end; end;
procedure TEditorFileManagerForm.SetSortAlphabetically(AValue: boolean);
begin
if FSortAlphabetically=AValue then exit;
FSortAlphabetically:=AValue;
SortAlphabeticallyButton.Down:=FSortAlphabetically;
FilterEdit.SortData:=FSortAlphabetically;
FilterEdit.InvalidateFilter;
end;
procedure TEditorFileManagerForm.UpdateButtons; procedure TEditorFileManagerForm.UpdateButtons;
// Update the filter and buttons. Reuse event handlers for it. // Update the filter and buttons. Reuse event handlers for it.
begin begin
@ -300,10 +323,12 @@ begin
end; end;
procedure TEditorFileManagerForm.UpdateMoveButtons(ListIndex: integer); procedure TEditorFileManagerForm.UpdateMoveButtons(ListIndex: integer);
var
b: Boolean;
begin begin
MoveUpBtn.Enabled := (ListIndex > 0) and (FilterEdit.Filter=''); b:=(FilterEdit.Filter='') and not SortAlphabetically;
MoveDownBtn.Enabled := (ListIndex > -1) and (ListIndex < CheckListBox1.Items.Count-1) MoveUpBtn.Enabled:=(ListIndex>0) and b;
and (FilterEdit.Filter=''); MoveDownBtn.Enabled:=(ListIndex>-1) and (ListIndex<CheckListBox1.Items.Count-1) and b;
end; end;
end. end.