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