]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "xh_listbk.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #if wxUSE_XRC && wxUSE_LISTBOOK
23 #include "wx/xrc/xh_listbk.h"
26 #include "wx/listbook.h"
27 #include "wx/imaglist.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler
, wxXmlResourceHandler
)
32 wxListbookXmlHandler::wxListbookXmlHandler()
33 : wxXmlResourceHandler(), m_isInside(false), m_listbook(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
*wxListbookXmlHandler::DoCreateResource()
44 if (m_class
== wxT("listbookpage"))
46 wxXmlNode
*n
= GetParamNode(wxT("object"));
49 n
= GetParamNode(wxT("object_ref"));
53 bool old_ins
= m_isInside
;
55 wxObject
*item
= CreateResFromNode(n
, m_listbook
, NULL
);
57 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
61 m_listbook
->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_listbook
->GetImageList();
67 if ( imgList
== NULL
)
69 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
70 m_listbook
->AssignImageList( imgList
);
72 int imgIndex
= imgList
->Add(bmp
);
73 m_listbook
->SetPageImage(m_listbook
->GetPageCount()-1, imgIndex
);
77 wxLogError(wxT("Error in resource."));
82 wxLogError(wxT("Error in resource: no control within listbook's <page> tag."));
89 XRC_MAKE_INSTANCE(nb
, wxListbook
)
91 nb
->Create(m_parentAsWindow
,
93 GetPosition(), GetSize(),
94 GetStyle(wxT("style")),
97 wxListbook
*old_par
= m_listbook
;
99 bool old_ins
= m_isInside
;
101 CreateChildren(m_listbook
, true/*only this handler*/);
102 m_isInside
= old_ins
;
103 m_listbook
= old_par
;
109 bool wxListbookXmlHandler::CanHandle(wxXmlNode
*node
)
111 return ((!m_isInside
&& IsOfClass(node
, wxT("wxListbook"))) ||
112 (m_isInside
&& IsOfClass(node
, wxT("listbookpage"))));
115 #endif // wxUSE_XRC && wxUSE_LISTBOOK