- public:
- wxXmlResourceHandler();
- virtual ~wxXmlResourceHandler() {}
-
- // Creates object (menu, dialog, control, ...) from XML node.
- // Should check for validity.
- // parent is higher-level object (usually window, dialog or panel)
- // that is often neccessary to create resource
- // if instance != NULL it should not create new instance via 'new' but
- // rather use this one and call its Create method
- wxObject *CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance);
-
- // This one is called from CreateResource after variables
- // were filled
- virtual wxObject *DoCreateResource() = 0;
-
- // Returns TRUE if it understands this node and can create
- // resource from it, FALSE otherwise.
- virtual bool CanHandle(wxXmlNode *node) = 0;
-
- void SetParentResource(wxXmlResource *res) { m_Resource = res; }
-
-
- protected:
-
- wxXmlResource *m_Resource;
- wxArrayString m_StyleNames;
- wxArrayInt m_StyleValues;
-
- // Variables (filled by CreateResource)
- wxXmlNode *m_Node;
- wxString m_Class;
- wxObject *m_Parent, *m_Instance;
- wxWindow *m_ParentAsWindow, *m_InstanceAsWindow;
-
- // --- Handy methods:
-
- // Returns true if the node has property class equal to classname,
- // e.g. <object class="wxDialog">
- bool IsOfClass(wxXmlNode *node, const wxString& classname)
- { return node->GetPropVal(wxT("class"), wxEmptyString) == classname; }
-
- // Gets node content from wxXML_ENTITY_NODE
- // (the problem is, <tag>content<tag> is represented as
- // wxXML_ENTITY_NODE name="tag", content=""
- // |-- wxXML_TEXT_NODE or
- // wxXML_CDATA_SECTION_NODE name="" content="content"
- wxString GetNodeContent(wxXmlNode *node);
-
- // Check to see if a param exists
- bool HasParam(const wxString& param);
-
- // Finds the node or returns NULL
- wxXmlNode *GetParamNode(const wxString& param);
- wxString GetParamValue(const wxString& param);
-
- // Add style flag (e.g. wxMB_DOCKABLE) to list of flags
- // understood by this handler
- void AddStyle(const wxString& name, int value);
-
- // Add styles common to all wxWindow-derived classes
- void AddWindowStyles();
-
- // Gets style flags from text in form "flag | flag2| flag3 |..."
- // Only understads flags added with AddStyle
- int GetStyle(const wxString& param = wxT("style"), int defaults = 0);
-
- // Gets text from param and does some convertions:
- // - replaces \n, \r, \t by respective chars (according to C syntax)
- // - replaces $ by & and $$ by $ (needed for $File => &File because of XML)
- // - calls wxGetTranslations (unless disabled in wxXmlResource)
- wxString GetText(const wxString& param);
-
- // Return XMLID
- int GetID();
- wxString GetName();
-
- // Get bool flag (1,t,yes,on,true are TRUE, everything else is FALSE)
- bool GetBool(const wxString& param, bool defaultv = FALSE);
-
- // Get integer value from param
- long GetLong( const wxString& param, long defaultv = 0 );
-
- // Get colour in HTML syntax (#RRGGBB)
- wxColour GetColour(const wxString& param);
-
- // Get size/position (may be in dlg units):
- wxSize GetSize(const wxString& param = wxT("size"));
- wxPoint GetPosition(const wxString& param = wxT("pos"));
-
- // Get dimension (may be in dlg units):
- wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
-
- // Get bitmap:
- wxBitmap GetBitmap(const wxString& param = wxT("bitmap"), wxSize size = wxDefaultSize);
- wxIcon GetIcon(const wxString& param = wxT("icon"), wxSize size = wxDefaultSize);
-
- // Get font:
- wxFont GetFont(const wxString& param = wxT("font"));
-
- // Sets common window options:
- void SetupWindow(wxWindow *wnd);
-
- void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE);
- void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
- wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL)
- { return m_Resource->CreateResFromNode(node, parent, instance); }
-
- // helper
- wxFileSystem& GetCurFileSystem() { return m_Resource->GetCurFileSystem(); }
+public:
+ wxXmlResourceHandler();
+ virtual ~wxXmlResourceHandler() {}
+
+ // Creates object (menu, dialog, control, ...) from XML node.
+ // Should check for validity.
+ // parent is higher-level object (usually window, dialog or panel)
+ // that is often neccessary to create resource
+ // if instance != NULL it should not create new instance via 'new' but
+ // rather use this one and call its Create method
+ wxObject *CreateResource(wxXmlNode *node, wxObject *parent,
+ wxObject *instance);
+
+ // This one is called from CreateResource after variables
+ // were filled
+ virtual wxObject *DoCreateResource() = 0;
+
+ // Returns TRUE if it understands this node and can create
+ // resource from it, FALSE otherwise.
+ virtual bool CanHandle(wxXmlNode *node) = 0;
+
+ void SetParentResource(wxXmlResource *res) { m_resource = res; }
+
+
+protected:
+
+ wxXmlResource *m_resource;
+ wxArrayString m_styleNames;
+ wxArrayInt m_styleValues;
+
+ // Variables (filled by CreateResource)
+ wxXmlNode *m_node;
+ wxString m_class;
+ wxObject *m_parent, *m_instance;
+ wxWindow *m_parentAsWindow, *m_instanceAsWindow;
+
+ // --- Handy methods:
+
+ // Returns true if the node has property class equal to classname,
+ // e.g. <object class="wxDialog">
+ bool IsOfClass(wxXmlNode *node, const wxString& classname)
+ { return node->GetPropVal(wxT("class"), wxEmptyString) == classname; }
+
+ // Gets node content from wxXML_ENTITY_NODE
+ // (the problem is, <tag>content<tag> is represented as
+ // wxXML_ENTITY_NODE name="tag", content=""
+ // |-- wxXML_TEXT_NODE or
+ // wxXML_CDATA_SECTION_NODE name="" content="content"
+ wxString GetNodeContent(wxXmlNode *node);
+
+ // Check to see if a param exists
+ bool HasParam(const wxString& param);
+
+ // Finds the node or returns NULL
+ wxXmlNode *GetParamNode(const wxString& param);
+ wxString GetParamValue(const wxString& param);
+
+ // Add style flag (e.g. wxMB_DOCKABLE) to list of flags
+ // understood by this handler
+ void AddStyle(const wxString& name, int value);
+
+ // Add styles common to all wxWindow-derived classes
+ void AddWindowStyles();
+
+ // Gets style flags from text in form "flag | flag2| flag3 |..."
+ // Only understads flags added with AddStyle
+ int GetStyle(const wxString& param = wxT("style"), int defaults = 0);
+
+ // Gets text from param and does some convertions:
+ // - replaces \n, \r, \t by respective chars (according to C syntax)
+ // - replaces $ by & and $$ by $ (needed for $File => &File because of XML)
+ // - calls wxGetTranslations (unless disabled in wxXmlResource)
+ wxString GetText(const wxString& param);
+
+ // Return XMLID
+ int GetID();
+ wxString GetName();
+
+ // Get bool flag (1,t,yes,on,true are TRUE, everything else is FALSE)
+ bool GetBool(const wxString& param, bool defaultv = FALSE);
+
+ // Get integer value from param
+ long GetLong( const wxString& param, long defaultv = 0 );
+
+ // Get colour in HTML syntax (#RRGGBB)
+ wxColour GetColour(const wxString& param);
+
+ // Get size/position (may be in dlg units):
+ wxSize GetSize(const wxString& param = wxT("size"));
+ wxPoint GetPosition(const wxString& param = wxT("pos"));
+
+ // Get dimension (may be in dlg units):
+ wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
+
+ // Get bitmap:
+ wxBitmap GetBitmap(const wxString& param = wxT("bitmap"),
+ wxSize size = wxDefaultSize);
+ wxIcon GetIcon(const wxString& param = wxT("icon"),
+ wxSize size = wxDefaultSize);
+
+ // Get font:
+ wxFont GetFont(const wxString& param = wxT("font"));
+
+ // Sets common window options:
+ void SetupWindow(wxWindow *wnd);
+
+ void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE);
+ void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
+ wxObject *CreateResFromNode(wxXmlNode *node,
+ wxObject *parent, wxObject *instance = NULL)
+ { return m_resource->CreateResFromNode(node, parent, instance); }
+
+ // helper
+ wxFileSystem& GetCurFileSystem() { return m_resource->GetCurFileSystem(); }