Added wx/xrc sources

This commit is contained in:
Julio C. Rocha 2015-11-17 18:58:43 -08:00
parent 8534ac665e
commit 3b0ea85d6c
71 changed files with 10528 additions and 0 deletions

View File

@ -0,0 +1,164 @@
#*****************************************************************************
# *
# Make file for VMS *
# Author : J.Jansen (joukj@hrem.nano.tudelft.nl) *
# Date : 6 November 2012 *
# *
#*****************************************************************************
.first
define wx [--.include.wx]
.ifdef __WXMOTIF__
CXX_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)\
/assume=(nostdnew,noglobal_array_new)
CC_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)
.else
.ifdef __WXGTK__
CXX_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/ieee=denorm\
/assume=(nostdnew,noglobal_array_new)
CC_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/ieee=denorm
.else
.ifdef __WXGTK2__
CXX_DEFINE = /define=(__WXGTK__=1,VMS_GTK2=1)/float=ieee/name=(as_is,short)/ieee=denorm\
/assume=(nostdnew,noglobal_array_new)
CC_DEFINE = /define=(__WXGTK__=1,VMS_GTK2=1)/float=ieee/name=(as_is,short)/ieee=denorm
.else
.ifdef __WXX11__
CXX_DEFINE = /define=(__WXX11__=1,__WXUNIVERSAL__==1)/float=ieee\
/name=(as_is,short)/assume=(nostdnew,noglobal_array_new)
CC_DEFINE = /define=(__WXX11__=1,__WXUNIVERSAL__==1)/float=ieee\
/name=(as_is,short)
.else
CXX_DEFINE =
CC_DEFINE =
.endif
.endif
.endif
.endif
.suffixes : .cpp
.cpp.obj :
cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp
.c.obj :
cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c
OBJECTS=xh_bmp.obj,xh_bmpbt.obj,xh_bttn.obj,xh_cald.obj,xh_chckb.obj,\
xh_chckl.obj,xh_choic.obj,xh_combo.obj,xh_dlg.obj,xh_frame.obj,\
xh_gauge.obj,xh_gdctl.obj,xh_html.obj,xh_listb.obj,xh_listc.obj,\
xh_menu.obj,xh_notbk.obj,xh_panel.obj,xh_radbt.obj,xh_radbx.obj,\
xh_scrol.obj,xh_scwin.obj,xh_sizer.obj,xh_slidr.obj,xh_spin.obj,\
xh_split.obj,xh_statbar.obj,xh_stbmp.obj,xh_stbox.obj,xh_stlin.obj,\
xh_sttxt.obj,xh_text.obj,xh_tglbtn.obj,xh_toolb.obj,xh_tree.obj,\
xh_unkwn.obj,xh_wizrd.obj,xmlres.obj,xmlrsall.obj,xh_listbk.obj,\
xh_choicbk.obj,xh_dirpicker.obj,xh_hyperlink.obj,xh_filepicker.obj,\
xh_fontpicker.obj,xh_clrpicker.obj,xh_odcombo.obj,xh_mdi.obj,\
xh_grid.obj,xh_datectrl.obj,xh_treebk.obj,xh_bmpcbox.obj,\
xh_animatctrl.obj,xh_htmllbox.obj,xh_collpane.obj,xh_srchctrl.obj,\
xh_propdlg.obj,xh_comboctrl.obj,xmladv.obj,xh_editlbox.obj,\
xh_filectrl.obj,xh_cmdlinkbn.obj,xh_toolbk.obj,xh_bannerwindow.obj,\
xh_timectrl.obj,xmlreshandler.obj,xh_ribbon.obj
SOURCES =xh_bmp.cpp,xh_bmpbt.cpp,xh_bttn.cpp,xh_cald.cpp,xh_chckb.cpp,\
xh_chckl.cpp,xh_choic.cpp,xh_combo.cpp,xh_dlg.cpp,xh_frame.cpp,\
xh_gauge.cpp,xh_gdctl.cpp,xh_html.cpp,xh_listb.cpp,xh_listc.cpp,\
xh_menu.cpp,xh_notbk.cpp,xh_panel.cpp,xh_radbt.cpp,xh_radbx.cpp,\
xh_scrol.cpp,xh_scwin.cpp,xh_sizer.cpp,xh_slidr.cpp,xh_spin.cpp,\
xh_split.cpp,xh_statbar.cpp,xh_stbmp.cpp,xh_stbox.cpp,xh_stlin.cpp,\
xh_sttxt.cpp,xh_text.cpp,xh_tglbtn.cpp,xh_toolb.cpp,xh_tree.cpp,\
xh_unkwn.cpp,xh_wizrd.cpp,xmlres.cpp,xmlrsall.cpp,xh_listbk.cpp,\
xh_choicbk.cpp,xh_dirpicker.cpp,xh_hyperlink.cpp,xh_filepicker.cpp,\
xh_fontpicker.cpp,xh_clrpicker.cpp,xh_odcombo.cpp,xh_mdi.cpp,\
xh_grid.cpp,xh_datectrl.cpp,xh_treebk.cpp,xh_bmpcbox.cpp,\
xh_animatctrl.cpp,xh_htmllbox.cpp,xh_collpane.cpp,xh_srchctrl.cpp,\
xh_propdlg.cpp,xh_comboctrl.cpp,xmladv.cpp,xh_editlbox.cpp,\
xh_filectrl.cpp,xh_cmdlinkbn.cpp,xh_toolbk.cpp,xh_bannerwindow.cpp,\
xh_timectrl.cpp,xmlreshandler.cpp,xh_ribbon.cpp
all : $(SOURCES)
$(MMS)$(MMSQUALIFIERS) $(OBJECTS)
.ifdef __WXMOTIF__
library [--.lib]libwx_motif.olb $(OBJECTS)
.else
.ifdef __WXGTK__
library [--.lib]libwx_gtk.olb $(OBJECTS)
.else
.ifdef __WXGTK2__
library [--.lib]libwx_gtk2.olb $(OBJECTS)
.else
.ifdef __WXX11__
library [--.lib]libwx_x11_univ.olb $(OBJECTS)
.endif
.endif
.endif
.endif
$(OBJECTS) : [--.include.wx]setup.h
xh_bmp.obj : xh_bmp.cpp
xh_bmpbt.obj : xh_bmpbt.cpp
xh_bttn.obj : xh_bttn.cpp
xh_cald.obj : xh_cald.cpp
xh_chckb.obj : xh_chckb.cpp
xh_chckl.obj : xh_chckl.cpp
xh_choic.obj : xh_choic.cpp
xh_combo.obj : xh_combo.cpp
xh_comboctrl.obj : xh_comboctrl.cpp
xh_dlg.obj : xh_dlg.cpp
xh_frame.obj : xh_frame.cpp
xh_gauge.obj : xh_gauge.cpp
xh_gdctl.obj : xh_gdctl.cpp
xh_html.obj : xh_html.cpp
xh_listb.obj : xh_listb.cpp
xh_listc.obj : xh_listc.cpp
xh_menu.obj : xh_menu.cpp
xh_notbk.obj : xh_notbk.cpp
xh_panel.obj : xh_panel.cpp
xh_radbt.obj : xh_radbt.cpp
xh_radbx.obj : xh_radbx.cpp
xh_scrol.obj : xh_scrol.cpp
xh_scwin.obj : xh_scwin.cpp
xh_sizer.obj : xh_sizer.cpp
xh_slidr.obj : xh_slidr.cpp
xh_spin.obj : xh_spin.cpp
xh_split.obj : xh_split.cpp
xh_statbar.obj : xh_statbar.cpp
xh_stbmp.obj : xh_stbmp.cpp
xh_stbox.obj : xh_stbox.cpp
xh_stlin.obj : xh_stlin.cpp
xh_sttxt.obj : xh_sttxt.cpp
xh_text.obj : xh_text.cpp
xh_tglbtn.obj : xh_tglbtn.cpp
xh_toolb.obj : xh_toolb.cpp
xh_tree.obj : xh_tree.cpp
xh_unkwn.obj : xh_unkwn.cpp
xh_wizrd.obj : xh_wizrd.cpp
xmlres.obj : xmlres.cpp
xmlrsall.obj : xmlrsall.cpp
xh_listbk.obj : xh_listbk.cpp
xh_choicbk.obj : xh_choicbk.cpp
xh_dirpicker.obj : xh_dirpicker.cpp
xh_hyperlink.obj : xh_hyperlink.cpp
xh_filepicker.obj : xh_filepicker.cpp
xh_fontpicker.obj : xh_fontpicker.cpp
xh_clrpicker.obj : xh_clrpicker.cpp
xh_odcombo.obj : xh_odcombo.cpp
xh_mdi.obj : xh_mdi.cpp
xh_grid.obj : xh_grid.cpp
xh_datectrl.obj : xh_datectrl.cpp
xh_treebk.obj : xh_treebk.cpp
xh_bmpcbox.obj : xh_bmpcbox.cpp
xh_animatctrl.obj : xh_animatctrl.cpp
xh_htmllbox.obj : xh_htmllbox.cpp
xh_collpane.obj : xh_collpane.cpp
xh_srchctrl.obj : xh_srchctrl.cpp
xh_propdlg.obj : xh_propdlg.cpp
xmladv.obj : xmladv.cpp
xh_editlbox.obj : xh_editlbox.cpp
xh_filectrl.obj : xh_filectrl.cpp
xh_cmdlinkbn.obj : xh_cmdlinkbn.cpp
xh_toolbk.obj : xh_toolbk.cpp
xh_bannerwindow.obj : xh_bannerwindow.cpp
xh_timectrl.obj : xh_timectrl.cpp
xmlreshandler.obj : xmlreshandler.cpp
xh_ribbon.obj : xh_ribbon.cpp

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_animatctrl.cpp
// Purpose: XML resource handler for wxAnimationCtrl
// Author: Francesco Montorsi
// Created: 2006-10-15
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_ANIMATIONCTRL
#include "wx/xrc/xh_animatctrl.h"
#include "wx/animate.h"
#include "wx/scopedptr.h"
IMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler, wxXmlResourceHandler)
wxAnimationCtrlXmlHandler::wxAnimationCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxAC_NO_AUTORESIZE);
XRC_ADD_STYLE(wxAC_DEFAULT_STYLE);
AddWindowStyles();
}
wxObject *wxAnimationCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(ctrl, wxAnimationCtrl)
wxScopedPtr<wxAnimation> animation(GetAnimation(wxT("animation")));
ctrl->Create(m_parentAsWindow,
GetID(),
animation ? *animation : wxNullAnimation,
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxAC_DEFAULT_STYLE),
GetName());
// if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap
// which just tells wxAnimationCtrl to use the default for inactive status
ctrl->SetInactiveBitmap(GetBitmap(wxT("inactive-bitmap")));
SetupWindow(ctrl);
return ctrl;
}
bool wxAnimationCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxAnimationCtrl"));
}
#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL

View File

@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_auinotbk.cpp
// Purpose: XML resource handler for wxAuiNotebook
// Author: Steve Lamerton
// Created: 2009-06-12
// Copyright: (c) 2009 Steve Lamerton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_AUI
#include "wx/xrc/xh_auinotbk.h"
#include "wx/aui/auibook.h"
wxIMPLEMENT_DYNAMIC_CLASS(wxAuiNotebookXmlHandler, wxXmlResourceHandler);
wxAuiNotebookXmlHandler::wxAuiNotebookXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxAUI_NB_DEFAULT_STYLE);
XRC_ADD_STYLE(wxAUI_NB_TAB_SPLIT);
XRC_ADD_STYLE(wxAUI_NB_TAB_MOVE);
XRC_ADD_STYLE(wxAUI_NB_TAB_EXTERNAL_MOVE);
XRC_ADD_STYLE(wxAUI_NB_TAB_FIXED_WIDTH);
XRC_ADD_STYLE(wxAUI_NB_SCROLL_BUTTONS);
XRC_ADD_STYLE(wxAUI_NB_WINDOWLIST_BUTTON);
XRC_ADD_STYLE(wxAUI_NB_CLOSE_BUTTON);
XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ALL_TABS);
XRC_ADD_STYLE(wxAUI_NB_TOP);
XRC_ADD_STYLE(wxAUI_NB_BOTTOM);
AddWindowStyles();
}
wxObject *wxAuiNotebookXmlHandler::DoCreateResource()
{
if (m_class == wxT("notebookpage"))
{
wxXmlNode *anb = GetParamNode(wxT("object"));
if (!anb)
anb = GetParamNode(wxT("object_ref"));
if (anb)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(anb, m_notebook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
if ( HasParam(wxT("bitmap")) )
{
m_notebook->AddPage(wnd,
GetText(wxT("label")),
GetBool(wxT("selected")),
GetBitmap(wxT("bitmap"), wxART_OTHER));
}
else
{
m_notebook->AddPage(wnd,
GetText(wxT("label")),
GetBool(wxT("selected")));
}
}
else
{
ReportError(anb, "notebookpage child must be a window");
}
return wnd;
}
else
{
ReportError("notebookpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(anb, wxAuiNotebook)
anb->Create(m_parentAsWindow,
GetID(),
GetPosition(),
GetSize(),
GetStyle(wxT("style")));
SetupWindow(anb);
wxAuiNotebook *old_par = m_notebook;
m_notebook = anb;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_notebook, true/*only this handler*/);
m_isInside = old_ins;
m_notebook = old_par;
return anb;
}
}
bool wxAuiNotebookXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxAuiNotebook"))) ||
(m_isInside && IsOfClass(node, wxT("notebookpage"))));
}
#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL

View File

@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////
// Name: srx/xrc/xh_bannerwindow.h
// Purpose: Implementation of wxBannerWindow XRC handler.
// Author: Vadim Zeitlin
// Created: 2011-08-16
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_BANNERWINDOW
#include "wx/xrc/xh_bannerwindow.h"
#include "wx/bannerwindow.h"
wxIMPLEMENT_DYNAMIC_CLASS(wxBannerWindowXmlHandler, wxXmlResourceHandler)
wxBannerWindowXmlHandler::wxBannerWindowXmlHandler()
: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxBannerWindowXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(banner, wxBannerWindow)
banner->Create(m_parentAsWindow,
GetID(),
GetDirection(wxS("direction")),
GetPosition(),
GetSize(),
GetStyle(wxS("style")),
GetName());
SetupWindow(banner);
const wxColour colStart = GetColour(wxS("gradient-start"));
const wxColour colEnd = GetColour(wxS("gradient-end"));
if ( colStart.IsOk() || colEnd.IsOk() )
{
if ( !colStart.IsOk() || !colEnd.IsOk() )
{
ReportError
(
"Both start and end gradient colours must be "
"specified if either one is."
);
}
else
{
banner->SetGradient(colStart, colEnd);
}
}
wxBitmap bitmap = GetBitmap();
if ( bitmap.IsOk() )
{
if ( colStart.IsOk() || colEnd.IsOk() )
{
ReportError
(
"Gradient colours are ignored by wxBannerWindow "
"if the background bitmap is specified."
);
}
banner->SetBitmap(bitmap);
}
banner->SetText(GetText(wxS("title")), GetText(wxS("message")));
return banner;
}
bool wxBannerWindowXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxS("wxBannerWindow"));
}
#endif // wxUSE_XRC && wxUSE_BANNERWINDOW

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_bmp.cpp
// Purpose: XRC resource for wxBitmap and wxIcon
// Author: Vaclav Slavik
// Created: 2000/09/09
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_bmp.h"
#ifndef WX_PRECOMP
#include "wx/bitmap.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler)
wxBitmapXmlHandler::wxBitmapXmlHandler()
:wxXmlResourceHandler()
{
}
wxObject *wxBitmapXmlHandler::DoCreateResource()
{
return new wxBitmap(GetBitmap(m_node));
}
bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxBitmap"));
}
IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler)
wxIconXmlHandler::wxIconXmlHandler()
: wxXmlResourceHandler()
{
}
wxObject *wxIconXmlHandler::DoCreateResource()
{
return new wxIcon(GetIcon(m_node));
}
bool wxIconXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxIcon"));
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_bmpbt.cpp
// Purpose: XRC resource for bitmap buttons
// Author: Brian Gavin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_BMPBUTTON
#include "wx/xrc/xh_bmpbt.h"
#ifndef WX_PRECOMP
#include "wx/bmpbuttn.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler)
wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_AUTODRAW);
XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT);
XRC_ADD_STYLE(wxBU_TOP);
XRC_ADD_STYLE(wxBU_BOTTOM);
XRC_ADD_STYLE(wxBU_EXACTFIT);
AddWindowStyles();
}
wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(button, wxBitmapButton)
button->Create(m_parentAsWindow,
GetID(),
GetBitmap(wxT("bitmap"), wxART_BUTTON),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxBU_AUTODRAW),
wxDefaultValidator,
GetName());
if (GetBool(wxT("default"), 0))
button->SetDefault();
SetupWindow(button);
if (GetParamNode(wxT("selected")))
button->SetBitmapSelected(GetBitmap(wxT("selected")));
if (GetParamNode(wxT("focus")))
button->SetBitmapFocus(GetBitmap(wxT("focus")));
if (GetParamNode(wxT("disabled")))
button->SetBitmapDisabled(GetBitmap(wxT("disabled")));
if (GetParamNode(wxT("hover")))
button->SetBitmapHover(GetBitmap(wxT("hover")));
return button;
}
bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxBitmapButton"));
}
#endif // wxUSE_XRC && wxUSE_BMPBUTTON

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_bmpcbox.cpp
// Purpose: XRC resource for wxBitmapComboBox
// Author: Jaakko Salli
// Created: Sep-10-2006
// Copyright: (c) 2006 Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_BITMAPCOMBOBOX
#include "wx/xrc/xh_bmpcbox.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#endif
#include "wx/bmpcbox.h"
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler)
wxBitmapComboBoxXmlHandler::wxBitmapComboBoxXmlHandler()
:wxXmlResourceHandler()
,m_combobox(NULL)
,m_isInside(false)
{
XRC_ADD_STYLE(wxCB_SORT);
XRC_ADD_STYLE(wxCB_READONLY);
AddWindowStyles();
}
wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource()
{
if (m_class == wxT("ownerdrawnitem"))
{
if ( !m_combobox )
{
ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox");
return NULL;
}
m_combobox->Append(GetText(wxT("text")),
GetBitmap(wxT("bitmap")));
return m_combobox;
}
else /*if( m_class == wxT("wxBitmapComboBox"))*/
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
XRC_MAKE_INSTANCE(control, wxBitmapComboBox)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
0,
NULL,
GetStyle(),
wxDefaultValidator,
GetName());
m_isInside = true;
m_combobox = control;
wxXmlNode *children_node = GetParamNode(wxT("object"));
wxXmlNode *n = children_node;
while (n)
{
if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object")))
{
CreateResFromNode(n, control, NULL);
}
n = n->GetNext();
}
m_isInside = false;
m_combobox = NULL;
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
return control;
}
}
bool wxBitmapComboBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxBitmapComboBox"))) ||
(m_isInside && IsOfClass(node, wxT("ownerdrawnitem"))));
}
#endif // wxUSE_XRC && wxUSE_BITMAPCOMBOBOX

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_bttn.cpp
// Purpose: XRC resource for buttons
// Author: Vaclav Slavik
// Created: 2000/03/05
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_BUTTON
#include "wx/xrc/xh_bttn.h"
#ifndef WX_PRECOMP
#include "wx/button.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler)
wxButtonXmlHandler::wxButtonXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT);
XRC_ADD_STYLE(wxBU_TOP);
XRC_ADD_STYLE(wxBU_BOTTOM);
XRC_ADD_STYLE(wxBU_EXACTFIT);
AddWindowStyles();
}
wxObject *wxButtonXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(button, wxButton)
button->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if (GetBool(wxT("default"), 0))
button->SetDefault();
if ( GetParamNode("bitmap") )
{
button->SetBitmap(GetBitmap("bitmap", wxART_BUTTON),
GetDirection("bitmapposition"));
}
SetupWindow(button);
return button;
}
bool wxButtonXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxButton"));
}
#endif // wxUSE_XRC && wxUSE_BUTTON

View File

