Added first cut wxWindows Configuration Tool
[wxWidgets.git] / utils / configtool / src / configtooldoc.h
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
15 #ifdef __GNUG__
16 #pragma interface "configtooldoc.cpp"
17 #endif
18
19 #include "wx/docview.h"
20 #include "wx/cmdproc.h"
21
22 #include "configitem.h"
23
24 class wxSimpleHtmlTag;
25
26 /*!
27 * ctConfigToolDoc
28 */
29
30 class ctConfigToolDoc: public wxDocument
31 {
32 DECLARE_DYNAMIC_CLASS(ctConfigToolDoc)
33 public:
34 ctConfigToolDoc();
35 ~ctConfigToolDoc();
36
37 //// Overrides
38 virtual bool OnCreate(const wxString& path, long flags);
39 virtual bool OnOpenDocument(const wxString& filename);
40 virtual bool OnSaveDocument(const wxString& filename);
41 virtual bool OnNewDocument() { return TRUE; }
42 virtual bool OnCloseDocument() ;
43 virtual bool Save(); // Overridden only to correct bug in wxWindows, docview.cpp
44
45 //// Accessors
46
47 /// Returns the top item.
48 ctConfigItem* GetTopItem() const { return m_topItem; }
49
50 /// Sets the top item.
51 void SetTopItem(ctConfigItem* item) { m_topItem = item; }
52
53 /// Returns the clipboard item.
54 ctConfigItem* GetClipboardItem() const { return m_clipboardItem; }
55
56 /// Sets the clipboard item.
57 void SetClipboardItem(ctConfigItem* item) ;
58
59 /// Clears the clipboard item.
60 void ClearClipboard() ;
61
62 /// Gets the current framework directory
63 wxString GetFrameworkDir(bool makeUnix);
64
65 //// Operations
66
67 /// Add items
68 void AddItems();
69
70 /// Delete items
71 void DeleteItems();
72
73 /// Save the settings file
74 bool DoSave(const wxString& filename);
75
76 /// Recursive helper function for file saving
77 bool DoSave(ctConfigItem* item, wxOutputStream& stream, int indent);
78
79 /// Open the settings file
80 bool DoOpen(const wxString& filename);
81
82 /// Helper for file opening.
83 bool DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent);
84
85 /// Refresh dependencies
86 void RefreshDependencies();
87 void RefreshDependencies(ctConfigItem* item);
88
89 /// Clear dependencies
90 void ClearDependencies(ctConfigItem* item);
91
92 /// Generate the text of a setup.h
93 wxString GenerateSetup();
94
95 /// Helper function
96 void GenerateSetup(ctConfigItem* item, wxString& str);
97
98 /// Generate a configure command
99 wxString GenerateConfigureCommand();
100
101 /// Helper function
102 void GenerateConfigureCommand(ctConfigItem* item, wxString& str);
103
104 protected:
105 ctConfigItem* m_topItem;
106 ctConfigItem* m_clipboardItem;
107 };
108
109
110 /*!
111 * Implements a document editing command.
112 * We only need to store one state at a time,
113 * since we don't have (or need) multiple selection.
114 */
115
116 #define ctCMD_NEW_ELEMENT 1
117 #define ctCMD_PASTE 2
118 #define ctCMD_CUT 3
119 #define ctCMD_APPLY_PROPERTY 4
120
121 class ctConfigCommand: public wxCommand
122 {
123 public:
124 ctConfigCommand(const wxString& name, int cmdId,
125 ctConfigItem* activeState, ctConfigItem* savedState,
126 ctConfigItem* parent = NULL, ctConfigItem* insertBefore = NULL,
127 bool ignoreFirstTime = FALSE);
128 ctConfigCommand(const wxString& name, int cmdId,
129 ctConfigItem* activeState, ctProperties* properties,
130 bool ignoreFirstTime = FALSE);
131 ~ctConfigCommand();
132
133 bool Do();
134 bool Undo();
135 bool DoAndUndo(bool doCmd); // Combine Do and Undo into one
136
137 protected:
138 ctConfigItem* m_activeState;
139 ctConfigItem* m_savedState;
140 ctProperties* m_properties;
141 bool m_ignoreThis; // Ignore 1st Do because we already did it
142 int m_cmdId;
143 ctConfigItem* m_parent;
144 ctConfigItem* m_insertBefore;
145 };
146
147
148 #endif
149 // _CT_CONFIGTOOLDOC_H_