mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-21 13:26:08 +08:00
added XML resources library
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -8,6 +8,8 @@ all:
|
||||
clean:
|
||||
cd src; make clean
|
||||
cd samples; make clean
|
||||
cd utils; make clean
|
||||
|
||||
|
||||
samples:
|
||||
cd samples; make
|
||||
|
||||
Vendored
+8
@@ -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 <<EOF
|
||||
@@ -906,12 +910,16 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
|
||||
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
|
||||
"}
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<\EOF
|
||||
|
||||
@@ -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
|
||||
])
|
||||
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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 <img src="hello.gif" id="3"/> "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 <title>hi</title> 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_
|
||||
@@ -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_
|
||||
@@ -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. <menuitem id="my_menu">...</menuitem>) 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, <tag>content<tag> 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_
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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 <item checked="boolean">Label</item>
|
||||
|
||||
// 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" ))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <item>Label</item>
|
||||
|
||||
// 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" ))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <item>Label</item>
|
||||
|
||||
// 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
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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 <page> 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
|
||||
@@ -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");
|
||||
}
|
||||
@@ -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
|
||||
@@ -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 <item selected="boolean">Label</item>
|
||||
|
||||
// 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
|
||||
@@ -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 <item> 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")));
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user