@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_cald.cpp
// Purpose: XRC resource for wxCalendarCtrl
// Author: Brian Gavin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_CALENDARCTRL
#include "wx/xrc/xh_cald.h"
#ifndef WX_PRECOMP
#include "wx/event.h"
#endif //WX_PRECOMP
#include "wx/calctrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrlXmlHandler, wxXmlResourceHandler)
wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxCAL_SUNDAY_FIRST);
XRC_ADD_STYLE(wxCAL_MONDAY_FIRST);
XRC_ADD_STYLE(wxCAL_SHOW_HOLIDAYS);
XRC_ADD_STYLE(wxCAL_NO_YEAR_CHANGE);
XRC_ADD_STYLE(wxCAL_NO_MONTH_CHANGE);
XRC_ADD_STYLE(wxCAL_SEQUENTIAL_MONTH_SELECTION);
XRC_ADD_STYLE(wxCAL_SHOW_SURROUNDING_WEEKS);
AddWindowStyles();
}
wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(calendar, wxCalendarCtrl);
calendar->Create(m_parentAsWindow,
GetID(),
wxDefaultDateTime,
/*TODO: take it from resource*/
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(calendar);
return calendar;
}
bool wxCalendarCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxCalendarCtrl"));
}
#endif // wxUSE_XRC && wxUSE_CALENDARCTRL

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_chckb.cpp
// Purpose: XRC resource for wxCheckBox
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_CHECKBOX
#include "wx/xrc/xh_chckb.h"
#ifndef WX_PRECOMP
#include "wx/checkbox.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCheckBoxXmlHandler, wxXmlResourceHandler)
wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxCHK_2STATE);
XRC_ADD_STYLE(wxCHK_3STATE);
XRC_ADD_STYLE(wxCHK_ALLOW_3RD_STATE_FOR_USER);
XRC_ADD_STYLE(wxALIGN_RIGHT);
AddWindowStyles();
}
wxObject *wxCheckBoxXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxCheckBox)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetValue(GetBool( wxT("checked")));
SetupWindow(control);
return control;
}
bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxCheckBox"));
}
#endif // wxUSE_XRC && wxUSE_CHECKBOX

View File

@ -0,0 +1,111 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_chckl.cpp
// Purpose: XRC resource for wxCheckListBox
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_CHECKLISTBOX
#include "wx/xrc/xh_chckl.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/checklst.h"
#endif
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler)
wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
: wxXmlResourceHandler(), m_insideBox(false)
{
// wxListBox styles:
XRC_ADD_STYLE(wxLB_SINGLE);
XRC_ADD_STYLE(wxLB_MULTIPLE);
XRC_ADD_STYLE(wxLB_EXTENDED);
XRC_ADD_STYLE(wxLB_HSCROLL);
XRC_ADD_STYLE(wxLB_ALWAYS_SB);
XRC_ADD_STYLE(wxLB_NEEDED_SB);
XRC_ADD_STYLE(wxLB_SORT);
AddWindowStyles();
}
wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
{
if (m_class == wxT("wxCheckListBox"))
{
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
XRC_MAKE_INSTANCE(control, wxCheckListBox)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
strList,
GetStyle(),
wxDefaultValidator,
GetName());
// step through children myself (again.)
wxXmlNode *n = GetParamNode(wxT("content"));
if (n)
n = n->GetChildren();
int i = 0;
while (n)
{
if (n->GetType() != wxXML_ELEMENT_NODE ||
n->GetName() != wxT("item"))
{ n = n->GetNext(); continue; }
// checking boolean is a bit ugly here (see GetBool() )
wxString v = n->GetAttribute(wxT("checked"), wxEmptyString);
v.MakeLower();
if (v == wxT("1"))
control->Check( i, true );
i++;
n = n->GetNext();
}
SetupWindow(control);
strList.Clear(); // dump the strings
return control;
}
else
{
// on the inside now.
// handle <item checked="boolean">Label</item>
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
str = wxGetTranslation(str, m_resource->GetDomain());
strList.Add(str);
return NULL;
}
}
bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxCheckListBox")) ||
(m_insideBox && node->GetName() == wxT("item")));
}
#endif // wxUSE_XRC && wxUSE_CHECKLISTBOX

View File

@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_choic.cpp
// Purpose: XRC resource for wxChoice
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_CHOICE
#include "wx/xrc/xh_choic.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/choice.h"
#endif
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
wxChoiceXmlHandler::wxChoiceXmlHandler()
: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SORT);
AddWindowStyles();
}
wxObject *wxChoiceXmlHandler::DoCreateResource()
{
if( m_class == wxT("wxChoice"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
XRC_MAKE_INSTANCE(control, wxChoice)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
strList,
GetStyle(),
wxDefaultValidator,
GetName());
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
strList.Clear(); // dump the strings
return control;
}
else
{
// on the inside now.
// handle <item>Label</item>
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
str = wxGetTranslation(str, m_resource->GetDomain());
strList.Add(str);
return NULL;
}
}
bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxChoice")) ||
(m_insideBox && node->GetName() == wxT("item")));
}
#endif // wxUSE_XRC && wxUSE_CHOICE

View File

@ -0,0 +1,143 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_choicbk.cpp
// Purpose: XRC resource for wxChoicebook
// Author: Vaclav Slavik
// Created: 2000/03/21
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_CHOICEBOOK
#include "wx/xrc/xh_choicbk.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/sizer.h"
#endif
#include "wx/choicebk.h"
#include "wx/imaglist.h"
IMPLEMENT_DYNAMIC_CLASS(wxChoicebookXmlHandler, wxXmlResourceHandler)
wxChoicebookXmlHandler::wxChoicebookXmlHandler()
:wxXmlResourceHandler(),
m_isInside(false),
m_choicebook(NULL)
{
XRC_ADD_STYLE(wxBK_DEFAULT);
XRC_ADD_STYLE(wxBK_LEFT);
XRC_ADD_STYLE(wxBK_RIGHT);
XRC_ADD_STYLE(wxBK_TOP);
XRC_ADD_STYLE(wxBK_BOTTOM);
XRC_ADD_STYLE(wxCHB_DEFAULT);
XRC_ADD_STYLE(wxCHB_LEFT);
XRC_ADD_STYLE(wxCHB_RIGHT);
XRC_ADD_STYLE(wxCHB_TOP);
XRC_ADD_STYLE(wxCHB_BOTTOM);
AddWindowStyles();
}
wxObject *wxChoicebookXmlHandler::DoCreateResource()
{
if (m_class == wxT("choicebookpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_choicebook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
m_choicebook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected")));
if ( HasParam(wxT("bitmap")) )
{
wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
wxImageList *imgList = m_choicebook->GetImageList();
if ( imgList == NULL )
{
imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
m_choicebook->AssignImageList( imgList );
}
int imgIndex = imgList->Add(bmp);
m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, imgIndex );
}
else if ( HasParam(wxT("image")) )
{
if ( m_choicebook->GetImageList() )
{
m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1,
GetLong(wxT("image")) );
}
else // image without image list?
{
ReportError(n, "image can only be used in conjunction "
"with imagelist");
}
}
}
else
{
ReportError(n, "choicebookpage child must be a window");
}
return wnd;
}
else
{
ReportError("choicebookpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(nb, wxChoicebook)
nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
GetName());
wxImageList *imagelist = GetImageList();
if ( imagelist )
nb->AssignImageList(imagelist);
wxChoicebook *old_par = m_choicebook;
m_choicebook = nb;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_choicebook, true/*only this handler*/);
m_isInside = old_ins;
m_choicebook = old_par;
return nb;
}
}
bool wxChoicebookXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxChoicebook"))) ||
(m_isInside && IsOfClass(node, wxT("choicebookpage"))));
}
#endif // wxUSE_XRC && wxUSE_CHOICEBOOK

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_clrpicker.cpp
// Purpose: XML resource handler for wxColourPickerCtrl
// Author: Francesco Montorsi
// Created: 2006-04-17
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_COLOURPICKERCTRL
#include "wx/xrc/xh_clrpicker.h"
#include "wx/clrpicker.h"
IMPLEMENT_DYNAMIC_CLASS(wxColourPickerCtrlXmlHandler, wxXmlResourceHandler)
wxColourPickerCtrlXmlHandler::wxColourPickerCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxCLRP_USE_TEXTCTRL);
XRC_ADD_STYLE(wxCLRP_SHOW_LABEL);
XRC_ADD_STYLE(wxCLRP_DEFAULT_STYLE);
AddWindowStyles();
}
wxObject *wxColourPickerCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(picker, wxColourPickerCtrl)
picker->Create(m_parentAsWindow,
GetID(),
GetColour(wxT("value"), *wxBLACK),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxCLRP_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
SetupWindow(picker);
return picker;
}
bool wxColourPickerCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxColourPickerCtrl"));
}
#endif // wxUSE_XRC && wxUSE_COLOURPICKERCTRL

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_cmdlinkbn.cpp
// Purpose: XRC resource for command link buttons
// Author: Kinaou Herve
// Created: 2010/10/20
// Copyright:
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_COMMANDLINKBUTTON
#include "wx/xrc/xh_cmdlinkbn.h"
#include "wx/commandlinkbutton.h"
IMPLEMENT_DYNAMIC_CLASS(wxCommandLinkButtonXmlHandler, wxXmlResourceHandler)
wxCommandLinkButtonXmlHandler::wxCommandLinkButtonXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT);
XRC_ADD_STYLE(wxBU_TOP);
XRC_ADD_STYLE(wxBU_BOTTOM);
XRC_ADD_STYLE(wxBU_EXACTFIT);
AddWindowStyles();
}
wxObject *wxCommandLinkButtonXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(button, wxCommandLinkButton)
button->Create(m_parentAsWindow,
GetID(),
GetText(wxS("label")),
GetText(wxS("note")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
SetupWindow(button);
return button;
}
bool wxCommandLinkButtonXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxS("wxCommandLinkButton"));
}
#endif // wxUSE_XRC && wxUSE_COMMANDLINKBUTTON

View File

@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_collpane.cpp
// Purpose: XML resource handler for wxCollapsiblePane
// Author: Francesco Montorsi
// Created: 2006-10-27
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_COLLPANE
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif
#include "wx/collpane.h"
#include "wx/xrc/xh_collpane.h"
IMPLEMENT_DYNAMIC_CLASS(wxCollapsiblePaneXmlHandler, wxXmlResourceHandler)
wxCollapsiblePaneXmlHandler::wxCollapsiblePaneXmlHandler()
: wxXmlResourceHandler(), m_isInside(false)
{
XRC_ADD_STYLE(wxCP_NO_TLW_RESIZE);
XRC_ADD_STYLE(wxCP_DEFAULT_STYLE);
AddWindowStyles();
}
wxObject *wxCollapsiblePaneXmlHandler::DoCreateResource()
{
if (m_class == wxT("panewindow")) // read the XRC for the pane window
{
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_collpane->GetPane(), NULL);
m_isInside = old_ins;
return item;
}
else
{
ReportError("no control within panewindow");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(ctrl, wxCollapsiblePane)
wxString label = GetParamValue(wxT("label"));
if (label.empty())
{
ReportParamError("label", "label cannot be empty");
return NULL;
}
ctrl->Create(m_parentAsWindow,
GetID(),
label,
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxCP_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
ctrl->Collapse(GetBool(wxT("collapsed")));
SetupWindow(ctrl);
wxCollapsiblePane *old_par = m_collpane;
m_collpane = ctrl;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_collpane, true/*only this handler*/);
m_isInside = old_ins;
m_collpane = old_par;
return ctrl;
}
}
bool wxCollapsiblePaneXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxCollapsiblePane")) ||
(m_isInside && IsOfClass(node, wxT("panewindow")));
}
#endif // wxUSE_XRC && wxUSE_COLLPANE

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_combo.cpp
// Purpose: XRC resource for wxComboBox
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_COMBOBOX
#include "wx/xrc/xh_combo.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/combobox.h"
#include "wx/textctrl.h" // for wxTE_PROCESS_ENTER
#endif
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler)
wxComboBoxXmlHandler::wxComboBoxXmlHandler()
:wxXmlResourceHandler()
,m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SIMPLE);
XRC_ADD_STYLE(wxCB_SORT);
XRC_ADD_STYLE(wxCB_READONLY);
XRC_ADD_STYLE(wxCB_DROPDOWN);
XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
AddWindowStyles();
}
wxObject *wxComboBoxXmlHandler::DoCreateResource()
{
if( m_class == wxT("wxComboBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
XRC_MAKE_INSTANCE(control, wxComboBox)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
strList,
GetStyle(),
wxDefaultValidator,
GetName());
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
strList.Clear(); // dump the strings
return control;
}
else
{
// on the inside now.
// handle <item>Label</item>
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
str = wxGetTranslation(str, m_resource->GetDomain());
strList.Add(str);
return NULL;
}
}
bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxComboBox")) ||
(m_insideBox && node->GetName() == wxT("item")));
}
#endif // wxUSE_XRC && wxUSE_COMBOBOX

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_comboctrl.cpp
// Purpose: XRC resource for wxComboCtrl
// Author: Jaakko Salli
// Created: 2009/01/25
// Copyright: (c) 2009 Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_COMBOCTRL
#include "wx/xrc/xh_comboctrl.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/textctrl.h" // for wxTE_PROCESS_ENTER
#endif
#include "wx/combo.h"
IMPLEMENT_DYNAMIC_CLASS(wxComboCtrlXmlHandler, wxXmlResourceHandler)
wxComboCtrlXmlHandler::wxComboCtrlXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxCB_SORT);
XRC_ADD_STYLE(wxCB_READONLY);
XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
XRC_ADD_STYLE(wxCC_SPECIAL_DCLICK);
XRC_ADD_STYLE(wxCC_STD_BUTTON);
AddWindowStyles();
}
wxObject *wxComboCtrlXmlHandler::DoCreateResource()
{
if( m_class == wxT("wxComboCtrl"))
{
XRC_MAKE_INSTANCE(control, wxComboCtrl)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
SetupWindow(control);
return control;
}
return NULL;
}
bool wxComboCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxComboCtrl"));
}
#endif // wxUSE_XRC && wxUSE_COMBOBOX

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_datectrl.cpp
// Purpose: XML resource handler for wxDatePickerCtrl
// Author: Vaclav Slavik
// Created: 2005-02-07
// Copyright: (c) 2005 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_DATEPICKCTRL
#include "wx/xrc/xh_datectrl.h"
#include "wx/datectrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxDateCtrlXmlHandler, wxXmlResourceHandler)
wxDateCtrlXmlHandler::wxDateCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxDP_DEFAULT);
XRC_ADD_STYLE(wxDP_SPIN);
XRC_ADD_STYLE(wxDP_DROPDOWN);
XRC_ADD_STYLE(wxDP_ALLOWNONE);
XRC_ADD_STYLE(wxDP_SHOWCENTURY);
AddWindowStyles();
}
wxObject *wxDateCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(picker, wxDatePickerCtrl)
picker->Create(m_parentAsWindow,
GetID(),
wxDefaultDateTime,
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxDP_DEFAULT | wxDP_SHOWCENTURY),
wxDefaultValidator,
GetName());
SetupWindow(picker);
return picker;
}
bool wxDateCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxDatePickerCtrl"));
}
#endif // wxUSE_XRC && wxUSE_DATEPICKCTRL

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_dirpicker.cpp
// Purpose: XML resource handler for wxDirPickerCtrl
// Author: Francesco Montorsi
// Created: 2006-04-17
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_DIRPICKERCTRL
#include "wx/xrc/xh_dirpicker.h"
#include "wx/filepicker.h"
IMPLEMENT_DYNAMIC_CLASS(wxDirPickerCtrlXmlHandler, wxXmlResourceHandler)
wxDirPickerCtrlXmlHandler::wxDirPickerCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxDIRP_USE_TEXTCTRL);
XRC_ADD_STYLE(wxDIRP_DIR_MUST_EXIST);
XRC_ADD_STYLE(wxDIRP_CHANGE_DIR);
XRC_ADD_STYLE(wxDIRP_SMALL);
XRC_ADD_STYLE(wxDIRP_DEFAULT_STYLE);
AddWindowStyles();
}
wxObject *wxDirPickerCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(picker, wxDirPickerCtrl)
picker->Create(m_parentAsWindow,
GetID(),
GetParamValue(wxT("value")),
GetText(wxT("message")),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxDIRP_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
SetupWindow(picker);
return picker;
}
bool wxDirPickerCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxDirPickerCtrl"));
}
#endif // wxUSE_XRC && wxUSE_DIRPICKERCTRL

View File

@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_dlg.cpp
// Purpose: XRC resource for dialogs
// Author: Vaclav Slavik
// Created: 2000/03/05
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_dlg.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/frame.h"
#include "wx/dialog.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxDialogXmlHandler, wxXmlResourceHandler)
wxDialogXmlHandler::wxDialogXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSTAY_ON_TOP);
XRC_ADD_STYLE(wxCAPTION);
XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
XRC_ADD_STYLE(wxSYSTEM_MENU);
XRC_ADD_STYLE(wxRESIZE_BORDER);
XRC_ADD_STYLE(wxCLOSE_BOX);
XRC_ADD_STYLE(wxDIALOG_NO_PARENT);
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
XRC_ADD_STYLE(wxDIALOG_EX_METAL);
XRC_ADD_STYLE(wxMAXIMIZE_BOX);
XRC_ADD_STYLE(wxMINIMIZE_BOX);
XRC_ADD_STYLE(wxFRAME_SHAPED);
XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxDIALOG_MODAL);
XRC_ADD_STYLE(wxTHICK_FRAME);
XRC_ADD_STYLE(wxRESIZE_BOX);
XRC_ADD_STYLE(wxDIALOG_MODELESS);
XRC_ADD_STYLE(wxNO_3D);
#endif // WXWIN_COMPATIBILITY_2_6
AddWindowStyles();
}
wxObject *wxDialogXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(dlg, wxDialog);
dlg->Create(m_parentAsWindow,
GetID(),
GetText(wxT("title")),
wxDefaultPosition, wxDefaultSize,
GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE),
GetName());
if (HasParam(wxT("size")))
dlg->SetClientSize(GetSize(wxT("size"), dlg));
if (HasParam(wxT("pos")))
dlg->Move(GetPosition());
if (HasParam(wxT("icon")))
dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON));
SetupWindow(dlg);
CreateChildren(dlg);
if (GetBool(wxT("centered"), false))
dlg->Centre();
return dlg;
}
bool wxDialogXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxDialog"));
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,123 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_editlbox.cpp
// Purpose: implementation of wxEditableListBox XRC handler
// Author: Vadim Zeitlin
// Created: 2009-06-04
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_EDITABLELISTBOX
#ifndef WX_PRECOMP
#include "wx/intl.h"
#endif // WX_PRECOMP
#include "wx/editlbox.h"
#include "wx/xrc/xh_editlbox.h"
#include "wx/xml/xml.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
namespace
{
const char * const EDITLBOX_CLASS_NAME = "wxEditableListBox";
const char * const EDITLBOX_ITEM_NAME = "item";
} // anonymous namespace
// ============================================================================
// implementation
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxEditableListBoxXmlHandler, wxXmlResourceHandler)
wxEditableListBoxXmlHandler::wxEditableListBoxXmlHandler()
{
m_insideBox = false;
XRC_ADD_STYLE(wxEL_ALLOW_NEW);
XRC_ADD_STYLE(wxEL_ALLOW_EDIT);
XRC_ADD_STYLE(wxEL_ALLOW_DELETE);
XRC_ADD_STYLE(wxEL_NO_REORDER);
AddWindowStyles();
}
wxObject *wxEditableListBoxXmlHandler::DoCreateResource()
{
if ( m_class == EDITLBOX_CLASS_NAME )
{
// create the control itself
XRC_MAKE_INSTANCE(control, wxEditableListBox)
control->Create
(
m_parentAsWindow,
GetID(),
GetText("label"),
GetPosition(),
GetSize(),
GetStyle(),
GetName()
);
SetupWindow(control);
// if any items are given, add them to the control
wxXmlNode * const contents = GetParamNode("content");
if ( contents )
{
m_insideBox = true;
CreateChildrenPrivately(NULL, contents);
m_insideBox = false;
control->SetStrings(m_items);
m_items.clear();
}
return control;
}
else if ( m_insideBox && m_node->GetName() == EDITLBOX_ITEM_NAME )
{
wxString str = GetNodeContent(m_node);
if ( m_resource->GetFlags() & wxXRC_USE_LOCALE )
str = wxGetTranslation(str, m_resource->GetDomain());
m_items.push_back(str);
return NULL;
}
else
{
ReportError("Unexpected node inside wxEditableListBox");
return NULL;
}
}
bool wxEditableListBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, EDITLBOX_CLASS_NAME) ||
(m_insideBox && node->GetName() == EDITLBOX_ITEM_NAME);
}
#endif // wxUSE_XRC && wxUSE_EDITABLELISTBOX

View File

