]>
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 IMPLEMENT_DYNAMIC_CLASS(wxToolbookXmlHandler
, wxXmlResourceHandler
)
31 wxToolbookXmlHandler::wxToolbookXmlHandler()
32 :wxXmlResourceHandler(),
36 XRC_ADD_STYLE(wxBK_DEFAULT
);
37 XRC_ADD_STYLE(wxBK_TOP
);
38 XRC_ADD_STYLE(wxBK_BOTTOM
);
39 XRC_ADD_STYLE(wxBK_LEFT
);
40 XRC_ADD_STYLE(wxBK_RIGHT
);
42 XRC_ADD_STYLE(wxTBK_BUTTONBAR
);
43 XRC_ADD_STYLE(wxTBK_HORZ_LAYOUT
);
48 wxObject
*wxToolbookXmlHandler::DoCreateResource()
50 if (m_class
== wxT("toolbookpage"))
52 wxXmlNode
*n
= GetParamNode(wxT("object"));
55 n
= GetParamNode(wxT("object_ref"));
59 bool old_ins
= m_isInside
;
61 wxObject
*item
= CreateResFromNode(n
, m_toolbook
, NULL
);
63 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
69 if ( HasParam(wxT("bitmap")) )
71 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
72 wxImageList
*imgList
= m_toolbook
->GetImageList();
73 if ( imgList
== NULL
)
75 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
76 m_toolbook
->AssignImageList( imgList
);
78 imgId
= imgList
->Add(bmp
);
80 else if ( HasParam(wxT("image")) )
82 if ( m_toolbook
->GetImageList() )
84 imgId
= (int)GetLong(wxT("image"));
86 else // image without image list?
88 ReportError(n
, "image can only be used in conjunction "
93 m_toolbook
->AddPage(wnd
, GetText(wxT("label")),
94 GetBool(wxT("selected")), imgId
);
98 ReportError(n
, "toolbookpage child must be a window");
104 ReportError("toolbookpage must have a window child");
111 XRC_MAKE_INSTANCE(nb
, wxToolbook
)
113 nb
->Create( m_parentAsWindow
,
115 GetPosition(), GetSize(),
116 GetStyle(wxT("style")),
119 wxImageList
*imagelist
= GetImageList();
121 nb
->AssignImageList(imagelist
);
123 wxToolbook
*old_par
= m_toolbook
;
125 bool old_ins
= m_isInside
;
127 CreateChildren(m_toolbook
, true/*only this handler*/);
128 m_isInside
= old_ins
;
129 m_toolbook
= old_par
;
135 bool wxToolbookXmlHandler::CanHandle(wxXmlNode
*node
)
137 return ((!m_isInside
&& IsOfClass(node
, wxT("wxToolbook"))) ||
138 (m_isInside
&& IsOfClass(node
, wxT("toolbookpage"))));
141 #endif // wxUSE_XRC && wxUSE_TOOLBOOK