]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_choicbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_choicbk.cpp
3 // Purpose: XRC resource for wxChoicebook
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2000 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "xh_choicbk.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #if wxUSE_XRC && wxUSE_CHOICEBOOK
23 #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(wxCHB_DEFAULT
);
36 XRC_ADD_STYLE(wxCHB_LEFT
);
37 XRC_ADD_STYLE(wxCHB_RIGHT
);
38 XRC_ADD_STYLE(wxCHB_TOP
);
39 XRC_ADD_STYLE(wxCHB_BOTTOM
);
44 wxObject
*wxChoicebookXmlHandler::DoCreateResource()
46 if (m_class
== wxT("choicebookpage"))
48 wxXmlNode
*n
= GetParamNode(wxT("object"));
51 n
= GetParamNode(wxT("object_ref"));
55 bool old_ins
= m_isInside
;
57 wxObject
*item
= CreateResFromNode(n
, m_choicebook
, NULL
);
59 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
63 m_choicebook
->AddPage(wnd
, GetText(wxT("label")),
64 GetBool(wxT("selected")));
65 if ( HasParam(wxT("bitmap")) )
67 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
68 wxImageList
*imgList
= m_choicebook
->GetImageList();
69 if ( imgList
== NULL
)
71 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
72 m_choicebook
->AssignImageList( imgList
);
74 int imgIndex
= imgList
->Add(bmp
);
75 m_choicebook
->SetPageImage(m_choicebook
->GetPageCount()-1, imgIndex
);
79 wxLogError(wxT("Error in resource."));
84 wxLogError(wxT("Error in resource: no control within choicebook's <page> tag."));
91 XRC_MAKE_INSTANCE(nb
, wxChoicebook
)
93 nb
->Create(m_parentAsWindow
,
95 GetPosition(), GetSize(),
96 GetStyle(wxT("style")),
99 wxChoicebook
*old_par
= m_choicebook
;
101 bool old_ins
= m_isInside
;
103 CreateChildren(m_choicebook
, true/*only this handler*/);
104 m_isInside
= old_ins
;
105 m_choicebook
= old_par
;
111 bool wxChoicebookXmlHandler::CanHandle(wxXmlNode
*node
)
113 return ((!m_isInside
&& IsOfClass(node
, wxT("wxChoicebook"))) ||
114 (m_isInside
&& IsOfClass(node
, wxT("choicebookpage"))));
117 #endif // wxUSE_XRC && wxUSE_CHOICEBOOK