]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_notbk.cpp
c683fbc273f1f982bbbad311086f85434e241bfa
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"
27 #include "wx/notebook.h"
28 #include "wx/imaglist.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler
, wxXmlResourceHandler
)
32 wxNotebookXmlHandler::wxNotebookXmlHandler()
33 :wxXmlResourceHandler(),
37 XRC_ADD_STYLE(wxBK_DEFAULT
);
38 XRC_ADD_STYLE(wxBK_LEFT
);
39 XRC_ADD_STYLE(wxBK_RIGHT
);
40 XRC_ADD_STYLE(wxBK_TOP
);
41 XRC_ADD_STYLE(wxBK_BOTTOM
);
43 // provide the old synonyms for these fields as well
44 XRC_ADD_STYLE(wxNB_DEFAULT
);
45 XRC_ADD_STYLE(wxNB_LEFT
);
46 XRC_ADD_STYLE(wxNB_RIGHT
);
47 XRC_ADD_STYLE(wxNB_TOP
);
48 XRC_ADD_STYLE(wxNB_BOTTOM
);
50 XRC_ADD_STYLE(wxNB_FIXEDWIDTH
);
51 XRC_ADD_STYLE(wxNB_MULTILINE
);
52 XRC_ADD_STYLE(wxNB_NOPAGETHEME
);
57 wxObject
*wxNotebookXmlHandler::DoCreateResource()
59 if (m_class
== wxT("notebookpage"))
61 wxXmlNode
*n
= GetParamNode(wxT("object"));
64 n
= GetParamNode(wxT("object_ref"));
68 bool old_ins
= m_isInside
;
70 wxObject
*item
= CreateResFromNode(n
, m_notebook
, NULL
);
72 wxWindow
*wnd
= wxDynamicCast(item
, wxWindow
);
76 m_notebook
->AddPage(wnd
, GetText(wxT("label")),
77 GetBool(wxT("selected")));
78 if ( HasParam(wxT("bitmap")) )
80 wxBitmap bmp
= GetBitmap(wxT("bitmap"), wxART_OTHER
);
81 wxImageList
*imgList
= m_notebook
->GetImageList();
82 if ( imgList
== NULL
)
84 imgList
= new wxImageList( bmp
.GetWidth(), bmp
.GetHeight() );
85 m_notebook
->AssignImageList( imgList
);
87 int imgIndex
= imgList
->Add(bmp
);
88 m_notebook
->SetPageImage(m_notebook
->GetPageCount()-1, imgIndex
);
90 else if ( HasParam(wxT("image")) )
92 if ( m_notebook
->GetImageList() )
94 m_notebook
->SetPageImage(m_notebook
->GetPageCount()-1,
95 GetLong(wxT("image")) );
97 else // image without image list?
99 ReportError(n
, "image can only be used in conjunction "
106 ReportError(n
, "notebookpage child must be a window");
112 ReportError("notebookpage must have a window child");
119 XRC_MAKE_INSTANCE(nb
, wxNotebook
)
121 nb
->Create(m_parentAsWindow
,
123 GetPosition(), GetSize(),
124 GetStyle(wxT("style")),
127 wxImageList
*imagelist
= GetImageList();
129 nb
->AssignImageList(imagelist
);
133 wxNotebook
*old_par
= m_notebook
;
135 bool old_ins
= m_isInside
;
137 CreateChildren(m_notebook
, true/*only this handler*/);
138 m_isInside
= old_ins
;
139 m_notebook
= old_par
;
145 bool wxNotebookXmlHandler::CanHandle(wxXmlNode
*node
)
147 return ((!m_isInside
&& IsOfClass(node
, wxT("wxNotebook"))) ||
148 (m_isInside
&& IsOfClass(node
, wxT("notebookpage"))));
151 #endif // wxUSE_XRC && wxUSE_NOTEBOOK