1 /////////////////////////////////////////////////////////////////////////////
2 // Name: configtoolview.h
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _CT_CONFIGTOOLVIEW_H_
13 #define _CT_CONFIGTOOLVIEW_H_
15 #include "wx/docview.h"
16 #include "wx/treectrl.h"
17 #include "wx/fdrepdlg.h"
18 #include "configitem.h"
20 class ctConfigTreeCtrl
;
21 class WXDLLEXPORT wxNotebookEvent
;
28 class ctConfigToolView
: public wxView
30 DECLARE_DYNAMIC_CLASS(ctConfigToolView
)
33 ~ctConfigToolView(){};
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();
45 /// Gets the tree item in sync with the item.
46 void SyncItem(ctConfigTreeCtrl
* treeControl
, ctConfigItem
* item
);
48 /// Add item and its children to the tree
49 void AddItems(ctConfigTreeCtrl
* treeControl
, ctConfigItem
* item
);
52 void OnIconLeftDown(ctConfigTreeCtrl
* treeControl
, ctConfigItem
* item
);
55 void AddItem(ctConfigType type
, const wxString
& msg
);
57 /// Regenerate setup.h and configure command
58 void RegenerateSetup();
62 /// Returns the selected config item, if any.
63 ctConfigItem
* GetSelection();
68 void OnUpdateDisable(wxUpdateUIEvent
& event
);
70 /// Enable add item menu items
71 void OnUpdateAddItem(wxUpdateUIEvent
& event
);
73 /// Add a checkbox item
74 void OnAddCheckBoxItem(wxCommandEvent
& event
);
76 /// Add a radiobutton item
77 void OnAddRadioButtonItem(wxCommandEvent
& event
);
80 void OnAddGroupItem(wxCommandEvent
& event
);
82 /// Add a check group item
83 void OnAddCheckGroupItem(wxCommandEvent
& event
);
85 /// Add a radio group item
86 void OnAddRadioGroupItem(wxCommandEvent
& event
);
89 void OnAddStringItem(wxCommandEvent
& event
);
92 void OnDeleteItem(wxCommandEvent
& event
);
95 void OnRenameItem(wxCommandEvent
& event
);
97 /// Copy an item to the clipboard
98 void OnCopy(wxCommandEvent
& event
);
100 /// Copy an item to the clipboard and cut the item
101 void OnCut(wxCommandEvent
& event
);
103 /// Paste an item from the clipboard to the tree
104 void OnPaste(wxCommandEvent
& event
);
107 void OnItemHelp(wxCommandEvent
& event
);
109 /// Update for copy command
110 void OnUpdateCopy(wxUpdateUIEvent
& event
);
113 void OnUpdateCut(wxUpdateUIEvent
& event
);
116 void OnUpdatePaste(wxUpdateUIEvent
& event
);
118 /// Update for item help
119 void OnUpdateItemHelp(wxUpdateUIEvent
& event
);
121 // Context menu events
123 /// Copy an item to the clipboard
124 void OnContextCopy(wxCommandEvent
& event
);
126 /// Copy an item to the clipboard and cut the item
127 void OnContextCut(wxCommandEvent
& event
);
129 /// Paste an item from the clipboard to the tree
130 void OnContextPasteBefore(wxCommandEvent
& event
);
132 /// Paste an item from the clipboard to the tree
133 void OnContextPasteAfter(wxCommandEvent
& event
);
135 /// Paste an item from the clipboard to the tree
136 void OnContextPasteAsChild(wxCommandEvent
& event
);
138 /// Copy an item to the clipboard
139 void OnUpdateContextCopy(wxUpdateUIEvent
& event
);
141 /// Copy an item to the clipboard and cut the item
142 void OnUpdateContextCut(wxUpdateUIEvent
& event
);
144 /// Paste an item from the clipboard to the tree
145 void OnUpdateContextPasteBefore(wxUpdateUIEvent
& event
);
147 /// Paste an item from the clipboard to the tree
148 void OnUpdateContextPasteAfter(wxUpdateUIEvent
& event
);
150 /// Paste an item from the clipboard to the tree
151 void OnUpdateContextPasteAsChild(wxUpdateUIEvent
& event
);
153 // Custom property events
155 /// Add a custom property
156 void OnAddCustomProperty(wxCommandEvent
& event
);
158 /// Edit a custom property
159 void OnEditCustomProperty(wxCommandEvent
& event
);
161 /// Delete a custom property
162 void OnDeleteCustomProperty(wxCommandEvent
& event
);
164 /// Add a custom property: update event
165 void OnUpdateAddCustomProperty(wxUpdateUIEvent
& event
);
167 /// Edit a custom property: update event
168 void OnUpdateEditCustomProperty(wxUpdateUIEvent
& event
);
170 /// Delete a custom property: update event
171 void OnUpdateDeleteCustomProperty(wxUpdateUIEvent
& event
);
175 /// Regenerate if selected a tab
176 void OnTabSelect(wxNotebookEvent
& event
);
178 /// Saving setup file
179 void OnSaveSetupFile(wxCommandEvent
& event
);
181 /// Save configure command file
182 void OnSaveConfigureCommand(wxCommandEvent
& event
);
184 /// Saving setup file update handler
185 void OnUpdateSaveSetupFile(wxUpdateUIEvent
& event
);
187 /// Save configure command file update handler
188 void OnUpdateSaveConfigureCommand(wxUpdateUIEvent
& event
);
193 void OnFind(wxCommandEvent
& event
);
196 void OnUpdateFind(wxUpdateUIEvent
& event
);
198 // Go (now: save setup.h or configurewx.sh. later: invoke configure/make)
200 /// Save default file type
201 void OnGo(wxCommandEvent
& event
);
204 void OnUpdateGo(wxUpdateUIEvent
& event
);
206 DECLARE_EVENT_TABLE()
214 * Hint to pass to UpdateAllViews
218 // Update hint symbols
222 #define ctValueChanged 3
223 #define ctSelChanged 4
224 #define ctFilenameChanged 5
225 #define ctInitialUpdate 6
228 class ctConfigToolHint
: public wxObject
231 ctConfigToolHint(ctConfigItem
* item
, int op
) { m_item
= item
; m_op
= op
; }
233 ctConfigItem
* m_item
;
238 * ctFindReplaceDialog
241 class ctFindReplaceDialog
: public wxFindReplaceDialog
244 // constructors and destructors
245 ctFindReplaceDialog( wxWindow
* parent
, const wxString
& title
,
248 void OnFind(wxFindDialogEvent
& event
);
249 void OnClose(wxFindDialogEvent
& event
);
251 // If wrap is true, go back to the beginning if at the end of the
253 bool DoFind(const wxString
& textToFind
, bool matchCase
, bool wholeWord
, bool wrap
= true);
255 ctConfigItem
* FindNextItem(ctConfigToolDoc
* doc
,
257 const wxString
& text
,
262 static wxFindReplaceData sm_findData
;
263 static wxString sm_currentItem
; // card name
266 DECLARE_EVENT_TABLE()
270 // _CT_CONFIGTOOLVIEW_H_