]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_notbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_notbk.cpp
3 // Purpose: XRC resource for wxNotebook
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_NOTEBOOK
20 #include "wx/xrc/xh_notbk.h"
23 #include "wx/notebook.h"
24 #include "wx/imaglist.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler
, wxXmlResourceHandler
)
29 wxNotebookXmlHandler::wxNotebookXmlHandler()
30 : wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL
)
32 XRC_ADD_STYLE(wxBK_DEFAULT
);
33 XRC_ADD_STYLE(wxBK_LEFT
);
34 XRC_ADD_STYLE(wxBK_RIGHT
);
35 XRC_ADD_STYLE(wxBK_TOP
);
36 XRC_ADD_STYLE(wxBK_BOTTOM
);
38 #if WXWIN_COMPATIBILITY_2_6
39 XRC_ADD_STYLE(wxNB_DEFAULT
);
40 XRC_ADD_STYLE(wxNB_LEFT
);
41 XRC_ADD_STYLE(wxNB_RIGHT
);
42 XRC_ADD_STYLE(wxNB_TOP
);
43 XRC_ADD_STYLE(wxNB_BOTTOM
);
46 XRC_ADD_STYLE(wxNB_FIXEDWIDTH
);
47 XRC_ADD_STYLE(wxNB_MULTILINE
);
48 XRC_ADD_STYLE(wxNB_NOPAGETHEME
);
53 wxObject
*wxNotebookXmlHandler::DoCreateResource()
55 if (m_class
== wxT("notebookpage"))
57 wxXmlNode
*n
= GetParamNode(wxT("object"));
60 n
= GetParamNode(wxT("object_ref"));
64 bool old_ins
= m_isInside
;
66 wxObject
*item
= CreateResFromNode(n
, m_notebook
, NULL
);
68 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
72 m_notebook
->AddPage(wnd
, GetText(wxT("label")),
73 GetBool(wxT("selected")));
74 if ( HasParam(wxT("bitmap")) )
76 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
77 wxImageList
*imgList
= m_notebook
->GetImageList();
78 if ( imgList
== NULL
)
80 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
81 m_notebook
->AssignImageList( imgList
);
83 int imgIndex
= imgList
->Add(bmp
);
84 m_notebook
->SetPageImage(m_notebook
->GetPageCount()-1, imgIndex
);
88 wxLogError(wxT("Error in resource."));
93 wxLogError(wxT("Error in resource: no control within notebook's <page> tag."));
100 XRC_MAKE_INSTANCE(nb
, wxNotebook
)
102 nb
->Create(m_parentAsWindow
,
104 GetPosition(), GetSize(),
105 GetStyle(wxT("style")),
110 wxNotebook
*old_par
= m_notebook
;
112 bool old_ins
= m_isInside
;
114 CreateChildren(m_notebook
, true/*only this handler*/);
115 m_isInside
= old_ins
;
116 m_notebook
= old_par
;
122 bool wxNotebookXmlHandler::CanHandle(wxXmlNode
*node
)
124 return ((!m_isInside
&& IsOfClass(node
, wxT("wxNotebook"))) ||
125 (m_isInside
&& IsOfClass(node
, wxT("notebookpage"))));
128 #endif // wxUSE_XRC && wxUSE_NOTEBOOK