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,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (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 GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXReplaceDialog.h,v 1.22 2006/01/22 17:58:08 fox Exp $                   *
23 ********************************************************************************/
24 #ifndef FXREPLACEDIALOG_H
25 #define FXREPLACEDIALOG_H
26 
27 #ifndef FXDIALOGBOX_H
28 #include "FXDialogBox.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXButton;
35 class FXLabel;
36 class FXTextField;
37 class FXHorizontalFrame;
38 
39 
40 /// Text replace dialog
41 class FXAPI FXReplaceDialog : public FXDialogBox {
42   FXDECLARE(FXReplaceDialog)
43 protected:
44   FXLabel           *searchlabel;
45   FXTextField       *searchtext;
46   FXHorizontalFrame *searchbox;
47   FXLabel           *replacelabel;
48   FXTextField       *replacetext;
49   FXHorizontalFrame *replacebox;
50   FXButton          *accept;
51   FXButton          *cancel;
52   FXButton          *every;
53   FXuint             searchmode;
54   FXuint             current;
55 protected:
FXReplaceDialog()56   FXReplaceDialog(){}
57   void appendHistory(const FXString& search,const FXString& replace,FXuint mode);
58 private:
59   FXReplaceDialog(const FXReplaceDialog&);
60   FXReplaceDialog &operator=(const FXReplaceDialog&);
61 public:
62   long onCmdAll(FXObject*,FXSelector,void*);
63   long onCmdNext(FXObject*,FXSelector,void*);
64   long onUpdDir(FXObject*,FXSelector,void*);
65   long onCmdDir(FXObject*,FXSelector,void*);
66   long onUpdMode(FXObject*,FXSelector,void*);
67   long onCmdMode(FXObject*,FXSelector,void*);
68   long onSearchKey(FXObject*,FXSelector,void*);
69   long onReplaceKey(FXObject*,FXSelector,void*);
70   long onCmdSearchHist(FXObject*,FXSelector,void*);
71   long onCmdReplaceHist(FXObject*,FXSelector,void*);
72   long onCmdAccept(FXObject*,FXSelector,void*);
73 public:
74   enum{
75     ID_NEXT=FXDialogBox::ID_LAST,
76     ID_PREV,
77     ID_SEARCH_UP,
78     ID_SEARCH_DN,
79     ID_REPLACE_UP,
80     ID_REPLACE_DN,
81     ID_ALL,
82     ID_DIR,
83     ID_SEARCH_TEXT,
84     ID_REPLACE_TEXT,
85     ID_MODE,
86     ID_LAST=ID_MODE+32
87     };
88 public:
89   enum {
90     DONE          = 0,    /// Cancel search
91     SEARCH        = 1,    /// Search first occurrence
92     REPLACE       = 1,    /// Replace first occurrence
93     SEARCH_NEXT   = 2,    /// Search next occurrence
94     REPLACE_NEXT  = 2,    /// Replace next occurrence
95     REPLACE_ALL   = 3     /// Replace all occurrences
96     };
97 public:
98 
99   /// Construct search and replace dialog box
100   FXReplaceDialog(FXWindow* owner,const FXString& caption,FXIcon* ic=NULL,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
101 
102   /// Set text or pattern to search for
103   void setSearchText(const FXString& text);
104 
105   /// Return text or pattern the user has entered
106   FXString getSearchText() const;
107 
108   /// Set replace text
109   void setReplaceText(const FXString& text);
110 
111   /// Return replace text the user has entered
112   FXString getReplaceText() const;
113 
114   /// Set search match mode
setSearchMode(FXuint mode)115   void setSearchMode(FXuint mode){ searchmode=mode; }
116 
117   /// Return search mode the user has selected
getSearchMode()118   FXuint getSearchMode() const { return searchmode; }
119 
120   /// Run modal invocation of the dialog
121   virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR);
122 
123   /// Save to stream
124   virtual void save(FXStream& store) const;
125 
126   /// Load from stream
127   virtual void load(FXStream& store);
128 
129   /// Destructor
130   virtual ~FXReplaceDialog();
131   };
132 
133 }
134 
135 #endif
136