]>
Commit | Line | Data |
---|---|---|
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 | ||
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); | |
e7767867 JS |
103 | |
104 | /// Finds the next item in the tree | |
105 | ctConfigItem* FindNextItem(ctConfigItem* item, bool wrap); | |
106 | ||
107 | /// Finds the next sibling in the tree | |
108 | ctConfigItem* FindNextSibling(ctConfigItem* item); | |
d7463f75 JS |
109 | |
110 | protected: | |
111 | ctConfigItem* m_topItem; | |
112 | ctConfigItem* m_clipboardItem; | |
113 | }; | |
114 | ||
115 | ||
116 | /*! | |
117 | * Implements a document editing command. | |
118 | * We only need to store one state at a time, | |
119 | * since we don't have (or need) multiple selection. | |
120 | */ | |
121 | ||
122 | #define ctCMD_NEW_ELEMENT 1 | |
123 | #define ctCMD_PASTE 2 | |
124 | #define ctCMD_CUT 3 | |
125 | #define ctCMD_APPLY_PROPERTY 4 | |
126 | ||
127 | class ctConfigCommand: public wxCommand | |
128 | { | |
129 | public: | |
130 | ctConfigCommand(const wxString& name, int cmdId, | |
131 | ctConfigItem* activeState, ctConfigItem* savedState, | |
132 | ctConfigItem* parent = NULL, ctConfigItem* insertBefore = NULL, | |
133 | bool ignoreFirstTime = FALSE); | |
134 | ctConfigCommand(const wxString& name, int cmdId, | |
135 | ctConfigItem* activeState, ctProperties* properties, | |
136 | bool ignoreFirstTime = FALSE); | |
137 | ~ctConfigCommand(); | |
138 | ||
139 | bool Do(); | |
140 | bool Undo(); | |
141 | bool DoAndUndo(bool doCmd); // Combine Do and Undo into one | |
142 | ||
143 | protected: | |
144 | ctConfigItem* m_activeState; | |
145 | ctConfigItem* m_savedState; | |
146 | ctProperties* m_properties; | |
147 | bool m_ignoreThis; // Ignore 1st Do because we already did it | |
148 | int m_cmdId; | |
149 | ctConfigItem* m_parent; | |
150 | ctConfigItem* m_insertBefore; | |
151 | }; | |
152 | ||
153 | ||
154 | #endif | |
155 | // _CT_CONFIGTOOLDOC_H_ |