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 // This class holds XML resources from one or more .xml files
36 // (or derived forms, either binary or zipped -- see manual for
39 class wxXmlResource : public wxObject
42 // Ctor. If use_locale is TRUE, translatable strings are
43 // translated via _(). You can disable it by passing use_locale=FALSE
44 // (for example if you provide resource file for each locale)
45 %name(wxXmlResourceEmpty)wxXmlResource(bool use_locale = TRUE); // TODO, a better %name
48 wxXmlResource(const wxString* filemask, bool use_locale = TRUE) {
49 wxXmlResource* res = new wxXmlResource(*filemask, use_locale);
50 res->InitAllHandlers();
58 // Loads resources from XML files that match given filemask.
59 // This method understands VFS (see filesys.h).
60 bool Load(const wxString& filemask);
62 // Initialize handlers for all supported controls/windows. This will
63 // make the executable quite big because it forces linking against
64 // most of wxWin library
65 void InitAllHandlers();
67 // Initialize only specific handler (or custom handler). Convention says
68 // that handler name is equal to control's name plus 'XmlHandler', e.g.
69 // wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler
70 // (xmlres) can create include file that contains initialization code for
71 // all controls used within the resource.
72 void AddHandler(wxXmlResourceHandler *handler);
74 // Removes all handlers
77 // Loads menu from resource. Returns NULL on failure.
78 wxMenu *LoadMenu(const wxString& name);
80 // Loads menubar from resource. Returns NULL on failure.
81 wxMenuBar *LoadMenuBar(const wxString& name);
84 wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
86 // Loads dialog. dlg points to parent window (if any). Second form
87 // is used to finish creation of already existing instance (main reason
88 // for this is that you may want to use derived class with new event table)
89 // Example (typical usage):
91 // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
93 wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
94 %name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
96 // Loads panel. panel points to parent window (if any). Second form
97 // is used to finish creation of already existing instance.
98 wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
99 %name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
101 bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
103 // Loads bitmap or icon resource from file:
104 wxBitmap LoadBitmap(const wxString& name);
105 wxIcon LoadIcon(const wxString& name);
107 // Attaches unknown control into given panel/window/dialog:
108 // (unknown controls are used in conjunction with <object class="unknown">)
109 bool AttachUnknownControl(const wxString& name, wxWindow *control,
110 wxWindow *parent = NULL);
112 // Returns numeric ID that is equivalent to string id used in XML
113 // resource. To be used in event tables
114 // Macro XMLID is provided for convenience
115 static int GetXMLID(const char *str_id);
117 // Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
118 long GetVersion() const;
120 // Compares resources version to argument. Returns -1 if resources version
121 // is less than the argument, +1 if greater and 0 if they equal.
122 int CompareVersion(int major, int minor, int release, int revision) const;
126 //----------------------------------------------------------------------
129 // Global instance of resource class. For your convenience.
130 wxXmlResource *wxTheXmlResource;
133 //----------------------------------------------------------------------
135 %pragma(python) code = "
137 return wxXmlResource_GetXMLID(str_id)
139 def XMLCTRL(window, str_id, *args):
140 return window.FindWindowById(XMLID(str_id))
144 //----------------------------------------------------------------------
146 // TODO: Add wxXmlResourceHandler and etc.
148 //----------------------------------------------------------------------
152 wxClassInfo::CleanUpClasses();
153 wxClassInfo::InitializeClasses();
155 wxXmlInitXmlModule();
156 wxXmlInitResourceModule();
157 wxTheXmlResource->InitAllHandlers();
161 //---------------------------------------------------------------------------