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