Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXReplaceDialog.h
1 /********************************************************************************
2 * *
3 * T e x t R e p l a c e D i a l o g *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2000,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXREPLACEDIALOG_H
22 #define FXREPLACEDIALOG_H
23 
24 #ifndef FXDIALOGBOX_H
25 #include "FXDialogBox.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXButton;
32 class FXLabel;
33 class FXTextField;
34 class FXArrowButton;
35 class FXHorizontalFrame;
36 
37 
54 class FXAPI FXReplaceDialog : public FXDialogBox {
55  FXDECLARE(FXReplaceDialog)
56 protected:
57  FXLabel *searchlabel;
58  FXHorizontalFrame *searchbox;
59  FXTextField *searchtext;
60  FXArrowButton *ar1;
61  FXArrowButton *ar2;
62  FXLabel *replacelabel;
63  FXHorizontalFrame *replacebox;
64  FXTextField *replacetext;
65  FXArrowButton *ar3;
66  FXArrowButton *ar4;
67  FXButton *search;
68  FXButton *replace;
69  FXButton *replacesel;
70  FXButton *replaceall;
71  FXButton *cancel;
72  FXString searchHistory[20]; // Search string history
73  FXString replacHistory[20]; // Replace string history
74  FXuint optionHistory[20]; // Options history
75  FXint activeHistory; // Current active history index
76  FXuint searchmode; // Search mode
77 protected:
78  static const FXchar sectionName[];
79 protected:
80  FXReplaceDialog(){}
81  void appendHistory(const FXString& pat,const FXString& sub,FXuint opt);
82  void loadHistory();
83  void saveHistory();
84 private:
86  FXReplaceDialog &operator=(const FXReplaceDialog&);
87 public:
88  long onUpdDir(FXObject*,FXSelector,void*);
89  long onCmdDir(FXObject*,FXSelector,void*);
90  long onUpdWrap(FXObject*,FXSelector,void*);
91  long onCmdWrap(FXObject*,FXSelector,void*);
92  long onUpdCase(FXObject*,FXSelector,void*);
93  long onCmdCase(FXObject*,FXSelector,void*);
94  long onUpdWords(FXObject*,FXSelector,void*);
95  long onCmdWords(FXObject*,FXSelector,void*);
96  long onUpdRegex(FXObject*,FXSelector,void*);
97  long onCmdRegex(FXObject*,FXSelector,void*);
98  long onSearchKey(FXObject*,FXSelector,void*);
99  long onReplaceKey(FXObject*,FXSelector,void*);
100  long onCmdSearchHistUp(FXObject*,FXSelector,void*);
101  long onCmdSearchHistDn(FXObject*,FXSelector,void*);
102  long onCmdReplaceHistUp(FXObject*,FXSelector,void*);
103  long onCmdReplaceHistDn(FXObject*,FXSelector,void*);
104  long onWheelSearch(FXObject*,FXSelector,void*);
105  long onWheelReplace(FXObject*,FXSelector,void*);
106  long onCmdSearch(FXObject*,FXSelector,void*);
107  long onUpdSearch(FXObject*,FXSelector,void*);
108  long onCmdReplace(FXObject*,FXSelector,void*);
109  long onCmdReplaceSel(FXObject*,FXSelector,void*);
110  long onCmdReplaceAll(FXObject*,FXSelector,void*);
111 public:
112  enum{
113  ID_SEARCH_UP=FXDialogBox::ID_LAST,
114  ID_SEARCH_DN,
115  ID_REPLACE_UP,
116  ID_REPLACE_DN,
117  ID_SEARCH,
118  ID_SEARCH_NEXT,
119  ID_SEARCH_PREV,
120  ID_REPLACE,
121  ID_REPLACE_SEL,
122  ID_REPLACE_ALL,
123  ID_DIR,
124  ID_CASE,
125  ID_WORDS,
126  ID_REGEX,
127  ID_WRAP,
128  ID_SEARCH_TEXT,
129  ID_REPLACE_TEXT,
130  ID_LAST
131  };
132 public:
133  enum {
134  DONE = 0,
135  SEARCH = 1,
136  REPLACE = 2,
137  REPLACE_SEL = 3,
138  REPLACE_ALL = 4
139  };
140 public:
141 
143  FXReplaceDialog(FXWindow* owner,const FXString& caption,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
144 
146  void setSearchText(const FXString& text);
147 
149  FXString getSearchText() const;
150 
152  void setReplaceText(const FXString& text);
153 
155  FXString getReplaceText() const;
156 
158  void setSearchMode(FXuint mode){ searchmode=mode; }
159 
161  FXuint getSearchMode() const { return searchmode; }
162 
164  void setSearchTextColor(FXColor clr);
165 
167  FXColor getSearchTextColor() const;
168 
170  void setReplaceTextColor(FXColor clr);
171 
173  FXColor getReplaceTextColor() const;
174 
176  virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR);
177 
179  virtual void save(FXStream& store) const;
180 
182  virtual void load(FXStream& store);
183 
185  virtual ~FXReplaceDialog();
186  };
187 
188 }
189 
190 #endif
DialogBox window.
Definition: FXDialogBox.h:37
A label widget can be used to place a text and/or icon for explanation purposes.
Definition: FXLabel.h:64
Window is the base class for all widgets in FOX.
Definition: FXWindow.h:130
A button provides a push button, with optional icon and/or text label.
Definition: FXButton.h:70
Horizontal frame layout manager widget is used to automatically place child-windows horizontally from...
Definition: FXHorizontalFrame.h:36
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
A text field is a single-line text entry widget.
Definition: FXTextField.h:63
FXuint getSearchMode() const
Return search mode the user has selected.
Definition: FXReplaceDialog.h:161
Search and Replace Dialog.
Definition: FXReplaceDialog.h:54
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
void setSearchMode(FXuint mode)
Set search match mode.
Definition: FXReplaceDialog.h:158
Closes the dialog, accept the entry.
Definition: FXDialogBox.h:51
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42
Button with an arrow; the arrow can point in any direction.
Definition: FXArrowButton.h:55

Copyright © 1997-2022 Jeroen van der Zijp