]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/xml/xh_notbk.cpp
added wxStaticLine handler
[wxWidgets.git] / contrib / src / xml / xh_notbk.cpp
CommitLineData
56d2f750
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_notbk.cpp
0bed1cee 3// Purpose: XML resource for wxNotebook
56d2f750
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/xml/xh_notbk.h"
23
24#if wxUSE_NOTEBOOK
25
26#include "wx/log.h"
27#include "wx/notebook.h"
0bed1cee 28#include "wx/sizer.h"
56d2f750
VS
29
30wxNotebookXmlHandler::wxNotebookXmlHandler()
31: wxXmlResourceHandler(), m_IsInside(FALSE), m_Notebook(NULL)
32{
33 ADD_STYLE(wxNB_FIXEDWIDTH);
34 ADD_STYLE(wxNB_LEFT);
35 ADD_STYLE(wxNB_RIGHT);
36 ADD_STYLE(wxNB_BOTTOM);
09dc1241 37 AddWindowStyles();
56d2f750
VS
38}
39
40
41
42wxObject *wxNotebookXmlHandler::DoCreateResource()
43{
0bed1cee 44 if (m_Node->GetName() == _T("notebookpage"))
56d2f750 45 {
0bed1cee 46 wxXmlNode *n = GetParamNode(_T("window"))->GetChildren();
56d2f750
VS
47 while (n)
48 {
49 if (n->GetType() == wxXML_ELEMENT_NODE)
0bed1cee 50 {
56d2f750
VS
51 bool old_ins = m_IsInside;
52 m_IsInside = FALSE;
53 m_IsInside = old_ins;
54 wxObject *item = CreateResFromNode(n, m_Notebook, NULL);
55 wxWindow *wnd = wxDynamicCast(item, wxWindow);
56
57 if (wnd)
0bed1cee 58 m_Notebook->AddPage(wnd, GetText(_T("label")),
56d2f750
VS
59 GetBool(_T("selected"), 0));
60 else
61 wxLogError(_T("Error in resource."));
62 return wnd;
63 }
64 n = n->GetNext();
65 }
66 wxLogError(_T("Error in resource: no control within notebook's <page> tag."));
67 return NULL;
68 }
69
70 else {
71 wxNotebook *nb = new wxNotebook(m_ParentAsWindow,
72 GetID(),
73 GetPosition(), GetSize(),
74 GetStyle( _T("style" )),
75 GetName());
76
77 wxNotebook *old_par = m_Notebook;
78 m_Notebook = nb;
79 bool old_ins = m_IsInside;
80 m_IsInside = TRUE;
81 CreateChildren(m_Notebook, TRUE/*only this handler*/);
82 m_IsInside = old_ins;
83 m_Notebook = old_par;
0bed1cee
VS
84
85 if (GetBool(_T("usenotebooksizer"), FALSE))
86 return new wxNotebookSizer(nb);
87 else
88 return nb;
56d2f750
VS
89 }
90}
91
92
93
94bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
95{
96 return ((!m_IsInside && node->GetName() == _T("notebook")) ||
0bed1cee 97 (m_IsInside && node->GetName() == _T("notebookpage")));
56d2f750
VS
98}
99
100#endif