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