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