IDE: Improve EditorMacroListViever.

This commit is contained in:
Juha 2022-03-05 13:31:11 +02:00
parent a1dca01b66
commit 06352700aa
5 changed files with 408 additions and 292 deletions

View File

@ -19,8 +19,7 @@ resourcestring
EMSNotActive = 'Scripting not active. Selftest failed.'; EMSNotActive = 'Scripting not active. Selftest failed.';
EMSNotActiveVerbose = 'EditorMacroScript failed its self-test and is not active. Some macros may not work.'; EMSNotActiveVerbose = 'EditorMacroScript failed its self-test and is not active. Some macros may not work.';
EMSActive = 'Scripting active.'; EMSActive = 'Scripting active.';
EMSPending = 'Scripting not active. Selftest will run next time the IDE is ' EMSPending = 'Scripting not active. Selftest will run next time the IDE is started.';
+'started.';
implementation implementation

View File

@ -1,41 +1,41 @@
object MacroListView: TMacroListView object MacroListView: TMacroListView
Left = 390 Left = 390
Height = 387 Height = 487
Top = 249 Top = 249
Width = 424 Width = 455
Caption = 'MacroListView' Caption = 'MacroListView'
ClientHeight = 387 ClientHeight = 487
ClientWidth = 424 ClientWidth = 455
Constraints.MinHeight = 365 Constraints.MinHeight = 450
Constraints.MinWidth = 300 Constraints.MinWidth = 360
OnActivate = FormActivate OnActivate = FormActivate
OnDeactivate = FormActivate OnDeactivate = FormActivate
LCLVersion = '2.1.0.0' LCLVersion = '2.3.0.0'
object Panel1: TPanel object Panel1: TPanel
AnchorSideRight.Control = pnlButtons AnchorSideRight.Control = pnlButtons
AnchorSideBottom.Control = gbAddMacro
Left = 6 Left = 6
Height = 313 Height = 346
Top = 6 Top = 6
Width = 295 Width = 333
Align = alLeft
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 313 ClientHeight = 346
ClientWidth = 295 ClientWidth = 333
TabOrder = 0 TabOrder = 0
object lbMacroView: TListView object lbMacroView: TListView
Left = 0 Left = 0
Height = 266 Height = 299
Top = 22 Top = 22
Width = 295 Width = 333
Align = alClient Align = alClient
AutoWidthLastColumn = True AutoWidthLastColumn = True
Columns = < Columns = <
item item
Width = 291 Width = 311
end> end>
PopupMenu = PopupMenu1 PopupMenu = PopupMenu1
RowSelect = True RowSelect = True
@ -49,7 +49,7 @@ object MacroListView: TMacroListView
Left = 0 Left = 0
Height = 22 Height = 22
Top = 0 Top = 0
Width = 295 Width = 333
AutoSize = True AutoSize = True
BorderSpacing.InnerBorder = 1 BorderSpacing.InnerBorder = 1
EdgeBorders = [] EdgeBorders = []
@ -69,7 +69,7 @@ object MacroListView: TMacroListView
end end
object tbProject: TToolButton object tbProject: TToolButton
Tag = 1 Tag = 1
Left = 78 Left = 89
Top = 0 Top = 0
Caption = 'tbProject' Caption = 'tbProject'
Grouped = True Grouped = True
@ -78,7 +78,7 @@ object MacroListView: TMacroListView
end end
object tbIDE: TToolButton object tbIDE: TToolButton
Tag = 1 Tag = 1
Left = 142 Left = 161
Top = 0 Top = 0
Caption = 'tbIDE' Caption = 'tbIDE'
Grouped = True Grouped = True
@ -86,14 +86,14 @@ object MacroListView: TMacroListView
Style = tbsCheck Style = tbsCheck
end end
object ToolButton3: TToolButton object ToolButton3: TToolButton
Left = 70 Left = 81
Height = 22 Height = 22
Top = 0 Top = 0
Caption = 'ToolButton3' Caption = 'ToolButton3'
Style = tbsSeparator Style = tbsSeparator
end end
object ToolButton4: TToolButton object ToolButton4: TToolButton
Left = 134 Left = 153
Height = 22 Height = 22
Top = 0 Top = 0
Caption = 'ToolButton4' Caption = 'ToolButton4'
@ -103,8 +103,8 @@ object MacroListView: TMacroListView
object ToolBar2: TToolBar object ToolBar2: TToolBar
Left = 0 Left = 0
Height = 22 Height = 22
Top = 291 Top = 324
Width = 295 Width = 333
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BorderSpacing.Top = 3 BorderSpacing.Top = 3
@ -116,20 +116,19 @@ object MacroListView: TMacroListView
Left = 1 Left = 1
Height = 22 Height = 22
Top = 0 Top = 0
Width = 52 Width = 60
Align = alLeft Align = alLeft
Caption = 'lbMoveTo' Caption = 'lbMoveTo'
Layout = tlCenter Layout = tlCenter
ParentColor = False
end end
object tbMoveProject: TToolButton object tbMoveProject: TToolButton
Left = 53 Left = 61
Top = 0 Top = 0
Caption = 'tbMoveProject' Caption = 'tbMoveProject'
OnClick = tbMoveProjectClick OnClick = tbMoveProjectClick
end end
object tbMoveIDE: TToolButton object tbMoveIDE: TToolButton
Left = 139 Left = 160
Top = 0 Top = 0
Caption = 'tbMoveIDE' Caption = 'tbMoveIDE'
OnClick = tbMoveIDEClick OnClick = tbMoveIDEClick
@ -138,9 +137,9 @@ object MacroListView: TMacroListView
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 34 Height = 42
Top = 347 Top = 439
Width = 412 Width = 443
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
@ -154,187 +153,31 @@ object MacroListView: TMacroListView
ShowButtons = [pbClose, pbHelp] ShowButtons = [pbClose, pbHelp]
end end
object pnlButtons: TPanel object pnlButtons: TPanel
Left = 307 AnchorSideTop.Control = Panel1
Height = 319 AnchorSideRight.Side = asrBottom
Top = 0 Left = 345
Width = 117 Height = 307
Align = alRight Top = 22
Width = 110
Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 16
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 319 ClientHeight = 307
ClientWidth = 117 ClientWidth = 110
Constraints.MinHeight = 250 Constraints.MinHeight = 250
TabOrder = 1 TabOrder = 1
object btnSelect: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = pnlButtons
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 6
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSelect'
OnClick = btnSelectClick
TabOrder = 0
end
object btnRename: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSelect
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 37
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnRename'
OnClick = btnRenameClick
TabOrder = 1
end
object btnPlay: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PanelRepeat
Left = 6
Height = 25
Top = 178
Width = 105
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
Caption = 'btnPlay'
OnClick = btnPlayClick
TabOrder = 5
end
object btnRecord: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnRecordStop
Left = 6
Height = 25
Top = 263
Width = 105
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Caption = 'btnRecord'
OnClick = btnRecordClick
TabOrder = 6
end
object btnRecordStop: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = pnlButtons
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 294
Width = 105
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'btnRecordStop'
OnClick = btnRecordStopClick
TabOrder = 7
end
object btnDelete: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 130
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnDelete'
OnClick = btnDeleteClick
TabOrder = 4
end
object btnSetKeys: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 68
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSetKeys'
OnClick = btnSetKeysClick
TabOrder = 2
end
object btnEdit: TButton
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSetKeys
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 99
Width = 105
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnEdit'
OnClick = btnEditClick
TabOrder = 3
end
object PanelRepeat: TPanel object PanelRepeat: TPanel
AnchorSideLeft.Control = pnlButtons AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnPlay AnchorSideTop.Control = btnPlay
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnRecord
Left = 6 Left = 6
Height = 54 Height = 61
Top = 206 Top = 243
Width = 105 Width = 98
Anchors = [akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 3 BorderSpacing.Top = 3
@ -342,9 +185,9 @@ object MacroListView: TMacroListView
BorderSpacing.Bottom = 3 BorderSpacing.Bottom = 3
BevelOuter = bvNone BevelOuter = bvNone
BorderStyle = bsSingle BorderStyle = bsSingle
ClientHeight = 50 ClientHeight = 59
ClientWidth = 101 ClientWidth = 96
TabOrder = 8 TabOrder = 0
object edRepeat: TSpinEdit object edRepeat: TSpinEdit
AnchorSideLeft.Control = PanelRepeat AnchorSideLeft.Control = PanelRepeat
AnchorSideTop.Control = chkRepeat AnchorSideTop.Control = chkRepeat
@ -352,9 +195,9 @@ object MacroListView: TMacroListView
AnchorSideRight.Control = PanelRepeat AnchorSideRight.Control = PanelRepeat
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 3 Left = 3
Height = 23 Height = 29
Top = 24 Top = 27
Width = 95 Width = 90
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 3 BorderSpacing.Left = 3
BorderSpacing.Top = 3 BorderSpacing.Top = 3
@ -370,11 +213,10 @@ object MacroListView: TMacroListView
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = PanelRepeat AnchorSideRight.Control = PanelRepeat
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edRepeat
Left = 3 Left = 3
Height = 19 Height = 21
Top = 2 Top = 3
Width = 95 Width = 90
Anchors = [akLeft, akRight] Anchors = [akLeft, akRight]
BorderSpacing.Left = 3 BorderSpacing.Left = 3
BorderSpacing.Right = 3 BorderSpacing.Right = 3
@ -383,53 +225,234 @@ object MacroListView: TMacroListView
TabOrder = 1 TabOrder = 1
end end
end end
object btnPlay: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnDelete
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
Left = 6
Height = 33
Top = 207
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 12
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
Caption = 'btnPlay'
OnClick = btnPlayClick
TabOrder = 1
end
object btnDelete: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 162
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnDelete'
OnClick = btnDeleteClick
TabOrder = 2
end
object btnEdit: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSetKeys
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 123
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnEdit'
OnClick = btnEditClick
TabOrder = 3
end
object btnSetKeys: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnRename
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 84
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSetKeys'
OnClick = btnSetKeysClick
TabOrder = 4
end
object btnRename: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = btnSelect
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 45
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnRename'
OnClick = btnRenameClick
TabOrder = 5
end
object btnSelect: TBitBtn
AnchorSideLeft.Control = pnlButtons
AnchorSideTop.Control = pnlButtons
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 6
Width = 98
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'btnSelect'
OnClick = btnSelectClick
TabOrder = 6
end
end end
object PanelWarnings: TPanel object PanelWarnings: TPanel
Left = 0 AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1
Left = 6
Height = 22 Height = 22
Top = 319 Top = 411
Width = 424 Width = 443
Align = alBottom Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 22 ClientHeight = 22
ClientWidth = 424 ClientWidth = 443
TabOrder = 3 TabOrder = 3
Visible = False Visible = False
object LabelWarning: TLabel object LabelWarning: TLabel
AnchorSideTop.Control = PanelWarnings
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = BtnWarnClose
Left = 0 Left = 0
Height = 22 Height = 19
Top = 0 Top = 2
Width = 401 Width = 412
Align = alClient Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 3
Caption = 'LabelWarning'
Font.Color = clRed Font.Color = clRed
ParentColor = False
ParentFont = False ParentFont = False
WordWrap = True WordWrap = True
end end
object PnlWarnClose: TPanel object BtnWarnClose: TSpeedButton
Left = 401 AnchorSideTop.Control = PanelWarnings
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = PanelWarnings
AnchorSideRight.Side = asrBottom
Left = 415
Height = 22 Height = 22
Top = 0 Top = 0
Width = 23 Width = 26
Align = alRight Anchors = [akTop, akRight]
BorderSpacing.Right = 2
OnClick = BtnWarnCloseClick
end
end
object gbAddMacro: TGroupBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlButtons
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PanelWarnings
Left = 6
Height = 56
Top = 355
Width = 449
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 3
Caption = 'gbAddMacro'
ClientHeight = 36
ClientWidth = 447
TabOrder = 4
object btnRecord: TBitBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 6
Height = 33
Top = 0
Width = 76
AutoSize = True AutoSize = True
BevelOuter = bvNone BorderSpacing.Left = 6
ClientHeight = 22 BorderSpacing.Bottom = 3
ClientWidth = 23 Caption = 'btnRecord'
OnClick = btnRecordClick
TabOrder = 0 TabOrder = 0
object BtnWarnClose: TSpeedButton end
Left = 0 object btnRecordStop: TBitBtn
Height = 22 AnchorSideLeft.Control = btnRecord
Top = 0 AnchorSideLeft.Side = asrBottom
Width = 23 AnchorSideTop.Control = btnRecord
OnClick = BtnWarnCloseClick AnchorSideRight.Side = asrBottom
end AnchorSideBottom.Side = asrBottom
Left = 88
Height = 33
Top = 0
Width = 104
AutoSize = True
BorderSpacing.Left = 6
Caption = 'btnRecordStop'
OnClick = btnRecordStopClick
TabOrder = 1
end
object btnAddEditNew: TBitBtn
AnchorSideLeft.Control = btnRecordStop
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnRecordStop
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 219
Height = 33
Top = 0
Width = 109
AutoSize = True
BorderSpacing.Left = 27
Caption = 'btnAddEditNew'
OnClick = btnAddEditNewClick
TabOrder = 2
end end
end end
object PopupMenu1: TPopupMenu object PopupMenu1: TPopupMenu
left = 144 Left = 144
top = 72 Top = 72
object mnExport: TMenuItem object mnExport: TMenuItem
Caption = 'New Item1' Caption = 'New Item1'
OnClick = mnExportClick OnClick = mnExportClick
@ -443,14 +466,14 @@ object MacroListView: TMacroListView
DefaultExt = '.xml' DefaultExt = '.xml'
Filter = 'xml|*.xml|*|*' Filter = 'xml|*.xml|*|*'
Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofViewDetail] Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofViewDetail]
left = 24 Left = 24
top = 56 Top = 56
end end
object OpenDialog1: TOpenDialog object OpenDialog1: TOpenDialog
DefaultExt = '.xml' DefaultExt = '.xml'
Filter = 'xml|*.xml|*|*' Filter = 'xml|*.xml|*|*'
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail] Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 88 Left = 88
top = 64 Top = 64
end end
end end

