]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_propdlg.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / src / xrc / xh_propdlg.cpp
index 191acf4abfe12014570314ea8c0656f07888bba5..d07e3a6b40a5313de60b6f6410fdc7807da329d8 100644 (file)
-/////////////////////////////////////////////////////////////////////////////\r
-// Name:        src/xrc/xh_propdlg.cpp\r
-// Purpose:     XRC resource handler for wxPropertySheetDialog\r
-// Author:      Sander Berents\r
-// Created:     2007/07/12\r
-// RCS-ID:      $Id$\r
-// Copyright:   (c) 2007 Sander Berents\r
-// Licence:     wxWindows licence\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-// For compilers that support precompilation, includes "wx.h".\r
-#include "wx/wxprec.h"\r
-\r
-#ifdef __BORLANDC__\r
-    #pragma hdrstop\r
-#endif\r
-\r
-#if wxUSE_XRC && wxUSE_BOOKCTRL\r
-\r
-#include "wx/xrc/xh_propdlg.h"\r
-\r
-#ifndef WX_PRECOMP\r
-    #include "wx/log.h"\r
-    #include "wx/sizer.h"\r
-#endif\r
-\r
-#include "wx/bookctrl.h"\r
-#include "wx/propdlg.h"\r
-\r
-IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler, wxXmlResourceHandler)\r
-\r
-wxPropertySheetDialogXmlHandler::wxPropertySheetDialogXmlHandler()\r
-                     :wxXmlResourceHandler(),\r
-                      m_isInside(false),\r
-                      m_dialog(NULL)\r
-{\r
-    XRC_ADD_STYLE(wxSTAY_ON_TOP);\r
-    XRC_ADD_STYLE(wxCAPTION);\r
-    XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);\r
-    XRC_ADD_STYLE(wxSYSTEM_MENU);\r
-    XRC_ADD_STYLE(wxRESIZE_BORDER);\r
-    XRC_ADD_STYLE(wxCLOSE_BOX);\r
-    XRC_ADD_STYLE(wxDIALOG_NO_PARENT);\r
-\r
-    XRC_ADD_STYLE(wxTAB_TRAVERSAL);\r
-    XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);\r
-    XRC_ADD_STYLE(wxDIALOG_EX_METAL);\r
-    XRC_ADD_STYLE(wxMAXIMIZE_BOX);\r
-    XRC_ADD_STYLE(wxMINIMIZE_BOX);\r
-    XRC_ADD_STYLE(wxFRAME_SHAPED);\r
-    XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP);\r
-\r
-    AddWindowStyles();\r
-}\r
-\r
-wxObject *wxPropertySheetDialogXmlHandler::DoCreateResource()\r
-{\r
-    if (m_class == wxT("propertysheetpage"))\r
-    {\r
-        wxXmlNode *n = GetParamNode(wxT("object"));\r
-\r
-        if (!n) n = GetParamNode(wxT("object_ref"));\r
-\r
-        if (n)\r
-        {\r
-            wxBookCtrlBase *bookctrl = m_dialog->GetBookCtrl();\r
-            bool old_ins = m_isInside;\r
-            m_isInside = false;\r
-            wxObject *item = CreateResFromNode(n, bookctrl, NULL);\r
-            m_isInside = old_ins;\r
-            wxWindow *wnd = wxDynamicCast(item, wxWindow);\r
-\r
-            if (wnd)\r
-            {\r
-                bookctrl->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")));\r
-                if (HasParam(wxT("bitmap")))\r
-                {\r
-                    wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);\r
-                    wxImageList *imgList = bookctrl->GetImageList();\r
-                    if (imgList == NULL)\r
-                    {\r
-                        imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight());\r
-                        bookctrl->AssignImageList(imgList);\r
-                    }\r
-                    int imgIndex = imgList->Add(bmp);\r
-                    bookctrl->SetPageImage(bookctrl->GetPageCount()-1, imgIndex);\r
-                }\r
-            }\r
-            else\r
-                wxLogError(wxT("Error in resource."));\r
-            return wnd;\r
-        }\r
-        else\r
-        {\r
-            wxLogError(wxT("Error in resource: no control within wxPropertySheetDialog's <page> tag."));\r
-            return NULL;\r
-        }\r
-    }\r
-\r
-    else\r
-    {\r
-        XRC_MAKE_INSTANCE(dlg, wxPropertySheetDialog)\r
-\r
-        dlg->Create(m_parentAsWindow,\r
-                   GetID(),\r
-                   GetText(wxT("title")),\r
-                   GetPosition(),\r
-                   GetSize(),\r
-                   GetStyle(),\r
-                   GetName());\r
-\r
-        if (HasParam(wxT("icon"))) dlg->SetIcon(GetIcon(wxT("icon"), wxART_FRAME_ICON));\r
-\r
-        SetupWindow(dlg);\r
-\r
-        wxPropertySheetDialog *old_par = m_dialog;\r
-        m_dialog = dlg;\r
-        bool old_ins = m_isInside;\r
-        m_isInside = true;\r
-        CreateChildren(m_dialog, true/*only this handler*/);\r
-        m_isInside = old_ins;\r
-        m_dialog = old_par;\r
-\r
-        if (GetBool(wxT("centered"), false)) dlg->Centre();\r
-        wxString buttons = GetText(wxT("buttons"));\r
-        if (!buttons.IsEmpty())\r
-        {\r
-            int flags = 0;\r
-            if (buttons.Find(wxT("wxOK"))         != wxNOT_FOUND) flags |= wxOK;\r
-            if (buttons.Find(wxT("wxCANCEL"))     != wxNOT_FOUND) flags |= wxCANCEL;\r
-            if (buttons.Find(wxT("wxYES"))        != wxNOT_FOUND) flags |= wxYES;\r
-            if (buttons.Find(wxT("wxNO"))         != wxNOT_FOUND) flags |= wxNO;\r
-            if (buttons.Find(wxT("wxHELP"))       != wxNOT_FOUND) flags |= wxHELP;\r
-            if (buttons.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND) flags |= wxNO_DEFAULT;\r
-            dlg->CreateButtons(flags);\r
-        }\r
-\r
-        return dlg;\r
-    }\r
-}\r
-\r
-bool wxPropertySheetDialogXmlHandler::CanHandle(wxXmlNode *node)\r
-{\r
-    return ((!m_isInside && IsOfClass(node, wxT("wxPropertySheetDialog"))) ||\r
-            (m_isInside && IsOfClass(node, wxT("propertysheetpage"))));\r
-}\r
-\r
-#endif // wxUSE_XRC && wxUSE_BOOKCTRL\r
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/xrc/xh_propdlg.cpp
+// Purpose:     XRC resource handler for wxPropertySheetDialog
+// Author:      Sander Berents
+// Created:     2007/07/12
+// Copyright:   (c) 2007 Sander Berents
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_XRC && wxUSE_BOOKCTRL
+
+#include "wx/xrc/xh_propdlg.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+    #include "wx/sizer.h"
+    #include "wx/frame.h"
+#endif
+
+#include "wx/bookctrl.h"
+#include "wx/propdlg.h"
+#include "wx/imaglist.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler, wxXmlResourceHandler)
+
+wxPropertySheetDialogXmlHandler::wxPropertySheetDialogXmlHandler()
+                     :wxXmlResourceHandler(),
+                      m_isInside(false),
+                      m_dialog(NULL)
+{
+    XRC_ADD_STYLE(wxSTAY_ON_TOP);
+    XRC_ADD_STYLE(wxCAPTION);
+    XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
+    XRC_ADD_STYLE(wxSYSTEM_MENU);
+    XRC_ADD_STYLE(wxRESIZE_BORDER);
+    XRC_ADD_STYLE(wxCLOSE_BOX);
+    XRC_ADD_STYLE(wxDIALOG_NO_PARENT);
+
+    XRC_ADD_STYLE(wxTAB_TRAVERSAL);
+    XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
+    XRC_ADD_STYLE(wxDIALOG_EX_METAL);
+    XRC_ADD_STYLE(wxMAXIMIZE_BOX);
+    XRC_ADD_STYLE(wxMINIMIZE_BOX);
+    XRC_ADD_STYLE(wxFRAME_SHAPED);
+    XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP);
+
+    AddWindowStyles();
+}
+
+wxObject *wxPropertySheetDialogXmlHandler::DoCreateResource()
+{
+    if (m_class == wxT("propertysheetpage"))
+    {
+        wxXmlNode *n = GetParamNode(wxT("object"));
+
+        if (!n) n = GetParamNode(wxT("object_ref"));
+
+        if (n)
+        {
+            wxBookCtrlBase *bookctrl = m_dialog->GetBookCtrl();
+            bool old_ins = m_isInside;
+            m_isInside = false;
+            wxObject *item = CreateResFromNode(n, bookctrl, NULL);
+            m_isInside = old_ins;
+            wxWindow *wnd = wxDynamicCast(item, wxWindow);
+
+            if (wnd)
+            {
+                bookctrl->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")));
+                if (HasParam(wxT("bitmap")))
+                {
+                    wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
+                    wxImageList *imgList = bookctrl->GetImageList();
+                    if (imgList == NULL)
+                    {
+                        imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
+                        bookctrl->AssignImageList(imgList);
+                    }
+                    int imgIndex = imgList->Add(bmp);
+                    bookctrl->SetPageImage(bookctrl->GetPageCount()-1, imgIndex);
+                }
+            }
+            else
+            {
+                ReportError(n, "propertysheetpage child must be a window");
+            }
+            return wnd;
+        }
+        else
+        {
+            ReportError("propertysheetpage must have a window child");
+            return NULL;
+        }
+    }
+
+    else
+    {
+        XRC_MAKE_INSTANCE(dlg, wxPropertySheetDialog)
+
+        dlg->Create(m_parentAsWindow,
+                   GetID(),
+                   GetText(wxT("title")),
+                   GetPosition(),
+                   GetSize(),
+                   GetStyle(),
+                   GetName());
+
+        if (HasParam(wxT("icon")))
+            dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON));
+
+        SetupWindow(dlg);
+
+        wxPropertySheetDialog *old_par = m_dialog;
+        m_dialog = dlg;
+        bool old_ins = m_isInside;
+        m_isInside = true;
+        CreateChildren(m_dialog, true/*only this handler*/);
+        m_isInside = old_ins;
+        m_dialog = old_par;
+
+        if (GetBool(wxT("centered"), false)) dlg->Centre();
+        wxString buttons = GetText(wxT("buttons"));
+        if (!buttons.IsEmpty())
+        {
+            int flags = 0;
+            if (buttons.Find(wxT("wxOK"))         != wxNOT_FOUND) flags |= wxOK;
+            if (buttons.Find(wxT("wxCANCEL"))     != wxNOT_FOUND) flags |= wxCANCEL;
+            if (buttons.Find(wxT("wxYES"))        != wxNOT_FOUND) flags |= wxYES;
+            if (buttons.Find(wxT("wxNO"))         != wxNOT_FOUND) flags |= wxNO;
+            if (buttons.Find(wxT("wxHELP"))       != wxNOT_FOUND) flags |= wxHELP;
+            if (buttons.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND) flags |= wxNO_DEFAULT;
+            dlg->CreateButtons(flags);
+        }
+
+        return dlg;
+    }
+}
+
+bool wxPropertySheetDialogXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return ((!m_isInside && IsOfClass(node, wxT("wxPropertySheetDialog"))) ||
+            (m_isInside && IsOfClass(node, wxT("propertysheetpage"))));
+}
+
+#endif // wxUSE_XRC && wxUSE_BOOKCTRL