1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for other wxXml classes
7 // Created: 4-June-2001
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
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
24 class wxPyXmlResourceHandler : public wxXmlResourceHandler {
26 wxPyXmlResourceHandler() : wxXmlResourceHandler() {}
27 ~wxPyXmlResourceHandler() {}
29 // Base class virtuals
31 DEC_PYCALLBACK_OBJECT__pure(DoCreateResource);
32 DEC_PYCALLBACK_BOOL_NODE_pure(CanHandle);
35 // accessors for protected members
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; }
45 // turn some protected methods into public via delegation
47 bool IsOfClass(wxXmlNode *node, const wxString& classname)
48 { return wxXmlResourceHandler::IsOfClass(node, classname); }
50 wxString GetNodeContent(wxXmlNode *node)
51 { return wxXmlResourceHandler::GetNodeContent(node); }
53 bool HasParam(const wxString& param)
54 { return wxXmlResourceHandler::HasParam(param); }
56 wxXmlNode *GetParamNode(const wxString& param)
57 { return wxXmlResourceHandler::GetParamNode(param); }
59 wxString GetParamValue(const wxString& param)
60 { return wxXmlResourceHandler::GetParamValue(param); }
62 void AddStyle(const wxString& name, int value)
63 { wxXmlResourceHandler::AddStyle(name, value); }
65 void AddWindowStyles()
66 { wxXmlResourceHandler::AddWindowStyles(); }
68 int GetStyle(const wxString& param = wxT("style"), int defaults = 0)
69 { return wxXmlResourceHandler::GetStyle(param, defaults); }
71 wxString GetText(const wxString& param, bool translate = true)
72 { return wxXmlResourceHandler::GetText(param, translate); }
75 { return wxXmlResourceHandler::GetID(); }
78 { return wxXmlResourceHandler::GetName(); }
80 bool GetBool(const wxString& param, bool defaultv = false)
81 { return wxXmlResourceHandler::GetBool(param, defaultv); }
83 long GetLong( const wxString& param, long defaultv = 0 )
84 { return wxXmlResourceHandler::GetLong(param, defaultv); }
86 wxColour GetColour(const wxString& param)
87 { return wxXmlResourceHandler::GetColour(param); }
89 wxSize GetSize(const wxString& param = wxT("size"))
90 { return wxXmlResourceHandler::GetSize(param); }
92 wxPoint GetPosition(const wxString& param = wxT("pos"))
93 { return wxXmlResourceHandler::GetPosition(param); }
95 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0)
96 { return wxXmlResourceHandler::GetDimension(param, defaultv); }
98 wxBitmap GetBitmap(const wxString& param = wxT("bitmap"),
99 const wxArtClient& defaultArtClient = wxART_OTHER,
100 wxSize size = wxDefaultSize)
101 { return wxXmlResourceHandler::GetBitmap(param, defaultArtClient, size); }
103 wxIcon GetIcon(const wxString& param = wxT("icon"),
104 const wxArtClient& defaultArtClient = wxART_OTHER,
105 wxSize size = wxDefaultSize)
106 { return wxXmlResourceHandler::GetIcon(param, defaultArtClient, size); }
108 wxAnimation GetAnimation(const wxString& param = wxT("animation"))
109 { return wxXmlResourceHandler::GetAnimation(param); }
111 wxFont GetFont(const wxString& param = wxT("font"))
112 { return wxXmlResourceHandler::GetFont(param); }
114 void SetupWindow(wxWindow *wnd)
115 { wxXmlResourceHandler::SetupWindow(wnd); }
117 void CreateChildren(wxObject *parent, bool this_hnd_only = false)
118 { wxXmlResourceHandler::CreateChildren(parent, this_hnd_only); }
120 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL)
121 { wxXmlResourceHandler::CreateChildrenPrivately(parent, rootnode); }
123 wxObject *CreateResFromNode(wxXmlNode *node,
124 wxObject *parent, wxObject *instance = NULL)
125 { return wxXmlResourceHandler::CreateResFromNode(node, parent, instance); }
127 wxFileSystem& GetCurFileSystem()
128 { return wxXmlResourceHandler::GetCurFileSystem(); }
134 IMP_PYCALLBACK_OBJECT__pure(wxPyXmlResourceHandler, wxXmlResourceHandler, DoCreateResource);
135 IMP_PYCALLBACK_BOOL_NODE_pure(wxPyXmlResourceHandler, wxXmlResourceHandler, CanHandle);
140 // Now the version that will be SWIGged.
143 %rename(XmlResourceHandler) wxPyXmlResourceHandler;
144 class wxPyXmlResourceHandler : public wxObject {
146 %pythonAppend wxPyXmlResourceHandler setCallbackInfo(XmlResourceHandler)
147 wxPyXmlResourceHandler() : wxXmlResourceHandler() {}
148 ~wxPyXmlResourceHandler();
150 void _setCallbackInfo(PyObject* self, PyObject* _class);
153 // Creates an object (menu, dialog, control, ...) from an XML node.
154 // Should check for validity.
155 // parent is a higher-level object (usually window, dialog or panel)
156 // that is often neccessary to create the resource.
157 // If instance is non-NULL it should not create a new instance via 'new' but
158 // should rather use this one, and call its Create method.
159 wxObject *CreateResource(wxXmlNode *node, wxObject *parent,
162 // Sets the parent resource.
163 void SetParentResource(wxXmlResource *res);
166 wxXmlResource* GetResource() { return m_resource; }
167 wxXmlNode* GetNode() { return m_node; }
168 wxString GetClass() { return m_class; }
169 wxObject* GetParent() { return m_parent; }
170 wxObject* GetInstance() { return m_instance; }
171 wxWindow* GetParentAsWindow() { return m_parentAsWindow; }
172 // wxWindow* GetInstanceAsWindow() { return m_instanceAsWindow; }
175 // Returns true if the node has a property class equal to classname,
176 // e.g. <object class="wxDialog">.
177 bool IsOfClass(wxXmlNode *node, const wxString& classname);
179 // Gets node content from wxXML_ENTITY_NODE
180 // The problem is, <tag>content<tag> is represented as
181 // wxXML_ENTITY_NODE name="tag", content=""
182 // |-- wxXML_TEXT_NODE or
183 // wxXML_CDATA_SECTION_NODE name="" content="content"
184 wxString GetNodeContent(wxXmlNode *node);
186 // Check to see if a parameter exists.
187 bool HasParam(const wxString& param);
189 // Finds the node or returns NULL.
190 wxXmlNode *GetParamNode(const wxString& param);
192 // Finds the parameter value or returns the empty string.
193 wxString GetParamValue(const wxString& param);
195 // Add a style flag (e.g. wxMB_DOCKABLE) to the list of flags
196 // understood by this handler.
197 void AddStyle(const wxString& name, int value);
199 // Add styles common to all wxWindow-derived classes.
200 void AddWindowStyles();
202 // Gets style flags from text in form "flag | flag2| flag3 |..."
203 // Only understads flags added with AddStyle
204 int GetStyle(const wxString& param = wxPyStyleString, int defaults = 0);
206 // Gets text from param and does some conversions:
207 // - replaces \n, \r, \t by respective chars (according to C syntax)
208 // - replaces _ by & and __ by _ (needed for _File => &File because of XML)
209 // - calls wxGetTranslations (unless disabled in wxXmlResource)
210 wxString GetText(const wxString& param, bool translate = true);
212 // Returns the XRCID.
215 // Returns the resource name.
218 // Gets a bool flag (1, t, yes, on, true are True, everything else is false).
219 bool GetBool(const wxString& param, bool defaultv = false);
221 // Gets the integer value from the parameter.
222 long GetLong( const wxString& param, long defaultv = 0 );
224 // Gets colour in HTML syntax (#RRGGBB).
225 wxColour GetColour(const wxString& param);
227 // Gets the size (may be in dialog units).
228 wxSize GetSize(const wxString& param = wxPySizeString);
230 // Gets the position (may be in dialog units).
231 wxPoint GetPosition(const wxString& param = wxPyPosString);
233 // Gets a dimension (may be in dialog units).
234 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
237 wxBitmap GetBitmap(const wxString& param = wxPyBitmapString,
238 const wxArtClient& defaultArtClient = wxART_OTHER,
239 wxSize size = wxDefaultSize);
242 wxIcon GetIcon(const wxString& param = wxPyIconString,
243 const wxArtClient& defaultArtClient = wxART_OTHER,
244 wxSize size = wxDefaultSize);
247 wxFont GetFont(const wxString& param = wxPyFontString);
249 // Gets an animation.
250 wxAnimation GetAnimation(const wxString& param = wxPyAnimationString);
252 // Sets common window options.
253 void SetupWindow(wxWindow *wnd);
256 void CreateChildren(wxObject *parent, bool this_hnd_only = false);
259 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
261 // Creates a resource from a node.
262 wxObject *CreateResFromNode(wxXmlNode *node,
263 wxObject *parent, wxObject *instance = NULL);
266 wxFileSystem& GetCurFileSystem();
268 %property(Class, GetClass, doc="See `GetClass`");
269 %property(CurFileSystem, GetCurFileSystem, doc="See `GetCurFileSystem`");
270 %property(ID, GetID, doc="See `GetID`");
271 %property(Instance, GetInstance, doc="See `GetInstance`");
272 %property(Name, GetName, doc="See `GetName`");
273 %property(Node, GetNode, doc="See `GetNode`");
274 %property(Parent, GetParent, doc="See `GetParent`");
275 %property(ParentAsWindow, GetParentAsWindow, doc="See `GetParentAsWindow`");
276 %property(Resource, GetResource, doc="See `GetResource`");
281 //---------------------------------------------------------------------------
282 //---------------------------------------------------------------------------