]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_listbk.cpp
fixed unused param 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
2ddb4d13 6// RCS-ID: $Id$
9aaf1192
WS
7// Copyright: (c) 2000 Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
9aaf1192
WS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#if wxUSE_XRC && wxUSE_LISTBOOK
19
20#include "wx/xrc/xh_listbk.h"
21
22#include "wx/log.h"
23#include "wx/listbook.h"
24#include "wx/imaglist.h"
25#include "wx/sizer.h"
26
27IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler, wxXmlResourceHandler)
28
29wxListbookXmlHandler::wxListbookXmlHandler()
30: wxXmlResourceHandler(), m_isInside(false), m_listbook(NULL)
31{
2ddb4d13
WS
32 XRC_ADD_STYLE(wxBK_DEFAULT);
33 XRC_ADD_STYLE(wxBK_LEFT);
34 XRC_ADD_STYLE(wxBK_RIGHT);
35 XRC_ADD_STYLE(wxBK_TOP);
36 XRC_ADD_STYLE(wxBK_BOTTOM);
37
38#if WXWIN_COMPATIBILITY_2_6
5a439c1a 39 XRC_ADD_STYLE(wxLB_DEFAULT);
9aaf1192
WS
40 XRC_ADD_STYLE(wxLB_LEFT);
41 XRC_ADD_STYLE(wxLB_RIGHT);
42 XRC_ADD_STYLE(wxLB_TOP);
43 XRC_ADD_STYLE(wxLB_BOTTOM);
2ddb4d13 44#endif
5a439c1a 45
9aaf1192
WS
46 AddWindowStyles();
47}
48
49wxObject *wxListbookXmlHandler::DoCreateResource()
50{
51 if (m_class == wxT("listbookpage"))
52 {
53 wxXmlNode *n = GetParamNode(wxT("object"));
54
55 if ( !n )
56 n = GetParamNode(wxT("object_ref"));
57
58 if (n)
59 {
60 bool old_ins = m_isInside;
61 m_isInside = false;
62 wxObject *item = CreateResFromNode(n, m_listbook, NULL);
63 m_isInside = old_ins;
64 wxWindow *wnd = wxDynamicCast(item, wxWindow);
65
66 if (wnd)
67 {
68 m_listbook->AddPage(wnd, GetText(wxT("label")),
69 GetBool(wxT("selected")));
70 if ( HasParam(wxT("bitmap")) )
71 {
72 wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
73 wxImageList *imgList = m_listbook->GetImageList();
74 if ( imgList == NULL )
75 {
76 imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
77 m_listbook->AssignImageList( imgList );
78 }
79 int imgIndex = imgList->Add(bmp);
80 m_listbook->SetPageImage(m_listbook->GetPageCount()-1, imgIndex );
81 }
82 }
83 else
84 wxLogError(wxT("Error in resource."));
85 return wnd;
86 }
87 else
88 {
89 wxLogError(wxT("Error in resource: no control within listbook's <page> tag."));
90 return NULL;
91 }
92 }
93
94 else
95 {
96 XRC_MAKE_INSTANCE(nb, wxListbook)
97
98 nb->Create(m_parentAsWindow,
99 GetID(),
100 GetPosition(), GetSize(),
101 GetStyle(wxT("style")),
102 GetName());
103
104 wxListbook *old_par = m_listbook;
105 m_listbook = nb;
106 bool old_ins = m_isInside;
107 m_isInside = true;
108 CreateChildren(m_listbook, true/*only this handler*/);
109 m_isInside = old_ins;
110 m_listbook = old_par;
111
112 return nb;
113 }
114}
115
116bool wxListbookXmlHandler::CanHandle(wxXmlNode *node)
117{
118 return ((!m_isInside && IsOfClass(node, wxT("wxListbook"))) ||
119 (m_isInside && IsOfClass(node, wxT("listbookpage"))));
120}
121
122#endif // wxUSE_XRC && wxUSE_LISTBOOK