1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Wrappers for the XML based Resource system
7 // Created: 4-June-2001
9 // Copyright: (c) 2001 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include "wx/xrc/xmlres.h"
21 //---------------------------------------------------------------------------
24 %include my_typemaps.i
33 //---------------------------------------------------------------------------
35 enum wxXmlResourceFlags
38 wxXRC_NO_SUBCLASSING = 2
42 // This class holds XML resources from one or more .xml files
43 // (or derived forms, either binary or zipped -- see manual for
46 class wxXmlResource : public wxObject
50 // Flags: wxXRC_USE_LOCALE
51 // translatable strings will be translated via _()
52 // wxXRC_NO_SUBCLASSING
53 // subclass property of object nodes will be ignored
54 // (useful for previews in XRC editors)
55 %name(wxXmlResourceEmpty)wxXmlResource(int flags = wxXRC_USE_LOCALE); // TODO, a better %name
58 wxXmlResource(const wxString* filemask, int flags = wxXRC_USE_LOCALE) {
59 wxXmlResource* res = new wxXmlResource(*filemask, flags);
60 res->InitAllHandlers();
68 // Loads resources from XML files that match given filemask.
69 // This method understands VFS (see filesys.h).
70 bool Load(const wxString& filemask);
72 // Initialize handlers for all supported controls/windows. This will
73 // make the executable quite big because it forces linking against
74 // most of wxWin library
75 void InitAllHandlers();
77 // Initialize only specific handler (or custom handler). Convention says
78 // that handler name is equal to control's name plus 'XmlHandler', e.g.
79 // wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler
80 // (xmlres) can create include file that contains initialization code for
81 // all controls used within the resource.
82 void AddHandler(wxXmlResourceHandler *handler);
84 // Removes all handlers
87 // Loads menu from resource. Returns NULL on failure.
88 wxMenu *LoadMenu(const wxString& name);
90 // Loads menubar from resource. Returns NULL on failure.
91 wxMenuBar *LoadMenuBar(const wxString& name);
94 wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
96 // Loads dialog. dlg points to parent window (if any). Second form
97 // is used to finish creation of already existing instance (main reason
98 // for this is that you may want to use derived class with new event table)
99 // Example (typical usage):
101 // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
103 wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
104 %name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
106 // Loads panel. panel points to parent window (if any). Second form
107 // is used to finish creation of already existing instance.
108 wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
109 %name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
111 bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
113 // Loads bitmap or icon resource from file:
114 wxBitmap LoadBitmap(const wxString& name);
115 wxIcon LoadIcon(const wxString& name);
117 // Attaches unknown control into given panel/window/dialog:
118 // (unknown controls are used in conjunction with <object class="unknown">)
119 bool AttachUnknownControl(const wxString& name, wxWindow *control,
120 wxWindow *parent = NULL);
122 // Returns numeric ID that is equivalent to string id used in XML
123 // resource. To be used in event tables
124 // Macro XMLID is provided for convenience
125 static int GetXRCID(const wxString& str_id);
127 // Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
128 long GetVersion() const;
130 // Compares resources version to argument. Returns -1 if resources version
131 // is less than the argument, +1 if greater and 0 if they equal.
132 int CompareVersion(int major, int minor, int release, int revision) const;
135 // Gets global resources object or create one if none exists
136 static wxXmlResource *Get();
137 // Sets global resources object and returns pointer to previous one (may be NULL).
138 static wxXmlResource *Set(wxXmlResource *res);
142 //----------------------------------------------------------------------
144 %pragma(python) code = "
146 return wxXmlResource_GetXRCID(str_id)
148 def XRCCTRL(window, str_id, *ignoreargs):
149 return window.FindWindowById(XRCID(str_id))
155 //----------------------------------------------------------------------
157 // TODO: Add wxXmlResourceHandler and allow it to be derived from.
159 //----------------------------------------------------------------------
163 wxClassInfo::CleanUpClasses();
164 wxClassInfo::InitializeClasses();
166 wxXmlInitResourceModule();
167 wxXmlResource::Get()->InitAllHandlers();
171 //----------------------------------------------------------------------
172 // This file gets appended to the shadow class file.
173 //----------------------------------------------------------------------
175 %pragma(python) include="_xrcextras.py";