]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_notbk.cpp
no changes, just mention gtk_paint_expander() in comment
[wxWidgets.git] / src / xrc / xh_notbk.cpp
CommitLineData
78d14f80
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_notbk.cpp
b5d6954b 3// Purpose: XRC resource for wxNotebook
78d14f80
VS
4// Author: Vaclav Slavik
5// Created: 2000/03/21
6// RCS-ID: $Id$
7// Copyright: (c) 2000 Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
f80ea77b 10
c575e45a 11#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
78d14f80
VS
12#pragma implementation "xh_notbk.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
621be1ec 22#if wxUSE_XRC && wxUSE_NOTEBOOK
78d14f80 23
a1e4ec87 24#include "wx/xrc/xh_notbk.h"
78d14f80
VS
25
26#include "wx/log.h"
27#include "wx/notebook.h"
48414952 28#include "wx/imaglist.h"
78d14f80
VS
29#include "wx/sizer.h"
30
854e189f
VS
31IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
32
f80ea77b
WS
33wxNotebookXmlHandler::wxNotebookXmlHandler()
34: wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
78d14f80 35{
544fee32
VS
36 XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
37 XRC_ADD_STYLE(wxNB_LEFT);
38 XRC_ADD_STYLE(wxNB_RIGHT);
2c12c792 39 XRC_ADD_STYLE(wxNB_TOP);
544fee32 40 XRC_ADD_STYLE(wxNB_BOTTOM);
78d14f80
VS
41 AddWindowStyles();
42}
43
78d14f80 44wxObject *wxNotebookXmlHandler::DoCreateResource()
f80ea77b 45{
78d14f80
VS
46 if (m_class == wxT("notebookpage"))
47 {
48 wxXmlNode *n = GetParamNode(wxT("object"));
49
544fee32
VS
50 if ( !n )
51 n = GetParamNode(wxT("object_ref"));
f2588180 52
78d14f80
VS
53 if (n)
54 {
55 bool old_ins = m_isInside;
f80ea77b 56 m_isInside = false;
78d14f80 57 wxObject *item = CreateResFromNode(n, m_notebook, NULL);
71ff7c91 58 m_isInside = old_ins;
78d14f80
VS
59 wxWindow *wnd = wxDynamicCast(item, wxWindow);
60
61 if (wnd)
48414952 62 {
78d14f80 63 m_notebook->AddPage(wnd, GetText(wxT("label")),
9fbad34d 64 GetBool(wxT("selected")));
48414952
JS
65 if ( HasParam(wxT("bitmap")) )
66 {
67 wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
68 wxImageList *imgList = m_notebook->GetImageList();
69 if ( imgList == NULL )
70 {
71 imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
72 m_notebook->AssignImageList( imgList );
73 }
74 int imgIndex = imgList->Add(bmp);
75 m_notebook->SetPageImage(m_notebook->GetPageCount()-1, imgIndex );
76 }
77 }
f80ea77b
WS
78 else
79 wxLogError(wxT("Error in resource."));
78d14f80
VS
80 return wnd;
81 }
82 else
83 {
84 wxLogError(wxT("Error in resource: no control within notebook's <page> tag."));
85 return NULL;
86 }
87 }
f80ea77b
WS
88
89 else
544fee32
VS
90 {
91 XRC_MAKE_INSTANCE(nb, wxNotebook)
f2588180 92
f80ea77b 93 nb->Create(m_parentAsWindow,
544fee32
VS
94 GetID(),
95 GetPosition(), GetSize(),
96 GetStyle(wxT("style")),
97 GetName());
f2588180 98
78d14f80
VS
99 wxNotebook *old_par = m_notebook;
100 m_notebook = nb;
101 bool old_ins = m_isInside;
f80ea77b
WS
102 m_isInside = true;
103 CreateChildren(m_notebook, true/*only this handler*/);
78d14f80
VS
104 m_isInside = old_ins;
105 m_notebook = old_par;
106
adbf2d73 107 return nb;
78d14f80
VS
108 }
109}
110
78d14f80
VS
111bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
112{
113 return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) ||
114 (m_isInside && IsOfClass(node, wxT("notebookpage"))));
115}
116
621be1ec 117#endif // wxUSE_XRC && wxUSE_NOTEBOOK