]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_notbk.cpp
1 /////////////////////////////////////////////////////////////////////////////
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(wxNB_DEFAULT
);
33 XRC_ADD_STYLE(wxNB_LEFT
);
34 XRC_ADD_STYLE(wxNB_RIGHT
);
35 XRC_ADD_STYLE(wxNB_TOP
);
36 XRC_ADD_STYLE(wxNB_BOTTOM
);
38 XRC_ADD_STYLE(wxNB_FIXEDWIDTH
);
39 XRC_ADD_STYLE(wxNB_MULTILINE
);
40 XRC_ADD_STYLE(wxNB_NOPAGETHEME
);
45 wxObject
*wxNotebookXmlHandler::DoCreateResource()
47 if (m_class
== wxT("notebookpage"))
49 wxXmlNode
*n
= GetParamNode(wxT("object"));
52 n
= GetParamNode(wxT("object_ref"));
56 bool old_ins
= m_isInside
;
58 wxObject
*item
= CreateResFromNode(n
, m_notebook
, NULL
);
60 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
64 m_notebook
->AddPage(wnd
, GetText(wxT("label")),
65 GetBool(wxT("selected")));
66 if ( HasParam(wxT("bitmap")) )
68 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
69 wxImageList
*imgList
= m_notebook
->GetImageList();
70 if ( imgList
== NULL
)
72 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
73 m_notebook
->AssignImageList( imgList
);
75 int imgIndex
= imgList
->Add(bmp
);
76 m_notebook
->SetPageImage(m_notebook
->GetPageCount()-1, imgIndex
);
80 wxLogError(wxT("Error in resource."));
85 wxLogError(wxT("Error in resource: no control within notebook's <page> tag."));
92 XRC_MAKE_INSTANCE(nb
, wxNotebook
)
94 nb
->Create(m_parentAsWindow
,
96 GetPosition(), GetSize(),
97 GetStyle(wxT("style")),
102 wxNotebook
*old_par
= m_notebook
;
104 bool old_ins
= m_isInside
;
106 CreateChildren(m_notebook
, true/*only this handler*/);
107 m_isInside
= old_ins
;
108 m_notebook
= old_par
;
114 bool wxNotebookXmlHandler::CanHandle(wxXmlNode
*node
)
116 return ((!m_isInside
&& IsOfClass(node
, wxT("wxNotebook"))) ||
117 (m_isInside
&& IsOfClass(node
, wxT("notebookpage"))));
120 #endif // wxUSE_XRC && wxUSE_NOTEBOOK