From 56d2f75071fc2a29ec10abe97c5a908bb35f30f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 25 Jul 2000 18:47:21 +0000 Subject: [PATCH] added XML resources library git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/Makefile.in | 2 + contrib/configure | 8 + contrib/configure.in | 4 + contrib/include/wx/xml/xh_all.h | 37 + contrib/include/wx/xml/xh_bttn.h | 29 + contrib/include/wx/xml/xh_chckb.h | 35 + contrib/include/wx/xml/xh_chckl.h | 33 + contrib/include/wx/xml/xh_choic.h | 32 + contrib/include/wx/xml/xh_combo.h | 35 + contrib/include/wx/xml/xh_dlg.h | 29 + contrib/include/wx/xml/xh_gauge.h | 40 + contrib/include/wx/xml/xh_html.h | 34 + contrib/include/wx/xml/xh_menu.h | 40 + contrib/include/wx/xml/xh_notbk.h | 37 + contrib/include/wx/xml/xh_panel.h | 29 + contrib/include/wx/xml/xh_radbt.h | 33 + contrib/include/wx/xml/xh_radbx.h | 35 + contrib/include/wx/xml/xh_sizer.h | 36 + contrib/include/wx/xml/xh_slidr.h | 40 + contrib/include/wx/xml/xh_spin.h | 55 ++ contrib/include/wx/xml/xh_stbmp.h | 30 + contrib/include/wx/xml/xh_sttxt.h | 30 + contrib/include/wx/xml/xh_text.h | 30 + contrib/include/wx/xml/xml.h | 241 ++++++ contrib/include/wx/xml/xmlio.h | 72 ++ contrib/include/wx/xml/xmlres.h | 255 ++++++ contrib/src/Makefile.in | 2 +- contrib/src/xml/Makefile.in | 31 + contrib/src/xml/xh_bttn.cpp | 47 ++ contrib/src/xml/xh_chckb.cpp | 56 ++ contrib/src/xml/xh_chckl.cpp | 115 +++ contrib/src/xml/xh_choic.cpp | 95 +++ contrib/src/xml/xh_combo.cpp | 101 +++ contrib/src/xml/xh_dlg.cpp | 75 ++ contrib/src/xml/xh_gauge.cpp | 73 ++ contrib/src/xml/xh_html.cpp | 71 ++ contrib/src/xml/xh_menu.cpp | 126 +++ contrib/src/xml/xh_notbk.cpp | 95 +++ contrib/src/xml/xh_panel.cpp | 52 ++ contrib/src/xml/xh_radbt.cpp | 65 ++ contrib/src/xml/xh_radbx.cpp | 102 +++ contrib/src/xml/xh_sizer.cpp | 195 +++++ contrib/src/xml/xh_slidr.cpp | 93 ++ contrib/src/xml/xh_spin.cpp | 98 +++ contrib/src/xml/xh_stbmp.cpp | 58 ++ contrib/src/xml/xh_sttxt.cpp | 52 ++ contrib/src/xml/xh_text.cpp | 57 ++ contrib/src/xml/xml.cpp | 424 ++++++++++ contrib/src/xml/xmlbin.cpp | 161 ++++ contrib/src/xml/xmlbinz.cpp | 59 ++ contrib/src/xml/xmlpars.cpp | 283 +++++++ contrib/src/xml/xmlres.cpp | 688 +++++++++++++++ contrib/src/xml/xmlrsall.cpp | 66 ++ contrib/utils/Makefile.in | 10 + contrib/utils/wxrc/Makefile.in | 16 + contrib/utils/wxrc/wxrc.cpp | 292 +++++++ contrib/utils/wxrcedit/Makefile.in | 23 + contrib/utils/wxrcedit/bitmaps/close.xpm | 33 + contrib/utils/wxrcedit/bitmaps/control.xpm | 21 + contrib/utils/wxrcedit/bitmaps/hsizer.xpm | 22 + contrib/utils/wxrcedit/bitmaps/open.xpm | 229 +++++ contrib/utils/wxrcedit/bitmaps/panel.xpm | 26 + contrib/utils/wxrcedit/bitmaps/preview.xpm | 267 ++++++ contrib/utils/wxrcedit/bitmaps/save.xpm | 222 +++++ contrib/utils/wxrcedit/bitmaps/unused.xpm | 20 + contrib/utils/wxrcedit/bitmaps/used.xpm | 21 + contrib/utils/wxrcedit/bitmaps/vsizer.xpm | 22 + contrib/utils/wxrcedit/df/boxsizer.df | 6 + contrib/utils/wxrcedit/df/break.df | 3 + contrib/utils/wxrcedit/df/button.df | 4 + contrib/utils/wxrcedit/df/checkbox.df | 4 + contrib/utils/wxrcedit/df/control.df | 6 + contrib/utils/wxrcedit/df/dialog.df | 4 + contrib/utils/wxrcedit/df/gauge.df | 7 + contrib/utils/wxrcedit/df/htmlwindow.df | 6 + contrib/utils/wxrcedit/df/menu.df | 8 + contrib/utils/wxrcedit/df/menu_item.df | 3 + contrib/utils/wxrcedit/df/menubar.df | 5 + contrib/utils/wxrcedit/df/menuitem.df | 9 + contrib/utils/wxrcedit/df/panel.df | 3 + contrib/utils/wxrcedit/df/panel_item.df | 4 + contrib/utils/wxrcedit/df/panelbase.df | 9 + contrib/utils/wxrcedit/df/radiobutton.df | 5 + contrib/utils/wxrcedit/df/separator.df | 4 + contrib/utils/wxrcedit/df/sizer_item.df | 4 + contrib/utils/wxrcedit/df/sizeritem.df | 8 + contrib/utils/wxrcedit/df/slider.df | 13 + contrib/utils/wxrcedit/df/spacer.df | 10 + contrib/utils/wxrcedit/df/staticbitmap.df | 3 + contrib/utils/wxrcedit/df/staticboxsizer.df | 3 + contrib/utils/wxrcedit/df/statictext.df | 3 + contrib/utils/wxrcedit/df/textctrl.df | 4 + contrib/utils/wxrcedit/df/toolbar_item.df | 3 + contrib/utils/wxrcedit/df/window.df | 11 + contrib/utils/wxrcedit/edapp.cpp | 56 ++ contrib/utils/wxrcedit/editor.cpp | 885 ++++++++++++++++++++ contrib/utils/wxrcedit/editor.h | 107 +++ contrib/utils/wxrcedit/nodehnd.cpp | 437 ++++++++++ contrib/utils/wxrcedit/nodehnd.h | 138 +++ contrib/utils/wxrcedit/prophnd.cpp | 332 ++++++++ contrib/utils/wxrcedit/prophnd.h | 116 +++ contrib/utils/wxrcedit/treedt.h | 30 + contrib/utils/wxrcedit/xmlhelpr.cpp | 84 ++ contrib/utils/wxrcedit/xmlhelpr.h | 23 + utils/wxrc/Makefile.in | 16 + utils/wxrc/wxrc.cpp | 292 +++++++ 106 files changed, 8512 insertions(+), 1 deletion(-) create mode 100644 contrib/include/wx/xml/xh_all.h create mode 100644 contrib/include/wx/xml/xh_bttn.h create mode 100644 contrib/include/wx/xml/xh_chckb.h create mode 100644 contrib/include/wx/xml/xh_chckl.h create mode 100644 contrib/include/wx/xml/xh_choic.h create mode 100644 contrib/include/wx/xml/xh_combo.h create mode 100644 contrib/include/wx/xml/xh_dlg.h create mode 100644 contrib/include/wx/xml/xh_gauge.h create mode 100644 contrib/include/wx/xml/xh_html.h create mode 100644 contrib/include/wx/xml/xh_menu.h create mode 100644 contrib/include/wx/xml/xh_notbk.h create mode 100644 contrib/include/wx/xml/xh_panel.h create mode 100644 contrib/include/wx/xml/xh_radbt.h create mode 100644 contrib/include/wx/xml/xh_radbx.h create mode 100644 contrib/include/wx/xml/xh_sizer.h create mode 100644 contrib/include/wx/xml/xh_slidr.h create mode 100644 contrib/include/wx/xml/xh_spin.h create mode 100644 contrib/include/wx/xml/xh_stbmp.h create mode 100644 contrib/include/wx/xml/xh_sttxt.h create mode 100644 contrib/include/wx/xml/xh_text.h create mode 100644 contrib/include/wx/xml/xml.h create mode 100644 contrib/include/wx/xml/xmlio.h create mode 100644 contrib/include/wx/xml/xmlres.h create mode 100644 contrib/src/xml/Makefile.in create mode 100644 contrib/src/xml/xh_bttn.cpp create mode 100644 contrib/src/xml/xh_chckb.cpp create mode 100644 contrib/src/xml/xh_chckl.cpp create mode 100644 contrib/src/xml/xh_choic.cpp create mode 100644 contrib/src/xml/xh_combo.cpp create mode 100644 contrib/src/xml/xh_dlg.cpp create mode 100644 contrib/src/xml/xh_gauge.cpp create mode 100644 contrib/src/xml/xh_html.cpp create mode 100644 contrib/src/xml/xh_menu.cpp create mode 100644 contrib/src/xml/xh_notbk.cpp create mode 100644 contrib/src/xml/xh_panel.cpp create mode 100644 contrib/src/xml/xh_radbt.cpp create mode 100644 contrib/src/xml/xh_radbx.cpp create mode 100644 contrib/src/xml/xh_sizer.cpp create mode 100644 contrib/src/xml/xh_slidr.cpp create mode 100644 contrib/src/xml/xh_spin.cpp create mode 100644 contrib/src/xml/xh_stbmp.cpp create mode 100644 contrib/src/xml/xh_sttxt.cpp create mode 100644 contrib/src/xml/xh_text.cpp create mode 100644 contrib/src/xml/xml.cpp create mode 100644 contrib/src/xml/xmlbin.cpp create mode 100644 contrib/src/xml/xmlbinz.cpp create mode 100644 contrib/src/xml/xmlpars.cpp create mode 100644 contrib/src/xml/xmlres.cpp create mode 100644 contrib/src/xml/xmlrsall.cpp create mode 100644 contrib/utils/Makefile.in create mode 100644 contrib/utils/wxrc/Makefile.in create mode 100644 contrib/utils/wxrc/wxrc.cpp create mode 100644 contrib/utils/wxrcedit/Makefile.in create mode 100644 contrib/utils/wxrcedit/bitmaps/close.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/control.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/hsizer.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/open.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/panel.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/preview.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/save.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/unused.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/used.xpm create mode 100644 contrib/utils/wxrcedit/bitmaps/vsizer.xpm create mode 100644 contrib/utils/wxrcedit/df/boxsizer.df create mode 100644 contrib/utils/wxrcedit/df/break.df create mode 100644 contrib/utils/wxrcedit/df/button.df create mode 100644 contrib/utils/wxrcedit/df/checkbox.df create mode 100644 contrib/utils/wxrcedit/df/control.df create mode 100644 contrib/utils/wxrcedit/df/dialog.df create mode 100644 contrib/utils/wxrcedit/df/gauge.df create mode 100644 contrib/utils/wxrcedit/df/htmlwindow.df create mode 100644 contrib/utils/wxrcedit/df/menu.df create mode 100644 contrib/utils/wxrcedit/df/menu_item.df create mode 100644 contrib/utils/wxrcedit/df/menubar.df create mode 100644 contrib/utils/wxrcedit/df/menuitem.df create mode 100644 contrib/utils/wxrcedit/df/panel.df create mode 100644 contrib/utils/wxrcedit/df/panel_item.df create mode 100644 contrib/utils/wxrcedit/df/panelbase.df create mode 100644 contrib/utils/wxrcedit/df/radiobutton.df create mode 100644 contrib/utils/wxrcedit/df/separator.df create mode 100644 contrib/utils/wxrcedit/df/sizer_item.df create mode 100644 contrib/utils/wxrcedit/df/sizeritem.df create mode 100644 contrib/utils/wxrcedit/df/slider.df create mode 100644 contrib/utils/wxrcedit/df/spacer.df create mode 100644 contrib/utils/wxrcedit/df/staticbitmap.df create mode 100644 contrib/utils/wxrcedit/df/staticboxsizer.df create mode 100644 contrib/utils/wxrcedit/df/statictext.df create mode 100644 contrib/utils/wxrcedit/df/textctrl.df create mode 100644 contrib/utils/wxrcedit/df/toolbar_item.df create mode 100644 contrib/utils/wxrcedit/df/window.df create mode 100644 contrib/utils/wxrcedit/edapp.cpp create mode 100644 contrib/utils/wxrcedit/editor.cpp create mode 100644 contrib/utils/wxrcedit/editor.h create mode 100644 contrib/utils/wxrcedit/nodehnd.cpp create mode 100644 contrib/utils/wxrcedit/nodehnd.h create mode 100644 contrib/utils/wxrcedit/prophnd.cpp create mode 100644 contrib/utils/wxrcedit/prophnd.h create mode 100644 contrib/utils/wxrcedit/treedt.h create mode 100644 contrib/utils/wxrcedit/xmlhelpr.cpp create mode 100644 contrib/utils/wxrcedit/xmlhelpr.h create mode 100644 utils/wxrc/Makefile.in create mode 100644 utils/wxrc/wxrc.cpp diff --git a/contrib/Makefile.in b/contrib/Makefile.in index 163174b4b9..59844c4e6f 100644 --- a/contrib/Makefile.in +++ b/contrib/Makefile.in @@ -8,6 +8,8 @@ all: clean: cd src; make clean cd samples; make clean + cd utils; make clean + samples: cd samples; make diff --git a/contrib/configure b/contrib/configure index 1e0f10b3cb..297027a299 100755 --- a/contrib/configure +++ b/contrib/configure @@ -817,12 +817,16 @@ trap 'rm -fr `echo " src/ogl/Makefile src/mmedia/Makefile src/stc/Makefile + src/xml/Makefile samples/Makefile samples/mmedia/Makefile samples/ogl/Makefile samples/ogl/ogledit/Makefile samples/ogl/studio/Makefile samples/stc/Makefile + utils/Makefile + utils/wxrc/Makefile + utils/wxrcedit/Makefile " | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF diff --git a/contrib/configure.in b/contrib/configure.in index d4b6e3aa27..e1311a7008 100644 --- a/contrib/configure.in +++ b/contrib/configure.in @@ -42,10 +42,14 @@ AC_OUTPUT([ src/ogl/Makefile src/mmedia/Makefile src/stc/Makefile + src/xml/Makefile samples/Makefile samples/mmedia/Makefile samples/ogl/Makefile samples/ogl/ogledit/Makefile samples/ogl/studio/Makefile samples/stc/Makefile + utils/Makefile + utils/wxrc/Makefile + utils/wxrcedit/Makefile ]) diff --git a/contrib/include/wx/xml/xh_all.h b/contrib/include/wx/xml/xh_all.h new file mode 100644 index 0000000000..3e5803facf --- /dev/null +++ b/contrib/include/wx/xml/xh_all.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_all.h +// Purpose: includes all xh_*.h files +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_ALL_H_ +#define _WX_XH_ALL_H_ + + +// Existing handlers: + +#include "wx/xml/xh_menu.h" +#include "wx/xml/xh_panel.h" +#include "wx/xml/xh_dlg.h" +#include "wx/xml/xh_bttn.h" +#include "wx/xml/xh_chckb.h" +#include "wx/xml/xh_gauge.h" +#include "wx/xml/xh_html.h" +#include "wx/xml/xh_spin.h" +#include "wx/xml/xh_sttxt.h" +#include "wx/xml/xh_slidr.h" +#include "wx/xml/xh_radbt.h" +#include "wx/xml/xh_radbx.h" +#include "wx/xml/xh_combo.h" +#include "wx/xml/xh_chckl.h" +#include "wx/xml/xh_choic.h" +#include "wx/xml/xh_sizer.h" +#include "wx/xml/xh_stbmp.h" +#include "wx/xml/xh_notbk.h" +#include "wx/xml/xh_text.h" + +#endif // _WX_XMLRES_H_ diff --git a/contrib/include/wx/xml/xh_bttn.h b/contrib/include/wx/xml/xh_bttn.h new file mode 100644 index 0000000000..74a1d538a4 --- /dev/null +++ b/contrib/include/wx/xml/xh_bttn.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_bttn.h +// Purpose: XML resource handler for buttons +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_BTTN_H_ +#define _WX_XH_BTTN_H_ + +#ifdef __GNUG__ +#pragma interface "xh_bttn.h" +#endif + +#include "wx/xml/xmlres.h" + +class wxButtonXmlHandler : public wxXmlResourceHandler +{ + public: + wxButtonXmlHandler() : wxXmlResourceHandler() {} + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_BTTN_H_ diff --git a/contrib/include/wx/xml/xh_chckb.h b/contrib/include/wx/xml/xh_chckb.h new file mode 100644 index 0000000000..329331ab3b --- /dev/null +++ b/contrib/include/wx/xml/xh_chckb.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_chckb.h +// Purpose: XML resource handler for wxCheckBox +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_CHCKB_H_ +#define _WX_XH_CHCKB_H_ + +#ifdef __GNUG__ +#pragma interface "xh_chckb.h" +#endif + +#include "wx/xml/xmlres.h" +#include "wx/defs.h" + +#if wxUSE_CHECKBOX + +class wxCheckBoxXmlHandler : public wxXmlResourceHandler +{ + public: + wxCheckBoxXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif + + +#endif // _WX_XH_CHECKBOX_H_ + diff --git a/contrib/include/wx/xml/xh_chckl.h b/contrib/include/wx/xml/xh_chckl.h new file mode 100644 index 0000000000..c1bea68a5c --- /dev/null +++ b/contrib/include/wx/xml/xh_chckl.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_chckl.h +// Purpose: XML resource handler for wxCheckListBox +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_CHCKL_H_ +#define _WX_XH_CHCKL_H_ + +#ifdef __GNUG__ +#pragma interface "xh_chckl.h" +#endif + +#include "wx/xml/xmlres.h" + +class wxCheckListXmlHandler : public wxXmlResourceHandler +{ + public: + wxCheckListXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + private: + bool m_InsideBox; + wxArrayString strList; +}; + + + +#endif // _WX_XH_CHECKLIST_H_ \ No newline at end of file diff --git a/contrib/include/wx/xml/xh_choic.h b/contrib/include/wx/xml/xh_choic.h new file mode 100644 index 0000000000..f6ca1f890f --- /dev/null +++ b/contrib/include/wx/xml/xh_choic.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_choic.h +// Purpose: XML resource handler for wxChoice +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_CHOIC_H_ +#define _WX_XH_CHOIC_H_ + +#ifdef __GNUG__ +#pragma interface "xh_choic.h" +#endif + +#include "wx/xml/xmlres.h" + +class wxChoiceXmlHandler : public wxXmlResourceHandler +{ + public: + wxChoiceXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + private: + bool m_InsideBox; + wxArrayString strList; +}; + + +#endif // _WX_XH_CHOIC_H_ diff --git a/contrib/include/wx/xml/xh_combo.h b/contrib/include/wx/xml/xh_combo.h new file mode 100644 index 0000000000..4a4d29b887 --- /dev/null +++ b/contrib/include/wx/xml/xh_combo.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_combo.h +// Purpose: XML resource handler for wxComboBox +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_COMBO_H_ +#define _WX_XH_COMBO_H_ + +#ifdef __GNUG__ +#pragma interface "xh_combo.h" +#endif + +#include "wx/xml/xmlres.h" + +#if wxUSE_COMBOBOX + +class wxComboBoxXmlHandler : public wxXmlResourceHandler +{ + public: + wxComboBoxXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + private: + bool m_InsideBox; + wxArrayString strList; +}; + +#endif + +#endif // _WX_XH_COMBO_H_ diff --git a/contrib/include/wx/xml/xh_dlg.h b/contrib/include/wx/xml/xh_dlg.h new file mode 100644 index 0000000000..d2157c93be --- /dev/null +++ b/contrib/include/wx/xml/xh_dlg.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_dlg.h +// Purpose: XML resource handler for dialogs +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_DLG_H_ +#define _WX_XH_DLG_H_ + +#ifdef __GNUG__ +#pragma interface "xh_dlg.h" +#endif + +#include "wx/xml/xmlres.h" + +class wxDialogXmlHandler : public wxXmlResourceHandler +{ + public: + wxDialogXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_DLG_H_ diff --git a/contrib/include/wx/xml/xh_gauge.h b/contrib/include/wx/xml/xh_gauge.h new file mode 100644 index 0000000000..7380a3e330 --- /dev/null +++ b/contrib/include/wx/xml/xh_gauge.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_gauge.h +// Purpose: XML resource handler for wxGauge +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_GAUGE_H_ +#define _WX_XH_GAUGE_H_ + +#ifdef __GNUG__ +#pragma interface "xh_gauge.h" +#endif + +#include "wx/defs.h" + +#if wxUSE_GAUGE + +#include "wx/xml/xmlres.h" + + +class wxGaugeXmlHandler : public wxXmlResourceHandler +{ + enum + { + wxGAUGE_DEFAULT_RANGE = 100 + }; + + public: + wxGaugeXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif + +#endif // _WX_XH_GAUGE_H_ diff --git a/contrib/include/wx/xml/xh_html.h b/contrib/include/wx/xml/xh_html.h new file mode 100644 index 0000000000..dc1acd1228 --- /dev/null +++ b/contrib/include/wx/xml/xh_html.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_html.h +// Purpose: XML resource handler for wxHtmlWindow +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_HTML_H_ +#define _WX_XH_HTML_H_ + +#ifdef __GNUG__ +#pragma interface "xh_html.h" +#endif + +#include "wx/xml/xmlres.h" + +#include "wx/defs.h" + +#if wxUSE_HTML + +class wxHtmlWindowXmlHandler : public wxXmlResourceHandler +{ + public: + wxHtmlWindowXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif + +#endif // _WX_XH_SLIDER_H_ diff --git a/contrib/include/wx/xml/xh_menu.h b/contrib/include/wx/xml/xh_menu.h new file mode 100644 index 0000000000..7e1e31fa53 --- /dev/null +++ b/contrib/include/wx/xml/xh_menu.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_menu.h +// Purpose: XML resource handler for menus/menubars +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_MENU_H_ +#define _WX_XH_MENU_H_ + +#ifdef __GNUG__ +#pragma interface "xh_menu.h" +#endif + +#include "wx/xml/xmlres.h" + +class wxMenuXmlHandler : public wxXmlResourceHandler +{ + public: + wxMenuXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + + private: + bool m_InsideMenu; +}; + +class wxMenuBarXmlHandler : public wxXmlResourceHandler +{ + public: + wxMenuBarXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_MENU_H_ diff --git a/contrib/include/wx/xml/xh_notbk.h b/contrib/include/wx/xml/xh_notbk.h new file mode 100644 index 0000000000..63e14ee054 --- /dev/null +++ b/contrib/include/wx/xml/xh_notbk.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_notbk.h +// Purpose: XML resource handler for wxNotebook +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_NOTBK_H_ +#define _WX_XH_NOTBK_H_ + +#ifdef __GNUG__ +#pragma interface "xh_notbk.h" +#endif + +#include "wx/xml/xmlres.h" + +#if wxUSE_NOTEBOOK + +class wxNotebook; + +class wxNotebookXmlHandler : public wxXmlResourceHandler +{ + public: + wxNotebookXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + + private: + bool m_IsInside; + wxNotebook *m_Notebook; +}; + +#endif + +#endif // _WX_XH_NOTBK_H_ diff --git a/contrib/include/wx/xml/xh_panel.h b/contrib/include/wx/xml/xh_panel.h new file mode 100644 index 0000000000..efa5ab3774 --- /dev/null +++ b/contrib/include/wx/xml/xh_panel.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_panel.h +// Purpose: XML resource handler for panels +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_PANEL_H_ +#define _WX_XH_PANEL_H_ + +#ifdef __GNUG__ +#pragma interface "xh_panel.h" +#endif + +#include "wx/xml/xmlres.h" + +class wxPanelXmlHandler : public wxXmlResourceHandler +{ + public: + wxPanelXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_PANEL_H_ diff --git a/contrib/include/wx/xml/xh_radbt.h b/contrib/include/wx/xml/xh_radbt.h new file mode 100644 index 0000000000..efe341b719 --- /dev/null +++ b/contrib/include/wx/xml/xh_radbt.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_radbt.h +// Purpose: XML resource handler for radio buttons +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_RADBT_H_ +#define _WX_XH_RADBT_H_ + +#ifdef __GNUG__ +#pragma interface "xh_radbt.h" +#endif + +#include "wx/xml/xmlres.h" +#include "wx/defs.h" + +#if wxUSE_RADIOBOX + +class wxRadioButtonXmlHandler : public wxXmlResourceHandler +{ + public: + wxRadioButtonXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif + +#endif // _WX_XH_RADIOBUTTON_H_ diff --git a/contrib/include/wx/xml/xh_radbx.h b/contrib/include/wx/xml/xh_radbx.h new file mode 100644 index 0000000000..e7846a9952 --- /dev/null +++ b/contrib/include/wx/xml/xh_radbx.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_radbx.h +// Purpose: XML resource handler for radio box +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_RADBX_H_ +#define _WX_XH_RADBX_H_ + +#ifdef __GNUG__ +#pragma interface "xh_radbx.h" +#endif + +#include "wx/xml/xmlres.h" + +#if wxUSE_RADIOBOX + +class wxRadioBoxXmlHandler : public wxXmlResourceHandler +{ + public: + wxRadioBoxXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + private: + bool m_InsideBox; + wxArrayString strList; +}; + +#endif + +#endif // _WX_XH_RADBX_H_ diff --git a/contrib/include/wx/xml/xh_sizer.h b/contrib/include/wx/xml/xh_sizer.h new file mode 100644 index 0000000000..4dfc87d95d --- /dev/null +++ b/contrib/include/wx/xml/xh_sizer.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_sizer.h +// Purpose: XML resource handler for wxBoxSizer +// Author: Vaclav Slavik +// Created: 2000/04/24 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_SIZER_H_ +#define _WX_XH_SIZER_H_ + +#ifdef __GNUG__ +#pragma interface "xh_sizer.h" +#endif + +#include "wx/xml/xmlres.h" + + +class wxSizer; + +class wxSizerXmlHandler : public wxXmlResourceHandler +{ + public: + wxSizerXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); + + private: + bool m_IsInside; + wxSizer *m_ParentSizer; +}; + + +#endif // _WX_XH_BOXSIZER_H_ diff --git a/contrib/include/wx/xml/xh_slidr.h b/contrib/include/wx/xml/xh_slidr.h new file mode 100644 index 0000000000..f27942f602 --- /dev/null +++ b/contrib/include/wx/xml/xh_slidr.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_slidr.h +// Purpose: XML resource handler for wxSlider +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_SLIDR_H_ +#define _WX_XH_SLIDR_H_ + +#ifdef __GNUG__ +#pragma interface "xh_slidr.h" +#endif + +#include "wx/xml/xmlres.h" +#include "wx/defs.h" + +#if wxUSE_SLIDER + +class wxSliderXmlHandler : public wxXmlResourceHandler +{ + enum + { + wxSL_DEFAULT_VALUE = 0, + wxSL_DEFAULT_MIN = 0, + wxSL_DEFAULT_MAX = 100 + }; + + public: + wxSliderXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif + +#endif // _WX_XH_SLIDER_H_ diff --git a/contrib/include/wx/xml/xh_spin.h b/contrib/include/wx/xml/xh_spin.h new file mode 100644 index 0000000000..31f42491e1 --- /dev/null +++ b/contrib/include/wx/xml/xh_spin.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_spin.h +// Purpose: XML resource handler for wxSpinButton +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_SPIN_H_ +#define _WX_XH_SPIN_H_ + +#ifdef __GNUG__ +#pragma interface "xh_spin.h" +#endif + +#include "wx/xml/xmlres.h" +#include "wx/defs.h" + +#if wxUSE_SPINBTN +class wxSpinButtonXmlHandler : public wxXmlResourceHandler +{ + enum + { + wxSP_DEFAULT_VALUE = 0, + wxSP_DEFAULT_MIN = 0, + wxSP_DEFAULT_MAX = 100 + }; + + public: + wxSpinButtonXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; +#endif + +#if wxUSE_SPINCTRL +class wxSpinCtrlXmlHandler : public wxXmlResourceHandler +{ + enum + { + wxSP_DEFAULT_VALUE = 0, + wxSP_DEFAULT_MIN = 0, + wxSP_DEFAULT_MAX = 100 + }; + + public: + wxSpinCtrlXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; +#endif + +#endif // _WX_XH_SPIN_H_ diff --git a/contrib/include/wx/xml/xh_stbmp.h b/contrib/include/wx/xml/xh_stbmp.h new file mode 100644 index 0000000000..a72941fbb9 --- /dev/null +++ b/contrib/include/wx/xml/xh_stbmp.h @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_stbmp.h +// Purpose: XML resource handler for wxStaticBitmap +// Author: Vaclav Slavik +// Created: 2000/04/22 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_STBMP_H_ +#define _WX_XH_STBMP_H_ + +#ifdef __GNUG__ +#pragma interface "xh_stbmp.h" +#endif + +#include "wx/xml/xmlres.h" + + +class wxStaticBitmapXmlHandler : public wxXmlResourceHandler +{ + public: + wxStaticBitmapXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_STBMP_H_ diff --git a/contrib/include/wx/xml/xh_sttxt.h b/contrib/include/wx/xml/xh_sttxt.h new file mode 100644 index 0000000000..840a101d6c --- /dev/null +++ b/contrib/include/wx/xml/xh_sttxt.h @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_sttxt.h +// Purpose: XML resource handler for wxStaticBitmap +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_STTXT_H_ +#define _WX_XH_STTXT_H_ + +#ifdef __GNUG__ +#pragma interface "xh_sttxt.h" +#endif + +#include "wx/xml/xmlres.h" + + +class wxStaticTextXmlHandler : public wxXmlResourceHandler +{ + public: + wxStaticTextXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_STBMP_H_ diff --git a/contrib/include/wx/xml/xh_text.h b/contrib/include/wx/xml/xh_text.h new file mode 100644 index 0000000000..56f6f8e880 --- /dev/null +++ b/contrib/include/wx/xml/xh_text.h @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_text.h +// Purpose: XML resource handler for wxTextCtrl +// Author: Aleksandras Gluchovas +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Aleksandras Gluchovas +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_TEXT_H_ +#define _WX_XH_TEXT_H_ + +#ifdef __GNUG__ +#pragma interface "xh_text.h" +#endif + +#include "wx/xml/xmlres.h" + + +class wxTextCtrlXmlHandler : public wxXmlResourceHandler +{ + public: + wxTextCtrlXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif // _WX_XH_TEXT_H_ diff --git a/contrib/include/wx/xml/xml.h b/contrib/include/wx/xml/xml.h new file mode 100644 index 0000000000..45aedba49f --- /dev/null +++ b/contrib/include/wx/xml/xml.h @@ -0,0 +1,241 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xml.h +// Purpose: wxXmlDocument - XML parser & data holder class +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XML_H_ +#define _WX_XML_H_ + +#ifdef __GNUG__ +#pragma interface "xml.h" +#endif + +#include "wx/defs.h" +#include "wx/string.h" +#include "wx/object.h" +#include "wx/list.h" + + +class wxXmlNode; +class wxXmlProperty; +class wxXmlDocument; +class wxXmlIOHandler; +class wxInputStream; +class wxOutputStream; + + +// Represents XML node type. +enum wxXmlNodeType +{ + // note: values are synchronized with xmlElementType from libxml + wxXML_ELEMENT_NODE = 1, + wxXML_ATTRIBUTE_NODE = 2, + wxXML_TEXT_NODE = 3, + wxXML_CDATA_SECTION_NODE = 4, + wxXML_ENTITY_REF_NODE = 5, + wxXML_ENTITY_NODE = 6, + wxXML_PI_NODE = 7, + wxXML_COMMENT_NODE = 8, + wxXML_DOCUMENT_NODE = 9, + wxXML_DOCUMENT_TYPE_NODE = 10, + wxXML_DOCUMENT_FRAG_NODE = 11, + wxXML_NOTATION_NODE = 12, + wxXML_HTML_DOCUMENT_NODE = 13 +}; + + +// Types of XML files: + +enum wxXmlIOType +{ + wxXML_IO_AUTO = 0, // detect it automatically + wxXML_IO_LIBXML, // use libxml2 to parse/save XML document + wxXML_IO_BIN, // save in binary uncompressed proprietary format + wxXML_IO_BINZ // svae in binary zlib-compressed proprietary format +}; + + +// Represents node property(ies). +// Example: in "src" is property with value +// "hello.gif" and "id" is prop. with value "3". + +class WXDLLEXPORT wxXmlProperty +{ + public: + wxXmlProperty() : m_Next(NULL) {} + wxXmlProperty(const wxString& name, const wxString& value, wxXmlProperty *next) + : m_Name(name), m_Value(value), m_Next(next) {} + ~wxXmlProperty() { delete m_Next; } + + wxString GetName() const { return m_Name; } + wxString GetValue() const { return m_Value; } + wxXmlProperty *GetNext() const { return m_Next; } + + void SetName(const wxString& name) { m_Name = name; } + void SetValue(const wxString& value) { m_Value = value; } + void SetNext(wxXmlProperty *next) { m_Next = next; } + + private: + wxString m_Name; + wxString m_Value; + wxXmlProperty *m_Next; +}; + + + +// Represents node in XML document. Node has name and may have content +// and properties. Most common node types are wxXML_TEXT_NODE (name and props +// are irrelevant) and wxXML_ELEMENT_NODE (e.g. in hi there is +// element with name="title", irrelevant content and one child (wxXML_TEXT_NODE +// with content="hi"). + +class WXDLLEXPORT wxXmlNode +{ + public: + wxXmlNode() : m_Properties(NULL), m_Parent(NULL), + m_Children(NULL), m_Next(NULL) {} + wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, + const wxString& name, const wxString& content, + wxXmlProperty *props, wxXmlNode *next); + ~wxXmlNode() { delete m_Properties; delete m_Next; delete m_Children; } + + // copy ctor & operator=. Note that this does NOT copy syblings + // and parent pointer, i.e. m_Parent and m_Next will be NULL + // after using copy ctor and are never unmodified by operator=. + // On the other hand, it DOES copy children and properties. + wxXmlNode(const wxXmlNode& node); + wxXmlNode& operator=(const wxXmlNode& node); + + // user-friendly creation: + wxXmlNode(wxXmlNodeType type, const wxString& name, + const wxString& content = wxEmptyString); + void AddChild(wxXmlNode *child); + void InsertChild(wxXmlNode *child, wxXmlNode *before_node); + bool RemoveChild(wxXmlNode *child); + void AddProperty(const wxString& name, const wxString& value); + bool DeleteProperty(const wxString& name); + + // access methods: + wxXmlNodeType GetType() const { return m_Type; } + wxString GetName() const { return m_Name; } + wxString GetContent() const { return m_Content; } + + wxXmlNode *GetParent() const { return m_Parent; } + wxXmlNode *GetNext() const { return m_Next; } + wxXmlNode *GetChildren() const { return m_Children; } + + wxXmlProperty *GetProperties() const { return m_Properties; } + bool GetPropVal(const wxString& propName, wxString *value) const; + wxString GetPropVal(const wxString& propName, const wxString& defaultVal) const; + bool HasProp(const wxString& propName) const; + + void SetType(wxXmlNodeType type) { m_Type = type; } + void SetName(const wxString& name) { m_Name = name; } + void SetContent(const wxString& con) { m_Content = con; } + + void SetParent(wxXmlNode *parent) { m_Parent = parent; } + void SetNext(wxXmlNode *next) { m_Next = next; } + void SetChildren(wxXmlNode *child) { m_Children = child; } + + void SetProperties(wxXmlProperty *prop) { m_Properties = prop; } + void AddProperty(wxXmlProperty *prop); + + private: + wxXmlNodeType m_Type; + wxString m_Name; + wxString m_Content; + wxXmlProperty *m_Properties; + wxXmlNode *m_Parent, *m_Children, *m_Next; + + void DoCopy(const wxXmlNode& node); +}; + + + + + + + +// This class holds XML data/document as parsed by libxml. Note that +// internal representation is independant on libxml and you can use +// it without libxml (see Load/SaveBinary). + +class WXDLLEXPORT wxXmlDocument : public wxObject +{ + public: + wxXmlDocument() : wxObject(), m_Version(_T("1.0")), m_Root(NULL) {} + wxXmlDocument(const wxString& filename, wxXmlIOType io_type = wxXML_IO_AUTO); + wxXmlDocument(wxInputStream& stream, wxXmlIOType io_type = wxXML_IO_AUTO); + ~wxXmlDocument() { delete m_Root; } + + wxXmlDocument(const wxXmlDocument& doc); + wxXmlDocument& operator=(const wxXmlDocument& doc); + + // Parses .xml file and loads data. Returns TRUE on success, FALSE + // otherwise. + // NOTE: Any call to this method will result into linking against libxml + // and app's binary size will grow by ca. 250kB + bool Load(const wxString& filename, wxXmlIOType io_type = wxXML_IO_AUTO); + bool Load(wxInputStream& stream, wxXmlIOType io_type = wxXML_IO_AUTO); + + // Saves document as .xml file. + // NOTE: Any call to this method will result into linking against libxml + // and app's binary size will grow by ca. 250kB + bool Save(const wxString& filename, wxXmlIOType io_type) const; + bool Save(wxOutputStream& stream, wxXmlIOType io_type) const; + + // Returns root node of the document. + wxXmlNode *GetRoot() const { return m_Root; } + + // Returns version of document (may be empty). + wxString GetVersion() const { return m_Version; } + // Returns encoding of document (may be empty). + wxString GetEncoding() const { return m_Encoding; } + + // Write-access methods: + void SetRoot(wxXmlNode *node) { delete m_Root ; m_Root = node; } + void SetVersion(const wxString& version) { m_Version = version; } + void SetEncoding(const wxString& encoding) { m_Encoding = encoding; } + + static void AddHandler(wxXmlIOHandler *handler); + static void CleanUpHandlers(); + static void InitStandardHandlers(); + + protected: + static wxList *sm_Handlers; + + private: + wxString m_Version, m_Encoding; + wxXmlNode *m_Root; + + void DoCopy(const wxXmlDocument& doc); +}; + + + +// wxXmlIOHandler takes care of loading and/or saving XML data. +// see xmlio.h for available handlers + +class WXDLLEXPORT wxXmlIOHandler : public wxObject +{ + public: + wxXmlIOHandler() {} + + virtual wxXmlIOType GetType() = 0; + virtual bool CanLoad(wxInputStream& stream) = 0; + virtual bool CanSave() = 0; + + virtual bool Load(wxInputStream& stream, wxXmlDocument& doc) = 0; + virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc) = 0; +}; + + + + + +#endif // _WX_XML_H_ diff --git a/contrib/include/wx/xml/xmlio.h b/contrib/include/wx/xml/xmlio.h new file mode 100644 index 0000000000..3e336b46c9 --- /dev/null +++ b/contrib/include/wx/xml/xmlio.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlio.h +// Purpose: wxXmlIOHandler - XML I/O classes +// Author: Vaclav Slavik +// Created: 2000/07/24 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XMLIO_H_ +#define _WX_XMLIO_H_ + +#ifdef __GNUG__ +#pragma interface "xmlio.h" +#endif + +#include "wx/defs.h" +#include "wx/string.h" +#include "wx/xml/xml.h" + + +class WXDLLEXPORT wxXmlIOHandlerBin : public wxXmlIOHandler +{ + public: + wxXmlIOHandlerBin() {} + + virtual wxXmlIOType GetType() { return wxXML_IO_BIN; } + virtual bool CanLoad(wxInputStream& stream); + virtual bool CanSave() { return TRUE; } + + virtual bool Load(wxInputStream& stream, wxXmlDocument& doc); + virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc); + + protected: + wxString ReadHeader(wxInputStream& stream); + void WriteHeader(wxOutputStream& stream, const wxString& header); +}; + + + +#if wxUSE_ZLIB + +class WXDLLEXPORT wxXmlIOHandlerBinZ : public wxXmlIOHandlerBin +{ + public: + wxXmlIOHandlerBinZ() {} + + virtual wxXmlIOType GetType() { return wxXML_IO_BINZ; } + virtual bool CanLoad(wxInputStream& stream); + + virtual bool Load(wxInputStream& stream, wxXmlDocument& doc); + virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc); +}; + +#endif + + + +class WXDLLEXPORT wxXmlIOHandlerLibxml : public wxXmlIOHandler +{ + public: + virtual wxXmlIOType GetType() { return wxXML_IO_LIBXML; } + virtual bool CanLoad(wxInputStream& stream); + virtual bool CanSave(); + + virtual bool Load(wxInputStream& stream, wxXmlDocument& doc); + virtual bool Save(wxOutputStream& stream, const wxXmlDocument& doc); +}; + + +#endif // _WX_XMLIO_H_ diff --git a/contrib/include/wx/xml/xmlres.h b/contrib/include/wx/xml/xmlres.h new file mode 100644 index 0000000000..118561b7ba --- /dev/null +++ b/contrib/include/wx/xml/xmlres.h @@ -0,0 +1,255 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlres.h +// Purpose: XML resources +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XMLRES_H_ +#define _WX_XMLRES_H_ + +#ifdef __GNUG__ +#pragma interface "xmlres.h" +#endif + +#include "wx/defs.h" +#include "wx/string.h" +#include "wx/dynarray.h" +#include "wx/datetime.h" +#include "wx/list.h" +#include "wx/gdicmn.h" + +class wxMenu; +class wxMenuBar; +class wxDialog; +class wxPanel; +class wxWindow; + +class wxXmlResourceHandler; + +#include "wx/xml/xml.h" + +enum +{ + wxXML_BINARY, + wxXML_ARCHIVE +}; + + + +class WXDLLEXPORT wxXmlResourceDataRecord +{ + public: + wxXmlResourceDataRecord() : Doc(NULL), Time(wxDateTime::Now()) {} + ~wxXmlResourceDataRecord() {delete Doc;} + + wxString File; + wxXmlDocument *Doc; + wxDateTime Time; +}; + +WX_DECLARE_OBJARRAY(wxXmlResourceDataRecord, wxXmlResourceDataRecords); + +// This class holds XML resources from one or more .xml files +// (or derived forms, either binary or zipped -- see manual for +// details). + +class WXDLLEXPORT wxXmlResource : public wxObject +{ + public: + wxXmlResource(); + wxXmlResource(const wxString& filemask, int type); + ~wxXmlResource(); + + // Loads resources from XML files that match given filemask. + // This method understands VFS (see filesys.h). Type is one of + // wxXML_TEXT, wxXML_BINARY, wxXML_ARCHIVE and specifies type of + // data to be expected: + // wxXML_BINARY - binary version of .xml file, as produced + // by wxXmlDocument::SaveBinary + // wxXML_ARCHIVE - ZIP archive that contains arbitrary number + // of files with .xmb extension + // (this kind of ZIP archive is produced by + // XML resources compiler that ships with wxWin) + bool Load(const wxString& filemask, int type = wxXML_ARCHIVE); + + // Initialize handlers for all supported controls/windows. This will + // make the executable quite big because it forces linking against + // most of wxWin library + void InitAllHandlers(); + + // Initialize only specific handler (or custom handler). Convention says + // that handler name is equal to control's name plus 'XmlHandler', e.g. + // wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler + // (xmlres) can create include file that contains initialization code for + // all controls used within the resource. + void AddHandler(wxXmlResourceHandler *handler); + + // Removes all handlers + void ClearHandlers(); + + // Loads menu from resource. Returns NULL on failure. + wxMenu *LoadMenu(const wxString& name); + + // Loads menubar from resource. Returns NULL on failure. + wxMenuBar *LoadMenuBar(const wxString& name); + + // Loads dialog. dlg points to parent window (if any). Second form + // is used to finish creation of already existing instance (main reason + // for this is that you may want to use derived class with new event table) + // Example (typical usage): + // MyDialog dlg; + // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog"); + // dlg->ShowModal(); + wxDialog *LoadDialog(wxWindow *parent, const wxString& name); + bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name); + + // Loads panel. panel points to parent window (if any). Second form + // is used to finish creation of already existing instance. + wxPanel *LoadPanel(wxWindow *parent, const wxString& name); + bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name); + + // Returns numeric ID that is equivalent to string id used in XML + // resource. To be used in event tables + // Macro XMLID is provided for convenience + static int GetXMLID(const char *str_id); + + protected: + // Scans resources list for unloaded files and loads them. Also reloads + // files that have been modified since last loading. + void UpdateResources(); + + // Finds resource (calls UpdateResources) and returns node containing it + wxXmlNode *FindResource(const wxString& name, const wxString& type); + + // Creates resource from info in given node: + wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL); + + private: + wxList m_Handlers; + wxXmlResourceDataRecords m_Data; + + friend class wxXmlResourceHandler; +}; + + +// Global instance of resource class. For your convenience. +extern wxXmlResource *wxTheXmlResource; + +// This macro translates string identifier (as used in XML resource, +// e.g. ...) to integer id that is needed by +// wxWindows event tables. +// Example: +// BEGIN_EVENT_TABLE(MyFrame, wxFrame) +// EVT_MENU(XMLID("quit"), MyFrame::OnQuit) +// EVT_MENU(XMLID("about"), MyFrame::OnAbout) +// EVT_MENU(XMLID("new"), MyFrame::OnNew) +// EVT_MENU(XMLID("open"), MyFrame::OnOpen) +// END_EVENT_TABLE() +#define XMLID(str_id) wxXmlResource::GetXMLID(str_id) + + +class WXDLLEXPORT wxXmlResourceHandler : public wxObject +{ + public: + wxXmlResourceHandler(); + virtual ~wxXmlResourceHandler() {} + + // Creates object (menu, dialog, control, ...) from XML node. + // Should check for validity. + // parent is higher-level object (usually window, dialog or panel) + // that is often neccessary to create resource + // if instance != NULL it should not create new instance via 'new' but + // rather use this one and call its Create method + wxObject *CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance); + + // This one is called from CreateResource after variables + // were filled + virtual wxObject *DoCreateResource() = 0; + + // Returns TRUE if it understands this node and can create + // resource from it, FALSE otherwise. + virtual bool CanHandle(wxXmlNode *node) = 0; + + // Check "platform" property if it matches this platform + // that is, if this node 'exists' under this platform + static bool CheckPlatform(wxXmlNode *node); + + void SetParentResource(wxXmlResource *res) { m_Resource = res; } + + + protected: + + wxXmlResource *m_Resource; + wxArrayString m_StyleNames; + wxArrayInt m_StyleValues; + + // Variables (filled by CreateResource) + wxXmlNode *m_Node; + wxObject *m_Parent, *m_Instance; + wxWindow *m_ParentAsWindow, *m_InstanceAsWindow; + + // --- Handy methods: + + // Gets node content from wxXML_ENTITY_NODE + // (the problem is, content is represented as + // wxXML_ENTITY_NODE name="tag", content="" + // |-- wxXML_TEXT_NODE or + // wxXML_CDATA_SECTION_NODE name="" content="content" + wxString GetNodeContent(wxXmlNode *node); + + // Check to see if a param exists + bool HasParam(const wxString& param); + + // Finds the node or returns NULL + wxXmlNode *GetParamNode(const wxString& param); + wxString GetParamValue(const wxString& param); + + // Add style flag (e.g. wxMB_DOCKABLE) to list of flags + // understood by this handler + void AddStyle(const wxString& name, int value); + + // Gets style flags from text in form "flag | flag2| flag3 |..." + // Only understads flags added with AddStyle + int GetStyle(const wxString& param = _T("style"), int defaults = 0); + + // Gets text from param and does some convertions: + // - replaces \n, \r, \t by respective chars (according to C syntax) + // - replaces $ by & and $$ by $ (needed for $File => &File because of XML) + // - converts encodings if neccessary + wxString GetText(const wxString& param); + + // Return XMLID + int GetID(); + wxString GetName(); + + // Get bool flag (1,t,yes,on,true are TRUE, everything else is FALSE) + bool GetBool(const wxString& param, bool defaultv = FALSE); + + // Get integer value from param + long GetLong( const wxString& param, long defaultv = 0 ); + + // Get colour in HTML syntax (#RRGGBB) + wxColour GetColour(const wxString& param); + + wxSize GetSize(const wxString& param = _T("size")); + wxPoint GetPosition(const wxString& param = _T("pos")); + + // Sets common window options: + void SetupWindow(wxWindow *wnd); + + void CreateChildren(wxObject *parent, bool only_this_handler = FALSE, + wxXmlNode *children_node = NULL /*stands for + GetParamNode("children")*/); + wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL) + { return m_Resource->CreateResFromNode(node, parent, instance); } +}; + +#define ADD_STYLE(style) AddStyle(_T(#style), style) + + + +#endif // _WX_XMLRES_H_ diff --git a/contrib/src/Makefile.in b/contrib/src/Makefile.in index 42a7ef8d06..46646b5d86 100644 --- a/contrib/src/Makefile.in +++ b/contrib/src/Makefile.in @@ -1,6 +1,6 @@ # $Id$ -CONTRIB_SUBDIRS=ogl mmedia stc +CONTRIB_SUBDIRS=ogl mmedia stc xml all: @for d in $(CONTRIB_SUBDIRS); do (cd $$d && $(MAKE)); done diff --git a/contrib/src/xml/Makefile.in b/contrib/src/xml/Makefile.in new file mode 100644 index 0000000000..67b1fa3cce --- /dev/null +++ b/contrib/src/xml/Makefile.in @@ -0,0 +1,31 @@ +# $Id$ + +top_srcdir = @top_srcdir@/.. +top_builddir = ../../.. +libsrc_dir = contrib/src/xml + +TARGET_LIBNAME=libwxxml + +LIBVERSION_CURRENT=0 +LIBVERSION_REVISION=1 +LIBVERSION_AGE=0 + +HEADER_PATH=$(top_srcdir)/contrib/include/wx +HEADER_SUBDIR=xml + +HEADERS=xh_all.h xh_bttn.h xh_chckb.h xh_chckl.h xh_choic.h xh_combo.h \ + xh_dlg.h xh_gauge.h xh_html.h xh_menu.h xh_notbk.h xh_panel.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 xml.h xmlio.h xmlres.h + + +OBJECTS=xml.o xmlbin.o xmlbinz.o xmlpars.o xmlres.o xmlrsall.o \ + xh_bttn.o xh_chckb.o xh_chckl.o xh_choic.o xh_combo.o xh_dlg.o \ + xh_gauge.o xh_html.o xh_menu.o xh_notbk.o xh_panel.o xh_radbt.o \ + xh_radbx.o xh_sizer.o xh_slidr.o xh_spin.o xh_stbmp.o xh_sttxt.o \ + xh_text.o \ + +APPEXTRADEFS=-I$(top_srcdir)/contrib/include + +include $(top_builddir)/src/makelib.env + diff --git a/contrib/src/xml/xh_bttn.cpp b/contrib/src/xml/xh_bttn.cpp new file mode 100644 index 0000000000..39c58b4989 --- /dev/null +++ b/contrib/src/xml/xh_bttn.cpp @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_bttn.cpp +// Purpose: XML resource for buttons +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_bttn.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_bttn.h" +#include "wx/button.h" + + +wxObject *wxButtonXmlHandler::DoCreateResource() +{ + wxButton *button = new wxButton(m_ParentAsWindow, + GetID(), + GetText(_T("label")), + GetPosition(), GetSize(), + GetStyle()); + button->SetName(GetName()); + if (GetBool(_T("default"), 0) == 1) button->SetDefault(); + SetupWindow(button); + + return button; +} + + + +bool wxButtonXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("button"); +} + + diff --git a/contrib/src/xml/xh_chckb.cpp b/contrib/src/xml/xh_chckb.cpp new file mode 100644 index 0000000000..d2d3c15f1a --- /dev/null +++ b/contrib/src/xml/xh_chckb.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_chckb.cpp +// Purpose: XML resource for wxCheckBox +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_chckb.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_chckb.h" +#include "wx/checkbox.h" + +#if wxUSE_CHECKBOX + +wxCheckBoxXmlHandler::wxCheckBoxXmlHandler() +: wxXmlResourceHandler() +{ +} + +wxObject *wxCheckBoxXmlHandler::DoCreateResource() +{ + wxCheckBox *control = new wxCheckBox(m_ParentAsWindow, + GetID(), + GetText(_T("label")), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetName() + ); + + control->SetValue( GetBool( _T("checked"))); + SetupWindow(control); + + return control; +} + + + +bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("checkbox"); +} + +#endif diff --git a/contrib/src/xml/xh_chckl.cpp b/contrib/src/xml/xh_chckl.cpp new file mode 100644 index 0000000000..7f709b14a4 --- /dev/null +++ b/contrib/src/xml/xh_chckl.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_chckl.cpp +// Purpose: XML resource for wxCheckList +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_chckl.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_chckl.h" +#include "wx/checklst.h" + +wxCheckListXmlHandler::wxCheckListXmlHandler() +: wxXmlResourceHandler(), m_InsideBox(FALSE) +{ + // no styles +} + +wxObject *wxCheckListXmlHandler::DoCreateResource() +{ + if( m_Node->GetName() == _T("checklist")) + { + // need to build the list of strings from children + m_InsideBox = TRUE; + CreateChildren( NULL, TRUE /* only this handler */); + wxString *strings = (wxString *) NULL; + if( strList.GetCount() > 0 ) + { + strings = new wxString[strList.GetCount()]; + int count = strList.GetCount(); + for( int i = 0; i < count; i++ ) + strings[i]=strList[i]; + } + + + wxCheckListBox *control = new wxCheckListBox(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + strList.GetCount(), + strings, + GetStyle(), + wxDefaultValidator, + GetName() + ); + + // step through children myself (again.) + wxXmlNode *n = GetParamNode(_T("children")); + if (n) n = n->GetChildren(); + int i = 0; + while (n) + { + if (n->GetType() != wxXML_ELEMENT_NODE || + n->GetName() != _T("item" )) + { n = n->GetNext(); continue; } + + // checking boolean is a bit ugly here (see GetBool() ) + wxString v = n->GetPropVal(_T("checked"), wxEmptyString); + v.MakeLower(); + if (v) + { + if( v == _T("1") || v == _T("t") || v == _T("yes") || + v == _T("on") || v == _T("true") ) + { + control->Check( i, TRUE ); + } + } + + i++; + n = n->GetNext(); + } + + SetupWindow(control); + + if( strings != NULL ) + delete [] strings; + strList.Clear(); // dump the strings + + return control; + } + else + { + // on the inside now. + // handle Label + + // add to the list + strList.Add( GetNodeContent(m_Node) ); + + return NULL; + } + +} + + + +bool wxCheckListXmlHandler::CanHandle(wxXmlNode *node) +{ + return( node->GetName() == _T("checklist") || + ( m_InsideBox && + node->GetName() == _T("item" )) + ); +} + + diff --git a/contrib/src/xml/xh_choic.cpp b/contrib/src/xml/xh_choic.cpp new file mode 100644 index 0000000000..ea39ffb94b --- /dev/null +++ b/contrib/src/xml/xh_choic.cpp @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_choic.cpp +// Purpose: XML resource for wxChoice +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_choic.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_choic.h" +#include "wx/choice.h" + +wxChoiceXmlHandler::wxChoiceXmlHandler() +: wxXmlResourceHandler() , m_InsideBox(FALSE) +{ + ADD_STYLE(wxCB_SORT); +} + +wxObject *wxChoiceXmlHandler::DoCreateResource() +{ + if( m_Node->GetName() == _T("choice")) + { + // find the selection + long selection = GetLong( _T("selection"), -1 ); + + // need to build the list of strings from children + m_InsideBox = TRUE; + CreateChildren( NULL, TRUE /* only this handler */); + wxString *strings = (wxString *) NULL; + if( strList.GetCount() > 0 ) + { + strings = new wxString[strList.GetCount()]; + int count = strList.GetCount(); + for( int i = 0; i < count; i++ ) + strings[i]=strList[i]; + } + + + wxChoice *control = new wxChoice(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + strList.GetCount(), + strings, + GetStyle(), + wxDefaultValidator, + GetName() + ); + + if( selection != -1 ) + control->SetSelection( selection ); + + SetupWindow(control); + + if( strings != NULL ) + delete [] strings; + strList.Clear(); // dump the strings + + return control; + } + else + { + // on the inside now. + // handle Label + + // add to the list + strList.Add( GetNodeContent(m_Node) ); + + return NULL; + } + +} + + + +bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node) +{ + return( node->GetName() == _T("choice") || + ( m_InsideBox && + node->GetName() == _T("item" )) + ); +} + + diff --git a/contrib/src/xml/xh_combo.cpp b/contrib/src/xml/xh_combo.cpp new file mode 100644 index 0000000000..115e87f1ad --- /dev/null +++ b/contrib/src/xml/xh_combo.cpp @@ -0,0 +1,101 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_combo.cpp +// Purpose: XML resource for wxRadioBox +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_combo.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_combo.h" +#include "wx/combobox.h" + +#if wxUSE_COMBOBOX + +wxComboBoxXmlHandler::wxComboBoxXmlHandler() +: wxXmlResourceHandler() , m_InsideBox(FALSE) +{ + ADD_STYLE(wxCB_SIMPLE); + ADD_STYLE(wxCB_SORT); + ADD_STYLE(wxCB_READONLY); + ADD_STYLE(wxCB_DROPDOWN); +} + +wxObject *wxComboBoxXmlHandler::DoCreateResource() +{ + if( m_Node->GetName() == _T("combobox")) + { + // find the selection + long selection = GetLong( _T("selection"), -1 ); + + // need to build the list of strings from children + m_InsideBox = TRUE; + CreateChildren( NULL, TRUE /* only this handler */); + wxString *strings = (wxString *) NULL; + if( strList.GetCount() > 0 ) + { + strings = new wxString[strList.GetCount()]; + int count = strList.GetCount(); + for( int i = 0; i < count; i++ ) + strings[i]=strList[i]; + } + + + wxComboBox *control = new wxComboBox(m_ParentAsWindow, + GetID(), + GetText(_T("value")), + GetPosition(), GetSize(), + strList.GetCount(), + strings, + GetStyle(), + wxDefaultValidator, + GetName() + ); + + if( selection != -1 ) + control->SetSelection( selection ); + + SetupWindow(control); + + if( strings != NULL ) + delete [] strings; + strList.Clear(); // dump the strings + + return control; + } + else + { + // on the inside now. + // handle Label + + // add to the list + strList.Add( GetNodeContent(m_Node) ); + + return NULL; + } + +} + + + +bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node) +{ + return( node->GetName() == _T("combobox") || + ( m_InsideBox && + node->GetName() == _T("item" )) + ); +} + +#endif diff --git a/contrib/src/xml/xh_dlg.cpp b/contrib/src/xml/xh_dlg.cpp new file mode 100644 index 0000000000..a05fb8e0bf --- /dev/null +++ b/contrib/src/xml/xh_dlg.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_dlg.cpp +// Purpose: XML resource for dialogs +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_dlg.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_dlg.h" +#include "wx/dialog.h" +#include "wx/log.h" +#include "wx/intl.h" + + +wxDialogXmlHandler::wxDialogXmlHandler() : wxXmlResourceHandler() +{ + ADD_STYLE(wxSTAY_ON_TOP); + ADD_STYLE(wxCAPTION); + ADD_STYLE(wxDEFAULT_DIALOG_STYLE); + ADD_STYLE(wxTHICK_FRAME); + ADD_STYLE(wxSYSTEM_MENU); + ADD_STYLE(wxRESIZE_BORDER); + ADD_STYLE(wxRESIZE_BOX); + ADD_STYLE(wxDIALOG_MODAL); + ADD_STYLE(wxDIALOG_MODELESS); + + ADD_STYLE(wxNO_3D); + ADD_STYLE(wxTAB_TRAVERSAL); + ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY); +} + + + +wxObject *wxDialogXmlHandler::DoCreateResource() +{ + wxDialog *dlg = wxDynamicCast(m_Instance, wxDialog); + + wxASSERT_MSG(dlg, _("XML resource: Cannot create dialog without instance.")); + + dlg->Create(m_ParentAsWindow, + GetID(), + GetText(_T("title")), + wxDefaultPosition, wxDefaultSize, + GetStyle(_T("style"), wxDEFAULT_DIALOG_STYLE), + GetName()); + dlg->SetClientSize(GetSize()); + dlg->Move(GetPosition()); + SetupWindow(dlg); + + CreateChildren(dlg); + + return dlg; +} + + + +bool wxDialogXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("dialog"); +} + + diff --git a/contrib/src/xml/xh_gauge.cpp b/contrib/src/xml/xh_gauge.cpp new file mode 100644 index 0000000000..5a4f227ff8 --- /dev/null +++ b/contrib/src/xml/xh_gauge.cpp @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_gauge.cpp +// Purpose: XML resource for wxGauge +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_gauge.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_gauge.h" +#include "wx/gauge.h" + +#if wxUSE_GAUGE + +wxGaugeXmlHandler::wxGaugeXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxGA_HORIZONTAL ); + ADD_STYLE( wxGA_VERTICAL ); + ADD_STYLE( wxGA_PROGRESSBAR ); + ADD_STYLE( wxGA_SMOOTH ); // windows only +} + +wxObject *wxGaugeXmlHandler::DoCreateResource() +{ + wxGauge *control = new wxGauge(m_ParentAsWindow, + GetID(), + GetLong( _T("range"), wxGAUGE_DEFAULT_RANGE), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetName() + ); + + if( HasParam( _T("value") )) + { + control->SetValue( GetLong( _T("value") )); + } + if( HasParam( _T("shadow") )) + { + control->SetShadowWidth( GetLong( _T("shadow") )); + } + if( HasParam( _T("bezel") )) + { + control->SetBezelFace( GetLong( _T("bezel") )); + } + + SetupWindow(control); + + return control; +} + + + +bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("gauge"); +} + + +#endif // wxUSE_GAUGE diff --git a/contrib/src/xml/xh_html.cpp b/contrib/src/xml/xh_html.cpp new file mode 100644 index 0000000000..ed0a5bcf4c --- /dev/null +++ b/contrib/src/xml/xh_html.cpp @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_html.cpp +// Purpose: XML resource for wxHtmlWindow +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_html.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_html.h" + +#if wxUSE_HTML + +#include "wx/html/htmlwin.h" + + +wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxHW_SCROLLBAR_NEVER ); + ADD_STYLE( wxHW_SCROLLBAR_AUTO ); +} + +wxObject *wxHtmlWindowXmlHandler::DoCreateResource() +{ + wxHtmlWindow *control = new wxHtmlWindow(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + GetStyle( _T("style" ), wxHW_SCROLLBAR_AUTO), + GetName() + ); + + if( HasParam( _T("borders") )) + { + control->SetBorders( GetLong( _T("borders" ))); + } + + if( HasParam( _T("url") )) + { + control->LoadPage( GetParamValue( _T("url" ))); + } + else if( HasParam( _T("htmlcode") )) + { + control->SetPage( GetText(_T("htmlcode")) ); + } + + SetupWindow(control); + + return control; +} + + + +bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("htmlwindow"); +} + +#endif // wxUSE_HTML diff --git a/contrib/src/xml/xh_menu.cpp b/contrib/src/xml/xh_menu.cpp new file mode 100644 index 0000000000..900b05b874 --- /dev/null +++ b/contrib/src/xml/xh_menu.cpp @@ -0,0 +1,126 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_menu.cpp +// Purpose: XML resource for menus and menubars +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_menu.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_menu.h" +#include "wx/menu.h" + + +wxMenuXmlHandler::wxMenuXmlHandler() : + wxXmlResourceHandler(), m_InsideMenu(FALSE) +{ + ADD_STYLE(wxMENU_TEAROFF); +} + + + +wxObject *wxMenuXmlHandler::DoCreateResource() +{ + if (m_Node->GetName() == _T("menu")) + { + wxMenu *menu = new wxMenu(GetStyle()); + wxString title = GetText(_T("label")); + wxString help = GetText(_T("help")); + + bool oldins = m_InsideMenu; + m_InsideMenu = TRUE; + CreateChildren(menu, TRUE/*only this handler*/); + m_InsideMenu = oldins; + + wxMenuBar *p_bar = wxDynamicCast(m_Parent, wxMenuBar); + if (p_bar) + p_bar->Append(menu, title); + else + { + wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu); + if (p_menu) + p_menu->Append(GetID(), title, menu, help); + } + + return menu; + } + + else + { + wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu); + + if (m_Node->GetName() == _T("separator")) + p_menu->AppendSeparator(); + else if (m_Node->GetName() == _T("break")) + p_menu->Break(); + else + { + int id = GetID(); + bool checkable = GetBool(_T("checkable")); + p_menu->Append(id, GetText(_T("label")), + GetText(_T("help")), checkable); + if (id != -1) + { + p_menu->Enable(id, GetBool(_T("enabled"), TRUE)); + if (checkable) p_menu->Check(id, GetBool(_T("checked"))); + } + } + return NULL; + } +} + + + +bool wxMenuXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("menu") || + (m_InsideMenu && + (node->GetName() == _T("menuitem") || + node->GetName() == _T("break") || + node->GetName() == _T("separator")) + ); +} + + + + + + + + + + + +wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler() +{ + ADD_STYLE(wxMB_DOCKABLE); +} + + + +wxObject *wxMenuBarXmlHandler::DoCreateResource() +{ + wxMenuBar *menubar = new wxMenuBar(GetStyle()); + CreateChildren(menubar); + return menubar; +} + + + +bool wxMenuBarXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("menubar"); +} + diff --git a/contrib/src/xml/xh_notbk.cpp b/contrib/src/xml/xh_notbk.cpp new file mode 100644 index 0000000000..30b4b6322a --- /dev/null +++ b/contrib/src/xml/xh_notbk.cpp @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_notbk.cpp +// Purpose: XML resource for wxBoxSizer +// Author: Vaclav Slavik +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_notbk.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_notbk.h" + +#if wxUSE_NOTEBOOK + +#include "wx/log.h" +#include "wx/notebook.h" + +wxNotebookXmlHandler::wxNotebookXmlHandler() +: wxXmlResourceHandler(), m_IsInside(FALSE), m_Notebook(NULL) +{ + ADD_STYLE(wxNB_FIXEDWIDTH); + ADD_STYLE(wxNB_LEFT); + ADD_STYLE(wxNB_RIGHT); + ADD_STYLE(wxNB_BOTTOM); +} + + + +wxObject *wxNotebookXmlHandler::DoCreateResource() +{ + if (m_Node->GetName() == _T("page")) + { + wxXmlNode *n = GetParamNode(_T("child"))->GetChildren(); + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + { + bool old_ins = m_IsInside; + m_IsInside = FALSE; + m_IsInside = old_ins; + wxObject *item = CreateResFromNode(n, m_Notebook, NULL); + wxWindow *wnd = wxDynamicCast(item, wxWindow); + + if (wnd) + m_Notebook->AddPage(wnd, GetText(_T("label")), + GetBool(_T("selected"), 0)); + else + wxLogError(_T("Error in resource.")); + return wnd; + } + n = n->GetNext(); + } + wxLogError(_T("Error in resource: no control within notebook's tag.")); + return NULL; + } + + else { + wxNotebook *nb = new wxNotebook(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + GetStyle( _T("style" )), + GetName()); + + wxNotebook *old_par = m_Notebook; + m_Notebook = nb; + bool old_ins = m_IsInside; + m_IsInside = TRUE; + CreateChildren(m_Notebook, TRUE/*only this handler*/); + m_IsInside = old_ins; + m_Notebook = old_par; + + return nb; + } +} + + + +bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node) +{ + return ((!m_IsInside && node->GetName() == _T("notebook")) || + (m_IsInside && node->GetName() == _T("page"))); +} + +#endif diff --git a/contrib/src/xml/xh_panel.cpp b/contrib/src/xml/xh_panel.cpp new file mode 100644 index 0000000000..5ed9c2a9f4 --- /dev/null +++ b/contrib/src/xml/xh_panel.cpp @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_panel.cpp +// Purpose: XML resource for panels +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_panel.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_panel.h" +#include "wx/panel.h" + + +wxPanelXmlHandler::wxPanelXmlHandler() : wxXmlResourceHandler() +{ + ADD_STYLE(wxNO_3D); + ADD_STYLE(wxTAB_TRAVERSAL); + ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY); +} + + + +wxObject *wxPanelXmlHandler::DoCreateResource() +{ + wxPanel *panel = new wxPanel(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + GetStyle(_T("style"), 0), + GetName()); + SetupWindow(panel); + CreateChildren(panel); + + return panel; +} + + +bool wxPanelXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("panel"); +} diff --git a/contrib/src/xml/xh_radbt.cpp b/contrib/src/xml/xh_radbt.cpp new file mode 100644 index 0000000000..bdcbfe5925 --- /dev/null +++ b/contrib/src/xml/xh_radbt.cpp @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_radbt.cpp +// Purpose: XML resource for wxRadioButton +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_radbt.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_radbt.h" +#include "wx/radiobut.h" + +#if wxUSE_RADIOBOX + +wxRadioButtonXmlHandler::wxRadioButtonXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxRB_GROUP ); +} + +wxObject *wxRadioButtonXmlHandler::DoCreateResource() +{ + /* BOBM - implementation note. + * once the wxBitmapRadioButton is implemented. + * look for a bitmap property. If not null, + * make it a wxBitmapRadioButton instead of the + * normal radio button. + */ + + wxRadioButton *control = new wxRadioButton(m_ParentAsWindow, + GetID(), + GetText(_T("label")), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetName() + ); + + control->SetValue( GetBool(_T("value"), 0)); + SetupWindow(control); + + return control; +} + + + +bool wxRadioButtonXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("radiobutton"); +} + + +#endif diff --git a/contrib/src/xml/xh_radbx.cpp b/contrib/src/xml/xh_radbx.cpp new file mode 100644 index 0000000000..0b1e6f13f4 --- /dev/null +++ b/contrib/src/xml/xh_radbx.cpp @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_radbx.cpp +// Purpose: XML resource for wxRadioBox +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_radbx.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_radbx.h" +#include "wx/radiobox.h" + +#if wxUSE_RADIOBOX + +wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() +: wxXmlResourceHandler() , m_InsideBox(FALSE) +{ + ADD_STYLE(wxRA_SPECIFY_COLS); + ADD_STYLE(wxRA_HORIZONTAL); + ADD_STYLE(wxRA_SPECIFY_ROWS); + ADD_STYLE(wxRA_VERTICAL); +} + +wxObject *wxRadioBoxXmlHandler::DoCreateResource() +{ + if( m_Node->GetName() == _T("radiobox")) + { + // find the selection + long selection = GetLong( _T("selection"), -1 ); + + // need to build the list of strings from children + m_InsideBox = TRUE; + CreateChildren( NULL, TRUE /* only this handler */, GetParamNode(_T("buttons"))); + wxString *strings = (wxString *) NULL; + if( strList.GetCount() > 0 ) + { + strings = new wxString[strList.GetCount()]; + int count = strList.GetCount(); + for( int i = 0; i < count; i++ ) + strings[i]=strList[i]; + } + + + wxRadioBox *control = new wxRadioBox(m_ParentAsWindow, + GetID(), + GetText(_T("label")), + GetPosition(), GetSize(), + strList.GetCount(), + strings, + GetLong( _T("dimension"), 0 ), + GetStyle(), + wxDefaultValidator, + GetName() + ); + + if( selection != -1 ) + control->SetSelection( selection ); + + SetupWindow(control); + + if( strings != NULL ) + delete [] strings; + strList.Clear(); // dump the strings + + return control; + } + else + { + // on the inside now. + // handle Label + + // add to the list + strList.Add( GetNodeContent(m_Node) ); + + return NULL; + } + +} + + + +bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node) +{ + return( node->GetName() == _T("radiobox") || + ( m_InsideBox && + node->GetName() == _T("item" )) + ); +} + +#endif diff --git a/contrib/src/xml/xh_sizer.cpp b/contrib/src/xml/xh_sizer.cpp new file mode 100644 index 0000000000..8932fc6557 --- /dev/null +++ b/contrib/src/xml/xh_sizer.cpp @@ -0,0 +1,195 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_sizer.cpp +// Purpose: XML resource for wxBoxSizer +// Author: Vaclav Slavik +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_sizer.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_sizer.h" +#include "wx/sizer.h" +#include "wx/log.h" +#include "wx/statbox.h" +#include "wx/notebook.h" + +wxSizerXmlHandler::wxSizerXmlHandler() +: wxXmlResourceHandler(), m_IsInside(FALSE), m_ParentSizer(NULL) +{ + ADD_STYLE(wxHORIZONTAL); + ADD_STYLE(wxVERTICAL); + + // and flags + ADD_STYLE(wxLEFT); + ADD_STYLE(wxRIGHT); + ADD_STYLE(wxTOP); + ADD_STYLE(wxBOTTOM); + ADD_STYLE(wxNORTH); + ADD_STYLE(wxSOUTH); + ADD_STYLE(wxEAST); + ADD_STYLE(wxWEST); + ADD_STYLE(wxALL); + + ADD_STYLE(wxGROW); + ADD_STYLE(wxEXPAND); + ADD_STYLE(wxSHAPED); + ADD_STYLE(wxSTRETCH_NOT); + + ADD_STYLE(wxALIGN_CENTER); + ADD_STYLE(wxALIGN_CENTRE); + ADD_STYLE(wxALIGN_LEFT); + ADD_STYLE(wxALIGN_TOP); + ADD_STYLE(wxALIGN_RIGHT); + ADD_STYLE(wxALIGN_BOTTOM); + ADD_STYLE(wxALIGN_CENTER_HORIZONTAL); + ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL); + ADD_STYLE(wxALIGN_CENTER_VERTICAL); + ADD_STYLE(wxALIGN_CENTRE_VERTICAL); +} + + + +wxObject *wxSizerXmlHandler::DoCreateResource() +{ + if (m_Node->GetName() == _T("sizeritem")) + { + wxXmlNode *n = GetParamNode(_T("window"))->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + { + bool old_ins = m_IsInside; + m_IsInside = FALSE; + wxObject *item = CreateResFromNode(n, m_Parent, NULL); + m_IsInside = old_ins; + wxSizer *sizer = wxDynamicCast(item, wxSizer); + wxWindow *wnd = wxDynamicCast(item, wxWindow); + + if (sizer) + m_ParentSizer->Add(sizer, GetLong(_T("option")), + GetStyle(_T("flag")), GetLong(_T("border"))); + else if (wnd) + m_ParentSizer->Add(wnd, GetLong(_T("option")), + GetStyle(_T("flag")), GetLong(_T("border"))); + else + wxLogError(_T("Error in resource.")); + + return item; + } + n = n->GetNext(); + } + wxLogError(_T("Error in resource: no control/sizer within sizer's tag.")); + return NULL; + } + + else if (m_Node->GetName() == _T("spacer")) + { + wxCHECK_MSG(m_ParentSizer, NULL, _T("Incorrect syntax of XML resource: spacer not within sizer!")); + wxSize sz = GetSize(); + m_ParentSizer->Add(sz.x, sz.y, + GetLong(_T("option")), GetStyle(_T("flag")), GetLong(_T("border"))); + return NULL; + } + +#if wxUSE_NOTEBOOK + else if (m_Node->GetName() == _T("notebooksizer")) + { + wxCHECK_MSG(m_ParentSizer, NULL, _T("Incorrect syntax of XML resource: notebooksizer not within sizer!")); + + wxSizer *old_par = m_ParentSizer; + m_ParentSizer = NULL; + + wxNotebook *nb = NULL; + wxObject *item; + wxXmlNode *n = GetParamNode(_T("window"))->GetChildren(); + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + { + item = CreateResFromNode(n, m_Parent, NULL); + nb = wxDynamicCast(item, wxNotebook); + break; + } + n = n->GetNext(); + } + + m_ParentSizer = old_par; + + wxCHECK_MSG(nb, NULL, _T("Incorrect syntax of XML resource: notebooksizer must contain a notebook!")); + return new wxNotebookSizer(nb); + } +#endif + + else { + wxSizer *sizer = NULL; + + wxXmlNode *parentNode = m_Node->GetParent()->GetParent(); + + wxCHECK_MSG(m_ParentSizer != NULL || + ((parentNode->GetName() == _T("panel") || + parentNode->GetName() == _T("dialog")) && + parentNode->GetType() == wxXML_ELEMENT_NODE), NULL, + _T("Incorrect use of sizer: parent is not 'dialog' or 'panel'.")); + + if (m_Node->GetName() == _T("boxsizer")) + sizer = new wxBoxSizer(GetStyle(_T("orient"), wxHORIZONTAL)); + + else if (m_Node->GetName() == _T("staticboxsizer")) + { + sizer = new wxStaticBoxSizer( + new wxStaticBox(m_ParentAsWindow, -1, GetText(_T("label"))), + GetStyle(_T("orient"), wxHORIZONTAL)); + } + + wxSizer *old_par = m_ParentSizer; + m_ParentSizer = sizer; + bool old_ins = m_IsInside; + m_IsInside = TRUE; + CreateChildren(m_Parent, TRUE/*only this handler*/); + m_IsInside = old_ins; + m_ParentSizer = old_par; + + if (m_ParentSizer == NULL) // setup window: + { + m_ParentAsWindow->SetAutoLayout(TRUE); + m_ParentAsWindow->SetSizer(sizer); + + wxXmlNode *nd = m_Node; + m_Node = parentNode; + if (GetSize() == wxDefaultSize) + sizer->Fit(m_ParentAsWindow); + m_Node = nd; + + if (m_ParentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER)) + sizer->SetSizeHints(m_ParentAsWindow); + } + + return sizer; + } +} + + + +bool wxSizerXmlHandler::CanHandle(wxXmlNode *node) +{ + return ((!m_IsInside && node->GetName() == _T("boxsizer")) || + (!m_IsInside && node->GetName() == _T("staticboxsizer")) || +#if wxUSE_NOTEBOOK + (!m_IsInside && node->GetName() == _T("notebooksizer")) || +#endif + (m_IsInside && node->GetName() == _T("sizeritem")) || + (m_IsInside && node->GetName() == _T("spacer"))); +} diff --git a/contrib/src/xml/xh_slidr.cpp b/contrib/src/xml/xh_slidr.cpp new file mode 100644 index 0000000000..38847f7d21 --- /dev/null +++ b/contrib/src/xml/xh_slidr.cpp @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_slidr.cpp +// Purpose: XML resource for wxSlider +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_slidr.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_slidr.h" +#include "wx/slider.h" + +#if wxUSE_SLIDER + +wxSliderXmlHandler::wxSliderXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxSL_HORIZONTAL ); + ADD_STYLE( wxSL_VERTICAL ); + ADD_STYLE( wxSL_AUTOTICKS ); + ADD_STYLE( wxSL_LABELS ); + ADD_STYLE( wxSL_LEFT ); + ADD_STYLE( wxSL_TOP ); + ADD_STYLE( wxSL_RIGHT ); + ADD_STYLE( wxSL_BOTTOM ); + ADD_STYLE( wxSL_BOTH ); + ADD_STYLE( wxSL_SELRANGE ); +} + +wxObject *wxSliderXmlHandler::DoCreateResource() +{ + wxSlider *control = new wxSlider(m_ParentAsWindow, + GetID(), + GetLong( _T("value"), wxSL_DEFAULT_VALUE), + GetLong( _T("min"), wxSL_DEFAULT_MIN), + GetLong( _T("max"), wxSL_DEFAULT_MAX), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetName() + ); + + if( HasParam( _T("tickfreq") )) + { + control->SetTickFreq( GetLong( _T("tickfreq") ), 0 ); + } + if( HasParam( _T("pagesize") )) + { + control->SetPageSize( GetLong( _T("pagesize") ) ); + } + if( HasParam( _T("linesize") )) + { + control->SetLineSize( GetLong( _T("linesize") )); + } + if( HasParam( _T("thumb") )) + { + control->SetThumbLength( GetLong( _T("thumb") )); + } + if( HasParam( _T("tick") )) + { + control->SetTick( GetLong( _T("tick") )); + } + if( HasParam( _T("selmin") ) && HasParam( _T("selmax")) ) + { + control->SetSelection( GetLong( _T("selmin") ), GetLong( _T("selmax")) ); + } + + SetupWindow(control); + + return control; +} + + + +bool wxSliderXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("slider"); +} + + +#endif diff --git a/contrib/src/xml/xh_spin.cpp b/contrib/src/xml/xh_spin.cpp new file mode 100644 index 0000000000..320813c999 --- /dev/null +++ b/contrib/src/xml/xh_spin.cpp @@ -0,0 +1,98 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_spin.cpp +// Purpose: XML resource for wxSpinButton +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_spin.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_spin.h" +#include "wx/spinctrl.h" + +#if wxUSE_SPINBTN + +wxSpinButtonXmlHandler::wxSpinButtonXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxSP_HORIZONTAL ); + ADD_STYLE( wxSP_VERTICAL ); + ADD_STYLE( wxSP_ARROW_KEYS ); + ADD_STYLE( wxSP_WRAP ); +} + +wxObject *wxSpinButtonXmlHandler::DoCreateResource() +{ + wxSpinButton *control = new wxSpinButton(m_ParentAsWindow, + GetID(), + GetPosition(), GetSize(), + GetStyle( _T("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS ), + GetName() + ); + + control->SetValue( GetLong( _T("value"), wxSP_DEFAULT_VALUE) ); + control->SetRange( GetLong( _T("min"), wxSP_DEFAULT_MIN), + GetLong( _T("max"), wxSP_DEFAULT_MAX) ); + SetupWindow(control); + + return control; +} + + + +bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("spinbutton"); +} + +#endif // wxUSE_SPINBTN + +#if wxUSE_SPINCTRL + +wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxSP_HORIZONTAL ); + ADD_STYLE( wxSP_VERTICAL ); + ADD_STYLE( wxSP_ARROW_KEYS ); + ADD_STYLE( wxSP_WRAP ); +} + +wxObject *wxSpinCtrlXmlHandler::DoCreateResource() +{ + wxSpinCtrl *control = new wxSpinCtrl(m_ParentAsWindow, + GetID(), + GetText(_T("label")), + GetPosition(), GetSize(), + GetStyle( _T("style"), wxSP_ARROW_KEYS ), + GetLong( _T("min"), wxSP_DEFAULT_MIN), + GetLong( _T("max"), wxSP_DEFAULT_MAX), + GetLong( _T("value"), wxSP_DEFAULT_VALUE), + GetName() + ); + + SetupWindow(control); + + return control; +} + + + +bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("spinctrl"); +} + +#endif // wxUSE_SPINCTRL diff --git a/contrib/src/xml/xh_stbmp.cpp b/contrib/src/xml/xh_stbmp.cpp new file mode 100644 index 0000000000..903b84b92d --- /dev/null +++ b/contrib/src/xml/xh_stbmp.cpp @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_stbmp.cpp +// Purpose: XML resource for wxStaticBitmap +// Author: Vaclav Slavik +// Created: 2000/04/22 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_stbmp.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_stbmp.h" +#include "wx/statbmp.h" +#include "wx/image.h" +#include "wx/bitmap.h" + +wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler() +: wxXmlResourceHandler() +{ +} + +wxObject *wxStaticBitmapXmlHandler::DoCreateResource() +{ + wxImage img(GetParamValue(_T("bitmap"))); + wxSize sz = GetSize(); + + if (!(sz == wxDefaultSize)) img.Rescale(sz.x, sz.y); + + wxStaticBitmap *bmp = new wxStaticBitmap(m_ParentAsWindow, + GetID(), + img.ConvertToBitmap(), + GetPosition(), GetSize(), + GetStyle(), + GetName() + ); + SetupWindow(bmp); + + return bmp; +} + + + +bool wxStaticBitmapXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("staticbitmap"); +} + + diff --git a/contrib/src/xml/xh_sttxt.cpp b/contrib/src/xml/xh_sttxt.cpp new file mode 100644 index 0000000000..f0e59c094f --- /dev/null +++ b/contrib/src/xml/xh_sttxt.cpp @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_sttxt.cpp +// Purpose: XML resource for wxStaticText +// Author: Bob Mitchell +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Bob Mitchell and Verant Interactive +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_sttxt.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_sttxt.h" +#include "wx/stattext.h" + +wxStaticTextXmlHandler::wxStaticTextXmlHandler() +: wxXmlResourceHandler() +{ + ADD_STYLE( wxST_NO_AUTORESIZE ); +} + +wxObject *wxStaticTextXmlHandler::DoCreateResource() +{ + wxStaticText *text = new wxStaticText(m_ParentAsWindow, + GetID(), + GetText(_T("label")), + GetPosition(), GetSize(), + GetStyle(), + GetName() + ); + SetupWindow(text); + + return text; +} + + + +bool wxStaticTextXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("statictext"); +} + + diff --git a/contrib/src/xml/xh_text.cpp b/contrib/src/xml/xh_text.cpp new file mode 100644 index 0000000000..8775d86cdf --- /dev/null +++ b/contrib/src/xml/xh_text.cpp @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_text.cpp +// Purpose: XML resource for wxTextCtrl +// Author: Aleksandras Gluchovas +// Created: 2000/03/21 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Aleksandras Gluchovas +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_text.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xh_text.h" +#include "wx/textctrl.h" + +wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler() +{ + ADD_STYLE(wxTE_PROCESS_ENTER); + ADD_STYLE(wxTE_PROCESS_TAB); + ADD_STYLE(wxTE_MULTILINE); + ADD_STYLE(wxTE_PASSWORD); + ADD_STYLE(wxTE_READONLY); + ADD_STYLE(wxHSCROLL); +} + +wxObject *wxTextCtrlXmlHandler::DoCreateResource() +{ + wxTextCtrl *text = new wxTextCtrl(m_ParentAsWindow, + GetID(), + GetText(_T("value")), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetText(_T("name")) + ); + SetupWindow(text); + + return text; +} + + + +bool wxTextCtrlXmlHandler::CanHandle(wxXmlNode *node) +{ + return node->GetName() == _T("textctrl"); +} + + diff --git a/contrib/src/xml/xml.cpp b/contrib/src/xml/xml.cpp new file mode 100644 index 0000000000..284b870acb --- /dev/null +++ b/contrib/src/xml/xml.cpp @@ -0,0 +1,424 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xml.cpp +// Purpose: wxXmlDocument - XML parser & data holder class +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xml.h" +#pragma implementation "xmlio.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + + +#include "wx/wfstream.h" +#include "wx/datstrm.h" +#include "wx/zstream.h" +#include "wx/log.h" +#include "wx/intl.h" + +#include "wx/xml/xml.h" +#include "wx/xml/xmlio.h" + + + +wxXmlNode::wxXmlNode(wxXmlNode *parent,wxXmlNodeType type, + const wxString& name, const wxString& content, + wxXmlProperty *props, wxXmlNode *next) + : m_Type(type), m_Name(name), m_Content(content), + m_Properties(props), m_Parent(parent), + m_Children(NULL), m_Next(next) +{ + if (m_Parent) + { + if (m_Parent->m_Children) + { + m_Next = m_Parent->m_Children; + m_Parent->m_Children = this; + } + else + m_Parent->m_Children = this; + } +} + + + +wxXmlNode::wxXmlNode(wxXmlNodeType type, const wxString& name, + const wxString& content) + : m_Type(type), m_Name(name), m_Content(content), + m_Properties(NULL), m_Parent(NULL), + m_Children(NULL), m_Next(NULL) +{} + + + +wxXmlNode::wxXmlNode(const wxXmlNode& node) +{ + m_Next = NULL; + m_Parent = NULL; + DoCopy(node); +} + + + +wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node) +{ + delete m_Properties; + delete m_Children; + DoCopy(node); + return *this; +} + + + +void wxXmlNode::DoCopy(const wxXmlNode& node) +{ + m_Type = node.m_Type; + m_Name = node.m_Name; + m_Content = node.m_Content; + m_Children = NULL; + + wxXmlNode *n = node.m_Children; + while (n) + { + AddChild(new wxXmlNode(*n)); + n = n->GetNext(); + } + + m_Properties = NULL; + wxXmlProperty *p = node.m_Properties; + while (p) + { + AddProperty(p->GetName(), p->GetValue()); + p = p->GetNext(); + } +} + + +bool wxXmlNode::HasProp(const wxString& propName) const +{ + wxXmlProperty *prop = GetProperties(); + + while (prop) + { + if (prop->GetName() == propName) return TRUE; + prop = prop->GetNext(); + } + + return FALSE; +} + + + +bool wxXmlNode::GetPropVal(const wxString& propName, wxString *value) const +{ + wxXmlProperty *prop = GetProperties(); + + while (prop) + { + if (prop->GetName() == propName) + { + *value = prop->GetValue(); + return TRUE; + } + prop = prop->GetNext(); + } + + return FALSE; +} + + + +wxString wxXmlNode::GetPropVal(const wxString& propName, const wxString& defaultVal) const +{ + wxString tmp; + if (GetPropVal(propName, &tmp)) + return tmp; + else + return defaultVal; +} + + + +void wxXmlNode::AddChild(wxXmlNode *child) +{ + if (m_Children == NULL) + m_Children = child; + else + { + wxXmlNode *ch = m_Children; + while (ch->m_Next) ch = ch->m_Next; + ch->m_Next = child; + } + child->m_Next = NULL; + child->m_Parent = this; +} + + + +void wxXmlNode::InsertChild(wxXmlNode *child, wxXmlNode *before_node) +{ + wxASSERT_MSG(before_node->GetParent() == this, _T("wxXmlNode::InsertChild - the node has incorrect parent")); + + if (m_Children == before_node) + m_Children = child; + else + { + wxXmlNode *ch = m_Children; + while (ch->m_Next != before_node) ch = ch->m_Next; + ch->m_Next = child; + } + + child->m_Parent = this; + child->m_Next = before_node; +} + + + +bool wxXmlNode::RemoveChild(wxXmlNode *child) +{ + if (m_Children == NULL) + return FALSE; + else if (m_Children == child) + { + m_Children = child->m_Next; + child->m_Parent = NULL; + child->m_Next = NULL; + return TRUE; + } + else + { + wxXmlNode *ch = m_Children; + while (ch->m_Next) + { + if (ch->m_Next == child) + { + ch->m_Next = child->m_Next; + child->m_Parent = NULL; + child->m_Next = NULL; + return TRUE; + } + ch = ch->m_Next; + } + return FALSE; + } +} + + + +void wxXmlNode::AddProperty(const wxString& name, const wxString& value) +{ + AddProperty(new wxXmlProperty(name, value, NULL)); +} + +void wxXmlNode::AddProperty(wxXmlProperty *prop) +{ + if (m_Properties == NULL) + m_Properties = prop; + else + { + wxXmlProperty *p = m_Properties; + while (p->GetNext()) p = p->GetNext(); + p->SetNext(prop); + } +} + + + +bool wxXmlNode::DeleteProperty(const wxString& name) +{ + if (m_Properties == NULL) + return FALSE; + + else if (m_Properties->GetName() == name) + { + wxXmlProperty *prop = m_Properties; + m_Properties = prop->GetNext(); + prop->SetNext(NULL); + delete prop; + return TRUE; + } + + else + { + wxXmlProperty *p = m_Properties; + while (p->GetNext()) + { + if (p->GetNext()->GetName() == name) + { + wxXmlProperty *prop = p->GetNext(); + p->SetNext(prop->GetNext()); + prop->SetNext(NULL); + delete prop; + return TRUE; + } + p = p->GetNext(); + } + return FALSE; + } +} + + + + + + + + + + +wxXmlDocument::wxXmlDocument(const wxString& filename, wxXmlIOType io_type) + : wxObject(), m_Root(NULL) +{ + if (!Load(filename, io_type)) + { + delete m_Root; + m_Root = NULL; + } +} + + + +wxXmlDocument::wxXmlDocument(wxInputStream& stream, wxXmlIOType io_type) + : wxObject(), m_Root(NULL) +{ + if (!Load(stream, io_type)) + { + delete m_Root; + m_Root = NULL; + } +} + + + +wxXmlDocument::wxXmlDocument(const wxXmlDocument& doc) +{ + DoCopy(doc); +} + + + +wxXmlDocument& wxXmlDocument::operator=(const wxXmlDocument& doc) +{ + delete m_Root; + DoCopy(doc); + return *this; +} + + + +void wxXmlDocument::DoCopy(const wxXmlDocument& doc) +{ + m_Version = doc.m_Version; + m_Encoding = doc.m_Encoding; + m_Root = new wxXmlNode(*doc.m_Root); +} + + + +bool wxXmlDocument::Load(const wxString& filename, wxXmlIOType io_type) +{ + wxFileInputStream stream(filename); + return Load(stream, io_type); +} + + + +bool wxXmlDocument::Load(wxInputStream& stream, wxXmlIOType io_type) +{ + wxNode *n = sm_Handlers->GetFirst(); + while (n) + { + wxXmlIOHandler *h = (wxXmlIOHandler*) n->GetData(); + + if ((io_type == wxXML_IO_AUTO || io_type == h->GetType()) && + h->CanLoad(stream)) + { + return h->Load(stream, *this); + } + n = n->GetNext(); + } + wxLogError(_("Cannot find XML I/O handler capable of loading this format.")); + return FALSE; +} + + + +bool wxXmlDocument::Save(const wxString& filename, wxXmlIOType io_type) const +{ + wxFileOutputStream stream(filename); + return Save(stream, io_type); +} + + + +bool wxXmlDocument::Save(wxOutputStream& stream, wxXmlIOType io_type) const +{ + wxNode *n = sm_Handlers->GetFirst(); + while (n) + { + wxXmlIOHandler *h = (wxXmlIOHandler*) n->GetData(); + if (io_type == h->GetType() && h->CanSave()) + { + return h->Save(stream, *this); + } + n = n->GetNext(); + } + wxLogError(_("Cannot find XML I/O handler capable of saving in this format.")); + return FALSE; +} + + + + + + +wxList *wxXmlDocument::sm_Handlers = NULL; + +void wxXmlDocument::AddHandler(wxXmlIOHandler *handler) +{ + if (sm_Handlers == NULL) + { + sm_Handlers = new wxList; + sm_Handlers->DeleteContents(TRUE); + } + sm_Handlers->Append(handler); +} + + +void wxXmlDocument::CleanUpHandlers() +{ + delete sm_Handlers; + sm_Handlers = NULL; +} + + +void wxXmlDocument::InitStandardHandlers() +{ + AddHandler(new wxXmlIOHandlerBin); + AddHandler(new wxXmlIOHandlerLibxml); +} + + +#include "wx/module.h" + +class wxXmlModule: public wxModule +{ + DECLARE_DYNAMIC_CLASS(wxXmlModule) + public: + wxXmlModule() {} + bool OnInit() { wxXmlDocument::InitStandardHandlers(); return TRUE; }; + void OnExit() { wxXmlDocument::CleanUpHandlers(); }; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxXmlModule, wxModule) diff --git a/contrib/src/xml/xmlbin.cpp b/contrib/src/xml/xmlbin.cpp new file mode 100644 index 0000000000..d647e8fe9b --- /dev/null +++ b/contrib/src/xml/xmlbin.cpp @@ -0,0 +1,161 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlbin.cpp +// Purpose: wxXmlIOHandlerBin +// Author: Vaclav Slavik +// Created: 2000/07/24 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// nothing, already in xml.cpp +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/datstrm.h" +#include "wx/log.h" +#include "wx/intl.h" + +#include "wx/xml/xmlio.h" + + + + +bool wxXmlIOHandlerBin::CanLoad(wxInputStream& stream) +{ + bool canread; + canread = (ReadHeader(stream) == _T("XMLBIN ")); + stream.SeekI(-9, wxFromCurrent); + return canread; +} + + + +wxString wxXmlIOHandlerBin::ReadHeader(wxInputStream& stream) +{ + wxUint8 version; + char cheader[8]; + + stream.Read(cheader, 8); + cheader[7] = 0; + stream.Read(&version, 1); + + if (version != 1) return wxEmptyString; + else return wxString(cheader); +} + + + +void wxXmlIOHandlerBin::WriteHeader(wxOutputStream& stream, const wxString& header) +{ + char cheader[8]; + size_t i; + wxUint8 version = 1; + + for (i = 0; i < header.Length(); i++) cheader[i] = header[i]; + for (; i < 7; i++) cheader[i] = ' '; + cheader[7] = 0; + stream.Write(cheader, 8); + stream.Write(&version, 1); +} + + + +static bool SaveBinNode(wxDataOutputStream& ds, wxXmlNode *node) +{ + if (node) + { + ds << (wxUint8)1 << + (wxUint8)node->GetType() << + node->GetName() << node->GetContent(); + + wxXmlProperty *prop = node->GetProperties(); + while (prop) + { + ds << (wxUint8)1; + ds << prop->GetName() << prop->GetValue(); + prop = prop->GetNext(); + + } + ds << (wxUint8)0; + + SaveBinNode(ds, node->GetNext()); + SaveBinNode(ds, node->GetChildren()); + } + else + ds << (wxUint8)0; + + return TRUE; +} + + + +bool wxXmlIOHandlerBin::Save(wxOutputStream& stream, const wxXmlDocument& doc) +{ + WriteHeader(stream, "XMLBIN "); + wxDataOutputStream ds(stream); + ds << doc.GetVersion() << doc.GetEncoding(); + SaveBinNode(ds, doc.GetRoot()); + return stream.LastError() == wxSTREAM_NOERROR; +} + + + +static wxXmlProperty *LoadBinProp(wxDataInputStream& ds) +{ + wxUint8 dummy; + ds >> dummy; + if (dummy == 0) return NULL; + + wxString name, value; + ds >> name >> value; + return new wxXmlProperty(name, value, LoadBinProp(ds)); +} + + + + +static wxXmlNode *LoadBinNode(wxDataInputStream& ds, wxXmlNode *parent) +{ + wxUint8 type; + wxString name, content; + wxUint8 dummy; + + ds >> dummy; + if (dummy == 0) return NULL; + ds >> type >> name >> content; + + wxXmlProperty *prop = LoadBinProp(ds); + + wxXmlNode *nd = new wxXmlNode(parent, (wxXmlNodeType)type, name, content, + prop, LoadBinNode(ds, parent)); + LoadBinNode(ds, nd); + return nd; +} + + + +bool wxXmlIOHandlerBin::Load(wxInputStream& stream, wxXmlDocument& doc) +{ + ReadHeader(stream); + wxDataInputStream ds(stream); + wxString tmp; + + ds >> tmp; + doc.SetVersion(tmp); + ds >> tmp; + doc.SetEncoding(tmp); + + doc.SetRoot(LoadBinNode(ds, NULL)); + + return (doc.GetRoot() != NULL); +} + + diff --git a/contrib/src/xml/xmlbinz.cpp b/contrib/src/xml/xmlbinz.cpp new file mode 100644 index 0000000000..a65d81bd99 --- /dev/null +++ b/contrib/src/xml/xmlbinz.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlbinz.cpp +// Purpose: wxXmlIOHandlerBinZ +// Author: Vaclav Slavik +// Created: 2000/07/24 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// nothing, already in xml.cpp +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/datstrm.h" +#include "wx/log.h" +#include "wx/zstream.h" + +#include "wx/xml/xmlio.h" + +#if wxUSE_ZLIB + + + +bool wxXmlIOHandlerBinZ::CanLoad(wxInputStream& stream) +{ + bool canread; + canread = (ReadHeader(stream) == _T("XMLBINZ")); + stream.SeekI(-9, wxFromCurrent); + return canread; +} + + + +bool wxXmlIOHandlerBinZ::Save(wxOutputStream& stream, const wxXmlDocument& doc) +{ + WriteHeader(stream, "XMLBINZ"); + wxZlibOutputStream costr(stream, 9); + return wxXmlIOHandlerBin::Save(costr, doc); +} + + + +bool wxXmlIOHandlerBinZ::Load(wxInputStream& stream, wxXmlDocument& doc) +{ + ReadHeader(stream); + wxZlibInputStream costr(stream); + return wxXmlIOHandlerBin::Load(stream, doc); +} + + +#endif diff --git a/contrib/src/xml/xmlpars.cpp b/contrib/src/xml/xmlpars.cpp new file mode 100644 index 0000000000..797c76d0a9 --- /dev/null +++ b/contrib/src/xml/xmlpars.cpp @@ -0,0 +1,283 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlpars.cpp +// Purpose: wxXmlDocument - XML parser +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// nothing - already in xml.cpp +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/wfstream.h" +#include "wx/intl.h" +#include "wx/log.h" +#include "wx/dynlib.h" +#include "wx/xml/xmlio.h" + +#include + +// dynamically loaded functions from libxml: +typedef xmlParserCtxtPtr (*type_xmlCreatePushParserCtxt) + (xmlSAXHandlerPtr sax, void *, const char *, int, const char *); +typedef xmlNodePtr (*type_xmlNewText)(const xmlChar *); +typedef xmlAttrPtr (*type_xmlSetProp)(xmlNodePtr, const xmlChar *, const xmlChar *); +typedef int (*type_xmlParseChunk)(xmlParserCtxtPtr, const char *, int, int); +typedef void (*type_xmlFreeParserCtxt)(xmlParserCtxtPtr); +typedef xmlDocPtr (*type_xmlNewDoc)(const xmlChar *); +typedef void (*type_xmlFreeDoc)(xmlDocPtr); +typedef xmlNodePtr (*type_xmlNewDocNode)(xmlDocPtr, xmlNsPtr, const xmlChar *, const xmlChar *); +typedef void (*type_xmlDocDumpMemory)(xmlDocPtr, xmlChar**, int *); +typedef xmlNodePtr (*type_xmlAddChild)(xmlNodePtr, xmlNodePtr); +typedef xmlNodePtr (*type_xmlNewChild)(xmlNodePtr, xmlNsPtr, const xmlChar *, const xmlChar *); +typedef xmlChar * (*type_xmlNodeListGetString)(xmlDocPtr, xmlNodePtr, int); +typedef xmlNodePtr (*type_xmlDocGetRootElement)(xmlDocPtr); +typedef xmlNodePtr (*type_xmlDocSetRootElement)(xmlDocPtr doc, xmlNodePtr root); + +static struct +{ + wxDllType Handle; + + type_xmlCreatePushParserCtxt xmlCreatePushParserCtxt; + type_xmlNewText xmlNewText; + type_xmlSetProp xmlSetProp; + type_xmlParseChunk xmlParseChunk; + type_xmlFreeParserCtxt xmlFreeParserCtxt; + type_xmlNewDoc xmlNewDoc; + type_xmlFreeDoc xmlFreeDoc; + type_xmlNewDocNode xmlNewDocNode; + type_xmlDocDumpMemory xmlDocDumpMemory; + type_xmlAddChild xmlAddChild; + type_xmlNewChild xmlNewChild; + type_xmlNodeListGetString xmlNodeListGetString; + type_xmlDocGetRootElement xmlDocGetRootElement; + type_xmlDocSetRootElement xmlDocSetRootElement; +} gs_libxmlDLL; + +static bool gs_libxmlLoaded = FALSE; +static bool gs_libxmlLoadFailed = FALSE; + + + +static void ReleaseLibxml() +{ + if (gs_libxmlLoaded) + { + wxLogDebug("Releasing libxml.so.2"); + wxDllLoader::UnloadLibrary(gs_libxmlDLL.Handle); + } + gs_libxmlLoaded = FALSE; + gs_libxmlLoadFailed = FALSE; +} + + +static bool LoadLibxml() +{ + if (gs_libxmlLoaded) return TRUE; + if (gs_libxmlLoadFailed) return FALSE; + gs_libxmlLoadFailed = TRUE; + + wxLogDebug("Loading libxml.so.2..."); +#ifdef __UNIX__ + gs_libxmlDLL.Handle = + wxDllLoader::LoadLibrary(_T("libxml.so.2"), &gs_libxmlLoaded); +#endif + + if (!gs_libxmlLoaded) return FALSE; + +#define LOAD_SYMBOL(sym) \ + gs_libxmlDLL.sym = \ + (type_##sym)wxDllLoader::GetSymbol(gs_libxmlDLL.Handle, _T(#sym)); \ + if (!gs_libxmlDLL.sym) { ReleaseLibxml(); return FALSE; } + + LOAD_SYMBOL(xmlCreatePushParserCtxt) + LOAD_SYMBOL(xmlNewText) + LOAD_SYMBOL(xmlSetProp) + LOAD_SYMBOL(xmlParseChunk) + LOAD_SYMBOL(xmlFreeParserCtxt) + LOAD_SYMBOL(xmlNewDoc) + LOAD_SYMBOL(xmlFreeDoc) + LOAD_SYMBOL(xmlNewDocNode) + LOAD_SYMBOL(xmlDocDumpMemory) + LOAD_SYMBOL(xmlAddChild) + LOAD_SYMBOL(xmlNewChild) + LOAD_SYMBOL(xmlNodeListGetString) + LOAD_SYMBOL(xmlDocGetRootElement) + LOAD_SYMBOL(xmlDocSetRootElement) + +#undef LOAD_SYMBOL + + gs_libxmlLoadFailed = FALSE; + + wxLogDebug("...succeed"); + return TRUE; +} + + + + +bool wxXmlIOHandlerLibxml::CanLoad(wxInputStream& stream) +{ + if (!LoadLibxml()) return FALSE; + char cheader[7]; + cheader[6] = 0; + stream.Read(cheader, 6); + stream.SeekI(-6, wxFromCurrent); + return strcmp(cheader, "children, 1); + wxXmlProperty *prop = + new wxXmlProperty(attr->name, val, CreateWXProperty(doc, attr->next)); + free(val); + return prop; +} + + + +static wxXmlNode *CreateWXNode(xmlDocPtr doc, wxXmlNode *parent, xmlNodePtr node) +{ + if (node == NULL) return NULL; + + wxXmlNode *nd = new wxXmlNode(parent, (wxXmlNodeType)node->type, + node->name, node->content, + CreateWXProperty(doc, node->properties), + CreateWXNode(doc, parent, node->next)); + CreateWXNode(doc, nd, node->children); + return nd; +} + + + +bool wxXmlIOHandlerLibxml::Load(wxInputStream& stream, wxXmlDocument& doc) +{ + if (!LoadLibxml()) return FALSE; + + xmlDocPtr dc; + xmlParserCtxtPtr ctxt; + + char buffer[1024]; + int res; + + res = stream.Read(buffer, 4).LastRead(); + if (res > 0) + { + bool okay = TRUE; + ctxt = gs_libxmlDLL.xmlCreatePushParserCtxt(NULL, NULL, + buffer, res, ""/*docname*/); + while ((res = stream.Read(buffer, 1024).LastRead()) > 0) + if (gs_libxmlDLL.xmlParseChunk(ctxt, buffer, res, 0) != 0) + okay = FALSE; + if (gs_libxmlDLL.xmlParseChunk(ctxt, buffer, 0, 1) != 0) okay = FALSE; + dc = ctxt->myDoc; + gs_libxmlDLL.xmlFreeParserCtxt(ctxt); + + doc.SetVersion(dc->version); + doc.SetEncoding(dc->encoding); + doc.SetRoot(CreateWXNode(dc, NULL, gs_libxmlDLL.xmlDocGetRootElement(dc))); + + gs_libxmlDLL.xmlFreeDoc(dc); + + return okay; + } + else return FALSE; +} + + + +static void CreateLibxmlNode(xmlNodePtr node, wxXmlNode *wxnode) +{ + node->type = (xmlElementType)wxnode->GetType(); + + wxXmlProperty *prop = wxnode->GetProperties(); + while (prop) + { + gs_libxmlDLL.xmlSetProp(node, (xmlChar*)prop->GetName().mb_str(), + (xmlChar*)prop->GetValue().mb_str()); + prop = prop->GetNext(); + } + + wxXmlNode *child = wxnode->GetChildren(); + xmlNodePtr n; + xmlChar *content, *name; + + while (child) + { + name = (xmlChar*)child->GetName().mb_str(); + if (!child->GetContent()) content = NULL; + else content = (xmlChar*)child->GetContent().mb_str(); + if (child->GetType() == wxXML_TEXT_NODE) + gs_libxmlDLL.xmlAddChild(node, n = gs_libxmlDLL.xmlNewText(content)); + else + n = gs_libxmlDLL.xmlNewChild(node, NULL, name, content); + CreateLibxmlNode(n, child); + child = child->GetNext(); + } +} + + + +bool wxXmlIOHandlerLibxml::Save(wxOutputStream& stream, const wxXmlDocument& doc) +{ + if (!LoadLibxml()) return FALSE; + + xmlDocPtr dc; + + wxASSERT_MSG(doc.GetRoot() != NULL, _("Trying to save empty document!")); + + dc = gs_libxmlDLL.xmlNewDoc((xmlChar*)doc.GetVersion().mb_str()); + + gs_libxmlDLL.xmlDocSetRootElement(dc, + gs_libxmlDLL.xmlNewDocNode(dc, NULL, + (xmlChar*)doc.GetRoot()->GetName().mb_str(), NULL)); + CreateLibxmlNode(gs_libxmlDLL.xmlDocGetRootElement(dc), doc.GetRoot()); + + xmlChar *buffer; + int size; + + gs_libxmlDLL.xmlDocDumpMemory(dc, &buffer, &size); + gs_libxmlDLL.xmlFreeDoc(dc); + stream.Write(buffer, size); + free(buffer); + return stream.LastWrite() == (unsigned)size; +} + + + + +#include "wx/module.h" + +class wxXmlLibxmlModule: public wxModule +{ + DECLARE_DYNAMIC_CLASS(wxXmlLibxmlModule) + public: + wxXmlLibxmlModule() {} + bool OnInit() { return TRUE; } + void OnExit() { ReleaseLibxml(); } +}; + +IMPLEMENT_DYNAMIC_CLASS(wxXmlLibxmlModule, wxModule) diff --git a/contrib/src/xml/xmlres.cpp b/contrib/src/xml/xmlres.cpp new file mode 100644 index 0000000000..ea00c03c75 --- /dev/null +++ b/contrib/src/xml/xmlres.cpp @@ -0,0 +1,688 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlres.cpp +// Purpose: XML resources +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xmlres.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/dialog.h" +#include "wx/panel.h" +#include "wx/wfstream.h" +#include "wx/filesys.h" +#include "wx/log.h" +#include "wx/intl.h" +#include "wx/tokenzr.h" +#include "wx/module.h" + +#include "wx/xml/xml.h" +#include "wx/xml/xmlres.h" + +#include "wx/arrimpl.cpp" +WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords); + + +wxXmlResource::wxXmlResource() +{ + m_Handlers.DeleteContents(TRUE); +} + +wxXmlResource::wxXmlResource(const wxString& filemask, int type) +{ + m_Handlers.DeleteContents(TRUE); + Load(filemask, type); +} + +wxXmlResource::~wxXmlResource() +{ + ClearHandlers(); +} + + +bool wxXmlResource::Load(const wxString& filemask, int type) +{ + wxString fnd; + wxXmlResourceDataRecord *drec; + +#if wxUSE_FILESYSTEM + wxFileSystem fsys; +# define wxXmlFindFirst fsys.FindFirst(filemask, wxFILE) +# define wxXmlFindNext fsys.FindNext() +#else +# define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE) +# define wxXmlFindNext wxFindNextFile() + wxASSERT_MSG(type != wxXML_ARCHIVE, wxT("ZIP archive XML resources supported only with wxUSE_FILESYSTEM set to 1!")); +#endif + fnd = wxXmlFindFirst; + while (!!fnd) + { +#if wxUSE_FILESYSTEM + if (type == wxXML_ARCHIVE) + { + wxFileSystem fs2; + wxString fnd2; + + fnd2 = fs2.FindFirst(fnd + wxT("#zip:*.xmb"), wxFILE); + while (!!fnd2) + { + drec = new wxXmlResourceDataRecord; + drec->File = fnd2; + m_Data.Add(drec); + fnd2 = fs2.FindNext(); + } + } + else +#endif + { + drec = new wxXmlResourceDataRecord; + drec->File = fnd; + m_Data.Add(drec); + } + fnd = wxXmlFindNext; + } +# undef wxXmlFindFirst +# undef wxXmlFindNext + return TRUE; +} + + + +void wxXmlResource::AddHandler(wxXmlResourceHandler *handler) +{ + m_Handlers.Append(handler); + handler->SetParentResource(this); +} + + + +void wxXmlResource::ClearHandlers() +{ + m_Handlers.Clear(); +} + + + +wxMenu *wxXmlResource::LoadMenu(const wxString& name) +{ + return (wxMenu*)CreateResFromNode(FindResource(name, wxT("menu")), NULL, NULL); +} + + + +wxMenuBar *wxXmlResource::LoadMenuBar(const wxString& name) +{ + return (wxMenuBar*)CreateResFromNode(FindResource(name, wxT("menubar")), NULL, NULL); +} + + + +wxDialog *wxXmlResource::LoadDialog(wxWindow *parent, const wxString& name) +{ + wxDialog *dialog = new wxDialog; + if (!LoadDialog(dialog, parent, name)) + { delete dialog; return NULL; } + else return dialog; +} + +bool wxXmlResource::LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name) +{ + return CreateResFromNode(FindResource(name, wxT("dialog")), parent, dlg) != NULL; +} + + + +wxPanel *wxXmlResource::LoadPanel(wxWindow *parent, const wxString& name) +{ + wxPanel *panel = new wxPanel; + if (!LoadPanel(panel, parent, name)) + { delete panel; return NULL; } + else return panel; +} + +bool wxXmlResource::LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name) +{ + return CreateResFromNode(FindResource(name, wxT("panel")), parent, panel) != NULL; +} + + + +void wxXmlResource::UpdateResources() +{ + bool modif; +# if wxUSE_FILESYSTEM + wxFSFile *file; + wxFileSystem fsys; +# endif + + for (size_t i = 0; i < m_Data.GetCount(); i++) + { + modif = (m_Data[i].Doc == NULL); + + if (!modif) + { +# if wxUSE_FILESYSTEM + file = fsys.OpenFile(m_Data[i].File); + modif = file && file->GetModificationTime() > m_Data[i].Time; + if (!file) + wxLogError(_("Cannot open file '%s'."), m_Data[i].File.c_str()); + delete file; +# else + modif = wxDateTime(wxFileModificationTime(m_Data[i].File)) > m_Data[i].Time; +# endif + } + + if (modif) + { + wxInputStream *stream; + +# if wxUSE_FILESYSTEM + file = fsys.OpenFile(m_Data[i].File); + stream = file->GetStream(); +# else + stream = new wxFileInputStream(m_Data[i].File); +# endif + + if (stream) + { + delete m_Data[i].Doc; + m_Data[i].Doc = new wxXmlDocument; + } + if (!stream || !m_Data[i].Doc->Load(*stream)) + wxLogError(_("Cannot load resources from file '%s'."), m_Data[i].File.c_str()); + + if (m_Data[i].Doc->GetRoot()->GetName() != _T("resource")) + wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data[i].File.c_str()); + +# if wxUSE_FILESYSTEM + delete file; +# else + delete stream; +# endif + } + } +} + + + +wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& type) +{ + UpdateResources(); //ensure everything is up-to-date + + wxString dummy; + for (size_t f = 0; f < m_Data.GetCount(); f++) + { + for (wxXmlNode *node = m_Data[f].Doc->GetRoot()->GetChildren(); + node; node = node->GetNext()) + if ( node->GetType() == wxXML_ELEMENT_NODE && + (!type || node->GetName() == type) && + node->GetPropVal(wxT("name"), &dummy) && + dummy == name && + wxXmlResourceHandler::CheckPlatform(node)) + return node; + } + + wxLogError(_("XML resource '%s' (type '%s') not found!"), + name.c_str(), type.c_str()); + return NULL; +} + + + +wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance) +{ + if (node == NULL) return NULL; + + wxXmlResourceHandler *handler; + wxObject *ret; + wxNode * ND = m_Handlers.GetFirst(); + while (ND) + { + handler = (wxXmlResourceHandler*)ND->GetData(); + if (handler->CanHandle(node)) + { + ret = handler->CreateResource(node, parent, instance); + if (ret) return ret; + } + ND = ND->GetNext(); + } + + wxLogError(_("No handler found for XML node '%s'!"), node->GetName().c_str()); + return NULL; +} + + + + + + + + + +wxXmlResourceHandler::wxXmlResourceHandler() + : m_Node(NULL), m_Parent(NULL), m_Instance(NULL), + m_ParentAsWindow(NULL), m_InstanceAsWindow(NULL) +{} + + + +wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance) +{ + if (!CheckPlatform(node)) return NULL; + + wxXmlNode *myNode = m_Node; + wxObject *myParent = m_Parent, *myInstance = m_Instance; + wxWindow *myParentAW = m_ParentAsWindow, *myInstanceAW = m_InstanceAsWindow; + + m_Node = node; + m_Parent = parent; + m_Instance = instance; + m_ParentAsWindow = wxDynamicCast(m_Parent, wxWindow); + m_InstanceAsWindow = wxDynamicCast(m_Instance, wxWindow); + + wxObject *returned = DoCreateResource(); + + m_Node = myNode; + m_Parent = myParent; m_ParentAsWindow = myParentAW; + m_Instance = myInstance; m_InstanceAsWindow = myInstanceAW; + + return returned; +} + + + +/*static*/ bool wxXmlResourceHandler::CheckPlatform(wxXmlNode *node) +{ + wxString s; + if (!node->GetPropVal(_T("platform"), &s)) return TRUE; +#ifdef __WXMSW__ + return s == wxString(_T("win")); +#elif defined(__UNIX__) + return s == wxString(_T("unix")); +#elif defined(__MAC__) + return s == wxString(_T("mac")); +#elif defined(__OS2__) + return s == wxString(_T("os2")); +#else + wxLogWarning(_("You're running the application on unknown platform, check for platfrom '%s' failed."), s.mb_str()); + return TRUE; // unknown platform +#endif +} + + +void wxXmlResourceHandler::AddStyle(const wxString& name, int value) +{ + m_StyleNames.Add(name); + m_StyleValues.Add(value); +} + + +bool wxXmlResourceHandler::HasParam(const wxString& param) +{ + return (GetParamNode(param) != NULL); +} + + +int wxXmlResourceHandler::GetStyle(const wxString& param, int defaults) +{ + wxString s = GetParamValue(param); + + if (!s) return defaults; + + wxStringTokenizer tkn(s, _T("| "), wxTOKEN_STRTOK); + int style = 0; + int index; + wxString fl; + while (tkn.HasMoreTokens()) + { + fl = tkn.GetNextToken(); + index = m_StyleNames.Index(fl); + if (index != wxNOT_FOUND) + style |= m_StyleValues[index]; + else + wxLogError(_("Unknown style flag ") + fl); + } + return style; +} + + + +wxString wxXmlResourceHandler::GetText(const wxString& param) +{ + wxString str1 = GetParamValue(param); + wxString str2; + const wxChar *dt; + + for (dt = str1.c_str(); *dt; dt++) + { + // Remap $ to &, map $$ to $ (for things like "&File..." -- + // this is illegal in XML, so we use "$File..."): + if (*dt == '$') + switch (*(++dt)) + { + case '$' : str2 << '$'; break; + default : str2 << '&' << *dt; break; + } + // Remap \n to CR, \r LF, \t to TAB: + else if (*dt == '\\') + switch (*(++dt)) + { + case 'n' : str2 << '\n'; break; + case 't' : str2 << '\t'; break; + case 'r' : str2 << '\r'; break; + default : str2 << '\\' << *dt; break; + } + else str2 << *dt; + } + return str2; +} + + + +long wxXmlResourceHandler::GetLong(const wxString& param, long defaultv) +{ + long value; + wxString str1 = GetParamValue(param); + + if (!str1.ToLong(&value)) + value = defaultv; + + return value; +} + + +int wxXmlResourceHandler::GetID() +{ + wxString sid = GetName(); + long num; + + if (sid == _T("-1")) return -1; + else if (sid.IsNumber() && sid.ToLong(&num)) return num; +#define stdID(id) else if (sid == _T(#id)) return id + stdID(wxID_OPEN); stdID(wxID_CLOSE); stdID(wxID_NEW); + stdID(wxID_SAVE); stdID(wxID_SAVEAS); stdID(wxID_REVERT); + stdID(wxID_EXIT); stdID(wxID_UNDO); stdID(wxID_REDO); + stdID(wxID_HELP); stdID(wxID_PRINT); stdID(wxID_PRINT_SETUP); + stdID(wxID_PREVIEW); stdID(wxID_ABOUT); stdID(wxID_HELP_CONTENTS); + stdID(wxID_HELP_COMMANDS); stdID(wxID_HELP_PROCEDURES); + stdID(wxID_CUT); stdID(wxID_COPY); stdID(wxID_PASTE); + stdID(wxID_CLEAR); stdID(wxID_FIND); stdID(wxID_DUPLICATE); + stdID(wxID_SELECTALL); stdID(wxID_OK); stdID(wxID_CANCEL); + stdID(wxID_APPLY); stdID(wxID_YES); stdID(wxID_NO); + stdID(wxID_STATIC); stdID(wxID_FORWARD); stdID(wxID_BACKWARD); + stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP); + stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT); +#undef stdID + else return XMLID(sid.c_str()); +} + + +wxString wxXmlResourceHandler::GetName() +{ + return m_Node->GetPropVal(_T("name"), _T("-1")); +} + + + +bool wxXmlResourceHandler::GetBool(const wxString& param, bool defaultv) +{ + wxString v = GetParamValue(param); + v.MakeLower(); + if (!v) return defaultv; + else return v == _T("1") || v == _T("t") || v == _T("yes") || + v == _T("on") || v == _T("true"); +} + + + +wxColour wxXmlResourceHandler::GetColour(const wxString& param) +{ + wxString v = GetParamValue(param); + unsigned long tmp = 0; + + if (v.Length() != 7 || v[0] != _T('#') || + wxSscanf(v.c_str(), _T("#%lX"), &tmp) != 1) + { + wxLogError(_("XML resource: Incorrect colour specification '%s' for property '%s'."), + v.c_str(), param.c_str()); + return wxNullColour; + } + + return wxColour((tmp & 0xFF0000) >> 16 , + (tmp & 0x00FF00) >> 8, + (tmp & 0x0000FF)); +} + + +wxXmlNode *wxXmlResourceHandler::GetParamNode(const wxString& param) +{ + wxXmlNode *n = m_Node->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == param) + return n; + n = n->GetNext(); + } + return NULL; +} + + +wxString wxXmlResourceHandler::GetNodeContent(wxXmlNode *node) +{ + wxXmlNode *n = node; + if (n == NULL) return wxEmptyString; + n = n->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_TEXT_NODE || + n->GetType() == wxXML_CDATA_SECTION_NODE) + return n->GetContent(); + n = n->GetNext(); + } + return wxEmptyString; +} + + + +wxString wxXmlResourceHandler::GetParamValue(const wxString& param) +{ + return GetNodeContent(GetParamNode(param)); +} + + + +wxSize wxXmlResourceHandler::GetSize(const wxString& param) +{ + wxString s = GetParamValue(param); + if (!s) s = _T("-1,-1"); + bool is_dlg; + long sx, sy; + + is_dlg = s[s.Length()-1] == _T('d'); + if (is_dlg) s.RemoveLast(); + + if (!s.BeforeFirst(_T(',')).ToLong(&sx) || + !s.AfterLast(_T(',')).ToLong(&sy)) + { + wxLogError(_("Cannot parse coordinates from '%s'."), s.mb_str()); + return wxDefaultSize; + } + + if (is_dlg) + { + if (m_InstanceAsWindow) + return wxDLG_UNIT(m_InstanceAsWindow, wxSize(sx, sy)); + else if (m_ParentAsWindow) + return wxDLG_UNIT(m_ParentAsWindow, wxSize(sx, sy)); + else + { + wxLogError(_("Cannot convert dialog units: dialog unknown.")); + return wxDefaultSize; + } + } + else return wxSize(sx, sy); +} + + + +wxPoint wxXmlResourceHandler::GetPosition(const wxString& param) +{ + wxSize sz = GetSize(param); + return wxPoint(sz.x, sz.y); +} + + + +void wxXmlResourceHandler::SetupWindow(wxWindow *wnd) +{ + //FIXME : add font, cursor + + if (HasParam(_T("exstyle"))) + wnd->SetExtraStyle(GetStyle(_T("exstyle"))); + if (HasParam(_T("bg"))) + wnd->SetBackgroundColour(GetColour(_T("bg"))); + if (HasParam(_T("fg"))) + wnd->SetForegroundColour(GetColour(_T("fg"))); + if (GetBool(_T("enabled"), 1) == 0) + wnd->Enable(FALSE); + if (GetBool(_T("focused"), 0) == 1) + wnd->SetFocus(); + if (GetBool(_T("hidden"), 0) == 1) + wnd->Show(FALSE); +#if wxUSE_TOOLTIPS + if (HasParam(_T("tooltip"))) + wnd->SetToolTip(GetText(_T("tooltip"))); +#endif +} + + +void wxXmlResourceHandler::CreateChildren(wxObject *parent, + bool only_this_handler, wxXmlNode *children_node) +{ + if (children_node == NULL) children_node = GetParamNode(_T("children")); + if (children_node == NULL) return; + + wxXmlNode *n = children_node->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + { + if (only_this_handler) + { + if (CanHandle(n)) + CreateResource(n, parent, NULL); + } + else + m_Resource->CreateResFromNode(n, parent, NULL); + } + n = n->GetNext(); + } +} + + + + + + + + + +// --------------- XMLID implementation ----------------------------- + + +#define XMLID_TABLE_SIZE 1024 + +struct XMLID_record +{ + int id; + const char *key; + XMLID_record *next; +}; + +static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL}; +static int XMLID_LastID = wxID_HIGHEST; + +/*static*/ int wxXmlResource::GetXMLID(const char *str_id) +{ + int index = 0; + + for (const char *c = str_id; *c != '\0'; c++) index += (int)*c; + index %= XMLID_TABLE_SIZE; + + XMLID_record *oldrec = NULL; + for (XMLID_record *rec = XMLID_Records[index]; rec; rec = rec->next) + { + if (strcmp(rec->key, str_id) == 0) return rec->id; + oldrec = rec; + } + + XMLID_record **rec_var = (oldrec == NULL) ? + &XMLID_Records[index] : &oldrec->next; + *rec_var = new XMLID_record; + (*rec_var)->id = ++XMLID_LastID; + (*rec_var)->key = str_id; + (*rec_var)->next = NULL; + + return (*rec_var)->id; +} + + +static void CleanXMLID_Record(XMLID_record *rec) +{ + if (rec) + { + CleanXMLID_Record(rec->next); + delete rec; + } +} + +static void CleanXMLID_Records() +{ + for (int i = 0; i < XMLID_TABLE_SIZE; i++) + CleanXMLID_Record(XMLID_Records[i]); +} + + + + + + + + +// --------------- module and globals ----------------------------- + + +static wxXmlResource gs_XmlResource; + +wxXmlResource *wxTheXmlResource = &gs_XmlResource; + + +class wxXmlResourceModule: public wxModule +{ +DECLARE_DYNAMIC_CLASS(wxXmlResourceModule) +public: + wxXmlResourceModule() {} + bool OnInit() {return TRUE;} + void OnExit() + { + wxTheXmlResource->ClearHandlers(); + CleanXMLID_Records(); + } +}; + +IMPLEMENT_DYNAMIC_CLASS(wxXmlResourceModule, wxModule) diff --git a/contrib/src/xml/xmlrsall.cpp b/contrib/src/xml/xmlrsall.cpp new file mode 100644 index 0000000000..d28ee9bb14 --- /dev/null +++ b/contrib/src/xml/xmlrsall.cpp @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xmlrsall.cpp +// Purpose: wxXmlResource::InitAllHandlers +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// -- Already done in xmlres.cpp +//#ifdef __GNUG__ +//#pragma implementation "xmlres.h" +//#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xmlres.h" +#include "wx/xml/xh_all.h" + +void wxXmlResource::InitAllHandlers() +{ + AddHandler(new wxMenuXmlHandler); + AddHandler(new wxMenuBarXmlHandler); + + AddHandler(new wxDialogXmlHandler); + AddHandler(new wxPanelXmlHandler); + AddHandler(new wxButtonXmlHandler); +#if wxUSE_GAUGE + AddHandler(new wxGaugeXmlHandler); +#endif +#if wxUSE_CHECKBOX + AddHandler(new wxCheckBoxXmlHandler); +#endif +#if wxUSE_HTML + AddHandler(new wxHtmlWindowXmlHandler); +#endif +#if wxUSE_SPINBTN + AddHandler(new wxSpinButtonXmlHandler); +#endif +#if wxUSE_SPINCTRL + AddHandler(new wxSpinCtrlXmlHandler); +#endif + AddHandler(new wxStaticTextXmlHandler); + AddHandler(new wxStaticBitmapXmlHandler); + AddHandler(new wxSliderXmlHandler); +#if wxUSE_RADIOBOX + AddHandler(new wxRadioBoxXmlHandler); + AddHandler(new wxRadioButtonXmlHandler); +#endif +#if wxUSE_COMBOBOX + AddHandler(new wxComboBoxXmlHandler); +#endif + AddHandler(new wxChoiceXmlHandler); + AddHandler(new wxCheckListXmlHandler); + AddHandler(new wxSizerXmlHandler); +#if wxUSE_NOTEBOOK + AddHandler(new wxNotebookXmlHandler); +#endif + AddHandler(new wxTextCtrlXmlHandler); +} diff --git a/contrib/utils/Makefile.in b/contrib/utils/Makefile.in new file mode 100644 index 0000000000..5bf9f61d11 --- /dev/null +++ b/contrib/utils/Makefile.in @@ -0,0 +1,10 @@ +# $Id$ + +CONTRIB_UTILS=wxrc wxrcedit + +all: + @for d in $(CONTRIB_UTILS); do (cd $$d && $(MAKE)); done + +clean: + @for d in $(CONTRIB_UTILS); do (cd $$d && $(MAKE) clean); done + diff --git a/contrib/utils/wxrc/Makefile.in b/contrib/utils/wxrc/Makefile.in new file mode 100644 index 0000000000..1814109adf --- /dev/null +++ b/contrib/utils/wxrc/Makefile.in @@ -0,0 +1,16 @@ +# $Id$ + +top_srcdir = @top_srcdir@/.. +top_builddir = ../../.. +program_dir = contrib/utils/wxrc + +PROGRAM=wxrc + +OBJECTS=wxrc.o + + +APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@ +APPEXTRADEFS=-I$(top_srcdir)/contrib/include + +include $(top_builddir)/src/makeprog.env + diff --git a/contrib/utils/wxrc/wxrc.cpp b/contrib/utils/wxrc/wxrc.cpp new file mode 100644 index 0000000000..64a81ea2c2 --- /dev/null +++ b/contrib/utils/wxrc/wxrc.cpp @@ -0,0 +1,292 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wxrc.cpp +// Purpose: XML resource compiler +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation + #pragma interface +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/cmdline.h" +#include "wx/xml/xml.h" +#include "wx/ffile.h" + + +#if wxUSE_GUI +#error "You must compile the resource compiler with wxBase!" +#endif + + +class XmlResApp : public wxApp +{ +public: + virtual int OnRun(); + +private: + + void ParseParams(const wxCmdLineParser& cmdline); + void CompileRes(); + wxArrayString PrepareTempFiles(); + void DeleteTempFiles(const wxArrayString& flist); + void MakePackageZIP(const wxArrayString& flist); + void MakePackageCPP(const wxArrayString& flist); + + bool flagVerbose, flagCPP, flagCompress; + wxString parOutput, parFuncname, parOutputPath; + wxArrayString parFiles; + int retCode; +}; + +IMPLEMENT_APP(XmlResApp) + +int XmlResApp::OnRun() +{ + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" }, + { wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" }, + { wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" }, + { wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" }, + { wxCMD_LINE_OPTION, "o", "output", "output file [resource.rsc/cpp]" }, + { wxCMD_LINE_OPTION, "h", "handlers", "output list of neccessary handlers to this file" }, + + { wxCMD_LINE_PARAM, NULL, NULL, "input file", + wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE }, + + { wxCMD_LINE_NONE } + }; + + wxCmdLineParser parser(cmdLineDesc, argc, argv); + + switch (parser.Parse()) + { + case -1: + return 0; + break; + + case 0: + retCode = 0; + ParseParams(parser); + CompileRes(); + return retCode; + break; + + default: + return 1; + break; + } +} + + + + +void XmlResApp::ParseParams(const wxCmdLineParser& cmdline) +{ + flagVerbose = cmdline.Found("v"); + flagCPP = cmdline.Found("c"); + flagCompress = flagCPP && !cmdline.Found("u"); + + if (!cmdline.Found("o", &parOutput)) + parOutput = flagCPP ? "resource.cpp" : "resource.rsc"; + parOutputPath = wxPathOnly(parOutput); + if (!parOutputPath) parOutputPath = "."; + + if (!cmdline.Found("n", &parFuncname)) + parFuncname = "InitXmlResource"; + + for (size_t i = 0; i < cmdline.GetParamCount(); i++) + parFiles.Add(cmdline.GetParam(i)); +} + + + + +void XmlResApp::CompileRes() +{ + wxArrayString files = PrepareTempFiles(); + + wxRemoveFile(parOutput); + + printf("TODO: include bitmaps, list of handlers\n"); + + if (!retCode) + { + if (flagCPP) + MakePackageCPP(files); + else + MakePackageZIP(files); + } + + DeleteTempFiles(files); +} + + + +wxArrayString XmlResApp::PrepareTempFiles() +{ + wxArrayString flist; + + for (size_t i = 0; i < parFiles.Count(); i++) + { + if (flagVerbose) + wxPrintf("processing " + parFiles[i] + "...\n"); + + wxXmlDocument doc; + + if (!doc.Load(parFiles[i])) + { + wxLogError("Error parsing file " + parFiles[i]); + retCode = 1; + continue; + } + + wxString name, ext; + wxSplitPath(parFiles[i], NULL, &name, &ext); + + doc.Save(parOutputPath + "/" + name + ".xmb", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN); + flist.Add(name + ".xmb"); + } + + return flist; +} + + + +void XmlResApp::DeleteTempFiles(const wxArrayString& flist) +{ + for (size_t i = 0; i < flist.Count(); i++) + wxRemoveFile(parOutputPath + "/" + flist[i]); +} + + + +void XmlResApp::MakePackageZIP(const wxArrayString& flist) +{ + wxString files; + + for (size_t i = 0; i < flist.Count(); i++) + files += flist[i] + " "; + files.RemoveLast(); + + if (flagVerbose) + wxPrintf("compressing " + parOutput + "...\n"); + + if (wxExecute("zip -9 -j " + wxString(flagVerbose ? "" : "-q ") + + parOutput + " " + files, TRUE) == -1) + { + wxLogError("Unable to execute zip program. Make sure it is in the path."); + wxLogError("You can download it at http://www.cdrom.com/pub/infozip/"); + retCode = 1; + return; + } +} + + + + +static wxString FileToCppArray(wxString filename, int num) +{ + wxString output; + wxString snum; + wxString tmp; + wxFFile file(filename, "rb"); + size_t lng = file.Length(); + + snum.Printf("%i", num); + output.Printf("static size_t xml_res_size_" + snum + " = %i;\n", lng); + output += "static unsigned char xml_res_file_" + snum + "[] = {"; + + unsigned char *buffer = new unsigned char[lng]; + file.Read(buffer, lng); + + for (size_t i = 0; i < lng; i++) + { + if (i % 16 == 0) output += "\n"; + tmp.Printf("0x%02X", buffer[i]); + output += tmp; + if (i != lng-1) output += ","; + } + + delete[] buffer; + + output += "\n};\n\n"; + + return output; +} + + +void XmlResApp::MakePackageCPP(const wxArrayString& flist) +{ + wxFFile file(parOutput, "wt"); + size_t i; + + if (flagVerbose) + wxPrintf("creating C++ source file " + parOutput + "...\n"); + + file.Write("\ +#include \"wx/wxprec.h\"\n\ +\n\ +#ifdef __BORLANDC__\n\ + #pragma hdrstop\n\ +#endif\n\ +\n\ +#ifndef WX_PRECOMP\n\ + #include \"wx/wx.h\"\n\ +#endif\n\ +\ +#include \"wx/filesys.h\"\n\ +#include \"wx/fs_mem.h\"\n\ +#include \"wx/xml/xmlres.h\"\n\ +#include \"wx/xml/xh_all.h\"\n\ +\n"); + + for (i = 0; i < flist.Count(); i++) + file.Write(FileToCppArray(flist[i], i)); + + file.Write("\ +void " + parFuncname + "()\n\ +{\n\ +\n\ + // Check for memory FS. If not present, load the handler:\n\ + {\n\ + wxMemoryFSHandler::AddFile(\"xml_resource/dummy_file\", \"dummy one\");\n\ + wxFileSystem fsys;\n\ + wxFSFile *f = fsys.OpenFile(\"xml_resource/dummy_file\");\n\ + wxMemoryFSHandler::RemoveFile(\"xml_resource/dummy_file\");\n\ + if (f) delete f;\n\ + else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n\ + }\n\ +\n"); + + for (i = 0; i < flist.Count(); i++) + { + wxString s; + s.Printf(" wxMemoryFSHandler::AddFile(\"xml_resource/" + flist[i] + + "\", xml_res_file_%i, xml_res_size_%i);\n" + " wxTheXmlResource->Read(\"xml_resource/" + flist[i] + + "\", wxXML_BINARY);\n", i, i); + file.Write(s); + } + + file.Write("\n}\n"); + +} diff --git a/contrib/utils/wxrcedit/Makefile.in b/contrib/utils/wxrcedit/Makefile.in new file mode 100644 index 0000000000..94843b0b36 --- /dev/null +++ b/contrib/utils/wxrcedit/Makefile.in @@ -0,0 +1,23 @@ +# $Id$ + +top_srcdir = @top_srcdir@/.. +top_builddir = ../../.. +program_dir = contrib/utils/wxrcedit + +PROGRAM=wxrcedit + +OBJECTS=edapp.o editor.o nodehnd.o prophnd.o xmlhelpr.o + +DATADIRS = df +DATAFILES = df/boxsizer.df df/break.df df/button.df df/checkbox.df \ + df/control.df df/dialog.df df/gauge.df df/htmlwindow.df \ + df/menu.df df/menu_item.df df/menubar.df df/menuitem.df \ + df/panel.df df/panel_item.df df/panelbase.df df/radiobutton.df \ + df/separator.df df/sizer_item.df df/sizeritem.df df/slider.df \ + df/spacer.df df/staticbitmap.df df/staticboxsizer.df \ + df/statictext.df df/textctrl.df df/toolbar_item.df df/window.df + +APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@ +APPEXTRADEFS=-I$(top_srcdir)/contrib/include + +include $(top_builddir)/src/makeprog.env diff --git a/contrib/utils/wxrcedit/bitmaps/close.xpm b/contrib/utils/wxrcedit/bitmaps/close.xpm new file mode 100644 index 0000000000..518829b0c6 --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/close.xpm @@ -0,0 +1,33 @@ +/* XPM */ +static char *close_xpm[] = { +/* width height num_colors chars_per_pixel */ +" 24 24 2 1", +/* colors */ +". c #000000", +"# c none", +/* pixels */ +"########################", +"########################", +"########################", +"########################", +"########################", +"########################", +"#######.####..##########", +"#######..##....#########", +"########..#...##########", +"########.....###########", +"#########...############", +"#########....###########", +"########......##########", +"########..#....#########", +"#######..###....########", +"#######.#####..#########", +"########################", +"########################", +"########################", +"########################", +"########################", +"########################", +"########################", +"########################" +}; diff --git a/contrib/utils/wxrcedit/bitmaps/control.xpm b/contrib/utils/wxrcedit/bitmaps/control.xpm new file mode 100644 index 0000000000..e2bb7b1696 --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/control.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * control_xpm[] = { +"16 14 4 1", +" c None", +". c #008000", +"+ c #FFFFFF", +"@ c #7F7F7F", +" ", +" ", +" ", +" ", +" ... ", +" .++.. ", +" .++..@ ", +" .....@ ", +" ...@@ ", +" @@@ ", +" ", +" ", +" ", +" "}; diff --git a/contrib/utils/wxrcedit/bitmaps/hsizer.xpm b/contrib/utils/wxrcedit/bitmaps/hsizer.xpm new file mode 100644 index 0000000000..38ec705778 --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/hsizer.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * hsizer_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" ", +" ", +" ", +" . . ", +" .. .. ", +" ..+......+.. ", +" ..++++++++++.. ", +"..++++++++++++..", +" ..++++++++++.. ", +" ..+......+.. ", +" .. .. ", +" . . ", +" ", +" ", +" ", +" "}; diff --git a/contrib/utils/wxrcedit/bitmaps/open.xpm b/contrib/utils/wxrcedit/bitmaps/open.xpm new file mode 100644 index 0000000000..c47593fffc --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/open.xpm @@ -0,0 +1,229 @@ +/* XPM */ +static char * open_xpm[] = { +"24 24 202 2", +" c None", +". c #020202", +"+ c #5A5226", +"@ c #9A8A46", +"# c #C6AE52", +"$ c #EEDE7E", +"% c #FEB26A", +"& c #06060A", +"* c #B6AE7A", +"= c #CEA272", +"- c #E2D27E", +"; c #FEDEA2", +"> c #7A6E4E", +", c #BEAA56", +"' c #1E1E22", +") c #826A4E", +"! c #FEDEA6", +"~ c #F6F6F2", +"{ c #9A7E5A", +"] c #C2BE86", +"^ c #3E3A2A", +"/ c #7E5E3A", +"( c #EADA82", +"_ c #FEDEAE", +": c #FEBE7A", +"< c #BABAB6", +"[ c #7E7E7E", +"} c #625A3A", +"| c #E2DA9A", +"1 c #322212", +"2 c #D2BA5A", +"3 c #9E9E9E", +"4 c #9E7A52", +"5 c #EAEAE6", +"6 c #969262", +"7 c #AEAEAA", +"8 c #826E52", +"9 c #FED69A", +"0 c #DEBE8A", +"a c #DEB67E", +"b c #9E8A66", +"c c #6E5A42", +"d c #C2C2BE", +"e c #32322E", +"f c #EEA256", +"g c #664226", +"h c #BEA67A", +"i c #8A8A8A", +"j c #969692", +"k c #C68246", +"l c #CECECA", +"m c #7A7256", +"n c #DEDEDE", +"o c #362E22", +"p c #6E563A", +"q c #A66A3A", +"r c #625E4A", +"s c #DADAD6", +"t c #4A4A4A", +"u c #FEC282", +"v c #D2BE6A", +"w c #464646", +"x c #363636", +"y c #A6A6A2", +"z c #6E6E72", +"A c #666666", +"B c #261A12", +"C c #B6B6B2", +"D c #FECE92", +"E c #4E3A2A", +"F c #DECA6A", +"G c #DEAE76", +"H c #2A2A26", +"I c #CACAC6", +"J c #3E2A1A", +"K c #5E4A3A", +"L c #F2F2EE", +"M c #929292", +"N c #767676", +"O c #5A5242", +"P c #EEE692", +"Q c #D2D2CE", +"R c #766A3E", +"S c #3E2E1A", +"T c #E6E6E6", +"U c #FAFAFA", +"V c #121212", +"W c #5A5A56", +"X c #EEE69A", +"Y c #968A4E", +"Z c #3E321E", +"` c #867642", +" . c #FEC686", +".. c #423626", +"+. c #3E3E3E", +"@. c #4E4E52", +"#. c #A69246", +"$. c #4A3E36", +"%. c #6E5E3A", +"&. c #E2E2E2", +"*. c #5E5E5A", +"=. c #565246", +"-. c #BEBEBA", +";. c #DAC666", +">. c #4E422A", +",. c #E2D272", +"'. c #8E8E8A", +"). c #D6D6D2", +"!. c #AAAAA6", +"~. c #C6C6C6", +"{. c #FEBA76", +"]. c #868686", +"^. c #969266", +"/. c #F6AA62", +"(. c #9A9A96", +"_. c #5A523A", +":. c #5E5236", +"<. c #525252", +"[. c #A2A29E", +"}. c #7A7A76", +"|. c #FEFEFE", +"1. c #7E6A4E", +"2. c #FEDA9E", +"3. c #EADE8E", +"4. c #EEEEEA", +"5. c #42321E", +"6. c #7E7672", +"7. c #FED296", +"8. c #2E2E2E", +"9. c #F2EA96", +"0. c #826E56", +"a. c #7E6A42", +"b. c #FECA8A", +"c. c #3E3226", +"d. c #5E5E5E", +"e. c #82764E", +"f. c #4E4236", +"g. c #626262", +"h. c #020206", +"i. c #423A2E", +"j. c #422E1A", +"k. c #CEA672", +"l. c #7E6242", +"m. c #727272", +"n. c #6A6A6E", +"o. c #CACACA", +"p. c #F2F2F6", +"q. c #C6C286", +"r. c #828286", +"s. c #F2EAA2", +"t. c #5A564A", +"u. c #565656", +"v. c #AEAEAE", +"w. c #EEE696", +"x. c #8E8E92", +"y. c #7A7A7E", +"z. c #FEDAA6", +"A. c #423226", +"B. c #B6B6B6", +"C. c #AAAAAA", +"D. c #BABABA", +"E. c #DADADA", +"F. c #422A16", +"G. c #F2E68E", +"H. c #16120E", +"I. c #DEC666", +"J. c #EAEAEA", +"K. c #969696", +"L. c #CECECE", +"M. c #BEBEBE", +"N. c #F6F6F6", +"O. c #F2F2F2", +"P. c #C2C2C2", +"Q. c #42362A", +"R. c #FECA8E", +"S. c #8A8A8E", +"T. c #D2D2D2", +"U. c #3E3222", +"V. c #8E8E8E", +"W. c #D6D6D6", +"X. c #A2A2A2", +"Y. c #423222", +"Z. c #422E1E", +"`. c #FED69E", +" + c #323232", +".+ c #362E26", +"++ c #46464A", +"@+ c #FECE96", +"#+ c #9A9A9A", +"$+ c #7A7A7A", +"%+ c #2E2E32", +"&+ c #5E5E62", +"*+ c #CACACE", +"=+ c #9A8A4A", +"-+ c #DEBE8E", +";+ c #DECA6E", +">+ c #2A2A2A", +",+ c #5A5A5A", +"'+ c #FEDAA2", +")+ c #EEEEEE", +"!+ c #FED29A", +"~+ c #727276", +" .+i.c. ", +" 0._ -+8 o ", +" 1.9 c .k.{ h. ", +" H / S ] ^ 4 k.b.a.>. c.Q.o ", +">+x.A . g 1 - w.^.m l.G a 1.0 9 h ) ", +"x n T 3 6.8.+ F G.| * :.p b.D ! ; ; h c ", +" +*+|.L 5 E.g.} Y ,.P X ] ^ 4 = @+2.! b ", +" N N.|.N.p.T.C.+.#.;.$ 9.9.6 > l.G `.z.Q. ", +" n.O.|.|.N.J.W.K.=.R # , e.v 3.* :. .`.i. ", +" W &.U O.O.J.&.T.~.x.u.> $+@.` ;+w.Y.7.Q. ", +" . v.U L )+5 &.E.T.*+P.S.< !.W =+( U.@+i. ", +" . X.O.J.T &.n W.T.L.~.P.D.v.y.} ;.S D Q. ", +" $+4.5 &.E.s T.o.~.P.D.B.7 r._.2 S b.Q. ", +" . n &.n s Q l I ~.-.C C 7 S.O =+U. ... ", +" . T.E.W.T.l ~.d -.< C v.y K.&+%.Z b.Q. ", +" . M v.~.l ~.d D.C B.C.y y M &+%.S u .. ", +" V t ,+B.-.M.B.C v.C.y X.M ~+O S {.A. ", +" +N y v.C.!.X.X.#+M i ++S {.Y. ", +" ' z ].3 #+3 (.j i ++J % Y. ", +" . %+<.M M j j '.d.E /.Z. ", +" >+,+].i '.}.K f j.h.h. ", +" . *.m.}.$.k J . . h.", +" & %+w $.q 1 h.. ", +" H.B "}; diff --git a/contrib/utils/wxrcedit/bitmaps/panel.xpm b/contrib/utils/wxrcedit/bitmaps/panel.xpm new file mode 100644 index 0000000000..3ef2381178 --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/panel.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char * panel_xpm[] = { +"16 16 7 1", +" c None", +". c #000000", +"+ c #808080", +"@ c #0000FF", +"# c #A0A0A4", +"$ c #FFFFFF", +"% c #595959", +" ", +"................", +".++++++++++++++.", +".+@@@@@@@@@@@@#.", +".++++++++++++++.", +".+$$$$$$$$$$$$+.", +".%$$$$$$$$$$$$+.", +".+$$$$$$$$$$$$+.", +".+$$$$$$$$$$$$+.", +".+$$$$$$$$$$$$%.", +".+$$$$$$$$$$$$+.", +".+$$$$$$$$$$$$+.", +".%$$$$$$$$$$$$+.", +".++++++++++++++.", +"................", +" "}; diff --git a/contrib/utils/wxrcedit/bitmaps/preview.xpm b/contrib/utils/wxrcedit/bitmaps/preview.xpm new file mode 100644 index 0000000000..6858ca3122 --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/preview.xpm @@ -0,0 +1,267 @@ +/* XPM */ +static char * preview_xpm[] = { +"24 24 240 2", +" c None", +". c #060606", +"+ c #1E767E", +"@ c #2AA2A2", +"# c #92C6E6", +"$ c #0E0E12", +"% c #AADAF2", +"& c #4A8282", +"* c #5A9AEA", +"= c #0E3A3A", +"- c #52667A", +"; c #9A9A96", +"> c #D6DEE6", +", c #727272", +"' c #DEE6E6", +") c #2A3E42", +"! c #0A36BE", +"~ c #9ECAEA", +"{ c #7EB2E2", +"] c #565652", +"^ c #8A8A86", +"/ c #96B2BE", +"( c #A2CAE2", +"_ c #DEEEF6", +": c #2A36BA", +"< c #06262A", +"[ c #4A4A4A", +"} c #E6EEF2", +"| c #0E3ABA", +"1 c #2276C6", +"2 c #B2C6DE", +"3 c #6E72BA", +"4 c #566EBE", +"5 c #A6A6B2", +"6 c #9EBEDE", +"7 c #2A2A2A", +"8 c #3A72BE", +"9 c #F6F6F2", +"0 c #6E8EBE", +"a c #727E86", +"b c #0A8AFA", +"c c #3E92D6", +"d c #C6C6C2", +"e c #BADAEE", +"f c #D2D6DA", +"g c #6E76B2", +"h c #464642", +"i c #469AF2", +"j c #86A2C2", +"k c #B6B6B2", +"l c #52AADE", +"m c #BED2EA", +"n c #1252BE", +"o c #222E2E", +"p c #9696B2", +"q c #6EAADA", +"r c #126ECA", +"s c #F2FAFA", +"t c #AEBED6", +"u c #92928E", +"v c #1E1E1E", +"w c #3E7EF6", +"x c #1686F6", +"y c #3E3E3E", +"z c #C6DAE6", +"A c #4A86D2", +"B c #3AAAF6", +"C c #0A76F6", +"D c #62625E", +"E c #B2C2D6", +"F c #C2CEEA", +"G c #7E7E7E", +"H c #62BED6", +"I c #828AAE", +"J c #2E2E2E", +"K c #CAD2DE", +"L c #D2E6F2", +"M c #4E4E4E", +"N c #CECECA", +"O c #5E86C2", +"P c #6A6A6A", +"Q c #F2EEEA", +"R c #5E5E5A", +"S c #767676", +"T c #AEAEAA", +"U c #363636", +"V c #868686", +"W c #A2A2A2", +"X c #E2E2DA", +"Y c #4A6EBE", +"Z c #92AEF6", +"` c #E6E6E2", +" . c #226EFE", +".. c #F6FAFA", +"+. c #8A96AE", +"@. c #96A2BE", +"#. c #3A3A36", +"$. c #BEBEBE", +"%. c #8AD2EE", +"&. c #8AB2CE", +"*. c #3292F6", +"=. c #225ABE", +"-. c #76B6DE", +";. c #FAFEFE", +">. c #222222", +",. c #96B2DA", +"'. c #0296F6", +"). c #CACAC6", +"!. c #BAE6FA", +"~. c #9E9EAA", +"{. c #5A5A5A", +"]. c #B2B2BE", +"^. c #8E8E8E", +"/. c #7A8286", +"(. c #BABAB6", +"_. c #D2D2CE", +":. c #9E9E9A", +"<. c #DADAD6", +"[. c #D2DAEE", +"}. c #3276CA", +"|. c #AEC6EE", +"1. c #96D2EE", +"2. c #52524E", +"3. c #7A7A76", +"4. c #42423E", +"5. c #DADEDE", +"6. c #323232", +"7. c #9A9696", +"8. c #0A0A0E", +"9. c #161616", +"0. c #9AD2EE", +"a. c #B2CED6", +"b. c #3EB2F6", +"c. c #666662", +"d. c #82827E", +"e. c #B2B2AE", +"f. c #B6B6C2", +"g. c #524A4A", +"h. c #BEC2C2", +"i. c #7292CE", +"j. c #92B2DE", +"k. c #969696", +"l. c #EEEEEA", +"m. c #FAF2EE", +"n. c #EAEAEA", +"o. c #262626", +"p. c #F2F2F6", +"q. c #5E6EBA", +"r. c #76AEE6", +"s. c #FEFEFE", +"t. c #3A7AD2", +"u. c #3A3E3A", +"v. c #7A7A7A", +"w. c #86A2CE", +"x. c #76B2EA", +"y. c #DEF2FA", +"z. c #6E6E6E", +"A. c #56565A", +"B. c #E2E2DE", +"C. c #CACACE", +"D. c #464646", +"E. c #3A3A3A", +"F. c #96CAEA", +"G. c #DEEAEE", +"H. c #E6F2F6", +"I. c #AAAAAA", +"J. c #BABABA", +"K. c #828286", +"L. c #B2B2B6", +"M. c #CAC6C6", +"N. c #D6D2CE", +"O. c #464242", +"P. c #C2C2C2", +"Q. c #121212", +"R. c #AADEEE", +"S. c #9ECEEE", +"T. c #6A7AAA", +"U. c #D2EAFA", +"V. c #CEDEEA", +"W. c #DEDEDA", +"X. c #E6E2E2", +"Y. c #36363A", +"Z. c #46464A", +"`. c #3A3A3E", +" + c #FAFAF6", +".+ c #D6D6D2", +"++ c #EAE6E6", +"@+ c #DAE6EE", +"#+ c #C6C6CA", +"$+ c #5E5E62", +"%+ c #9E9EA2", +"&+ c #FAFAFE", +"*+ c #BAB6B6", +"=+ c #DEDADA", +"-+ c #9A9A9A", +";+ c #8A8A8A", +">+ c #2A2A2E", +",+ c #F6F6F6", +"'+ c #CACACA", +")+ c #565656", +"!+ c #828282", +"~+ c #7A7A7E", +"{+ c #E2E2E2", +"]+ c #DEDEDE", +"^+ c #0E36BE", +"/+ c #EAEEEE", +"(+ c #F6F2F6", +"_+ c #727276", +":+ c #525252", +"<+ c #D2D2D2", +"[+ c #424242", +"}+ c #C2C2C6", +"|+ c #C6C6C6", +"1+ c #86868A", +"2+ c #929292", +"3+ c #626262", +"4+ c #CECECE", +"5+ c #4A4A4E", +"6+ c #7E7E82", +"7+ c #A2A2A6", +"8+ c #8E8E92", +"9+ c #BABABE", +"0+ c #3E3E42", +"a+ c #4E4E52", +"b+ c #5E5E5E", +"c+ c #AEAEAE", +"d+ c #E6E6E6", +"e+ c #9E9E9E", +"f+ c #666666", +"g+ c #B2B2B2", +"h+ c #FAFAFA", +"i+ c #D6D6D6", +"j+ c #06060A", +"k+ c #B6B6B6", +"l+ c #1E1E22", +"m+ c #BEBEC2", +"n+ c #225AC2", +"o+ c #DADADA", +"p+ c #96CAEE", +"q+ c #AAAAAE", +" 3.D S v., P c.R )+:+[ h Z.Z.) 7 ", +"v.<+!+]+s.s.s.s.s.s.s.s.s.;.U.1.a ", +"3+!+c.]+s.s.s.s.s.s.s.s. +!.B i - 8.8. ", +"v.o+]+n.s.s.s.s.p.W.<.i+X F.x .T.2+; 8. ", +"3.s.s.s.s.s.9 ).^ )+2.)+M a O Z ~.;+2+8. ", +"P s.s.s.s.s.W [+3.'+#+4+J.R J I.T ^ 2+8. ", +"b+ +s.s.9 W D <+ +H.% [.n./+h.M {.G ^ 8. ", +"{.s.s.s.(.)+<+s.s.G.# 2 a.-.m c+6.f+^ 8. ", +"M s.s.p.G ^. +s.s.,+> > &.r i..+$+)+V 8. ", +"h s.s.).[+<+s.s.s.y.~ j.h.@.]._.; U V 8. ", +"h s. +).4.<+s y._ e r.}.@.j 0 ).:.7 V 8. ", +"D.h+ +P.`._._ F.S.{ A n+4 8 ! f.k.7 G 8. ", +"D.9 9 4+D.).U.l c 8 =.! g I 3 (.V U v.8. ", +"D.p.p.l.G V @+q 1 n | : 5 e.k c+2.[ 3.8. ", +"D.9 p.R./ [ $.> w.Y q.p c+L.$._+Q.g.S 8. ", +"O.m.%.'.*.+.:+e+4+_.P.m+$.c+, 7 @ = d.8. ", +"[+Q # C w f -+U M v.8+^.P 5+6.+ & :+h v ", +"[+++' |.F {+=+J.^ D.o.J )+!+7.< 7 {.:+$ ", +"[+` {+{+B.H f K <+P.(.(.g+k+h.N , 6.{.:+ ", +"4.{+B.5.~ x.6 t _.C.'+'+#+'+P.}+k.:+E.b+:+ ", +"0+{+{+z b.b * ,.E '+'+'+|+}+P.P.;+P b+7 {.)+ ", +"8.j+. >.l+6.E.y y y E.U 6.6.J >+7 4.V >.o.{.:+ ", +" . I.e+e+:.-+7.; k.u u ;+V !+G v.!+8. 7 {.v ", +" 8.E.E.E.Y.E.E.Y.#.Y.Y.E.U U Y.U J 8. Q. "}; diff --git a/contrib/utils/wxrcedit/bitmaps/save.xpm b/contrib/utils/wxrcedit/bitmaps/save.xpm new file mode 100644 index 0000000000..d00895a81e --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/save.xpm @@ -0,0 +1,222 @@ +/* XPM */ +static char * save_xpm[] = { +"24 24 195 2", +" c None", +". c #2B2B3B", +"+ c #3F3F55", +"@ c #9191DF", +"# c #51516D", +"$ c #A4A4DF", +"% c #B2B2FF", +"& c #47479C", +"* c #525252", +"= c #28283B", +"- c #9C9CEF", +"; c #5252B0", +"> c #F2F2F2", +", c #E7E7E7", +"' c #585858", +") c #373755", +"! c #9292DF", +"~ c #9494EF", +"{ c #6969BE", +"] c #DDDDED", +"^ c #DFDFDF", +"/ c #EEEEEE", +"( c #24243B", +"_ c #8989DF", +": c #9E9EFF", +"< c #4E4EAF", +"[ c #C6C6D6", +"} c #FAFAFA", +"| c #D6D6D6", +"1 c #21213B", +"2 c #9292FF", +"3 c #8181EF", +"4 c #4C4CB0", +"5 c #F3F3F3", +"6 c #FFFFFF", +"7 c #DCDCDC", +"8 c #F0F0F0", +"9 c #FDFDFD", +"0 c #2C2C55", +"a c #7777DF", +"b c #8989FF", +"c c #4444C0", +"d c #BFBFDF", +"e c #EFEFEF", +"f c #FEFEFE", +"g c #E6E6E6", +"h c #1D1D3B", +"i c #6E6EDF", +"j c #7F7FFF", +"k c #6E6EEF", +"l c #4747B0", +"m c #FBFBFB", +"n c #D7D7D7", +"o c #19193B", +"p c #7373FF", +"q c #5F5FE7", +"r c #4444B0", +"s c #DFDFEF", +"t c #DBDBDB", +"u c #34344C", +"v c #222255", +"w c #5B5BDF", +"x c #6969FF", +"y c #5050DF", +"z c #7E7ED7", +"A c #5555A7", +"B c #5B5BEF", +"C c #5959C0", +"D c #ECECEC", +"E c #4646BF", +"F c #2B2B6D", +"G c #16163B", +"H c #5353DF", +"I c #6060FF", +"J c #4E4EE7", +"K c #5454A8", +"L c #B3B3BB", +"M c #9494A9", +"N c #5353EF", +"O c #4141B0", +"P c #E0E0E0", +"Q c #CFCFE7", +"R c #4343C0", +"S c #5959F7", +"T c #1382C7", +"U c #000060", +"V c #101C3C", +"W c #4A63F8", +"X c #4545E7", +"Y c #54549C", +"Z c #A8A8B7", +"` c #3232A1", +" . c #4949CF", +".. c #9798B2", +"+. c #5454FF", +"@. c #3E3EB0", +"#. c #2424B8", +"$. c #4A63F7", +"%. c #108CD4", +"&. c #0000C5", +"*. c #000052", +"=. c #001934", +"-. c #1445C8", +";. c #5151A7", +">. c #3F3FAD", +",. c #3636E7", +"'. c #656BD2", +"). c #9FA1BC", +"!. c #BFBFBF", +"~. c #3939DF", +"{. c #4A4AFF", +"]. c #4040EF", +"^. c #5151C0", +"/. c #3A3ABF", +"(. c #415AF8", +"_. c #1477D9", +":. c #0019D0", +"<. c #00005C", +"[. c #B3B3D3", +"}. c #A5A8BA", +"|. c #474ECB", +"1. c #5A62D2", +"2. c #B1B4BD", +"3. c #5050A8", +"4. c #3434E7", +"5. c #4040FF", +"6. c #3737EF", +"7. c #3B3BB0", +"8. c #8F8FD7", +"9. c #3737C0", +"0. c #3C3CF7", +"a. c #0D89D4", +"b. c #000056", +"c. c #666666", +"d. c #E1E1E1", +"e. c #A5AABE", +"f. c #A7A9B3", +"g. c #B3B3B3", +"h. c #A8A8B0", +"i. c #4444A4", +"j. c #0000A0", +"k. c #2B2BE7", +"l. c #3434FF", +"m. c #2E47F7", +"n. c #0A86D4", +"o. c #757575", +"p. c #D5D5D5", +"q. c #A8A8A8", +"r. c #4141A0", +"s. c #0303DF", +"t. c #0202FF", +"u. c #0606BF", +"v. c #2121DF", +"w. c #2B2BFF", +"x. c #263FF8", +"y. c #0C6FD9", +"z. c #DEDEDE", +"A. c #9C9C9C", +"B. c #46468E", +"C. c #0808E7", +"D. c #0707FF", +"E. c #0505FF", +"F. c #0202DF", +"G. c #1111C0", +"H. c #2121FF", +"I. c #0783D4", +"J. c #CBCBD2", +"K. c #393996", +"L. c #0D0DE7", +"M. c #0D0DFF", +"N. c #0C0CFF", +"O. c #0808B8", +"P. c #132CF7", +"Q. c #0480D4", +"R. c #404060", +"S. c #0536B1", +"T. c #112AF8", +"U. c #1111FF", +"V. c #0C0CDF", +"W. c #0404BF", +"X. c #0A23F8", +"Y. c #0467D9", +"Z. c #001988", +"`. c #1111E7", +" + c #0202C0", +".+ c #0101F7", +"++ c #017DD4", +"@+ c #00009D", +"#+ c #000C9C", +"$+ c #0031F0", +"%+ c #007CD4", +"&+ c #001B6A", +"*+ c #0068C2", +"=+ c #000230", +"-+ c #000032", +" . ", +" + @ # ", +" . $ % & * ", +" = % - ; > , ' ", +" ) ! ~ { ] ^ / , * ", +" ( _ : < [ > } ^ > | * ", +" 1 2 3 4 5 6 7 8 9 7 > , ' ", +" 0 a b c d ^ e 6 ^ / f ^ e g * ", +" h i j j k l m ^ 5 m ^ e } ^ 5 n * ", +" o p p p q p p r s 7 5 6 7 > 9 t 5 , u ", +" v w x y z A y x B C s ^ e 6 ^ D f , d E F ", +"G H I J K L M K J I N O m P 5 m ^ 5 Q R S T U ", +"V W X Y Z ` ...Y X +.+.@.s 7 5 6 Q #.$.%.&.*. ", +"=.-.;.Z >.,.'.).!.;.~.{.].^.s , d /.(._.:.*. ", +" <.[.}.|.1.2.!.!.L 3.4.5.6.7.8.9.0.a.:.b. ", +" c.d.e.f.g.g.g.h.i.j.k.l.l.l.m.n.&.*. ", +" o.p.g.q.q.q.r.s.t.u.v.w.x.y.:.*. ", +" o.z.A.A.B.C.D.E.F.G.H.I.:.b. ", +" c.J.K.L.M.N.C.O.P.Q.&.*. ", +" R.S.T.U.V.W.X.Y.:.*. ", +" Z.Q.`. +.+++:.b. ", +" @+#+$+%+&.*. ", +" &+*+:.*. ", +" =+-+ "}; diff --git a/contrib/utils/wxrcedit/bitmaps/unused.xpm b/contrib/utils/wxrcedit/bitmaps/unused.xpm new file mode 100644 index 0000000000..41c11427af --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/unused.xpm @@ -0,0 +1,20 @@ +/* XPM */ +static char * unused_xpm[] = { +"16 16 1 1", +" c None", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/contrib/utils/wxrcedit/bitmaps/used.xpm b/contrib/utils/wxrcedit/bitmaps/used.xpm new file mode 100644 index 0000000000..20f6cd283d --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/used.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * used_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" . ", +" ... ", +" .... ", +" .... ", +" .. .... ", +" ....... ", +" ..... ", +" ... ", +" . ", +" ", +" ", +" "}; diff --git a/contrib/utils/wxrcedit/bitmaps/vsizer.xpm b/contrib/utils/wxrcedit/bitmaps/vsizer.xpm new file mode 100644 index 0000000000..c1512078a4 --- /dev/null +++ b/contrib/utils/wxrcedit/bitmaps/vsizer.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * vsizer_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" . ", +" ... ", +" ..+.. ", +" ..+++.. ", +" ..+++++.. ", +" .+++. ", +" .+++. ", +" .+++. ", +" .+++. ", +" .+++. ", +" .+++. ", +" ..+++++.. ", +" ..+++.. ", +" ..+.. ", +" ... ", +" . "}; diff --git a/contrib/utils/wxrcedit/df/boxsizer.df b/contrib/utils/wxrcedit/df/boxsizer.df new file mode 100644 index 0000000000..123c93efa3 --- /dev/null +++ b/contrib/utils/wxrcedit/df/boxsizer.df @@ -0,0 +1,6 @@ +node boxsizer +type sizer +icon 2 +childtype sizer_item +derived from panel_item +var orient of flags wxHORIZONTAL,wxVERTICAL diff --git a/contrib/utils/wxrcedit/df/break.df b/contrib/utils/wxrcedit/df/break.df new file mode 100644 index 0000000000..7c39e5bfdf --- /dev/null +++ b/contrib/utils/wxrcedit/df/break.df @@ -0,0 +1,3 @@ +node break +type normal +derived from menu_item diff --git a/contrib/utils/wxrcedit/df/button.df b/contrib/utils/wxrcedit/df/button.df new file mode 100644 index 0000000000..5322c96991 --- /dev/null +++ b/contrib/utils/wxrcedit/df/button.df @@ -0,0 +1,4 @@ +node button +var label of text +var default of bool +derived from control \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/checkbox.df b/contrib/utils/wxrcedit/df/checkbox.df new file mode 100644 index 0000000000..c11d2cb559 --- /dev/null +++ b/contrib/utils/wxrcedit/df/checkbox.df @@ -0,0 +1,4 @@ +node checkbox +var label of text +var checked of bool +derived from control \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/control.df b/contrib/utils/wxrcedit/df/control.df new file mode 100644 index 0000000000..ea628bd5db --- /dev/null +++ b/contrib/utils/wxrcedit/df/control.df @@ -0,0 +1,6 @@ +node control +abstract +icon 0 +derived from window +derived from panel_item +derived from toolbar_item diff --git a/contrib/utils/wxrcedit/df/dialog.df b/contrib/utils/wxrcedit/df/dialog.df new file mode 100644 index 0000000000..ee5ae8be99 --- /dev/null +++ b/contrib/utils/wxrcedit/df/dialog.df @@ -0,0 +1,4 @@ +node dialog +var title of text +var style of flags wxSTAY_ON_TOP,wxCAPTION,wxDEFAULT_DIALOG_STYLE,wxTHICK_FRAME,wxSYSTEM_MENU,wxRESIZE_BORDER,wxRESIZE_BOX,wxDIALOG_MODAL,wxDIALOG_MODELESS +derived from panelbase diff --git a/contrib/utils/wxrcedit/df/gauge.df b/contrib/utils/wxrcedit/df/gauge.df new file mode 100644 index 0000000000..8ebeee451f --- /dev/null +++ b/contrib/utils/wxrcedit/df/gauge.df @@ -0,0 +1,7 @@ +node gauge +var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH +var range of integer +var value of integer +var shadow of integer +var bezel of integer +derived from control diff --git a/contrib/utils/wxrcedit/df/htmlwindow.df b/contrib/utils/wxrcedit/df/htmlwindow.df new file mode 100644 index 0000000000..73dfbe6aaa --- /dev/null +++ b/contrib/utils/wxrcedit/df/htmlwindow.df @@ -0,0 +1,6 @@ +node htmlwindow +var url of text +var htmlcode of text +var borders of integer +var style of flags wxHW_SCROLLBAR_NEVER,wxHW_SCROLLBAR_AUTO +derived from control diff --git a/contrib/utils/wxrcedit/df/menu.df b/contrib/utils/wxrcedit/df/menu.df new file mode 100644 index 0000000000..641a0451a4 --- /dev/null +++ b/contrib/utils/wxrcedit/df/menu.df @@ -0,0 +1,8 @@ +node menu +type panel +icon 0 +childtype menu_item +var label of text +var style of flags wxMENU_TEAROFF +var help of text +derived from menu_item diff --git a/contrib/utils/wxrcedit/df/menu_item.df b/contrib/utils/wxrcedit/df/menu_item.df new file mode 100644 index 0000000000..bd0a2a36a3 --- /dev/null +++ b/contrib/utils/wxrcedit/df/menu_item.df @@ -0,0 +1,3 @@ +# anything that may be placed into menu +node menu_item +abstract diff --git a/contrib/utils/wxrcedit/df/menubar.df b/contrib/utils/wxrcedit/df/menubar.df new file mode 100644 index 0000000000..18c8397dee --- /dev/null +++ b/contrib/utils/wxrcedit/df/menubar.df @@ -0,0 +1,5 @@ +node menubar +type panel +icon 0 +childtype menu +var style of flags wxMB_DOCKABLE diff --git a/contrib/utils/wxrcedit/df/menuitem.df b/contrib/utils/wxrcedit/df/menuitem.df new file mode 100644 index 0000000000..5c487821e5 --- /dev/null +++ b/contrib/utils/wxrcedit/df/menuitem.df @@ -0,0 +1,9 @@ +node menuitem +type normal +icon 0 +var label of text +var help of text +var checkable of bool +var checked of bool +var enabled of bool +derived from menu_item \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/panel.df b/contrib/utils/wxrcedit/df/panel.df new file mode 100644 index 0000000000..4d44076b0e --- /dev/null +++ b/contrib/utils/wxrcedit/df/panel.df @@ -0,0 +1,3 @@ +node panel +derived from panel_item +derived from panelbase diff --git a/contrib/utils/wxrcedit/df/panel_item.df b/contrib/utils/wxrcedit/df/panel_item.df new file mode 100644 index 0000000000..00bfb51d4c --- /dev/null +++ b/contrib/utils/wxrcedit/df/panel_item.df @@ -0,0 +1,4 @@ +# anything that may be placed into panel +node panel_item +abstract +derived from sizer_item \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/panelbase.df b/contrib/utils/wxrcedit/df/panelbase.df new file mode 100644 index 0000000000..6136b048df --- /dev/null +++ b/contrib/utils/wxrcedit/df/panelbase.df @@ -0,0 +1,9 @@ +# base "class" for panel and dialog +node panelbase +type panel +icon 1 +childtype panel_item +abstract +var style of flags wxNO_3D,wxTAB_TRAVERSAL +var exstyle of flags wxWS_EX_VALIDATE_RECURSIVELY +derived from window diff --git a/contrib/utils/wxrcedit/df/radiobutton.df b/contrib/utils/wxrcedit/df/radiobutton.df new file mode 100644 index 0000000000..19185fb0b3 --- /dev/null +++ b/contrib/utils/wxrcedit/df/radiobutton.df @@ -0,0 +1,5 @@ +node radiobutton +var label of text +var value of bool +var style of flags wxRB_GROUP +derived from control diff --git a/contrib/utils/wxrcedit/df/separator.df b/contrib/utils/wxrcedit/df/separator.df new file mode 100644 index 0000000000..ea5458db9a --- /dev/null +++ b/contrib/utils/wxrcedit/df/separator.df @@ -0,0 +1,4 @@ +node separator +icon 0 +type normal +derived from menu_item diff --git a/contrib/utils/wxrcedit/df/sizer_item.df b/contrib/utils/wxrcedit/df/sizer_item.df new file mode 100644 index 0000000000..3d632925a7 --- /dev/null +++ b/contrib/utils/wxrcedit/df/sizer_item.df @@ -0,0 +1,4 @@ +# anything that may be placed into sizer +node sizer_item +abstract + diff --git a/contrib/utils/wxrcedit/df/sizeritem.df b/contrib/utils/wxrcedit/df/sizeritem.df new file mode 100644 index 0000000000..25b2b6544c --- /dev/null +++ b/contrib/utils/wxrcedit/df/sizeritem.df @@ -0,0 +1,8 @@ +# don't delete this file! +# it servers as helper df for sizer items + +node sizeritem +type sizeritem +var option of integer +var flag of flags wxEXPAND,wxALL,wxLEFT,wxRIGHT,wxTOP,wxBOTTOM,wxALIGN_CENTER,wxALIGN_LEFT,wxALIGN_TOP,wxALIGN_RIGHT,wxALIGN_BOTTOM,wxALIGN_CENTER_HORIZONTAL,wxALIGN_CENTER_VERTICAL,wxNORTH,wxSOUTH,wxEAST,wxWEST,wxGROW,wxSHAPED,wxSTRETCH_NOT +var border of integer diff --git a/contrib/utils/wxrcedit/df/slider.df b/contrib/utils/wxrcedit/df/slider.df new file mode 100644 index 0000000000..ee3866b970 --- /dev/null +++ b/contrib/utils/wxrcedit/df/slider.df @@ -0,0 +1,13 @@ +node slider +var value of integer +var min of integer +var max of integer +var style of flags wxSL_HORIZONTAL,wxSL_VERTICAL,wxSL_AUTOTICKS,wxSL_LABELS,wxSL_LEFT,wxSL_TOP,wxSL_RIGHT,wxSL_BOTTOM,wxSL_BOTH,wxSL_SELRANGE +var tickfreq of integer +var pagesize of integer +var linesize of integer +var thumb of integer +var tick of integer +var selmin of integer +var selmax of integer +derived from control diff --git a/contrib/utils/wxrcedit/df/spacer.df b/contrib/utils/wxrcedit/df/spacer.df new file mode 100644 index 0000000000..75a19ff40d --- /dev/null +++ b/contrib/utils/wxrcedit/df/spacer.df @@ -0,0 +1,10 @@ +# don't delete this file! +# it servers as helper df for sizer items + +node spacer +type normal +var option of integer +var flag of flags wxEXPAND,wxALL,wxLEFT,wxRIGHT,wxTOP,wxBOTTOM,wxALIGN_CENTER,wxALIGN_LEFT,wxALIGN_TOP,wxALIGN_RIGHT,wxALIGN_BOTTOM,wxALIGN_CENTER_HORIZONTAL,wxALIGN_CENTER_VERTICAL,wxNORTH,wxSOUTH,wxEAST,wxWEST,wxGROW,wxSHAPED,wxSTRETCH_NOT +var border of integer +var size of coord +derived from sizer_item diff --git a/contrib/utils/wxrcedit/df/staticbitmap.df b/contrib/utils/wxrcedit/df/staticbitmap.df new file mode 100644 index 0000000000..1591ed32c0 --- /dev/null +++ b/contrib/utils/wxrcedit/df/staticbitmap.df @@ -0,0 +1,3 @@ +node button +var bitmap of text +derived from control \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/staticboxsizer.df b/contrib/utils/wxrcedit/df/staticboxsizer.df new file mode 100644 index 0000000000..055d799213 --- /dev/null +++ b/contrib/utils/wxrcedit/df/staticboxsizer.df @@ -0,0 +1,3 @@ +node staticboxsizer +derived from boxsizer +var label of text diff --git a/contrib/utils/wxrcedit/df/statictext.df b/contrib/utils/wxrcedit/df/statictext.df new file mode 100644 index 0000000000..677c1f8632 --- /dev/null +++ b/contrib/utils/wxrcedit/df/statictext.df @@ -0,0 +1,3 @@ +node statictext +var label of text +derived from control \ No newline at end of file diff --git a/contrib/utils/wxrcedit/df/textctrl.df b/contrib/utils/wxrcedit/df/textctrl.df new file mode 100644 index 0000000000..706dcdf004 --- /dev/null +++ b/contrib/utils/wxrcedit/df/textctrl.df @@ -0,0 +1,4 @@ +node textctrl +var value of text +var style of flags wxTE_PROCESS_ENTER,wxTE_PROCESS_TAB,wxTE_MULTILINE,wxTE_PASSWORD,wxTE_READONLY,wxHSCROLL +derived from control diff --git a/contrib/utils/wxrcedit/df/toolbar_item.df b/contrib/utils/wxrcedit/df/toolbar_item.df new file mode 100644 index 0000000000..6e7d30f3dc --- /dev/null +++ b/contrib/utils/wxrcedit/df/toolbar_item.df @@ -0,0 +1,3 @@ +# anything that may be placed into toolbar +node toolbar_item +abstract diff --git a/contrib/utils/wxrcedit/df/window.df b/contrib/utils/wxrcedit/df/window.df new file mode 100644 index 0000000000..ec0530220f --- /dev/null +++ b/contrib/utils/wxrcedit/df/window.df @@ -0,0 +1,11 @@ +node window +type normal +abstract +var pos of coord +var size of coord +var tooltip of text +var fg of color +var bg of color +var enabled of bool +var focused of bool +var hidden of bool diff --git a/contrib/utils/wxrcedit/edapp.cpp b/contrib/utils/wxrcedit/edapp.cpp new file mode 100644 index 0000000000..ad65e05c1f --- /dev/null +++ b/contrib/utils/wxrcedit/edapp.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////// +// Purpose: XML resources editor +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation + #pragma interface +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/xml/xml.h" +#include "wx/image.h" + + +#include "editor.h" + + + +// -- Application + +class MyApp : public wxApp +{ +public: + virtual bool OnInit(); +}; + +IMPLEMENT_APP(MyApp) + + +bool MyApp::OnInit() +{ + wxString arg = (argc >= 1) ? argv[1] : ""; + wxInitAllImageHandlers(); + wxFrame *frame = new EditorFrame(NULL, arg); + SetTopWindow(frame); + frame->Show(TRUE); + return TRUE; +} + diff --git a/contrib/utils/wxrcedit/editor.cpp b/contrib/utils/wxrcedit/editor.cpp new file mode 100644 index 0000000000..15aa1fa98f --- /dev/null +++ b/contrib/utils/wxrcedit/editor.cpp @@ -0,0 +1,885 @@ +///////////////////////////////////////////////////////////////////////////// +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "editor.h" + #pragma implementation "treedt.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/wx.h" +#include "wx/xml/xml.h" +#include "wx/xml/xmlres.h" +#include "wx/splitter.h" +#include "wx/config.h" +#include "wx/dir.h" + +#include "treedt.h" +#include "editor.h" +#include "nodehnd.h" +#include "xmlhelpr.h" + + + +class EditorTreeCtrl : public wxTreeCtrl +{ + public: + EditorTreeCtrl(wxWindow *parent, int id, EditorFrame *frame) + : wxTreeCtrl(parent, id), m_EdFrame(frame) {} + + private: + EditorFrame *m_EdFrame; + + void OnRightClick(wxMouseEvent &event) + { + wxTreeItemId item = + m_EdFrame->m_TreeCtrl->HitTest(event.GetPosition()); + if (item.IsOk()) + { + m_EdFrame->m_TreeCtrl->SelectItem(item); + m_EdFrame->OnRightClickTree(event.GetPosition()); + } + } + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(EditorTreeCtrl, wxTreeCtrl) + EVT_RIGHT_DOWN(EditorTreeCtrl::OnRightClick) +END_EVENT_TABLE() + + +enum +{ + ID_PREVIEW = wxID_HIGHEST + 100, + ID_NEW, + ID_OPEN, + ID_CLOSE, + ID_SAVE, + ID_SAVEAS, + ID_DELETE_NODE, + ID_EXIT, + ID_TREE, + ID_XMLIDEDIT, + ID_XMLIDPICK, + ID_EDITCODE, + ID_PROPSLIST, + ID_CLEARPROP, + + ID_NEWDIALOG, + ID_NEWPANEL, + ID_NEWMENU, + ID_NEWMENUBAR, + ID_NEWTOOLBAR, + ID_NEWNODE = wxID_HIGHEST + 1000, + ID_NEWSYBNODE = ID_NEWNODE + 2000 +}; + +#ifdef __UNIX__ +#endif + + + + +BEGIN_EVENT_TABLE(EditorFrame, wxFrame) + EVT_TREE_SEL_CHANGED(ID_TREE, EditorFrame::OnTreeSel) + EVT_TOOL_RANGE(ID_PREVIEW, ID_EXIT, EditorFrame::OnToolbar) + EVT_MENU_RANGE(ID_NEWDIALOG, ID_NEWSYBNODE + 1000, EditorFrame::OnNewNode) + EVT_TEXT(ID_XMLIDEDIT, EditorFrame::OnXMLIDEdit) + EVT_BUTTON(ID_XMLIDPICK, EditorFrame::OnXMLIDPick) + EVT_BUTTON(ID_EDITCODE, EditorFrame::OnEditCode) + EVT_BUTTON(ID_CLEARPROP, EditorFrame::OnClearProp) + EVT_LIST_ITEM_SELECTED(ID_PROPSLIST, EditorFrame::OnPropSel) +END_EVENT_TABLE() + + + +#ifdef __UNIX__ +#include "bitmaps/preview.xpm" +#include "bitmaps/close.xpm" +#include "bitmaps/save.xpm" +#include "bitmaps/open.xpm" + +#include "bitmaps/control.xpm" +#include "bitmaps/vsizer.xpm" +#include "bitmaps/hsizer.xpm" +#include "bitmaps/panel.xpm" + +#include "bitmaps/unused.xpm" +#include "bitmaps/used.xpm" +#endif + + + +EditorFrame *EditorFrame::ms_Instance = NULL; + +EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename) + : wxFrame(parent, -1, filename + _("- wxWindows resources editor")) +{ + ms_Instance = this; + + wxConfigBase *cfg = wxConfigBase::Get(); + + SetSize(wxRect(wxPoint(cfg->Read("editor_x", -1), cfg->Read("editor_y", -1)), + wxSize(cfg->Read("editor_w", 400), cfg->Read("editor_h", 400)))); + + m_SelectedNode = NULL; + m_Resource = NULL; + m_FileName = wxEmptyString; + m_Preview = NULL; + m_SelectedProp = -1; + + wxMenu *menuFile = new wxMenu; + menuFile->Append(ID_NEW, "&New"); + menuFile->Append(ID_OPEN, "&Open\tCtrl-O"); + menuFile->Append(ID_SAVE, "&Save\tCtrl-S"); + menuFile->Append(ID_SAVEAS, "Save &as..."); + menuFile->AppendSeparator(); + menuFile->Append(ID_EXIT, "E&xit\tAlt-X"); + + wxMenuBar *menuBar = new wxMenuBar(); + menuBar->Append(menuFile, "&File"); + SetMenuBar(menuBar); + + // handlers: + m_Handlers.DeleteContents(TRUE); + RegisterHandlers("."); + RegisterHandlers("./df"); + m_Handlers.Append(new NodeHandlerUnknown(this)); + + #ifdef __UNIX__ + RegisterHandlers(wxGetHomeDir() + "/.wxrcedit"); + //FIXME - add $(prefix)/share/wx/wxrcedit + #endif + + // Create toolbar: + wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT); + toolBar->SetMargins(2, 2); + toolBar -> AddTool(ID_EXIT, wxBITMAP(close), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Quit the editor")); + toolBar -> AddTool(ID_OPEN, wxBITMAP(open), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Open XML resource file")); + toolBar -> AddTool(ID_SAVE, wxBITMAP(save), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Save XML file")); + toolBar -> AddTool(ID_PREVIEW, wxBITMAP(preview), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Preview")); + toolBar -> Realize(); + + // Create layout: + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + wxPanel *p = new wxPanel(this); + sizer->Add(p, 1, wxEXPAND); + wxSizer *sizer2 = new wxBoxSizer(wxVERTICAL); + + m_Splitter = new wxSplitterWindow(p); + sizer2->Add(m_Splitter, 1, wxEXPAND); + + + // Create tree control: + m_TreeCtrl = new EditorTreeCtrl(m_Splitter, ID_TREE, this); + m_ImgList = new wxImageList(16, 16); + m_ImgList->Add(wxICON(control)); + m_ImgList->Add(wxICON(panel)); + m_ImgList->Add(wxICON(vsizer)); + m_ImgList->Add(wxICON(hsizer)); + + m_TreeCtrl->SetImageList(m_ImgList); + + + // Create properties panel: + m_Splitter2 = new wxSplitterWindow(m_Splitter); + m_PropsPanel = new wxPanel(m_Splitter2, -1, wxDefaultPosition, + wxDefaultSize, wxTAB_TRAVERSAL); + + wxSizer *sizer3 = new wxBoxSizer(wxVERTICAL); + + wxSizer *sz = new wxBoxSizer(wxHORIZONTAL); + + sizer3->Add(new wxButton(m_PropsPanel, ID_EDITCODE, "Edit XML code"), + 0, wxALL | wxEXPAND, 2); + sz->Add(new wxStaticText(m_PropsPanel, -1, _("XMLID name:")), + 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 2); + m_XMLIDCtrl = new wxTextCtrl(m_PropsPanel, ID_XMLIDEDIT, ""); + sz->Add(m_XMLIDCtrl, 1, wxLEFT|wxRIGHT, 2); + sz->Add(new wxButton(m_PropsPanel, ID_XMLIDPICK, "...", wxDefaultPosition, wxSize(16,-1)), + 0, wxRIGHT, 2); + sizer3->Add(sz, 0, wxTOP|wxEXPAND, 2); + + m_PropsList = new wxListCtrl(m_PropsPanel, ID_PROPSLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); + + m_ImgListProp = new wxImageList(16, 16); + m_ImgListProp->Add(wxICON(unused)); + m_ImgListProp->Add(wxICON(used)); + m_PropsList->SetImageList(m_ImgListProp, wxIMAGE_LIST_SMALL); + + m_PropsList->InsertColumn(0, _("Property")); + m_PropsList->InsertColumn(1, _("Value")); + m_PropsList->SetColumnWidth(0, cfg->Read("editor_col0", wxLIST_AUTOSIZE_USEHEADER)); + m_PropsList->SetColumnWidth(1, cfg->Read("editor_col1", wxLIST_AUTOSIZE_USEHEADER)); + + sizer3->Add(m_PropsList, 1, wxALL | wxEXPAND, 2); + + m_PropsPanel->SetAutoLayout(TRUE); + m_PropsPanel->SetSizer(sizer3); + m_PropsPanel->Layout(); + + m_PropsEditPanel = new wxScrolledWindow(m_Splitter2, -1, wxDefaultPosition, + wxDefaultSize, wxTAB_TRAVERSAL); + + m_Splitter->SplitVertically(m_TreeCtrl, m_Splitter2); + m_Splitter->SetSashPosition(cfg->Read("editor_sash", 140)); + + m_Splitter2->SplitHorizontally(m_PropsPanel, m_PropsEditPanel); + m_Splitter2->SetSashPosition(cfg->Read("editor_sash2", 100)); + + p->SetAutoLayout(TRUE); + p->SetSizer(sizer2); + + + + SetAutoLayout(TRUE); + SetSizer(sizer); + + // Load file: + if (!filename) + NewFile(); + else + LoadFile(filename); +} + + + +EditorFrame::~EditorFrame() +{ + wxConfigBase *cfg = wxConfigBase::Get(); + + cfg->Write("editor_x", (long)GetPosition().x); + cfg->Write("editor_y", (long)GetPosition().y); + cfg->Write("editor_w", (long)GetSize().x); + cfg->Write("editor_h", (long)GetSize().y); + cfg->Write("editor_sash", (long)m_Splitter->GetSashPosition()); + cfg->Write("editor_sash2", (long)m_Splitter2->GetSashPosition()); + cfg->Write("editor_col0", (long)m_PropsList->GetColumnWidth(0)); + cfg->Write("editor_col1", (long)m_PropsList->GetColumnWidth(1)); + + delete m_ImgList; + delete m_ImgListProp; + RefreshProps(NULL); +} + + + +NodeHandler *EditorFrame::FindHandler(wxXmlNode *node) +{ + wxNode *n = m_Handlers.GetFirst(); + while (n) + { + NodeHandler *h = (NodeHandler*) n->GetData(); + if (h->CanHandle(node)) + return h; + n = n->GetNext(); + } + return NULL; +} + + + +void EditorFrame::RegisterHandlers(const wxString& dirname) +{ + if (!wxDirExists(dirname)) return; + + wxDir dir(dirname); + wxString filename; + bool cont; + NodeHandler *hnd; + + cont = dir.GetFirst(&filename, "*.df"); + while (cont) + { + hnd = NodeHandler::CreateFromFile(filename, this); + if (hnd) m_Handlers.Append(hnd); + cont = dir.GetNext(&filename); + } + +} + + + +void EditorFrame::LoadFile(const wxString& filename) +{ + delete m_Resource; + + m_FileName = ""; + m_Resource = new wxXmlDocument; + + if (!m_Resource->Load(filename)) + { + delete m_Resource; + m_Resource = NULL; + NewFile(); + wxLogError("Error parsing " + filename); + } + else + { + m_FileName = filename; + RefreshTree(); + SetTitle(m_FileName); + } +} + + + +void EditorFrame::SaveFile(const wxString& filename) +{ + m_FileName = filename; + SetTitle(filename); + + if (!m_Resource->Save(filename, wxXML_IO_LIBXML)) + wxLogError("Error saving " + filename); +} + + + +void EditorFrame::NewFile() +{ + delete m_Resource; + + m_FileName = ""; + m_Resource = new wxXmlDocument; + m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, "resource")); + + RefreshTree(); + SetTitle("unnamed"); +} + + + +void EditorFrame::RefreshPreview(wxXmlNode *node) +{ + wxBusyCursor bcur; + wxXmlResource *res = new wxXmlResource; + wxString tempfile; + wxPoint pos = wxDefaultPosition; + + while (node->GetParent() != m_Resource->GetRoot()) + node = node->GetParent(); + + if (m_Preview) pos = m_Preview->GetPosition(); + + res->InitAllHandlers(); + + wxGetTempFileName("xmleditor", tempfile); + m_Resource->Save(tempfile, wxXML_IO_BIN); + res->Load(tempfile, wxXML_BINARY); + + if (node->GetName() == "dialog") + { + wxDialog *dlg = new wxDialog; + if (res->LoadDialog(dlg, this, node->GetPropVal("name", "-1"))) + { + if (pos.x != -1) dlg->Move(pos); + dlg->Show(TRUE); + if (m_Preview) m_Preview->Close(TRUE); + m_Preview = dlg; + } + else + { + delete dlg; + wxLogError(_("Cannot preview the dialog -- XML resource corrupted.")); + } + } + delete res; + wxRemoveFile(tempfile); +} + + + +void EditorFrame::RefreshTree() +{ + wxXmlNode *sel = m_SelectedNode; + + m_TreeCtrl->DeleteAllItems(); + wxTreeItemId root = m_TreeCtrl->AddRoot("Resource: " + m_FileName); + + wxXmlNode *n = m_Resource->GetRoot()->GetChildren(); + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + CreateTreeNode(m_TreeCtrl, root, n); + n = n->GetNext(); + } + + m_TreeCtrl->Expand(root); + SelectNode(sel); +} + + +void EditorFrame::RefreshProps(wxXmlNode *node) +{ + m_SelectedProp = -1; + + for (int i = 0; i < m_PropsList->GetItemCount(); i++) + delete (wxObject*)(m_PropsList->GetItemData(i)); + + m_PropsList->DeleteAllItems(); + + if (node == NULL) return; + + m_XMLIDCtrl->SetValue(FindHandler(node)->GetRealNode(node)-> + GetPropVal("name", "-1")); + CreatePropsList(m_PropsList, node); + + RefreshPropsEdit(); +} + + + +void EditorFrame::RefreshPropsEdit() +{ + m_PropsEditPanel->DestroyChildren(); + m_PropsEditPanel->SetSizer(NULL); + + if (!m_SelectedNode || m_SelectedProp == -1 || + m_PropsList->GetItemData(m_SelectedProp) == 0) return; + + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + sizer->Add(new wxButton(m_PropsEditPanel, ID_CLEARPROP, _("Clear")), + 0, wxALL, 5); + + sizer->Add( + FindHandler(m_SelectedNode)->CreatePropEditPanel(m_PropsEditPanel, m_PropsList, m_SelectedProp), + 1, wxEXPAND, 0); + + m_PropsEditPanel->SetAutoLayout(TRUE); + m_PropsEditPanel->SetSizer(sizer); + m_PropsEditPanel->Layout(); + + wxSize winsz = m_PropsEditPanel->GetSize(); + sizer->SetMinSize(winsz.x, winsz.y); + + wxSize minsz = sizer->GetMinSize(); + + m_PropsEditPanel->SetScrollbars(8, 8, 1/*minsz.x/8*/, minsz.y/8); +} + + + +bool EditorFrame::SelectNode(wxXmlNode *node, wxTreeItemId *root) +{ + if (root == NULL) + { + wxTreeItemId rootitem = m_TreeCtrl->GetRootItem(); + return SelectNode(node, &rootitem); + } + + wxTreeItemId item; + XmlTreeData *dt; + wxXmlNode *nd; + long cookie; + + item = m_TreeCtrl->GetFirstChild(*root, cookie); + while (item.IsOk()) + { + dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(item)); + nd = (dt) ? dt->Node : NULL; + if (nd == node) + { + m_TreeCtrl->SelectItem(item); + m_TreeCtrl->EnsureVisible(item); + return TRUE; + } + if (m_TreeCtrl->ItemHasChildren(item) && SelectNode(node, &item)) + return TRUE; + item = m_TreeCtrl->GetNextChild(*root, cookie); + } + return FALSE; +} + + + +wxTreeItemId EditorFrame::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node) +{ + if (!node) + { + wxTreeItemId invalid; + return invalid; + } + + return FindHandler(node)->CreateTreeNode(treectrl, parent, node); +} + + + +void EditorFrame::CreatePropsList(wxListCtrl *treectrl, wxXmlNode *node) +{ + if (!node) return; + + FindHandler(node)->CreatePropsList(treectrl, node); +} + + + +void EditorFrame::NotifyChanged(int change_type) +{ + if (change_type & CHANGED_TREE) + RefreshTree(); + + if (change_type & CHANGED_TREE_SELECTED) + { + wxTreeItemId sel = m_TreeCtrl->GetSelection(); + m_TreeCtrl->SetItemText(sel, + FindHandler(m_SelectedNode)->GetTreeString(m_SelectedNode)); + } + + if (change_type & CHANGED_TREE_SELECTED_ICON) + { + wxTreeItemId sel = m_TreeCtrl->GetSelection(); + int icon = FindHandler(m_SelectedNode)->GetTreeIcon(m_SelectedNode); + m_TreeCtrl->SetItemImage(sel, icon); + } + + if (change_type & CHANGED_PROPS_PANEL) + RefreshProps(m_SelectedNode); +} + + + +void EditorFrame::OnTreeSel(wxTreeEvent& event) +{ + XmlTreeData *dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(event.GetItem())); + wxXmlNode *node = (dt) ? dt->Node : NULL; + + m_SelectedNode = node; + RefreshProps(node); +} + + + +void EditorFrame::OnXMLIDEdit(wxCommandEvent& event) +{ + if (!m_SelectedNode) return; + wxXmlNode *node = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode); + + node->DeleteProperty("name"); + wxString s = m_XMLIDCtrl->GetValue(); + if (!(s == "-1")) node->AddProperty("name", s); + NotifyChanged(CHANGED_TREE_SELECTED); +} + + + +void EditorFrame::OnXMLIDPick(wxCommandEvent& event) +{ + if (!m_SelectedNode) return; + wxXmlNode *node = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode); + + wxString choices[] = {wxString("-1") + #define stdID(id) , wxString(#id) + stdID(wxID_OK) stdID(wxID_CANCEL) + stdID(wxID_YES) stdID(wxID_NO) + stdID(wxID_APPLY) stdID(wxID_HELP) + stdID(wxID_HELP_CONTEXT) + + stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW) + stdID(wxID_SAVE) stdID(wxID_SAVEAS) stdID(wxID_REVERT) + stdID(wxID_EXIT) stdID(wxID_UNDO) stdID(wxID_REDO) + stdID(wxID_PRINT) stdID(wxID_PRINT_SETUP) + stdID(wxID_PREVIEW) stdID(wxID_ABOUT) stdID(wxID_HELP_CONTENTS) + stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES) + stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE) + stdID(wxID_CLEAR) stdID(wxID_FIND) stdID(wxID_DUPLICATE) + stdID(wxID_SELECTALL) + stdID(wxID_STATIC) stdID(wxID_FORWARD) stdID(wxID_BACKWARD) + stdID(wxID_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP) + stdID(wxID_RESET) + #undef stdID + }; + + wxString s = + wxGetSingleChoice(_("Choose from predefined IDs:"), _("XMLID"), + 38/*sizeof choices*/, choices); + if (!s) return; + + m_XMLIDCtrl->SetValue(s); + node->DeleteProperty("name"); + if (!(s == "-1")) node->AddProperty("name", s); + NotifyChanged(CHANGED_TREE_SELECTED); +} + + + +void EditorFrame::OnEditCode(wxCommandEvent& event) +{ + if (!m_SelectedNode) return; + + wxBusyCursor bcur; + wxDialog dlg(this, -1, _("XML code editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + wxTextCtrl *tc = new wxTextCtrl(&dlg, -1, "", wxDefaultPosition, + wxDefaultSize, wxTE_MULTILINE); + sizer->Add(tc, 1, wxEXPAND | wxALL, 10); + + wxSizer *sz2 = new wxBoxSizer(wxHORIZONTAL); + + sz2->Add(new wxButton(&dlg, wxID_OK, _("Save")), 0); + sz2->Add(new wxButton(&dlg, wxID_CANCEL, _("Cancel")), 0, wxLEFT, 10); + + sizer->Add(sz2, 0, wxALIGN_RIGHT | wxRIGHT|wxBOTTOM, 10); + + dlg.SetAutoLayout(TRUE); + dlg.SetSizer(sizer); + + wxConfigBase *cfg = wxConfigBase::Get(); + + dlg.SetSize(wxRect(wxPoint(cfg->Read("xmleditor_x", -1), cfg->Read("xmleditor_y", -1)), + wxSize(cfg->Read("xmleditor_w", 400), cfg->Read("xmleditor_h", 400)))); + + wxString tempfile; + wxGetTempFileName("xmleditor", tempfile); + + { + wxXmlDocument doc; + doc.SetRoot(new wxXmlNode(*m_SelectedNode)); + doc.Save(tempfile, wxXML_IO_LIBXML); + } + tc->LoadFile(tempfile); + + if (dlg.ShowModal() == wxID_OK) + { + tc->SaveFile(tempfile); + wxXmlDocument doc; + if (doc.Load(tempfile)) + { + (*m_SelectedNode) = *doc.GetRoot(); + NotifyChanged(CHANGED_TREE); + //FIXME-instead, regenerate only children + } + else wxLogError(_("Illegal XML file, canceled.")); + } + wxRemoveFile(tempfile); + + cfg->Write("xmleditor_x", (long)dlg.GetPosition().x); + cfg->Write("xmleditor_y", (long)dlg.GetPosition().y); + cfg->Write("xmleditor_w", (long)dlg.GetSize().x); + cfg->Write("xmleditor_h", (long)dlg.GetSize().y); +} + + + +void EditorFrame::OnClearProp(wxCommandEvent& event) +{ + m_PropsList->SetItemImage(m_SelectedProp, 0, 0); + m_PropsList->SetItem(m_SelectedProp, 1, ""); + + PropsListInfo *pli = (PropsListInfo*)m_PropsList->GetItemData(m_SelectedProp); + + wxXmlNode *nd = XmlFindNode(pli->m_Node, pli->m_PropInfo->Name); + + if (nd == NULL) return; + nd->GetParent()->RemoveChild(nd); + delete nd; + RefreshPropsEdit(); +} + + + +void EditorFrame::OnPropSel(wxListEvent& event) +{ + m_SelectedProp = event.GetIndex(); + RefreshPropsEdit(); +} + + + +void EditorFrame::OnToolbar(wxCommandEvent& event) +{ + switch (event.GetId()) + { + case ID_PREVIEW : + { + XmlTreeData* dt = (XmlTreeData*)m_TreeCtrl->GetItemData(m_TreeCtrl->GetSelection());; + if (dt != NULL && dt->Node != NULL) + RefreshPreview(dt->Node); + break; + } + + case ID_EXIT : + Close(TRUE); + break; + + case ID_NEW : + NewFile(); + break; + + case ID_OPEN : + { + wxString name = wxFileSelector("Open XML resource", "", "", "", "XML resources|*.xml", wxOPEN | wxFILE_MUST_EXIST); + if (!name.IsEmpty()) + LoadFile(name); + break; + } + + case ID_SAVE : + if (m_FileName != "") { SaveFile(m_FileName); break;} + // else go to SAVEAS + + case ID_SAVEAS : + { + wxString name = wxFileSelector("Save as", "", m_FileName, "", "XML resources|*.xml", wxSAVE | wxOVERWRITE_PROMPT); + if (!name.IsEmpty()) + SaveFile((m_FileName = name)); + break; + } + + case ID_DELETE_NODE : + { + XmlTreeData *dt = (XmlTreeData*) + (m_TreeCtrl->GetItemData(m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection()))); + wxXmlNode *n = (dt) ? dt->Node : NULL; + + m_SelectedNode->GetParent()->RemoveChild(m_SelectedNode); + NotifyChanged(CHANGED_TREE); + SelectNode(n); + break; + } + } +} + + + +void EditorFrame::OnNewNode(wxCommandEvent& event) +{ + if (event.GetId() >= ID_NEWSYBNODE) + { + XmlTreeData *pardt = + (XmlTreeData*)(m_TreeCtrl->GetItemData( + m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection()))); + + if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot()) + { + wxXmlNode *nd = pardt->Node; + + wxXmlNode *realnode = FindHandler(nd)->GetRealNode(nd); + NodeHandler *hnd = FindHandler(realnode); + wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWSYBNODE]; + + wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, name); + hnd->InsertNode(realnode, node, m_SelectedNode); + wxTreeItemId root = m_TreeCtrl->GetSelection(); + SelectNode(node, &root); + } + + } + + else if (event.GetId() >= ID_NEWNODE) + { + wxXmlNode *realnode = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode); + NodeHandler *hnd = FindHandler(realnode); + wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWNODE]; + + wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, name); + hnd->InsertNode(realnode, node); + wxTreeItemId root = m_TreeCtrl->GetSelection(); + SelectNode(node, &root); + } + + else + { + wxString name; + switch (event.GetId()) + { + case ID_NEWDIALOG : name = "dialog"; break; + case ID_NEWPANEL : name = "panel"; break; + case ID_NEWMENU : name = "menu"; break; + case ID_NEWMENUBAR : name = "menubar"; break; + case ID_NEWTOOLBAR : name = "toolbar"; break; + default : return; // never occurs + } + + wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, name); + m_Resource->GetRoot()->AddChild(node); + NotifyChanged(CHANGED_TREE); + SelectNode(node); + } +} + + + +void EditorFrame::OnRightClickTree(wxPoint pos) +{ + wxMenu *popup = new wxMenu; + + if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot()) + { + popup->Append(ID_NEWDIALOG, _("New dialog")); + popup->Append(ID_NEWPANEL, _("New panel")); + popup->Append(ID_NEWMENU, _("New menu")); + popup->Append(ID_NEWMENUBAR, _("New menubar")); + popup->Append(ID_NEWTOOLBAR, _("New toolbar")); + } + + else + { + { + wxArrayString& arr = + FindHandler(FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode))-> + GetChildTypes(); + + if (!arr.IsEmpty()) + { + wxMenu *news = new wxMenu; + for (size_t i = 0; i < arr.GetCount(); i++) + { + news->Append(i + ID_NEWNODE, arr[i]); + if (i % 16 == 15) news->Break(); + } + popup->Append(ID_NEWNODE-1, _("New child"), news); + } + } + + + XmlTreeData *pardt = + (XmlTreeData*)(m_TreeCtrl->GetItemData( + m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection()))); + if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot()) + { + wxXmlNode *nd = pardt->Node; + wxArrayString& arr = + FindHandler(FindHandler(nd)->GetRealNode(nd))-> + GetChildTypes(); + + if (!arr.IsEmpty()) + { + wxMenu *news = new wxMenu; + for (size_t i = 0; i < arr.GetCount(); i++) + { + news->Append(i + ID_NEWSYBNODE, arr[i]); + if (i % 16 == 15) news->Break(); + } + popup->Append(ID_NEWSYBNODE-1, _("New sybling"), news); + } + } + + + popup->AppendSeparator(); + popup->Append(ID_DELETE_NODE, _("Delete")); + } + + m_TreeCtrl->PopupMenu(popup, pos); + delete popup; +} diff --git a/contrib/utils/wxrcedit/editor.h b/contrib/utils/wxrcedit/editor.h new file mode 100644 index 0000000000..72333a3143 --- /dev/null +++ b/contrib/utils/wxrcedit/editor.h @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////// +// Purpose: XML resources editor +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma interface "editor.h" +#endif + +#ifndef _EDITOR_H_ +#define _EDITOR_H_ + + +class wxXmlNode; +class wxTreeCtrl; +class wxScrolledWindow; +class wxSplitterWindow; + +#include "wx/frame.h" + + + +class NodeHandler; +class wxXmlNode; +class wxXmlDocument; +class EditorTreeCtrl; + +enum ChangeType +{ + CHANGED_NOTHING = 0, + CHANGED_TREE = 1, + CHANGED_TREE_SELECTED = 2, + CHANGED_TREE_SELECTED_ICON = 4, + CHANGED_PROPS = 8, + CHANGED_PROPS_PANEL = 16, + CHANGED_EVERYTHING = CHANGED_TREE | CHANGED_PROPS | CHANGED_PROPS_PANEL, +}; + + +class EditorFrame : public wxFrame +{ + public: + friend class EditorTreeCtrl; + + EditorFrame(wxFrame *parent, const wxString& filename); + ~EditorFrame(); + + void LoadFile(const wxString& filename); + void NewFile(); + void SaveFile(const wxString& filename); + + void RefreshTree(); + void RefreshPreview(wxXmlNode *node); + void RefreshProps(wxXmlNode *node); + void RefreshPropsEdit(); + bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL); + + wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node); + void CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node); + + void NotifyChanged(int change_type); + + void RegisterHandlers(const wxString& dir); + + NodeHandler *FindHandler(wxXmlNode *node); + + static EditorFrame *Get() { return ms_Instance; } + + private: + static EditorFrame *ms_Instance; + + wxTreeCtrl *m_TreeCtrl; + wxTextCtrl *m_XMLIDCtrl; + wxImageList *m_ImgList, *m_ImgListProp; + wxPanel *m_PropsPanel; + wxScrolledWindow *m_PropsEditPanel; + wxSplitterWindow *m_Splitter, *m_Splitter2; + wxListCtrl *m_PropsList; + int m_SelectedProp; + + wxList m_Handlers; + + wxXmlNode *m_SelectedNode; + + wxString m_FileName; + wxXmlDocument *m_Resource; + wxWindow *m_Preview; + + DECLARE_EVENT_TABLE() + void OnTreeSel(wxTreeEvent& event); + void OnToolbar(wxCommandEvent& event); + void OnNew(wxCommandEvent& event); + void OnXMLIDEdit(wxCommandEvent& event); + void OnXMLIDPick(wxCommandEvent& event); + void OnEditCode(wxCommandEvent& event); + void OnClearProp(wxCommandEvent& event); + void OnPropSel(wxListEvent& event); + void OnNewNode(wxCommandEvent& event); + void OnRightClickTree(wxPoint pos); +}; + + +#endif diff --git a/contrib/utils/wxrcedit/nodehnd.cpp b/contrib/utils/wxrcedit/nodehnd.cpp new file mode 100644 index 0000000000..b8fc433f4c --- /dev/null +++ b/contrib/utils/wxrcedit/nodehnd.cpp @@ -0,0 +1,437 @@ +///////////////////////////////////////////////////////////////////////////// +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "nodehnd.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "nodehnd.h" +#include "wx/xml/xml.h" +#include "wx/filefn.h" +#include "wx/wx.h" +#include "wx/arrimpl.cpp" +#include "wx/textfile.h" +#include "wx/tokenzr.h" +#include "wx/listctrl.h" +#include "editor.h" +#include "treedt.h" +#include "xmlhelpr.h" + + +WX_DEFINE_OBJARRAY(NodeInfoArray); + + + +void NodeInfo::Read(const wxString& filename) +{ + HandlerType tp = HANDLER_NONE; + wxString nd, cht; + bool ab = FALSE; + long icn = -1; + + Node.Empty(); + + wxPathList list; + list.Add("."); + list.Add("./df"); + #ifdef __UNIX__ + list.Add(wxGetHomeDir() + "/.wxrcedit"); + #endif + + wxString path = list.FindValidPath(filename); + if (path.IsEmpty()) return; + + wxTextFile tf; + tf.Open(path); + if (!tf.IsOpened()) return; + + for (size_t i = 0; i < tf.GetLineCount(); i++) + { + if (tf[i].IsEmpty() || tf[i][0] == '#') continue; + wxStringTokenizer tkn(tf[i], ' '); + wxString s = tkn.GetNextToken(); + if (s == "node") + nd = tkn.GetNextToken(); + else if (s == "childtype") + cht = tkn.GetNextToken(); + else if (s == "icon") + tkn.GetNextToken().ToLong(&icn); + else if (s == "derived") + { + if (tkn.GetNextToken() == "from") + { + s = tkn.GetNextToken(); + DerivedFrom.Add(s); + Read(s + ".df"); + } + } + else if (s == "abstract") + ab = true; + else if (s == "type") + { + s = tkn.GetNextToken(); + if (s == "sizer") tp = HANDLER_SIZER; + else if (s == "sizeritem") tp = HANDLER_SIZERITEM; + else if (s == "panel") tp = HANDLER_PANEL; + else /*if (s == "normal")*/ tp = HANDLER_NORMAL; + } + else if (s == "var") + { + PropertyInfo pi; + pi.Name = tkn.GetNextToken(); + tkn.GetNextToken(); + wxString typ = tkn.GetNextToken(); + if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken(); + if (typ == "color") pi.Type = PROP_COLOR; + else if (typ == "flags") pi.Type = PROP_FLAGS; + else if (typ == "bool") pi.Type = PROP_BOOL; + else if (typ == "integer") pi.Type = PROP_INTEGER; + else if (typ == "coord") pi.Type = PROP_COORD; + else /*if (typ == "text")*/ pi.Type = PROP_TEXT; + + bool fnd = FALSE; + for (size_t j = 0; j < Props.GetCount(); j++) + { + if (Props[j].Name == pi.Name) + { + if (Props[j].Type == pi.Type && pi.Type == PROP_FLAGS) + Props[j].MoreInfo << ',' << pi.MoreInfo; + else + Props[j] = pi; + fnd = TRUE; + } + } + + if (!fnd) Props.Add(pi); + } + } + + if (!nd.IsEmpty()) Node = nd; + if (!cht.IsEmpty()) ChildType = cht; + if (tp != HANDLER_NONE) Type = tp; + if (icn != -1) Icon = icn; + Abstract = ab; +} + + + +NodeHandler *NodeHandler::CreateFromFile(const wxString& filename, EditorFrame *frame) +{ + NodeHandler *hnd = NULL; + + if (s_AllNodes == NULL) s_AllNodes = new NodeInfoArray; + + NodeInfo *ni = new NodeInfo; + ni->Type = HANDLER_NONE; + ni->Icon = 0; + ni->Read(filename); + s_AllNodes->Add(*ni); // add a copy + + if (ni->Type == HANDLER_NONE || ni->Node.IsEmpty() || ni->Abstract) + return NULL; + + switch (ni->Type) + { + case HANDLER_PANEL: + hnd = new NodeHandlerPanel(frame, ni); + break; + case HANDLER_SIZER: + hnd = new NodeHandlerSizer(frame, ni); + break; + case HANDLER_SIZERITEM: + hnd = new NodeHandlerSizerItem(frame, ni); + break; + default: + hnd = new NodeHandler(frame, ni); + break; + } + + return hnd; +} + + + + + + +PropertyHandler* NodeHandler::s_PropHandlers[PROP_TYPES_CNT] = {NULL}; +int NodeHandler::s_RefCnt = 0; +NodeInfoArray* NodeHandler::s_AllNodes = NULL; + + +NodeHandler::NodeHandler(EditorFrame *frame, NodeInfo *ni) : + m_NodeInfo(ni) +{ + if (s_RefCnt++ == 0) CreatePropHandlers(); +} + + +void NodeHandler::CreatePropHandlers() +{ + s_PropHandlers[PROP_TEXT] = new TextPropertyHandler; + s_PropHandlers[PROP_FLAGS] = new FlagsPropertyHandler; + s_PropHandlers[PROP_COLOR] = new TextPropertyHandler; + s_PropHandlers[PROP_BOOL] = new BoolPropertyHandler; + s_PropHandlers[PROP_INTEGER] = new TextPropertyHandler; + s_PropHandlers[PROP_COORD] = new CoordPropertyHandler; +} + + +NodeHandler::~NodeHandler() +{ + if (--s_RefCnt == 0) + { + for (int i = 0; i < PROP_TYPES_CNT; i++) + delete s_PropHandlers[i]; + delete s_AllNodes; s_AllNodes = NULL; + } + delete m_NodeInfo; +} + + + +bool NodeHandler::CanHandle(wxXmlNode *node) +{ + return (m_NodeInfo->Node == node->GetName()); +} + + + +wxTreeItemId NodeHandler::CreateTreeNode(wxTreeCtrl *treectrl, + wxTreeItemId parent, + wxXmlNode *node) +{ + int icon = GetTreeIcon(node); + wxTreeItemId item = + treectrl->AppendItem(parent, GetTreeString(node), + icon, icon, new XmlTreeData(node)); + if (parent == treectrl->GetRootItem()) + treectrl->SetItemBold(item); + return item; +} + + + +wxString NodeHandler::GetTreeString(wxXmlNode *node) +{ + wxString xmlid = node->GetPropVal("name", ""); + if (xmlid.IsEmpty()) + return node->GetName(); + else + return (node->GetName() + " '" + xmlid + "'"); +} + + + +void NodeHandler::CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node) +{ + int index; + + for (size_t i = 0; i < m_NodeInfo->Props.GetCount(); i++) + { + PropertyInfo *p = &(m_NodeInfo->Props[i]); + index = s_PropHandlers[p->Type]->CreateListItem(listctrl, node, p); + listctrl->SetItemData(index, (long)new PropsListInfo( + index, s_PropHandlers[p->Type], node, + p, listctrl)); + } +} + + + +wxPanel *NodeHandler::CreatePropEditPanel(wxWindow *parent, wxListCtrl *listctrl, int index) +{ + PropsListInfo *pli = (PropsListInfo*)listctrl->GetItemData(index); + + return pli->m_Handler->CreateEditPanel(parent, pli); +} + + + +wxArrayString& NodeHandler::GetChildTypes() +{ + if (m_ChildTypes.IsEmpty()) + { + wxString basetype = m_NodeInfo->ChildType; + + for (size_t i = 0; i < s_AllNodes->GetCount(); i++) + { + NodeInfo &ni = (*s_AllNodes)[i]; + + if (ni.Node == basetype && !ni.Abstract) + m_ChildTypes.Add(ni.Node); + + if (ni.DerivedFrom.Index(basetype) != wxNOT_FOUND && !ni.Abstract) + m_ChildTypes.Add(ni.Node); + } + m_ChildTypes.Sort(); + } + + return m_ChildTypes; +} + + + +void NodeHandler::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) +{ + delete node; + wxLogError(_("Cannot insert child into this type of node!")); +} + + + + + + + + +wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl, + wxTreeItemId parent, + wxXmlNode *node) +{ + wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node); + + wxXmlNode *n = XmlFindNode(node, "children"); + + if (n) n = n->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + EditorFrame::Get()->CreateTreeNode(treectrl, root, n); + n = n->GetNext(); + } + treectrl->Expand(root); + return root; +} + + + +void NodeHandlerPanel::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) +{ + wxXmlNode *cnd = XmlFindNode(parent, "children"); + if (cnd == NULL) + { + cnd = new wxXmlNode(wxXML_ELEMENT_NODE, "children"); + parent->AddChild(cnd); + } + if (insert_before) + cnd->InsertChild(node, insert_before); + else + cnd->AddChild(node); + EditorFrame::Get()->NotifyChanged(CHANGED_TREE); +} + + + + + +void NodeHandlerSizer::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) +{ + wxXmlNode *cnd = XmlFindNode(parent, "children"); + if (cnd == NULL) + { + cnd = new wxXmlNode(wxXML_ELEMENT_NODE, "children"); + parent->AddChild(cnd); + } + + if (node->GetName() == "spacer") + { + if (insert_before) + cnd->InsertChild(node, insert_before); + else + cnd->AddChild(node); + } + else + { + wxXmlNode *itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, "sizeritem"); + wxXmlNode *winnode = new wxXmlNode(wxXML_ELEMENT_NODE, "window"); + itemnode->AddChild(winnode); + winnode->AddChild(node); + + if (insert_before) + cnd->InsertChild(itemnode, insert_before); + else + cnd->AddChild(itemnode); + } + EditorFrame::Get()->NotifyChanged(CHANGED_TREE); +} + + + +int NodeHandlerSizer::GetTreeIcon(wxXmlNode *node) +{ + if (XmlReadValue(node, "orient") == "wxVERTICAL") return 2; + else return 3; +} + + + +wxTreeItemId NodeHandlerSizerItem::CreateTreeNode(wxTreeCtrl *treectrl, + wxTreeItemId parent, + wxXmlNode *node) +{ + wxTreeItemId root; + + root = EditorFrame::Get()->CreateTreeNode(treectrl, parent, GetRealNode(node)); + ((XmlTreeData*)treectrl->GetItemData(root))->Node = node; + + treectrl->Expand(root); + return root; +} + + + +void NodeHandlerSizerItem::CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node) +{ + NodeHandler::CreatePropsList(listctrl, node); + int item = listctrl->GetItemCount(); + listctrl->InsertItem(item, "------"); + listctrl->SetItemImage(item, 0, 0); + EditorFrame::Get()->CreatePropsList(listctrl, GetRealNode(node)); +} + + + +wxString NodeHandlerSizerItem::GetTreeString(wxXmlNode *node) +{ + wxXmlNode *n = GetRealNode(node); + return EditorFrame::Get()->FindHandler(n)->GetTreeString(n); +} + + + +int NodeHandlerSizerItem::GetTreeIcon(wxXmlNode *node) +{ + wxXmlNode *n = GetRealNode(node); + return EditorFrame::Get()->FindHandler(n)->GetTreeIcon(n); +} + + + +wxXmlNode *NodeHandlerSizerItem::GetRealNode(wxXmlNode *node) +{ + wxXmlNode *n = XmlFindNode(node, "window"); + + if (n) n = n->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE) + return n; + n = n->GetNext(); + } + return NULL; +} diff --git a/contrib/utils/wxrcedit/nodehnd.h b/contrib/utils/wxrcedit/nodehnd.h new file mode 100644 index 0000000000..fda59e050a --- /dev/null +++ b/contrib/utils/wxrcedit/nodehnd.h @@ -0,0 +1,138 @@ +///////////////////////////////////////////////////////////////////////////// +// Purpose: XML resources editor +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma interface "nodehnd.h" +#endif + +#ifndef _NODEHND_H_ +#define _NODEHND_H_ + + +class wxXmlNode; +class wxList; +class wxListCtrl; + +class EditorFrame; + +#include "wx/treectrl.h" +#include "wx/xml/xml.h" +#include "prophnd.h" + + + +enum HandlerType +{ + HANDLER_NONE = 0, + HANDLER_PANEL = 1, + HANDLER_NORMAL, + HANDLER_SIZER, + HANDLER_SIZERITEM +}; + + +class NodeInfo +{ + public: + wxString Node; + HandlerType Type; + PropertyInfoArray Props; + wxArrayString DerivedFrom; + bool Abstract; + wxString ChildType; + int Icon; + + void Read(const wxString& filename); +}; + +WX_DECLARE_OBJARRAY(NodeInfo, NodeInfoArray); + + + + +class NodeHandler : public wxObject +{ + public: + static NodeHandler *CreateFromFile(const wxString& filename, EditorFrame *frame); + + NodeHandler(EditorFrame *frame, NodeInfo *ni); + virtual ~NodeHandler(); + + virtual bool CanHandle(wxXmlNode *node); + virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, + wxXmlNode *node); + virtual void CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node); + virtual int GetTreeIcon(wxXmlNode * WXUNUSED(node)) {return m_NodeInfo->Icon;} + virtual wxString GetTreeString(wxXmlNode *node); + wxPanel *CreatePropEditPanel(wxWindow *parent, wxListCtrl *listctrl, int index); + wxArrayString& GetChildTypes(); + virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); + virtual wxXmlNode *GetRealNode(wxXmlNode *node) { return node; } + + protected: + NodeInfo *m_NodeInfo; + wxArrayString m_ChildTypes; + + static PropertyHandler* s_PropHandlers[PROP_TYPES_CNT]; + static int s_RefCnt; + static NodeInfoArray* s_AllNodes; + + void CreatePropHandlers(); +}; + +// wxPanel handler +class NodeHandlerPanel : public NodeHandler +{ + public: + NodeHandlerPanel(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {} + + virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, + wxXmlNode *node); + virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); +}; + + +// wxSizers handler +class NodeHandlerSizer : public NodeHandlerPanel +{ + public: + NodeHandlerSizer(EditorFrame *frame, NodeInfo *ni) : NodeHandlerPanel(frame, ni) {} + + virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); + virtual int GetTreeIcon(wxXmlNode *node); +}; + + +// item of wxSizer handler +class NodeHandlerSizerItem : public NodeHandler +{ + public: + NodeHandlerSizerItem(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {} + + virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, + wxXmlNode *node); + virtual void CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node); + virtual wxString GetTreeString(wxXmlNode *node); + virtual int GetTreeIcon(wxXmlNode *node); + virtual wxXmlNode *GetRealNode(wxXmlNode *node); +}; + + + +// Generic handler which handles everything +class NodeHandlerUnknown : public NodeHandler +{ + public: + NodeHandlerUnknown(EditorFrame *frame) : NodeHandler(frame, new NodeInfo) {} + + virtual bool CanHandle(wxXmlNode *node) { return TRUE; } +}; + + +#endif diff --git a/contrib/utils/wxrcedit/prophnd.cpp b/contrib/utils/wxrcedit/prophnd.cpp new file mode 100644 index 0000000000..24e8bb5189 --- /dev/null +++ b/contrib/utils/wxrcedit/prophnd.cpp @@ -0,0 +1,332 @@ +///////////////////////////////////////////////////////////////////////////// +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "prophnd.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "prophnd.h" +#include "wx/xml/xml.h" +#include "wx/wx.h" +#include "wx/arrimpl.cpp" +#include "wx/valtext.h" +#include "wx/tokenzr.h" +#include "wx/checklst.h" +#include "xmlhelpr.h" +#include "editor.h" + + +WX_DEFINE_OBJARRAY(PropertyInfoArray); + + +enum +{ + ID_EDITCTRL = wxID_HIGHEST + 1000, + ID_XEDIT, + ID_YEDIT, + ID_USEDLG, + ID_BOOLVAL, + ID_CHECKLIST +}; + + + +class PropertyPanel : public wxPanel +{ + public: + PropertyPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) + : wxPanel(parent, -1), m_Handler(hnd), m_PLI(pli) {} + + void Update(const wxString& value) + { + XmlWriteValue(m_PLI->m_Node, m_PLI->m_PropInfo->Name, value); + m_PLI->m_ListCtrl->SetItemImage(m_PLI->m_Index, 1, 1); + m_PLI->m_ListCtrl->SetItem(m_PLI->m_Index, 1, + m_Handler->GetBriefValue(m_PLI->m_Node, m_PLI->m_PropInfo)); + } + + protected: + PropertyHandler *m_Handler; + PropsListInfo *m_PLI; +}; + + + + + +int PropertyHandler::CreateListItem(wxListCtrl *listctrl, wxXmlNode *node, PropertyInfo *pi) +{ + wxString name, value; + int iconnum; + + if (XmlFindNode(node, pi->Name) == NULL) iconnum = 0; else iconnum = 1; + name = pi->Name; + value = GetBriefValue(node, pi); + + long pos = listctrl->GetItemCount(); + listctrl->InsertItem(pos, name, iconnum); + listctrl->SetItem(pos, 1, value); + return pos; +} + + + +wxString PropertyHandler::GetBriefValue(wxXmlNode *node, PropertyInfo *pi) +{ + return XmlReadValue(node, pi->Name); +} + + + + + + +class TextPropPanel : public PropertyPanel +{ + public: + TextPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli) + { + wxSizer *sz = new wxBoxSizer(wxVERTICAL); + wxTextCtrl *tc; + + sz->Add(new wxStaticText(this, -1, _("Value:")), 0, wxLEFT, 5); + sz->Add(tc = new wxTextCtrl(this, ID_EDITCTRL, XmlReadValue(pli->m_Node, pli->m_PropInfo->Name)), 0, wxALL|wxEXPAND, 5); + tc->SetFocus(); + + SetAutoLayout(TRUE); + SetSizer(sz); + Layout(); + } + + void OnEdit(wxCommandEvent &event) + { + Update(((wxTextCtrl*)event.GetEventObject())->GetValue()); + } + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(TextPropPanel, PropertyPanel) + EVT_TEXT(ID_EDITCTRL, TextPropPanel::OnEdit) +END_EVENT_TABLE() + + +wxPanel *TextPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli) +{ + return new TextPropPanel(parent, this, pli); +} + + + + + + + + + + + +class CoordPropPanel : public PropertyPanel +{ + public: + CoordPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli) + { + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + wxSizer *sz = new wxBoxSizer(wxHORIZONTAL); + m_ed1 = m_ed2 = NULL; m_chb = NULL; + + sz->Add(new wxStaticText(this, -1, _("X:")), 0, wxLEFT|wxRIGHT|wxALIGN_CENTER, 5); + sz->Add(m_ed1 = new wxTextCtrl(this, ID_XEDIT, "", + wxDefaultPosition, wxDefaultSize, 0, + wxTextValidator(wxFILTER_NUMERIC)), + 1, wxRIGHT, 5); + m_ed1->SetFocus(); + + sz->Add(new wxStaticText(this, -1, _("Y:")), 0, wxLEFT|wxRIGHT|wxALIGN_CENTER, 5); + sz->Add(m_ed2 = new wxTextCtrl(this, ID_YEDIT, "", + wxDefaultPosition, wxDefaultSize, 0, + wxTextValidator(wxFILTER_NUMERIC)), + 1, wxRIGHT, 5); + sizer->Add(sz, 0, wxEXPAND|wxTOP, 5); + + sizer->Add(m_chb = new wxCheckBox(this, ID_USEDLG, _("Use dialog units")), 0, wxLEFT|wxTOP, 5); + + SetAutoLayout(TRUE); + SetSizer(sizer); + Layout(); + + wxString val = XmlReadValue(pli->m_Node, pli->m_PropInfo->Name); + m_chb->SetValue(val.Len()==0 || val[val.Len()-1] == 'd'); + m_ed1->SetValue(val.BeforeFirst(',')); + m_ed2->SetValue(val.AfterFirst(',').BeforeFirst('d')); + } + + void OnEdit(wxCommandEvent &event) + { + wxString val, v1, v2; + + if (m_ed1 == NULL || m_ed2 == NULL || m_chb == NULL) return; + + v1 = m_ed1->GetValue(); + v2 = m_ed2->GetValue(); + if (v1.IsEmpty() || v2.IsEmpty()) return; + val = v1 + "," + v2; + if (m_chb->GetValue()) val << 'd'; + Update(val); + } + + wxTextCtrl *m_ed1, *m_ed2; + wxCheckBox *m_chb; + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(CoordPropPanel, PropertyPanel) + EVT_TEXT(ID_XEDIT, CoordPropPanel::OnEdit) + EVT_TEXT(ID_YEDIT, CoordPropPanel::OnEdit) + EVT_CHECKBOX(ID_USEDLG, CoordPropPanel::OnEdit) +END_EVENT_TABLE() + +wxPanel *CoordPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli) +{ + return new CoordPropPanel(parent, this, pli); +} + + + + + + + + +class BoolPropPanel : public PropertyPanel +{ + public: + BoolPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli) + { + m_chb = NULL; + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(m_chb = new wxCheckBox(this, ID_BOOLVAL, _("On/Yes/True")), 0, wxLEFT|wxTOP, 5); + SetAutoLayout(TRUE); + SetSizer(sizer); + Layout(); + m_chb->SetValue(XmlReadValue(pli->m_Node, pli->m_PropInfo->Name) == "1"); + } + + void OnEdit(wxCommandEvent &event) + { + if (m_chb == NULL) return; + if (m_chb->GetValue()) Update("1"); + else Update("0"); + } + + wxCheckBox *m_chb; + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(BoolPropPanel, PropertyPanel) + EVT_CHECKBOX(ID_BOOLVAL, BoolPropPanel::OnEdit) +END_EVENT_TABLE() + +wxPanel *BoolPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli) +{ + return new BoolPropPanel(parent, this, pli); +} + +wxString BoolPropertyHandler::GetBriefValue(wxXmlNode *node, PropertyInfo *pi) +{ + wxString v = XmlReadValue(node, pi->Name); + if (v.IsEmpty()) return wxEmptyString; + else if (v == "1") return "true"; + else return "false"; +} + + + + + + + + +class FlagsPropPanel : public PropertyPanel +{ + public: + FlagsPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli) + { + m_chl = NULL; + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(m_chl = new wxCheckListBox(this, ID_CHECKLIST), 1, wxEXPAND|wxALL, 5); + SetAutoLayout(TRUE); + SetSizer(sizer); + Layout(); + + { + wxStringTokenizer tkn(pli->m_PropInfo->MoreInfo, ","); + wxString s; + while (tkn.HasMoreTokens()) + { + s = tkn.GetNextToken(); + m_chl->Append(s); + m_flags.Add(s); + } + } + + { + wxStringTokenizer tkn(XmlReadValue(pli->m_Node, pli->m_PropInfo->Name), "| "); + int index; + while (tkn.HasMoreTokens()) + { + index = m_flags.Index(tkn.GetNextToken()); + if (index != wxNOT_FOUND) + m_chl->Check(index); + } + } + } + + void OnEdit(wxCommandEvent &event) + { + wxString s; + bool first = TRUE; + + for (size_t i = 0; i < m_flags.GetCount(); i++) + { + if (m_chl->IsChecked(i)) + { + if (!first) s << '|'; + s << m_flags[i]; + first = FALSE; + } + } + Update(s); + if (m_PLI->m_PropInfo->Name == "orient") + // FIXME - dirty hack related to sizers + EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED_ICON); + } + + wxCheckListBox *m_chl; + wxArrayString m_flags; + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(FlagsPropPanel, PropertyPanel) + EVT_CHECKLISTBOX(ID_CHECKLIST, FlagsPropPanel::OnEdit) +END_EVENT_TABLE() + +wxPanel *FlagsPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli) +{ + return new FlagsPropPanel(parent, this, pli); +} diff --git a/contrib/utils/wxrcedit/prophnd.h b/contrib/utils/wxrcedit/prophnd.h new file mode 100644 index 0000000000..09c2fd0761 --- /dev/null +++ b/contrib/utils/wxrcedit/prophnd.h @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////// +// Purpose: XML resources editor +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma interface "prophnd.h" +#endif + +#ifndef _PROPHND_H_ +#define _PROPHND_H_ + + +class wxXmlNode; +class wxList; +class wxListCtrl; +class wxPanel; +class wxWindow; + +#include "wx/xml/xml.h" +#include "wx/dynarray.h" + +enum PropertyType +{ + PROP_TEXT = 0, + PROP_FLAGS = 1, + PROP_COLOR = 2, + PROP_BOOL = 3, + PROP_INTEGER = 4, + PROP_COORD = 5 +}; +#define PROP_TYPES_CNT 6 + +class PropertyInfo +{ + public: + PropertyType Type; + wxString Name; + wxString MoreInfo; +}; + +WX_DECLARE_OBJARRAY(PropertyInfo, PropertyInfoArray); + + +class PropertyHandler; + +class PropsListInfo : public wxObject +{ + public: + PropsListInfo(int index, PropertyHandler *hnd, wxXmlNode *node, + PropertyInfo *pi, wxListCtrl *listctrl) : + m_Index(index), m_Handler(hnd), m_Node(node), + m_PropInfo(pi), m_ListCtrl(listctrl) {} + virtual ~PropsListInfo() {} + + int m_Index; + PropertyHandler *m_Handler; + wxXmlNode *m_Node; + PropertyInfo *m_PropInfo; + wxListCtrl *m_ListCtrl; +}; + + + + +class PropertyHandler +{ + public: + PropertyHandler() {} + + int CreateListItem(wxListCtrl *listctrl, wxXmlNode *node, PropertyInfo *pi); + + virtual wxString GetBriefValue(wxXmlNode *node, PropertyInfo *pi); + virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli) = 0; +}; + + + +class TextPropertyHandler : public PropertyHandler +{ + public: + TextPropertyHandler() {} + virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli); +}; + + +class CoordPropertyHandler : public PropertyHandler +{ + public: + CoordPropertyHandler() {} + virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli); +}; + + +class BoolPropertyHandler : public PropertyHandler +{ + public: + BoolPropertyHandler() {} + virtual wxString GetBriefValue(wxXmlNode *node, PropertyInfo *pi); + virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli); +}; + + +class FlagsPropertyHandler : public PropertyHandler +{ + public: + FlagsPropertyHandler() {} + virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli); +}; + + +#endif diff --git a/contrib/utils/wxrcedit/treedt.h b/contrib/utils/wxrcedit/treedt.h new file mode 100644 index 0000000000..39ef82b300 --- /dev/null +++ b/contrib/utils/wxrcedit/treedt.h @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// Purpose: XML resources editor +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma interface "treedt.h" +#endif + +#ifndef _TREEDT_H_ +#define _TREEDT_H_ + + +#include "wx/treectrl.h" + +class wxXmlNode; + +class XmlTreeData : public wxTreeItemData +{ + public: + XmlTreeData(wxXmlNode *n) : Node(n) {} + wxXmlNode *Node; +}; + + +#endif diff --git a/contrib/utils/wxrcedit/xmlhelpr.cpp b/contrib/utils/wxrcedit/xmlhelpr.cpp new file mode 100644 index 0000000000..c4c0f2ff17 --- /dev/null +++ b/contrib/utils/wxrcedit/xmlhelpr.cpp @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////// +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "xmlhelpr.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/xml/xml.h" +#include "wx/wx.h" +#include "xmlhelpr.h" + + + +wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& param) +{ + wxXmlNode *n = parent->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == param) + return n; + n = n->GetNext(); + } + return NULL; +} + + +void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value) +{ + wxXmlNode *n = XmlFindNode(parent, name); + if (n == NULL) + { + n = new wxXmlNode(wxXML_ELEMENT_NODE, name); + parent->AddChild(n); + n->AddChild(new wxXmlNode(wxXML_TEXT_NODE, "")); + } + + n = n->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_TEXT_NODE || + n->GetType() == wxXML_CDATA_SECTION_NODE) + { + n->SetContent(value); + break; + } + n = n->GetNext(); + } +} + + + +wxString XmlReadValue(wxXmlNode *parent, const wxString& name) +{ + wxXmlNode *n = XmlFindNode(parent, name); + if (n == NULL) return wxEmptyString; + n = n->GetChildren(); + + while (n) + { + if (n->GetType() == wxXML_TEXT_NODE || + n->GetType() == wxXML_CDATA_SECTION_NODE) + return n->GetContent(); + n = n->GetNext(); + } + return wxEmptyString; +} + + + + diff --git a/contrib/utils/wxrcedit/xmlhelpr.h b/contrib/utils/wxrcedit/xmlhelpr.h new file mode 100644 index 0000000000..3ec3d934e6 --- /dev/null +++ b/contrib/utils/wxrcedit/xmlhelpr.h @@ -0,0 +1,23 @@ +///////////////////////////////////////////////////////////////////////////// +// Purpose: XML resources editor +// Author: Vaclav Slavik +// Created: 2000/05/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma interface "xmlhelpr.h" +#endif + +#ifndef _XMLHELPR_H_ +#define _XMLHELPR_H_ + +// some helper functions: + +void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value); +wxString XmlReadValue(wxXmlNode *parent, const wxString& name); +wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& name); + +#endif diff --git a/utils/wxrc/Makefile.in b/utils/wxrc/Makefile.in new file mode 100644 index 0000000000..1814109adf --- /dev/null +++ b/utils/wxrc/Makefile.in @@ -0,0 +1,16 @@ +# $Id$ + +top_srcdir = @top_srcdir@/.. +top_builddir = ../../.. +program_dir = contrib/utils/wxrc + +PROGRAM=wxrc + +OBJECTS=wxrc.o + + +APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@ +APPEXTRADEFS=-I$(top_srcdir)/contrib/include + +include $(top_builddir)/src/makeprog.env + diff --git a/utils/wxrc/wxrc.cpp b/utils/wxrc/wxrc.cpp new file mode 100644 index 0000000000..64a81ea2c2 --- /dev/null +++ b/utils/wxrc/wxrc.cpp @@ -0,0 +1,292 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wxrc.cpp +// Purpose: XML resource compiler +// Author: Vaclav Slavik +// Created: 2000/03/05 +// RCS-ID: $Id$ +// Copyright: (c) 2000 Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation + #pragma interface +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/cmdline.h" +#include "wx/xml/xml.h" +#include "wx/ffile.h" + + +#if wxUSE_GUI +#error "You must compile the resource compiler with wxBase!" +#endif + + +class XmlResApp : public wxApp +{ +public: + virtual int OnRun(); + +private: + + void ParseParams(const wxCmdLineParser& cmdline); + void CompileRes(); + wxArrayString PrepareTempFiles(); + void DeleteTempFiles(const wxArrayString& flist); + void MakePackageZIP(const wxArrayString& flist); + void MakePackageCPP(const wxArrayString& flist); + + bool flagVerbose, flagCPP, flagCompress; + wxString parOutput, parFuncname, parOutputPath; + wxArrayString parFiles; + int retCode; +}; + +IMPLEMENT_APP(XmlResApp) + +int XmlResApp::OnRun() +{ + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" }, + { wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" }, + { wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" }, + { wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" }, + { wxCMD_LINE_OPTION, "o", "output", "output file [resource.rsc/cpp]" }, + { wxCMD_LINE_OPTION, "h", "handlers", "output list of neccessary handlers to this file" }, + + { wxCMD_LINE_PARAM, NULL, NULL, "input file", + wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE }, + + { wxCMD_LINE_NONE } + }; + + wxCmdLineParser parser(cmdLineDesc, argc, argv); + + switch (parser.Parse()) + { + case -1: + return 0; + break; + + case 0: + retCode = 0; + ParseParams(parser); + CompileRes(); + return retCode; + break; + + default: + return 1; + break; + } +} + + + + +void XmlResApp::ParseParams(const wxCmdLineParser& cmdline) +{ + flagVerbose = cmdline.Found("v"); + flagCPP = cmdline.Found("c"); + flagCompress = flagCPP && !cmdline.Found("u"); + + if (!cmdline.Found("o", &parOutput)) + parOutput = flagCPP ? "resource.cpp" : "resource.rsc"; + parOutputPath = wxPathOnly(parOutput); + if (!parOutputPath) parOutputPath = "."; + + if (!cmdline.Found("n", &parFuncname)) + parFuncname = "InitXmlResource"; + + for (size_t i = 0; i < cmdline.GetParamCount(); i++) + parFiles.Add(cmdline.GetParam(i)); +} + + + + +void XmlResApp::CompileRes() +{ + wxArrayString files = PrepareTempFiles(); + + wxRemoveFile(parOutput); + + printf("TODO: include bitmaps, list of handlers\n"); + + if (!retCode) + { + if (flagCPP) + MakePackageCPP(files); + else + MakePackageZIP(files); + } + + DeleteTempFiles(files); +} + + + +wxArrayString XmlResApp::PrepareTempFiles() +{ + wxArrayString flist; + + for (size_t i = 0; i < parFiles.Count(); i++) + { + if (flagVerbose) + wxPrintf("processing " + parFiles[i] + "...\n"); + + wxXmlDocument doc; + + if (!doc.Load(parFiles[i])) + { + wxLogError("Error parsing file " + parFiles[i]); + retCode = 1; + continue; + } + + wxString name, ext; + wxSplitPath(parFiles[i], NULL, &name, &ext); + + doc.Save(parOutputPath + "/" + name + ".xmb", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN); + flist.Add(name + ".xmb"); + } + + return flist; +} + + + +void XmlResApp::DeleteTempFiles(const wxArrayString& flist) +{ + for (size_t i = 0; i < flist.Count(); i++) + wxRemoveFile(parOutputPath + "/" + flist[i]); +} + + + +void XmlResApp::MakePackageZIP(const wxArrayString& flist) +{ + wxString files; + + for (size_t i = 0; i < flist.Count(); i++) + files += flist[i] + " "; + files.RemoveLast(); + + if (flagVerbose) + wxPrintf("compressing " + parOutput + "...\n"); + + if (wxExecute("zip -9 -j " + wxString(flagVerbose ? "" : "-q ") + + parOutput + " " + files, TRUE) == -1) + { + wxLogError("Unable to execute zip program. Make sure it is in the path."); + wxLogError("You can download it at http://www.cdrom.com/pub/infozip/"); + retCode = 1; + return; + } +} + + + + +static wxString FileToCppArray(wxString filename, int num) +{ + wxString output; + wxString snum; + wxString tmp; + wxFFile file(filename, "rb"); + size_t lng = file.Length(); + + snum.Printf("%i", num); + output.Printf("static size_t xml_res_size_" + snum + " = %i;\n", lng); + output += "static unsigned char xml_res_file_" + snum + "[] = {"; + + unsigned char *buffer = new unsigned char[lng]; + file.Read(buffer, lng); + + for (size_t i = 0; i < lng; i++) + { + if (i % 16 == 0) output += "\n"; + tmp.Printf("0x%02X", buffer[i]); + output += tmp; + if (i != lng-1) output += ","; + } + + delete[] buffer; + + output += "\n};\n\n"; + + return output; +} + + +void XmlResApp::MakePackageCPP(const wxArrayString& flist) +{ + wxFFile file(parOutput, "wt"); + size_t i; + + if (flagVerbose) + wxPrintf("creating C++ source file " + parOutput + "...\n"); + + file.Write("\ +#include \"wx/wxprec.h\"\n\ +\n\ +#ifdef __BORLANDC__\n\ + #pragma hdrstop\n\ +#endif\n\ +\n\ +#ifndef WX_PRECOMP\n\ + #include \"wx/wx.h\"\n\ +#endif\n\ +\ +#include \"wx/filesys.h\"\n\ +#include \"wx/fs_mem.h\"\n\ +#include \"wx/xml/xmlres.h\"\n\ +#include \"wx/xml/xh_all.h\"\n\ +\n"); + + for (i = 0; i < flist.Count(); i++) + file.Write(FileToCppArray(flist[i], i)); + + file.Write("\ +void " + parFuncname + "()\n\ +{\n\ +\n\ + // Check for memory FS. If not present, load the handler:\n\ + {\n\ + wxMemoryFSHandler::AddFile(\"xml_resource/dummy_file\", \"dummy one\");\n\ + wxFileSystem fsys;\n\ + wxFSFile *f = fsys.OpenFile(\"xml_resource/dummy_file\");\n\ + wxMemoryFSHandler::RemoveFile(\"xml_resource/dummy_file\");\n\ + if (f) delete f;\n\ + else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n\ + }\n\ +\n"); + + for (i = 0; i < flist.Count(); i++) + { + wxString s; + s.Printf(" wxMemoryFSHandler::AddFile(\"xml_resource/" + flist[i] + + "\", xml_res_file_%i, xml_res_size_%i);\n" + " wxTheXmlResource->Read(\"xml_resource/" + flist[i] + + "\", wxXML_BINARY);\n", i, i); + file.Write(s); + } + + file.Write("\n}\n"); + +} -- 2.45.2