@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_filectrl.cpp
// Purpose: XML resource handler for wxFileCtrl
// Author: Kinaou Hervé
// Created: 2009-05-11
// Copyright: (c) 2009 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_FILECTRL
#include "wx/xrc/xh_filectrl.h"
#include "wx/filectrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxFileCtrlXmlHandler, wxXmlResourceHandler)
wxFileCtrlXmlHandler::wxFileCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxFC_DEFAULT_STYLE);
XRC_ADD_STYLE(wxFC_OPEN);
XRC_ADD_STYLE(wxFC_SAVE);
XRC_ADD_STYLE(wxFC_MULTIPLE);
XRC_ADD_STYLE(wxFC_NOSHOWHIDDEN);
AddWindowStyles();
}
wxObject *wxFileCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(filectrl, wxFileCtrl)
filectrl->Create(m_parentAsWindow,
GetID(),
GetText(wxT("defaultdirectory")),
GetText(wxT("defaultfilename")),
GetParamValue(wxT("wildcard")),
GetStyle(wxT("style"), wxFC_DEFAULT_STYLE),
GetPosition(),
GetSize(),
GetName());
SetupWindow(filectrl);
return filectrl;
}
bool wxFileCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxFileCtrl"));
}
#endif // wxUSE_XRC && wxUSE_FILECTRL

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_filepicker.cpp
// Purpose: XML resource handler for wxFilePickerCtrl
// Author: Francesco Montorsi
// Created: 2006-04-17
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_FILEPICKERCTRL
#include "wx/xrc/xh_filepicker.h"
#include "wx/filepicker.h"
IMPLEMENT_DYNAMIC_CLASS(wxFilePickerCtrlXmlHandler, wxXmlResourceHandler)
wxFilePickerCtrlXmlHandler::wxFilePickerCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxFLP_OPEN);
XRC_ADD_STYLE(wxFLP_SAVE);
XRC_ADD_STYLE(wxFLP_OVERWRITE_PROMPT);
XRC_ADD_STYLE(wxFLP_FILE_MUST_EXIST);
XRC_ADD_STYLE(wxFLP_CHANGE_DIR);
XRC_ADD_STYLE(wxFLP_SMALL);
XRC_ADD_STYLE(wxFLP_DEFAULT_STYLE);
XRC_ADD_STYLE(wxFLP_USE_TEXTCTRL);
AddWindowStyles();
}
wxObject *wxFilePickerCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(picker, wxFilePickerCtrl)
picker->Create(m_parentAsWindow,
GetID(),
GetParamValue(wxT("value")),
GetText(wxT("message")),
GetParamValue(wxT("wildcard")),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxFLP_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
SetupWindow(picker);
return picker;
}
bool wxFilePickerCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxFilePickerCtrl"));
}
#endif // wxUSE_XRC && wxUSE_FILEPICKERCTRL

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_fontpicker.cpp
// Purpose: XML resource handler for wxFontPickerCtrl
// Author: Francesco Montorsi
// Created: 2006-04-17
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_FONTPICKERCTRL
#include "wx/xrc/xh_fontpicker.h"
#include "wx/fontpicker.h"
IMPLEMENT_DYNAMIC_CLASS(wxFontPickerCtrlXmlHandler, wxXmlResourceHandler)
wxFontPickerCtrlXmlHandler::wxFontPickerCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxFNTP_USE_TEXTCTRL);
XRC_ADD_STYLE(wxFNTP_FONTDESC_AS_LABEL);
XRC_ADD_STYLE(wxFNTP_USEFONT_FOR_LABEL);
XRC_ADD_STYLE(wxFNTP_DEFAULT_STYLE);
AddWindowStyles();
}
wxObject *wxFontPickerCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(picker, wxFontPickerCtrl)
wxFont f = *wxNORMAL_FONT;
if (HasParam(wxT("value")))
f = GetFont(wxT("value"));
picker->Create(m_parentAsWindow,
GetID(),
f,
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxFNTP_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
SetupWindow(picker);
return picker;
}
bool wxFontPickerCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxFontPickerCtrl"));
}
#endif // wxUSE_XRC && wxUSE_FONTPICKERCTRL

View File

@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_frame.cpp
// Purpose: XRC resource for dialogs
// Author: Vaclav Slavik & Aleks.
// Created: 2000/03/05
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_frame.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/frame.h"
#include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE
#endif
IMPLEMENT_DYNAMIC_CLASS(wxFrameXmlHandler, wxXmlResourceHandler)
wxFrameXmlHandler::wxFrameXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSTAY_ON_TOP);
XRC_ADD_STYLE(wxCAPTION);
XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTHICK_FRAME);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxSYSTEM_MENU);
XRC_ADD_STYLE(wxRESIZE_BORDER);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxRESIZE_BOX);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxCLOSE_BOX);
XRC_ADD_STYLE(wxFRAME_NO_TASKBAR);
XRC_ADD_STYLE(wxFRAME_SHAPED);
XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW);
XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT);
XRC_ADD_STYLE(wxMAXIMIZE_BOX);
XRC_ADD_STYLE(wxMINIMIZE_BOX);
XRC_ADD_STYLE(wxSTAY_ON_TOP);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxNO_3D);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
XRC_ADD_STYLE(wxFRAME_EX_METAL);
XRC_ADD_STYLE(wxFRAME_EX_CONTEXTHELP);
AddWindowStyles();
}
wxObject *wxFrameXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(frame, wxFrame);
frame->Create(m_parentAsWindow,
GetID(),
GetText(wxT("title")),
wxDefaultPosition, wxDefaultSize,
GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
GetName());
if (HasParam(wxT("size")))
frame->SetClientSize(GetSize(wxT("size"), frame));
if (HasParam(wxT("pos")))
frame->Move(GetPosition());
if (HasParam(wxT("icon")))
frame->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON));
SetupWindow(frame);
CreateChildren(frame);
if (GetBool(wxT("centered"), false))
frame->Centre();
return frame;
}
bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxFrame"));
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_gauge.cpp
// Purpose: XRC resource for wxGauge
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_GAUGE
#include "wx/xrc/xh_gauge.h"
#ifndef WX_PRECOMP
#include "wx/gauge.h"
#endif
static const long DEFAULT_RANGE = 100;
IMPLEMENT_DYNAMIC_CLASS(wxGaugeXmlHandler, wxXmlResourceHandler)
wxGaugeXmlHandler::wxGaugeXmlHandler()
:wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxGA_HORIZONTAL);
XRC_ADD_STYLE(wxGA_VERTICAL);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxGA_PROGRESSBAR);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxGA_SMOOTH); // windows only
AddWindowStyles();
}
wxObject *wxGaugeXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxGauge)
control->Create(m_parentAsWindow,
GetID(),
GetLong(wxT("range"), DEFAULT_RANGE),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if( HasParam(wxT("value")))
{
control->SetValue(GetLong(wxT("value")));
}
if( HasParam(wxT("shadow")))
{
control->SetShadowWidth(GetDimension(wxT("shadow")));
}
if( HasParam(wxT("bezel")))
{
control->SetBezelFace(GetDimension(wxT("bezel")));
}
SetupWindow(control);
return control;
}
bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxGauge"));
}
#endif // wxUSE_XRC && wxUSE_GAUGE

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_gdctl.cpp
// Purpose: XRC resource for wxGenericDirCtrl
// Author: Markus Greither
// Created: 2002/01/20
// Copyright: (c) 2002 Markus Greither
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_DIRDLG
#include "wx/xrc/xh_gdctl.h"
#ifndef WX_PRECOMP
#include "wx/textctrl.h"
#endif
#include "wx/dirctrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxGenericDirCtrlXmlHandler, wxXmlResourceHandler)
wxGenericDirCtrlXmlHandler::wxGenericDirCtrlXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxDIRCTRL_DIR_ONLY);
XRC_ADD_STYLE(wxDIRCTRL_3D_INTERNAL);
XRC_ADD_STYLE(wxDIRCTRL_SELECT_FIRST);
XRC_ADD_STYLE(wxDIRCTRL_SHOW_FILTERS);
XRC_ADD_STYLE(wxDIRCTRL_EDIT_LABELS);
XRC_ADD_STYLE(wxDIRCTRL_MULTIPLE);
AddWindowStyles();
}
wxObject *wxGenericDirCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(ctrl, wxGenericDirCtrl)
ctrl->Create(m_parentAsWindow,
GetID(),
GetText(wxT("defaultfolder")),
GetPosition(), GetSize(),
GetStyle(),
GetText(wxT("filter")),
(int)GetLong(wxT("defaultfilter")),
GetName());
SetupWindow(ctrl);
return ctrl;
}
bool wxGenericDirCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxGenericDirCtrl"));
}
#endif // wxUSE_XRC && wxUSE_DIRDLG

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_grid.cpp
// Purpose: XML resource handler for the grid control
// Author: Agron Selimaj
// Created: 2005/08/11
// Copyright: (c) 2005 Agron Selimaj, Freepour Controls Inc.
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_GRID
#include "wx/xrc/xh_grid.h"
#include "wx/grid.h"
IMPLEMENT_DYNAMIC_CLASS(wxGridXmlHandler, wxXmlResourceHandler)
wxGridXmlHandler::wxGridXmlHandler()
: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxGridXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(grid, wxGrid)
grid->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
GetName());
SetupWindow( grid);
return grid;
}
bool wxGridXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxGrid"));
}
#endif // wxUSE_XRC && wxUSE_GRID

View File

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_html.cpp
// Purpose: XRC resource for wxHtmlWindow
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_HTML
#include "wx/xrc/xh_html.h"
#include "wx/html/htmlwin.h"
#include "wx/filesys.h"
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler)
wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER);
XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO);
XRC_ADD_STYLE(wxHW_NO_SELECTION);
AddWindowStyles();
}
wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxHtmlWindow)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
GetName());
if (HasParam(wxT("borders")))
{
control->SetBorders(GetDimension(wxT("borders")));
}
if (HasParam(wxT("url")))
{
wxString url = GetParamValue(wxT("url"));
wxFileSystem& fsys = GetCurFileSystem();
wxFSFile *f = fsys.OpenFile(url);
if (f)
{
control->LoadPage(f->GetLocation());
delete f;
}
else
control->LoadPage(url);
}
else if (HasParam(wxT("htmlcode")))
{
control->SetPage(GetText(wxT("htmlcode")));
}
SetupWindow(control);
return control;
}
bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxHtmlWindow"));
}
#endif // wxUSE_XRC && wxUSE_HTML

View File

@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_simplehtmllbox.cpp
// Purpose: XML resource handler for wxSimpleHtmlListBox
// Author: Francesco Montorsi
// Created: 2006/10/21
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_HTML
#include "wx/xrc/xh_htmllbox.h"
#include "wx/htmllbox.h"
#include "wx/filesys.h"
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler, wxXmlResourceHandler)
wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler()
: wxXmlResourceHandler(), m_insideBox(false)
{
XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE);
XRC_ADD_STYLE(wxHLB_MULTIPLE);
AddWindowStyles();
}
wxObject *wxSimpleHtmlListBoxXmlHandler::DoCreateResource()
{
if ( m_class == wxT("wxSimpleHtmlListBox"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
m_insideBox = false;
XRC_MAKE_INSTANCE(control, wxSimpleHtmlListBox)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
strList,
GetStyle(wxT("style"), wxHLB_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
strList.Clear(); // dump the strings
return control;
}
else
{
// on the inside now.
// handle <item>Label</item>
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
str = wxGetTranslation(str, m_resource->GetDomain());
strList.Add(str);
return NULL;
}
}
bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxSimpleHtmlListBox")) ||
(m_insideBox && node->GetName() == wxT("item")));
}
#endif // wxUSE_XRC && wxUSE_HTML

View File

@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_hyperlink.cpp
// Purpose: Hyperlink control
// Author: David Norris <danorris@gmail.com>
// Modified by: Ryan Norton, Francesco Montorsi
// Created: 04/02/2005
// Copyright: (c) 2005 David Norris
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//===========================================================================
// Declarations
//===========================================================================
//---------------------------------------------------------------------------
// Pre-compiled header stuff
//---------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_HYPERLINKCTRL
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "wx/xrc/xh_hyperlink.h"
#ifndef WX_PRECOMP
#endif
#include "wx/hyperlink.h"
#include "wx/xrc/xmlres.h"
//===========================================================================
// Implementation
//===========================================================================
//---------------------------------------------------------------------------
// wxHyperlinkCtrlXmlHandler
//---------------------------------------------------------------------------
// Register with wxWindows' dynamic class subsystem.
IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkCtrlXmlHandler, wxXmlResourceHandler)
wxHyperlinkCtrlXmlHandler::wxHyperlinkCtrlXmlHandler()
{
XRC_ADD_STYLE(wxHL_CONTEXTMENU);
XRC_ADD_STYLE(wxHL_ALIGN_LEFT);
XRC_ADD_STYLE(wxHL_ALIGN_RIGHT);
XRC_ADD_STYLE(wxHL_ALIGN_CENTRE);
XRC_ADD_STYLE(wxHL_DEFAULT_STYLE);
AddWindowStyles();
}
wxObject *wxHyperlinkCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxHyperlinkCtrl)
control->Create
(
m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetParamValue(wxT("url")),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxHL_DEFAULT_STYLE),
GetName()
);
SetupWindow(control);
return control;
}
bool wxHyperlinkCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxHyperlinkCtrl"));
}
#endif // wxUSE_XRC && wxUSE_HYPERLINKCTRL

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_listb.cpp
// Purpose: XRC resource for wxListBox
// Author: Bob Mitchell & Vaclav Slavik
// Created: 2000/07/29
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_LISTBOX
#include "wx/xrc/xh_listb.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/listbox.h"
#endif
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler)
wxListBoxXmlHandler::wxListBoxXmlHandler()
: wxXmlResourceHandler(),
m_insideBox(false)
{
XRC_ADD_STYLE(wxLB_SINGLE);
XRC_ADD_STYLE(wxLB_MULTIPLE);
XRC_ADD_STYLE(wxLB_EXTENDED);
XRC_ADD_STYLE(wxLB_HSCROLL);
XRC_ADD_STYLE(wxLB_ALWAYS_SB);
XRC_ADD_STYLE(wxLB_NEEDED_SB);
XRC_ADD_STYLE(wxLB_SORT);
AddWindowStyles();
}
wxObject *wxListBoxXmlHandler::DoCreateResource()
{
if ( m_class == wxT("wxListBox"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
m_insideBox = false;
XRC_MAKE_INSTANCE(control, wxListBox)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
strList,
GetStyle(),
wxDefaultValidator,
GetName());
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
strList.Clear(); // dump the strings
return control;
}
else
{
// on the inside now.
// handle <item>Label</item>
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
str = wxGetTranslation(str, m_resource->GetDomain());
strList.Add(str);
return NULL;
}
}
bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxListBox")) ||
(m_insideBox && node->GetName() == wxT("item")));
}
#endif // wxUSE_XRC && wxUSE_LISTBOX

View File

@ -0,0 +1,143 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_listbk.cpp
// Purpose: XRC resource for wxListbook
// Author: Vaclav Slavik
// Created: 2000/03/21
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_LISTBOOK
#include "wx/xrc/xh_listbk.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/sizer.h"
#endif
#include "wx/listbook.h"
#include "wx/imaglist.h"
IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler, wxXmlResourceHandler)
wxListbookXmlHandler::wxListbookXmlHandler()
:wxXmlResourceHandler(),
m_isInside(false),
m_listbook(NULL)
{
XRC_ADD_STYLE(wxBK_DEFAULT);
XRC_ADD_STYLE(wxBK_LEFT);
XRC_ADD_STYLE(wxBK_RIGHT);
XRC_ADD_STYLE(wxBK_TOP);
XRC_ADD_STYLE(wxBK_BOTTOM);
XRC_ADD_STYLE(wxLB_DEFAULT);
XRC_ADD_STYLE(wxLB_LEFT);
XRC_ADD_STYLE(wxLB_RIGHT);
XRC_ADD_STYLE(wxLB_TOP);
XRC_ADD_STYLE(wxLB_BOTTOM);
AddWindowStyles();
}
wxObject *wxListbookXmlHandler::DoCreateResource()
{
if (m_class == wxT("listbookpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_listbook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
m_listbook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected")));
if ( HasParam(wxT("bitmap")) )
{
wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
wxImageList *imgList = m_listbook->GetImageList();
if ( imgList == NULL )
{
imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
m_listbook->AssignImageList( imgList );
}
int imgIndex = imgList->Add(bmp);
m_listbook->SetPageImage(m_listbook->GetPageCount()-1, imgIndex );
}
else if ( HasParam(wxT("image")) )
{
if ( m_listbook->GetImageList() )
{
m_listbook->SetPageImage(m_listbook->GetPageCount()-1,
GetLong(wxT("image")) );
}
else // image without image list?
{
ReportError(n, "image can only be used in conjunction "
"with imagelist");
}
}
}
else
{
ReportError(n, "listbookpage child must be a window");
}
return wnd;
}
else
{
ReportError("listbookpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(nb, wxListbook)
nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
GetName());
wxImageList *imagelist = GetImageList();
if ( imagelist )
nb->AssignImageList(imagelist);
wxListbook *old_par = m_listbook;
m_listbook = nb;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_listbook, true/*only this handler*/);
m_isInside = old_ins;
m_listbook = old_par;
return nb;
}
}
bool wxListbookXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxListbook"))) ||
(m_isInside && IsOfClass(node, wxT("listbookpage"))));
}
#endif // wxUSE_XRC && wxUSE_LISTBOOK

View File

@ -0,0 +1,265 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_listc.cpp
// Purpose: XRC resource for wxListCtrl
// Author: Brian Gavin, Kinaou Hervé, Vadim Zeitlin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// (c) 2009 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_LISTCTRL
#include "wx/xrc/xh_listc.h"
#ifndef WX_PRECOMP
#include "wx/textctrl.h"
#endif
#include "wx/listctrl.h"
#include "wx/imaglist.h"
namespace
{
const char *LISTCTRL_CLASS_NAME = "wxListCtrl";
const char *LISTITEM_CLASS_NAME = "listitem";
const char *LISTCOL_CLASS_NAME = "listcol";
} // anonymous namespace
IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler)
wxListCtrlXmlHandler::wxListCtrlXmlHandler()
: wxXmlResourceHandler()
{
// wxListItem styles
XRC_ADD_STYLE(wxLIST_FORMAT_LEFT);
XRC_ADD_STYLE(wxLIST_FORMAT_RIGHT);
XRC_ADD_STYLE(wxLIST_FORMAT_CENTRE);
XRC_ADD_STYLE(wxLIST_MASK_STATE);
XRC_ADD_STYLE(wxLIST_MASK_TEXT);
XRC_ADD_STYLE(wxLIST_MASK_IMAGE);
XRC_ADD_STYLE(wxLIST_MASK_DATA);
XRC_ADD_STYLE(wxLIST_MASK_WIDTH);
XRC_ADD_STYLE(wxLIST_MASK_FORMAT);
XRC_ADD_STYLE(wxLIST_STATE_FOCUSED);
XRC_ADD_STYLE(wxLIST_STATE_SELECTED);
// wxListCtrl styles
XRC_ADD_STYLE(wxLC_LIST);
XRC_ADD_STYLE(wxLC_REPORT);
XRC_ADD_STYLE(wxLC_ICON);
XRC_ADD_STYLE(wxLC_SMALL_ICON);
XRC_ADD_STYLE(wxLC_ALIGN_TOP);
XRC_ADD_STYLE(wxLC_ALIGN_LEFT);
XRC_ADD_STYLE(wxLC_AUTOARRANGE);
XRC_ADD_STYLE(wxLC_USER_TEXT);
XRC_ADD_STYLE(wxLC_EDIT_LABELS);
XRC_ADD_STYLE(wxLC_NO_HEADER);
XRC_ADD_STYLE(wxLC_SINGLE_SEL);
XRC_ADD_STYLE(wxLC_SORT_ASCENDING);
XRC_ADD_STYLE(wxLC_SORT_DESCENDING);
XRC_ADD_STYLE(wxLC_VIRTUAL);
XRC_ADD_STYLE(wxLC_HRULES);
XRC_ADD_STYLE(wxLC_VRULES);
XRC_ADD_STYLE(wxLC_NO_SORT_HEADER);
AddWindowStyles();
}
wxObject *wxListCtrlXmlHandler::DoCreateResource()
{
if ( m_class == LISTITEM_CLASS_NAME )
{
HandleListItem();
}
else if ( m_class == LISTCOL_CLASS_NAME )
{
HandleListCol();
}
else
{
wxASSERT_MSG( m_class == LISTCTRL_CLASS_NAME,
"can't handle unknown node" );
return HandleListCtrl();
}
return m_parentAsWindow;
}
bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, LISTCTRL_CLASS_NAME) ||
IsOfClass(node, LISTITEM_CLASS_NAME) ||
IsOfClass(node, LISTCOL_CLASS_NAME);
}
void wxListCtrlXmlHandler::HandleCommonItemAttrs(wxListItem& item)
{
if (HasParam(wxT("align")))
item.SetAlign((wxListColumnFormat)GetStyle(wxT("align")));
if (HasParam(wxT("text")))
item.SetText(GetText(wxT("text")));
}
void wxListCtrlXmlHandler::HandleListCol()
{
wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl);
wxCHECK_RET( list, "must have wxListCtrl parent" );
if ( !list->HasFlag(wxLC_REPORT) )
{
ReportError("Only report mode list controls can have columns.");
return;
}
wxListItem item;
HandleCommonItemAttrs(item);
if (HasParam(wxT("width")))
item.SetWidth((int)GetLong(wxT("width")));
if (HasParam(wxT("image")))
item.SetImage((int)GetLong(wxT("image")));
list->InsertColumn(list->GetColumnCount(), item);
}
void wxListCtrlXmlHandler::HandleListItem()
{
wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl);
wxCHECK_RET( list, "must have wxListCtrl parent" );
wxListItem item;
HandleCommonItemAttrs(item);
if (HasParam(wxT("bg")))
item.SetBackgroundColour(GetColour(wxT("bg")));
if (HasParam(wxT("col")))
item.SetColumn((int)GetLong(wxT("col")));
if (HasParam(wxT("data")))
item.SetData(GetLong(wxT("data")));
if (HasParam(wxT("font")))
item.SetFont(GetFont(wxT("font"), list));
if (HasParam(wxT("state")))
item.SetState(GetStyle(wxT("state")));
if (HasParam(wxT("textcolour")))
item.SetTextColour(GetColour(wxT("textcolour")));
if (HasParam(wxT("textcolor")))
item.SetTextColour(GetColour(wxT("textcolor")));
// the list control icon style, may be 0
int image;
if ( list->HasFlag(wxLC_ICON) )
image = GetImageIndex(list, wxIMAGE_LIST_NORMAL);
else if ( list->HasFlag(wxLC_SMALL_ICON) || list->HasFlag(wxLC_REPORT) || list->HasFlag(wxLC_LIST) )
image = GetImageIndex(list, wxIMAGE_LIST_SMALL);
else
image = wxNOT_FOUND;
if ( image != wxNOT_FOUND )
item.SetImage(image);
// append the list item to the control
item.SetId(list->GetItemCount());
list->InsertItem(item);
}
wxListCtrl *wxListCtrlXmlHandler::HandleListCtrl()
{
XRC_MAKE_INSTANCE(list, wxListCtrl)
list->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
// we can optionally have normal and/or small image lists
wxImageList *imagelist;
imagelist = GetImageList(wxT("imagelist"));
if ( imagelist )
list->AssignImageList(imagelist, wxIMAGE_LIST_NORMAL);
imagelist = GetImageList(wxT("imagelist-small"));
if ( imagelist )
list->AssignImageList(imagelist, wxIMAGE_LIST_SMALL);
CreateChildrenPrivately(list);
SetupWindow(list);
return list;
}
long wxListCtrlXmlHandler::GetImageIndex(wxListCtrl *listctrl, int which)
{
// use different tag names depending on whether we need a normal or small
// image
wxString
bmpParam("bitmap"),
imgParam("image");
switch ( which )
{
case wxIMAGE_LIST_SMALL:
bmpParam += "-small";
imgParam += "-small";
break;
case wxIMAGE_LIST_NORMAL:
// nothing to do
break;
default:
wxFAIL_MSG( "unsupported image list kind" );
return wxNOT_FOUND;
}
// look for either bitmap or image tags
int imgIndex = wxNOT_FOUND;
if ( HasParam(bmpParam) )
{
// we implicitly construct an image list containing the specified
// bitmaps
wxBitmap bmp = GetBitmap(bmpParam, wxART_OTHER);
// create the image list on demand for the first bitmap
wxImageList *imgList = listctrl->GetImageList(which);
if ( !imgList )
{
imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
listctrl->AssignImageList( imgList, which );
}
imgIndex = imgList->Add(bmp);
}
if ( HasParam(imgParam) )
{
if ( imgIndex != wxNOT_FOUND )
{
// TODO: we should really check that only bitmap or only image tags
// are used across all items of the control, not just in this
// one
ReportError(wxString::Format(
"listitem %s attribute ignored because %s is also specified",
bmpParam, imgParam));
}
// just use the specified index directly
imgIndex = GetLong(imgParam);
}
return imgIndex;
}
#endif // wxUSE_XRC && wxUSE_LISTCTRL

