]> git.saurik.com Git - wxWidgets.git/blob - include/wx/xrc/xmlres.h
4622b3d8a74a1d78711af473817cd4e7e3657c9e
[wxWidgets.git] / include / wx / xrc / xmlres.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/xrc/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
14 #include "wx/defs.h"
15
16 #if wxUSE_XRC
17
18 #include "wx/string.h"
19 #include "wx/dynarray.h"
20 #include "wx/arrstr.h"
21 #include "wx/datetime.h"
22 #include "wx/list.h"
23 #include "wx/gdicmn.h"
24 #include "wx/filesys.h"
25 #include "wx/bitmap.h"
26 #include "wx/icon.h"
27 #include "wx/artprov.h"
28 #include "wx/colour.h"
29 #include "wx/animate.h"
30 #include "wx/vector.h"
31
32 #include "wx/xrc/xmlreshandler.h"
33
34 class WXDLLIMPEXP_FWD_BASE wxFileName;
35
36 class WXDLLIMPEXP_FWD_CORE wxIconBundle;
37 class WXDLLIMPEXP_FWD_CORE wxImageList;
38 class WXDLLIMPEXP_FWD_CORE wxMenu;
39 class WXDLLIMPEXP_FWD_CORE wxMenuBar;
40 class WXDLLIMPEXP_FWD_CORE wxDialog;
41 class WXDLLIMPEXP_FWD_CORE wxPanel;
42 class WXDLLIMPEXP_FWD_CORE wxWindow;
43 class WXDLLIMPEXP_FWD_CORE wxFrame;
44 class WXDLLIMPEXP_FWD_CORE wxToolBar;
45
46 class WXDLLIMPEXP_FWD_XML wxXmlDocument;
47 class WXDLLIMPEXP_FWD_XML wxXmlNode;
48 class WXDLLIMPEXP_FWD_XRC wxXmlSubclassFactory;
49 class wxXmlSubclassFactories;
50 class wxXmlResourceModule;
51 class wxXmlResourceDataRecords;
52
53 // These macros indicate current version of XML resources (this information is
54 // encoded in root node of XRC file as "version" property).
55 //
56 // Rules for increasing version number:
57 // - change it only if you made incompatible change to the format. Addition
58 // of new attribute to control handler is _not_ incompatible change, because
59 // older versions of the library may ignore it.
60 // - if you change version number, follow these steps:
61 // - set major, minor and release numbers to respective version numbers of
62 // the wxWidgets library (see wx/version.h)
63 // - reset revision to 0 unless the first three are same as before,
64 // in which case you should increase revision by one
65 #define WX_XMLRES_CURRENT_VERSION_MAJOR 2
66 #define WX_XMLRES_CURRENT_VERSION_MINOR 5
67 #define WX_XMLRES_CURRENT_VERSION_RELEASE 3
68 #define WX_XMLRES_CURRENT_VERSION_REVISION 0
69 #define WX_XMLRES_CURRENT_VERSION_STRING wxT("2.5.3.0")
70
71 #define WX_XMLRES_CURRENT_VERSION \
72 (WX_XMLRES_CURRENT_VERSION_MAJOR * 256*256*256 + \
73 WX_XMLRES_CURRENT_VERSION_MINOR * 256*256 + \
74 WX_XMLRES_CURRENT_VERSION_RELEASE * 256 + \
75 WX_XMLRES_CURRENT_VERSION_REVISION)
76
77 enum wxXmlResourceFlags
78 {
79 wxXRC_USE_LOCALE = 1,
80 wxXRC_NO_SUBCLASSING = 2,
81 wxXRC_NO_RELOADING = 4
82 };
83
84 // This class holds XML resources from one or more .xml files
85 // (or derived forms, either binary or zipped -- see manual for
86 // details).
87 class WXDLLIMPEXP_XRC wxXmlResource : public wxObject
88 {
89 public:
90 // Constructor.
91 // Flags: wxXRC_USE_LOCALE
92 // translatable strings will be translated via _()
93 // using the given domain if specified
94 // wxXRC_NO_SUBCLASSING
95 // subclass property of object nodes will be ignored
96 // (useful for previews in XRC editors)
97 // wxXRC_NO_RELOADING
98 // don't check the modification time of the XRC files and
99 // reload them if they have changed on disk
100 wxXmlResource(int flags = wxXRC_USE_LOCALE,
101 const wxString& domain = wxEmptyString);
102
103 // Constructor.
104 // Flags: wxXRC_USE_LOCALE
105 // translatable strings will be translated via _()
106 // using the given domain if specified
107 // wxXRC_NO_SUBCLASSING
108 // subclass property of object nodes will be ignored
109 // (useful for previews in XRC editors)
110 wxXmlResource(const wxString& filemask, int flags = wxXRC_USE_LOCALE,
111 const wxString& domain = wxEmptyString);
112
113 // Destructor.
114 virtual ~wxXmlResource();
115
116 // Loads resources from XML files that match given filemask.
117 // This method understands wxFileSystem URLs if wxUSE_FILESYS.
118 bool Load(const wxString& filemask);
119
120 // Loads resources from single XRC file.
121 bool LoadFile(const wxFileName& file);
122
123 // Loads all XRC files from a directory.
124 bool LoadAllFiles(const wxString& dirname);
125
126 // Unload resource from the given XML file (wildcards not allowed)
127 bool Unload(const wxString& filename);
128
129 // Initialize handlers for all supported controls/windows. This will
130 // make the executable quite big because it forces linking against
131 // most of the wxWidgets library.
132 void InitAllHandlers();
133
134 // Initialize only a specific handler (or custom handler). Convention says
135 // that handler name is equal to the control's name plus 'XmlHandler', for
136 // example wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. The XML resource
137 // compiler (xmlres) can create include file that contains initialization
138 // code for all controls used within the resource.
139 void AddHandler(wxXmlResourceHandler *handler);
140
141 // Add a new handler at the beginning of the handler list
142 void InsertHandler(wxXmlResourceHandler *handler);
143
144 // Removes all handlers
145 void ClearHandlers();
146
147 // Registers subclasses factory for use in XRC. This function is not meant
148 // for public use, please see the comment above wxXmlSubclassFactory
149 // definition.
150 static void AddSubclassFactory(wxXmlSubclassFactory *factory);
151
152 // Loads menu from resource. Returns NULL on failure.
153 wxMenu *LoadMenu(const wxString& name);
154
155 // Loads menubar from resource. Returns NULL on failure.
156 wxMenuBar *LoadMenuBar(wxWindow *parent, const wxString& name);
157
158 // Loads menubar from resource. Returns NULL on failure.
159 wxMenuBar *LoadMenuBar(const wxString& name) { return LoadMenuBar(NULL, name); }
160
161 #if wxUSE_TOOLBAR
162 // Loads a toolbar.
163 wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
164 #endif
165
166 // Loads a dialog. dlg points to parent window (if any).
167 wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
168
169 // Loads a dialog. dlg points to parent window (if any). This form
170 // is used to finish creation of already existing instance (main reason
171 // for this is that you may want to use derived class with new event table)
172 // Example (typical usage):
173 // MyDialog dlg;
174 // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
175 // dlg->ShowModal();
176 bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
177
178 // Loads a panel. panel points to parent window (if any).
179 wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
180
181 // Loads a panel. panel points to parent window (if any). This form
182 // is used to finish creation of already existing instance.
183 bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
184
185 // Loads a frame.
186 wxFrame *LoadFrame(wxWindow* parent, const wxString& name);
187 bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
188
189 // Load an object from the resource specifying both the resource name and
190 // the classname. This lets you load nonstandard container windows.
191 wxObject *LoadObject(wxWindow *parent, const wxString& name,
192 const wxString& classname)
193 {
194 return DoLoadObject(parent, name, classname, false /* !recursive */);
195 }
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,
201 wxWindow *parent,
202 const wxString& name,
203 const wxString& classname)
204 {
205 return DoLoadObject(instance, parent, name, classname, false);
206 }
207
208 // These versions of LoadObject() look for the object with the given name
209 // recursively (breadth first) and can be used to instantiate an individual
210 // control defined anywhere in an XRC file. No check is done that the name
211 // is unique, it's up to the caller to ensure this.
212 wxObject *LoadObjectRecursively(wxWindow *parent,
213 const wxString& name,
214 const wxString& classname)
215 {
216 return DoLoadObject(parent, name, classname, true /* recursive */);
217 }
218
219 bool LoadObjectRecursively(wxObject *instance,
220 wxWindow *parent,
221 const wxString& name,
222 const wxString& classname)
223 {
224 return DoLoadObject(instance, parent, name, classname, true);
225 }
226
227 // Loads a bitmap resource from a file.
228 wxBitmap LoadBitmap(const wxString& name);
229
230 // Loads an icon resource from a file.
231 wxIcon LoadIcon(const wxString& name);
232
233 // Attaches an unknown control to the given panel/window/dialog.
234 // Unknown controls are used in conjunction with <object class="unknown">.
235 bool AttachUnknownControl(const wxString& name, wxWindow *control,
236 wxWindow *parent = NULL);
237
238 // Returns a numeric ID that is equivalent to the string ID used in an XML
239 // resource. If an unknown str_id is requested (i.e. other than wxID_XXX
240 // or integer), a new record is created which associates the given string
241 // with a number. If value_if_not_found == wxID_NONE, the number is obtained via
242 // wxWindow::NewControlId(). Otherwise value_if_not_found is used.
243 // Macro XRCID(name) is provided for convenient use in event tables.
244 static int GetXRCID(const wxString& str_id, int value_if_not_found = wxID_NONE)
245 { return DoGetXRCID(str_id.mb_str(), value_if_not_found); }
246
247 // version for internal use only
248 static int DoGetXRCID(const char *str_id, int value_if_not_found = wxID_NONE);
249
250
251 // Find the string ID with the given numeric value, returns an empty string
252 // if no such ID is found.
253 //
254 // Notice that unlike GetXRCID(), which is fast, this operation is slow as
255 // it checks all the IDs used in XRC.
256 static wxString FindXRCIDById(int numId);
257
258
259 // Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
260 long GetVersion() const { return m_version; }
261
262 // Compares resources version to argument. Returns -1 if resources version
263 // is less than the argument, +1 if greater and 0 if they equal.
264 int CompareVersion(int major, int minor, int release, int revision) const
265 { return GetVersion() -
266 (major*256*256*256 + minor*256*256 + release*256 + revision); }
267
268 //// Singleton accessors.
269
270 // Gets the global resources object or creates one if none exists.
271 static wxXmlResource *Get();
272
273 // Sets the global resources object and returns a pointer to the previous one (may be NULL).
274 static wxXmlResource *Set(wxXmlResource *res);
275
276 // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING.
277 int GetFlags() const { return m_flags; }
278 // Set flags after construction.
279 void SetFlags(int flags) { m_flags = flags; }
280
281 // Get/Set the domain to be passed to the translation functions, defaults
282 // to empty string (no domain).
283 const wxString& GetDomain() const { return m_domain; }
284 void SetDomain(const wxString& domain);
285
286
287 // This function returns the wxXmlNode containing the definition of the
288 // object with the given name or NULL.
289 //
290 // It can be used to access additional information defined in the XRC file
291 // and not used by wxXmlResource itself.
292 const wxXmlNode *GetResourceNode(const wxString& name) const
293 { return GetResourceNodeAndLocation(name, wxString(), true); }
294
295 protected:
296 // reports input error at position 'context'
297 void ReportError(const wxXmlNode *context, const wxString& message);
298
299 // override this in derived class to customize errors reporting
300 virtual void DoReportError(const wxString& xrcFile, const wxXmlNode *position,
301 const wxString& message);
302
303 // Load the contents of a single file and returns its contents as a new
304 // wxXmlDocument (which will be owned by caller) on success or NULL.
305 wxXmlDocument *DoLoadFile(const wxString& file);
306
307 // Scans the resources list for unloaded files and loads them. Also reloads
308 // files that have been modified since last loading.
309 bool UpdateResources();
310
311
312 // Common implementation of GetResourceNode() and FindResource(): searches
313 // all top-level or all (if recursive == true) nodes if all loaded XRC
314 // files and returns the node, if found, as well as the path of the file it
315 // was found in if path is non-NULL
316 wxXmlNode *GetResourceNodeAndLocation(const wxString& name,
317 const wxString& classname,
318 bool recursive = false,
319 wxString *path = NULL) const;
320
321
322 // Note that these functions are used outside of wxWidgets itself, e.g.
323 // there are several known cases of inheriting from wxXmlResource just to
324 // be able to call FindResource() so we keep them for compatibility even if
325 // their names are not really consistent with GetResourceNode() public
326 // function and FindResource() is also non-const because it changes the
327 // current path of m_curFileSystem to ensure that relative paths work
328 // correctly when CreateResFromNode() is called immediately afterwards
329 // (something const public function intentionally does not do)
330
331 // Returns the node containing the resource with the given name and class
332 // name unless it's empty (then any class matches) or NULL if not found.
333 wxXmlNode *FindResource(const wxString& name, const wxString& classname,
334 bool recursive = false);
335
336 // Helper function used by FindResource() to look under the given node.
337 wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name,
338 const wxString& classname, bool recursive) const;
339
340 // Creates a resource from information in the given node
341 // (Uses only 'handlerToUse' if != NULL)
342 wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent,
343 wxObject *instance = NULL,
344 wxXmlResourceHandler *handlerToUse = NULL)
345 {
346 return node ? DoCreateResFromNode(*node, parent, instance, handlerToUse)
347 : NULL;
348 }
349
350 // Helper of Load() and Unload(): returns the URL corresponding to the
351 // given file if it's indeed a file, otherwise returns the original string
352 // unmodified
353 static wxString ConvertFileNameToURL(const wxString& filename);
354
355 // loading resources from archives is impossible without wxFileSystem
356 #if wxUSE_FILESYSTEM
357 // Another helper: detect if the filename is a ZIP or XRS file
358 static bool IsArchive(const wxString& filename);
359 #endif // wxUSE_FILESYSTEM
360
361 private:
362 wxXmlResourceDataRecords& Data() { return *m_data; }
363 const wxXmlResourceDataRecords& Data() const { return *m_data; }
364
365 // the real implementation of CreateResFromNode(): this should be only
366 // called if node is non-NULL
367 wxObject *DoCreateResFromNode(wxXmlNode& node,
368 wxObject *parent,
369 wxObject *instance,
370 wxXmlResourceHandler *handlerToUse = NULL);
371
372 // common part of LoadObject() and LoadObjectRecursively()
373 wxObject *DoLoadObject(wxWindow *parent,
374 const wxString& name,
375 const wxString& classname,
376 bool recursive);
377 bool DoLoadObject(wxObject *instance,
378 wxWindow *parent,
379 const wxString& name,
380 const wxString& classname,
381 bool recursive);
382
383 private:
384 long m_version;
385
386 int m_flags;
387 wxVector<wxXmlResourceHandler*> m_handlers;
388 wxXmlResourceDataRecords *m_data;
389 #if wxUSE_FILESYSTEM
390 wxFileSystem m_curFileSystem;
391 wxFileSystem& GetCurFileSystem() { return m_curFileSystem; }
392 #endif
393
394 // domain to pass to translation functions, if any.
395 wxString m_domain;
396
397 friend class wxXmlResourceHandlerImpl;
398 friend class wxXmlResourceModule;
399 friend class wxIdRangeManager;
400 friend class wxIdRange;
401
402 static wxXmlSubclassFactories *ms_subclassFactories;
403
404 // singleton instance:
405 static wxXmlResource *ms_instance;
406 };
407
408
409 // This macro translates string identifier (as used in XML resource,
410 // e.g. <menuitem id="my_menu">...</menuitem>) to integer id that is needed by
411 // wxWidgets event tables.
412 // Example:
413 // BEGIN_EVENT_TABLE(MyFrame, wxFrame)
414 // EVT_MENU(XRCID("quit"), MyFrame::OnQuit)
415 // EVT_MENU(XRCID("about"), MyFrame::OnAbout)
416 // EVT_MENU(XRCID("new"), MyFrame::OnNew)
417 // EVT_MENU(XRCID("open"), MyFrame::OnOpen)
418 // END_EVENT_TABLE()
419
420 #define XRCID(str_id) \
421 wxXmlResource::DoGetXRCID(str_id)
422
423
424 // This macro returns pointer to particular control in dialog
425 // created using XML resources. You can use it to set/get values from
426 // controls.
427 // Example:
428 // wxDialog dlg;
429 // wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog");
430 // XRCCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value"));
431
432 #define XRCCTRL(window, id, type) \
433 (wxStaticCast((window).FindWindow(XRCID(id)), type))
434
435 // This macro returns pointer to sizer item
436 // Example:
437 //
438 // <object class="spacer" name="area">
439 // <size>400, 300</size>
440 // </object>
441 //
442 // wxSizerItem* item = XRCSIZERITEM(*this, "area")
443
444 #define XRCSIZERITEM(window, id) \
445 ((window).GetSizer() ? (window).GetSizer()->GetItemById(XRCID(id)) : NULL)
446
447
448 // wxXmlResourceHandlerImpl is the back-end of the wxXmlResourceHander class to
449 // really implementing all its functionality. It is defined in the "xrc"
450 // library unlike wxXmlResourceHandler itself which is defined in "core" to
451 // allow inheriting from it in the code from the other libraries too.
452
453 class WXDLLIMPEXP_XRC wxXmlResourceHandlerImpl : public wxXmlResourceHandlerImplBase
454 {
455 public:
456 // Constructor.
457 wxXmlResourceHandlerImpl(wxXmlResourceHandler *handler);
458
459 // Destructor.
460 virtual ~wxXmlResourceHandlerImpl() {}
461
462 // Creates an object (menu, dialog, control, ...) from an XML node.
463 // Should check for validity.
464 // parent is a higher-level object (usually window, dialog or panel)
465 // that is often necessary to create the resource.
466 // If instance is non-NULL it should not create a new instance via 'new' but
467 // should rather use this one, and call its Create method.
468 wxObject *CreateResource(wxXmlNode *node, wxObject *parent,
469 wxObject *instance);
470
471
472 // --- Handy methods:
473
474 // Returns true if the node has a property class equal to classname,
475 // e.g. <object class="wxDialog">.
476 bool IsOfClass(wxXmlNode *node, const wxString& classname) const;
477
478 // Gets node content from wxXML_ENTITY_NODE
479 // The problem is, <tag>content<tag> is represented as
480 // wxXML_ENTITY_NODE name="tag", content=""
481 // |-- wxXML_TEXT_NODE or
482 // wxXML_CDATA_SECTION_NODE name="" content="content"
483 wxString GetNodeContent(const wxXmlNode *node);
484
485 // Check to see if a parameter exists.
486 bool HasParam(const wxString& param);
487
488 // Finds the node or returns NULL.
489 wxXmlNode *GetParamNode(const wxString& param);
490
491 // Finds the parameter value or returns the empty string.
492 wxString GetParamValue(const wxString& param);
493
494 // Returns the parameter value from given node.
495 wxString GetParamValue(const wxXmlNode* node);
496
497 // Gets style flags from text in form "flag | flag2| flag3 |..."
498 // Only understands flags added with AddStyle
499 int GetStyle(const wxString& param = wxT("style"), int defaults = 0);
500
501 // Gets text from param and does some conversions:
502 // - replaces \n, \r, \t by respective chars (according to C syntax)
503 // - replaces _ by & and __ by _ (needed for _File => &File because of XML)
504 // - calls wxGetTranslations (unless disabled in wxXmlResource)
505 wxString GetText(const wxString& param, bool translate = true);
506
507 // Returns the XRCID.
508 int GetID();
509
510 // Returns the resource name.
511 wxString GetName();
512
513 // Gets a bool flag (1, t, yes, on, true are true, everything else is false).
514 bool GetBool(const wxString& param, bool defaultv = false);
515
516 // Gets an integer value from the parameter.
517 long GetLong(const wxString& param, long defaultv = 0);
518
519 // Gets a float value from the parameter.
520 float GetFloat(const wxString& param, float defaultv = 0);
521
522 // Gets colour in HTML syntax (#RRGGBB).
523 wxColour GetColour(const wxString& param, const wxColour& defaultv = wxNullColour);
524
525 // Gets the size (may be in dialog units).
526 wxSize GetSize(const wxString& param = wxT("size"),
527 wxWindow *windowToUse = NULL);
528
529 // Gets the position (may be in dialog units).
530 wxPoint GetPosition(const wxString& param = wxT("pos"));
531
532 // Gets a dimension (may be in dialog units).
533 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0,
534 wxWindow *windowToUse = NULL);
535
536 // Gets a direction, complains if the value is invalid.
537 wxDirection GetDirection(const wxString& param, wxDirection dir = wxLEFT);
538
539 // Gets a bitmap.
540 wxBitmap GetBitmap(const wxString& param = wxT("bitmap"),
541 const wxArtClient& defaultArtClient = wxART_OTHER,
542 wxSize size = wxDefaultSize);
543
544 // Gets a bitmap from an XmlNode.
545 wxBitmap GetBitmap(const wxXmlNode* node,
546 const wxArtClient& defaultArtClient = wxART_OTHER,
547 wxSize size = wxDefaultSize);
548
549 // Gets an icon.
550 wxIcon GetIcon(const wxString& param = wxT("icon"),
551 const wxArtClient& defaultArtClient = wxART_OTHER,
552 wxSize size = wxDefaultSize);
553
554 // Gets an icon from an XmlNode.
555 wxIcon GetIcon(const wxXmlNode* node,
556 const wxArtClient& defaultArtClient = wxART_OTHER,
557 wxSize size = wxDefaultSize);
558
559 // Gets an icon bundle.
560 wxIconBundle GetIconBundle(const wxString& param,
561 const wxArtClient& defaultArtClient = wxART_OTHER);
562
563 // Gets an image list.
564 wxImageList *GetImageList(const wxString& param = wxT("imagelist"));
565
566 #if wxUSE_ANIMATIONCTRL
567 // Gets an animation.
568 wxAnimation GetAnimation(const wxString& param = wxT("animation"));
569 #endif
570
571 // Gets a font.
572 wxFont GetFont(const wxString& param = wxT("font"), wxWindow* parent = NULL);
573
574 // Gets the value of a boolean attribute (only "0" and "1" are valid values)
575 bool GetBoolAttr(const wxString& attr, bool defaultv);
576
577
578 // Sets common window options.
579 void SetupWindow(wxWindow *wnd);
580
581 // Creates children.
582 void CreateChildren(wxObject *parent, bool this_hnd_only = false);
583
584 // Helper function.
585 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
586
587 // Creates a resource from a node.
588 wxObject *CreateResFromNode(wxXmlNode *node,
589 wxObject *parent, wxObject *instance = NULL);
590
591 // helper
592 #if wxUSE_FILESYSTEM
593 wxFileSystem& GetCurFileSystem();
594 #endif
595
596 // reports input error at position 'context'
597 void ReportError(wxXmlNode *context, const wxString& message);
598 // reports input error at m_node
599 void ReportError(const wxString& message);
600 // reports input error when parsing parameter with given name
601 void ReportParamError(const wxString& param, const wxString& message);
602 };
603
604
605 // Programmer-friendly macros for writing XRC handlers:
606
607 #define XRC_MAKE_INSTANCE(variable, classname) \
608 classname *variable = NULL; \
609 if (m_instance) \
610 variable = wxStaticCast(m_instance, classname); \
611 if (!variable) \
612 variable = new classname;
613
614
615 // FIXME -- remove this $%^#$%#$@# as soon as Ron checks his changes in!!
616 WXDLLIMPEXP_XRC void wxXmlInitResourceModule();
617
618
619 // This class is used to create instances of XRC "object" nodes with "subclass"
620 // property. It is _not_ supposed to be used by XRC users, you should instead
621 // register your subclasses via wxWidgets' RTTI mechanism. This class is useful
622 // only for language bindings developer who need a way to implement subclassing
623 // in wxWidgets ports that don't support wxRTTI (e.g. wxPython).
624 class WXDLLIMPEXP_XRC wxXmlSubclassFactory
625 {
626 public:
627 // Try to create instance of given class and return it, return NULL on
628 // failure:
629 virtual wxObject *Create(const wxString& className) = 0;
630 virtual ~wxXmlSubclassFactory() {}
631 };
632
633
634 /* -------------------------------------------------------------------------
635 Backward compatibility macros. Do *NOT* use, they may disappear in future
636 versions of the XRC library!
637 ------------------------------------------------------------------------- */
638
639 #endif // wxUSE_XRC
640
641 #endif // _WX_XMLRES_H_