]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_toolbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_toolbk.cpp
3 // Purpose: XRC resource for wxToolbook
4 // Author: Andrea Zanellato
6 // Copyright: (c) 2010 wxWidgets development team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_TOOLBOOK
19 #include "wx/xrc/xh_toolbk.h"
26 #include "wx/toolbook.h"
27 #include "wx/imaglist.h"
29 #include "wx/xml/xml.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxToolbookXmlHandler
, wxXmlResourceHandler
)
33 wxToolbookXmlHandler::wxToolbookXmlHandler()
34 :wxXmlResourceHandler(),
38 XRC_ADD_STYLE(wxBK_DEFAULT
);
39 XRC_ADD_STYLE(wxBK_TOP
);
40 XRC_ADD_STYLE(wxBK_BOTTOM
);
41 XRC_ADD_STYLE(wxBK_LEFT
);
42 XRC_ADD_STYLE(wxBK_RIGHT
);
44 XRC_ADD_STYLE(wxTBK_BUTTONBAR
);
45 XRC_ADD_STYLE(wxTBK_HORZ_LAYOUT
);
50 wxObject
*wxToolbookXmlHandler::DoCreateResource()
52 if (m_class
== wxT("toolbookpage"))
54 wxXmlNode
*n
= GetParamNode(wxT("object"));
57 n
= GetParamNode(wxT("object_ref"));
61 bool old_ins
= m_isInside
;
63 wxObject
*item
= CreateResFromNode(n
, m_toolbook
, NULL
);
65 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
71 if ( HasParam(wxT("bitmap")) )
73 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
74 wxImageList
*imgList
= m_toolbook
->GetImageList();
75 if ( imgList
== NULL
)
77 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
78 m_toolbook
->AssignImageList( imgList
);
80 imgId
= imgList
->Add(bmp
);
82 else if ( HasParam(wxT("image")) )
84 if ( m_toolbook
->GetImageList() )
86 imgId
= (int)GetLong(wxT("image"));
88 else // image without image list?
90 ReportError(n
, "image can only be used in conjunction "
95 m_toolbook
->AddPage(wnd
, GetText(wxT("label")),
96 GetBool(wxT("selected")), imgId
);
100 ReportError(n
, "toolbookpage child must be a window");
106 ReportError("toolbookpage must have a window child");
113 XRC_MAKE_INSTANCE(nb
, wxToolbook
)
115 nb
->Create( m_parentAsWindow
,
117 GetPosition(), GetSize(),
118 GetStyle(wxT("style")),
121 wxImageList
*imagelist
= GetImageList();
123 nb
->AssignImageList(imagelist
);
125 wxToolbook
*old_par
= m_toolbook
;
127 bool old_ins
= m_isInside
;
129 CreateChildren(m_toolbook
, true/*only this handler*/);
130 m_isInside
= old_ins
;
131 m_toolbook
= old_par
;
137 bool wxToolbookXmlHandler::CanHandle(wxXmlNode
*node
)
139 return ((!m_isInside
&& IsOfClass(node
, wxT("wxToolbook"))) ||
140 (m_isInside
&& IsOfClass(node
, wxT("toolbookpage"))));
143 #endif // wxUSE_XRC && wxUSE_TOOLBOOK