View File

@ -0,0 +1,138 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_mdi.cpp
// Purpose: XRC resource for wxMDI
// Author: David M. Falkinder & Vaclav Slavik
// Created: 14/02/2005
// Copyright: (c) 2005 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_MDI
#include "wx/xrc/xh_mdi.h"
#include "wx/mdi.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/dialog.h" // to get wxDEFAULT_DIALOG_STYLE
#endif
IMPLEMENT_DYNAMIC_CLASS(wxMdiXmlHandler, wxXmlResourceHandler)
wxMdiXmlHandler::wxMdiXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSTAY_ON_TOP);
XRC_ADD_STYLE(wxCAPTION);
XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
XRC_ADD_STYLE(wxDEFAULT_FRAME_STYLE);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTHICK_FRAME);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxSYSTEM_MENU);
XRC_ADD_STYLE(wxRESIZE_BORDER);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxRESIZE_BOX);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxCLOSE_BOX);
XRC_ADD_STYLE(wxFRAME_NO_TASKBAR);
XRC_ADD_STYLE(wxFRAME_SHAPED);
XRC_ADD_STYLE(wxFRAME_TOOL_WINDOW);
XRC_ADD_STYLE(wxFRAME_FLOAT_ON_PARENT);
XRC_ADD_STYLE(wxMAXIMIZE_BOX);
XRC_ADD_STYLE(wxMINIMIZE_BOX);
XRC_ADD_STYLE(wxSTAY_ON_TOP);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxNO_3D);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
XRC_ADD_STYLE(wxFRAME_EX_METAL);
XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxVSCROLL);
XRC_ADD_STYLE(wxMAXIMIZE);
XRC_ADD_STYLE(wxFRAME_NO_WINDOW_MENU);
AddWindowStyles();
}
wxWindow *wxMdiXmlHandler::CreateFrame()
{
if (m_class == wxT("wxMDIParentFrame"))
{
XRC_MAKE_INSTANCE(frame, wxMDIParentFrame);
frame->Create(m_parentAsWindow,
GetID(),
GetText(wxT("title")),
wxDefaultPosition, wxDefaultSize,
GetStyle(wxT("style"),
wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL),
GetName());
return frame;
}
else // wxMDIChildFrame
{
wxMDIParentFrame *mdiParent = wxDynamicCast(m_parent, wxMDIParentFrame);
if ( !mdiParent )
{
ReportError("parent of wxMDIChildFrame must be wxMDIParentFrame");
return NULL;
}
XRC_MAKE_INSTANCE(frame, wxMDIChildFrame);
frame->Create(mdiParent,
GetID(),
GetText(wxT("title")),
wxDefaultPosition, wxDefaultSize,
GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
GetName());
return frame;
}
}
wxObject *wxMdiXmlHandler::DoCreateResource()
{
wxWindow *frame = CreateFrame();
if (HasParam(wxT("size")))
frame->SetClientSize(GetSize());
if (HasParam(wxT("pos")))
frame->Move(GetPosition());
if (HasParam(wxT("icon")))
{
wxFrame* f = wxDynamicCast(frame, wxFrame);
if (f)
f->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON));
}
SetupWindow(frame);
CreateChildren(frame);
if (GetBool(wxT("centered"), false))
frame->Centre();
return frame;
}
bool wxMdiXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxMDIParentFrame")) ||
IsOfClass(node, wxT("wxMDIChildFrame")));
}
#endif // wxUSE_XRC && wxUSE_MDI

View File

@ -0,0 +1,180 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_menu.cpp
// Purpose: XRC resource for menus and menubars
// Author: Vaclav Slavik
// Created: 2000/03/05
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_MENUS
#include "wx/xrc/xh_menu.h"
#ifndef WX_PRECOMP
#include "wx/frame.h"
#include "wx/log.h"
#include "wx/menu.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxMenuXmlHandler, wxXmlResourceHandler)
wxMenuXmlHandler::wxMenuXmlHandler() :
wxXmlResourceHandler(), m_insideMenu(false)
{
XRC_ADD_STYLE(wxMENU_TEAROFF);
}
wxObject *wxMenuXmlHandler::DoCreateResource()
{
if (m_class == wxT("wxMenu"))
{
wxMenu *menu = m_instance ? wxStaticCast(m_instance, wxMenu)
: new wxMenu(GetStyle());
wxString title = GetText(wxT("label"));
wxString help = GetText(wxT("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);
if (HasParam(wxT("enabled")))
p_menu->Enable(GetID(), GetBool(wxT("enabled")));
}
}
return menu;
}
else
{
wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
if (m_class == wxT("separator"))
p_menu->AppendSeparator();
else if (m_class == wxT("break"))
p_menu->Break();
else /*wxMenuItem*/
{
int id = GetID();
wxString label = GetText(wxT("label"));
wxString accel = GetText(wxT("accel"), false);
wxString fullLabel = label;
if (!accel.empty())
fullLabel << wxT("\t") << accel;
wxItemKind kind = wxITEM_NORMAL;
if (GetBool(wxT("radio")))
kind = wxITEM_RADIO;
if (GetBool(wxT("checkable")))
{
if ( kind != wxITEM_NORMAL )
{
ReportParamError
(
"checkable",
"menu item can't have both <radio> and <checkable> properties"
);
}
kind = wxITEM_CHECK;
}
wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
GetText(wxT("help")), kind);
#if (!defined(__WXMSW__) && !defined(__WXPM__)) || wxUSE_OWNER_DRAWN
if (HasParam(wxT("bitmap")))
{
// currently only wxMSW has support for using different checked
// and unchecked bitmaps for menu items
#ifdef __WXMSW__
if (HasParam(wxT("bitmap2")))
mitem->SetBitmaps(GetBitmap(wxT("bitmap2"), wxART_MENU),
GetBitmap(wxT("bitmap"), wxART_MENU));
else
#endif // __WXMSW__
mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
}
#endif
p_menu->Append(mitem);
mitem->Enable(GetBool(wxT("enabled"), true));
if (kind == wxITEM_CHECK)
mitem->Check(GetBool(wxT("checked")));
}
return NULL;
}
}
bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxMenu")) ||
(m_insideMenu &&
(IsOfClass(node, wxT("wxMenuItem")) ||
IsOfClass(node, wxT("break")) ||
IsOfClass(node, wxT("separator")))
);
}
IMPLEMENT_DYNAMIC_CLASS(wxMenuBarXmlHandler, wxXmlResourceHandler)
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxMB_DOCKABLE);
}
wxObject *wxMenuBarXmlHandler::DoCreateResource()
{
wxMenuBar *menubar = NULL;
const int style = GetStyle();
wxASSERT_MSG(!style || !m_instance,
"cannot use <style> with pre-created menubar");
if ( m_instance )
menubar = wxDynamicCast(m_instance, wxMenuBar);
if ( !menubar )
menubar = new wxMenuBar(style);
CreateChildren(menubar);
if (m_parentAsWindow)
{
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
if (parentFrame)
parentFrame->SetMenuBar(menubar);
}
return menubar;
}
bool wxMenuBarXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxMenuBar"));
}
#endif // wxUSE_XRC && wxUSE_MENUS

View File

@ -0,0 +1,150 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_notbk.cpp
// Purpose: XRC resource for wxNotebook
// Author: Vaclav Slavik
// Created: 2000/03/21
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_NOTEBOOK
#include "wx/xrc/xh_notbk.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/sizer.h"
#endif
#include "wx/notebook.h"
#include "wx/imaglist.h"
IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
wxNotebookXmlHandler::wxNotebookXmlHandler()
:wxXmlResourceHandler(),
m_isInside(false),
m_notebook(NULL)
{
XRC_ADD_STYLE(wxBK_DEFAULT);
XRC_ADD_STYLE(wxBK_LEFT);
XRC_ADD_STYLE(wxBK_RIGHT);
XRC_ADD_STYLE(wxBK_TOP);
XRC_ADD_STYLE(wxBK_BOTTOM);
// provide the old synonyms for these fields as well
XRC_ADD_STYLE(wxNB_DEFAULT);
XRC_ADD_STYLE(wxNB_LEFT);
XRC_ADD_STYLE(wxNB_RIGHT);
XRC_ADD_STYLE(wxNB_TOP);
XRC_ADD_STYLE(wxNB_BOTTOM);
XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
XRC_ADD_STYLE(wxNB_MULTILINE);
XRC_ADD_STYLE(wxNB_NOPAGETHEME);
AddWindowStyles();
}
wxObject *wxNotebookXmlHandler::DoCreateResource()
{
if (m_class == wxT("notebookpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_notebook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
m_notebook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected")));
if ( HasParam(wxT("bitmap")) )
{
wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
wxImageList *imgList = m_notebook->GetImageList();
if ( imgList == NULL )
{
imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
m_notebook->AssignImageList( imgList );
}
int imgIndex = imgList->Add(bmp);
m_notebook->SetPageImage(m_notebook->GetPageCount()-1, imgIndex );
}
else if ( HasParam(wxT("image")) )
{
if ( m_notebook->GetImageList() )
{
m_notebook->SetPageImage(m_notebook->GetPageCount()-1,
GetLong(wxT("image")) );
}
else // image without image list?
{
ReportError(n, "image can only be used in conjunction "
"with imagelist");
}
}
}
else
{
ReportError(n, "notebookpage child must be a window");
}
return wnd;
}
else
{
ReportError("notebookpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(nb, wxNotebook)
nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
GetName());
wxImageList *imagelist = GetImageList();
if ( imagelist )
nb->AssignImageList(imagelist);
SetupWindow(nb);
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 && IsOfClass(node, wxT("wxNotebook"))) ||
(m_isInside && IsOfClass(node, wxT("notebookpage"))));
}
#endif // wxUSE_XRC && wxUSE_NOTEBOOK

View File

@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_odcombo.cpp
// Purpose: XRC resource for wxRadioBox
// Author: Alex Bligh - Based on src/xrc/xh_combo.cpp
// Created: 2006/06/19
// Copyright: (c) 2006 Alex Bligh
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_ODCOMBOBOX
#include "wx/xrc/xh_odcombo.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/textctrl.h"
#endif
#include "wx/odcombo.h"
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxOwnerDrawnComboBoxXmlHandler, wxXmlResourceHandler)
wxOwnerDrawnComboBoxXmlHandler::wxOwnerDrawnComboBoxXmlHandler()
:wxXmlResourceHandler()
,m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SIMPLE);
XRC_ADD_STYLE(wxCB_SORT);
XRC_ADD_STYLE(wxCB_READONLY);
XRC_ADD_STYLE(wxCB_DROPDOWN);
XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT);
XRC_ADD_STYLE(wxODCB_DCLICK_CYCLES);
XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
AddWindowStyles();
}
wxObject *wxOwnerDrawnComboBoxXmlHandler::DoCreateResource()
{
if( m_class == wxT("wxOwnerDrawnComboBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
XRC_MAKE_INSTANCE(control, wxOwnerDrawnComboBox)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
strList,
GetStyle(),
wxDefaultValidator,
GetName());
wxSize sizeBtn=GetSize(wxT("buttonsize"));
if (sizeBtn != wxDefaultSize)
control->SetButtonPosition(sizeBtn.GetWidth(), sizeBtn.GetHeight());
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
strList.Clear(); // dump the strings
return control;
}
else
{
// on the inside now.
// handle <item>Label</item>
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
str = wxGetTranslation(str, m_resource->GetDomain());
strList.Add(str);
return NULL;
}
}
bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode *node)
{
#if wxCHECK_VERSION(2,7,0)
return (IsOfClass(node, wxT("wxOwnerDrawnComboBox")) ||
(m_insideBox && node->GetName() == wxT("item")));
#else
// Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason
// it is believed to be related to the fact IsOfClass is inline, and node->GetAttribute
// gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the
// above should work fine. This code is left in here so this file can easily be used
// in a version backported to 2.6. All we are doing here is expanding the macro
bool fOurClass = node->GetAttribute(wxT("class"), wxEmptyString) == wxT("wxOwnerDrawnComboBox");
return (fOurClass ||
(m_insideBox && node->GetName() == wxT("item")));
#endif
}
#endif // wxUSE_XRC && wxUSE_ODCOMBOBOX

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_panel.cpp
// Purpose: XRC resource for panels
// Author: Vaclav Slavik
// Created: 2000/03/05
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_panel.h"
#ifndef WX_PRECOMP
#include "wx/panel.h"
#include "wx/frame.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxPanelXmlHandler, wxXmlResourceHandler)
wxPanelXmlHandler::wxPanelXmlHandler() : wxXmlResourceHandler()
{
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxNO_3D);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
AddWindowStyles();
}
wxObject *wxPanelXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(panel, wxPanel)
panel->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxTAB_TRAVERSAL),
GetName());
SetupWindow(panel);
CreateChildren(panel);
return panel;
}
bool wxPanelXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxPanel"));
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,152 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_propdlg.cpp
// Purpose: XRC resource handler for wxPropertySheetDialog
// Author: Sander Berents
// Created: 2007/07/12
// Copyright: (c) 2007 Sander Berents
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_BOOKCTRL
#include "wx/xrc/xh_propdlg.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/sizer.h"
#include "wx/frame.h"
#endif
#include "wx/bookctrl.h"
#include "wx/propdlg.h"
#include "wx/imaglist.h"
IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialogXmlHandler, wxXmlResourceHandler)
wxPropertySheetDialogXmlHandler::wxPropertySheetDialogXmlHandler()
:wxXmlResourceHandler(),
m_isInside(false),
m_dialog(NULL)
{
XRC_ADD_STYLE(wxSTAY_ON_TOP);
XRC_ADD_STYLE(wxCAPTION);
XRC_ADD_STYLE(wxDEFAULT_DIALOG_STYLE);
XRC_ADD_STYLE(wxSYSTEM_MENU);
XRC_ADD_STYLE(wxRESIZE_BORDER);
XRC_ADD_STYLE(wxCLOSE_BOX);
XRC_ADD_STYLE(wxDIALOG_NO_PARENT);
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
XRC_ADD_STYLE(wxDIALOG_EX_METAL);
XRC_ADD_STYLE(wxMAXIMIZE_BOX);
XRC_ADD_STYLE(wxMINIMIZE_BOX);
XRC_ADD_STYLE(wxFRAME_SHAPED);
XRC_ADD_STYLE(wxDIALOG_EX_CONTEXTHELP);
AddWindowStyles();
}
wxObject *wxPropertySheetDialogXmlHandler::DoCreateResource()
{
if (m_class == wxT("propertysheetpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if (!n) n = GetParamNode(wxT("object_ref"));
if (n)
{
wxBookCtrlBase *bookctrl = m_dialog->GetBookCtrl();
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, bookctrl, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
bookctrl->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")));
if (HasParam(wxT("bitmap")))
{
wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
wxImageList *imgList = bookctrl->GetImageList();
if (imgList == NULL)
{
imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
bookctrl->AssignImageList(imgList);
}
int imgIndex = imgList->Add(bmp);
bookctrl->SetPageImage(bookctrl->GetPageCount()-1, imgIndex);
}
}
else
{
ReportError(n, "propertysheetpage child must be a window");
}
return wnd;
}
else
{
ReportError("propertysheetpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(dlg, wxPropertySheetDialog)
dlg->Create(m_parentAsWindow,
GetID(),
GetText(wxT("title")),
GetPosition(),
GetSize(),
GetStyle(),
GetName());
if (HasParam(wxT("icon")))
dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON));
SetupWindow(dlg);
wxPropertySheetDialog *old_par = m_dialog;
m_dialog = dlg;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_dialog, true/*only this handler*/);
m_isInside = old_ins;
m_dialog = old_par;
if (GetBool(wxT("centered"), false)) dlg->Centre();
wxString buttons = GetText(wxT("buttons"));
if (!buttons.IsEmpty())
{
int flags = 0;
if (buttons.Find(wxT("wxOK")) != wxNOT_FOUND) flags |= wxOK;
if (buttons.Find(wxT("wxCANCEL")) != wxNOT_FOUND) flags |= wxCANCEL;
if (buttons.Find(wxT("wxYES")) != wxNOT_FOUND) flags |= wxYES;
if (buttons.Find(wxT("wxNO")) != wxNOT_FOUND) flags |= wxNO;
if (buttons.Find(wxT("wxHELP")) != wxNOT_FOUND) flags |= wxHELP;
if (buttons.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND) flags |= wxNO_DEFAULT;
dlg->CreateButtons(flags);
}
return dlg;
}
}
bool wxPropertySheetDialogXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxPropertySheetDialog"))) ||
(m_isInside && IsOfClass(node, wxT("propertysheetpage"))));
}
#endif // wxUSE_XRC && wxUSE_BOOKCTRL

View File

@ -0,0 +1,65 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_radbt.cpp
// Purpose: XRC resource for wxRadioButton
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_RADIOBTN
#include "wx/xrc/xh_radbt.h"
#ifndef WX_PRECOMP
#include "wx/radiobut.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxRadioButtonXmlHandler, wxXmlResourceHandler)
wxRadioButtonXmlHandler::wxRadioButtonXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxRB_GROUP);
XRC_ADD_STYLE(wxRB_SINGLE);
AddWindowStyles();
}
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.
*/
XRC_MAKE_INSTANCE(control, wxRadioButton)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetValue(GetBool(wxT("value"), 0));
SetupWindow(control);
return control;
}
bool wxRadioButtonXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxRadioButton"));
}
#endif // wxUSE_XRC && wxUSE_RADIOBTN

View File

