]>
Commit | Line | Data |
---|---|---|
56d2f750 | 1 | ///////////////////////////////////////////////////////////////////////////// |
e8a793f0 | 2 | // Name: wx/xrc/xmlres.h |
56d2f750 VS |
3 | // Purpose: XML resources |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2000/03/05 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2000 Vaclav Slavik | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_XMLRES_H_ | |
12 | #define _WX_XMLRES_H_ | |
13 | ||
56d2f750 | 14 | #include "wx/defs.h" |
a1e4ec87 | 15 | |
621be1ec | 16 | #if wxUSE_XRC |
a1e4ec87 | 17 | |
56d2f750 VS |
18 | #include "wx/string.h" |
19 | #include "wx/dynarray.h" | |
20 | #include "wx/datetime.h" | |
8e8a4e85 | 21 | #include "wx/list.h" |
56d2f750 | 22 | #include "wx/gdicmn.h" |
792064e9 VS |
23 | #include "wx/filesys.h" |
24 | #include "wx/bitmap.h" | |
25 | #include "wx/icon.h" | |
af1337b0 | 26 | #include "wx/artprov.h" |
836724c3 | 27 | #include "wx/colour.h" |
56d2f750 | 28 | |
a90d7e68 VS |
29 | #include "wx/xml/xml.h" |
30 | ||
1ad83f6b VS |
31 | class WXDLLEXPORT wxMenu; |
32 | class WXDLLEXPORT wxMenuBar; | |
33 | class WXDLLEXPORT wxDialog; | |
34 | class WXDLLEXPORT wxPanel; | |
35 | class WXDLLEXPORT wxWindow; | |
1486ed87 | 36 | class WXDLLEXPORT wxFrame; |
792064e9 | 37 | class WXDLLEXPORT wxToolBar; |
56d2f750 | 38 | |
30dc3455 VS |
39 | class WXDLLIMPEXP_XRC wxXmlResourceHandler; |
40 | class WXDLLIMPEXP_XRC wxXmlSubclassFactory; | |
41 | class WXDLLIMPEXP_XRC wxXmlSubclassFactoriesList; | |
2b5f62a0 | 42 | class wxXmlResourceModule; |
56d2f750 | 43 | |
56d2f750 | 44 | |
1ce70313 VS |
45 | // These macros indicate current version of XML resources (this information is |
46 | // encoded in root node of XRC file as "version" property). | |
47 | // | |
48 | // Rules for increasing version number: | |
30dc3455 VS |
49 | // - change it only if you made incompatible change to the format. Addition |
50 | // of new attribute to control handler is _not_ incompatible change, because | |
51 | // older versions of the library may ignore it. | |
1ce70313 VS |
52 | // - if you change version number, follow these steps: |
53 | // - set major, minor and release numbers to respective version numbers of | |
be5a51fb | 54 | // the wxWidgets library (see wx/version.h) |
30dc3455 VS |
55 | // - reset revision to 0 unless the first three are same as before, |
56 | // in which case you should increase revision by one | |
1ce70313 | 57 | #define WX_XMLRES_CURRENT_VERSION_MAJOR 2 |
984c33c9 VS |
58 | #define WX_XMLRES_CURRENT_VERSION_MINOR 5 |
59 | #define WX_XMLRES_CURRENT_VERSION_RELEASE 3 | |
60 | #define WX_XMLRES_CURRENT_VERSION_REVISION 0 | |
61 | #define WX_XMLRES_CURRENT_VERSION_STRING _T("2.5.3.0") | |
1ce70313 VS |
62 | |
63 | #define WX_XMLRES_CURRENT_VERSION \ | |
64 | (WX_XMLRES_CURRENT_VERSION_MAJOR * 256*256*256 + \ | |
65 | WX_XMLRES_CURRENT_VERSION_MINOR * 256*256 + \ | |
66 | WX_XMLRES_CURRENT_VERSION_RELEASE * 256 + \ | |
67 | WX_XMLRES_CURRENT_VERSION_REVISION) | |
56d2f750 | 68 | |
30dc3455 | 69 | class WXDLLIMPEXP_XRC wxXmlResourceDataRecord |
56d2f750 | 70 | { |
eb8671f2 | 71 | public: |
87152bb5 VZ |
72 | wxXmlResourceDataRecord() : Doc(NULL) { |
73 | #if wxUSE_DATETIME | |
74 | Time = wxDateTime::Now(); | |
75 | #endif | |
76 | } | |
eb8671f2 VS |
77 | ~wxXmlResourceDataRecord() {delete Doc;} |
78 | ||
79 | wxString File; | |
80 | wxXmlDocument *Doc; | |
87152bb5 | 81 | #if wxUSE_DATETIME |
eb8671f2 | 82 | wxDateTime Time; |
87152bb5 | 83 | #endif |
56d2f750 VS |
84 | }; |
85 | ||
ea89ec17 | 86 | |
30dc3455 VS |
87 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxXmlResourceDataRecord, |
88 | wxXmlResourceDataRecords, | |
89 | WXDLLIMPEXP_XRC); | |
56d2f750 | 90 | |
daa85ee3 VS |
91 | enum wxXmlResourceFlags |
92 | { | |
93 | wxXRC_USE_LOCALE = 1, | |
648db587 VS |
94 | wxXRC_NO_SUBCLASSING = 2, |
95 | wxXRC_NO_RELOADING = 4 | |
daa85ee3 | 96 | }; |
ea89ec17 RD |
97 | |
98 | // This class holds XML resources from one or more .xml files | |
56d2f750 | 99 | // (or derived forms, either binary or zipped -- see manual for |
ea89ec17 | 100 | // details). |
30dc3455 | 101 | class WXDLLIMPEXP_XRC wxXmlResource : public wxObject |
56d2f750 | 102 | { |
eb8671f2 | 103 | public: |
273b399f | 104 | // Constructor. |
daa85ee3 VS |
105 | // Flags: wxXRC_USE_LOCALE |
106 | // translatable strings will be translated via _() | |
107 | // wxXRC_NO_SUBCLASSING | |
108 | // subclass property of object nodes will be ignored | |
109 | // (useful for previews in XRC editors) | |
cd900c59 VZ |
110 | // wxXRC_NO_RELOADING |
111 | // don't check the modification time of the XRC files and | |
112 | // reload them if they have changed on disk | |
daa85ee3 | 113 | wxXmlResource(int flags = wxXRC_USE_LOCALE); |
273b399f JS |
114 | |
115 | // Constructor. | |
116 | // Flags: wxXRC_USE_LOCALE | |
117 | // translatable strings will be translated via _() | |
118 | // wxXRC_NO_SUBCLASSING | |
119 | // subclass property of object nodes will be ignored | |
120 | // (useful for previews in XRC editors) | |
daa85ee3 | 121 | wxXmlResource(const wxString& filemask, int flags = wxXRC_USE_LOCALE); |
273b399f JS |
122 | |
123 | // Destructor. | |
eb8671f2 | 124 | ~wxXmlResource(); |
92e898b0 | 125 | |
eb8671f2 VS |
126 | // Loads resources from XML files that match given filemask. |
127 | // This method understands VFS (see filesys.h). | |
128 | bool Load(const wxString& filemask); | |
129 | ||
60fd818a VZ |
130 | // Unload resource from the given XML file (wildcards not allowed) |
131 | bool Unload(const wxString& filename); | |
132 | ||
eb8671f2 VS |
133 | // Initialize handlers for all supported controls/windows. This will |
134 | // make the executable quite big because it forces linking against | |
be5a51fb | 135 | // most of the wxWidgets library. |
eb8671f2 VS |
136 | void InitAllHandlers(); |
137 | ||
273b399f | 138 | // Initialize only a specific handler (or custom handler). Convention says |
30dc3455 VS |
139 | // that handler name is equal to the control's name plus 'XmlHandler', for |
140 | // example wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. The XML resource | |
141 | // compiler (xmlres) can create include file that contains initialization | |
142 | // code for all controls used within the resource. | |
eb8671f2 VS |
143 | void AddHandler(wxXmlResourceHandler *handler); |
144 | ||
92e898b0 RD |
145 | // Add a new handler at the begining of the handler list |
146 | void InsertHandler(wxXmlResourceHandler *handler); | |
147 | ||
eb8671f2 VS |
148 | // Removes all handlers |
149 | void ClearHandlers(); | |
408ac1b8 | 150 | |
2b5f62a0 VZ |
151 | // Registers subclasses factory for use in XRC. This function is not meant |
152 | // for public use, please see the comment above wxXmlSubclassFactory | |
153 | // definition. | |
154 | static void AddSubclassFactory(wxXmlSubclassFactory *factory); | |
eb8671f2 VS |
155 | |
156 | // Loads menu from resource. Returns NULL on failure. | |
157 | wxMenu *LoadMenu(const wxString& name); | |
158 | ||
159 | // Loads menubar from resource. Returns NULL on failure. | |
4a1b9596 | 160 | wxMenuBar *LoadMenuBar(wxWindow *parent, const wxString& name); |
273b399f JS |
161 | |
162 | // Loads menubar from resource. Returns NULL on failure. | |
4a1b9596 | 163 | wxMenuBar *LoadMenuBar(const wxString& name) { return LoadMenuBar(NULL, name); } |
56d2f750 | 164 | |
792064e9 | 165 | #if wxUSE_TOOLBAR |
273b399f | 166 | // Loads a toolbar. |
eb8671f2 | 167 | wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name); |
792064e9 VS |
168 | #endif |
169 | ||
273b399f JS |
170 | // Loads a dialog. dlg points to parent window (if any). |
171 | wxDialog *LoadDialog(wxWindow *parent, const wxString& name); | |
172 | ||
173 | // Loads a dialog. dlg points to parent window (if any). This form | |
eb8671f2 VS |
174 | // is used to finish creation of already existing instance (main reason |
175 | // for this is that you may want to use derived class with new event table) | |
176 | // Example (typical usage): | |
177 | // MyDialog dlg; | |
178 | // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog"); | |
179 | // dlg->ShowModal(); | |
eb8671f2 VS |
180 | bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name); |
181 | ||
273b399f | 182 | // Loads a panel. panel points to parent window (if any). |
eb8671f2 | 183 | wxPanel *LoadPanel(wxWindow *parent, const wxString& name); |
273b399f JS |
184 | |
185 | // Loads a panel. panel points to parent window (if any). This form | |
186 | // is used to finish creation of already existing instance. | |
eb8671f2 VS |
187 | bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name); |
188 | ||
273b399f | 189 | // Loads a frame. |
92e898b0 | 190 | wxFrame *LoadFrame(wxWindow* parent, const wxString& name); |
eb8671f2 VS |
191 | bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name); |
192 | ||
92e898b0 RD |
193 | // Load an object from the resource specifying both the resource name and |
194 | // the classname. This lets you load nonstandard container windows. | |
195 | wxObject *LoadObject(wxWindow *parent, const wxString& name, | |
196 | const wxString& classname); | |
197 | ||
198 | // Load an object from the resource specifying both the resource name and | |
199 | // the classname. This form lets you finish the creation of an existing | |
200 | // instance. | |
201 | bool LoadObject(wxObject *instance, wxWindow *parent, const wxString& name, | |
202 | const wxString& classname); | |
203 | ||
273b399f | 204 | // Loads a bitmap resource from a file. |
eb8671f2 | 205 | wxBitmap LoadBitmap(const wxString& name); |
273b399f JS |
206 | |
207 | // Loads an icon resource from a file. | |
eb8671f2 | 208 | wxIcon LoadIcon(const wxString& name); |
ea89ec17 | 209 | |
273b399f JS |
210 | // Attaches an unknown control to the given panel/window/dialog. |
211 | // Unknown controls are used in conjunction with <object class="unknown">. | |
e6c3f404 VS |
212 | bool AttachUnknownControl(const wxString& name, wxWindow *control, |
213 | wxWindow *parent = NULL); | |
eb8671f2 | 214 | |
9b2a7469 VZ |
215 | // Returns a numeric ID that is equivalent to the string ID used in an XML |
216 | // resource. If an unknown str_id is requested (i.e. other than wxID_XXX | |
217 | // or integer), a new record is created which associates the given string | |
218 | // with a number. If value_if_not_found == wxID_NONE, the number is obtained via | |
219 | // wxNewId(). Otherwise value_if_not_found is used. | |
220 | // Macro XRCID(name) is provided for convenient use in event tables. | |
221 | static int GetXRCID(const wxChar *str_id, int value_if_not_found = wxID_NONE); | |
ea89ec17 | 222 | |
273b399f | 223 | // Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a). |
1ce70313 | 224 | long GetVersion() const { return m_version; } |
ea89ec17 | 225 | |
1ce70313 VS |
226 | // Compares resources version to argument. Returns -1 if resources version |
227 | // is less than the argument, +1 if greater and 0 if they equal. | |
228 | int CompareVersion(int major, int minor, int release, int revision) const | |
ea89ec17 | 229 | { return GetVersion() - |
1ce70313 | 230 | (major*256*256*256 + minor*256*256 + release*256 + revision); } |
92e898b0 | 231 | |
273b399f | 232 | //// Singleton accessors. |
92e898b0 | 233 | |
273b399f | 234 | // Gets the global resources object or creates one if none exists. |
824e8eaa | 235 | static wxXmlResource *Get(); |
273b399f JS |
236 | |
237 | // Sets the global resources object and returns a pointer to the previous one (may be NULL). | |
824e8eaa | 238 | static wxXmlResource *Set(wxXmlResource *res); |
eb8671f2 | 239 | |
74c107ba | 240 | // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING. |
2b5f62a0 VZ |
241 | int GetFlags() const { return m_flags; } |
242 | // Set flags after construction. | |
243 | void SetFlags(int flags) { m_flags = flags; } | |
74c107ba | 244 | |
eb8671f2 | 245 | protected: |
273b399f | 246 | // Scans the resources list for unloaded files and loads them. Also reloads |
eb8671f2 | 247 | // files that have been modified since last loading. |
d614f51b | 248 | bool UpdateResources(); |
eb8671f2 | 249 | |
273b399f | 250 | // Finds a resource (calls UpdateResources) and returns a node containing it. |
f80ea77b | 251 | wxXmlNode *FindResource(const wxString& name, const wxString& classname, bool recursive = false); |
273b399f JS |
252 | |
253 | // Helper function: finds a resource (calls UpdateResources) and returns a node containing it. | |
47793ab8 | 254 | wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive); |
eb8671f2 | 255 | |
e5db1609 VS |
256 | // Creates a resource from information in the given node |
257 | // (Uses only 'handlerToUse' if != NULL) | |
258 | wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, | |
259 | wxObject *instance = NULL, | |
260 | wxXmlResourceHandler *handlerToUse = NULL); | |
eb8671f2 | 261 | |
60fd818a VZ |
262 | // Helper of Load() and Unload(): returns the URL corresponding to the |
263 | // given file if it's indeed a file, otherwise returns the original string | |
264 | // unmodified | |
265 | static wxString ConvertFileNameToURL(const wxString& filename); | |
266 | ||
267 | // loading resources from archives is impossible without wxFileSystem | |
268 | #if wxUSE_FILESYSTEM | |
269 | // Another helper: detect if the filename is a ZIP or XRS file | |
270 | static bool IsArchive(const wxString& filename); | |
271 | #endif // wxUSE_FILESYSTEM | |
272 | ||
eb8671f2 | 273 | private: |
1ce70313 | 274 | long m_version; |
ea89ec17 | 275 | |
daa85ee3 | 276 | int m_flags; |
8e8a4e85 | 277 | wxList m_handlers; |
eb8671f2 | 278 | wxXmlResourceDataRecords m_data; |
792064e9 | 279 | #if wxUSE_FILESYSTEM |
eb8671f2 VS |
280 | wxFileSystem m_curFileSystem; |
281 | wxFileSystem& GetCurFileSystem() { return m_curFileSystem; } | |
792064e9 VS |
282 | #endif |
283 | ||
eb8671f2 | 284 | friend class wxXmlResourceHandler; |
2b5f62a0 VZ |
285 | friend class wxXmlResourceModule; |
286 | ||
287 | static wxXmlSubclassFactoriesList *ms_subclassFactories; | |
92e898b0 | 288 | |
824e8eaa VS |
289 | // singleton instance: |
290 | static wxXmlResource *ms_instance; | |
56d2f750 VS |
291 | }; |
292 | ||
293 | ||
56d2f750 VS |
294 | // This macro translates string identifier (as used in XML resource, |
295 | // e.g. <menuitem id="my_menu">...</menuitem>) to integer id that is needed by | |
be5a51fb | 296 | // wxWidgets event tables. |
56d2f750 VS |
297 | // Example: |
298 | // BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
5ed345b7 VS |
299 | // EVT_MENU(XRCID("quit"), MyFrame::OnQuit) |
300 | // EVT_MENU(XRCID("about"), MyFrame::OnAbout) | |
301 | // EVT_MENU(XRCID("new"), MyFrame::OnNew) | |
302 | // EVT_MENU(XRCID("open"), MyFrame::OnOpen) | |
ea89ec17 | 303 | // END_EVENT_TABLE() |
45a24817 | 304 | |
5ed345b7 VS |
305 | #define XRCID(str_id) \ |
306 | wxXmlResource::GetXRCID(wxT(str_id)) | |
45a24817 VS |
307 | |
308 | ||
45a24817 VS |
309 | // This macro returns pointer to particular control in dialog |
310 | // created using XML resources. You can use it to set/get values from | |
311 | // controls. | |
312 | // Example: | |
313 | // wxDialog dlg; | |
546b0006 | 314 | // wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog"); |
5ed345b7 | 315 | // XRCCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value")); |
45a24817 | 316 | |
5ed345b7 | 317 | #define XRCCTRL(window, id, type) \ |
ae688b64 | 318 | (wxStaticCast((window).FindWindow(XRCID(id)), type)) |
56d2f750 | 319 | |
273b399f JS |
320 | // wxXmlResourceHandler is an abstract base class for resource handlers |
321 | // capable of creating a control from an XML node. | |
56d2f750 | 322 | |
30dc3455 | 323 | class WXDLLIMPEXP_XRC wxXmlResourceHandler : public wxObject |
56d2f750 | 324 | { |
854e189f | 325 | DECLARE_ABSTRACT_CLASS(wxXmlResourceHandler) |
eb8671f2 | 326 | public: |
273b399f | 327 | // Constructor. |
eb8671f2 | 328 | wxXmlResourceHandler(); |
273b399f JS |
329 | |
330 | // Destructor. | |
eb8671f2 VS |
331 | virtual ~wxXmlResourceHandler() {} |
332 | ||
273b399f | 333 | // Creates an object (menu, dialog, control, ...) from an XML node. |
eb8671f2 | 334 | // Should check for validity. |
273b399f | 335 | // parent is a higher-level object (usually window, dialog or panel) |
3103e8a9 | 336 | // that is often necessary to create the resource. |
273b399f JS |
337 | // If instance is non-NULL it should not create a new instance via 'new' but |
338 | // should rather use this one, and call its Create method. | |
ea89ec17 | 339 | wxObject *CreateResource(wxXmlNode *node, wxObject *parent, |
eb8671f2 VS |
340 | wxObject *instance); |
341 | ||
342 | // This one is called from CreateResource after variables | |
273b399f | 343 | // were filled. |
eb8671f2 VS |
344 | virtual wxObject *DoCreateResource() = 0; |
345 | ||
f80ea77b WS |
346 | // Returns true if it understands this node and can create |
347 | // a resource from it, false otherwise. | |
eb8671f2 VS |
348 | virtual bool CanHandle(wxXmlNode *node) = 0; |
349 | ||
273b399f | 350 | // Sets the parent resource. |
eb8671f2 VS |
351 | void SetParentResource(wxXmlResource *res) { m_resource = res; } |
352 | ||
eb8671f2 | 353 | protected: |
eb8671f2 VS |
354 | wxXmlResource *m_resource; |
355 | wxArrayString m_styleNames; | |
356 | wxArrayInt m_styleValues; | |
357 | ||
358 | // Variables (filled by CreateResource) | |
359 | wxXmlNode *m_node; | |
360 | wxString m_class; | |
361 | wxObject *m_parent, *m_instance; | |
9a8d8c5a | 362 | wxWindow *m_parentAsWindow; |
eb8671f2 VS |
363 | |
364 | // --- Handy methods: | |
365 | ||
273b399f JS |
366 | // Returns true if the node has a property class equal to classname, |
367 | // e.g. <object class="wxDialog">. | |
2d672c46 | 368 | bool IsOfClass(wxXmlNode *node, const wxString& classname); |
eb8671f2 VS |
369 | |
370 | // Gets node content from wxXML_ENTITY_NODE | |
273b399f | 371 | // The problem is, <tag>content<tag> is represented as |
eb8671f2 | 372 | // wxXML_ENTITY_NODE name="tag", content="" |
ea89ec17 | 373 | // |-- wxXML_TEXT_NODE or |
eb8671f2 VS |
374 | // wxXML_CDATA_SECTION_NODE name="" content="content" |
375 | wxString GetNodeContent(wxXmlNode *node); | |
376 | ||
273b399f | 377 | // Check to see if a parameter exists. |
ea89ec17 | 378 | bool HasParam(const wxString& param); |
eb8671f2 | 379 | |
273b399f | 380 | // Finds the node or returns NULL. |
eb8671f2 | 381 | wxXmlNode *GetParamNode(const wxString& param); |
273b399f JS |
382 | |
383 | // Finds the parameter value or returns the empty string. | |
eb8671f2 VS |
384 | wxString GetParamValue(const wxString& param); |
385 | ||
273b399f JS |
386 | // Add a style flag (e.g. wxMB_DOCKABLE) to the list of flags |
387 | // understood by this handler. | |
eb8671f2 VS |
388 | void AddStyle(const wxString& name, int value); |
389 | ||
273b399f | 390 | // Add styles common to all wxWindow-derived classes. |
eb8671f2 VS |
391 | void AddWindowStyles(); |
392 | ||
393 | // Gets style flags from text in form "flag | flag2| flag3 |..." | |
43e8916f | 394 | // Only understands flags added with AddStyle |
eb8671f2 VS |
395 | int GetStyle(const wxString& param = wxT("style"), int defaults = 0); |
396 | ||
273b399f | 397 | // Gets text from param and does some conversions: |
eb8671f2 | 398 | // - replaces \n, \r, \t by respective chars (according to C syntax) |
ee1046d1 | 399 | // - replaces _ by & and __ by _ (needed for _File => &File because of XML) |
eb8671f2 | 400 | // - calls wxGetTranslations (unless disabled in wxXmlResource) |
f80ea77b | 401 | wxString GetText(const wxString& param, bool translate = true); |
eb8671f2 | 402 | |
5ed345b7 | 403 | // Returns the XRCID. |
eb8671f2 | 404 | int GetID(); |
273b399f JS |
405 | |
406 | // Returns the resource name. | |
eb8671f2 VS |
407 | wxString GetName(); |
408 | ||
f80ea77b WS |
409 | // Gets a bool flag (1, t, yes, on, true are true, everything else is false). |
410 | bool GetBool(const wxString& param, bool defaultv = false); | |
eb8671f2 | 411 | |
1df61962 VS |
412 | // Gets an integer value from the parameter. |
413 | long GetLong(const wxString& param, long defaultv = 0); | |
0c00c86f | 414 | |
1df61962 VS |
415 | // Gets a float value from the parameter. |
416 | float GetFloat(const wxString& param, float defaultv = 0); | |
eb8671f2 | 417 | |
273b399f | 418 | // Gets colour in HTML syntax (#RRGGBB). |
984f1d84 | 419 | wxColour GetColour(const wxString& param, const wxColour& defaultv = wxNullColour); |
eb8671f2 | 420 | |
273b399f | 421 | // Gets the size (may be in dialog units). |
0c00c86f VS |
422 | wxSize GetSize(const wxString& param = wxT("size"), |
423 | wxWindow *windowToUse = NULL); | |
273b399f JS |
424 | |
425 | // Gets the position (may be in dialog units). | |
eb8671f2 VS |
426 | wxPoint GetPosition(const wxString& param = wxT("pos")); |
427 | ||
273b399f | 428 | // Gets a dimension (may be in dialog units). |
0c00c86f VS |
429 | wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0, |
430 | wxWindow *windowToUse = NULL); | |
eb8671f2 | 431 | |
273b399f | 432 | // Gets a bitmap. |
1ce70313 | 433 | wxBitmap GetBitmap(const wxString& param = wxT("bitmap"), |
7a442f31 | 434 | const wxArtClient& defaultArtClient = wxART_OTHER, |
eb8671f2 | 435 | wxSize size = wxDefaultSize); |
273b399f JS |
436 | |
437 | // Gets an icon. | |
1ce70313 | 438 | wxIcon GetIcon(const wxString& param = wxT("icon"), |
7a442f31 | 439 | const wxArtClient& defaultArtClient = wxART_OTHER, |
eb8671f2 VS |
440 | wxSize size = wxDefaultSize); |
441 | ||
273b399f | 442 | // Gets a font. |
eb8671f2 VS |
443 | wxFont GetFont(const wxString& param = wxT("font")); |
444 | ||
273b399f | 445 | // Sets common window options. |
eb8671f2 VS |
446 | void SetupWindow(wxWindow *wnd); |
447 | ||
273b399f | 448 | // Creates children. |
f80ea77b | 449 | void CreateChildren(wxObject *parent, bool this_hnd_only = false); |
273b399f JS |
450 | |
451 | // Helper function. | |
eb8671f2 | 452 | void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL); |
273b399f JS |
453 | |
454 | // Creates a resource from a node. | |
ea89ec17 | 455 | wxObject *CreateResFromNode(wxXmlNode *node, |
eb8671f2 VS |
456 | wxObject *parent, wxObject *instance = NULL) |
457 | { return m_resource->CreateResFromNode(node, parent, instance); } | |
458 | ||
459 | // helper | |
150e58d8 | 460 | #if wxUSE_FILESYSTEM |
eb8671f2 | 461 | wxFileSystem& GetCurFileSystem() { return m_resource->GetCurFileSystem(); } |
150e58d8 | 462 | #endif |
56d2f750 VS |
463 | }; |
464 | ||
daa85ee3 VS |
465 | |
466 | // Programmer-friendly macros for writing XRC handlers: | |
467 | ||
468 | #define XRC_ADD_STYLE(style) AddStyle(wxT(#style), style) | |
daa85ee3 VS |
469 | |
470 | #define XRC_MAKE_INSTANCE(variable, classname) \ | |
471 | classname *variable = NULL; \ | |
472 | if (m_instance) \ | |
473 | variable = wxStaticCast(m_instance, classname); \ | |
474 | if (!variable) \ | |
475 | variable = new classname; | |
56d2f750 VS |
476 | |
477 | ||
daa85ee3 | 478 | // FIXME -- remove this $%^#$%#$@# as soon as Ron checks his changes in!! |
408ac1b8 | 479 | WXDLLIMPEXP_XRC void wxXmlInitResourceModule(); |
56d2f750 | 480 | |
546b0006 | 481 | |
2b5f62a0 VZ |
482 | // This class is used to create instances of XRC "object" nodes with "subclass" |
483 | // property. It is _not_ supposed to be used by XRC users, you should instead | |
be5a51fb | 484 | // register your subclasses via wxWidgets' RTTI mechanism. This class is useful |
2b5f62a0 | 485 | // only for language bindings developer who need a way to implement subclassing |
be5a51fb | 486 | // in wxWidgets ports that don't support wxRTTI (e.g. wxPython). |
30dc3455 | 487 | class WXDLLIMPEXP_XRC wxXmlSubclassFactory |
2b5f62a0 VZ |
488 | { |
489 | public: | |
30dc3455 VS |
490 | // Try to create instance of given class and return it, return NULL on |
491 | // failure: | |
2b5f62a0 VZ |
492 | virtual wxObject *Create(const wxString& className) = 0; |
493 | virtual ~wxXmlSubclassFactory() {} | |
494 | }; | |
495 | ||
496 | ||
92e898b0 | 497 | /* ------------------------------------------------------------------------- |
546b0006 VS |
498 | Backward compatibility macros. Do *NOT* use, they may disappear in future |
499 | versions of the XRC library! | |
500 | ------------------------------------------------------------------------- */ | |
cf21abe5 VS |
501 | #if WXWIN_COMPATIBILITY_2_4 |
502 | #define ADD_STYLE XRC_ADD_STYLE | |
503 | #define wxTheXmlResource wxXmlResource::Get() | |
504 | #define XMLID XRCID | |
505 | #define XMLCTRL XRCCTRL | |
506 | #define GetXMLID GetXRCID | |
507 | #endif | |
546b0006 | 508 | |
621be1ec | 509 | #endif // wxUSE_XRC |
546b0006 | 510 | |
56d2f750 | 511 | #endif // _WX_XMLRES_H_ |