View File

@ -1,3 +1,26 @@
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
* *
***************************************************************************
Abstract:
A GUI for managing editor macros.
}
unit EditorMacroListViewer; unit EditorMacroListViewer;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
@ -55,7 +78,6 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure AssignEventsFrom(AMacroRecorder: TEditorMacro); override; procedure AssignEventsFrom(AMacroRecorder: TEditorMacro); override;
function AddEditor(AValue: TCustomSynEdit): integer; function AddEditor(AValue: TCustomSynEdit): integer;
procedure Clear; override; procedure Clear; override;
function GetAsSource: String; override; function GetAsSource: String; override;
@ -170,17 +192,19 @@ type
{ TMacroListView } { TMacroListView }
TMacroListView = class(TForm) TMacroListView = class(TForm)
btnEdit: TButton; btnDelete: TBitBtn;
btnSetKeys: TButton; btnEdit: TBitBtn;
btnPlay: TButton; btnPlay: TBitBtn;
btnRecord: TButton; btnRecord: TBitBtn;
btnRecordStop: TButton; btnRecordStop: TBitBtn;
btnDelete: TButton; btnAddEditNew: TBitBtn;
btnSelect: TButton; btnRename: TBitBtn;
btnRename: TButton; btnSelect: TBitBtn;
btnSetKeys: TBitBtn;
BtnWarnClose: TSpeedButton;
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
chkRepeat: TCheckBox; chkRepeat: TCheckBox;
GroupBox1: TGroupBox; gbAddMacro: TGroupBox;
LabelWarning: TLabel; LabelWarning: TLabel;
lbMoveTo: TLabel; lbMoveTo: TLabel;
lbMacroView: TListView; lbMacroView: TListView;
@ -188,7 +212,6 @@ type
mnImport: TMenuItem; mnImport: TMenuItem;
OpenDialog1: TOpenDialog; OpenDialog1: TOpenDialog;
Panel1: TPanel; Panel1: TPanel;
PnlWarnClose: TPanel;
PanelWarnings: TPanel; PanelWarnings: TPanel;
PanelRepeat: TPanel; PanelRepeat: TPanel;
pnlButtons: TPanel; pnlButtons: TPanel;
@ -196,7 +219,6 @@ type
RenameButton: TPanelBitBtn; RenameButton: TPanelBitBtn;
edRepeat: TSpinEdit; edRepeat: TSpinEdit;
SaveDialog1: TSaveDialog; SaveDialog1: TSaveDialog;
BtnWarnClose: TSpeedButton;
ToolBar1: TToolBar; ToolBar1: TToolBar;
tbRecorded: TToolButton; tbRecorded: TToolButton;
tbProject: TToolButton; tbProject: TToolButton;
@ -210,6 +232,7 @@ type
procedure btnEditClick(Sender: TObject); procedure btnEditClick(Sender: TObject);
procedure btnPlayClick(Sender: TObject); procedure btnPlayClick(Sender: TObject);
procedure btnRecordClick(Sender: TObject); procedure btnRecordClick(Sender: TObject);
procedure btnAddEditNewClick(Sender: TObject);
procedure btnRecordStopClick(Sender: TObject); procedure btnRecordStopClick(Sender: TObject);
procedure btnRenameClick(Sender: TObject); procedure btnRenameClick(Sender: TObject);
procedure btnSelectClick(Sender: TObject); procedure btnSelectClick(Sender: TObject);
@ -226,6 +249,7 @@ type
procedure tbProjectClick(Sender: TObject); procedure tbProjectClick(Sender: TObject);
procedure tbRecordedClick(Sender: TObject); procedure tbRecordedClick(Sender: TObject);
private private
FImageReady: Integer;
FImageRec: Integer; FImageRec: Integer;
FImagePlay: Integer; FImagePlay: Integer;
FImageSel: Integer; FImageSel: Integer;
@ -295,22 +319,19 @@ var
const const
GlobalConfFileName = 'EditorMacros.xml'; GlobalConfFileName = 'EditorMacros.xml';
procedure DoMacroListViewerWarningChanged({%H-}Sender: TObject);
begin
if MacroListView = nil then exit;
MacroListView.LabelWarning.Caption := MacroListViewerWarningText;
MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> '';
end;
function MacroListViewer: TMacroListView; function MacroListViewer: TMacroListView;
begin begin
if MacroListView = nil then if MacroListView = nil then
MacroListView := TMacroListView.Create(Application); MacroListView := TMacroListView.Create(Application);
Result := MacroListView; Result := MacroListView;
DoMacroListViewerWarningChanged(nil);
MacroListView.LabelWarning.Caption := MacroListViewerWarningText;
MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> '';
end;
procedure DoMacroListViewerWarningChanged({%H-}ASender: TObject);
begin
if MacroListView <> nil then begin
MacroListView.LabelWarning.Caption := MacroListViewerWarningText;
MacroListView.PanelWarnings.Visible := MacroListViewerWarningText <> '';
end;
end; end;
procedure ShowMacroListViewer; procedure ShowMacroListViewer;
@ -678,7 +699,6 @@ end;
procedure TIdeEditorMacro.Clear; procedure TIdeEditorMacro.Clear;
begin begin
FSynMacro.Clear; FSynMacro.Clear;
DoChanged; DoChanged;
end; end;
@ -1119,7 +1139,8 @@ begin
if se = nil then Exit; if se = nil then Exit;
i := 1; i := 1;
if chkRepeat.Checked then i := edRepeat.Value; if chkRepeat.Checked then
i := edRepeat.Value;
FIsPlaying := True; FIsPlaying := True;
UpdateButtons; UpdateButtons;
@ -1143,12 +1164,11 @@ var
m: TEditorMacro; m: TEditorMacro;
begin begin
if lbMacroView.ItemIndex < 0 then exit; if lbMacroView.ItemIndex < 0 then exit;
if IDEMessageDialog(lisReallyDelete, lisDeleteSelectedMacro, mtConfirmation, [ if IDEMessageDialog(lisReallyDelete, lisDeleteSelectedMacro, mtConfirmation,
mbYes, mbNo]) = mrYes [mbYes, mbNo]) = mrYes
then begin then begin
if SelectedEditorMacro = CurrentEditorMacroList.Macros[lbMacroView.ItemIndex] then begin if SelectedEditorMacro = CurrentEditorMacroList.Macros[lbMacroView.ItemIndex] then
SelectedEditorMacro := nil; SelectedEditorMacro := nil;
end;
m := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex]; m := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex];
CurrentEditorMacroList.Delete(lbMacroView.ItemIndex); CurrentEditorMacroList.Delete(lbMacroView.ItemIndex);
m.Free; m.Free;
@ -1176,8 +1196,14 @@ var
begin begin
se := SourceEditorManagerIntf.ActiveEditor; se := SourceEditorManagerIntf.ActiveEditor;
if se = nil then Exit; if se = nil then Exit;
if CurrentEditorMacroList <> EditorMacroListRec then
begin
tbRecorded.Down := True; // Switch to "recorded" page when recording.
tbRecorded.Click;
end;
lbMacroView.ItemIndex := -1;
if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then if (ActiveEditorMacro = nil) and (EditorMacroForRecording.State = emStopped) then
EditorMacroForRecording.RecordMacro(TCustomSynEdit(se.EditorControl)) EditorMacroForRecording.RecordMacro(se.EditorControl)
else else
if EditorMacroForRecording.State = emRecording then if EditorMacroForRecording.State = emRecording then
EditorMacroForRecording.Pause EditorMacroForRecording.Pause
@ -1191,6 +1217,30 @@ procedure TMacroListView.btnRecordStopClick(Sender: TObject);
begin begin
FIsPlaying := False; FIsPlaying := False;
EditorMacroForRecording.Stop; EditorMacroForRecording.Stop;
UpdateButtons;
end;
procedure TMacroListView.btnAddEditNewClick(Sender: TObject);
var
se: TSourceEditorInterface;
M: TEditorMacro;
begin
se := SourceEditorManagerIntf.ActiveEditor;
Assert(Assigned(se) and (ActiveEditorMacro=nil) and (EditorMacroForRecording.State=emStopped),
'TMacroListView.btnAddEditNewClick: Problem');
lbMacroView.ItemIndex := -1;
M := TIdeEditorMacro.Create(nil);
M.OnStateChange := @MacroListViewer.DoMacroStateChanged;
M.OnChange := @MacroListViewer.DoMacroContentChanged;
M.MacroName := Format(lisNewMacroName, [MacroRecCounter]);
inc(MacroRecCounter);
CurrentEditorMacroList.Add(M);
Assert(not FIsPlaying, 'TMacroListView.btnAddEditNewClick: IsPlaying');
LazarusIDE.DoOpenEditorFile(
EditorMacroVirtualDrive+MacroListToName(CurrentEditorMacroList)+'|'+M.MacroName,
-1, -1, [ofVirtualFile, ofInternalFile]);
UpdateDisplay;
end; end;
procedure TMacroListView.btnSelectClick(Sender: TObject); procedure TMacroListView.btnSelectClick(Sender: TObject);
@ -1239,7 +1289,9 @@ end;
procedure TMacroListView.FormActivate(Sender: TObject); procedure TMacroListView.FormActivate(Sender: TObject);
begin begin
lbMacroView.HideSelection := Active; DebugLn(['TMacroListView.FormActivate: Active=', Active]);
lbMacroView.HideSelection := Active; // Active = False always ?
UpdateButtons;
end; end;
procedure TMacroListView.HelpButtonClick(Sender: TObject); procedure TMacroListView.HelpButtonClick(Sender: TObject);
@ -1343,7 +1395,6 @@ end;
procedure TMacroListView.DoOnMacroListChange(Sender: TObject); procedure TMacroListView.DoOnMacroListChange(Sender: TObject);
begin begin
UpdateDisplay; UpdateDisplay;
if Sender = EditorMacroListProj then if Sender = EditorMacroListProj then
Project1.SessionModified := True; Project1.SessionModified := True;
end; end;
@ -1428,14 +1479,24 @@ begin
btnRecord.Enabled := Assigned(SourceEditorManagerIntf.ActiveEditor) btnRecord.Enabled := Assigned(SourceEditorManagerIntf.ActiveEditor)
and (RecState in [emStopped, emRecPaused, emRecording]) and (RecState in [emStopped, emRecPaused, emRecording])
and (not FIsPlaying); and (not FIsPlaying);
btnAddEditNew.Enabled := Assigned(SourceEditorManagerIntf.ActiveEditor)
and (RecState = emStopped) and not FIsPlaying;
btnRecordStop.Enabled := (not IsStopped) or FIsPlaying; btnRecordStop.Enabled := (not IsStopped) or FIsPlaying;
if (RecState = emRecording) then if (RecState = emRecording) then
btnRecord.Caption := lisPause begin
btnRecord.Caption := lisPause;
btnRecord.ImageIndex := FImageRec;
end
else if (RecState = emRecPaused) then else if (RecState = emRecPaused) then
btnRecord.Caption := lisContinue begin
else btnRecord.Caption := lisContinue;
btnRecord.ImageIndex := FImageReady;
end
else begin
btnRecord.Caption := lisRecord; btnRecord.Caption := lisRecord;
btnRecord.ImageIndex := FImageReady;
end;
mnImport.Enabled := IsStopped and (not FIsPlaying); mnImport.Enabled := IsStopped and (not FIsPlaying);
mnExport.Enabled := IsStopped and IsSel and (not FIsPlaying); mnExport.Enabled := IsStopped and IsSel and (not FIsPlaying);
@ -1492,32 +1553,64 @@ begin
tbMoveIDE.Caption := lisIDE; tbMoveIDE.Caption := lisIDE;
lbMoveTo.Caption := lisMoveTo + ' '; // Anchors do not work here. Use spaces. lbMoveTo.Caption := lisMoveTo + ' '; // Anchors do not work here. Use spaces.
// Preloaded images
lbMacroView.SmallImages := IDEImages.Images_16;
FImageReady := IDEImages.LoadImage('InactiveBreakPoint'); // green dot
FImageRec := IDEImages.LoadImage('Record'); // red dot
FImagePlay := IDEImages.LoadImage('menu_run'); // green triangle
FImageSel := IDEImages.LoadImage('arrow_right');
FImageErr := IDEImages.LoadImage('state_error');
// Controls in pnlButtons
btnSelect.Caption := lisMakeCurrent; btnSelect.Caption := lisMakeCurrent;
btnSelect.Images := IDEImages.Images_16;
btnSelect.ImageIndex := IDEImages.LoadImage('btn_ok');
btnRename.Caption := lisRename2; btnRename.Caption := lisRename2;
btnRename.Images := IDEImages.Images_16;
btnRename.ImageIndex := IDEImages.LoadImage('laz_edit');
btnSetKeys.Caption := lisEditKey; btnSetKeys.Caption := lisEditKey;
btnEdit.Caption := lisEdit; btnSetKeys.Images := IDEImages.Images_16;
btnSetKeys.ImageIndex := IDEImages.LoadImage('item_character');
btnEdit.Caption := lisEdit;
btnEdit.Images := IDEImages.Images_16;
btnEdit.ImageIndex := IDEImages.LoadImage('show_source');
btnDelete.Caption := lisDelete; btnDelete.Caption := lisDelete;
btnDelete.Images := IDEImages.Images_16;
btnDelete.ImageIndex := IDEImages.LoadImage('laz_delete');
btnPlay.Caption := lisPlay; btnPlay.Caption := lisPlay;
btnPlay.Images := IDEImages.Images_16;
btnPlay.ImageIndex := IDEImages.LoadImage('menu_run');
chkRepeat.Caption := lisRepeat; chkRepeat.Caption := lisRepeat;
// Add new macro
gbAddMacro.Caption := lisAddNewMacro;
btnRecord.Caption := lisRecord; btnRecord.Caption := lisRecord;
btnRecord.Images := IDEImages.Images_16;
btnRecord.ImageIndex := FImageReady;
btnRecordStop.Caption := lisStop; btnRecordStop.Caption := lisStop;
btnRecordStop.Images := IDEImages.Images_16;
btnRecordStop.ImageIndex := IDEImages.LoadImage('menu_stop');
btnAddEditNew.Caption := lisCreateAndEdit;
btnAddEditNew.Images := IDEImages.Images_16;
btnAddEditNew.ImageIndex := IDEImages.LoadImage('laz_add');
// Warning
BtnWarnClose.Images := IDEImages.Images_16;
BtnWarnClose.ImageIndex := IDEImages.LoadImage('menu_close');
SaveDialog1.Title := lisSaveMacroAs; SaveDialog1.Title := lisSaveMacroAs;
OpenDialog1.Title := lisLoadMacroFrom; OpenDialog1.Title := lisLoadMacroFrom;
mnImport.Caption := lisDlgImport; mnImport.Caption := lisDlgImport;
mnExport.Caption := lisDlgExport; mnExport.Caption := lisDlgExport;
lbMacroView.SmallImages := IDEImages.Images_16;
FImageRec := IDEImages.LoadImage('Record'); // red dot
FImagePlay := IDEImages.LoadImage('menu_run'); // green triangle
FImageSel := IDEImages.LoadImage('arrow_right');
FImageErr := IDEImages.LoadImage('state_error');
FIsPlaying := False;
BtnWarnClose.Images := IDEImages.Images_16;
BtnWarnClose.ImageIndex := IDEImages.LoadImage('menu_close');
UpdateDisplay;
end; end;
destructor TMacroListView.Destroy; destructor TMacroListView.Destroy;

View File

@ -6383,6 +6383,7 @@ resourcestring
lisPlay = 'Play'; lisPlay = 'Play';
lisRecord = 'Record'; lisRecord = 'Record';
lisRepeat = 'Repeat'; lisRepeat = 'Repeat';
lisCreateAndEdit = 'Create and edit';
lisDeleteSelectedMacro = 'Delete selected macro?'; lisDeleteSelectedMacro = 'Delete selected macro?';
lisReallyDelete = 'Really delete?'; lisReallyDelete = 'Really delete?';
lisSaveMacroAs = 'Save macro as'; lisSaveMacroAs = 'Save macro as';

View File

@ -276,8 +276,8 @@ type
procedure EditorMouseMoved(Sender: TObject; Shift: TShiftState; X,Y:Integer); procedure EditorMouseMoved(Sender: TObject; Shift: TShiftState; X,Y:Integer);
procedure EditorMouseDown(Sender: TObject; Button: TMouseButton; procedure EditorMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X,Y: Integer); Shift: TShiftState; X,Y: Integer);
procedure EditorMouseUp(Sender: TObject; Button: TMouseButton; procedure EditorMouseUp(Sender: TObject; {%H-}Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); {%H-}Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState; procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);