]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_notbk.cpp
wxSYS_COLOUR_WINDOW is better for window backgrounds on PPC/Smartphone
[wxWidgets.git] / src / xrc / xh_notbk.cpp
CommitLineData
78d14f80
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_notbk.cpp
b5d6954b 3// Purpose: XRC resource for wxNotebook
78d14f80
VS
4// Author: Vaclav Slavik
5// Created: 2000/03/21
6// RCS-ID: $Id$
7// Copyright: (c) 2000 Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
f80ea77b 10
c575e45a 11#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
78d14f80
VS
12#pragma implementation "xh_notbk.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
621be1ec 22#if wxUSE_XRC && wxUSE_NOTEBOOK
78d14f80 23
a1e4ec87 24#include "wx/xrc/xh_notbk.h"
78d14f80
VS
25
26#include "wx/log.h"
27#include "wx/notebook.h"
48414952 28#include "wx/imaglist.h"
78d14f80
VS
29#include "wx/sizer.h"
30
854e189f
VS
31IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
32
f80ea77b
WS
33wxNotebookXmlHandler::wxNotebookXmlHandler()
34: wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
78d14f80 35{
5a439c1a 36 XRC_ADD_STYLE(wxNB_DEFAULT);
544fee32
VS
37 XRC_ADD_STYLE(wxNB_LEFT);
38 XRC_ADD_STYLE(wxNB_RIGHT);
2c12c792 39 XRC_ADD_STYLE(wxNB_TOP);
544fee32 40 XRC_ADD_STYLE(wxNB_BOTTOM);
5a439c1a
WS
41
42 XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
43 XRC_ADD_STYLE(wxNB_MULTILINE);
44 XRC_ADD_STYLE(wxNB_NOPAGETHEME);
45
78d14f80
VS
46 AddWindowStyles();
47}
48
78d14f80 49wxObject *wxNotebookXmlHandler::DoCreateResource()
f80ea77b 50{
78d14f80
VS
51 if (m_class == wxT("notebookpage"))
52 {
53 wxXmlNode *n = GetParamNode(wxT("object"));
54
544fee32
VS
55 if ( !n )
56 n = GetParamNode(wxT("object_ref"));
f2588180 57
78d14f80
VS
58 if (n)
59 {
60 bool old_ins = m_isInside;
f80ea77b 61 m_isInside = false;
78d14f80 62 wxObject *item = CreateResFromNode(n, m_notebook, NULL);
71ff7c91 63 m_isInside = old_ins;
78d14f80
VS
64 wxWindow *wnd = wxDynamicCast(item, wxWindow);
65
66 if (wnd)
48414952 67 {
78d14f80 68 m_notebook->AddPage(wnd, GetText(wxT("label")),
9fbad34d 69 GetBool(wxT("selected")));
48414952
JS
70 if ( HasParam(wxT("bitmap")) )
71 {
72 wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
73 wxImageList *imgList = m_notebook->GetImageList();
74 if ( imgList == NULL )
75 {
76 imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
77 m_notebook->AssignImageList( imgList );
78 }
79 int imgIndex = imgList->Add(bmp);
80 m_notebook->SetPageImage(m_notebook->GetPageCount()-1, imgIndex );
81 }
82 }
f80ea77b
WS
83 else
84 wxLogError(wxT("Error in resource."));
78d14f80
VS
85 return wnd;
86 }
87 else
88 {
89 wxLogError(wxT("Error in resource: no control within notebook's <page> tag."));
90 return NULL;
91 }
92 }
f80ea77b
WS
93
94 else
544fee32
VS
95 {
96 XRC_MAKE_INSTANCE(nb, wxNotebook)
f2588180 97
f80ea77b 98 nb->Create(m_parentAsWindow,
544fee32
VS
99 GetID(),
100 GetPosition(), GetSize(),
101 GetStyle(wxT("style")),
102 GetName());
f2588180 103
311b2ea7
VS
104 SetupWindow(nb);
105
78d14f80
VS
106 wxNotebook *old_par = m_notebook;
107 m_notebook = nb;
108 bool old_ins = m_isInside;
f80ea77b
WS
109 m_isInside = true;
110 CreateChildren(m_notebook, true/*only this handler*/);
78d14f80
VS
111 m_isInside = old_ins;
112 m_notebook = old_par;
113
adbf2d73 114 return nb;
78d14f80
VS
115 }
116}
117
78d14f80
VS
118bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
119{
120 return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) ||
121 (m_isInside && IsOfClass(node, wxT("notebookpage"))));
122}
123
621be1ec 124#endif // wxUSE_XRC && wxUSE_NOTEBOOK