]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/xrc/xh_sizer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xrc/xh_sizer.h
3 // Purpose: XML resource handler for wxSizer
4 // Author: Kinaou Hervé
6 // Copyright: (c) 2010 wxWidgets development team
7 // Licence: wxWindows license
8 /////////////////////////////////////////////////////////////////////////////
11 @class wxSizerXmlHandler
13 @class wxXmlResourceHandler
15 wxSizerXmlHandler is a class for resource handlers capable of creating
16 a wxSizer object from an XML node.
18 @see wxXmlResourceHandler, wxSizer
23 class wxSizerXmlHandler
: public wxXmlResourceHandler
28 Initializes the attributes and adds the supported styles.
33 Creates a sizer, sizeritem or spacer object, depending on
34 the current handled node.
35 @see wxXmlResourceHandler::DoCreateResource().
37 virtual wxObject
*DoCreateResource();
40 Returns @true if the given node can be handled by this class.
41 If the node concerns a sizer object, the method IsSizerNode is called
42 to know if the class is managed or not.
43 If the node concerns a sizer item or a spacer, @true is returned.
44 Otherwise @false is returned.
45 @see wxXmlResourceHandler::CanHandle().
47 virtual bool CanHandle(wxXmlNode
*node
);
51 Creates an object of type wxSizer from the XML node content.
53 This virtual method can be overridden to add support for custom sizer
54 classes to the derived handler.
56 Notice that if you override this method you would typically overload
57 IsSizerNode() as well.
59 Example of use of this method:
61 class MySizerXmlHandler : public wxSizerXmlHandler
66 bool IsSizerNode(wxXmlNode *node) const
68 return IsOfClass(node, "MySizer") ||
69 wxSizerXmlHandler::IsSizerNode(node));
72 void DoCreateSizer(const wxString& name)
74 if ( name == "MySizer" )
75 return Handle_MySizer();
77 return wxSizerXmlHandler::DoCreateSizer(name);
81 wxSizer* Handle_MySizer()
83 // Create your own sizer here from XRC content (see
84 // wxXmlResource methods) and return the instance.
91 virtual wxSizer
* DoCreateSizer(const wxString
& name
);
94 Used by CanHandle() to know if the given node contains a sizer
95 supported by this class.
97 This method should be overridden to allow this handler to be used for
98 the custom sizer types.
100 See the example in DoCreateSizer() description for how it can be used.
104 virtual bool IsSizerNode(wxXmlNode
*node
) const;