]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_listbk.cpp
Add virtual ~wxAnyScrollHelperBase() to fix compiler warning.
[wxWidgets.git] / src / xrc / xh_listbk.cpp
CommitLineData
9aaf1192 1/////////////////////////////////////////////////////////////////////////////
2ddb4d13 2// Name: src/xrc/xh_listbk.cpp
9aaf1192
WS
3// Purpose: XRC resource for wxListbook
4// Author: Vaclav Slavik
5// Created: 2000/03/21
6// Copyright: (c) 2000 Vaclav Slavik
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
9aaf1192
WS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#if wxUSE_XRC && wxUSE_LISTBOOK
18
19#include "wx/xrc/xh_listbk.h"
20
e4db172a
WS
21#ifndef WX_PRECOMP
22 #include "wx/log.h"
ed2fbeb8 23 #include "wx/sizer.h"
e4db172a
WS
24#endif
25
9aaf1192
WS
26#include "wx/listbook.h"
27#include "wx/imaglist.h"
9aaf1192
WS
28
29IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler, wxXmlResourceHandler)
30
31wxListbookXmlHandler::wxListbookXmlHandler()
ed2fbeb8
WS
32 :wxXmlResourceHandler(),
33 m_isInside(false),
34 m_listbook(NULL)
9aaf1192 35{
2ddb4d13
WS
36 XRC_ADD_STYLE(wxBK_DEFAULT);
37 XRC_ADD_STYLE(wxBK_LEFT);
38 XRC_ADD_STYLE(wxBK_RIGHT);
39 XRC_ADD_STYLE(wxBK_TOP);
40 XRC_ADD_STYLE(wxBK_BOTTOM);
41
5a439c1a 42 XRC_ADD_STYLE(wxLB_DEFAULT);
9aaf1192
WS
43 XRC_ADD_STYLE(wxLB_LEFT);
44 XRC_ADD_STYLE(wxLB_RIGHT);
45 XRC_ADD_STYLE(wxLB_TOP);
46 XRC_ADD_STYLE(wxLB_BOTTOM);
5a439c1a 47
9aaf1192
WS
48 AddWindowStyles();
49}
50
51wxObject *wxListbookXmlHandler::DoCreateResource()
52{
53 if (m_class == wxT("listbookpage"))
54 {
55 wxXmlNode *n = GetParamNode(wxT("object"));
56
57 if ( !n )
58 n = GetParamNode(wxT("object_ref"));
59
60 if (n)
61 {
62 bool old_ins = m_isInside;
63 m_isInside = false;
64 wxObject *item = CreateResFromNode(n, m_listbook, NULL);
65 m_isInside = old_ins;
66 wxWindow *wnd = wxDynamicCast(item, wxWindow);
67
68 if (wnd)
69 {
70 m_listbook->AddPage(wnd, GetText(wxT("label")),
71 GetBool(wxT("selected")));
72 if ( HasParam(wxT("bitmap")) )
73 {
74 wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
75 wxImageList *imgList = m_listbook->GetImageList();
76 if ( imgList == NULL )
77 {
78 imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
79 m_listbook->AssignImageList( imgList );
80 }
81 int imgIndex = imgList->Add(bmp);
82 m_listbook->SetPageImage(m_listbook->GetPageCount()-1, imgIndex );
83 }
326462ae
VZ
84 else if ( HasParam(wxT("image")) )
85 {
86 if ( m_listbook->GetImageList() )
87 {
88 m_listbook->SetPageImage(m_listbook->GetPageCount()-1,
89 GetLong(wxT("image")) );
90 }
91 else // image without image list?
92 {
93 ReportError(n, "image can only be used in conjunction "
94 "with imagelist");
95 }
96 }
9aaf1192
WS
97 }
98 else
819559b2
VS
99 {
100 ReportError(n, "listbookpage child must be a window");
101 }
9aaf1192
WS
102 return wnd;
103 }
104 else
105 {
819559b2 106 ReportError("listbookpage must have a window child");
9aaf1192
WS
107 return NULL;
108 }
109 }
110
111 else
112 {
113 XRC_MAKE_INSTANCE(nb, wxListbook)
114
115 nb->Create(m_parentAsWindow,
116 GetID(),
117 GetPosition(), GetSize(),
118 GetStyle(wxT("style")),
119 GetName());
120
326462ae
VZ
121 wxImageList *imagelist = GetImageList();
122 if ( imagelist )
123 nb->AssignImageList(imagelist);
124
9aaf1192
WS
125 wxListbook *old_par = m_listbook;
126 m_listbook = nb;
127 bool old_ins = m_isInside;
128 m_isInside = true;
129 CreateChildren(m_listbook, true/*only this handler*/);
130 m_isInside = old_ins;
131 m_listbook = old_par;
132
133 return nb;
134 }
135}
136
137bool wxListbookXmlHandler::CanHandle(wxXmlNode *node)
138{
139 return ((!m_isInside && IsOfClass(node, wxT("wxListbook"))) ||
140 (m_isInside && IsOfClass(node, wxT("listbookpage"))));
141}
142
143#endif // wxUSE_XRC && wxUSE_LISTBOOK