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; }
43 // wxWindow* GetInstanceAsWindow() { return m_instanceAsWindow; }
46 // turn some protected methods into public via delegation
48 bool IsOfClass(wxXmlNode *node, const wxString& classname)
49 { return wxXmlResourceHandler::IsOfClass(node, classname); }
51 wxString GetNodeContent(wxXmlNode *node)
52 { return wxXmlResourceHandler::GetNodeContent(node); }
54 bool HasParam(const wxString& param)
55 { return wxXmlResourceHandler::HasParam(param); }
57 wxXmlNode *GetParamNode(const wxString& param)
58 { return wxXmlResourceHandler::GetParamNode(param); }
60 wxString GetParamValue(const wxString& param)
61 { return wxXmlResourceHandler::GetParamValue(param); }
63 void AddStyle(const wxString& name, int value)
64 { wxXmlResourceHandler::AddStyle(name, value); }
66 void AddWindowStyles()
67 { wxXmlResourceHandler::AddWindowStyles(); }
69 int GetStyle(const wxString& param = wxT("style"), int defaults = 0)
70 { return wxXmlResourceHandler::GetStyle(param, defaults); }
72 wxString GetText(const wxString& param, bool translate = true)
73 { return wxXmlResourceHandler::GetText(param, translate); }
76 { return wxXmlResourceHandler::GetID(); }
79 { return wxXmlResourceHandler::GetName(); }
81 bool GetBool(const wxString& param, bool defaultv = false)
82 { return wxXmlResourceHandler::GetBool(param, defaultv); }
84 long GetLong( const wxString& param, long defaultv = 0 )
85 { return wxXmlResourceHandler::GetLong(param, defaultv); }
87 wxColour GetColour(const wxString& param)
88 { return wxXmlResourceHandler::GetColour(param); }
90 wxSize GetSize(const wxString& param = wxT("size"))
91 { return wxXmlResourceHandler::GetSize(param); }
93 wxPoint GetPosition(const wxString& param = wxT("pos"))
94 { return wxXmlResourceHandler::GetPosition(param); }
96 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0)
97 { return wxXmlResourceHandler::GetDimension(param, defaultv); }
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); }
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); }
109 wxFont GetFont(const wxString& param = wxT("font"))
110 { return wxXmlResourceHandler::GetFont(param); }
112 void SetupWindow(wxWindow *wnd)
113 { wxXmlResourceHandler::SetupWindow(wnd); }
115 void CreateChildren(wxObject *parent, bool this_hnd_only = false)
116 { wxXmlResourceHandler::CreateChildren(parent, this_hnd_only); }
118 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL)
119 { wxXmlResourceHandler::CreateChildrenPrivately(parent, rootnode); }
121 wxObject *CreateResFromNode(wxXmlNode *node,
122 wxObject *parent, wxObject *instance = NULL)
123 { return wxXmlResourceHandler::CreateResFromNode(node, parent, instance); }
125 wxFileSystem& GetCurFileSystem()
126 { return wxXmlResourceHandler::GetCurFileSystem(); }
132 IMP_PYCALLBACK_OBJECT__pure(wxPyXmlResourceHandler, wxXmlResourceHandler, DoCreateResource);
133 IMP_PYCALLBACK_BOOL_NODE_pure(wxPyXmlResourceHandler, wxXmlResourceHandler, CanHandle);
138 // Now the version that will be SWIGged.
141 %rename(XmlResourceHandler) wxPyXmlResourceHandler;
142 class wxPyXmlResourceHandler : public wxObject {
144 %pythonAppend wxPyXmlResourceHandler "self._setCallbackInfo(self, XmlResourceHandler)"
145 wxPyXmlResourceHandler() : wxXmlResourceHandler() {}
146 //~wxPyXmlResourceHandler();
148 void _setCallbackInfo(PyObject* self, PyObject* _class);
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,
160 // Sets the parent resource.
161 void SetParentResource(wxXmlResource *res);
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; }
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);
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);
184 // Check to see if a parameter exists.
185 bool HasParam(const wxString& param);
187 // Finds the node or returns NULL.
188 wxXmlNode *GetParamNode(const wxString& param);
190 // Finds the parameter value or returns the empty string.
191 wxString GetParamValue(const wxString& param);
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);
197 // Add styles common to all wxWindow-derived classes.
198 void AddWindowStyles();
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);
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);
210 // Returns the XRCID.
213 // Returns the resource name.
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);
219 // Gets the integer value from the parameter.
220 long GetLong( const wxString& param, long defaultv = 0 );
222 // Gets colour in HTML syntax (#RRGGBB).
223 wxColour GetColour(const wxString& param);
225 // Gets the size (may be in dialog units).
226 wxSize GetSize(const wxString& param = wxPySizeString);
228 // Gets the position (may be in dialog units).
229 wxPoint GetPosition(const wxString& param = wxPyPosString);
231 // Gets a dimension (may be in dialog units).
232 wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
235 wxBitmap GetBitmap(const wxString& param = wxPyBitmapString,
236 const wxArtClient& defaultArtClient = wxART_OTHER,
237 wxSize size = wxDefaultSize);
240 wxIcon GetIcon(const wxString& param = wxPyIconString,
241 const wxArtClient& defaultArtClient = wxART_OTHER,
242 wxSize size = wxDefaultSize);
245 wxFont GetFont(const wxString& param = wxPyFontString);
247 // Sets common window options.
248 void SetupWindow(wxWindow *wnd);
251 void CreateChildren(wxObject *parent, bool this_hnd_only = false);
254 void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
256 // Creates a resource from a node.
257 wxObject *CreateResFromNode(wxXmlNode *node,
258 wxObject *parent, wxObject *instance = NULL);
261 wxFileSystem& GetCurFileSystem();
266 //---------------------------------------------------------------------------
267 //---------------------------------------------------------------------------