@ -0,0 +1,149 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_radbx.cpp
// Purpose: XRC resource for wxRadioBox
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_RADIOBOX
#include "wx/xrc/xh_radbx.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/radiobox.h"
#endif
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
: wxXmlResourceHandler(), m_insideBox(false)
{
XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
XRC_ADD_STYLE(wxRA_HORIZONTAL);
XRC_ADD_STYLE(wxRA_SPECIFY_ROWS);
XRC_ADD_STYLE(wxRA_VERTICAL);
AddWindowStyles();
}
wxObject *wxRadioBoxXmlHandler::DoCreateResource()
{
if ( m_class == wxT("wxRadioBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
m_insideBox = true;
CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
XRC_MAKE_INSTANCE(control, wxRadioBox)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
m_labels,
GetLong(wxT("dimension"), 1),
GetStyle(),
wxDefaultValidator,
GetName());
if (selection != -1)
control->SetSelection(selection);
SetupWindow(control);
const unsigned count = m_labels.size();
for( unsigned i = 0; i < count; i++ )
{
#if wxUSE_TOOLTIPS
if ( !m_tooltips[i].empty() )
control->SetItemToolTip(i, m_tooltips[i]);
#endif // wxUSE_TOOLTIPS
#if wxUSE_HELP
if ( m_helptextSpecified[i] )
control->SetItemHelpText(i, m_helptexts[i]);
#endif // wxUSE_HELP
if ( !m_isShown[i] )
control->Show(i, false);
if ( !m_isEnabled[i] )
control->Enable(i, false);
}
// forget information about the items of this radiobox, we should start
// afresh for the next one
m_labels.clear();
#if wxUSE_TOOLTIPS
m_tooltips.clear();
#endif // wxUSE_TOOLTIPS
#if wxUSE_HELP
m_helptexts.clear();
m_helptextSpecified.clear();
#endif // wxUSE_HELP
m_isShown.clear();
m_isEnabled.clear();
return control;
}
else // inside the radiobox element
{
// we handle handle <item>Label</item> constructs here, and the item
// tag can have tooltip, helptext, enabled and hidden attributes
wxString label = GetNodeContent(m_node);
wxString tooltip;
m_node->GetAttribute(wxT("tooltip"), &tooltip);
wxString helptext;
bool hasHelptext = m_node->GetAttribute(wxT("helptext"), &helptext);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
{
label = wxGetTranslation(label, m_resource->GetDomain());
if ( !tooltip.empty() )
tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
if ( hasHelptext )
helptext = wxGetTranslation(helptext, m_resource->GetDomain());
}
m_labels.push_back(label);
#if wxUSE_TOOLTIPS
m_tooltips.push_back(tooltip);
#endif // wxUSE_TOOLTIPS
#if wxUSE_HELP
m_helptexts.push_back(helptext);
m_helptextSpecified.push_back(hasHelptext);
#endif // wxUSE_HELP
m_isEnabled.push_back(GetBoolAttr("enabled", 1));
m_isShown.push_back(!GetBoolAttr("hidden", 0));
return NULL;
}
}
bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return (IsOfClass(node, wxT("wxRadioBox")) ||
(m_insideBox && node->GetName() == wxT("item")));
}
#endif // wxUSE_XRC && wxUSE_RADIOBOX

View File

@ -0,0 +1,335 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_ribbon.cpp
// Purpose: XML resource handler for wxRibbon related classes
// Author: Armel Asselin
// Created: 2010-04-23
// Copyright: (c) 2010 Armel Asselin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_RIBBON
#include "wx/xrc/xh_ribbon.h"
#include "wx/ribbon/bar.h"
#include "wx/ribbon/buttonbar.h"
#include "wx/ribbon/gallery.h"
#include "wx/scopeguard.h"
#ifndef WX_PRECOMP
#include "wx/menu.h"
#endif
// Ribbon bars can contain only pages which are usually panels but may contain
// any wxWindow.
//
// Panels are usually for wxRibbonControls but may as well contain any
// wxWindow.
//
// Galleries are wxRibbonControl and simply contain bitmaps with IDs.
//
// Button bars are wxRibbonControl and contain buttons (normal/dropdown/mixed),
// with id/bitmap/label/short help.
wxIMPLEMENT_DYNAMIC_CLASS(wxRibbonXmlHandler, wxXmlResourceHandler);
wxRibbonXmlHandler::wxRibbonXmlHandler()
: wxXmlResourceHandler(),
m_isInside(NULL)
{
XRC_ADD_STYLE(wxRIBBON_BAR_SHOW_PAGE_LABELS);
XRC_ADD_STYLE(wxRIBBON_BAR_SHOW_PAGE_ICONS);
XRC_ADD_STYLE(wxRIBBON_BAR_FLOW_HORIZONTAL);
XRC_ADD_STYLE(wxRIBBON_BAR_FLOW_VERTICAL);
XRC_ADD_STYLE(wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS);
XRC_ADD_STYLE(wxRIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS);
XRC_ADD_STYLE(wxRIBBON_BAR_ALWAYS_SHOW_TABS);
XRC_ADD_STYLE(wxRIBBON_BAR_DEFAULT_STYLE);
XRC_ADD_STYLE(wxRIBBON_BAR_FOLDBAR_STYLE);
}
wxObject *wxRibbonXmlHandler::DoCreateResource()
{
if (m_class == wxT("button"))
return Handle_button();
if (m_class == wxT("wxRibbonButtonBar"))
return Handle_buttonbar();
else if (m_class == wxT("item"))
return Handle_galleryitem();
else if (m_class == wxT("wxRibbonGallery"))
return Handle_gallery();
else if (m_class == wxT("wxRibbonPanel") || m_class == wxT("panel"))
return Handle_panel();
else if (m_class == wxT("wxRibbonPage") || m_class == wxT("page"))
return Handle_page();
else if (m_class == wxT("wxRibbonBar"))
return Handle_bar();
else
return Handle_control ();
}
bool wxRibbonXmlHandler::CanHandle(wxXmlNode *node)
{
return IsRibbonControl(node) ||
(m_isInside == &wxRibbonButtonBar::ms_classInfo &&
IsOfClass(node, wxT("button"))) ||
(m_isInside == &wxRibbonBar::ms_classInfo &&
IsOfClass(node, wxT("page"))) ||
(m_isInside == &wxRibbonPage::ms_classInfo &&
IsOfClass(node, wxT("panel"))) ||
(m_isInside == &wxRibbonGallery::ms_classInfo &&
IsOfClass(node, wxT("item")));
}
bool wxRibbonXmlHandler::IsRibbonControl (wxXmlNode *node)
{
return IsOfClass(node, wxT("wxRibbonBar")) ||
IsOfClass(node, wxT("wxRibbonButtonBar")) ||
IsOfClass(node, wxT("wxRibbonPage")) ||
IsOfClass(node, wxT("wxRibbonPanel")) ||
IsOfClass(node, wxT("wxRibbonGallery")) ||
IsOfClass(node, wxT("wxRibbonControl"));
}
void wxRibbonXmlHandler::Handle_RibbonArtProvider(wxRibbonControl *control)
{
wxString provider = GetText("art-provider", false);
if (provider == "default" || provider.IsEmpty())
control->SetArtProvider(new wxRibbonDefaultArtProvider);
else if (provider.CmpNoCase("aui") == 0)
control->SetArtProvider(new wxRibbonAUIArtProvider);
else if (provider.CmpNoCase("msw") == 0)
control->SetArtProvider(new wxRibbonMSWArtProvider);
else
ReportError("invalid ribbon art provider");
}
wxObject* wxRibbonXmlHandler::Handle_buttonbar()
{
XRC_MAKE_INSTANCE (buttonBar, wxRibbonButtonBar);
if (!buttonBar->Create (wxDynamicCast(m_parent, wxWindow), GetID(),
GetPosition(), GetSize(), GetStyle()))
{
ReportError("could not create ribbon panel");
}
else
{
const wxClassInfo* const wasInside = m_isInside;
wxON_BLOCK_EXIT_SET(m_isInside, wasInside);
m_isInside = &wxRibbonButtonBar::ms_classInfo;
CreateChildren (buttonBar, true);
buttonBar->Realize();
}
return buttonBar;
}
wxObject* wxRibbonXmlHandler::Handle_button()
{
wxRibbonButtonBar *buttonBar = wxStaticCast(m_parent, wxRibbonButtonBar);
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL;
if (GetBool(wxT("hybrid")))
kind = wxRIBBON_BUTTON_HYBRID;
// FIXME: The code below uses wxXmlNode directly but this can't be done
// in the ribbon library code as it would force it to always link
// with the xml library. Disable it for now but the real solution
// would be to virtualize GetChildren() and GetNext() methods via
// wxXmlResourceHandler, just as we already do for many others.
//
// FIXME: If re-enabling, don't forget to update the docs and RELAG NG schema!
#if 0 // wxUSE_MENUS
// check whether we have dropdown tag inside
wxMenu *menu = NULL; // menu for drop down items
wxXmlNode * const nodeDropdown = GetParamNode("dropdown");
if ( nodeDropdown )
{
if (kind == wxRIBBON_BUTTON_NORMAL)
kind = wxRIBBON_BUTTON_DROPDOWN;
// also check for the menu specified inside dropdown (it is
// optional and may be absent for e.g. dynamically-created
// menus)
wxXmlNode * const nodeMenu = nodeDropdown->GetChildren();
if ( nodeMenu )
{
wxObject *res = CreateResFromNode(nodeMenu, NULL);
menu = wxDynamicCast(res, wxMenu);
if ( !menu )
{
ReportError
(
nodeMenu,
"drop-down tool contents can only be a wxMenu"
);
}
if ( nodeMenu->GetNext() )
{
ReportError
(
nodeMenu->GetNext(),
"unexpected extra contents under drop-down tool"
);
}
}
}
#endif // wxUSE_MENUS
if (!buttonBar->AddButton(GetID(),
GetText("label"),
GetBitmap ("bitmap"),
GetBitmap ("small-bitmap"),
GetBitmap ("disabled-bitmap"),
GetBitmap ("small-disabled-bitmap"),
kind,
GetText("help")))
{
ReportError ("could not create button");
}
if ( GetBool(wxT("disabled")) )
buttonBar->EnableButton(GetID(), false);
return NULL; // nothing to return
}
wxObject* wxRibbonXmlHandler::Handle_control()
{
wxRibbonControl *control = wxDynamicCast (m_instance, wxRibbonControl);
if (!m_instance)
ReportError("wxRibbonControl must be subclassed");
else if (!control)
ReportError("controls must derive from wxRibbonControl");
control->Create(wxDynamicCast(m_parent, wxWindow), GetID(),
GetPosition(), GetSize(), GetStyle());
return m_instance;
}
wxObject* wxRibbonXmlHandler::Handle_page()
{
XRC_MAKE_INSTANCE (ribbonPage, wxRibbonPage);
if (!ribbonPage->Create (wxDynamicCast(m_parent, wxRibbonBar), GetID(),
GetText ("label"), GetBitmap ("icon"), GetStyle()))
{
ReportError("could not create ribbon page");
}
else
{
const wxClassInfo* const wasInside = m_isInside;
wxON_BLOCK_EXIT_SET(m_isInside, wasInside);
m_isInside = &wxRibbonPage::ms_classInfo;
CreateChildren (ribbonPage);
ribbonPage->Realize();
}
return ribbonPage;
}
wxObject* wxRibbonXmlHandler::Handle_gallery()
{
XRC_MAKE_INSTANCE (ribbonGallery, wxRibbonGallery);
if (!ribbonGallery->Create (wxDynamicCast(m_parent, wxWindow), GetID(),
GetPosition(), GetSize(), GetStyle()))
{
ReportError("could not create ribbon gallery");
}
else
{
const wxClassInfo* const wasInside = m_isInside;
wxON_BLOCK_EXIT_SET(m_isInside, wasInside);
m_isInside = &wxRibbonGallery::ms_classInfo;
CreateChildren (ribbonGallery);
ribbonGallery->Realize();
}
return ribbonGallery;
}
wxObject* wxRibbonXmlHandler::Handle_galleryitem()
{
wxRibbonGallery *gallery = wxStaticCast(m_parent, wxRibbonGallery);
wxCHECK (gallery, NULL);
gallery->Append (GetBitmap(), GetID());
return NULL; // nothing to return
}
wxObject* wxRibbonXmlHandler::Handle_panel()
{
XRC_MAKE_INSTANCE (ribbonPanel, wxRibbonPanel);
if (!ribbonPanel->Create (wxDynamicCast(m_parent, wxWindow), GetID(),
GetText ("label"), GetBitmap ("icon"), GetPosition(), GetSize(),
GetStyle("style", wxRIBBON_PANEL_DEFAULT_STYLE)))
{
ReportError("could not create ribbon panel");
}
else
{
CreateChildren (ribbonPanel);
ribbonPanel->Realize();
}
return ribbonPanel;
}
wxObject* wxRibbonXmlHandler::Handle_bar()
{
XRC_MAKE_INSTANCE (ribbonBar, wxRibbonBar);
Handle_RibbonArtProvider (ribbonBar);
if ( !ribbonBar->Create(wxDynamicCast(m_parent, wxWindow),
GetID(),
GetPosition(),
GetSize(),
GetStyle("style", wxRIBBON_BAR_DEFAULT_STYLE)) )
{
ReportError ("could not create ribbonbar");
}
else
{
// Currently the art provider style must be explicitly set to the
// ribbon style too.
ribbonBar->GetArtProvider()
->SetFlags(GetStyle("style", wxRIBBON_BAR_DEFAULT_STYLE));
const wxClassInfo* const wasInside = m_isInside;
wxON_BLOCK_EXIT_SET(m_isInside, wasInside);
m_isInside = &wxRibbonBar::ms_classInfo;
CreateChildren (ribbonBar, true);
ribbonBar->Realize();
}
return ribbonBar;
}
#endif // wxUSE_XRC && wxUSE_RIBBON

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_richtext.cpp
// Purpose: XRC resource for wxRichTextCtrl
// Author: Julian Smart
// Created: 2006-11-08
// Copyright: (c) 2006 Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_RICHTEXT
#include "wx/xrc/xh_richtext.h"
#include "wx/richtext/richtextctrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxRichTextCtrlXmlHandler, wxXmlResourceHandler)
wxRichTextCtrlXmlHandler::wxRichTextCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
XRC_ADD_STYLE(wxTE_PROCESS_TAB);
XRC_ADD_STYLE(wxTE_MULTILINE);
XRC_ADD_STYLE(wxTE_READONLY);
XRC_ADD_STYLE(wxTE_AUTO_URL);
AddWindowStyles();
}
wxObject *wxRichTextCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(text, wxRichTextCtrl)
text->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
SetupWindow(text);
if (HasParam(wxT("maxlength")))
text->SetMaxLength(GetLong(wxT("maxlength")));
return text;
}
bool wxRichTextCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxRichTextCtrl"));
}
#endif // wxUSE_XRC && wxUSE_RICHTEXT

View File

@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_scrol.cpp
// Purpose: XRC resource for wxScrollBar
// Author: Brian Gavin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_SCROLLBAR
#include "wx/xrc/xh_scrol.h"
#ifndef WX_PRECOMP
#include "wx/scrolbar.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxScrollBarXmlHandler, wxXmlResourceHandler)
wxScrollBarXmlHandler::wxScrollBarXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSB_HORIZONTAL);
XRC_ADD_STYLE(wxSB_VERTICAL);
AddWindowStyles();
}
wxObject *wxScrollBarXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxScrollBar)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetScrollbar(GetLong( wxT("value"), 0),
GetLong( wxT("thumbsize"),1),
GetLong( wxT("range"), 10),
GetLong( wxT("pagesize"),1));
SetupWindow(control);
CreateChildren(control);
return control;
}
bool wxScrollBarXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxScrollBar"));
}
#endif // wxUSE_XRC && wxUSE_SCROLLBAR

View File

@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_scwin.cpp
// Purpose: XRC resource for wxScrolledWindow
// Author: Vaclav Slavik
// Created: 2002/10/18
// Copyright: (c) 2002 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_scwin.h"
#ifndef WX_PRECOMP
#include "wx/frame.h"
#include "wx/scrolwin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindowXmlHandler, wxXmlResourceHandler)
wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxVSCROLL);
// wxPanel styles
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxNO_3D);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
AddWindowStyles();
}
wxObject *wxScrolledWindowXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxScrolledWindow)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxHSCROLL | wxVSCROLL),
GetName());
SetupWindow(control);
CreateChildren(control);
if ( HasParam(wxT("scrollrate")) )
{
wxSize rate = GetSize(wxT("scrollrate"));
control->SetScrollRate(rate.x, rate.y);
}
return control;
}
bool wxScrolledWindowXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxScrolledWindow"));
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_simplebook.cpp
// Purpose: XRC resource handler for wxSimplebook
// Author: Vaclav Slavik
// Created: 2014-08-05
// Copyright: (c) 2014 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_BOOKCTRL
#include "wx/xrc/xh_simplebook.h"
#ifndef WX_PRECOMP
#endif
#include "wx/simplebook.h"
wxIMPLEMENT_DYNAMIC_CLASS(wxSimplebookXmlHandler, wxXmlResourceHandler);
wxSimplebookXmlHandler::wxSimplebookXmlHandler()
: wxXmlResourceHandler(),
m_isInside(false),
m_simplebook(NULL)
{
AddWindowStyles();
}
wxObject *wxSimplebookXmlHandler::DoCreateResource()
{
if (m_class == wxS("simplebookpage"))
{
wxXmlNode *n = GetParamNode(wxS("object"));
if ( !n )
n = GetParamNode(wxS("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_simplebook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
m_simplebook->AddPage(wnd, GetText(wxS("label")),
GetBool(wxS("selected")));
}
else
{
ReportError(n, "simplebookpage child must be a window");
}
return wnd;
}
else
{
ReportError("simplebookpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(sb, wxSimplebook)
sb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxS("style")),
GetName());
SetupWindow(sb);
wxSimplebook *old_par = m_simplebook;
m_simplebook = sb;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_simplebook, true/*only this handler*/);
m_isInside = old_ins;
m_simplebook = old_par;
return sb;
}
}
bool wxSimplebookXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxS("wxSimplebook"))) ||
(m_isInside && IsOfClass(node, wxS("simplebookpage"))));
}
#endif // wxUSE_XRC && wxUSE_BOOKCTRL

View File

