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 FXHorizontalFrame;
35 
36 
53 class FXAPI FXReplaceDialog : public FXDialogBox {
54  FXDECLARE(FXReplaceDialog)
55 protected:
56  FXLabel *searchlabel;
57  FXTextField *searchtext;
58  FXHorizontalFrame *searchbox;
59  FXLabel *replacelabel;
60  FXTextField *replacetext;
61  FXHorizontalFrame *replacebox;
62  FXButton *search;
63  FXButton *replace;
64  FXButton *replacesel;
65  FXButton *replaceall;
66  FXButton *cancel;
67  FXString searchHistory[20]; // Search string history
68  FXString replacHistory[20]; // Replace string history
69  FXuint optionHistory[20]; // Options history
70  FXint activeHistory; // Current active history index
71  FXuint searchmode; // Search mode
72 protected:
73  static const FXchar sectionName[];
74 protected:
75  FXReplaceDialog(){}
76  void appendHistory(const FXString& pat,const FXString& sub,FXuint opt);
77  void loadHistory();
78  void saveHistory();
79 private:
81  FXReplaceDialog &operator=(const FXReplaceDialog&);
82 public:
83  long onUpdDir(FXObject*,FXSelector,void*);
84  long onCmdDir(FXObject*,FXSelector,void*);
85  long onUpdWrap(FXObject*,FXSelector,void*);
86  long onCmdWrap(FXObject*,FXSelector,void*);
87  long onUpdCase(FXObject*,FXSelector,void*);
88  long onCmdCase(FXObject*,FXSelector,void*);
89  long onUpdWords(FXObject*,FXSelector,void*);
90  long onCmdWords(FXObject*,FXSelector,void*);
91  long onUpdRegex(FXObject*,FXSelector,void*);
92  long onCmdRegex(FXObject*,FXSelector,void*);
93  long onSearchKey(FXObject*,FXSelector,void*);
94  long onReplaceKey(FXObject*,FXSelector,void*);
95  long onCmdSearchHistUp(FXObject*,FXSelector,void*);
96  long onCmdSearchHistDn(FXObject*,FXSelector,void*);
97  long onCmdReplaceHistUp(FXObject*,FXSelector,void*);
98  long onCmdReplaceHistDn(FXObject*,FXSelector,void*);
99  long onWheelSearch(FXObject*,FXSelector,void*);
100  long onWheelReplace(FXObject*,FXSelector,void*);
101  long onCmdSearch(FXObject*,FXSelector,void*);
102  long onUpdSearch(FXObject*,FXSelector,void*);
103  long onCmdReplace(FXObject*,FXSelector,void*);
104  long onCmdReplaceSel(FXObject*,FXSelector,void*);
105  long onCmdReplaceAll(FXObject*,FXSelector,void*);
106 public:
107  enum{
108  ID_SEARCH_UP=FXDialogBox::ID_LAST,
109  ID_SEARCH_DN,
110  ID_REPLACE_UP,
111  ID_REPLACE_DN,
112  ID_SEARCH,
113  ID_SEARCH_NEXT,
114  ID_SEARCH_PREV,
115  ID_REPLACE,
116  ID_REPLACE_SEL,
117  ID_REPLACE_ALL,
118  ID_DIR,
119  ID_CASE,
120  ID_WORDS,
121  ID_REGEX,
122  ID_WRAP,
123  ID_SEARCH_TEXT,
124  ID_REPLACE_TEXT,
125  ID_LAST
126  };
127 public:
128  enum {
129  DONE = 0,
130  SEARCH = 1,
131  REPLACE = 2,
132  REPLACE_SEL = 3,
133  REPLACE_ALL = 4
134  };
135 public:
136 
138  FXReplaceDialog(FXWindow* owner,const FXString& caption,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
139 
141  void setSearchText(const FXString& text);
142 
144  FXString getSearchText() const;
145 
147  void setReplaceText(const FXString& text);
148 
150  FXString getReplaceText() const;
151 
153  void setSearchMode(FXuint mode){ searchmode=mode; }
154 
156  FXuint getSearchMode() const { return searchmode; }
157 
159  void setSearchTextColor(FXColor clr);
160 
162  FXColor getSearchTextColor() const;
163 
165  void setReplaceTextColor(FXColor clr);
166 
168  FXColor getReplaceTextColor() const;
169 
171  virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR);
172 
174  virtual void save(FXStream& store) const;
175 
177  virtual void load(FXStream& store);
178 
180  virtual ~FXReplaceDialog();
181  };
182 
183 }
184 
185 #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:156
Search and Replace Dialog.
Definition: FXReplaceDialog.h:53
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
void setSearchMode(FXuint mode)
Set search match mode.
Definition: FXReplaceDialog.h:153
Closes the dialog, accept the entry.
Definition: FXDialogBox.h:51
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp