]>
Commit | Line | Data |
---|---|---|
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 | |
30 | wxNotebookXmlHandler::wxNotebookXmlHandler() | |
ab708d5d | 31 | : wxXmlResourceHandler(), m_isInside(FALSE), m_notebook(NULL) |
56d2f750 VS |
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 | ||
42 | wxObject *wxNotebookXmlHandler::DoCreateResource() | |
43 | { | |
ab708d5d | 44 | if (m_class == wxT("notebookpage")) |
56d2f750 | 45 | { |
a559d708 | 46 | wxXmlNode *n = GetParamNode(wxT("object")); |
e066e256 VS |
47 | |
48 | if (n) | |
49 | { | |
ab708d5d VS |
50 | bool old_ins = m_isInside; |
51 | m_isInside = FALSE; | |
52 | m_isInside = old_ins; | |
53 | wxObject *item = CreateResFromNode(n, m_notebook, NULL); | |
e066e256 VS |
54 | wxWindow *wnd = wxDynamicCast(item, wxWindow); |
55 | ||
56 | if (wnd) | |
ab708d5d | 57 | m_notebook->AddPage(wnd, GetText(wxT("label")), |
a559d708 | 58 | GetBool(wxT("selected"), 0)); |
e066e256 | 59 | else |
a559d708 | 60 | wxLogError(wxT("Error in resource.")); |
e066e256 VS |
61 | return wnd; |
62 | } | |
63 | else | |
56d2f750 | 64 | { |
a559d708 | 65 | wxLogError(wxT("Error in resource: no control within notebook's <page> tag.")); |
e066e256 | 66 | return NULL; |
56d2f750 | 67 | } |
56d2f750 VS |
68 | } |
69 | ||
70 | else { | |
ab708d5d | 71 | wxNotebook *nb = new wxNotebook(m_parentAsWindow, |
56d2f750 VS |
72 | GetID(), |
73 | GetPosition(), GetSize(), | |
a559d708 | 74 | GetStyle( wxT("style" )), |
56d2f750 VS |
75 | GetName()); |
76 | ||
ab708d5d VS |
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 | 84 | |
a559d708 | 85 | if (GetBool(wxT("usenotebooksizer"), FALSE)) |
0bed1cee VS |
86 | return new wxNotebookSizer(nb); |
87 | else | |
88 | return nb; | |
56d2f750 VS |
89 | } |
90 | } | |
91 | ||
92 | ||
93 | ||
94 | bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node) | |
95 | { | |
ab708d5d VS |
96 | return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) || |
97 | (m_isInside && IsOfClass(node, wxT("notebookpage")))); | |
56d2f750 VS |
98 | } |
99 | ||
100 | #endif |