]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/xrc/xh_sizer.h
wxDefaultVideoMode is const
[wxWidgets.git] / interface / wx / xrc / xh_sizer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xrc/xh_sizer.h
3 // Purpose: XML resource handler for wxSizer
4 // Author: Kinaou Hervé
5 // Created: 2010-10-24
6 // Copyright: (c) 2010 wxWidgets development team
7 // Licence: wxWindows license
8 /////////////////////////////////////////////////////////////////////////////
9
10 /**
11 @class wxSizerXmlHandler
12
13 @class wxXmlResourceHandler
14
15 wxSizerXmlHandler is a class for resource handlers capable of creating
16 a wxSizer object from an XML node.
17
18 @see wxXmlResourceHandler, wxSizer
19
20 @library{wxxrc}
21 @category{xrc}
22 */
23 class wxSizerXmlHandler : public wxXmlResourceHandler
24 {
25 public:
26 /**
27 Constructor.
28 Initializes the attributes and adds the supported styles.
29 */
30 wxSizerXmlHandler();
31
32 /**
33 Creates a sizer, sizeritem or spacer object, depending on
34 the current handled node.
35 @see wxXmlResourceHandler::DoCreateResource().
36 */
37 virtual wxObject *DoCreateResource();
38
39 /**
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().
46 */
47 virtual bool CanHandle(wxXmlNode *node);
48
49 protected:
50 /**
51 Creates an object of type wxSizer from the XML node content.
52
53 This virtual method can be overridden to add support for custom sizer
54 classes to the derived handler.
55
56 Notice that if you override this method you would typically overload
57 IsSizerNode() as well.
58
59 Example of use of this method:
60 @code
61 class MySizerXmlHandler : public wxSizerXmlHandler
62 {
63 ...
64
65 protected:
66 bool IsSizerNode(wxXmlNode *node) const
67 {
68 return IsOfClass(node, "MySizer") ||
69 wxSizerXmlHandler::IsSizerNode(node));
70 }
71
72 void DoCreateSizer(const wxString& name)
73 {
74 if ( name == "MySizer" )
75 return Handle_MySizer();
76 else
77 return wxSizerXmlHandler::DoCreateSizer(name);
78 }
79
80 private:
81 wxSizer* Handle_MySizer()
82 {
83 // Create your own sizer here from XRC content (see
84 // wxXmlResource methods) and return the instance.
85 }
86 };
87 @endcode
88
89 @since 2.9.2
90 */
91 virtual wxSizer* DoCreateSizer(const wxString& name);
92
93 /**
94 Used by CanHandle() to know if the given node contains a sizer
95 supported by this class.
96
97 This method should be overridden to allow this handler to be used for
98 the custom sizer types.
99
100 See the example in DoCreateSizer() description for how it can be used.
101
102 @since 2.9.2
103 */
104 virtual bool IsSizerNode(wxXmlNode *node) const;
105
106 };