@ -0,0 +1,637 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_sizer.cpp
// Purpose: XRC resource for wxBoxSizer
// Author: Vaclav Slavik
// Created: 2000/03/21
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_sizer.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/panel.h"
#include "wx/statbox.h"
#include "wx/sizer.h"
#include "wx/frame.h"
#include "wx/dialog.h"
#include "wx/button.h"
#include "wx/scrolwin.h"
#endif
#include "wx/gbsizer.h"
#include "wx/wrapsizer.h"
#include "wx/notebook.h"
#include "wx/tokenzr.h"
#include "wx/xml/xml.h"
//-----------------------------------------------------------------------------
// wxSizerXmlHandler
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler)
wxSizerXmlHandler::wxSizerXmlHandler()
:wxXmlResourceHandler(),
m_isInside(false),
m_isGBS(false),
m_parentSizer(NULL)
{
XRC_ADD_STYLE(wxHORIZONTAL);
XRC_ADD_STYLE(wxVERTICAL);
// and flags
XRC_ADD_STYLE(wxLEFT);
XRC_ADD_STYLE(wxRIGHT);
XRC_ADD_STYLE(wxTOP);
XRC_ADD_STYLE(wxBOTTOM);
XRC_ADD_STYLE(wxNORTH);
XRC_ADD_STYLE(wxSOUTH);
XRC_ADD_STYLE(wxEAST);
XRC_ADD_STYLE(wxWEST);
XRC_ADD_STYLE(wxALL);
XRC_ADD_STYLE(wxGROW);
XRC_ADD_STYLE(wxEXPAND);
XRC_ADD_STYLE(wxSHAPED);
XRC_ADD_STYLE(wxSTRETCH_NOT);
XRC_ADD_STYLE(wxALIGN_CENTER);
XRC_ADD_STYLE(wxALIGN_CENTRE);
XRC_ADD_STYLE(wxALIGN_LEFT);
XRC_ADD_STYLE(wxALIGN_TOP);
XRC_ADD_STYLE(wxALIGN_RIGHT);
XRC_ADD_STYLE(wxALIGN_BOTTOM);
XRC_ADD_STYLE(wxALIGN_CENTER_HORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
XRC_ADD_STYLE(wxFIXED_MINSIZE);
XRC_ADD_STYLE(wxRESERVE_SPACE_EVEN_IF_HIDDEN);
// this flag doesn't do anything any more but we can just ignore its
// occurrences in the old resource files instead of raising a fuss because
// of it
AddStyle("wxADJUST_MINSIZE", 0);
// wxWrapSizer-specific flags
XRC_ADD_STYLE(wxEXTEND_LAST_ON_EACH_LINE);
XRC_ADD_STYLE(wxREMOVE_LEADING_SPACES);
}
bool wxSizerXmlHandler::CanHandle(wxXmlNode *node)
{
return ( (!m_isInside && IsSizerNode(node)) ||
(m_isInside && IsOfClass(node, wxT("sizeritem"))) ||
(m_isInside && IsOfClass(node, wxT("spacer")))
);
}
wxObject* wxSizerXmlHandler::DoCreateResource()
{
if (m_class == wxT("sizeritem"))
return Handle_sizeritem();
else if (m_class == wxT("spacer"))
return Handle_spacer();
else
return Handle_sizer();
}
wxSizer* wxSizerXmlHandler::DoCreateSizer(const wxString& name)
{
if (name == wxT("wxBoxSizer"))
return Handle_wxBoxSizer();
#if wxUSE_STATBOX
else if (name == wxT("wxStaticBoxSizer"))
return Handle_wxStaticBoxSizer();
#endif
else if (name == wxT("wxGridSizer"))
{
if ( !ValidateGridSizerChildren() )
return NULL;
return Handle_wxGridSizer();
}
else if (name == wxT("wxFlexGridSizer"))
{
return Handle_wxFlexGridSizer();
}
else if (name == wxT("wxGridBagSizer"))
{
return Handle_wxGridBagSizer();
}
else if (name == wxT("wxWrapSizer"))
{
return Handle_wxWrapSizer();
}
ReportError(wxString::Format("unknown sizer class \"%s\"", name));
return NULL;
}
bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node) const
{
return (IsOfClass(node, wxT("wxBoxSizer"))) ||
(IsOfClass(node, wxT("wxStaticBoxSizer"))) ||
(IsOfClass(node, wxT("wxGridSizer"))) ||
(IsOfClass(node, wxT("wxFlexGridSizer"))) ||
(IsOfClass(node, wxT("wxGridBagSizer"))) ||
(IsOfClass(node, wxT("wxWrapSizer")));
}
wxObject* wxSizerXmlHandler::Handle_sizeritem()
{
// find the item to be managed by this sizeritem
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
// did we find one?
if (n)
{
// create a sizer item for it
wxSizerItem* sitem = MakeSizerItem();
// now fetch the item to be managed
bool old_gbs = m_isGBS;
bool old_ins = m_isInside;
wxSizer *old_par = m_parentSizer;
m_isInside = false;
if (!IsSizerNode(n)) m_parentSizer = NULL;
wxObject *item = CreateResFromNode(n, m_parent, NULL);
m_isInside = old_ins;
m_parentSizer = old_par;
m_isGBS = old_gbs;
// and figure out what type it is
wxSizer *sizer = wxDynamicCast(item, wxSizer);
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (sizer)
sitem->AssignSizer(sizer);
else if (wnd)
sitem->AssignWindow(wnd);
else
ReportError(n, "unexpected item in sizer");
// finally, set other wxSizerItem attributes
SetSizerItemAttributes(sitem);
AddSizerItem(sitem);
return item;
}
else /*n == NULL*/
{
ReportError("no window/sizer/spacer within sizeritem object");
return NULL;
}
}
wxObject* wxSizerXmlHandler::Handle_spacer()
{
if ( !m_parentSizer )
{
ReportError("spacer only allowed inside a sizer");
return NULL;
}
wxSizerItem* sitem = MakeSizerItem();
SetSizerItemAttributes(sitem);
sitem->AssignSpacer(GetSize());
AddSizerItem(sitem);
return NULL;
}
wxObject* wxSizerXmlHandler::Handle_sizer()
{
wxXmlNode *parentNode = m_node->GetParent();
if ( !m_parentSizer &&
(!parentNode || parentNode->GetType() != wxXML_ELEMENT_NODE ||
!m_parentAsWindow) )
{
ReportError("sizer must have a window parent");
return NULL;
}
// Create the sizer of the appropriate class.
wxSizer * const sizer = DoCreateSizer(m_class);
// creation of sizer failed for some (already reported) reason, so exit:
if ( !sizer )
return NULL;
wxSize minsize = GetSize(wxT("minsize"));
if (!(minsize == wxDefaultSize))
sizer->SetMinSize(minsize);
// save state
wxSizer *old_par = m_parentSizer;
bool old_ins = m_isInside;
// set new state
m_parentSizer = sizer;
m_isInside = true;
m_isGBS = (m_class == wxT("wxGridBagSizer"));
wxObject* parent = m_parent;
#if wxUSE_STATBOX
// wxStaticBoxSizer's child controls should be parented by the box itself,
// not its parent.
wxStaticBoxSizer* const stsizer = wxDynamicCast(sizer, wxStaticBoxSizer);
if ( stsizer )
parent = stsizer->GetStaticBox();
#endif // wxUSE_STATBOX
CreateChildren(parent, true/*only this handler*/);
// set growable rows and cols for sizers which support this
if ( wxFlexGridSizer *flexsizer = wxDynamicCast(sizer, wxFlexGridSizer) )
{
SetFlexibleMode(flexsizer);
SetGrowables(flexsizer, wxT("growablerows"), true);
SetGrowables(flexsizer, wxT("growablecols"), false);
}
// restore state
m_isInside = old_ins;
m_parentSizer = old_par;
if (m_parentSizer == NULL) // setup window:
{
m_parentAsWindow->SetSizer(sizer);
wxXmlNode *nd = m_node;
m_node = parentNode;
if (GetSize() == wxDefaultSize)
{
if ( wxDynamicCast(m_parentAsWindow, wxScrolledWindow) != NULL )
{
sizer->FitInside(m_parentAsWindow);
}
else
{
sizer->Fit(m_parentAsWindow);
}
}
m_node = nd;
if (m_parentAsWindow->IsTopLevel())
{
sizer->SetSizeHints(m_parentAsWindow);
}
}
return sizer;
}
wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
{
return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
}
#if wxUSE_STATBOX
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
{
return new wxStaticBoxSizer(
new wxStaticBox(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
wxDefaultPosition, wxDefaultSize,
0/*style*/,
GetName()),
GetStyle(wxT("orient"), wxHORIZONTAL));
}
#endif // wxUSE_STATBOX
wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
{
return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
}
wxFlexGridSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
{
if ( !ValidateGridSizerChildren() )
return NULL;
return new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
}
wxGridBagSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
{
if ( !ValidateGridSizerChildren() )
return NULL;
return new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
}
wxSizer* wxSizerXmlHandler::Handle_wxWrapSizer()
{
wxWrapSizer *sizer = new wxWrapSizer(GetStyle("orient", wxHORIZONTAL), GetStyle("flag"));
return sizer;
}
bool wxSizerXmlHandler::ValidateGridSizerChildren()
{
int rows = GetLong("rows");
int cols = GetLong("cols");
if ( rows && cols )
{
// fixed number of cells, need to verify children count
int children = 0;
for ( wxXmlNode *n = m_node->GetChildren(); n; n = n->GetNext() )
{
if ( n->GetType() == wxXML_ELEMENT_NODE &&
(n->GetName() == "object" || n->GetName() == "object_ref") )
{
children++;
}
}
if ( children > rows * cols )
{
ReportError
(
wxString::Format
(
"too many children in grid sizer: %d > %d x %d"
" (consider omitting the number of rows or columns)",
children,
cols,
rows
)
);
return false;
}
}
return true;
}
void wxSizerXmlHandler::SetFlexibleMode(wxFlexGridSizer* fsizer)
{
if (HasParam(wxT("flexibledirection")))
{
wxString dir = GetParamValue(wxT("flexibledirection"));
if (dir == wxT("wxVERTICAL"))
fsizer->SetFlexibleDirection(wxVERTICAL);
else if (dir == wxT("wxHORIZONTAL"))
fsizer->SetFlexibleDirection(wxHORIZONTAL);
else if (dir == wxT("wxBOTH"))
fsizer->SetFlexibleDirection(wxBOTH);
else
{
ReportParamError
(
wxT("flexibledirection"),
wxString::Format("unknown direction \"%s\"", dir)
);
}
}
if (HasParam(wxT("nonflexiblegrowmode")))
{
wxString mode = GetParamValue(wxT("nonflexiblegrowmode"));
if (mode == wxT("wxFLEX_GROWMODE_NONE"))
fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_NONE);
else if (mode == wxT("wxFLEX_GROWMODE_SPECIFIED"))
fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
else if (mode == wxT("wxFLEX_GROWMODE_ALL"))
fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
else
{
ReportParamError
(
wxT("nonflexiblegrowmode"),
wxString::Format("unknown grow mode \"%s\"", mode)
);
}
}
}
void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
const wxChar* param,
bool rows)
{
int nrows, ncols;
sizer->CalcRowsCols(nrows, ncols);
const int nslots = rows ? nrows : ncols;
wxStringTokenizer tkn;
tkn.SetString(GetParamValue(param), wxT(","));
while (tkn.HasMoreTokens())
{
wxString propStr;
wxString idxStr = tkn.GetNextToken().BeforeFirst(wxT(':'), &propStr);
unsigned long li;
if (!idxStr.ToULong(&li))
{
ReportParamError
(
param,
"value must be a comma-separated list of numbers"
);
break;
}
unsigned long lp = 0;
if (!propStr.empty())
{
if (!propStr.ToULong(&lp))
{
ReportParamError
(
param,
"value must be a comma-separated list of numbers"
);
break;
}
}
const int n = static_cast<int>(li);
if ( n >= nslots )
{
ReportParamError
(
param,
wxString::Format
(
"invalid %s index %d: must be less than %d",
rows ? "row" : "column",
n,
nslots
)
);
// ignore incorrect value, still try to process the rest
continue;
}
if (rows)
sizer->AddGrowableRow(n, static_cast<int>(lp));
else
sizer->AddGrowableCol(n, static_cast<int>(lp));
}
}
wxGBPosition wxSizerXmlHandler::GetGBPos(const wxString& param)
{
wxSize sz = GetSize(param);
if (sz.x < 0) sz.x = 0;
if (sz.y < 0) sz.y = 0;
return wxGBPosition(sz.x, sz.y);
}
wxGBSpan wxSizerXmlHandler::GetGBSpan(const wxString& param)
{
wxSize sz = GetSize(param);
if (sz.x < 1) sz.x = 1;
if (sz.y < 1) sz.y = 1;
return wxGBSpan(sz.x, sz.y);
}
wxSizerItem* wxSizerXmlHandler::MakeSizerItem()
{
if (m_isGBS)
return new wxGBSizerItem();
else
return new wxSizerItem();
}
void wxSizerXmlHandler::SetSizerItemAttributes(wxSizerItem* sitem)
{
sitem->SetProportion(GetLong(wxT("option"))); // Should this check for "proportion" too?
sitem->SetFlag(GetStyle(wxT("flag")));
sitem->SetBorder(GetDimension(wxT("border")));
wxSize sz = GetSize(wxT("minsize"));
if (!(sz == wxDefaultSize))
sitem->SetMinSize(sz);
sz = GetSize(wxT("ratio"));
if (!(sz == wxDefaultSize))
sitem->SetRatio(sz);
if (m_isGBS)
{
wxGBSizerItem* gbsitem = (wxGBSizerItem*)sitem;
gbsitem->SetPos(GetGBPos(wxT("cellpos")));
gbsitem->SetSpan(GetGBSpan(wxT("cellspan")));
}
// record the id of the item, if any, for use by XRCSIZERITEM()
sitem->SetId(GetID());
}
void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem)
{
if (m_isGBS)
((wxGridBagSizer*)m_parentSizer)->Add((wxGBSizerItem*)sitem);
else
m_parentSizer->Add(sitem);
}
//-----------------------------------------------------------------------------
// wxStdDialogButtonSizerXmlHandler
//-----------------------------------------------------------------------------
#if wxUSE_BUTTON
IMPLEMENT_DYNAMIC_CLASS(wxStdDialogButtonSizerXmlHandler, wxXmlResourceHandler)
wxStdDialogButtonSizerXmlHandler::wxStdDialogButtonSizerXmlHandler()
: m_isInside(false), m_parentSizer(NULL)
{
}
wxObject *wxStdDialogButtonSizerXmlHandler::DoCreateResource()
{
if (m_class == wxT("wxStdDialogButtonSizer"))
{
wxASSERT( !m_parentSizer );
wxSizer *s = m_parentSizer = new wxStdDialogButtonSizer;
m_isInside = true;
CreateChildren(m_parent, true/*only this handler*/);
m_parentSizer->Realize();
m_isInside = false;
m_parentSizer = NULL;
return s;
}
else // m_class == "button"
{
wxASSERT( m_parentSizer );
// find the item to be managed by this sizeritem
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
// did we find one?
if (n)
{
wxObject *item = CreateResFromNode(n, m_parent, NULL);
wxButton *button = wxDynamicCast(item, wxButton);
if (button)
m_parentSizer->AddButton(button);
else
ReportError(n, "expected wxButton");
return item;
}
else /*n == NULL*/
{
ReportError("no button within wxStdDialogButtonSizer");
return NULL;
}
}
}
bool wxStdDialogButtonSizerXmlHandler::CanHandle(wxXmlNode *node)
{
return (!m_isInside && IsOfClass(node, wxT("wxStdDialogButtonSizer"))) ||
(m_isInside && IsOfClass(node, wxT("button")));
}
#endif // wxUSE_BUTTON
#endif // wxUSE_XRC

View File

@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_slidr.cpp
// Purpose: XRC resource for wxSlider
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_SLIDER
#include "wx/xrc/xh_slidr.h"
#ifndef WX_PRECOMP
#include "wx/slider.h"
#endif
static const long DEFAULT_VALUE = 0;
static const long DEFAULT_MIN = 0;
static const long DEFAULT_MAX = 100;
IMPLEMENT_DYNAMIC_CLASS(wxSliderXmlHandler, wxXmlResourceHandler)
wxSliderXmlHandler::wxSliderXmlHandler()
:wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSL_HORIZONTAL);
XRC_ADD_STYLE(wxSL_VERTICAL);
XRC_ADD_STYLE(wxSL_AUTOTICKS);
XRC_ADD_STYLE(wxSL_LABELS);
XRC_ADD_STYLE(wxSL_LEFT);
XRC_ADD_STYLE(wxSL_TOP);
XRC_ADD_STYLE(wxSL_RIGHT);
XRC_ADD_STYLE(wxSL_BOTTOM);
XRC_ADD_STYLE(wxSL_BOTH);
XRC_ADD_STYLE(wxSL_SELRANGE);
XRC_ADD_STYLE(wxSL_INVERSE);
AddWindowStyles();
}
wxObject *wxSliderXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxSlider)
control->Create(m_parentAsWindow,
GetID(),
GetLong(wxT("value"), DEFAULT_VALUE),
GetLong(wxT("min"), DEFAULT_MIN),
GetLong(wxT("max"), DEFAULT_MAX),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if( HasParam(wxT("tickfreq")))
{
control->SetTickFreq(GetLong(wxT("tickfreq")));
}
if( HasParam(wxT("pagesize")))
{
control->SetPageSize(GetLong(wxT("pagesize")));
}
if( HasParam(wxT("linesize")))
{
control->SetLineSize(GetLong(wxT("linesize")));
}
if( HasParam(wxT("thumb")))
{
control->SetThumbLength(GetLong(wxT("thumb")));
}
if( HasParam(wxT("tick")))
{
control->SetTick(GetLong(wxT("tick")));
}
if( HasParam(wxT("selmin")) && HasParam(wxT("selmax")))
{
control->SetSelection(GetLong(wxT("selmin")), GetLong(wxT("selmax")));
}
SetupWindow(control);
return control;
}
bool wxSliderXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxSlider"));
}
#endif // wxUSE_XRC && wxUSE_SLIDER

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_spin.cpp
// Purpose: XRC resource for wxSpinButton
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_spin.h"
#if wxUSE_SPINBTN
#include "wx/spinbutt.h"
static const long DEFAULT_VALUE = 0;
static const long DEFAULT_MIN = 0;
static const long DEFAULT_MAX = 100;
IMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler)
wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL);
XRC_ADD_STYLE(wxSP_ARROW_KEYS);
XRC_ADD_STYLE(wxSP_WRAP);
AddWindowStyles();
}
wxObject *wxSpinButtonXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxSpinButton)
control->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS),
GetName());
control->SetValue(GetLong( wxT("value"), DEFAULT_VALUE));
control->SetRange(GetLong( wxT("min"), DEFAULT_MIN),
GetLong(wxT("max"), DEFAULT_MAX));
SetupWindow(control);
return control;
}
bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxSpinButton"));
}
#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
#include "wx/spinctrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler)
wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL);
XRC_ADD_STYLE(wxSP_ARROW_KEYS);
XRC_ADD_STYLE(wxSP_WRAP);
XRC_ADD_STYLE(wxALIGN_LEFT);
XRC_ADD_STYLE(wxALIGN_CENTER);
XRC_ADD_STYLE(wxALIGN_RIGHT);
}
wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxSpinCtrl)
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxSP_ARROW_KEYS | wxALIGN_RIGHT),
GetLong(wxT("min"), DEFAULT_MIN),
GetLong(wxT("max"), DEFAULT_MAX),
GetLong(wxT("value"), DEFAULT_VALUE),
GetName());
const long base = GetLong(wxS("base"), 10);
if ( base != 10 )
control->SetBase(base);
SetupWindow(control);
return control;
}
bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxSpinCtrl"));
}
#endif // wxUSE_SPINCTRL
#endif // wxUSE_XRC

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_split.cpp
// Purpose: XRC resource for wxSplitterWindow
// Author: panga@freemail.hu, Vaclav Slavik
// Created: 2003/01/26
// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_SPLITTER
#include "wx/xrc/xh_split.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif
#include "wx/splitter.h"
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxSplitterWindowXmlHandler, wxXmlResourceHandler)
wxSplitterWindowXmlHandler::wxSplitterWindowXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_3D);
XRC_ADD_STYLE(wxSP_3DSASH);
XRC_ADD_STYLE(wxSP_3DBORDER);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxSP_FULLSASH);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxSP_BORDER);
XRC_ADD_STYLE(wxSP_NOBORDER);
XRC_ADD_STYLE(wxSP_PERMIT_UNSPLIT);
XRC_ADD_STYLE(wxSP_LIVE_UPDATE);
XRC_ADD_STYLE(wxSP_NO_XP_THEME);
AddWindowStyles();
}
wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(splitter, wxSplitterWindow);
splitter->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxSP_3D),
GetName());
SetupWindow(splitter);
long sashpos = GetDimension(wxT("sashpos"), 0);
long minpanesize = GetDimension(wxT("minsize"), -1);
float gravity = GetFloat(wxT("gravity"), 0.0);
if (minpanesize != -1)
splitter->SetMinimumPaneSize(minpanesize);
if (gravity != 0.0)
splitter->SetSashGravity(gravity);
wxWindow *win1 = NULL, *win2 = NULL;
wxXmlNode *n = m_node->GetChildren();
while (n)
{
if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") ||
n->GetName() == wxT("object_ref")))
{
wxObject *created = CreateResFromNode(n, splitter, NULL);
wxWindow *win = wxDynamicCast(created, wxWindow);
if (win1 == NULL)
{
win1 = win;
}
else
{
win2 = win;
break;
}
}
n = n->GetNext();
}
if (win1 == NULL)
ReportError("wxSplitterWindow node must contain at least one window");
bool horizontal = (GetParamValue(wxT("orientation")) != wxT("vertical"));
if (win1 && win2)
{
if (horizontal)
splitter->SplitHorizontally(win1, win2, sashpos);
else
splitter->SplitVertically(win1, win2, sashpos);
}
else
{
splitter->Initialize(win1);
}
return splitter;
}
bool wxSplitterWindowXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxSplitterWindow"));
}
#endif // wxUSE_XRC && wxUSE_SPLITTER

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_srchctl.cpp
// Purpose: XRC resource handler for wxSearchCtrl
// Author: Sander Berents
// Created: 2007/07/12
// Copyright: (c) 2007 Sander Berents
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_SEARCHCTRL
#include "wx/xrc/xh_srchctrl.h"
#include "wx/srchctrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrlXmlHandler, wxXmlResourceHandler)
wxSearchCtrlXmlHandler::wxSearchCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
XRC_ADD_STYLE(wxTE_PROCESS_TAB);
XRC_ADD_STYLE(wxTE_NOHIDESEL);
XRC_ADD_STYLE(wxTE_LEFT);
XRC_ADD_STYLE(wxTE_CENTRE);
XRC_ADD_STYLE(wxTE_RIGHT);
XRC_ADD_STYLE(wxTE_CAPITALIZE);
AddWindowStyles();
}
wxObject *wxSearchCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(ctrl, wxSearchCtrl)
ctrl->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(),
GetSize(),
GetStyle(wxT("style"), wxTE_LEFT),
wxDefaultValidator,
GetName());
SetupWindow(ctrl);
return ctrl;
}
bool wxSearchCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxSearchCtrl"));
}
#endif // wxUSE_XRC && wxUSE_SEARCHCTRL

View File

