File: FXReplaceDialog.h

package info (click to toggle)
gogglesmm 1.2.5-6
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 16,812 kB
  • sloc: cpp: 231,960; ansic: 893; xml: 222; makefile: 33
file content (185 lines) | stat: -rw-r--r-- 6,875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/********************************************************************************
*                                                                               *
*                      T e x t   R e p l a c e   D i a l o g                    *
*                                                                               *
*********************************************************************************
* Copyright (C) 2000,2022 by Jeroen van der Zijp.   All Rights Reserved.        *
*********************************************************************************
* This library is free software; you can redistribute it and/or modify          *
* it under the terms of the GNU Lesser General Public License as published by   *
* the Free Software Foundation; either version 3 of the License, or             *
* (at your option) any later version.                                           *
*                                                                               *
* This library 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 Lesser General Public License for more details.                           *
*                                                                               *
* You should have received a copy of the GNU Lesser General Public License      *
* along with this program.  If not, see <http://www.gnu.org/licenses/>          *
********************************************************************************/
#ifndef FXREPLACEDIALOG_H
#define FXREPLACEDIALOG_H

#ifndef FXDIALOGBOX_H
#include "FXDialogBox.h"
#endif

namespace FX {


class FXButton;
class FXLabel;
class FXTextField;
class FXHorizontalFrame;


/**
* Search and Replace Dialog.
* This dialog allows the user to enter a string or pattern to
* search for, and a replace string to replace the matched contents with.
* Some options can control the search process: case-sensitivity, regular
* expression searches, and search direction (forward or backward).
* For convenience, the most recent search and replace strings are remembered,
* and can be quickly recalled by scrolling back in the respective entry-boxes.
* The flags controlling case-sensitivity, pattern search, and search direction
* are also remembered and will automatically be reinstated when the corresponding
* search string is selected.
* Note, the dialog does not itself perform a search, it just provided a convenient
* entry box for the search and replace parameters.
* A history is kept of past strings and flags that we searched; this can be quickly
* recalled by using the arrow-buttons.
*/
class FXAPI FXReplaceDialog : public FXDialogBox {
  FXDECLARE(FXReplaceDialog)
protected:
  FXLabel           *searchlabel;
  FXTextField       *searchtext;
  FXHorizontalFrame *searchbox;
  FXLabel           *replacelabel;
  FXTextField       *replacetext;
  FXHorizontalFrame *replacebox;
  FXButton          *search;
  FXButton          *replace;
  FXButton          *replacesel;
  FXButton          *replaceall;
  FXButton          *cancel;
  FXString           searchHistory[20]; // Search string history
  FXString           replacHistory[20]; // Replace string history
  FXuint             optionHistory[20]; // Options history
  FXint              activeHistory;     // Current active history index
  FXuint             searchmode;        // Search mode
protected:
  static const FXchar sectionName[];
protected:
  FXReplaceDialog(){}
  void appendHistory(const FXString& pat,const FXString& sub,FXuint opt);
  void loadHistory();
  void saveHistory();
private:
  FXReplaceDialog(const FXReplaceDialog&);
  FXReplaceDialog &operator=(const FXReplaceDialog&);
public:
  long onUpdDir(FXObject*,FXSelector,void*);
  long onCmdDir(FXObject*,FXSelector,void*);
  long onUpdWrap(FXObject*,FXSelector,void*);
  long onCmdWrap(FXObject*,FXSelector,void*);
  long onUpdCase(FXObject*,FXSelector,void*);
  long onCmdCase(FXObject*,FXSelector,void*);
  long onUpdWords(FXObject*,FXSelector,void*);
  long onCmdWords(FXObject*,FXSelector,void*);
  long onUpdRegex(FXObject*,FXSelector,void*);
  long onCmdRegex(FXObject*,FXSelector,void*);
  long onSearchKey(FXObject*,FXSelector,void*);
  long onReplaceKey(FXObject*,FXSelector,void*);
  long onCmdSearchHistUp(FXObject*,FXSelector,void*);
  long onCmdSearchHistDn(FXObject*,FXSelector,void*);
  long onCmdReplaceHistUp(FXObject*,FXSelector,void*);
  long onCmdReplaceHistDn(FXObject*,FXSelector,void*);
  long onWheelSearch(FXObject*,FXSelector,void*);
  long onWheelReplace(FXObject*,FXSelector,void*);
  long onCmdSearch(FXObject*,FXSelector,void*);
  long onUpdSearch(FXObject*,FXSelector,void*);
  long onCmdReplace(FXObject*,FXSelector,void*);
  long onCmdReplaceSel(FXObject*,FXSelector,void*);
  long onCmdReplaceAll(FXObject*,FXSelector,void*);
public:
  enum{
    ID_SEARCH_UP=FXDialogBox::ID_LAST,
    ID_SEARCH_DN,
    ID_REPLACE_UP,
    ID_REPLACE_DN,
    ID_SEARCH,
    ID_SEARCH_NEXT,
    ID_SEARCH_PREV,
    ID_REPLACE,
    ID_REPLACE_SEL,
    ID_REPLACE_ALL,
    ID_DIR,
    ID_CASE,
    ID_WORDS,
    ID_REGEX,
    ID_WRAP,
    ID_SEARCH_TEXT,
    ID_REPLACE_TEXT,
    ID_LAST
    };
public:
  enum {
    DONE          = 0,    /// Cancel search
    SEARCH        = 1,    /// Search for pattern
    REPLACE       = 2,    /// Replace first occurrence
    REPLACE_SEL   = 3,    /// Replace occurrences in selection
    REPLACE_ALL   = 4     /// Replace all occurrences
    };
public:

  /// Construct search and replace dialog box
  FXReplaceDialog(FXWindow* owner,const FXString& caption,FXIcon* ic=nullptr,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);

  /// Set text or pattern to search for
  void setSearchText(const FXString& text);

  /// Return text or pattern the user has entered
  FXString getSearchText() const;

  /// Set replace text
  void setReplaceText(const FXString& text);

  /// Return replace text the user has entered
  FXString getReplaceText() const;

  /// Set search match mode
  void setSearchMode(FXuint mode){ searchmode=mode; }

  /// Return search mode the user has selected
  FXuint getSearchMode() const { return searchmode; }

  /// Change search text color
  void setSearchTextColor(FXColor clr);

  /// Return search text color
  FXColor getSearchTextColor() const;

  /// Change replace text color
  void setReplaceTextColor(FXColor clr);

  /// Return replace text color
  FXColor getReplaceTextColor() const;

  /// Run modal invocation of the dialog
  virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR);

  /// Save to stream
  virtual void save(FXStream& store) const;

  /// Load from stream
  virtual void load(FXStream& store);

  /// Destructor
  virtual ~FXReplaceDialog();
  };

}

#endif