Added XRC handler for wxPropertySheetDialog (Sander Berents)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-08-13 12:04:31 +00:00
parent 22e97d4cbe
commit aa1b2573f3
6 changed files with 250 additions and 44 deletions

View 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 -->

View 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) $**

View File

@@ -14,58 +14,59 @@
// 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_gauge.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_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_sizer.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_text.h"
#include "wx/xrc/xh_listb.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_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_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_dirpicker.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_htmllbox.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"
#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_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_sttxt.h"
#include "wx/xrc/xh_stlin.h"
#include "wx/xrc/xh_text.h"
#include "wx/xrc/xh_tglbtn.h"
#include "wx/xrc/xh_toolb.h"
#include "wx/xrc/xh_tree.h"
#include "wx/xrc/xh_treebk.h"
#include "wx/xrc/xh_unkwn.h"
#include "wx/xrc/xh_wizrd.h"
#endif // _WX_XH_ALL_H_

View File

@@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/xrc/xh_propdlg.h
// Purpose: XML resource handler for wxPropertySheetDialog
// Author: Sander Berents
// Created: 2007/07/12
// RCS-ID: $Id$
// Copyright: (c) 2007 Sander Berents
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_XH_PROPDLG_H_
#define _WX_XH_PROPDLG_H_
#include "wx/xrc/xmlres.h"
#if wxUSE_XRC
class WXDLLEXPORT wxPropertySheetDialog;
class WXDLLIMPEXP_XRC wxPropertySheetDialogXmlHandler : public wxXmlResourceHandler
{
DECLARE_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler)
public:
wxPropertySheetDialogXmlHandler();
virtual wxObject *DoCreateResource();
virtual bool CanHandle(wxXmlNode *node);
private:
bool m_isInside;
wxPropertySheetDialog *m_dialog;
};
#endif // wxUSE_XRC
#endif // _WX_XH_PROPDLG_H_

148
src/xrc/xh_propdlg.cpp Normal file
View File

@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_propdlg.cpp
// Purpose: XRC resource handler for wxPropertySheetDialog
// Author: Sander Berents
// Created: 2007/07/12
// RCS-ID: $Id$
// 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"
#endif
#include "wx/bookctrl.h"
#include "wx/propdlg.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
wxLogError(wxT("Error in resource."));
return wnd;
}
else
{
wxLogError(wxT("Error in resource: no control within wxPropertySheetDialog's <page> tag."));
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->SetIcon(GetIcon(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

View 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);