@ -0,0 +1,128 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_statbar.cpp
// Purpose: XRC resource for wxStatusBar
// Author: Brian Ravnsgaard Riis
// Created: 2004/01/21
// Copyright: (c) 2004 Brian Ravnsgaard Riis
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_STATUSBAR
#include "wx/xrc/xh_statbar.h"
#ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/log.h"
#include "wx/frame.h"
#include "wx/statusbr.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
wxStatusBarXmlHandler::wxStatusBarXmlHandler()
:wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSTB_SIZEGRIP);
XRC_ADD_STYLE(wxSTB_SHOW_TIPS);
XRC_ADD_STYLE(wxSTB_ELLIPSIZE_START);
XRC_ADD_STYLE(wxSTB_ELLIPSIZE_MIDDLE);
XRC_ADD_STYLE(wxSTB_ELLIPSIZE_END);
XRC_ADD_STYLE(wxSTB_DEFAULT_STYLE);
// compat style name:
XRC_ADD_STYLE(wxST_SIZEGRIP);
AddWindowStyles();
}
wxObject *wxStatusBarXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(statbar, wxStatusBar)
statbar->Create(m_parentAsWindow,
GetID(),
GetStyle(),
GetName());
int fields = GetLong(wxT("fields"), 1);
wxString widths = GetParamValue(wxT("widths"));
wxString styles = GetParamValue(wxT("styles"));
if (fields > 1 && !widths.IsEmpty())
{
int *width = new int[fields];
for (int i = 0; i < fields; ++i)
{
width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
if(widths.Find(wxT(',')))
widths.Remove(0, widths.Find(wxT(',')) + 1);
}
statbar->SetFieldsCount(fields, width);
delete[] width;
}
else
statbar->SetFieldsCount(fields);
if (!styles.empty())
{
int *style = new int[fields];
for (int i = 0; i < fields; ++i)
{
style[i] = wxSB_NORMAL;
wxString first = styles.BeforeFirst(wxT(','));
if (first == wxT("wxSB_NORMAL"))
style[i] = wxSB_NORMAL;
else if (first == wxT("wxSB_FLAT"))
style[i] = wxSB_FLAT;
else if (first == wxT("wxSB_RAISED"))
style[i] = wxSB_RAISED;
else if (first == wxT("wxSB_SUNKEN"))
style[i] = wxSB_SUNKEN;
else if (!first.empty())
{
ReportParamError
(
"styles",
wxString::Format
(
"unknown status bar field style \"%s\"",
first
)
);
}
if(styles.Find(wxT(',')))
styles.Remove(0, styles.Find(wxT(',')) + 1);
}
statbar->SetStatusStyles(fields, style);
delete [] style;
}
CreateChildren(statbar);
if (m_parentAsWindow)
{
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
if (parentFrame)
parentFrame->SetStatusBar(statbar);
}
return statbar;
}
bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxStatusBar"));
}
#endif // wxUSE_XRC && wxUSE_STATUSBAR

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_stbmp.cpp
// Purpose: XRC resource for wxStaticBitmap
// Author: Vaclav Slavik
// Created: 2000/04/22
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_STATBMP
#include "wx/xrc/xh_stbmp.h"
#ifndef WX_PRECOMP
#include "wx/statbmp.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmapXmlHandler, wxXmlResourceHandler)
wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
:wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(bmp, wxStaticBitmap)
bmp->Create(m_parentAsWindow,
GetID(),
GetBitmap(wxT("bitmap"), wxART_OTHER, GetSize()),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(bmp);
return bmp;
}
bool wxStaticBitmapXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxStaticBitmap"));
}
#endif // wxUSE_XRC && wxUSE_STATBMP

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_stbox.cpp
// Purpose: XRC resource for wxStaticBox
// Author: Brian Gavin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_STATBOX
#include "wx/xrc/xh_stbox.h"
#ifndef WX_PRECOMP
#include "wx/statbox.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticBoxXmlHandler, wxXmlResourceHandler)
wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
:wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxStaticBoxXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(box, wxStaticBox)
box->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(box);
return box;
}
bool wxStaticBoxXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxStaticBox"));
}
#endif // wxUSE_XRC && wxUSE_STATBOX

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_stlin.cpp
// Purpose: XRC resource for wxStaticLine
// Author: Brian Gavin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_STATLINE
#include "wx/xrc/xh_stlin.h"
#include "wx/statline.h"
IMPLEMENT_DYNAMIC_CLASS(wxStaticLineXmlHandler, wxXmlResourceHandler)
wxStaticLineXmlHandler::wxStaticLineXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxLI_HORIZONTAL);
XRC_ADD_STYLE(wxLI_VERTICAL);
AddWindowStyles();
}
wxObject *wxStaticLineXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(line, wxStaticLine)
line->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxLI_HORIZONTAL),
GetName());
SetupWindow(line);
return line;
}
bool wxStaticLineXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxStaticLine"));
}
#endif // wxUSE_XRC && wxUSE_STATLINE

View File

@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_sttxt.cpp
// Purpose: XRC resource for wxStaticText
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_STATTEXT
#include "wx/xrc/xh_sttxt.h"
#ifndef WX_PRECOMP
#include "wx/stattext.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticTextXmlHandler, wxXmlResourceHandler)
wxStaticTextXmlHandler::wxStaticTextXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxST_NO_AUTORESIZE);
XRC_ADD_STYLE(wxALIGN_LEFT);
XRC_ADD_STYLE(wxALIGN_RIGHT);
XRC_ADD_STYLE(wxALIGN_CENTER);
XRC_ADD_STYLE(wxALIGN_CENTRE);
AddWindowStyles();
}
wxObject *wxStaticTextXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(text, wxStaticText)
text->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(text);
long wrap = GetDimension(wxT("wrap"), -1);
if (wrap != -1)
text->Wrap(wrap);
return text;
}
bool wxStaticTextXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxStaticText"));
}
#endif // wxUSE_XRC && wxUSE_STATTEXT

View File

@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_text.cpp
// Purpose: XRC resource for wxTextCtrl
// Author: Aleksandras Gluchovas
// Created: 2000/03/21
// Copyright: (c) 2000 Aleksandras Gluchovas
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TEXTCTRL
#include "wx/xrc/xh_text.h"
#ifndef WX_PRECOMP
#include "wx/textctrl.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler)
wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTE_NO_VSCROLL);
XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
XRC_ADD_STYLE(wxTE_PROCESS_TAB);
XRC_ADD_STYLE(wxTE_MULTILINE);
XRC_ADD_STYLE(wxTE_PASSWORD);
XRC_ADD_STYLE(wxTE_READONLY);
XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxTE_RICH);
XRC_ADD_STYLE(wxTE_RICH2);
XRC_ADD_STYLE(wxTE_AUTO_URL);
XRC_ADD_STYLE(wxTE_NOHIDESEL);
XRC_ADD_STYLE(wxTE_LEFT);
XRC_ADD_STYLE(wxTE_CENTRE);
XRC_ADD_STYLE(wxTE_RIGHT);
XRC_ADD_STYLE(wxTE_DONTWRAP);
#if WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTE_LINEWRAP);
#endif // WXWIN_COMPATIBILITY_2_6
XRC_ADD_STYLE(wxTE_CHARWRAP);
XRC_ADD_STYLE(wxTE_WORDWRAP);
// this style doesn't exist since wx 2.9.0 but we still support it (by
// ignoring it silently) in XRC files to avoid unimportant warnings when
// using XRC produced by old tools
AddStyle(wxT("wxTE_AUTO_SCROLL"), 0);
AddWindowStyles();
}
wxObject *wxTextCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(text, wxTextCtrl)
text->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
SetupWindow(text);
if (HasParam(wxT("maxlength")))
text->SetMaxLength(GetLong(wxT("maxlength")));
if (HasParam(wxT("hint")))
text->SetHint(GetText(wxS("hint")));
return text;
}
bool wxTextCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxTextCtrl"));
}
#endif // wxUSE_XRC && wxUSE_TEXTCTRL

View File

@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_tglbtn.cpp
// Purpose: XRC resource for wxToggleButton
// Author: Bob Mitchell
// Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TOGGLEBTN
#include "wx/xrc/xh_tglbtn.h"
#include "wx/tglbtn.h"
#include "wx/button.h" // solely for wxBU_EXACTFIT
IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler)
wxToggleButtonXmlHandler::wxToggleButtonXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_EXACTFIT);
AddWindowStyles();
}
wxObject *wxToggleButtonXmlHandler::DoCreateResource()
{
wxObject *control = m_instance;
#if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__))
if (m_class == wxT("wxBitmapToggleButton"))
{
if (!control)
control = new wxBitmapToggleButton;
DoCreateBitmapToggleButton(control);
}
else
#endif
{
if (!control)
control = new wxToggleButton;
DoCreateToggleButton(control);
}
SetupWindow(wxDynamicCast(control, wxWindow));
return control;
}
bool wxToggleButtonXmlHandler::CanHandle(wxXmlNode *node)
{
return (
IsOfClass(node, wxT("wxToggleButton")) ||
IsOfClass(node, wxT("wxBitmapToggleButton"))
);
}
void wxToggleButtonXmlHandler::DoCreateToggleButton(wxObject *control)
{
wxToggleButton *button = wxDynamicCast(control, wxToggleButton);
button->Create(m_parentAsWindow,
GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
button->SetValue(GetBool( wxT("checked")));
}
#if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__))
void wxToggleButtonXmlHandler::DoCreateBitmapToggleButton(wxObject *control)
{
wxBitmapToggleButton *button = wxDynamicCast(control, wxBitmapToggleButton);
button->Create(m_parentAsWindow,
GetID(),
GetBitmap(wxT("bitmap"), wxART_BUTTON),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
button->SetValue(GetBool( wxT("checked")));
}
#endif
#endif // wxUSE_XRC && wxUSE_TOGGLEBTN

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_timectrl.cpp
// Purpose: XML resource handler for wxTimePickerCtrl
// Author: Vadim Zeitlin
// Created: 2011-09-22
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TIMEPICKCTRL
#include "wx/xrc/xh_timectrl.h"
#include "wx/timectrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxTimeCtrlXmlHandler, wxXmlResourceHandler)
wxTimeCtrlXmlHandler::wxTimeCtrlXmlHandler()
{
XRC_ADD_STYLE(wxTP_DEFAULT);
AddWindowStyles();
}
wxObject *wxTimeCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(picker, wxTimePickerCtrl)
picker->Create(m_parentAsWindow,
GetID(),
wxDefaultDateTime,
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxTP_DEFAULT),
wxDefaultValidator,
GetName());
SetupWindow(picker);
return picker;
}
bool wxTimeCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxS("wxTimePickerCtrl"));
}
#endif // wxUSE_XRC && wxUSE_TIMEPICKCTRL

View File

@ -0,0 +1,264 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_toolb.cpp
// Purpose: XRC resource for wxToolBar
// Author: Vaclav Slavik
// Created: 2000/08/11
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TOOLBAR
#include "wx/xrc/xh_toolb.h"
#ifndef WX_PRECOMP
#include "wx/frame.h"
#include "wx/log.h"
#include "wx/menu.h"
#include "wx/toolbar.h"
#endif
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxToolBarXmlHandler, wxXmlResourceHandler)
wxToolBarXmlHandler::wxToolBarXmlHandler()
: wxXmlResourceHandler(), m_isInside(false), m_toolbar(NULL)
{
XRC_ADD_STYLE(wxTB_FLAT);
XRC_ADD_STYLE(wxTB_DOCKABLE);
XRC_ADD_STYLE(wxTB_VERTICAL);
XRC_ADD_STYLE(wxTB_HORIZONTAL);
XRC_ADD_STYLE(wxTB_3DBUTTONS);
XRC_ADD_STYLE(wxTB_TEXT);
XRC_ADD_STYLE(wxTB_NOICONS);
XRC_ADD_STYLE(wxTB_NODIVIDER);
XRC_ADD_STYLE(wxTB_NOALIGN);
XRC_ADD_STYLE(wxTB_HORZ_LAYOUT);
XRC_ADD_STYLE(wxTB_HORZ_TEXT);
XRC_ADD_STYLE(wxTB_TOP);
XRC_ADD_STYLE(wxTB_LEFT);
XRC_ADD_STYLE(wxTB_RIGHT);
XRC_ADD_STYLE(wxTB_BOTTOM);
AddWindowStyles();
}
wxObject *wxToolBarXmlHandler::DoCreateResource()
{
if (m_class == wxT("tool"))
{
if ( !m_toolbar )
{
ReportError("tool only allowed inside a wxToolBar");
return NULL;
}
wxItemKind kind = wxITEM_NORMAL;
if (GetBool(wxT("radio")))
kind = wxITEM_RADIO;
if (GetBool(wxT("toggle")))
{
if ( kind != wxITEM_NORMAL )
{
ReportParamError
(
"toggle",
"tool can't have both <radio> and <toggle> properties"
);
}
kind = wxITEM_CHECK;
}
#if wxUSE_MENUS
// check whether we have dropdown tag inside
wxMenu *menu = NULL; // menu for drop down items
wxXmlNode * const nodeDropdown = GetParamNode("dropdown");
if ( nodeDropdown )
{
if ( kind != wxITEM_NORMAL )
{
ReportParamError
(
"dropdown",
"drop-down tool can't have neither <radio> nor <toggle> properties"
);
}
kind = wxITEM_DROPDOWN;
// also check for the menu specified inside dropdown (it is
// optional and may be absent for e.g. dynamically-created
// menus)
wxXmlNode * const nodeMenu = nodeDropdown->GetChildren();
if ( nodeMenu )
{
wxObject *res = CreateResFromNode(nodeMenu, NULL);
menu = wxDynamicCast(res, wxMenu);
if ( !menu )
{
ReportError
(
nodeMenu,
"drop-down tool contents can only be a wxMenu"
);
}
if ( nodeMenu->GetNext() )
{
ReportError
(
nodeMenu->GetNext(),
"unexpected extra contents under drop-down tool"
);
}
}
}
#endif
wxToolBarToolBase * const tool =
m_toolbar->AddTool
(
GetID(),
GetText(wxT("label")),
GetBitmap(wxT("bitmap"), wxART_TOOLBAR, m_toolSize),
GetBitmap(wxT("bitmap2"), wxART_TOOLBAR, m_toolSize),
kind,
GetText(wxT("tooltip")),
GetText(wxT("longhelp"))
);
if ( GetBool(wxT("disabled")) )
m_toolbar->EnableTool(tool->GetId(), false);
if ( GetBool(wxS("checked")) )
{
if ( kind == wxITEM_NORMAL )
{
ReportParamError
(
"checked",
"only <radio> nor <toggle> tools can be checked"
);
}
else
{
m_toolbar->ToggleTool(tool->GetId(), true);
}
}
#if wxUSE_MENUS
if ( menu )
tool->SetDropdownMenu(menu);
#endif
return m_toolbar; // must return non-NULL
}
else if (m_class == wxT("separator") || m_class == wxT("space"))
{
if ( !m_toolbar )
{
ReportError("separators only allowed inside wxToolBar");
return NULL;
}
if ( m_class == wxT("separator") )
m_toolbar->AddSeparator();
else
m_toolbar->AddStretchableSpace();
return m_toolbar; // must return non-NULL
}
else /*<object class="wxToolBar">*/
{
int style = GetStyle(wxT("style"), wxNO_BORDER | wxTB_HORIZONTAL);
#ifdef __WXMSW__
if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
#endif
XRC_MAKE_INSTANCE(toolbar, wxToolBar)
toolbar->Create(m_parentAsWindow,
GetID(),
GetPosition(),
GetSize(),
style,
GetName());
SetupWindow(toolbar);
m_toolSize = GetSize(wxT("bitmapsize"));
if (!(m_toolSize == wxDefaultSize))
toolbar->SetToolBitmapSize(m_toolSize);
wxSize margins = GetSize(wxT("margins"));
if (!(margins == wxDefaultSize))
toolbar->SetMargins(margins.x, margins.y);
long packing = GetLong(wxT("packing"), -1);
if (packing != -1)
toolbar->SetToolPacking(packing);
long separation = GetLong(wxT("separation"), -1);
if (separation != -1)
toolbar->SetToolSeparation(separation);
wxXmlNode *children_node = GetParamNode(wxT("object"));
if (!children_node)
children_node = GetParamNode(wxT("object_ref"));
if (children_node == NULL) return toolbar;
m_isInside = true;
m_toolbar = toolbar;
wxXmlNode *n = children_node;
while (n)
{
if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
{
wxObject *created = CreateResFromNode(n, toolbar, NULL);
wxControl *control = wxDynamicCast(created, wxControl);
if (!IsOfClass(n, wxT("tool")) &&
!IsOfClass(n, wxT("separator")) &&
!IsOfClass(n, wxT("space")) &&
control != NULL)
toolbar->AddControl(control);
}
n = n->GetNext();
}
m_isInside = false;
m_toolbar = NULL;
if (m_parentAsWindow && !GetBool(wxT("dontattachtoframe")))
{
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
if (parentFrame)
parentFrame->SetToolBar(toolbar);
}
toolbar->Realize();
return toolbar;
}
}
bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxToolBar"))) ||
(m_isInside && IsOfClass(node, wxT("tool"))) ||
(m_isInside && IsOfClass(node, wxT("space"))) ||
(m_isInside && IsOfClass(node, wxT("separator"))));
}
#endif // wxUSE_XRC && wxUSE_TOOLBAR

View File

@ -0,0 +1,143 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_toolbk.cpp
// Purpose: XRC resource for wxToolbook
// Author: Andrea Zanellato
// Created: 2009/12/12
// Copyright: (c) 2010 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TOOLBOOK
#include "wx/xrc/xh_toolbk.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/sizer.h"
#endif
#include "wx/toolbook.h"
#include "wx/imaglist.h"
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxToolbookXmlHandler, wxXmlResourceHandler)
wxToolbookXmlHandler::wxToolbookXmlHandler()
:wxXmlResourceHandler(),
m_isInside(false),
m_toolbook(NULL)
{
XRC_ADD_STYLE(wxBK_DEFAULT);
XRC_ADD_STYLE(wxBK_TOP);
XRC_ADD_STYLE(wxBK_BOTTOM);
XRC_ADD_STYLE(wxBK_LEFT);
XRC_ADD_STYLE(wxBK_RIGHT);
XRC_ADD_STYLE(wxTBK_BUTTONBAR);
XRC_ADD_STYLE(wxTBK_HORZ_LAYOUT);
AddWindowStyles();
}
wxObject *wxToolbookXmlHandler::DoCreateResource()
{
if (m_class == wxT("toolbookpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_toolbook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
{
int imgId = -1;
if ( HasParam(wxT("bitmap")) )
{
wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
wxImageList *imgList = m_toolbook->GetImageList();
if ( imgList == NULL )
{
imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
m_toolbook->AssignImageList( imgList );
}
imgId = imgList->Add(bmp);
}
else if ( HasParam(wxT("image")) )
{
if ( m_toolbook->GetImageList() )
{
imgId = (int)GetLong(wxT("image"));
}
else // image without image list?
{
ReportError(n, "image can only be used in conjunction "
"with imagelist");
}
}
m_toolbook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected")), imgId );
}
else
{
ReportError(n, "toolbookpage child must be a window");
}
return wnd;
}
else
{
ReportError("toolbookpage must have a window child");
return NULL;
}
}
else
{
XRC_MAKE_INSTANCE(nb, wxToolbook)
nb->Create( m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
GetName() );
wxImageList *imagelist = GetImageList();
if ( imagelist )
nb->AssignImageList(imagelist);
wxToolbook *old_par = m_toolbook;
m_toolbook = nb;
bool old_ins = m_isInside;
m_isInside = true;
CreateChildren(m_toolbook, true/*only this handler*/);
m_isInside = old_ins;
m_toolbook = old_par;
return nb;
}
}
bool wxToolbookXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxToolbook"))) ||
(m_isInside && IsOfClass(node, wxT("toolbookpage"))));
}
#endif // wxUSE_XRC && wxUSE_TOOLBOOK

View File

@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_tree.cpp
// Purpose: XRC resource for wxTreeCtrl
// Author: Brian Gavin
// Created: 2000/09/09
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TREECTRL
#include "wx/xrc/xh_tree.h"
#include "wx/treectrl.h"
IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrlXmlHandler, wxXmlResourceHandler)
wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTR_EDIT_LABELS);
XRC_ADD_STYLE(wxTR_NO_BUTTONS);
XRC_ADD_STYLE(wxTR_HAS_BUTTONS);
XRC_ADD_STYLE(wxTR_TWIST_BUTTONS);
XRC_ADD_STYLE(wxTR_NO_LINES);
XRC_ADD_STYLE(wxTR_FULL_ROW_HIGHLIGHT);
XRC_ADD_STYLE(wxTR_LINES_AT_ROOT);
XRC_ADD_STYLE(wxTR_HIDE_ROOT);
XRC_ADD_STYLE(wxTR_ROW_LINES);
XRC_ADD_STYLE(wxTR_HAS_VARIABLE_ROW_HEIGHT);
XRC_ADD_STYLE(wxTR_SINGLE);
XRC_ADD_STYLE(wxTR_MULTIPLE);
XRC_ADD_STYLE(wxTR_DEFAULT_STYLE);
#if WXWIN_COMPATIBILITY_2_8
XRC_ADD_STYLE(wxTR_EXTENDED);
#endif
AddWindowStyles();
}
wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(tree, wxTreeCtrl)
tree->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxTR_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
wxImageList *imagelist = GetImageList();
if ( imagelist )
tree->AssignImageList(imagelist);
SetupWindow(tree);
return tree;
}
bool wxTreeCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxTreeCtrl"));
}
#endif // wxUSE_XRC && wxUSE_TREECTRL

