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