]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_xmlhandler.i
More methods for wxStdDialogButtonSizer
[wxWidgets.git] / wxPython / src / _xmlhandler.i
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.
24 class wxPyXmlResourceHandler : public wxXmlResourceHandler {
25 public:
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
72 wxString GetText(const wxString& param, bool translate = true)
73 { return wxXmlResourceHandler::GetText(param, translate); }
74
75 int GetID()
76 { return wxXmlResourceHandler::GetID(); }
77
78 wxString GetName()
79 { return wxXmlResourceHandler::GetName(); }
80
81 bool GetBool(const wxString& param, bool defaultv = false)
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
115 void CreateChildren(wxObject *parent, bool this_hnd_only = false)
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
132 IMP_PYCALLBACK_OBJECT__pure(wxPyXmlResourceHandler, wxXmlResourceHandler, DoCreateResource);
133 IMP_PYCALLBACK_BOOL_NODE_pure(wxPyXmlResourceHandler, wxXmlResourceHandler, CanHandle);
134
135 %}
136
137
138 // Now the version that will be SWIGged.
139
140
141 %rename(XmlResourceHandler) wxPyXmlResourceHandler;
142 class wxPyXmlResourceHandler : public wxObject {
143 public:
144 %pythonAppend wxPyXmlResourceHandler "self._setCallbackInfo(self, XmlResourceHandler)"
145 wxPyXmlResourceHandler() : wxXmlResourceHandler() {}
146 //~wxPyXmlResourceHandler();
147
148 void _setCallbackInfo(PyObject* self, PyObject* _class);
149
150
151 // Creates an object (menu, dialog, control, ...) from an XML node.
152 // Should check for validity.
153 // parent is a higher-level object (usually window, dialog or panel)
154 // that is often neccessary to create the resource.
155 // If instance is non-NULL it should not create a new instance via 'new' but
156 // should rather use this one, and call its Create method.
157 wxObject *CreateResource(wxXmlNode *node, wxObject *parent,
158 wxObject *instance);
159
160 // Sets the parent resource.
161 void SetParentResource(wxXmlResource *res);
162
163
164 wxXmlResource* GetResource() { return m_resource; }
165 wxXmlNode* GetNode() { return m_node; }
166 wxString GetClass() { return m_class; }
167 wxObject* GetParent() { return m_parent; }
168 wxObject* GetInstance() { return m_instance; }
169 wxWindow* GetParentAsWindow() { return m_parentAsWindow; }
170 // wxWindow* GetInstanceAsWindow() { return m_instanceAsWindow; }
171
172
173 // Returns true if the node has a property class equal to classname,
174 // e.g. <object class="wxDialog">.
175 bool IsOfClass(wxXmlNode *node, const wxString& classname);
176
177 // Gets node content from wxXML_ENTITY_NODE
178 // The problem is, <tag>content<tag> is represented as
179 // wxXML_ENTITY_NODE name="tag", content=""
180 // |-- wxXML_TEXT_NODE or
181 // wxXML_CDATA_SECTION_NODE name="" content="content"
182 wxString GetNodeContent(wxXmlNode *node);
183
184 // Check to see if a parameter exists.
185 bool HasParam(const wxString& param);
186
187 // Finds the node or returns NULL.
188 wxXmlNode *GetParamNode(const wxString& param);
189
190 // Finds the parameter value or returns the empty string.
191 wxString GetParamValue(const wxString& param);
192
193 // Add a style flag (e.g. wxMB_DOCKABLE) to the list of flags
194 // understood by this handler.
195 void AddStyle(const wxString& name, int value);
196
197 // Add styles common to all wxWindow-derived classes.
198 void AddWindowStyles();
199
200 // Gets style flags from text in form "flag | flag2| flag3 |..."
201 // Only understads flags added with AddStyle
202 int GetStyle(const wxString& param = wxPyStyleString, int defaults = 0);
203
204 // Gets text from param and does some conversions:
205 // - replaces \n, \r, \t by respective chars (according to C syntax)
206 // - replaces _ by & and __ by _ (needed for _File => &File because of XML)
207 // - calls wxGetTranslations (unless disabled in wxXmlResource)
208 wxString GetText(const wxString& param, bool translate = true);
209
210 // Returns the XRCID.
211 int GetID();
212
213 // Returns the resource name.
214 wxString GetName();
215
216 // Gets a bool flag (1, t, yes, on, true are True, everything else is false).
217 bool GetBool(const wxString& param, bool defaultv = false);
218
219 // Gets the integer value from the parameter.
220 long GetLong( const wxString& param, long defaultv = 0 );
221
222 // Gets colour in HTML syntax (#RRGGBB).
223 wxColour GetColour(const wxString& param);
224
225 // Gets the size (may be in dialog units).
226 wxSize GetSize(const wxString& param = wxPySizeString);
227
228 // Gets the position (may be in dialog units).
229 wxPoint GetPosition(const wxString& param = wxPyPosString);
230
231 // Gets a dimension (may be in dialog units).
232 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
233
234 // Gets a bitmap.
235 wxBitmap GetBitmap(const wxString& param = wxPyBitmapString,
236 const wxArtClient& defaultArtClient = wxART_OTHER,
237 wxSize size = wxDefaultSize);
238
239 // Gets an icon.
240 wxIcon GetIcon(const wxString& param = wxPyIconString,
241 const wxArtClient& defaultArtClient = wxART_OTHER,
242 wxSize size = wxDefaultSize);
243
244 // Gets a font.
245 wxFont GetFont(const wxString& param = wxPyFontString);
246
247 // Sets common window options.
248 void SetupWindow(wxWindow *wnd);
249
250 // Creates children.
251 void CreateChildren(wxObject *parent, bool this_hnd_only = false);
252
253 // Helper function.
254 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
255
256 // Creates a resource from a node.
257 wxObject *CreateResFromNode(wxXmlNode *node,
258 wxObject *parent, wxObject *instance = NULL);
259
260 // helper
261 wxFileSystem& GetCurFileSystem();
262 };
263
264
265
266 //---------------------------------------------------------------------------
267 //---------------------------------------------------------------------------