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