]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxWizard handler to XRC
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 22 Apr 2003 20:25:50 +0000 (20:25 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 22 Apr 2003 20:25:50 +0000 (20:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20310 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/include/wx/xrc/xh_all.h
contrib/include/wx/xrc/xh_wizrd.h [new file with mode: 0644]
contrib/src/xrc/xh_wizrd.cpp [new file with mode: 0644]
contrib/src/xrc/xmlrsall.cpp
docs/changes.txt
include/wx/xrc/xh_all.h
include/wx/xrc/xh_wizrd.h [new file with mode: 0644]
src/xrc/xh_wizrd.cpp [new file with mode: 0644]
src/xrc/xmlrsall.cpp

index 8f62594126525c52403c802d42dcb74f92a9be0f..51ccbf3533ff7d3b8c8f6fac8dd35efe6ef5e9be 100644 (file)
@@ -48,5 +48,6 @@
 #include "wx/xrc/xh_frame.h"
 #include "wx/xrc/xh_scwin.h"
 #include "wx/xrc/xh_split.h"
+#include "wx/xrc/xh_wizrd.h"
 
 #endif // _WX_XMLRES_H_
diff --git a/contrib/include/wx/xrc/xh_wizrd.h b/contrib/include/wx/xrc/xh_wizrd.h
new file mode 100644 (file)
index 0000000..aa5dfbf
--- /dev/null
@@ -0,0 +1,38 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        xh_wizrd.h
+// Purpose:     XML resource handler for wxWizard
+// Author:      Vaclav Slavik
+// Created:     2003/03/02
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_XH_WIZRD_H_
+#define _WX_XH_WIZRDL_H_
+
+#if defined(__GNUG__) && !defined(__APPLE__)
+#pragma interface "xh_wizrd.h"
+#endif
+
+#include "wx/xrc/xmlres.h"
+
+#if wxUSE_WIZARDDLG
+
+#include "wx/wizard.h"
+
+class WXXMLDLLEXPORT wxWizardXmlHandler : public wxXmlResourceHandler
+{
+public:
+    wxWizardXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+
+private:
+    wxWizard *m_wizard;
+    wxWizardPageSimple *m_lastSimplePage;
+};
+
+#endif
+
+#endif // _WX_XH_PANEL_H_
diff --git a/contrib/src/xrc/xh_wizrd.cpp b/contrib/src/xrc/xh_wizrd.cpp
new file mode 100644 (file)
index 0000000..958845b
--- /dev/null
@@ -0,0 +1,99 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        xh_wizrd.cpp
+// Purpose:     XRC resource for wxWizard
+// Author:      Vaclav Slavik
+// Created:     2003/03/01
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __GNUG__
+#pragma implementation "xh_wizrd.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_WIZARDDLG
+
+#include "wx/xrc/xh_wizrd.h"
+#include "wx/log.h"
+#include "wx/wizard.h"
+
+
+wxWizardXmlHandler::wxWizardXmlHandler() : wxXmlResourceHandler()
+{
+    m_wizard = NULL;
+    m_lastSimplePage = NULL;
+    XRC_ADD_STYLE(wxWIZARD_EX_HELPBUTTON);
+}
+
+wxObject *wxWizardXmlHandler::DoCreateResource()
+{ 
+    if (m_class == wxT("wxWizard"))
+    {
+        XRC_MAKE_INSTANCE(wiz, wxWizard)
+
+        long style = GetStyle(wxT("exstyle"), 0);
+        if (style != 0)
+            wiz->SetExtraStyle(style);
+        wiz->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("title")),
+                    GetBitmap(),
+                    GetPosition());
+
+        wxWizard *old = m_wizard;
+        m_wizard = wiz;
+        m_lastSimplePage = NULL;
+        CreateChildren(wiz, true /*this handler only*/);
+        m_wizard = old;
+        return wiz;
+    }
+    else
+    {
+        wxWizardPage *page = NULL;
+        if (m_class == wxT("wxWizardPageSimple"))
+        {
+            XRC_MAKE_INSTANCE(p, wxWizardPageSimple)
+            p->Create(m_wizard, NULL, NULL, GetBitmap());
+            if (m_lastSimplePage)
+                wxWizardPageSimple::Chain(m_lastSimplePage, p);
+            page = p;
+            m_lastSimplePage = p;
+        }
+        else /*if (m_class == wxT("wxWizardPage"))*/
+        {
+            wxWizardPage *p = NULL;
+            if (m_instance)
+                p = wxStaticCast(m_instance, wxWizardPage);
+            else
+                wxLogError(wxT("wxWizardPage is abstract class, must be subclassed"));
+            p->Create(m_wizard, GetBitmap());
+            page = p;
+        }
+
+        page->SetName(GetName());
+        page->SetId(GetID());
+
+        SetupWindow(page);
+        CreateChildren(page);
+        return page;
+    }
+}
+
+bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("wxWizard")) || 
+           (m_wizard != NULL &&
+                (IsOfClass(node, wxT("wxWizardPage")) ||
+                 IsOfClass(node, wxT("wxWizardPageSimple")))
+           );
+}
+
+#endif // wxUSE_WIZARDDLG
index ea175a776d929f6ec80c66f58b0f99e030727595..7de3f4f9cbaa21f1a6ea844455023a54a254a057 100644 (file)
@@ -96,4 +96,7 @@ void wxXmlResource::InitAllHandlers()
     AddHandler(new wxFrameXmlHandler);
     AddHandler(new wxScrolledWindowXmlHandler);
     AddHandler(new wxSplitterWindowXmlHandler);
+#if wxUSE_WIZARDDLG
+    AddHandler(new wxWizardXmlHandler);
+#endif
 }
