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