]>
Commit | Line | Data |
---|---|---|
00b4e7c9 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/xrc/xh_auinotbk.cpp | |
3 | // Purpose: XML resource handler for wxAuiNotebook | |
4 | // Author: Steve Lamerton | |
5 | // Created: 2009-06-12 | |
00b4e7c9 VZ |
6 | // Copyright: (c) 2009 Steve Lamerton |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | // For compilers that support precompilation, includes "wx.h". | |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
17 | #if wxUSE_XRC && wxUSE_AUI | |
18 | ||
19 | #include "wx/xrc/xh_auinotbk.h" | |
20 | #include "wx/aui/auibook.h" | |
21 | ||
22 | wxIMPLEMENT_DYNAMIC_CLASS(wxAuiNotebookXmlHandler, wxXmlResourceHandler); | |
23 | ||
24 | wxAuiNotebookXmlHandler::wxAuiNotebookXmlHandler() | |
25 | : wxXmlResourceHandler() | |
26 | { | |
27 | XRC_ADD_STYLE(wxAUI_NB_DEFAULT_STYLE); | |
28 | XRC_ADD_STYLE(wxAUI_NB_TAB_SPLIT); | |
29 | XRC_ADD_STYLE(wxAUI_NB_TAB_MOVE); | |
30 | XRC_ADD_STYLE(wxAUI_NB_TAB_EXTERNAL_MOVE); | |
31 | XRC_ADD_STYLE(wxAUI_NB_TAB_FIXED_WIDTH); | |
32 | XRC_ADD_STYLE(wxAUI_NB_SCROLL_BUTTONS); | |
33 | XRC_ADD_STYLE(wxAUI_NB_WINDOWLIST_BUTTON); | |
34 | XRC_ADD_STYLE(wxAUI_NB_CLOSE_BUTTON); | |
35 | XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ACTIVE_TAB); | |
36 | XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ALL_TABS); | |
37 | XRC_ADD_STYLE(wxAUI_NB_TOP); | |
38 | XRC_ADD_STYLE(wxAUI_NB_BOTTOM); | |
39 | ||
40 | AddWindowStyles(); | |
41 | } | |
42 | ||
43 | wxObject *wxAuiNotebookXmlHandler::DoCreateResource() | |
44 | { | |
45 | if (m_class == wxT("notebookpage")) | |
46 | { | |
47 | wxXmlNode *anb = GetParamNode(wxT("object")); | |
48 | ||
49 | if (!anb) | |
50 | anb = GetParamNode(wxT("object_ref")); | |
51 | ||
52 | if (anb) | |
53 | { | |
54 | bool old_ins = m_isInside; | |
55 | m_isInside = false; | |
56 | wxObject *item = CreateResFromNode(anb, m_notebook, NULL); | |
57 | m_isInside = old_ins; | |
58 | wxWindow *wnd = wxDynamicCast(item, wxWindow); | |
59 | ||
60 | if (wnd) | |
61 | { | |
62 | if ( HasParam(wxT("bitmap")) ) | |
63 | { | |
64 | m_notebook->AddPage(wnd, | |
65 | GetText(wxT("label")), | |
66 | GetBool(wxT("selected")), | |
67 | GetBitmap(wxT("bitmap"), wxART_OTHER)); | |
68 | } | |
69 | else | |
70 | { | |
71 | m_notebook->AddPage(wnd, | |
72 | GetText(wxT("label")), | |
73 | GetBool(wxT("selected"))); | |
74 | } | |
75 | } | |
76 | else | |
77 | { | |
78 | ReportError(anb, "notebookpage child must be a window"); | |
79 | } | |
80 | return wnd; | |
81 | } | |
82 | else | |
83 | { | |
84 | ReportError("notebookpage must have a window child"); | |
85 | return NULL; | |
86 | } | |
87 | } | |
88 | else | |
89 | { | |
90 | XRC_MAKE_INSTANCE(anb, wxAuiNotebook) | |
91 | ||
92 | anb->Create(m_parentAsWindow, | |
93 | GetID(), | |
94 | GetPosition(), | |
95 | GetSize(), | |
96 | GetStyle(wxT("style"))); | |
97 | ||
98 | SetupWindow(anb); | |
99 | ||
100 | wxAuiNotebook *old_par = m_notebook; | |
101 | m_notebook = anb; | |
102 | bool old_ins = m_isInside; | |
103 | m_isInside = true; | |
104 | CreateChildren(m_notebook, true/*only this handler*/); | |
105 | m_isInside = old_ins; | |
106 | m_notebook = old_par; | |
107 | ||
108 | return anb; | |
109 | } | |
110 | } | |
111 | ||
112 | bool wxAuiNotebookXmlHandler::CanHandle(wxXmlNode *node) | |
113 | { | |
114 | return ((!m_isInside && IsOfClass(node, wxT("wxAuiNotebook"))) || | |
115 | (m_isInside && IsOfClass(node, wxT("notebookpage")))); | |
116 | } | |
117 | ||
118 | #endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL |