]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_listbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for wxListbook
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2000 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_LISTBOOK
19 #include "wx/xrc/xh_listbk.h"
22 #include "wx/listbook.h"
23 #include "wx/imaglist.h"
26 IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler
, wxXmlResourceHandler
)
28 wxListbookXmlHandler::wxListbookXmlHandler()
29 : wxXmlResourceHandler(), m_isInside(false), m_listbook(NULL
)
31 XRC_ADD_STYLE(wxLB_DEFAULT
);
32 XRC_ADD_STYLE(wxLB_LEFT
);
33 XRC_ADD_STYLE(wxLB_RIGHT
);
34 XRC_ADD_STYLE(wxLB_TOP
);
35 XRC_ADD_STYLE(wxLB_BOTTOM
);
40 wxObject
*wxListbookXmlHandler::DoCreateResource()
42 if (m_class
== wxT("listbookpage"))
44 wxXmlNode
*n
= GetParamNode(wxT("object"));
47 n
= GetParamNode(wxT("object_ref"));
51 bool old_ins
= m_isInside
;
53 wxObject
*item
= CreateResFromNode(n
, m_listbook
, NULL
);
55 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
59 m_listbook
->AddPage(wnd
, GetText(wxT("label")),
60 GetBool(wxT("selected")));
61 if ( HasParam(wxT("bitmap")) )
63 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
64 wxImageList
*imgList
= m_listbook
->GetImageList();
65 if ( imgList
== NULL
)
67 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
68 m_listbook
->AssignImageList( imgList
);
70 int imgIndex
= imgList
->Add(bmp
);
71 m_listbook
->SetPageImage(m_listbook
->GetPageCount()-1, imgIndex
);
75 wxLogError(wxT("Error in resource."));
80 wxLogError(wxT("Error in resource: no control within listbook's <page> tag."));
87 XRC_MAKE_INSTANCE(nb
, wxListbook
)
89 nb
->Create(m_parentAsWindow
,
91 GetPosition(), GetSize(),
92 GetStyle(wxT("style")),
95 wxListbook
*old_par
= m_listbook
;
97 bool old_ins
= m_isInside
;
99 CreateChildren(m_listbook
, true/*only this handler*/);
100 m_isInside
= old_ins
;
101 m_listbook
= old_par
;
107 bool wxListbookXmlHandler::CanHandle(wxXmlNode
*node
)
109 return ((!m_isInside
&& IsOfClass(node
, wxT("wxListbook"))) ||
110 (m_isInside
&& IsOfClass(node
, wxT("listbookpage"))));
113 #endif // wxUSE_XRC && wxUSE_LISTBOOK