]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_xmlhandler.i
Added wxStandardPaths
[wxWidgets.git] / wxPython / src / _xmlhandler.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _xml.i
3// Purpose: SWIG interface for other wxXml classes
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%{ // C++ version of Python aware wxXmlResourceHandler, for the pure virtual
22 // callbacks, as well as to make some protected things public so they can
23 // be wrapped.
24class wxPyXmlResourceHandler : public wxXmlResourceHandler {
25public:
26 wxPyXmlResourceHandler() : wxXmlResourceHandler() {}
27 //~wxPyXmlResourceHandler();
28
29 // Base class virtuals
30
31 DEC_PYCALLBACK_OBJECT__pure(DoCreateResource);
32 DEC_PYCALLBACK_BOOL_NODE_pure(CanHandle);
33
34
35 // accessors for protected members
36
37 wxXmlResource* GetResource() { return m_resource; }
38 wxXmlNode* GetNode() { return m_node; }
39 wxString GetClass() { return m_class; }
40 wxObject* GetParent() { return m_parent; }
41 wxObject* GetInstance() { return m_instance; }
42 wxWindow* GetParentAsWindow() { return m_parentAsWindow; }
43 wxWindow* GetInstanceAsWindow() { return m_instanceAsWindow; }
44
45
46 // turn some protected methods into public via delegation
47
48 bool IsOfClass(wxXmlNode *node, const wxString& classname)
49 { return wxXmlResourceHandler::IsOfClass(node, classname); }
50
51 wxString GetNodeContent(wxXmlNode *node)
52 { return wxXmlResourceHandler::GetNodeContent(node); }
53
54 bool HasParam(const wxString& param)
55 { return wxXmlResourceHandler::HasParam(param); }
56
57 wxXmlNode *GetParamNode(const wxString& param)
58 { return wxXmlResourceHandler::GetParamNode(param); }
59
60 wxString GetParamValue(const wxString& param)
61 { return wxXmlResourceHandler::GetParamValue(param); }
62
63 void AddStyle(const wxString& name, int value)
64 { wxXmlResourceHandler::AddStyle(name, value); }
65
66 void AddWindowStyles()
67 { wxXmlResourceHandler::AddWindowStyles(); }
68
69 int GetStyle(const wxString& param = wxT("style"), int defaults = 0)
70 { return wxXmlResourceHandler::GetStyle(param, defaults); }
71
a72f4631 72 wxString GetText(const wxString& param, bool translate = true)
d14a1e28
RD
73 { return wxXmlResourceHandler::GetText(param, translate); }
74
75 int GetID()
76 { return wxXmlResourceHandler::GetID(); }
77
78 wxString GetName()
79 { return wxXmlResourceHandler::GetName(); }
80
a72f4631 81 bool GetBool(const wxString& param, bool defaultv = false)
d14a1e28
RD
82 { return wxXmlResourceHandler::GetBool(param, defaultv); }
83
84 long GetLong( const wxString& param, long defaultv = 0 )
85 { return wxXmlResourceHandler::GetLong(param, defaultv); }
86
87 wxColour GetColour(const wxString& param)
88 { return wxXmlResourceHandler::GetColour(param); }
89
90 wxSize GetSize(const wxString& param = wxT("size"))
91 { return wxXmlResourceHandler::GetSize(param); }
92
93 wxPoint GetPosition(const wxString& param = wxT("pos"))
94 { return wxXmlResourceHandler::GetPosition(param); }
95
96 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0)
97 { return wxXmlResourceHandler::GetDimension(param, defaultv); }
98
99 wxBitmap GetBitmap(const wxString& param = wxT("bitmap"),
100 const wxArtClient& defaultArtClient = wxART_OTHER,
101 wxSize size = wxDefaultSize)
102 { return wxXmlResourceHandler::GetBitmap(param, defaultArtClient, size); }
103
104 wxIcon GetIcon(const wxString& param = wxT("icon"),
105 const wxArtClient& defaultArtClient = wxART_OTHER,
106 wxSize size = wxDefaultSize)
107 { return wxXmlResourceHandler::GetIcon(param, defaultArtClient, size); }
108
109 wxFont GetFont(const wxString& param = wxT("font"))
110 { return wxXmlResourceHandler::GetFont(param); }
111
112 void SetupWindow(wxWindow *wnd)
113 { wxXmlResourceHandler::SetupWindow(wnd); }
114
a72f4631 115 void CreateChildren(wxObject *parent, bool this_hnd_only = false)
d14a1e28
RD
116 { wxXmlResourceHandler::CreateChildren(parent, this_hnd_only); }
117
118 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL)
119 { wxXmlResourceHandler::CreateChildrenPrivately(parent, rootnode); }
120
121 wxObject *CreateResFromNode(wxXmlNode *node,
122 wxObject *parent, wxObject *instance = NULL)
123 { return wxXmlResourceHandler::CreateResFromNode(node, parent, instance); }
124
125 wxFileSystem& GetCurFileSystem()
126 { return wxXmlResourceHandler::GetCurFileSystem(); }
127
128
129 PYPRIVATE;
130};
131
132IMP_PYCALLBACK_OBJECT__pure(wxPyXmlResourceHandler, wxXmlResourceHandler, DoCreateResource);
133IMP_PYCALLBACK_BOOL_NODE_pure(wxPyXmlResourceHandler, wxXmlResourceHandler, CanHandle);
134
135%}
136
137
138// Now the version that will be SWIGged.
139
140
141%name(XmlResourceHandler) class wxPyXmlResourceHandler : public wxObject {
142public:
2b9048c5 143 %pythonAppend wxPyXmlResourceHandler "self._setCallbackInfo(self, XmlResourceHandler)"
d14a1e28
RD
144 wxPyXmlResourceHandler() : wxXmlResourceHandler() {}
145 //~wxPyXmlResourceHandler();
146
147 void _setCallbackInfo(PyObject* self, PyObject* _class);
148
149
150 // Creates an object (menu, dialog, control, ...) from an XML node.
151 // Should check for validity.
152 // parent is a higher-level object (usually window, dialog or panel)
153 // that is often neccessary to create the resource.
154 // If instance is non-NULL it should not create a new instance via 'new' but
155 // should rather use this one, and call its Create method.
156 wxObject *CreateResource(wxXmlNode *node, wxObject *parent,
157 wxObject *instance);
158
159 // Sets the parent resource.
160 void SetParentResource(wxXmlResource *res);
161
162
163 wxXmlResource* GetResource() { return m_resource; }
164 wxXmlNode* GetNode() { return m_node; }
165 wxString GetClass() { return m_class; }
166 wxObject* GetParent() { return m_parent; }
167 wxObject* GetInstance() { return m_instance; }
168 wxWindow* GetParentAsWindow() { return m_parentAsWindow; }
169 wxWindow* GetInstanceAsWindow() { return m_instanceAsWindow; }
170
171
172 // Returns true if the node has a property class equal to classname,
173 // e.g. <object class="wxDialog">.
174 bool IsOfClass(wxXmlNode *node, const wxString& classname);
175
176 // Gets node content from wxXML_ENTITY_NODE
177 // The problem is, <tag>content<tag> is represented as
178 // wxXML_ENTITY_NODE name="tag", content=""
179 // |-- wxXML_TEXT_NODE or
180 // wxXML_CDATA_SECTION_NODE name="" content="content"
181 wxString GetNodeContent(wxXmlNode *node);
182
183 // Check to see if a parameter exists.
184 bool HasParam(const wxString& param);
185
186 // Finds the node or returns NULL.
187 wxXmlNode *GetParamNode(const wxString& param);
188
189 // Finds the parameter value or returns the empty string.
190 wxString GetParamValue(const wxString& param);
191
192 // Add a style flag (e.g. wxMB_DOCKABLE) to the list of flags
193 // understood by this handler.
194 void AddStyle(const wxString& name, int value);
195
196 // Add styles common to all wxWindow-derived classes.
197 void AddWindowStyles();
198
199 // Gets style flags from text in form "flag | flag2| flag3 |..."
200 // Only understads flags added with AddStyle
201 int GetStyle(const wxString& param = wxPyStyleString, int defaults = 0);
202
203 // Gets text from param and does some conversions:
204 // - replaces \n, \r, \t by respective chars (according to C syntax)
205 // - replaces _ by & and __ by _ (needed for _File => &File because of XML)
206 // - calls wxGetTranslations (unless disabled in wxXmlResource)
a72f4631 207 wxString GetText(const wxString& param, bool translate = true);
d14a1e28
RD
208
209 // Returns the XRCID.
210 int GetID();
211
212 // Returns the resource name.
213 wxString GetName();
214
a72f4631
RD
215 // Gets a bool flag (1, t, yes, on, true are True, everything else is false).
216 bool GetBool(const wxString& param, bool defaultv = false);
d14a1e28
RD
217
218 // Gets the integer value from the parameter.
219 long GetLong( const wxString& param, long defaultv = 0 );
220
221 // Gets colour in HTML syntax (#RRGGBB).
222 wxColour GetColour(const wxString& param);
223
224 // Gets the size (may be in dialog units).
225 wxSize GetSize(const wxString& param = wxPySizeString);
226
227 // Gets the position (may be in dialog units).
228 wxPoint GetPosition(const wxString& param = wxPyPosString);
229
230 // Gets a dimension (may be in dialog units).
231 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
232
233 // Gets a bitmap.
234 wxBitmap GetBitmap(const wxString& param = wxPyBitmapString,
235 const wxArtClient& defaultArtClient = wxART_OTHER,
236 wxSize size = wxDefaultSize);
237
238 // Gets an icon.
239 wxIcon GetIcon(const wxString& param = wxPyIconString,
240 const wxArtClient& defaultArtClient = wxART_OTHER,
241 wxSize size = wxDefaultSize);
242
243 // Gets a font.
244 wxFont GetFont(const wxString& param = wxPyFontString);
245
246 // Sets common window options.
247 void SetupWindow(wxWindow *wnd);
248
249 // Creates children.
a72f4631 250 void CreateChildren(wxObject *parent, bool this_hnd_only = false);
d14a1e28
RD
251
252 // Helper function.
253 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
254
255 // Creates a resource from a node.
256 wxObject *CreateResFromNode(wxXmlNode *node,
257 wxObject *parent, wxObject *instance = NULL);
258
259 // helper
260 wxFileSystem& GetCurFileSystem();
261};
262
263
264
265//---------------------------------------------------------------------------
266//---------------------------------------------------------------------------