]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_wizrd.cpp
Don't crash if XRC file contains '_' at the end of a string.
[wxWidgets.git] / src / xrc / xh_wizrd.cpp
CommitLineData
e5db28fd 1/////////////////////////////////////////////////////////////////////////////
e4db172a 2// Name: src/xrc/xh_wizrd.cpp
e5db28fd
VS
3// Purpose: XRC resource for wxWizard
4// Author: Vaclav Slavik
5// Created: 2003/03/01
6// RCS-ID: $Id$
7// Copyright: (c) 2000 Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
f80ea77b 10
e5db28fd
VS
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_WIZARDDLG
e5db28fd
VS
19
20#include "wx/xrc/xh_wizrd.h"
e4db172a
WS
21
22#ifndef WX_PRECOMP
23 #include "wx/log.h"
24#endif
25
e5db28fd
VS
26#include "wx/wizard.h"
27
854e189f 28IMPLEMENT_DYNAMIC_CLASS(wxWizardXmlHandler, wxXmlResourceHandler)
e5db28fd
VS
29
30wxWizardXmlHandler::wxWizardXmlHandler() : wxXmlResourceHandler()
31{
32 m_wizard = NULL;
33 m_lastSimplePage = NULL;
34 XRC_ADD_STYLE(wxWIZARD_EX_HELPBUTTON);
73026ab9 35 AddWindowStyles();
e5db28fd
VS
36}
37
38wxObject *wxWizardXmlHandler::DoCreateResource()
f80ea77b 39{
e5db28fd
VS
40 if (m_class == wxT("wxWizard"))
41 {
42 XRC_MAKE_INSTANCE(wiz, wxWizard)
43
44 long style = GetStyle(wxT("exstyle"), 0);
45 if (style != 0)
46 wiz->SetExtraStyle(style);
47 wiz->Create(m_parentAsWindow,
48 GetID(),
49 GetText(wxT("title")),
50 GetBitmap(),
51 GetPosition());
1b5d7525 52 SetupWindow(wiz);
e5db28fd
VS
53
54 wxWizard *old = m_wizard;
55 m_wizard = wiz;
56 m_lastSimplePage = NULL;
57 CreateChildren(wiz, true /*this handler only*/);
58 m_wizard = old;
59 return wiz;
60 }
61 else
62 {
37b6a426 63 wxWizardPage *page;
19d0f58d 64
e5db28fd
VS
65 if (m_class == wxT("wxWizardPageSimple"))
66 {
67 XRC_MAKE_INSTANCE(p, wxWizardPageSimple)
68 p->Create(m_wizard, NULL, NULL, GetBitmap());
69 if (m_lastSimplePage)
70 wxWizardPageSimple::Chain(m_lastSimplePage, p);
71 page = p;
72 m_lastSimplePage = p;
73 }
74 else /*if (m_class == wxT("wxWizardPage"))*/
75 {
37b6a426
VZ
76 if ( !m_instance )
77 {
819559b2 78 ReportError("wxWizardPage is abstract class and must be subclassed");
37b6a426
VZ
79 return NULL;
80 }
81
82 page = wxStaticCast(m_instance, wxWizardPage);
83 page->Create(m_wizard, GetBitmap());
e5db28fd
VS
84 }
85
86 page->SetName(GetName());
87 page->SetId(GetID());
88
89 SetupWindow(page);
90 CreateChildren(page);
91 return page;
92 }
93}
94
95bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
96{
f80ea77b 97 return IsOfClass(node, wxT("wxWizard")) ||
e5db28fd
VS
98 (m_wizard != NULL &&
99 (IsOfClass(node, wxT("wxWizardPage")) ||
100 IsOfClass(node, wxT("wxWizardPageSimple")))
101 );
102}
103
a1e4ec87 104#endif // wxUSE_XRC && wxUSE_WIZARDDLG