Issue #3191: Use some standard TActions to implement a simple search/replace dialog in the popup text editor.

This commit is contained in:
Ansgar Becker
2013-05-28 04:30:35 +00:00
parent 9cf6634426
commit debf37824c
2 changed files with 76 additions and 11 deletions

View File

@ -2,8 +2,8 @@ object frmTextEditor: TfrmTextEditor
Left = 0 Left = 0
Top = 0 Top = 0
Caption = 'Text editor' Caption = 'Text editor'
ClientHeight = 95 ClientHeight = 104
ClientWidth = 253 ClientWidth = 332
Color = clBtnFace Color = clBtnFace
Constraints.MinHeight = 100 Constraints.MinHeight = 100
Constraints.MinWidth = 130 Constraints.MinWidth = 130
@ -19,13 +19,13 @@ object frmTextEditor: TfrmTextEditor
OnDestroy = FormDestroy OnDestroy = FormDestroy
OnShow = FormShow OnShow = FormShow
DesignSize = ( DesignSize = (
253 332
95) 104)
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object lblTextLength: TLabel object lblTextLength: TLabel
Left = 137 Left = 213
Top = 77 Top = 87
Width = 65 Width = 65
Height = 13 Height = 13
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
@ -36,8 +36,8 @@ object frmTextEditor: TfrmTextEditor
object memoText: TMemo object memoText: TMemo
Left = 0 Left = 0
Top = 0 Top = 0
Width = 253 Width = 332
Height = 72 Height = 81
Align = alTop Align = alTop
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
Lines.Strings = ( Lines.Strings = (
@ -50,16 +50,18 @@ object frmTextEditor: TfrmTextEditor
end end
object tlbStandard: TToolBar object tlbStandard: TToolBar
Left = 0 Left = 0
Top = 73 Top = 82
Width = 131 Width = 207
Height = 22 Height = 22
Align = alNone Align = alNone
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True
Caption = 'tlbStandard' Caption = 'tlbStandard'
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
Wrapable = False
object btnWrap: TToolButton object btnWrap: TToolButton
Left = 0 Left = 0
Top = 0 Top = 0
@ -100,6 +102,29 @@ object frmTextEditor: TfrmTextEditor
ImageIndex = 55 ImageIndex = 55
OnClick = btnApplyClick OnClick = btnApplyClick
end end
object btnSeparator1: TToolButton
Left = 130
Top = 0
Width = 8
Caption = 'btnSeparator1'
ImageIndex = 60
Style = tbsSeparator
end
object btnSearchFind: TToolButton
Left = 138
Top = 0
Action = actSearchFind
end
object btnSearchFindNext: TToolButton
Left = 161
Top = 0
Action = actSearchFindNext
end
object btnSearchReplace: TToolButton
Left = 184
Top = 0
Action = actSearchReplace
end
end end
object popupLinebreaks: TPopupMenu object popupLinebreaks: TPopupMenu
Images = MainForm.ImageListMain Images = MainForm.ImageListMain
@ -131,4 +156,29 @@ object frmTextEditor: TfrmTextEditor
OnClick = SelectLinebreaks OnClick = SelectLinebreaks
end end
end end
object ActionList1: TActionList
Images = MainForm.ImageListMain
Left = 64
Top = 16
object actSearchFind: TSearchFind
Category = 'Search'
Caption = '&Find...'
Hint = 'Find|Finds the specified text'
ImageIndex = 30
ShortCut = 16454
end
object actSearchFindNext: TSearchFindNext
Category = 'Search'
Caption = 'Find &Next'
Hint = 'Find Next|Repeats the last find'
ImageIndex = 142
ShortCut = 114
end
object actSearchReplace: TSearchReplace
Category = 'Search'
Caption = '&Replace'
Hint = 'Replace|Replaces specific text with different text'
ImageIndex = 59
end
end
end end

View File

@ -5,7 +5,7 @@ interface
uses uses
Windows, Classes, Graphics, Forms, Controls, StdCtrls, VirtualTrees, Windows, Classes, Graphics, Forms, Controls, StdCtrls, VirtualTrees,
ComCtrls, ToolWin, Dialogs, SysUtils, Menus, ExtDlgs, ComCtrls, ToolWin, Dialogs, SysUtils, Menus, ExtDlgs,
helpers, gnugettext; helpers, gnugettext, ActnList, StdActns;
{$I const.inc} {$I const.inc}
@ -25,6 +25,14 @@ type
menuMacLB: TMenuItem; menuMacLB: TMenuItem;
menuMixedLB: TMenuItem; menuMixedLB: TMenuItem;
menuWideLB: TMenuItem; menuWideLB: TMenuItem;
ActionList1: TActionList;
actSearchFind: TSearchFind;
btnSearchFind: TToolButton;
actSearchFindNext: TSearchFindNext;
actSearchReplace: TSearchReplace;
btnSearchReplace: TToolButton;
btnSearchFindNext: TToolButton;
btnSeparator1: TToolButton;
procedure btnApplyClick(Sender: TObject); procedure btnApplyClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure btnLoadTextClick(Sender: TObject); procedure btnLoadTextClick(Sender: TObject);
@ -163,6 +171,13 @@ end;
procedure TfrmTextEditor.FormCreate(Sender: TObject); procedure TfrmTextEditor.FormCreate(Sender: TObject);
begin begin
InheritFont(Font); InheritFont(Font);
// Use same text properties as in query/find/replace actions
actSearchFind.Caption := MainForm.actQueryFind.Caption;
actSearchFind.Hint := MainForm.actQueryFind.Hint;
actSearchFindNext.Caption := MainForm.actQueryFindAgain.Caption;
actSearchFindNext.Hint := MainForm.actQueryFindAgain.Hint;
actSearchReplace.Caption := MainForm.actQueryReplace.Caption;
actSearchReplace.Hint := MainForm.actQueryReplace.Hint;
TranslateComponent(Self); TranslateComponent(Self);
// Work around broken dropdown toolbutton after translation: // Work around broken dropdown toolbutton after translation:
// https://sourceforge.net/tracker/index.php?func=detail&aid=902470&group_id=74086&atid=539908 // https://sourceforge.net/tracker/index.php?func=detail&aid=902470&group_id=74086&atid=539908