View File

@ -0,0 +1,181 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_treebk.cpp
// Purpose: XRC resource handler for wxTreebook
// Author: Evgeniy Tarassov
// Created: 2005/09/28
// Copyright: (c) 2005 TT-Solutions <vadim@tt-solutions.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_TREEBOOK
#include "wx/xrc/xh_treebk.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif
#include "wx/treebook.h"
#include "wx/imaglist.h"
#include "wx/xml/xml.h"
IMPLEMENT_DYNAMIC_CLASS(wxTreebookXmlHandler, wxXmlResourceHandler)
wxTreebookXmlHandler::wxTreebookXmlHandler()
: wxXmlResourceHandler(),
m_tbk(NULL),
m_isInside(false)
{
XRC_ADD_STYLE(wxBK_DEFAULT);
XRC_ADD_STYLE(wxBK_TOP);
XRC_ADD_STYLE(wxBK_BOTTOM);
XRC_ADD_STYLE(wxBK_LEFT);
XRC_ADD_STYLE(wxBK_RIGHT);
AddWindowStyles();
}
bool wxTreebookXmlHandler::CanHandle(wxXmlNode *node)
{
return ((!m_isInside && IsOfClass(node, wxT("wxTreebook"))) ||
(m_isInside && IsOfClass(node, wxT("treebookpage"))));
}
wxObject *wxTreebookXmlHandler::DoCreateResource()
{
if (m_class == wxT("wxTreebook"))
{
XRC_MAKE_INSTANCE(tbk, wxTreebook)
tbk->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
GetName());
wxImageList *imagelist = GetImageList();
if ( imagelist )
tbk->AssignImageList(imagelist);
wxTreebook * old_par = m_tbk;
m_tbk = tbk;
bool old_ins = m_isInside;
m_isInside = true;
wxArrayTbkPageIndexes old_treeContext = m_treeContext;
m_treeContext.Clear();
CreateChildren(m_tbk, true/*only this handler*/);
wxXmlNode *node = GetParamNode("object");
int pageIndex = 0;
for (unsigned int i = 0; i < m_tbk->GetPageCount(); i++)
{
if ( m_tbk->GetPage(i) )
{
wxXmlNode *child = node->GetChildren();
while (child)
{
if (child->GetName() == "expanded" && child->GetNodeContent() == "1")
m_tbk->ExpandNode(pageIndex, true);
child = child->GetNext();
}
pageIndex++;
}
}
m_treeContext = old_treeContext;
m_isInside = old_ins;
m_tbk = old_par;
return tbk;
}
// else ( m_class == wxT("treebookpage") )
wxXmlNode *n = GetParamNode(wxT("object"));
wxWindow *wnd = NULL;
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n)
{
bool old_ins = m_isInside;
m_isInside = false;
wxObject *item = CreateResFromNode(n, m_tbk, NULL);
m_isInside = old_ins;
wnd = wxDynamicCast(item, wxWindow);
if (wnd == NULL && item != NULL)
{
ReportError(n, "treebookpage child must be a window");
}
}
size_t depth = GetLong( wxT("depth") );
if( depth <= m_treeContext.GetCount() )
{
// first prepare the icon
int imgIndex = wxNOT_FOUND;
if ( HasParam(wxT("bitmap")) )
{
wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER);
wxImageList *imgList = m_tbk->GetImageList();
if ( imgList == NULL )
{
imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
m_tbk->AssignImageList( imgList );
}
imgIndex = imgList->Add(bmp);
}
else if ( HasParam(wxT("image")) )
{
if ( m_tbk->GetImageList() )
{
imgIndex = GetLong(wxT("image"));
}
else // image without image list?
{
ReportError(n, "image can only be used in conjunction "
"with imagelist");
}
}
// then add the page to the corresponding parent
if( depth < m_treeContext.GetCount() )
m_treeContext.RemoveAt(depth, m_treeContext.GetCount() - depth );
if( depth == 0)
{
m_tbk->AddPage(wnd,
GetText(wxT("label")), GetBool(wxT("selected")), imgIndex);
}
else
{
m_tbk->InsertSubPage(m_treeContext.Item(depth - 1), wnd,
GetText(wxT("label")), GetBool(wxT("selected")), imgIndex);
}
m_treeContext.Add( m_tbk->GetPageCount() - 1);
}
else
{
ReportParamError("depth", "invalid depth");
}
return wnd;
}
#endif // wxUSE_XRC && wxUSE_TREEBOOK

View File

@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_unkwn.cpp
// Purpose: XRC resource for unknown widget
// Author: Vaclav Slavik
// Created: 2000/09/09
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xh_unkwn.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/window.h"
#include "wx/panel.h"
#include "wx/sizer.h"
#endif
#ifdef __WXMSW__
#include "wx/msw/private.h"
#endif
class wxUnknownControlContainer : public wxPanel
{
public:
wxUnknownControlContainer(wxWindow *parent,
const wxString& controlName,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0)
// Always add the wxTAB_TRAVERSAL and wxNO_BORDER styles to what comes
// from the XRC if anything.
: wxPanel(parent, id, pos, size, style | wxTAB_TRAVERSAL | wxNO_BORDER,
controlName + wxT("_container")),
m_controlName(controlName), m_controlAdded(false)
{
m_bg = GetBackgroundColour();
SetBackgroundColour(wxColour(255, 0, 255));
}
virtual void AddChild(wxWindowBase *child);
virtual void RemoveChild(wxWindowBase *child);
protected:
wxString m_controlName;
bool m_controlAdded;
wxColour m_bg;
};
void wxUnknownControlContainer::AddChild(wxWindowBase *child)
{
wxASSERT_MSG( !m_controlAdded, wxT("Couldn't add two unknown controls to the same container!") );
wxPanel::AddChild(child);
SetBackgroundColour(m_bg);
child->SetName(m_controlName);
child->SetId(wxXmlResource::GetXRCID(m_controlName));
#ifdef __WXMSW__
// In 3.0, wxWindowBase::SetId() is not virtual and can't be overridden in
// wxWindowMSW to do the right thing, so work around it here instead.
::SetWindowLong(GetHwndOf((wxWindow*)child), GWL_ID, child->GetId());
#endif // __WXMSW__
m_controlAdded = true;
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add((wxWindow*)child, 1, wxEXPAND);
SetSizerAndFit(sizer);
}
void wxUnknownControlContainer::RemoveChild(wxWindowBase *child)
{
wxPanel::RemoveChild(child);
m_controlAdded = false;
GetSizer()->Detach((wxWindow*)child);
}
IMPLEMENT_DYNAMIC_CLASS(wxUnknownWidgetXmlHandler, wxXmlResourceHandler)
wxUnknownWidgetXmlHandler::wxUnknownWidgetXmlHandler()
: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE);
}
wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
{
wxASSERT_MSG( m_instance == NULL,
wxT("'unknown' controls can't be subclassed, use wxXmlResource::AttachUnknownControl") );
wxPanel *panel =
new wxUnknownControlContainer(m_parentAsWindow,
GetName(), wxID_ANY,
GetPosition(), GetSize(),
GetStyle(wxT("style")));
SetupWindow(panel);
return panel;
}
bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("unknown"));
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,103 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_wizrd.cpp
// Purpose: XRC resource for wxWizard
// Author: Vaclav Slavik
// Created: 2003/03/01
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC && wxUSE_WIZARDDLG
#include "wx/xrc/xh_wizrd.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif
#include "wx/wizard.h"
IMPLEMENT_DYNAMIC_CLASS(wxWizardXmlHandler, wxXmlResourceHandler)
wxWizardXmlHandler::wxWizardXmlHandler() : wxXmlResourceHandler()
{
m_wizard = NULL;
m_lastSimplePage = NULL;
XRC_ADD_STYLE(wxWIZARD_EX_HELPBUTTON);
AddWindowStyles();
}
wxObject *wxWizardXmlHandler::DoCreateResource()
{
if (m_class == wxT("wxWizard"))
{
XRC_MAKE_INSTANCE(wiz, wxWizard)
long style = GetStyle(wxT("exstyle"), 0);
if (style != 0)
wiz->SetExtraStyle(style);
wiz->Create(m_parentAsWindow,
GetID(),
GetText(wxT("title")),
GetBitmap(),
GetPosition());
SetupWindow(wiz);
wxWizard *old = m_wizard;
m_wizard = wiz;
m_lastSimplePage = NULL;
CreateChildren(wiz, true /*this handler only*/);
m_wizard = old;
return wiz;
}
else
{
wxWizardPage *page;
if (m_class == wxT("wxWizardPageSimple"))
{
XRC_MAKE_INSTANCE(p, wxWizardPageSimple)
p->Create(m_wizard, NULL, NULL, GetBitmap());
if (m_lastSimplePage)
wxWizardPageSimple::Chain(m_lastSimplePage, p);
page = p;
m_lastSimplePage = p;
}
else /*if (m_class == wxT("wxWizardPage"))*/
{
if ( !m_instance )
{
ReportError("wxWizardPage is abstract class and must be subclassed");
return NULL;
}
page = wxStaticCast(m_instance, wxWizardPage);
page->Create(m_wizard, GetBitmap());
}
page->SetName(GetName());
page->SetId(GetID());
SetupWindow(page);
CreateChildren(page);
return page;
}
}
bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxWizard")) ||
(m_wizard != NULL &&
(IsOfClass(node, wxT("wxWizardPage")) ||
IsOfClass(node, wxT("wxWizardPageSimple")))
);
}
#endif // wxUSE_XRC && wxUSE_WIZARDDLG

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xmladv.cpp
// Purpose: Parts of wxXRC library depending on wxAdv: they must not be in
// xmlres.cpp itself or it becomes impossible to use wxXRC without
// linking wxAdv even if the latter is not used at all.
// Author: Vadim Zeitlin (extracted from src/xrc/xmlres.cpp)
// Created: 2008-08-02
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xmlres.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif // WX_PRECOMP
#include "wx/animate.h"
#include "wx/scopedptr.h"
// ============================================================================
// implementation
// ============================================================================
#if wxUSE_ANIMATIONCTRL
wxAnimation* wxXmlResourceHandlerImpl::GetAnimation(const wxString& param)
{
const wxString name = GetParamValue(param);
if ( name.empty() )
return NULL;
// load the animation from file
wxScopedPtr<wxAnimation> ani(new wxAnimation);
#if wxUSE_FILESYSTEM
wxFSFile * const
fsfile = GetCurFileSystem().OpenFile(name, wxFS_READ | wxFS_SEEKABLE);
if ( fsfile )
{
ani->Load(*fsfile->GetStream());
delete fsfile;
}
#else
ani->LoadFile(name);
#endif
if ( !ani->IsOk() )
{
ReportParamError
(
param,
wxString::Format("cannot create animation from \"%s\"", name)
);
return NULL;
}
return ani.release();
}
#endif // wxUSE_ANIMATIONCTRL
#endif // wxUSE_XRC

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xmlreshandler.cpp
// Purpose: XML resource handler
// Author: Steven Lamerton
// Created: 2011/01/26
// RCS-ID: $id$
// Copyright: (c) 2011 Steven Lamerton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xmlreshandler.h"
IMPLEMENT_ABSTRACT_CLASS(wxXmlResourceHandler, wxObject)
wxXmlResourceHandlerImplBase* wxXmlResourceHandler::GetImpl() const
{
if ( !m_impl )
{
wxFAIL_MSG(wxT("SetImpl() must have been called!"));
}
return m_impl;
}
void wxXmlResourceHandler::AddStyle(const wxString& name, int value)
{
m_styleNames.Add(name);
m_styleValues.Add(value);
}
void wxXmlResourceHandler::AddWindowStyles()
{
XRC_ADD_STYLE(wxCLIP_CHILDREN);
// the border styles all have the old and new names, recognize both for now
XRC_ADD_STYLE(wxSIMPLE_BORDER); XRC_ADD_STYLE(wxBORDER_SIMPLE);
XRC_ADD_STYLE(wxSUNKEN_BORDER); XRC_ADD_STYLE(wxBORDER_SUNKEN);
XRC_ADD_STYLE(wxDOUBLE_BORDER); XRC_ADD_STYLE(wxBORDER_DOUBLE); // deprecated
XRC_ADD_STYLE(wxBORDER_THEME);
XRC_ADD_STYLE(wxRAISED_BORDER); XRC_ADD_STYLE(wxBORDER_RAISED);
XRC_ADD_STYLE(wxSTATIC_BORDER); XRC_ADD_STYLE(wxBORDER_STATIC);
XRC_ADD_STYLE(wxNO_BORDER); XRC_ADD_STYLE(wxBORDER_NONE);
XRC_ADD_STYLE(wxBORDER_DEFAULT);
XRC_ADD_STYLE(wxTRANSPARENT_WINDOW);
XRC_ADD_STYLE(wxWANTS_CHARS);
XRC_ADD_STYLE(wxTAB_TRAVERSAL);
XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE);
XRC_ADD_STYLE(wxFULL_REPAINT_ON_RESIZE);
XRC_ADD_STYLE(wxVSCROLL);
XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxALWAYS_SHOW_SB);
XRC_ADD_STYLE(wxWS_EX_BLOCK_EVENTS);
XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
XRC_ADD_STYLE(wxWS_EX_TRANSIENT);
XRC_ADD_STYLE(wxWS_EX_CONTEXTHELP);
XRC_ADD_STYLE(wxWS_EX_PROCESS_IDLE);
XRC_ADD_STYLE(wxWS_EX_PROCESS_UI_UPDATES);
}
#endif // wxUSE_XRC

View File

@ -0,0 +1,210 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xmlrsall.cpp
// Purpose: wxXmlResource::InitAllHandlers
// Author: Vaclav Slavik
// Created: 2000/03/05
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include "wx/xrc/xmlres.h"
#include "wx/xrc/xh_all.h"
void wxXmlResource::InitAllHandlers()
{
// these are the handlers, which we always have
AddHandler(new wxUnknownWidgetXmlHandler);
AddHandler(new wxBitmapXmlHandler);
AddHandler(new wxIconXmlHandler);
AddHandler(new wxDialogXmlHandler);
AddHandler(new wxPanelXmlHandler);
AddHandler(new wxSizerXmlHandler);
AddHandler(new wxFrameXmlHandler);
AddHandler(new wxScrolledWindowXmlHandler);
// these are configurable handlers
//
// please keep them in alphabetical order of wxUSE_XXX guards
#if wxUSE_ANIMATIONCTRL
AddHandler(new wxAnimationCtrlXmlHandler);
#endif
#if wxUSE_BANNERWINDOW
AddHandler(new wxBannerWindowXmlHandler);
#endif
#if wxUSE_BITMAPCOMBOBOX
AddHandler(new wxBitmapComboBoxXmlHandler);
#endif
#if wxUSE_BMPBUTTON
AddHandler(new wxBitmapButtonXmlHandler);
#endif
#if wxUSE_BOOKCTRL
AddHandler(new wxPropertySheetDialogXmlHandler);
#endif
#if wxUSE_BUTTON
AddHandler(new wxStdDialogButtonSizerXmlHandler);
AddHandler(new wxButtonXmlHandler);
#endif
#if wxUSE_CALENDARCTRL
AddHandler(new wxCalendarCtrlXmlHandler);
#endif
#if wxUSE_CHECKBOX
AddHandler(new wxCheckBoxXmlHandler);
#endif
#if wxUSE_CHECKLISTBOX
AddHandler(new wxCheckListBoxXmlHandler);
#endif
#if wxUSE_CHOICE
AddHandler(new wxChoiceXmlHandler);
#endif
#if wxUSE_CHOICEBOOK
AddHandler(new wxChoicebookXmlHandler);
#endif
#if wxUSE_COLLPANE
AddHandler(new wxCollapsiblePaneXmlHandler);
#endif
#if wxUSE_COLOURPICKERCTRL
AddHandler(new wxColourPickerCtrlXmlHandler);
#endif
#if wxUSE_COMBOBOX
AddHandler(new wxComboBoxXmlHandler);
#endif
#if wxUSE_COMBOCTRL
AddHandler(new wxComboCtrlXmlHandler);
#endif
#if wxUSE_COMMANDLINKBUTTON
AddHandler(new wxCommandLinkButtonXmlHandler);
#endif
#if wxUSE_DATEPICKCTRL
AddHandler(new wxDateCtrlXmlHandler);
#endif
#if wxUSE_DIRDLG
AddHandler(new wxGenericDirCtrlXmlHandler);
#endif
#if wxUSE_DIRPICKERCTRL
AddHandler(new wxDirPickerCtrlXmlHandler);
#endif
#if wxUSE_EDITABLELISTBOX
AddHandler(new wxEditableListBoxXmlHandler);
#endif
#if wxUSE_FILECTRL
AddHandler(new wxFileCtrlXmlHandler);
#endif
#if wxUSE_FILEPICKERCTRL
AddHandler(new wxFilePickerCtrlXmlHandler);
#endif
#if wxUSE_FONTPICKERCTRL
AddHandler(new wxFontPickerCtrlXmlHandler);
#endif
#if wxUSE_GAUGE
AddHandler(new wxGaugeXmlHandler);
#endif
#if wxUSE_GRID
AddHandler( new wxGridXmlHandler);
#endif
#if wxUSE_HTML
AddHandler(new wxHtmlWindowXmlHandler);
AddHandler(new wxSimpleHtmlListBoxXmlHandler);
#endif
#if wxUSE_HYPERLINKCTRL
AddHandler( new wxHyperlinkCtrlXmlHandler);
#endif
#if wxUSE_LISTBOOK
AddHandler(new wxListbookXmlHandler);
#endif
#if wxUSE_LISTBOX
AddHandler(new wxListBoxXmlHandler);
#endif
#if wxUSE_LISTCTRL
AddHandler(new wxListCtrlXmlHandler);
#endif
#if wxUSE_MDI
AddHandler(new wxMdiXmlHandler);
#endif
#if wxUSE_MENUS
AddHandler(new wxMenuXmlHandler);
AddHandler(new wxMenuBarXmlHandler);
#endif
#if wxUSE_NOTEBOOK
AddHandler(new wxNotebookXmlHandler);
#endif
#if wxUSE_ODCOMBOBOX
AddHandler(new wxOwnerDrawnComboBoxXmlHandler);
#endif
#if wxUSE_RADIOBOX
AddHandler(new wxRadioBoxXmlHandler);
#endif
#if wxUSE_RADIOBTN
AddHandler(new wxRadioButtonXmlHandler);
#endif
#if wxUSE_SCROLLBAR
AddHandler(new wxScrollBarXmlHandler);
#endif
#if wxUSE_SEARCHCTRL
AddHandler(new wxSearchCtrlXmlHandler);
#endif
#if wxUSE_BOOKCTRL
AddHandler(new wxSimplebookXmlHandler);
#endif
#if wxUSE_SLIDER
AddHandler(new wxSliderXmlHandler);
#endif
#if wxUSE_SPINBTN
AddHandler(new wxSpinButtonXmlHandler);
#endif
#if wxUSE_SPINCTRL
AddHandler(new wxSpinCtrlXmlHandler);
#endif
#if wxUSE_SPLITTER
AddHandler(new wxSplitterWindowXmlHandler);
#endif
#if wxUSE_STATBMP
AddHandler(new wxStaticBitmapXmlHandler);
#endif
#if wxUSE_STATBOX
AddHandler(new wxStaticBoxXmlHandler);
#endif
#if wxUSE_STATLINE
AddHandler(new wxStaticLineXmlHandler);
#endif
#if wxUSE_STATTEXT
AddHandler(new wxStaticTextXmlHandler);
#endif
#if wxUSE_STATUSBAR
AddHandler(new wxStatusBarXmlHandler);
#endif
#if wxUSE_TEXTCTRL
AddHandler(new wxTextCtrlXmlHandler);
#endif
#if wxUSE_TOGGLEBTN
AddHandler(new wxToggleButtonXmlHandler);
#endif
#if wxUSE_TIMEPICKCTRL
AddHandler(new wxTimeCtrlXmlHandler);
#endif
#if wxUSE_TOOLBAR
AddHandler(new wxToolBarXmlHandler);
#endif
#if wxUSE_TOOLBOOK
AddHandler(new wxToolbookXmlHandler);
#endif
#if wxUSE_TREEBOOK
AddHandler(new wxTreebookXmlHandler);
#endif
#if wxUSE_TREECTRL
AddHandler(new wxTreeCtrlXmlHandler);
#endif
#if wxUSE_WIZARDDLG
AddHandler(new wxWizardXmlHandler);
#endif
}
#endif // wxUSE_XRC