]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_notbk.cpp
removed assert which became incorrect after last change
[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/////////////////////////////////////////////////////////////////////////////
10
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
78d14f80
VS
32wxNotebookXmlHandler::wxNotebookXmlHandler()
33: wxXmlResourceHandler(), m_isInside(FALSE), m_notebook(NULL)
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
VS
42wxObject *wxNotebookXmlHandler::DoCreateResource()
43{
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;
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));
62 else
63 wxLogError(wxT("Error in resource."));
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 }
72
544fee32
VS
73 else
74 {
75 XRC_MAKE_INSTANCE(nb, wxNotebook)
f2588180 76
544fee32
VS
77 nb->Create(m_parentAsWindow,
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;
86 m_isInside = TRUE;
87 CreateChildren(m_notebook, TRUE/*only this handler*/);
88 m_isInside = old_ins;
89 m_notebook = old_par;
90
91 if (GetBool(wxT("usenotebooksizer"), FALSE))
92 return new wxNotebookSizer(nb);
93 else
94 return nb;
95 }
96}
97
78d14f80
VS
98bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
99{
100 return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) ||
101 (m_isInside && IsOfClass(node, wxT("notebookpage"))));
102}
103
104#endif