]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_wizrd.cpp
forgot to commit project file for CW before
[wxWidgets.git] / contrib / src / xrc / xh_wizrd.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_wizrd.cpp
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 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "xh_wizrd.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
22 #if wxUSE_WIZARDDLG
23
24 #include "wx/xrc/xh_wizrd.h"
25 #include "wx/log.h"
26 #include "wx/wizard.h"
27
28
29 wxWizardXmlHandler::wxWizardXmlHandler() : wxXmlResourceHandler()
30 {
31 m_wizard = NULL;
32 m_lastSimplePage = NULL;
33 XRC_ADD_STYLE(wxWIZARD_EX_HELPBUTTON);
34 }
35
36 wxObject *wxWizardXmlHandler::DoCreateResource()
37 {
38 if (m_class == wxT("wxWizard"))
39 {
40 XRC_MAKE_INSTANCE(wiz, wxWizard)
41
42 long style = GetStyle(wxT("exstyle"), 0);
43 if (style != 0)
44 wiz->SetExtraStyle(style);
45 wiz->Create(m_parentAsWindow,
46 GetID(),
47 GetText(wxT("title")),
48 GetBitmap(),
49 GetPosition());
50
51 wxWizard *old = m_wizard;
52 m_wizard = wiz;
53 m_lastSimplePage = NULL;
54 CreateChildren(wiz, true /*this handler only*/);
55 m_wizard = old;
56 return wiz;
57 }
58 else
59 {
60 wxWizardPage *page = NULL;
61 if (m_class == wxT("wxWizardPageSimple"))
62 {
63 XRC_MAKE_INSTANCE(p, wxWizardPageSimple)
64 p->Create(m_wizard, NULL, NULL, GetBitmap());
65 if (m_lastSimplePage)
66 wxWizardPageSimple::Chain(m_lastSimplePage, p);
67 page = p;
68 m_lastSimplePage = p;
69 }
70 else /*if (m_class == wxT("wxWizardPage"))*/
71 {
72 wxWizardPage *p = NULL;
73 if (m_instance)
74 p = wxStaticCast(m_instance, wxWizardPage);
75 else
76 wxLogError(wxT("wxWizardPage is abstract class, must be subclassed"));
77 p->Create(m_wizard, GetBitmap());
78 page = p;
79 }
80
81 page->SetName(GetName());
82 page->SetId(GetID());
83
84 SetupWindow(page);
85 CreateChildren(page);
86 return page;
87 }
88 }
89
90 bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
91 {
92 return IsOfClass(node, wxT("wxWizard")) ||
93 (m_wizard != NULL &&
94 (IsOfClass(node, wxT("wxWizardPage")) ||
95 IsOfClass(node, wxT("wxWizardPageSimple")))
96 );
97 }
98
99 #endif // wxUSE_WIZARDDLG