]>
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 XRC_ADD_STYLE(wxLB_DEFAULT
);
44 XRC_ADD_STYLE(wxLB_LEFT
);
45 XRC_ADD_STYLE(wxLB_RIGHT
);
46 XRC_ADD_STYLE(wxLB_TOP
);
47 XRC_ADD_STYLE(wxLB_BOTTOM
);
52 wxObject
*wxListbookXmlHandler::DoCreateResource()
54 if (m_class
== wxT("listbookpage"))
56 wxXmlNode
*n
= GetParamNode(wxT("object"));
59 n
= GetParamNode(wxT("object_ref"));
63 bool old_ins
= m_isInside
;
65 wxObject
*item
= CreateResFromNode(n
, m_listbook
, NULL
);
67 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
71 m_listbook
->AddPage(wnd
, GetText(wxT("label")),
72 GetBool(wxT("selected")));
73 if ( HasParam(wxT("bitmap")) )
75 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
76 wxImageList
*imgList
= m_listbook
->GetImageList();
77 if ( imgList
== NULL
)
79 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
80 m_listbook
->AssignImageList( imgList
);
82 int imgIndex
= imgList
->Add(bmp
);
83 m_listbook
->SetPageImage(m_listbook
->GetPageCount()-1, imgIndex
);
85 else if ( HasParam(wxT("image")) )
87 if ( m_listbook
->GetImageList() )
89 m_listbook
->SetPageImage(m_listbook
->GetPageCount()-1,
90 GetLong(wxT("image")) );
92 else // image without image list?
94 ReportError(n
, "image can only be used in conjunction "
101 ReportError(n
, "listbookpage child must be a window");
107 ReportError("listbookpage must have a window child");
114 XRC_MAKE_INSTANCE(nb
, wxListbook
)
116 nb
->Create(m_parentAsWindow
,
118 GetPosition(), GetSize(),
119 GetStyle(wxT("style")),
122 wxImageList
*imagelist
= GetImageList();
124 nb
->AssignImageList(imagelist
);
126 wxListbook
*old_par
= m_listbook
;
128 bool old_ins
= m_isInside
;
130 CreateChildren(m_listbook
, true/*only this handler*/);
131 m_isInside
= old_ins
;
132 m_listbook
= old_par
;
138 bool wxListbookXmlHandler::CanHandle(wxXmlNode
*node
)
140 return ((!m_isInside
&& IsOfClass(node
, wxT("wxListbook"))) ||
141 (m_isInside
&& IsOfClass(node
, wxT("listbookpage"))));
144 #endif // wxUSE_XRC && wxUSE_LISTBOOK