]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/xrc/_xmlres.i
Regenerated renamers, each has just a change in their headers
[wxWidgets.git] / wxPython / contrib / xrc / _xmlres.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _xmlres.i
3 // Purpose: SWIG interface for wxXmlResource
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 4-June-2001
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %newgroup
18
19
20
21 class wxPyXmlSubclassFactory;
22
23 enum {
24 WX_XMLRES_CURRENT_VERSION_MAJOR,
25 WX_XMLRES_CURRENT_VERSION_MINOR,
26 WX_XMLRES_CURRENT_VERSION_RELEASE,
27 WX_XMLRES_CURRENT_VERSION_REVISION,
28 };
29
30
31 enum wxXmlResourceFlags
32 {
33 wxXRC_USE_LOCALE = 1,
34 wxXRC_NO_SUBCLASSING = 2
35 };
36
37
38
39 // This class holds XML resources from one or more .xml files
40 // (or derived forms, either binary or zipped -- see manual for
41 // details).
42
43 class wxXmlResource : public wxObject
44 {
45 public:
46
47 %pythonAppend wxXmlResource(const wxString& filemask, int flags) "self.InitAllHandlers()"
48 %pythonAppend wxXmlResource(int flags) "val.InitAllHandlers()"
49
50 // Ctors.
51 // Flags: wxXRC_USE_LOCALE
52 // translatable strings will be translated via _()
53 // wxXRC_NO_SUBCLASSING
54 // subclass property of object nodes will be ignored
55 // (useful for previews in XRC editors)
56 wxXmlResource(const wxString& filemask, int flags = wxXRC_USE_LOCALE);
57 %name(EmptyXmlResource) wxXmlResource(int flags = wxXRC_USE_LOCALE);
58 ~wxXmlResource();
59
60
61 // Loads resources from XML files that match given filemask.
62 // This method understands VFS (see filesys.h).
63 bool Load(const wxString& filemask);
64
65 %extend {
66 bool LoadFromString(const wxString& data) {
67 static int s_memFileIdx = 0;
68
69 // Check for memory FS. If not present, load the handler:
70 wxMemoryFSHandler::AddFile(wxT("XRC_resource/dummy_file"),
71 wxT("dummy data"));
72 wxFileSystem fsys;
73 wxFSFile *f = fsys.OpenFile(wxT("memory:XRC_resource/dummy_file"));
74 wxMemoryFSHandler::RemoveFile(wxT("XRC_resource/dummy_file"));
75 if (f)
76 delete f;
77 else
78 wxFileSystem::AddHandler(new wxMemoryFSHandler);
79
80 // Now put the resource data into the memory FS
81 wxString filename(wxT("XRC_resource/data_string_"));
82 filename << s_memFileIdx;
83 s_memFileIdx += 1;
84 wxMemoryFSHandler::AddFile(filename, data);
85
86 // Load the "file" into the resource object
87 bool retval = self->Load(wxT("memory:") + filename );
88
89 return retval;
90 }
91 }
92
93 // Initialize handlers for all supported controls/windows.
94 void InitAllHandlers();
95
96 // Initialize only specific handler (or custom handler). Convention says
97 // that handler name is equal to control's name plus 'XmlHandler', e.g.
98 // wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler
99 // (xmlres) can create include file that contains initialization code for
100 // all controls used within the resource.
101 void AddHandler(wxPyXmlResourceHandler *handler);
102
103 // Add a new handler at the begining of the handler list
104 void InsertHandler(wxPyXmlResourceHandler *handler);
105
106 // Removes all handlers
107 void ClearHandlers();
108
109 // Registers subclasses factory for use in XRC. This function is not meant
110 // for public use, please see the comment above wxXmlSubclassFactory
111 // definition.
112 static void AddSubclassFactory(wxPyXmlSubclassFactory *factory);
113
114
115 // Loads menu from resource. Returns NULL on failure.
116 wxMenu *LoadMenu(const wxString& name);
117
118 // Loads menubar from resource. Returns NULL on failure.
119 wxMenuBar *LoadMenuBar(const wxString& name);
120 %name(LoadMenuBarOnFrame) wxMenuBar *LoadMenuBar(wxWindow *parent, const wxString& name);
121
122
123 // Loads toolbar
124 wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
125
126 // Loads dialog. dlg points to parent window (if any). Second form
127 // is used to finish creation of already existing instance (main reason
128 // for this is that you may want to use derived class with new event table)
129 // Example (typical usage):
130 // MyDialog dlg;
131 // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
132 // dlg->ShowModal();
133 wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
134 %name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
135
136 // Loads panel. panel points to parent window (if any). Second form
137 // is used to finish creation of already existing instance.
138 wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
139 %name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
140
141 // Load a frame's contents from a resource
142 wxFrame *LoadFrame(wxWindow* parent, const wxString& name);
143 %name(LoadOnFrame)bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
144
145 // Load an object from the resource specifying both the resource name and
146 // the classname. This lets you load nonstandard container windows.
147 wxObject *LoadObject(wxWindow *parent, const wxString& name,
148 const wxString& classname);
149
150 // Load an object from the resource specifying both the resource name and
151 // the classname. This form lets you finish the creation of an existing
152 // instance.
153 %name(LoadOnObject)bool LoadObject(wxObject *instance, wxWindow *parent, const wxString& name,
154 const wxString& classname);
155
156 // Loads a bitmap resource from a file.
157 wxBitmap LoadBitmap(const wxString& name);
158
159 // Loads an icon resource from a file.
160 wxIcon LoadIcon(const wxString& name);
161
162 // Attaches unknown control into given panel/window/dialog:
163 // (unknown controls are used in conjunction with <object class="unknown">)
164 bool AttachUnknownControl(const wxString& name, wxWindow *control,
165 wxWindow *parent = NULL);
166
167 // Returns numeric ID that is equivalent to string id used in XML
168 // resource. To be used in event tables
169 // Macro XMLID is provided for convenience
170 static int GetXRCID(const wxString& str_id);
171
172 // Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
173 long GetVersion() const;
174
175 // Compares resources version to argument. Returns -1 if resources version
176 // is less than the argument, +1 if greater and 0 if they equal.
177 int CompareVersion(int major, int minor, int release, int revision) const;
178
179
180 // Gets global resources object or create one if none exists
181 static wxXmlResource *Get();
182 // Sets global resources object and returns pointer to previous one (may be NULL).
183 static wxXmlResource *Set(wxXmlResource *res);
184
185 // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING.
186 int GetFlags();
187
188 // Set flags after construction.
189 void SetFlags(int flags) { m_flags = flags; }
190
191 };
192
193 //----------------------------------------------------------------------
194
195 %pythoncode {
196 def XRCID(str_id):
197 return XmlResource_GetXRCID(str_id)
198
199 def XRCCTRL(window, str_id, *ignoreargs):
200 return window.FindWindowById(XRCID(str_id))
201 };
202
203 //---------------------------------------------------------------------------