]>
Commit | Line | Data |
---|---|---|
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 | ||
30 | wxNotebookXmlHandler::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); | |
37 | AddWindowStyles(); | |
38 | } | |
39 | ||
40 | ||
41 | ||
42 | wxObject *wxNotebookXmlHandler::DoCreateResource() | |
43 | { | |
44 | if (m_class == wxT("notebookpage")) | |
45 | { | |
46 | wxXmlNode *n = GetParamNode(wxT("object")); | |
47 | ||
f2588180 VS |
48 | if ( !n ) |
49 | n = GetParamNode(wxT("object_ref")); | |
50 | ||
78d14f80 VS |
51 | if (n) |
52 | { | |
53 | bool old_ins = m_isInside; | |
54 | m_isInside = FALSE; | |
55 | m_isInside = old_ins; | |
56 | wxObject *item = CreateResFromNode(n, m_notebook, NULL); | |
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 | ||
73 | else { | |
f2588180 VS |
74 | wxNotebook *nb = wxStaticCast(m_instance, wxNotebook); |
75 | ||
76 | if ( !nb ) | |
77 | nb = new wxNotebook; | |
78 | ||
79 | nb->Create(m_parentAsWindow, | |
80 | GetID(), | |
81 | GetPosition(), GetSize(), | |
82 | GetStyle( wxT("style" )), | |
83 | GetName()); | |
84 | ||
78d14f80 VS |
85 | wxNotebook *old_par = m_notebook; |
86 | m_notebook = nb; | |
87 | bool old_ins = m_isInside; | |
88 | m_isInside = TRUE; | |
89 | CreateChildren(m_notebook, TRUE/*only this handler*/); | |
90 | m_isInside = old_ins; | |
91 | m_notebook = old_par; | |
92 | ||
93 | if (GetBool(wxT("usenotebooksizer"), FALSE)) | |
94 | return new wxNotebookSizer(nb); | |
95 | else | |
96 | return nb; | |
97 | } | |
98 | } | |
99 | ||
100 | ||
101 | ||
102 | bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node) | |
103 | { | |
104 | return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) || | |
105 | (m_isInside && IsOfClass(node, wxT("notebookpage")))); | |
106 | } | |
107 | ||
108 | #endif |