]> git.saurik.com Git - wxWidgets.git/blame - utils/configtool/src/configtooldoc.h
Ran bakefile -f autoconf and autoconf.
[wxWidgets.git] / utils / configtool / src / configtooldoc.h
CommitLineData
d7463f75
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: configtooldoc.h
3// Purpose: Document 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_CONFIGTOOLDOC_H_
13#define _CT_CONFIGTOOLDOC_H_
14
d7463f75
JS
15#include "wx/docview.h"
16#include "wx/cmdproc.h"
17
18#include "configitem.h"
19
20class wxSimpleHtmlTag;
61775320 21class ctConfiguration;
d7463f75
JS
22
23/*!
24 * ctConfigToolDoc
25 */
26
27class ctConfigToolDoc: public wxDocument
28{
29 DECLARE_DYNAMIC_CLASS(ctConfigToolDoc)
30public:
31 ctConfigToolDoc();
32 ~ctConfigToolDoc();
33
34//// Overrides
35 virtual bool OnCreate(const wxString& path, long flags);
36 virtual bool OnOpenDocument(const wxString& filename);
37 virtual bool OnSaveDocument(const wxString& filename);
4fe30bce 38 virtual bool OnNewDocument() { return true; }
d7463f75 39 virtual bool OnCloseDocument() ;
be5a51fb 40 virtual bool Save(); // Overridden only to correct bug in wxWidgets, docview.cpp
d7463f75
JS
41
42//// Accessors
43
44 /// Returns the top item.
45 ctConfigItem* GetTopItem() const { return m_topItem; }
46
47 /// Sets the top item.
48 void SetTopItem(ctConfigItem* item) { m_topItem = item; }
49
50 /// Returns the clipboard item.
51 ctConfigItem* GetClipboardItem() const { return m_clipboardItem; }
52
53 /// Sets the clipboard item.
54 void SetClipboardItem(ctConfigItem* item) ;
55
56 /// Clears the clipboard item.
57 void ClearClipboard() ;
58
59 /// Gets the current framework directory
60 wxString GetFrameworkDir(bool makeUnix);
61
62//// Operations
63
64 /// Add items
65 void AddItems();
66
67 /// Delete items
68 void DeleteItems();
69
70 /// Save the settings file
71 bool DoSave(const wxString& filename);
72
73 /// Recursive helper function for file saving
74 bool DoSave(ctConfigItem* item, wxOutputStream& stream, int indent);
75
76 /// Open the settings file
77 bool DoOpen(const wxString& filename);
78
79 /// Helper for file opening.
80 bool DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent);
81
82 /// Refresh dependencies
83 void RefreshDependencies();
84 void RefreshDependencies(ctConfigItem* item);
85
86 /// Clear dependencies
87 void ClearDependencies(ctConfigItem* item);
88
89 /// Generate the text of a setup.h
90 wxString GenerateSetup();
677ded95 91
d7463f75
JS
92 /// Helper function
93 void GenerateSetup(ctConfigItem* item, wxString& str);
677ded95 94
d7463f75
JS
95 /// Generate a configure command
96 wxString GenerateConfigureCommand();
97
98 /// Helper function
99 void GenerateConfigureCommand(ctConfigItem* item, wxString& str);
e7767867
JS
100
101 /// Finds the next item in the tree
102 ctConfigItem* FindNextItem(ctConfigItem* item, bool wrap);
677ded95 103
e7767867
JS
104 /// Finds the next sibling in the tree
105 ctConfigItem* FindNextSibling(ctConfigItem* item);
677ded95 106
d7463f75
JS
107protected:
108 ctConfigItem* m_topItem;
109 ctConfigItem* m_clipboardItem;
110};
111
61775320
JS
112/*!
113 * ctConfiguration is a configuration or a place-holder node within the
114 * hierarchy of configurations.
115 */
116
117class ctConfiguration: public wxObject
118{
119public:
120 /// Ctor and dtor
121 ctConfiguration(ctConfiguration* parent, const wxString& name);
122 ctConfiguration();
123 ~ctConfiguration();
124
125 /// Copy constructor.
677ded95 126 ctConfiguration(const ctConfiguration& configuration) : wxObject()
61775320
JS
127 {
128 (*this) = configuration;
129 }
130
131/// Operations
132
133 /// Assignment operator.
134 void operator= (const ctConfiguration& configuration);
135
136 /// Create a clone
137 ctConfiguration* Clone()
138 {
139 ctConfiguration* configuration = new ctConfiguration;
140 *configuration = *this;
141 return configuration;
142 }
143
144 /// Create a clone of this and children
145 ctConfiguration* DeepClone();
146
147 /// Clear children
148 void Clear();
149
150 /// Add a child
151 void AddChild(ctConfiguration* config);
152
153 /// Remove (but don't delete) a child
154 void RemoveChild(ctConfiguration* config);
155
156 /// Find an item in this hierarchy
157 ctConfiguration* FindConfiguration(const wxString& name);
158
159 /// Find the next sibling
160 ctConfiguration* FindNextSibling();
161
162 /// Find the previous sibling
163 ctConfiguration* FindPreviousSibling();
164
165 /// Detach: remove from parent, and remove tree items
166 void Detach();
167
168 /// Attach: insert before the given position
169 void Attach(ctConfiguration* parent, ctConfiguration* insertbefore);
170
171 void DetachFromTree();
172
173/// Accessors
174
175 /// Returns the top-level item.
176 ctConfigItem* GetTopItem() const { return m_topItem; }
177
178 /// Sets the top-level item.
179 void SetTopItem(ctConfigItem* item) { m_topItem = item; }
180
181 /// Returns the name.
182 wxString GetName() const { return m_name; }
183
184 /// Sets the name.
185 void SetName(const wxString& name ) { m_name = name; }
186
187 /// Get description.
188 wxString GetDescription() const { return m_description; }
189
190 /// Set description.
191 void SetDescription(const wxString& descr) { m_description = descr; }
192
193 /// Set the tree item id
194 void SetTreeItem(wxTreeItemId id) { m_treeItemId = id; }
195
196 // Get the type
197 wxTreeItemId GetTreeItemId() const { return m_treeItemId ; }
198
199 /// Get the list of children
200 wxList& GetChildren() { return m_children; }
201
202 /// Get the nth child
203 ctConfiguration* GetChild(int n) const;
204
205 /// Get the child count
206 int GetChildCount() const;
207
208 /// Get the parent
209 ctConfiguration* GetParent() const { return m_parent; }
210
211 /// Set the parent
212 void SetParent(ctConfiguration* parent) { m_parent = parent; }
213
214 /// Get the associated document (currently, assumes
215 /// there's only ever one document active)
216 ctConfigToolDoc* GetDocument() ;
217
218protected:
219
220 /// The corresponding tree item
221 wxTreeItemId m_treeItemId;
222
223 /// The list of children.
224 wxList m_children;
225
226 /// The parent config item
227 ctConfiguration* m_parent;
228
229 /// The name
230 wxString m_name;
231
232 /// The description
233 wxString m_description;
234
235 /// The top-level item of this description, if any
236 ctConfigItem* m_topItem;
237
238DECLARE_CLASS(ctConfiguration)
239};
240
d7463f75
JS
241
242/*!
243 * Implements a document editing command.
244 * We only need to store one state at a time,
245 * since we don't have (or need) multiple selection.
246 */
247
248#define ctCMD_NEW_ELEMENT 1
249#define ctCMD_PASTE 2
250#define ctCMD_CUT 3
251#define ctCMD_APPLY_PROPERTY 4
252
253class ctConfigCommand: public wxCommand
254{
255public:
256 ctConfigCommand(const wxString& name, int cmdId,
257 ctConfigItem* activeState, ctConfigItem* savedState,
258 ctConfigItem* parent = NULL, ctConfigItem* insertBefore = NULL,
4fe30bce 259 bool ignoreFirstTime = false);
d7463f75
JS
260 ctConfigCommand(const wxString& name, int cmdId,
261 ctConfigItem* activeState, ctProperties* properties,
4fe30bce 262 bool ignoreFirstTime = false);
d7463f75
JS
263 ~ctConfigCommand();
264
265 bool Do();
266 bool Undo();
267 bool DoAndUndo(bool doCmd); // Combine Do and Undo into one
677ded95 268
d7463f75
JS
269protected:
270 ctConfigItem* m_activeState;
271 ctConfigItem* m_savedState;
272 ctProperties* m_properties;
273 bool m_ignoreThis; // Ignore 1st Do because we already did it
274 int m_cmdId;
275 ctConfigItem* m_parent;
276 ctConfigItem* m_insertBefore;
277};
278
279
280#endif
281 // _CT_CONFIGTOOLDOC_H_