From 2f5b93fb9f2691f059643400ab3ff7b362b17aac Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 26 Jan 2003 23:19:04 +0000 Subject: [PATCH] added wxSplitterWindow to XRC git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18951 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/xrc/xh_all.h | 1 + contrib/include/wx/xrc/xh_split.h | 28 ++++++++ contrib/samples/xrc/rc/controls.xrc | 28 ++++++++ contrib/src/xrc/Makefile.in | 5 +- contrib/src/xrc/XrcVC.dsp | 4 ++ contrib/src/xrc/makefile.b32 | 3 +- contrib/src/xrc/makefile.g95 | 2 +- contrib/src/xrc/makefile.vc | 3 +- contrib/src/xrc/makefile.wat | 2 +- contrib/src/xrc/xh_split.cpp | 103 ++++++++++++++++++++++++++++ contrib/src/xrc/xmlrsall.cpp | 1 + docs/changes.txt | 1 + docs/tech/tn0014.txt | 18 +++++ include/wx/xrc/xh_all.h | 1 + include/wx/xrc/xh_split.h | 28 ++++++++ samples/xrc/rc/controls.xrc | 28 ++++++++ src/xrc/Makefile.in | 5 +- src/xrc/XrcVC.dsp | 4 ++ src/xrc/makefile.b32 | 3 +- src/xrc/makefile.g95 | 2 +- src/xrc/makefile.vc | 3 +- src/xrc/makefile.wat | 2 +- src/xrc/xh_split.cpp | 103 ++++++++++++++++++++++++++++ src/xrc/xmlrsall.cpp | 1 + 24 files changed, 367 insertions(+), 12 deletions(-) create mode 100644 contrib/include/wx/xrc/xh_split.h create mode 100644 contrib/src/xrc/xh_split.cpp create mode 100644 include/wx/xrc/xh_split.h create mode 100644 src/xrc/xh_split.cpp diff --git a/contrib/include/wx/xrc/xh_all.h b/contrib/include/wx/xrc/xh_all.h index 2ac1db392c..8f62594126 100644 --- a/contrib/include/wx/xrc/xh_all.h +++ b/contrib/include/wx/xrc/xh_all.h @@ -47,5 +47,6 @@ #include "wx/xrc/xh_gdctl.h" #include "wx/xrc/xh_frame.h" #include "wx/xrc/xh_scwin.h" +#include "wx/xrc/xh_split.h" #endif // _WX_XMLRES_H_ diff --git a/contrib/include/wx/xrc/xh_split.h b/contrib/include/wx/xrc/xh_split.h new file mode 100644 index 0000000000..010bede9f0 --- /dev/null +++ b/contrib/include/wx/xrc/xh_split.h @@ -0,0 +1,28 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_split.h +// Purpose: XRC resource for wxSplitterWindow +// Author: panga@freemail.hu, Vaclav Slavik +// Created: 2003/01/26 +// RCS-ID: $Id$ +// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_SPLIT_H_ +#define _WX_XH_SPLIT_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "xh_split.h" +#endif + +#include "wx/xrc/xmlres.h" + +class WXXMLDLLEXPORT wxSplitterWindowXmlHandler : public wxXmlResourceHandler +{ +public: + wxSplitterWindowXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif // _WX_XH_SPLIT_H_ diff --git a/contrib/samples/xrc/rc/controls.xrc b/contrib/samples/xrc/rc/controls.xrc index 119716ad1b..6972bd4cb7 100644 --- a/contrib/samples/xrc/rc/controls.xrc +++ b/contrib/samples/xrc/rc/controls.xrc @@ -380,6 +380,34 @@ + + + + + 1 + 0 + 0 + 0 + 0 + 0 + + wxALIGN_CENTRE|wxALL + 5 + + 50 + 100 + 400,200 + + #0000FF + + + #00FF00 + + + + + + diff --git a/contrib/src/xrc/Makefile.in b/contrib/src/xrc/Makefile.in index ca0f650ca8..b6358ea68d 100644 --- a/contrib/src/xrc/Makefile.in +++ b/contrib/src/xrc/Makefile.in @@ -24,7 +24,8 @@ HEADERS=xh_all.h xh_bttn.h xh_chckb.h xh_chckl.h xh_choic.h xh_combo.h \ xh_radbt.h xh_radbx.h xh_sizer.h xh_slidr.h xh_spin.h xh_stbmp.h \ xh_sttxt.h xh_text.h xh_listb.h xml.h xmlres.h xh_toolb.h \ xh_bmpbt.h xh_cald.h xh_listc.h xh_scrol.h xh_stbox.h xh_tree.h \ - xh_stlin.h xh_bmp.h xh_unkwn.h xh_frame.h xh_gdctl.h xh_scwin.h + xh_stlin.h xh_bmp.h xh_unkwn.h xh_frame.h xh_gdctl.h xh_scwin.h \ + xh_split.h OBJECTS=$(EXPAT_OBJECTS) \ xml.o xmlres.o xmlrsall.o \ @@ -33,7 +34,7 @@ OBJECTS=$(EXPAT_OBJECTS) \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ xh_text.o xh_listb.o xh_toolb.o xh_stlin.o xh_bmp.o xh_unkwn.o \ xh_bmpbt.o xh_cald.o xh_listc.o xh_scrol.o xh_stbox.o xh_tree.o \ - xh_frame.o xh_gdctl.o xh_scwin.o + xh_frame.o xh_gdctl.o xh_scwin.o xh_split.o DEPFILES=$(OBJECTS:.o=.d) APPEXTRADEFS=-I$(top_srcdir)/contrib/include $(EXPAT_DEFS) diff --git a/contrib/src/xrc/XrcVC.dsp b/contrib/src/xrc/XrcVC.dsp index 174c339711..9dbdbbffc0 100644 --- a/contrib/src/xrc/XrcVC.dsp +++ b/contrib/src/xrc/XrcVC.dsp @@ -200,6 +200,10 @@ SOURCE=.\xh_spin.cpp # End Source File # Begin Source File +SOURCE=.\xh_split.cpp +# End Source File +# Begin Source File + SOURCE=.\xh_stbmp.cpp # End Source File # Begin Source File diff --git a/contrib/src/xrc/makefile.b32 b/contrib/src/xrc/makefile.b32 index 2024abb133..97f83438e1 100644 --- a/contrib/src/xrc/makefile.b32 +++ b/contrib/src/xrc/makefile.b32 @@ -27,7 +27,8 @@ OBJECTS=$(EXPAT_OBJECTS) \ xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj \ xh_text.obj xh_listb.obj xh_toolb.obj xh_stlin.obj xh_bmp.obj \ xh_bmpbt.obj xh_cald.obj xh_listc.obj xh_scrol.obj xh_stbox.obj \ - xh_tree.obj xh_unkwn.obj xh_frame.obj xh_gdctl.obj xh_scwin.obj + xh_tree.obj xh_unkwn.obj xh_frame.obj xh_gdctl.obj xh_scwin.obj \ + xh_split.obj !include $(WXDIR)\src\makelib.b32 diff --git a/contrib/src/xrc/makefile.g95 b/contrib/src/xrc/makefile.g95 index 00b31580dc..4c1fde8856 100644 --- a/contrib/src/xrc/makefile.g95 +++ b/contrib/src/xrc/makefile.g95 @@ -28,7 +28,7 @@ OBJECTS= $(XMLPARSEDIR_OBJECTS) $(XMLTOKDIR_OBJECTS) \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ xh_text.o xh_listb.o xh_toolb.o xh_stlin.o xh_bmp.o xh_unkwn.o \ xh_bmpbt.o xh_cald.o xh_listc.o xh_scrol.o xh_stbox.o xh_tree.o \ - xh_frame.o xh_gdctl.o xh_scwin.o + xh_frame.o xh_gdctl.o xh_scwin.o xh_split.o include $(WXDIR)/src/makelib.g95 diff --git a/contrib/src/xrc/makefile.vc b/contrib/src/xrc/makefile.vc index 6065d42e49..309fd7107a 100644 --- a/contrib/src/xrc/makefile.vc +++ b/contrib/src/xrc/makefile.vc @@ -57,7 +57,8 @@ OBJECTS=$(EXPAT_OBJS) \ $(D)\xh_text.obj $(D)\xh_listb.obj $(D)\xh_toolb.obj \ $(D)\xh_bmpbt.obj $(D)\xh_cald.obj $(D)\xh_listc.obj $(D)\xh_scrol.obj \ $(D)\xh_stbox.obj $(D)\xh_tree.obj $(D)\xh_stlin.obj $(D)\xh_bmp.obj \ - $(D)\xh_unkwn.obj $(D)\xh_gdctl.obj $(D)\xh_scwin.obj + $(D)\xh_unkwn.obj $(D)\xh_gdctl.obj $(D)\xh_scwin.obj \ + $(D)\xh_split.obj !include $(WXDIR)\src\makelib.vc diff --git a/contrib/src/xrc/makefile.wat b/contrib/src/xrc/makefile.wat index d4069fc0f6..a2e3f6aa38 100644 --- a/contrib/src/xrc/makefile.wat +++ b/contrib/src/xrc/makefile.wat @@ -18,7 +18,7 @@ OBJECTS=xml.obj xmlres.obj xmlrsall.obj & xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj & xh_text.obj xh_listb.obj xh_toolb.obj xh_stlin.obj xh_bmp.obj & xh_bmpbt.obj xh_cald.obj xh_listc.obj xh_scrol.obj xh_stbox.obj & - xh_tree.obj xh_unkwn.obj xh_frame.obj xh_scwin.obj + xh_tree.obj xh_unkwn.obj xh_frame.obj xh_scwin.obj xh_split.obj all: $(WXXMLLIB) diff --git a/contrib/src/xrc/xh_split.cpp b/contrib/src/xrc/xh_split.cpp new file mode 100644 index 0000000000..4b23f9ff60 --- /dev/null +++ b/contrib/src/xrc/xh_split.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_split.cpp +// Purpose: XRC resource for wxSplitterWindow +// Author: panga@freemail.hu, Vaclav Slavik +// Created: 2003/01/26 +// RCS-ID: $Id$ +// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_split.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xrc/xh_split.h" +#include "wx/splitter.h" +#include "wx/log.h" + +wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler() +{ + XRC_ADD_STYLE(wxSP_3D); + XRC_ADD_STYLE(wxSP_3DSASH); + XRC_ADD_STYLE(wxSP_3DBORDER); + XRC_ADD_STYLE(wxSP_FULLSASH); + XRC_ADD_STYLE(wxSP_BORDER); + XRC_ADD_STYLE(wxSP_NOBORDER); + XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT); + XRC_ADD_STYLE(wxSP_LIVE_UPDATE); + AddWindowStyles(); +} + +wxObject *wxSplitterWindowXmlHandler::DoCreateResource() +{ + XRC_MAKE_INSTANCE(splitter, wxSplitterWindow); + + splitter->Create(m_parentAsWindow, + GetID(), + GetPosition(), GetSize(), + GetStyle(wxT("style"), wxSP_3D), + GetName()); + + SetupWindow(splitter); + + long sashpos = GetLong(wxT("sashpos"), 0); + long minpanesize = GetLong(wxT("minsize"), -1); + if (minpanesize != -1) + splitter->SetMinimumPaneSize(minpanesize); + + wxWindow *win1 = NULL, *win2 = NULL; + wxXmlNode *n = m_node->GetChildren(); + while (n) + { + if ((n->GetType() == wxXML_ELEMENT_NODE) && + (n->GetName() == wxT("object") || + n->GetName() == wxT("object_ref"))) + { + wxObject *created = CreateResFromNode(n, splitter, NULL); + wxWindow *win = wxDynamicCast(created, wxWindow); + if (win1 == NULL) + { + win1 = win; + } + else + { + win2 = win; + break; + } + } + n = n->GetNext(); + } + + if (win1 == NULL) + wxLogError(wxT("wxSplitterWindow node must contain at least one window.")); + + bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical")); + if (win1 && win2) + { + if (horizontal) + splitter->SplitHorizontally(win1, win2, sashpos); + else + splitter->SplitVertically(win1, win2, sashpos); + } + else + { + splitter->Initialize(win1); + } + + return splitter; +} + +bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node) +{ + return IsOfClass(node, wxT("wxSplitterWindow")); +} + + diff --git a/contrib/src/xrc/xmlrsall.cpp b/contrib/src/xrc/xmlrsall.cpp index 5d933f9490..ea175a776d 100644 --- a/contrib/src/xrc/xmlrsall.cpp +++ b/contrib/src/xrc/xmlrsall.cpp @@ -95,4 +95,5 @@ void wxXmlResource::InitAllHandlers() #endif AddHandler(new wxFrameXmlHandler); AddHandler(new wxScrolledWindowXmlHandler); + AddHandler(new wxSplitterWindowXmlHandler); } diff --git a/docs/changes.txt b/docs/changes.txt index ddc9309b7a..ec79242546 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -25,6 +25,7 @@ wxBase: All GUI ports: +- added wxSplitterWindow handler to XRC - added wxFlexGridSizer::SetFlexibleDirection() (Szczepan Holyszewski) - implemented GetEditControl for wxGenericTreeCtrl (Peter Stieber) - improved contrib/utils/convertrc parsing (David J. Cooke) diff --git a/docs/tech/tn0014.txt b/docs/tech/tn0014.txt index 8b8c8e31e6..af38cf30fe 100644 --- a/docs/tech/tn0014.txt +++ b/docs/tech/tn0014.txt @@ -303,6 +303,24 @@ size Size -1,-1 style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL +wxSplitterWindow +---------------- +position Position -1,-1 +size Size -1,-1 +style Style[wxSplitterWindow] wxSP_3D +sashpos Integer 0 + (Initial sash position) +minsize Integer -1 + (Minimal panel size) +orientation "horizontal"|"vertical" horizontal + +wxSplitterWindow must have at least one and at most two children objects. +If there's only one child object, it is passed to wxSplitterWindow::Initialize +and the splitter is created unsplitted. If there are two children, the +splitter is created splitted, either horizontally or vertically depending +on the value of "orientation" attribute. + + wxToolBar --------- position Position -1,-1 diff --git a/include/wx/xrc/xh_all.h b/include/wx/xrc/xh_all.h index 2ac1db392c..8f62594126 100644 --- a/include/wx/xrc/xh_all.h +++ b/include/wx/xrc/xh_all.h @@ -47,5 +47,6 @@ #include "wx/xrc/xh_gdctl.h" #include "wx/xrc/xh_frame.h" #include "wx/xrc/xh_scwin.h" +#include "wx/xrc/xh_split.h" #endif // _WX_XMLRES_H_ diff --git a/include/wx/xrc/xh_split.h b/include/wx/xrc/xh_split.h new file mode 100644 index 0000000000..010bede9f0 --- /dev/null +++ b/include/wx/xrc/xh_split.h @@ -0,0 +1,28 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_split.h +// Purpose: XRC resource for wxSplitterWindow +// Author: panga@freemail.hu, Vaclav Slavik +// Created: 2003/01/26 +// RCS-ID: $Id$ +// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_SPLIT_H_ +#define _WX_XH_SPLIT_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "xh_split.h" +#endif + +#include "wx/xrc/xmlres.h" + +class WXXMLDLLEXPORT wxSplitterWindowXmlHandler : public wxXmlResourceHandler +{ +public: + wxSplitterWindowXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif // _WX_XH_SPLIT_H_ diff --git a/samples/xrc/rc/controls.xrc b/samples/xrc/rc/controls.xrc index 119716ad1b..6972bd4cb7 100644 --- a/samples/xrc/rc/controls.xrc +++ b/samples/xrc/rc/controls.xrc @@ -380,6 +380,34 @@ + + + + + 1 + 0 + 0 + 0 + 0 + 0 + + wxALIGN_CENTRE|wxALL + 5 + + 50 + 100 + 400,200 + + #0000FF + + + #00FF00 + + + + + + diff --git a/src/xrc/Makefile.in b/src/xrc/Makefile.in index ca0f650ca8..b6358ea68d 100644 --- a/src/xrc/Makefile.in +++ b/src/xrc/Makefile.in @@ -24,7 +24,8 @@ HEADERS=xh_all.h xh_bttn.h xh_chckb.h xh_chckl.h xh_choic.h xh_combo.h \ xh_radbt.h xh_radbx.h xh_sizer.h xh_slidr.h xh_spin.h xh_stbmp.h \ xh_sttxt.h xh_text.h xh_listb.h xml.h xmlres.h xh_toolb.h \ xh_bmpbt.h xh_cald.h xh_listc.h xh_scrol.h xh_stbox.h xh_tree.h \ - xh_stlin.h xh_bmp.h xh_unkwn.h xh_frame.h xh_gdctl.h xh_scwin.h + xh_stlin.h xh_bmp.h xh_unkwn.h xh_frame.h xh_gdctl.h xh_scwin.h \ + xh_split.h OBJECTS=$(EXPAT_OBJECTS) \ xml.o xmlres.o xmlrsall.o \ @@ -33,7 +34,7 @@ OBJECTS=$(EXPAT_OBJECTS) \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ xh_text.o xh_listb.o xh_toolb.o xh_stlin.o xh_bmp.o xh_unkwn.o \ xh_bmpbt.o xh_cald.o xh_listc.o xh_scrol.o xh_stbox.o xh_tree.o \ - xh_frame.o xh_gdctl.o xh_scwin.o + xh_frame.o xh_gdctl.o xh_scwin.o xh_split.o DEPFILES=$(OBJECTS:.o=.d) APPEXTRADEFS=-I$(top_srcdir)/contrib/include $(EXPAT_DEFS) diff --git a/src/xrc/XrcVC.dsp b/src/xrc/XrcVC.dsp index 174c339711..9dbdbbffc0 100644 --- a/src/xrc/XrcVC.dsp +++ b/src/xrc/XrcVC.dsp @@ -200,6 +200,10 @@ SOURCE=.\xh_spin.cpp # End Source File # Begin Source File +SOURCE=.\xh_split.cpp +# End Source File +# Begin Source File + SOURCE=.\xh_stbmp.cpp # End Source File # Begin Source File diff --git a/src/xrc/makefile.b32 b/src/xrc/makefile.b32 index 2024abb133..97f83438e1 100644 --- a/src/xrc/makefile.b32 +++ b/src/xrc/makefile.b32 @@ -27,7 +27,8 @@ OBJECTS=$(EXPAT_OBJECTS) \ xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj \ xh_text.obj xh_listb.obj xh_toolb.obj xh_stlin.obj xh_bmp.obj \ xh_bmpbt.obj xh_cald.obj xh_listc.obj xh_scrol.obj xh_stbox.obj \ - xh_tree.obj xh_unkwn.obj xh_frame.obj xh_gdctl.obj xh_scwin.obj + xh_tree.obj xh_unkwn.obj xh_frame.obj xh_gdctl.obj xh_scwin.obj \ + xh_split.obj !include $(WXDIR)\src\makelib.b32 diff --git a/src/xrc/makefile.g95 b/src/xrc/makefile.g95 index 00b31580dc..4c1fde8856 100644 --- a/src/xrc/makefile.g95 +++ b/src/xrc/makefile.g95 @@ -28,7 +28,7 @@ OBJECTS= $(XMLPARSEDIR_OBJECTS) $(XMLTOKDIR_OBJECTS) \ xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ xh_text.o xh_listb.o xh_toolb.o xh_stlin.o xh_bmp.o xh_unkwn.o \ xh_bmpbt.o xh_cald.o xh_listc.o xh_scrol.o xh_stbox.o xh_tree.o \ - xh_frame.o xh_gdctl.o xh_scwin.o + xh_frame.o xh_gdctl.o xh_scwin.o xh_split.o include $(WXDIR)/src/makelib.g95 diff --git a/src/xrc/makefile.vc b/src/xrc/makefile.vc index 6065d42e49..309fd7107a 100644 --- a/src/xrc/makefile.vc +++ b/src/xrc/makefile.vc @@ -57,7 +57,8 @@ OBJECTS=$(EXPAT_OBJS) \ $(D)\xh_text.obj $(D)\xh_listb.obj $(D)\xh_toolb.obj \ $(D)\xh_bmpbt.obj $(D)\xh_cald.obj $(D)\xh_listc.obj $(D)\xh_scrol.obj \ $(D)\xh_stbox.obj $(D)\xh_tree.obj $(D)\xh_stlin.obj $(D)\xh_bmp.obj \ - $(D)\xh_unkwn.obj $(D)\xh_gdctl.obj $(D)\xh_scwin.obj + $(D)\xh_unkwn.obj $(D)\xh_gdctl.obj $(D)\xh_scwin.obj \ + $(D)\xh_split.obj !include $(WXDIR)\src\makelib.vc diff --git a/src/xrc/makefile.wat b/src/xrc/makefile.wat index d4069fc0f6..a2e3f6aa38 100644 --- a/src/xrc/makefile.wat +++ b/src/xrc/makefile.wat @@ -18,7 +18,7 @@ OBJECTS=xml.obj xmlres.obj xmlrsall.obj & xh_radbx.obj xh_sizer.obj xh_slidr.obj xh_spin.obj xh_stbmp.obj xh_sttxt.obj & xh_text.obj xh_listb.obj xh_toolb.obj xh_stlin.obj xh_bmp.obj & xh_bmpbt.obj xh_cald.obj xh_listc.obj xh_scrol.obj xh_stbox.obj & - xh_tree.obj xh_unkwn.obj xh_frame.obj xh_scwin.obj + xh_tree.obj xh_unkwn.obj xh_frame.obj xh_scwin.obj xh_split.obj all: $(WXXMLLIB) diff --git a/src/xrc/xh_split.cpp b/src/xrc/xh_split.cpp new file mode 100644 index 0000000000..4b23f9ff60 --- /dev/null +++ b/src/xrc/xh_split.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_split.cpp +// Purpose: XRC resource for wxSplitterWindow +// Author: panga@freemail.hu, Vaclav Slavik +// Created: 2003/01/26 +// RCS-ID: $Id$ +// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_split.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xrc/xh_split.h" +#include "wx/splitter.h" +#include "wx/log.h" + +wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler() +{ + XRC_ADD_STYLE(wxSP_3D); + XRC_ADD_STYLE(wxSP_3DSASH); + XRC_ADD_STYLE(wxSP_3DBORDER); + XRC_ADD_STYLE(wxSP_FULLSASH); + XRC_ADD_STYLE(wxSP_BORDER); + XRC_ADD_STYLE(wxSP_NOBORDER); + XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT); + XRC_ADD_STYLE(wxSP_LIVE_UPDATE); + AddWindowStyles(); +} + +wxObject *wxSplitterWindowXmlHandler::DoCreateResource() +{ + XRC_MAKE_INSTANCE(splitter, wxSplitterWindow); + + splitter->Create(m_parentAsWindow, + GetID(), + GetPosition(), GetSize(), + GetStyle(wxT("style"), wxSP_3D), + GetName()); + + SetupWindow(splitter); + + long sashpos = GetLong(wxT("sashpos"), 0); + long minpanesize = GetLong(wxT("minsize"), -1); + if (minpanesize != -1) + splitter->SetMinimumPaneSize(minpanesize); + + wxWindow *win1 = NULL, *win2 = NULL; + wxXmlNode *n = m_node->GetChildren(); + while (n) + { + if ((n->GetType() == wxXML_ELEMENT_NODE) && + (n->GetName() == wxT("object") || + n->GetName() == wxT("object_ref"))) + { + wxObject *created = CreateResFromNode(n, splitter, NULL); + wxWindow *win = wxDynamicCast(created, wxWindow); + if (win1 == NULL) + { + win1 = win; + } + else + { + win2 = win; + break; + } + } + n = n->GetNext(); + } + + if (win1 == NULL) + wxLogError(wxT("wxSplitterWindow node must contain at least one window.")); + + bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical")); + if (win1 && win2) + { + if (horizontal) + splitter->SplitHorizontally(win1, win2, sashpos); + else + splitter->SplitVertically(win1, win2, sashpos); + } + else + { + splitter->Initialize(win1); + } + + return splitter; +} + +bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node) +{ + return IsOfClass(node, wxT("wxSplitterWindow")); +} + + diff --git a/src/xrc/xmlrsall.cpp b/src/xrc/xmlrsall.cpp index 5d933f9490..ea175a776d 100644 --- a/src/xrc/xmlrsall.cpp +++ b/src/xrc/xmlrsall.cpp @@ -95,4 +95,5 @@ void wxXmlResource::InitAllHandlers() #endif AddHandler(new wxFrameXmlHandler); AddHandler(new wxScrolledWindowXmlHandler); + AddHandler(new wxSplitterWindowXmlHandler); } -- 2.45.2