]>
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"
27 #include "wx/listbook.h"
28 #include "wx/imaglist.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler
, wxXmlResourceHandler
)
32 wxListbookXmlHandler::wxListbookXmlHandler()
33 :wxXmlResourceHandler(),
37 XRC_ADD_STYLE(wxBK_DEFAULT
);
38 XRC_ADD_STYLE(wxBK_LEFT
);
39 XRC_ADD_STYLE(wxBK_RIGHT
);
40 XRC_ADD_STYLE(wxBK_TOP
);
41 XRC_ADD_STYLE(wxBK_BOTTOM
);
43 #if WXWIN_COMPATIBILITY_2_6
44 XRC_ADD_STYLE(wxLB_DEFAULT
);
45 XRC_ADD_STYLE(wxLB_LEFT
);
46 XRC_ADD_STYLE(wxLB_RIGHT
);
47 XRC_ADD_STYLE(wxLB_TOP
);
48 XRC_ADD_STYLE(wxLB_BOTTOM
);
54 wxObject
*wxListbookXmlHandler::DoCreateResource()
56 if (m_class
== wxT("listbookpage"))
58 wxXmlNode
*n
= GetParamNode(wxT("object"));
61 n
= GetParamNode(wxT("object_ref"));
65 bool old_ins
= m_isInside
;
67 wxObject
*item
= CreateResFromNode(n
, m_listbook
, NULL
);
69 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
73 m_listbook
->AddPage(wnd
, GetText(wxT("label")),
74 GetBool(wxT("selected")));
75 if ( HasParam(wxT("bitmap")) )
77 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
78 wxImageList
*imgList
= m_listbook
->GetImageList();
79 if ( imgList
== NULL
)
81 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
82 m_listbook
->AssignImageList( imgList
);
84 int imgIndex
= imgList
->Add(bmp
);
85 m_listbook
->SetPageImage(m_listbook
->GetPageCount()-1, imgIndex
);
90 ReportError(n
, "listbookpage child must be a window");
96 ReportError("listbookpage must have a window child");
103 XRC_MAKE_INSTANCE(nb
, wxListbook
)
105 nb
->Create(m_parentAsWindow
,
107 GetPosition(), GetSize(),
108 GetStyle(wxT("style")),
111 wxListbook
*old_par
= m_listbook
;
113 bool old_ins
= m_isInside
;
115 CreateChildren(m_listbook
, true/*only this handler*/);
116 m_isInside
= old_ins
;
117 m_listbook
= old_par
;
123 bool wxListbookXmlHandler::CanHandle(wxXmlNode
*node
)
125 return ((!m_isInside
&& IsOfClass(node
, wxT("wxListbook"))) ||
126 (m_isInside
&& IsOfClass(node
, wxT("listbookpage"))));
129 #endif // wxUSE_XRC && wxUSE_LISTBOOK