]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_notbk.cpp
Warning fix.
[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
78d14f80
VS
11#ifdef __GNUG__
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"
28#include "wx/sizer.h"
29
854e189f
VS
30IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
31
f80ea77b
WS
32wxNotebookXmlHandler::wxNotebookXmlHandler()
33: wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
78d14f80 34{
544fee32
VS
35 XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
36 XRC_ADD_STYLE(wxNB_LEFT);
37 XRC_ADD_STYLE(wxNB_RIGHT);
2c12c792 38 XRC_ADD_STYLE(wxNB_TOP);
544fee32 39 XRC_ADD_STYLE(wxNB_BOTTOM);
78d14f80
VS
40 AddWindowStyles();
41}
42
78d14f80 43wxObject *wxNotebookXmlHandler::DoCreateResource()
f80ea77b 44{
78d14f80
VS
45 if (m_class == wxT("notebookpage"))
46 {
47 wxXmlNode *n = GetParamNode(wxT("object"));
48
544fee32
VS
49 if ( !n )
50 n = GetParamNode(wxT("object_ref"));
f2588180 51
78d14f80
VS
52 if (n)
53 {
54 bool old_ins = m_isInside;
f80ea77b 55 m_isInside = false;
78d14f80 56 wxObject *item = CreateResFromNode(n, m_notebook, NULL);
71ff7c91 57 m_isInside = old_ins;
78d14f80
VS
58 wxWindow *wnd = wxDynamicCast(item, wxWindow);
59
60 if (wnd)
61 m_notebook->AddPage(wnd, GetText(wxT("label")),
9fbad34d 62 GetBool(wxT("selected")));
f80ea77b
WS
63 else
64 wxLogError(wxT("Error in resource."));
78d14f80
VS
65 return wnd;
66 }
67 else
68 {
69 wxLogError(wxT("Error in resource: no control within notebook's <page> tag."));
70 return NULL;
71 }
72 }
f80ea77b
WS
73
74 else
544fee32
VS
75 {
76 XRC_MAKE_INSTANCE(nb, wxNotebook)
f2588180 77
f80ea77b 78 nb->Create(m_parentAsWindow,
544fee32
VS
79 GetID(),
80 GetPosition(), GetSize(),
81 GetStyle(wxT("style")),
82 GetName());
f2588180 83
78d14f80
VS
84 wxNotebook *old_par = m_notebook;
85 m_notebook = nb;
86 bool old_ins = m_isInside;
f80ea77b
WS
87 m_isInside = true;
88 CreateChildren(m_notebook, true/*only this handler*/);
78d14f80
VS
89 m_isInside = old_ins;
90 m_notebook = old_par;
91
adbf2d73 92 return nb;
78d14f80
VS
93 }
94}
95
78d14f80
VS
96bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
97{
98 return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) ||
99 (m_isInside && IsOfClass(node, wxT("notebookpage"))));
100}
101
621be1ec 102#endif // wxUSE_XRC && wxUSE_NOTEBOOK