mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 20:49:30 +02:00
IDE: Add Move Buttons to EditorFileManager + other fixes.
git-svn-id: trunk@35435 -
This commit is contained in:
parent
9f4cf4d538
commit
228beff757
@ -180,9 +180,6 @@ begin
|
||||
clb.Checked[ListInd]:=fCheckedItems.Contains(s);
|
||||
end;
|
||||
end;
|
||||
// Notify the CheckListBox that checked state may have changed.
|
||||
if Assigned(clb) and Assigned(clb.OnItemClick) then
|
||||
clb.OnItemClick(clb, -1); // The handler must not use the index -1 directly
|
||||
fFilteredListbox.Items.EndUpdate;
|
||||
end;
|
||||
|
||||
@ -191,18 +188,27 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
fSelectionList.Clear;
|
||||
for i := 0 to fFilteredListbox.Count-1 do
|
||||
if fFilteredListbox.Selected[i] then
|
||||
fSelectionList.Add(fFilteredListbox.Items[i]);
|
||||
if fFilteredListbox.SelCount > 0 then
|
||||
for i := 0 to fFilteredListbox.Count-1 do
|
||||
if fFilteredListbox.Selected[i] then
|
||||
fSelectionList.Add(fFilteredListbox.Items[i]);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.RestoreSelection;
|
||||
var
|
||||
i: Integer;
|
||||
clb: TCustomCheckListBox;
|
||||
begin
|
||||
for i := 0 to fFilteredListbox.Count-1 do
|
||||
if fSelectionList.IndexOf(fFilteredListbox.Items[i])>0 then
|
||||
fFilteredListbox.Selected[i]:=True;
|
||||
if fSelectionList.Count > 0 then
|
||||
for i := 0 to fFilteredListbox.Count-1 do
|
||||
if fSelectionList.IndexOf(fFilteredListbox.Items[i]) > -1 then
|
||||
fFilteredListbox.Selected[i]:=True;
|
||||
// Notify the CheckListBox that checked state may have changed.
|
||||
if fFilteredListbox is TCustomCheckListBox then begin
|
||||
clb:=TCustomCheckListBox(fFilteredListbox);
|
||||
if Assigned(clb.OnItemClick) then
|
||||
clb.OnItemClick(clb, -1); // The handler must not use the index -1 directly
|
||||
end;
|
||||
end;
|
||||
|
||||
function TListFilterEdit.GetFirstSelected: Integer;
|
||||
|
@ -1,11 +1,11 @@
|
||||
object EditorFileManagerForm: TEditorFileManagerForm
|
||||
Left = 350
|
||||
Height = 336
|
||||
Top = 652
|
||||
Width = 589
|
||||
Left = 364
|
||||
Height = 380
|
||||
Top = 266
|
||||
Width = 722
|
||||
Caption = 'EditorFileManagerForm'
|
||||
ClientHeight = 336
|
||||
ClientWidth = 589
|
||||
ClientHeight = 380
|
||||
ClientWidth = 722
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.31'
|
||||
@ -16,13 +16,16 @@ object EditorFileManagerForm: TEditorFileManagerForm
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideBottom.Control = ButtonPanel1
|
||||
Left = 6
|
||||
Height = 260
|
||||
Height = 304
|
||||
Top = 30
|
||||
Width = 452
|
||||
Width = 530
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
ItemHeight = 0
|
||||
OnClick = CheckListBox1Click
|
||||
OnDblClick = CheckListBox1DblClick
|
||||
OnItemClick = CheckListBox1ItemClick
|
||||
OnKeyPress = CheckListBox1KeyPress
|
||||
OnKeyDown = CheckListBox1KeyDown
|
||||
PopupMenu = PopupMenu1
|
||||
TabOrder = 0
|
||||
end
|
||||
@ -40,8 +43,8 @@ object EditorFileManagerForm: TEditorFileManagerForm
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 34
|
||||
Top = 296
|
||||
Width = 577
|
||||
Top = 340
|
||||
Width = 710
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
@ -54,71 +57,111 @@ object EditorFileManagerForm: TEditorFileManagerForm
|
||||
ShowButtons = [pbClose, pbHelp]
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 458
|
||||
Height = 290
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ButtonPanel1
|
||||
Left = 536
|
||||
Height = 334
|
||||
Top = 0
|
||||
Width = 131
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
ClientHeight = 290
|
||||
ClientWidth = 131
|
||||
Width = 186
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
ClientHeight = 334
|
||||
ClientWidth = 186
|
||||
TabOrder = 3
|
||||
object ActivateButton: TBitBtn
|
||||
Left = 23
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Panel1
|
||||
Left = 53
|
||||
Height = 24
|
||||
Top = 43
|
||||
Top = 33
|
||||
Width = 81
|
||||
Anchors = []
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 12
|
||||
BorderSpacing.Top = 21
|
||||
BorderSpacing.Around = 11
|
||||
Caption = 'Make Active'
|
||||
Enabled = False
|
||||
OnClick = ActivateButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object SelectAllCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = ActivateButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = -1
|
||||
AnchorSideTop.Control = ActivateButton
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 29
|
||||
Height = 21
|
||||
Top = 112
|
||||
Top = 89
|
||||
Width = 129
|
||||
Anchors = [akLeft]
|
||||
BorderSpacing.Around = 12
|
||||
BorderSpacing.Top = 21
|
||||
BorderSpacing.Around = 11
|
||||
Caption = 'SelectAllCheckBox'
|
||||
OnClick = SelectAllCheckBoxClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object SaveCheckedButton: TBitBtn
|
||||
AnchorSideLeft.Control = ActivateButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = 17
|
||||
AnchorSideTop.Control = SelectAllCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 47
|
||||
Height = 24
|
||||
Top = 152
|
||||
Top = 121
|
||||
Width = 93
|
||||
Anchors = [akLeft]
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 12
|
||||
BorderSpacing.Around = 11
|
||||
Caption = 'Save Checked'
|
||||
Enabled = False
|
||||
OnClick = SaveCheckedButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object CloseCheckedButton: TBitBtn
|
||||
AnchorSideLeft.Control = ActivateButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = 15
|
||||
AnchorSideTop.Control = SaveCheckedButton
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 45
|
||||
Height = 24
|
||||
Top = 200
|
||||
Top = 156
|
||||
Width = 96
|
||||
Anchors = [akLeft]
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 12
|
||||
BorderSpacing.Around = 11
|
||||
Caption = 'Close Checked'
|
||||
Enabled = False
|
||||
OnClick = CloseCheckedButtonClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object MoveUpBtn: TSpeedButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = CloseCheckedButton
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 82
|
||||
Height = 26
|
||||
Top = 204
|
||||
Width = 22
|
||||
BorderSpacing.Top = 24
|
||||
Enabled = False
|
||||
NumGlyphs = 0
|
||||
OnClick = MoveUpBtnClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
object MoveDownBtn: TSpeedButton
|
||||
AnchorSideLeft.Control = MoveUpBtn
|
||||
AnchorSideTop.Control = MoveUpBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 82
|
||||
Height = 26
|
||||
Top = 237
|
||||
Width = 22
|
||||
BorderSpacing.Top = 7
|
||||
Enabled = False
|
||||
NumGlyphs = 0
|
||||
OnClick = MoveDownBtnClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
end
|
||||
end
|
||||
object PopupMenu1: TPopupMenu
|
||||
OnPopup = PopupMenu1Popup
|
||||
|
@ -5,9 +5,9 @@ unit EditorFileManager;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics,
|
||||
Dialogs, CheckLst, ButtonPanel, StdCtrls, Buttons, ExtCtrls, Menus, LCLProc,
|
||||
IDEImagesIntf, LazIDEIntf, SourceEditor, LazarusIDEStrConsts, IDECommands;
|
||||
Classes, ListFilterEdit, Forms, Controls, CheckLst, ButtonPanel, StdCtrls,
|
||||
Buttons, ExtCtrls, Menus, LCLProc, LCLType, IDEImagesIntf, LazIDEIntf,
|
||||
SourceEditor, LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
|
||||
@ -16,6 +16,8 @@ type
|
||||
TEditorFileManagerForm = class(TForm)
|
||||
ActivateMenuItem: TMenuItem;
|
||||
ActivateButton: TBitBtn;
|
||||
MoveDownBtn: TSpeedButton;
|
||||
MoveUpBtn: TSpeedButton;
|
||||
SaveCheckedButton: TBitBtn;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
CloseCheckedButton: TBitBtn;
|
||||
@ -26,6 +28,12 @@ type
|
||||
CheckListBox1: TCheckListBox;
|
||||
FilterEdit: TListFilterEdit;
|
||||
procedure ActivateMenuItemClick(Sender: TObject);
|
||||
procedure CheckListBox1DblClick(Sender: TObject);
|
||||
procedure CheckListBox1KeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
procedure CheckListBox1KeyPress(Sender: TObject; var Key: char);
|
||||
procedure MoveDownBtnClick(Sender: TObject);
|
||||
procedure MoveUpBtnClick(Sender: TObject);
|
||||
procedure CheckListBox1Click(Sender: TObject);
|
||||
procedure CheckListBox1ItemClick(Sender: TObject; Index: integer);
|
||||
procedure CloseCheckedButtonClick(Sender: TObject);
|
||||
@ -38,6 +46,7 @@ type
|
||||
private
|
||||
procedure CloseListItem(ListIndex: integer);
|
||||
procedure UpdateButtons;
|
||||
procedure UpdateMoveButtons(ListIndex: integer);
|
||||
public
|
||||
|
||||
end;
|
||||
@ -82,6 +91,8 @@ begin
|
||||
ActivateButton.Caption:=lisActivateSelected;
|
||||
SaveCheckedButton.Caption:=lisSaveAllChecked;
|
||||
CloseCheckedButton.Caption:=lisCloseAllChecked;
|
||||
MoveUpBtn.Hint:=lisMoveSelectedUp;
|
||||
MoveDownBtn.Hint:=lisMoveSelectedDown;
|
||||
// Icons
|
||||
PopupMenu1.Images:=IDEImages.Images_16;
|
||||
ActivateMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'laz_open');
|
||||
@ -89,12 +100,18 @@ begin
|
||||
ActivateButton.LoadGlyphFromLazarusResource('laz_open');
|
||||
CloseCheckedButton.LoadGlyphFromLazarusResource('menu_close_all');
|
||||
SaveCheckedButton.LoadGlyphFromLazarusResource('menu_save_all');
|
||||
MoveUpBtn.LoadGlyphFromLazarusResource('arrow_up');
|
||||
MoveDownBtn.LoadGlyphFromLazarusResource('arrow_down');
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1Click(Sender: TObject);
|
||||
var
|
||||
clb: TCheckListBox;
|
||||
begin
|
||||
clb:=Sender as TCheckListBox;
|
||||
// Enable ActivateButton when there is a selected item.
|
||||
ActivateButton.Enabled:=(Sender as TCheckListBox).SelCount>0;
|
||||
ActivateButton.Enabled:=clb.SelCount>0;
|
||||
UpdateMoveButtons(clb.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1ItemClick(Sender: TObject; Index: integer);
|
||||
@ -184,6 +201,67 @@ begin
|
||||
ActivateButtonClick(nil);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1DblClick(Sender: TObject);
|
||||
begin
|
||||
ActivateButtonClick(nil);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1KeyDown(Sender: TObject;
|
||||
var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
if (ssCtrl in shift ) and ((Key = VK_UP) or (Key = VK_DOWN)) then begin
|
||||
if Key = VK_UP then
|
||||
MoveUpBtnClick(nil)
|
||||
else
|
||||
MoveDownBtnClick(nil);
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1KeyPress(Sender: TObject; var Key: char);
|
||||
begin
|
||||
if Key = #13 then
|
||||
ActivateButtonClick(nil);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.MoveDownBtnClick(Sender: TObject);
|
||||
var
|
||||
SrcEdit: TSourceEditor;
|
||||
ANoteBook: TSourceNotebook;
|
||||
i: Integer;
|
||||
begin
|
||||
i := CheckListBox1.ItemIndex;
|
||||
if (i > -1) and (i < CheckListBox1.Items.Count-1) and (FilterEdit.Filter='') then begin
|
||||
// First move the source editor tab
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]);
|
||||
ANoteBook:=SrcEdit.SourceNotebook;
|
||||
ANoteBook.NotebookPages.Move(SrcEdit.PageIndex, SrcEdit.PageIndex+1);
|
||||
// Then switch the list items
|
||||
FilterEdit.Data.Exchange(i, i+1); // CheckListBox1.Items.Exchange(i, i+1);
|
||||
FilterEdit.InvalidateFilter;
|
||||
UpdateMoveButtons(i+1);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.MoveUpBtnClick(Sender: TObject);
|
||||
var
|
||||
SrcEdit: TSourceEditor;
|
||||
ANoteBook: TSourceNotebook;
|
||||
i: Integer;
|
||||
begin
|
||||
i := CheckListBox1.ItemIndex;
|
||||
if (i > 0) and (FilterEdit.Filter='') then begin
|
||||
// First move the source editor tab
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]);
|
||||
ANoteBook:=SrcEdit.SourceNotebook;
|
||||
ANoteBook.NotebookPages.Move(SrcEdit.PageIndex, SrcEdit.PageIndex-1);
|
||||
// Then switch the list items
|
||||
FilterEdit.Data.Exchange(i, i-1);
|
||||
FilterEdit.InvalidateFilter;
|
||||
UpdateMoveButtons(i-1);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.ActivateButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
@ -221,5 +299,12 @@ begin
|
||||
CheckListBox1ItemClick(CheckListBox1, 0);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.UpdateMoveButtons(ListIndex: integer);
|
||||
begin
|
||||
MoveUpBtn.Enabled := (ListIndex > 0) and (FilterEdit.Filter='');
|
||||
MoveDownBtn.Enabled := (ListIndex > -1) and (ListIndex < CheckListBox1.Items.Count-1)
|
||||
and (FilterEdit.Filter='');
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user