From: Julian Smart Date: Wed, 8 Nov 2006 15:45:11 +0000 (+0000) Subject: Added wxRichTextCtrl XRC handler X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fd4344d64dfeffa3522364691c5e737b6ca04612 Added wxRichTextCtrl XRC handler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43199 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 6a213b1655..640f876585 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2955,6 +2955,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/xrc/xh_panel.cpp src/xrc/xh_radbt.cpp src/xrc/xh_radbx.cpp + src/xrc/xh_richtext.cpp src/xrc/xh_scrol.cpp src/xrc/xh_scwin.cpp src/xrc/xh_htmllbox.cpp @@ -3013,6 +3014,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/xrc/xh_panel.h wx/xrc/xh_radbt.h wx/xrc/xh_radbx.h + wx/xrc/xh_richtext.h wx/xrc/xh_scrol.h wx/xrc/xh_scwin.h wx/xrc/xh_htmllbox.h diff --git a/include/wx/xrc/xh_all.h b/include/wx/xrc/xh_all.h index 0424611ed3..73f64a57ee 100644 --- a/include/wx/xrc/xh_all.h +++ b/include/wx/xrc/xh_all.h @@ -67,5 +67,6 @@ #include "wx/xrc/xh_bmpcbox.h" #include "wx/xrc/xh_animatctrl.h" #include "wx/xrc/xh_collpane.h" +#include "wx/xrc/xh_richtext.h" #endif // _WX_XH_ALL_H_ diff --git a/include/wx/xrc/xh_richtext.h b/include/wx/xrc/xh_richtext.h new file mode 100644 index 0000000000..c1c30fc267 --- /dev/null +++ b/include/wx/xrc/xh_richtext.h @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/xrc/xh_text.h +// Purpose: XML resource handler for wxRichTextCtrl +// Author: Julian Smart +// Created: 2006-11-08 +// RCS-ID: $Id$ +// Copyright: (c) 2006 Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_RICHTEXT_H_ +#define _WX_XH_RICHTEXT_H_ + +#include "wx/xrc/xmlres.h" + +#if wxUSE_XRC && wxUSE_RICHTEXT + +class WXDLLIMPEXP_XRC wxRichTextCtrlXmlHandler : public wxXmlResourceHandler +{ + DECLARE_DYNAMIC_CLASS(wxRichTextCtrlXmlHandler) + +public: + wxRichTextCtrlXmlHandler(); + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + +#endif // wxUSE_XRC && wxUSE_RICHTEXT + +#endif // _WX_XH_RICHTEXT_H_ diff --git a/src/xrc/xh_richtext.cpp b/src/xrc/xh_richtext.cpp new file mode 100644 index 0000000000..f8b08cc839 --- /dev/null +++ b/src/xrc/xh_richtext.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/xrc/xh_richtext.cpp +// Purpose: XRC resource for wxRichTextCtrl +// Author: Julian Smart +// Created: 2006-11-08 +// RCS-ID: $Id$ +// 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 + diff --git a/src/xrc/xmlrsall.cpp b/src/xrc/xmlrsall.cpp index 47f0292465..9f422fce6e 100644 --- a/src/xrc/xmlrsall.cpp +++ b/src/xrc/xmlrsall.cpp @@ -128,6 +128,9 @@ void wxXmlResource::InitAllHandlers() #if wxUSE_RADIOBTN AddHandler(new wxRadioButtonXmlHandler); #endif +#if wxUSE_RICHTEXT + AddHandler(new wxRichTextCtrlXmlHandler); +#endif #if wxUSE_SCROLLBAR AddHandler(new wxScrollBarXmlHandler); #endif