]> git.saurik.com Git - wxWidgets.git/commitdiff
Added XRC handler for wxPropertySheetDialog (Sander Berents)
authorJulian Smart <julian@anthemion.co.uk>
Mon, 13 Aug 2007 12:04:31 +0000 (12:04 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 13 Aug 2007 12:04:31 +0000 (12:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/bakefiles/files.bkl
build/msw/makefile.vc
include/wx/xrc/xh_all.h
include/wx/xrc/xh_propdlg.h [new file with mode: 0644]
src/xrc/xh_propdlg.cpp [new file with mode: 0644]
src/xrc/xmlrsall.cpp

index 8a0d1823bc7de9d456701ab30beeb647941dc73d..dae40bb31afcaf55ccfdb29c80f5d39776f71720 100644 (file)
@@ -3018,6 +3018,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/xrc/xh_notbk.cpp
     src/xrc/xh_odcombo.cpp
     src/xrc/xh_panel.cpp
+    src/xrc/xh_propdlg.cpp
     src/xrc/xh_radbt.cpp
     src/xrc/xh_radbx.cpp
     <!-- disabled until linking problems are fixed -->
@@ -3078,6 +3079,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/xrc/xh_notbk.h
     wx/xrc/xh_odcombo.h
     wx/xrc/xh_panel.h
+    wx/xrc/xh_propdlg.h
     wx/xrc/xh_radbt.h
     wx/xrc/xh_radbx.h
     <!-- wx/xrc/xh_richtext.h -->
index b3882367f412193e09ad54fd5efe30772d40a288..5f96a9341bae4b7134e6823f8c1372ff85701156 100644 (file)
@@ -1204,6 +1204,7 @@ XRCDLL_OBJECTS =  \
        $(OBJS)\xrcdll_xh_notbk.obj \
        $(OBJS)\xrcdll_xh_odcombo.obj \
        $(OBJS)\xrcdll_xh_panel.obj \
+       $(OBJS)\xrcdll_xh_propdlg.obj \
        $(OBJS)\xrcdll_xh_radbt.obj \
        $(OBJS)\xrcdll_xh_radbx.obj \
        $(OBJS)\xrcdll_xh_scrol.obj \
@@ -1272,6 +1273,7 @@ XRCLIB_OBJECTS =  \
        $(OBJS)\xrclib_xh_notbk.obj \
        $(OBJS)\xrclib_xh_odcombo.obj \
        $(OBJS)\xrclib_xh_panel.obj \
+       $(OBJS)\xrclib_xh_propdlg.obj \
        $(OBJS)\xrclib_xh_radbt.obj \
        $(OBJS)\xrclib_xh_radbx.obj \
        $(OBJS)\xrclib_xh_scrol.obj \
@@ -1642,6 +1644,7 @@ ____MONOLIB_GUI_SRC_FILENAMES_OBJECTS =  \
        $(OBJS)\monodll_xh_notbk.obj \
        $(OBJS)\monodll_xh_odcombo.obj \
        $(OBJS)\monodll_xh_panel.obj \
+       $(OBJS)\monodll_xh_propdlg.obj \
        $(OBJS)\monodll_xh_radbt.obj \
        $(OBJS)\monodll_xh_radbx.obj \
        $(OBJS)\monodll_xh_scrol.obj \
@@ -2278,6 +2281,7 @@ ____MONOLIB_GUI_SRC_FILENAMES_1_OBJECTS =  \
        $(OBJS)\monolib_xh_notbk.obj \
        $(OBJS)\monolib_xh_odcombo.obj \
        $(OBJS)\monolib_xh_panel.obj \
+       $(OBJS)\monolib_xh_propdlg.obj \
        $(OBJS)\monolib_xh_radbt.obj \
        $(OBJS)\monolib_xh_radbx.obj \
        $(OBJS)\monolib_xh_scrol.obj \
@@ -6219,6 +6223,9 @@ $(OBJS)\monodll_xh_odcombo.obj: ..\..\src\xrc\xh_odcombo.cpp
 $(OBJS)\monodll_xh_panel.obj: ..\..\src\xrc\xh_panel.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
 
+$(OBJS)\monodll_xh_propdlg.obj: ..\..\src\xrc\xh_propdlg.cpp
+       $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
+
 $(OBJS)\monodll_xh_radbt.obj: ..\..\src\xrc\xh_radbt.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
 
@@ -8284,6 +8291,9 @@ $(OBJS)\monolib_xh_odcombo.obj: ..\..\src\xrc\xh_odcombo.cpp
 $(OBJS)\monolib_xh_panel.obj: ..\..\src\xrc\xh_panel.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
 
+$(OBJS)\monolib_xh_propdlg.obj: ..\..\src\xrc\xh_propdlg.cpp
+       $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
+
 $(OBJS)\monolib_xh_radbt.obj: ..\..\src\xrc\xh_radbt.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
 
@@ -13483,6 +13493,9 @@ $(OBJS)\xrcdll_xh_odcombo.obj: ..\..\src\xrc\xh_odcombo.cpp
 $(OBJS)\xrcdll_xh_panel.obj: ..\..\src\xrc\xh_panel.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(XRCDLL_CXXFLAGS) $**
 
+$(OBJS)\xrcdll_xh_propdlg.obj: ..\..\src\xrc\xh_propdlg.cpp
+       $(CXX) /c /nologo /TP /Fo$@ $(XRCDLL_CXXFLAGS) $**
+
 $(OBJS)\xrcdll_xh_radbt.obj: ..\..\src\xrc\xh_radbt.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(XRCDLL_CXXFLAGS) $**
 
@@ -13651,6 +13664,9 @@ $(OBJS)\xrclib_xh_odcombo.obj: ..\..\src\xrc\xh_odcombo.cpp
 $(OBJS)\xrclib_xh_panel.obj: ..\..\src\xrc\xh_panel.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(XRCLIB_CXXFLAGS) $**
 
+$(OBJS)\xrclib_xh_propdlg.obj: ..\..\src\xrc\xh_propdlg.cpp
+       $(CXX) /c /nologo /TP /Fo$@ $(XRCLIB_CXXFLAGS) $**
+
 $(OBJS)\xrclib_xh_radbt.obj: ..\..\src\xrc\xh_radbt.cpp
        $(CXX) /c /nologo /TP /Fo$@ $(XRCLIB_CXXFLAGS) $**
 
index 0424611ed3f30911525077144399e5361d930f42..41600a0852587a80edc7f72e221613134ced0394 100644 (file)
 
 // Existing handlers:
 
-#include "wx/xrc/xh_menu.h"
-#include "wx/xrc/xh_panel.h"
-#include "wx/xrc/xh_dlg.h"
+#include "wx/xrc/xh_animatctrl.h"
+#include "wx/xrc/xh_bmp.h"
+#include "wx/xrc/xh_bmpbt.h"
+#include "wx/xrc/xh_bmpcbox.h"
 #include "wx/xrc/xh_bttn.h"
+#include "wx/xrc/xh_cald.h"
 #include "wx/xrc/xh_chckb.h"
-#include "wx/xrc/xh_tglbtn.h"
+#include "wx/xrc/xh_chckl.h"
+#include "wx/xrc/xh_choic.h"
+#include "wx/xrc/xh_choicbk.h"
+#include "wx/xrc/xh_clrpicker.h"
+#include "wx/xrc/xh_collpane.h"
+#include "wx/xrc/xh_combo.h"
+#include "wx/xrc/xh_datectrl.h"
+#include "wx/xrc/xh_dirpicker.h"
+#include "wx/xrc/xh_dlg.h"
+#include "wx/xrc/xh_filepicker.h"
+#include "wx/xrc/xh_fontpicker.h"
+#include "wx/xrc/xh_frame.h"
 #include "wx/xrc/xh_gauge.h"
+#include "wx/xrc/xh_gdctl.h"
+#include "wx/xrc/xh_grid.h"
 #include "wx/xrc/xh_html.h"
-#include "wx/xrc/xh_spin.h"
-#include "wx/xrc/xh_sttxt.h"
-#include "wx/xrc/xh_slidr.h"
+#include "wx/xrc/xh_htmllbox.h"
+#include "wx/xrc/xh_hyperlink.h"
+#include "wx/xrc/xh_listb.h"
+#include "wx/xrc/xh_listc.h"
+#include "wx/xrc/xh_listbk.h"
+#include "wx/xrc/xh_mdi.h"
+#include "wx/xrc/xh_menu.h"
+#include "wx/xrc/xh_notbk.h"
+#include "wx/xrc/xh_odcombo.h"
+#include "wx/xrc/xh_panel.h"
+#include "wx/xrc/xh_propdlg.h"
 #include "wx/xrc/xh_radbt.h"
 #include "wx/xrc/xh_radbx.h"
-#include "wx/xrc/xh_combo.h"
-#include "wx/xrc/xh_chckl.h"
-#include "wx/xrc/xh_choic.h"
-#include "wx/xrc/xh_datectrl.h"
+#include "wx/xrc/xh_scrol.h"
+#include "wx/xrc/xh_scwin.h"
 #include "wx/xrc/xh_sizer.h"
+#include "wx/xrc/xh_slidr.h"
+#include "wx/xrc/xh_spin.h"
+#include "wx/xrc/xh_split.h"
+#include "wx/xrc/xh_statbar.h"
+#include "wx/xrc/xh_stbox.h"
 #include "wx/xrc/xh_stbmp.h"
-#include "wx/xrc/xh_notbk.h"
-#include "wx/xrc/xh_odcombo.h"
-#include "wx/xrc/xh_listbk.h"
-#include "wx/xrc/xh_choicbk.h"
-#include "wx/xrc/xh_treebk.h"
+#include "wx/xrc/xh_sttxt.h"
+#include "wx/xrc/xh_stlin.h"
 #include "wx/xrc/xh_text.h"
-#include "wx/xrc/xh_listb.h"
+#include "wx/xrc/xh_tglbtn.h"
 #include "wx/xrc/xh_toolb.h"
-#include "wx/xrc/xh_bmpbt.h"
-#include "wx/xrc/xh_stbox.h"
-#include "wx/xrc/xh_scrol.h"
 #include "wx/xrc/xh_tree.h"
-#include "wx/xrc/xh_cald.h"
-#include "wx/xrc/xh_listc.h"
-#include "wx/xrc/xh_stlin.h"
-#include "wx/xrc/xh_bmp.h"
+#include "wx/xrc/xh_treebk.h"
 #include "wx/xrc/xh_unkwn.h"
-#include "wx/xrc/xh_gdctl.h"
-#include "wx/xrc/xh_frame.h"
-#include "wx/xrc/xh_scwin.h"
-#include "wx/xrc/xh_htmllbox.h"
-#include "wx/xrc/xh_split.h"
 #include "wx/xrc/xh_wizrd.h"
-#include "wx/xrc/xh_statbar.h"
-#include "wx/xrc/xh_mdi.h"
-#include "wx/xrc/xh_grid.h"
-#include "wx/xrc/xh_clrpicker.h"
-#include "wx/xrc/xh_filepicker.h"
-#include "wx/xrc/xh_fontpicker.h"
-#include "wx/xrc/xh_dirpicker.h"
-#include "wx/xrc/xh_hyperlink.h"
-#include "wx/xrc/xh_bmpcbox.h"
-#include "wx/xrc/xh_animatctrl.h"
-#include "wx/xrc/xh_collpane.h"
 
 #endif // _WX_XH_ALL_H_
diff --git a/include/wx/xrc/xh_propdlg.h b/include/wx/xrc/xh_propdlg.h
new file mode 100644 (file)
index 0000000..6148abe
--- /dev/null
@@ -0,0 +1,36 @@
+/////////////////////////////////////////////////////////////////////////////\r
+// Name:        wx/xrc/xh_propdlg.h\r
+// Purpose:     XML 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
+#ifndef _WX_XH_PROPDLG_H_\r
+#define _WX_XH_PROPDLG_H_\r
+\r
+#include "wx/xrc/xmlres.h"\r
+\r
+#if wxUSE_XRC\r
+\r
+class WXDLLEXPORT wxPropertySheetDialog;\r
+\r
+class WXDLLIMPEXP_XRC wxPropertySheetDialogXmlHandler : public wxXmlResourceHandler\r
+{\r
+    DECLARE_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler)\r
+\r
+public:\r
+    wxPropertySheetDialogXmlHandler();\r
+    virtual wxObject *DoCreateResource();\r
+    virtual bool CanHandle(wxXmlNode *node);\r
+\r
+private:\r
+    bool m_isInside;\r
+    wxPropertySheetDialog *m_dialog;\r
+};\r
+\r
+#endif // wxUSE_XRC\r
+\r
+#endif // _WX_XH_PROPDLG_H_\r
diff --git a/src/xrc/xh_propdlg.cpp b/src/xrc/xh_propdlg.cpp
new file mode 100644 (file)
index 0000000..191acf4
--- /dev/null
@@ -0,0 +1,148 @@
+/////////////////////////////////////////////////////////////////////////////\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
index b8c129505b58e84d97de651921d75fce5ec091b4..99648ca29944ad36105092678032014176738ac5 100644 (file)
@@ -44,6 +44,9 @@ void wxXmlResource::InitAllHandlers()
 #if wxUSE_BMPBUTTON
     AddHandler(new wxBitmapButtonXmlHandler);
 #endif
+#if wxUSE_BOOKCTRL
+    AddHandler(new wxPropertySheetDialogXmlHandler);
+#endif
 #if wxUSE_BUTTON
     AddHandler(new wxStdDialogButtonSizerXmlHandler);
     AddHandler(new wxButtonXmlHandler);