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