diff --git a/contrib/include/wx/xrc/xh_statbar.h b/contrib/include/wx/xrc/xh_statbar.h new file mode 100644 index 0000000000..7e57e00d2f --- /dev/null +++ b/contrib/include/wx/xrc/xh_statbar.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_statbar.h +// Purpose: XML resource handler for wxStatusBar +// Author: Brian Ravnsgaard Riis +// Created: 2004/01/21 +// RCS-ID: +// Copyright: (c) 2004 Brian Ravnsgaard Riis +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_STATBAR_H_ +#define _WX_XH_STATBAR_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "xh_statbar.h" +#endif + +#include "wx/xrc/xmlres.h" + +class WXXMLDLLEXPORT wxStatusBarXmlHandler : public wxXmlResourceHandler +{ + public: + wxStatusBarXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif // _WX_XH_STATBAR_H_ + diff --git a/contrib/src/xrc/xh_statbar.cpp b/contrib/src/xrc/xh_statbar.cpp new file mode 100644 index 0000000000..d69735c63b --- /dev/null +++ b/contrib/src/xrc/xh_statbar.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_statbar.cpp +// Purpose: XRC resource for wxStatusBar +// Author: Brian Ravnsgaard Riis +// Created: 2004/01/21 +// RCS-ID: +// Copyright: (c) 2004 Brian Ravnsgaard Riis +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_statbar.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/frame.h" +#include "wx/string.h" + +#if wxUSE_STATUSBAR + +#include "wx/xrc/xh_statbar.h" +#include "wx/statusbr.h" + +wxStatusBarXmlHandler::wxStatusBarXmlHandler() : + wxXmlResourceHandler() +{ + 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")); + + if(fields > 1) + { + int *width = new int[fields]; + + for (unsigned 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; + } + + 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 + diff --git a/include/wx/xrc/xh_statbar.h b/include/wx/xrc/xh_statbar.h new file mode 100644 index 0000000000..7e57e00d2f --- /dev/null +++ b/include/wx/xrc/xh_statbar.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_statbar.h +// Purpose: XML resource handler for wxStatusBar +// Author: Brian Ravnsgaard Riis +// Created: 2004/01/21 +// RCS-ID: +// Copyright: (c) 2004 Brian Ravnsgaard Riis +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_STATBAR_H_ +#define _WX_XH_STATBAR_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "xh_statbar.h" +#endif + +#include "wx/xrc/xmlres.h" + +class WXXMLDLLEXPORT wxStatusBarXmlHandler : public wxXmlResourceHandler +{ + public: + wxStatusBarXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif // _WX_XH_STATBAR_H_ + diff --git a/src/xrc/xh_statbar.cpp b/src/xrc/xh_statbar.cpp new file mode 100644 index 0000000000..d69735c63b --- /dev/null +++ b/src/xrc/xh_statbar.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_statbar.cpp +// Purpose: XRC resource for wxStatusBar +// Author: Brian Ravnsgaard Riis +// Created: 2004/01/21 +// RCS-ID: +// Copyright: (c) 2004 Brian Ravnsgaard Riis +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "xh_statbar.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/frame.h" +#include "wx/string.h" + +#if wxUSE_STATUSBAR + +#include "wx/xrc/xh_statbar.h" +#include "wx/statusbr.h" + +wxStatusBarXmlHandler::wxStatusBarXmlHandler() : + wxXmlResourceHandler() +{ + 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")); + + if(fields > 1) + { + int *width = new int[fields]; + + for (unsigned 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; + } + + 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 +