]>
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(wxLB_LEFT
);
36 XRC_ADD_STYLE(wxLB_RIGHT
);
37 XRC_ADD_STYLE(wxLB_TOP
);
38 XRC_ADD_STYLE(wxLB_BOTTOM
);
42 wxObject
*wxChoicebookXmlHandler::DoCreateResource()
44 if (m_class
== wxT("choicebookpage"))
46 wxXmlNode
*n
= GetParamNode(wxT("object"));
49 n
= GetParamNode(wxT("object_ref"));
53 bool old_ins
= m_isInside
;
55 wxObject
*item
= CreateResFromNode(n
, m_choicebook
, NULL
);
57 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
61 m_choicebook
->AddPage(wnd
, GetText(wxT("label")),
62 GetBool(wxT("selected")));
63 if ( HasParam(wxT("bitmap")) )
65 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
66 wxImageList
*imgList
= m_choicebook
->GetImageList();
67 if ( imgList
== NULL
)
69 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
70 m_choicebook
->AssignImageList( imgList
);
72 int imgIndex
= imgList
->Add(bmp
);
73 m_choicebook
->SetPageImage(m_choicebook
->GetPageCount()-1, imgIndex
);
77 wxLogError(wxT("Error in resource."));
82 wxLogError(wxT("Error in resource: no control within choicebook's <page> tag."));
89 XRC_MAKE_INSTANCE(nb
, wxChoicebook
)
91 nb
->Create(m_parentAsWindow
,
93 GetPosition(), GetSize(),
94 GetStyle(wxT("style")),
97 wxChoicebook
*old_par
= m_choicebook
;
99 bool old_ins
= m_isInside
;
101 CreateChildren(m_choicebook
, true/*only this handler*/);
102 m_isInside
= old_ins
;
103 m_choicebook
= old_par
;
109 bool wxChoicebookXmlHandler::CanHandle(wxXmlNode
*node
)
111 return ((!m_isInside
&& IsOfClass(node
, wxT("wxChoicebook"))) ||
112 (m_isInside
&& IsOfClass(node
, wxT("choicebookpage"))));
115 #endif // wxUSE_XRC && wxUSE_CHOICEBOOK