index 6d85c7d135dc89793eb78f76e51d639f85adc532..88d42fda0ea12c987dd46a85e8556a32a028e053 100644 (file)
@@ -35,7 +35,7 @@ All GUI ports:
 
 - added alpha channel support to wxImage
 - added wxCLOSE_BOX style for dialogs and frames
-- added wxSplitterWindow handler to XRC
+- added wxSplitterWindow and wxWizard handlers to XRC
 - added proportion to wxFlexGridSizer::AddGrowableRow/Col (Maxim Babitski)
 - added wxFlexGridSizer::SetFlexibleDirection() (Szczepan Holyszewski)
 - implemented GetEditControl for wxGenericTreeCtrl (Peter Stieber)
index 8f62594126525c52403c802d42dcb74f92a9be0f..51ccbf3533ff7d3b8c8f6fac8dd35efe6ef5e9be 100644 (file)
@@ -48,5 +48,6 @@
 #include "wx/xrc/xh_frame.h"
 #include "wx/xrc/xh_scwin.h"
 #include "wx/xrc/xh_split.h"
+#include "wx/xrc/xh_wizrd.h"
 
 #endif // _WX_XMLRES_H_
diff --git a/include/wx/xrc/xh_wizrd.h b/include/wx/xrc/xh_wizrd.h
new file mode 100644 (file)
index 0000000..aa5dfbf
--- /dev/null
@@ -0,0 +1,38 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        xh_wizrd.h
+// Purpose:     XML resource handler for wxWizard
+// Author:      Vaclav Slavik
+// Created:     2003/03/02
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_XH_WIZRD_H_
+#define _WX_XH_WIZRDL_H_
+
+#if defined(__GNUG__) && !defined(__APPLE__)
+#pragma interface "xh_wizrd.h"
+#endif
+
+#include "wx/xrc/xmlres.h"
+
+#if wxUSE_WIZARDDLG
+
+#include "wx/wizard.h"
+
+class WXXMLDLLEXPORT wxWizardXmlHandler : public wxXmlResourceHandler
+{
+public:
+    wxWizardXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+
+private:
+    wxWizard *m_wizard;
+    wxWizardPageSimple *m_lastSimplePage;
+};
+
+#endif
+
+#endif // _WX_XH_PANEL_H_
diff --git a/src/xrc/xh_wizrd.cpp b/src/xrc/xh_wizrd.cpp
new file mode 100644 (file)
index 0000000..958845b
--- /dev/null
@@ -0,0 +1,99 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        xh_wizrd.cpp
+// Purpose:     XRC resource for wxWizard
+// Author:      Vaclav Slavik
+// Created:     2003/03/01
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __GNUG__
+#pragma implementation "xh_wizrd.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_WIZARDDLG
+
+#include "wx/xrc/xh_wizrd.h"
+#include "wx/log.h"
+#include "wx/wizard.h"
+
+
+wxWizardXmlHandler::wxWizardXmlHandler() : wxXmlResourceHandler()
+{
+    m_wizard = NULL;
+    m_lastSimplePage = NULL;
+    XRC_ADD_STYLE(wxWIZARD_EX_HELPBUTTON);
+}
+
+wxObject *wxWizardXmlHandler::DoCreateResource()
+{ 
+    if (m_class == wxT("wxWizard"))
+    {
+        XRC_MAKE_INSTANCE(wiz, wxWizard)
+
+        long style = GetStyle(wxT("exstyle"), 0);
+        if (style != 0)
+            wiz->SetExtraStyle(style);
+        wiz->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("title")),
+                    GetBitmap(),
+                    GetPosition());
+
+        wxWizard *old = m_wizard;
+        m_wizard = wiz;
+        m_lastSimplePage = NULL;
+        CreateChildren(wiz, true /*this handler only*/);
+        m_wizard = old;
+        return wiz;
+    }
+    else
+    {
+        wxWizardPage *page = NULL;
+        if (m_class == wxT("wxWizardPageSimple"))
+        {
+            XRC_MAKE_INSTANCE(p, wxWizardPageSimple)
+            p->Create(m_wizard, NULL, NULL, GetBitmap());
+            if (m_lastSimplePage)
+                wxWizardPageSimple::Chain(m_lastSimplePage, p);
+            page = p;
+            m_lastSimplePage = p;
+        }
+        else /*if (m_class == wxT("wxWizardPage"))*/
+        {
+            wxWizardPage *p = NULL;
+            if (m_instance)
+                p = wxStaticCast(m_instance, wxWizardPage);
+            else
+                wxLogError(wxT("wxWizardPage is abstract class, must be subclassed"));
+            p->Create(m_wizard, GetBitmap());
+            page = p;
+        }
+
+        page->SetName(GetName());
+        page->SetId(GetID());
+
+        SetupWindow(page);
+        CreateChildren(page);
+        return page;
+    }
+}
+
+bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("wxWizard")) || 
+           (m_wizard != NULL &&
+                (IsOfClass(node, wxT("wxWizardPage")) ||
+                 IsOfClass(node, wxT("wxWizardPageSimple")))
+           );
+}
+
+#endif // wxUSE_WIZARDDLG
index ea175a776d929f6ec80c66f58b0f99e030727595..7de3f4f9cbaa21f1a6ea844455023a54a254a057 100644 (file)
@@ -96,4 +96,7 @@ void wxXmlResource::InitAllHandlers()
     AddHandler(new wxFrameXmlHandler);
     AddHandler(new wxScrolledWindowXmlHandler);
     AddHandler(new wxSplitterWindowXmlHandler);
+#if wxUSE_WIZARDDLG
+    AddHandler(new wxWizardXmlHandler);
+#endif
 }