]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_listbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_listbk.cpp
3 // Purpose: XRC resource for wxListbook
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_LISTBOOK
20 #include "wx/xrc/xh_listbk.h"
23 #include "wx/listbook.h"
24 #include "wx/imaglist.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler
, wxXmlResourceHandler
)
29 wxListbookXmlHandler::wxListbookXmlHandler()
30 : wxXmlResourceHandler(), m_isInside(false), m_listbook(NULL
)
32 XRC_ADD_STYLE(wxBK_DEFAULT
);
33 XRC_ADD_STYLE(wxBK_LEFT
);
34 XRC_ADD_STYLE(wxBK_RIGHT
);
35 XRC_ADD_STYLE(wxBK_TOP
);
36 XRC_ADD_STYLE(wxBK_BOTTOM
);
38 #if WXWIN_COMPATIBILITY_2_6
39 XRC_ADD_STYLE(wxLB_DEFAULT
);
40 XRC_ADD_STYLE(wxLB_LEFT
);
41 XRC_ADD_STYLE(wxLB_RIGHT
);
42 XRC_ADD_STYLE(wxLB_TOP
);
43 XRC_ADD_STYLE(wxLB_BOTTOM
);
49 wxObject
*wxListbookXmlHandler::DoCreateResource()
51 if (m_class
== wxT("listbookpage"))
53 wxXmlNode
*n
= GetParamNode(wxT("object"));
56 n
= GetParamNode(wxT("object_ref"));
60 bool old_ins
= m_isInside
;
62 wxObject
*item
= CreateResFromNode(n
, m_listbook
, NULL
);
64 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
68 m_listbook
->AddPage(wnd
, GetText(wxT("label")),
69 GetBool(wxT("selected")));
70 if ( HasParam(wxT("bitmap")) )
72 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
73 wxImageList
*imgList
= m_listbook
->GetImageList();
74 if ( imgList
== NULL
)
76 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
77 m_listbook
->AssignImageList( imgList
);
79 int imgIndex
= imgList
->Add(bmp
);
80 m_listbook
->SetPageImage(m_listbook
->GetPageCount()-1, imgIndex
);
84 wxLogError(wxT("Error in resource."));
89 wxLogError(wxT("Error in resource: no control within listbook's <page> tag."));
96 XRC_MAKE_INSTANCE(nb
, wxListbook
)
98 nb
->Create(m_parentAsWindow
,
100 GetPosition(), GetSize(),
101 GetStyle(wxT("style")),
104 wxListbook
*old_par
= m_listbook
;
106 bool old_ins
= m_isInside
;
108 CreateChildren(m_listbook
, true/*only this handler*/);
109 m_isInside
= old_ins
;
110 m_listbook
= old_par
;
116 bool wxListbookXmlHandler::CanHandle(wxXmlNode
*node
)
118 return ((!m_isInside
&& IsOfClass(node
, wxT("wxListbook"))) ||
119 (m_isInside
&& IsOfClass(node
, wxT("listbookpage"))));
122 #endif // wxUSE_XRC && wxUSE_LISTBOOK