]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_notbk.cpp
Fixed home and end accelerators.
[wxWidgets.git] / src / xrc / xh_notbk.cpp
CommitLineData
78d14f80 1/////////////////////////////////////////////////////////////////////////////
2ddb4d13 2// Name: src/xrc/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/////////////////////////////////////////////////////////////////////////////
78d14f80
VS
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
621be1ec 18#if wxUSE_XRC && wxUSE_NOTEBOOK
78d14f80 19
a1e4ec87 20#include "wx/xrc/xh_notbk.h"
78d14f80
VS
21
22#include "wx/log.h"
23#include "wx/notebook.h"
48414952 24#include "wx/imaglist.h"
78d14f80
VS
25#include "wx/sizer.h"
26
854e189f
VS
27IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
28
f80ea77b
WS
29wxNotebookXmlHandler::wxNotebookXmlHandler()
30: wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
78d14f80 31{
2ddb4d13
WS
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);
37
38#if WXWIN_COMPATIBILITY_2_6
5a439c1a 39 XRC_ADD_STYLE(wxNB_DEFAULT);
544fee32
VS
40 XRC_ADD_STYLE(wxNB_LEFT);
41 XRC_ADD_STYLE(wxNB_RIGHT);
2c12c792 42 XRC_ADD_STYLE(wxNB_TOP);
544fee32 43 XRC_ADD_STYLE(wxNB_BOTTOM);
2ddb4d13 44#endif
5a439c1a
WS
45
46 XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
47 XRC_ADD_STYLE(wxNB_MULTILINE);
48 XRC_ADD_STYLE(wxNB_NOPAGETHEME);
49
78d14f80
VS
50 AddWindowStyles();
51}
52
78d14f80 53wxObject *wxNotebookXmlHandler::DoCreateResource()
f80ea77b 54{
78d14f80
VS
55 if (m_class == wxT("notebookpage"))
56 {
57 wxXmlNode *n = GetParamNode(wxT("object"));
58
544fee32
VS
59 if ( !n )
60 n = GetParamNode(wxT("object_ref"));
f2588180 61
78d14f80
VS
62 if (n)
63 {
64 bool old_ins = m_isInside;
f80ea77b 65 m_isInside = false;
78d14f80 66 wxObject *item = CreateResFromNode(n, m_notebook, NULL);
71ff7c91 67 m_isInside = old_ins;
78d14f80
VS
68 wxWindow *wnd = wxDynamicCast(item, wxWindow);
69
70 if (wnd)
48414952 71 {
78d14f80 72 m_notebook->AddPage(wnd, GetText(wxT("label")),
9fbad34d 73 GetBool(wxT("selected")));
48414952
JS
74 if ( HasParam(wxT("bitmap")) )
75 {
76 wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
77 wxImageList *imgList = m_notebook->GetImageList();
78 if ( imgList == NULL )
79 {
80 imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
81 m_notebook->AssignImageList( imgList );
82 }
83 int imgIndex = imgList->Add(bmp);
84 m_notebook->SetPageImage(m_notebook->GetPageCount()-1, imgIndex );
85 }
86 }
f80ea77b
WS
87 else
88 wxLogError(wxT("Error in resource."));
78d14f80
VS
89 return wnd;
90 }
91 else
92 {
93 wxLogError(wxT("Error in resource: no control within notebook's <page> tag."));
94 return NULL;
95 }
96 }
f80ea77b
WS
97
98 else
544fee32
VS
99 {
100 XRC_MAKE_INSTANCE(nb, wxNotebook)
f2588180 101
f80ea77b 102 nb->Create(m_parentAsWindow,
544fee32
VS
103 GetID(),
104 GetPosition(), GetSize(),
105 GetStyle(wxT("style")),
106 GetName());
f2588180 107
311b2ea7
VS
108 SetupWindow(nb);
109
78d14f80
VS
110 wxNotebook *old_par = m_notebook;
111 m_notebook = nb;
112 bool old_ins = m_isInside;
f80ea77b
WS
113 m_isInside = true;
114 CreateChildren(m_notebook, true/*only this handler*/);
78d14f80
VS
115 m_isInside = old_ins;
116 m_notebook = old_par;
117
adbf2d73 118 return nb;
78d14f80
VS
119 }
120}
121
78d14f80
VS
122bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
123{
124 return ((!m_isInside && IsOfClass(node, wxT("wxNotebook"))) ||
125 (m_isInside && IsOfClass(node, wxT("notebookpage"))));
126}
127
621be1ec 128#endif // wxUSE_XRC && wxUSE_NOTEBOOK