]> git.saurik.com Git - wxWidgets.git/blob - utils/configtool/src/configtoolview.h
Do a sanity check before reading. Otherwise, if trying to read a duff image file,
[wxWidgets.git] / utils / configtool / src / configtoolview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: configtoolview.h
3 // Purpose: View class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 2003-06-04
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence:
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _CT_CONFIGTOOLVIEW_H_
13 #define _CT_CONFIGTOOLVIEW_H_
14
15 #include "wx/docview.h"
16 #include "wx/treectrl.h"
17 #include "wx/fdrepdlg.h"
18 #include "configitem.h"
19
20 class ctConfigTreeCtrl;
21 class WXDLLEXPORT wxNotebookEvent;
22
23 /*
24 * ctConfigToolView
25 */
26
27 class ctConfigItem;
28 class ctConfigToolView: public wxView
29 {
30 DECLARE_DYNAMIC_CLASS(ctConfigToolView)
31 public:
32 ctConfigToolView(){};
33 ~ctConfigToolView(){};
34
35 //// Overrides
36
37 bool OnCreate(wxDocument *doc, long flags);
38 void OnDraw(wxDC *dc);
39 void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
40 bool OnClose(bool deleteWindow = true);
41 void OnChangeFilename();
42
43 //// Operations
44
45 /// Gets the tree item in sync with the item.
46 void SyncItem(ctConfigTreeCtrl* treeControl, ctConfigItem* item);
47
48 /// Add item and its children to the tree
49 void AddItems(ctConfigTreeCtrl* treeControl, ctConfigItem* item);
50
51 /// Clicked an icon
52 void OnIconLeftDown(ctConfigTreeCtrl* treeControl, ctConfigItem* item);
53
54 /// Add an item
55 void AddItem(ctConfigType type, const wxString& msg);
56
57 /// Regenerate setup.h and configure command
58 void RegenerateSetup();
59
60 //// Accessors
61
62 /// Returns the selected config item, if any.
63 ctConfigItem* GetSelection();
64
65 //// Event handlers
66
67 /// General disabler
68 void OnUpdateDisable(wxUpdateUIEvent& event);
69
70 /// Enable add item menu items
71 void OnUpdateAddItem(wxUpdateUIEvent& event);
72
73 /// Add a checkbox item
74 void OnAddCheckBoxItem(wxCommandEvent& event);
75
76 /// Add a radiobutton item
77 void OnAddRadioButtonItem(wxCommandEvent& event);
78
79 /// Add a group item
80 void OnAddGroupItem(wxCommandEvent& event);
81
82 /// Add a check group item
83 void OnAddCheckGroupItem(wxCommandEvent& event);
84
85 /// Add a radio group item
86 void OnAddRadioGroupItem(wxCommandEvent& event);
87
88 /// Add a string item
89 void OnAddStringItem(wxCommandEvent& event);
90
91 /// Delete an item
92 void OnDeleteItem(wxCommandEvent& event);
93
94 /// Rename an item
95 void OnRenameItem(wxCommandEvent& event);
96
97 /// Copy an item to the clipboard
98 void OnCopy(wxCommandEvent& event);
99
100 /// Copy an item to the clipboard and cut the item
101 void OnCut(wxCommandEvent& event);
102
103 /// Paste an item from the clipboard to the tree
104 void OnPaste(wxCommandEvent& event);
105
106 /// Item help
107 void OnItemHelp(wxCommandEvent& event);
108
109 /// Update for copy command
110 void OnUpdateCopy(wxUpdateUIEvent& event);
111
112 /// Update for cut
113 void OnUpdateCut(wxUpdateUIEvent& event);
114
115 /// Update for paste
116 void OnUpdatePaste(wxUpdateUIEvent& event);
117
118 /// Update for item help
119 void OnUpdateItemHelp(wxUpdateUIEvent& event);
120
121 // Context menu events
122
123 /// Copy an item to the clipboard
124 void OnContextCopy(wxCommandEvent& event);
125
126 /// Copy an item to the clipboard and cut the item
127 void OnContextCut(wxCommandEvent& event);
128
129 /// Paste an item from the clipboard to the tree
130 void OnContextPasteBefore(wxCommandEvent& event);
131
132 /// Paste an item from the clipboard to the tree
133 void OnContextPasteAfter(wxCommandEvent& event);
134
135 /// Paste an item from the clipboard to the tree
136 void OnContextPasteAsChild(wxCommandEvent& event);
137
138 /// Copy an item to the clipboard
139 void OnUpdateContextCopy(wxUpdateUIEvent& event);
140
141 /// Copy an item to the clipboard and cut the item
142 void OnUpdateContextCut(wxUpdateUIEvent& event);
143
144 /// Paste an item from the clipboard to the tree
145 void OnUpdateContextPasteBefore(wxUpdateUIEvent& event);
146
147 /// Paste an item from the clipboard to the tree
148 void OnUpdateContextPasteAfter(wxUpdateUIEvent& event);
149
150 /// Paste an item from the clipboard to the tree
151 void OnUpdateContextPasteAsChild(wxUpdateUIEvent& event);
152
153 // Custom property events
154
155 /// Add a custom property
156 void OnAddCustomProperty(wxCommandEvent& event);
157
158 /// Edit a custom property
159 void OnEditCustomProperty(wxCommandEvent& event);
160
161 /// Delete a custom property
162 void OnDeleteCustomProperty(wxCommandEvent& event);
163
164 /// Add a custom property: update event
165 void OnUpdateAddCustomProperty(wxUpdateUIEvent& event);
166
167 /// Edit a custom property: update event
168 void OnUpdateEditCustomProperty(wxUpdateUIEvent& event);
169
170 /// Delete a custom property: update event
171 void OnUpdateDeleteCustomProperty(wxUpdateUIEvent& event);
172
173 // Notebook events
174
175 /// Regenerate if selected a tab
176 void OnTabSelect(wxNotebookEvent& event);
177
178 /// Saving setup file
179 void OnSaveSetupFile(wxCommandEvent& event);
180
181 /// Save configure command file
182 void OnSaveConfigureCommand(wxCommandEvent& event);
183
184 /// Saving setup file update handler
185 void OnUpdateSaveSetupFile(wxUpdateUIEvent& event);
186
187 /// Save configure command file update handler
188 void OnUpdateSaveConfigureCommand(wxUpdateUIEvent& event);
189
190 // Find
191
192 /// Find text
193 void OnFind(wxCommandEvent& event);
194
195 /// Update find text
196 void OnUpdateFind(wxUpdateUIEvent& event);
197
198 // Go (now: save setup.h or configurewx.sh. later: invoke configure/make)
199
200 /// Save default file type
201 void OnGo(wxCommandEvent& event);
202
203 /// Update
204 void OnUpdateGo(wxUpdateUIEvent& event);
205
206 DECLARE_EVENT_TABLE()
207
208 protected:
209 };
210
211 /*
212 * ctConfigToolHint
213 *
214 * Hint to pass to UpdateAllViews
215 *
216 */
217
218 // Update hint symbols
219 #define ctNoHint 0
220 #define ctAllSaved 1
221 #define ctClear 2
222 #define ctValueChanged 3
223 #define ctSelChanged 4
224 #define ctFilenameChanged 5
225 #define ctInitialUpdate 6
226
227 class ctConfigItem;
228 class ctConfigToolHint: public wxObject
229 {
230 public:
231 ctConfigToolHint(ctConfigItem* item, int op) { m_item = item; m_op = op; }
232
233 ctConfigItem* m_item;
234 int m_op;
235 };
236
237 /*
238 * ctFindReplaceDialog
239 */
240
241 class ctFindReplaceDialog: public wxFindReplaceDialog
242 {
243 public:
244 // constructors and destructors
245 ctFindReplaceDialog( wxWindow* parent, const wxString& title,
246 long style = 0 );
247
248 void OnFind(wxFindDialogEvent& event);
249 void OnClose(wxFindDialogEvent& event);
250
251 // If wrap is true, go back to the beginning if at the end of the
252 // document.
253 bool DoFind(const wxString& textToFind, bool matchCase, bool wholeWord, bool wrap = true);
254
255 ctConfigItem* FindNextItem(ctConfigToolDoc* doc,
256 ctConfigItem* item,
257 const wxString& text,
258 bool matchCase,
259 bool matchWordOnly,
260 bool wrap,
261 bool skipFirst);
262 static wxFindReplaceData sm_findData;
263 static wxString sm_currentItem; // card name
264
265 private:
266 DECLARE_EVENT_TABLE()
267 };
268
269 #endif
270 // _CT_CONFIGTOOLVIEW_H_