]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_choicbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_choicbk.cpp
3 // Purpose: XRC resource for wxChoicebook
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_CHOICEBOOK
20 #include "wx/xrc/xh_choicbk.h"
27 #include "wx/choicebk.h"
28 #include "wx/imaglist.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxChoicebookXmlHandler
, wxXmlResourceHandler
)
32 wxChoicebookXmlHandler::wxChoicebookXmlHandler()
33 :wxXmlResourceHandler(),
37 XRC_ADD_STYLE(wxBK_DEFAULT
);
38 XRC_ADD_STYLE(wxBK_LEFT
);
39 XRC_ADD_STYLE(wxBK_RIGHT
);
40 XRC_ADD_STYLE(wxBK_TOP
);
41 XRC_ADD_STYLE(wxBK_BOTTOM
);
43 #if WXWIN_COMPATIBILITY_2_6
44 XRC_ADD_STYLE(wxCHB_DEFAULT
);
45 XRC_ADD_STYLE(wxCHB_LEFT
);
46 XRC_ADD_STYLE(wxCHB_RIGHT
);
47 XRC_ADD_STYLE(wxCHB_TOP
);
48 XRC_ADD_STYLE(wxCHB_BOTTOM
);
54 wxObject
*wxChoicebookXmlHandler::DoCreateResource()
56 if (m_class
== wxT("choicebookpage"))
58 wxXmlNode
*n
= GetParamNode(wxT("object"));
61 n
= GetParamNode(wxT("object_ref"));
65 bool old_ins
= m_isInside
;
67 wxObject
*item
= CreateResFromNode(n
, m_choicebook
, NULL
);
69 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
73 m_choicebook
->AddPage(wnd
, GetText(wxT("label")),
74 GetBool(wxT("selected")));
75 if ( HasParam(wxT("bitmap")) )
77 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
78 wxImageList
*imgList
= m_choicebook
->GetImageList();
79 if ( imgList
== NULL
)
81 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
82 m_choicebook
->AssignImageList( imgList
);
84 int imgIndex
= imgList
->Add(bmp
);
85 m_choicebook
->SetPageImage(m_choicebook
->GetPageCount()-1, imgIndex
);
89 wxLogError(wxT("Error in resource."));
94 wxLogError(wxT("Error in resource: no control within choicebook's <page> tag."));
101 XRC_MAKE_INSTANCE(nb
, wxChoicebook
)
103 nb
->Create(m_parentAsWindow
,
105 GetPosition(), GetSize(),
106 GetStyle(wxT("style")),
109 wxChoicebook
*old_par
= m_choicebook
;
111 bool old_ins
= m_isInside
;
113 CreateChildren(m_choicebook
, true/*only this handler*/);
114 m_isInside
= old_ins
;
115 m_choicebook
= old_par
;
121 bool wxChoicebookXmlHandler::CanHandle(wxXmlNode
*node
)
123 return ((!m_isInside
&& IsOfClass(node
, wxT("wxChoicebook"))) ||
124 (m_isInside
&& IsOfClass(node
, wxT("choicebookpage"))));
127 #endif // wxUSE_XRC && wxUSE_CHOICEBOOK