]>
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"
26 #include "wx/choicebk.h"
27 #include "wx/imaglist.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxChoicebookXmlHandler
, wxXmlResourceHandler
)
32 wxChoicebookXmlHandler::wxChoicebookXmlHandler()
33 : wxXmlResourceHandler(), m_isInside(false), m_choicebook(NULL
)
35 XRC_ADD_STYLE(wxBK_DEFAULT
);
36 XRC_ADD_STYLE(wxBK_LEFT
);
37 XRC_ADD_STYLE(wxBK_RIGHT
);
38 XRC_ADD_STYLE(wxBK_TOP
);
39 XRC_ADD_STYLE(wxBK_BOTTOM
);
41 #if WXWIN_COMPATIBILITY_2_6
42 XRC_ADD_STYLE(wxCHB_DEFAULT
);
43 XRC_ADD_STYLE(wxCHB_LEFT
);
44 XRC_ADD_STYLE(wxCHB_RIGHT
);
45 XRC_ADD_STYLE(wxCHB_TOP
);
46 XRC_ADD_STYLE(wxCHB_BOTTOM
);
52 wxObject
*wxChoicebookXmlHandler::DoCreateResource()
54 if (m_class
== wxT("choicebookpage"))
56 wxXmlNode
*n
= GetParamNode(wxT("object"));
59 n
= GetParamNode(wxT("object_ref"));
63 bool old_ins
= m_isInside
;
65 wxObject
*item
= CreateResFromNode(n
, m_choicebook
, NULL
);
67 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
71 m_choicebook
->AddPage(wnd
, GetText(wxT("label")),
72 GetBool(wxT("selected")));
73 if ( HasParam(wxT("bitmap")) )
75 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
76 wxImageList
*imgList
= m_choicebook
->GetImageList();
77 if ( imgList
== NULL
)
79 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
80 m_choicebook
->AssignImageList( imgList
);
82 int imgIndex
= imgList
->Add(bmp
);
83 m_choicebook
->SetPageImage(m_choicebook
->GetPageCount()-1, imgIndex
);
87 wxLogError(wxT("Error in resource."));
92 wxLogError(wxT("Error in resource: no control within choicebook's <page> tag."));
99 XRC_MAKE_INSTANCE(nb
, wxChoicebook
)
101 nb
->Create(m_parentAsWindow
,
103 GetPosition(), GetSize(),
104 GetStyle(wxT("style")),
107 wxChoicebook
*old_par
= m_choicebook
;
109 bool old_ins
= m_isInside
;
111 CreateChildren(m_choicebook
, true/*only this handler*/);
112 m_isInside
= old_ins
;
113 m_choicebook
= old_par
;
119 bool wxChoicebookXmlHandler::CanHandle(wxXmlNode
*node
)
121 return ((!m_isInside
&& IsOfClass(node
, wxT("wxChoicebook"))) ||
122 (m_isInside
&& IsOfClass(node
, wxT("choicebookpage"))));
125 #endif // wxUSE_XRC && wxUSE_CHOICEBOOK