From 80f4c8cde3c1e9e042d850ef21a1859fdf213c21 Mon Sep 17 00:00:00 2001 From: Trylz Date: Wed, 10 Jan 2018 17:26:24 +0100 Subject: [PATCH 1/3] Add XRC handler for wxSpinCtrlDouble Create wxSpinCtrlDoubleXmlHandler class similar to the existing wxSpinCtrlXmlHandler and update the XRC schema to account for it. --- docs/changes.txt | 1 + include/wx/xrc/xh_spin.h | 13 ++++++++++-- misc/schema/xrc_schema.rnc | 14 +++++++++++++ src/xrc/xh_spin.cpp | 42 ++++++++++++++++++++++++++++++++++++++ src/xrc/xmlrsall.cpp | 1 + 5 files changed, 69 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 801172be93..f4e42fb2d1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -115,6 +115,7 @@ All (GUI): - Add support for loading fonts from external files (Arthur Norman). - Improve wxSVGFileDC to support more of wxDC API (Maarten Bent). - Add support for wxAuiManager and wxAuiPaneInfo to XRC (Andrea Zanellato). +- Add XRC handler for wxSpinCtrlDouble (Trylz). - Add support for wxSL_MIN_MAX_LABELS and wxSL_VALUE_LABEL to XRC (ousnius). - Update Scintilla to v3.7.2 (NewPagodi, Paul Kulchenko). - Update bundled libpng to 1.6.28 (Catalin Raceanu). diff --git a/include/wx/xrc/xh_spin.h b/include/wx/xrc/xh_spin.h index 93762e0325..bf522e936f 100644 --- a/include/wx/xrc/xh_spin.h +++ b/include/wx/xrc/xh_spin.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/xrc/xh_spin.h -// Purpose: XML resource handler for wxSpinButton and wxSpinCtrl +// Purpose: XML resource handler for wxSpinButton, wxSpinCtrl, wxSpinCtrlDouble // Author: Bob Mitchell // Created: 2000/03/21 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive @@ -28,7 +28,6 @@ public: #endif // wxUSE_SPINBTN - #if wxUSE_SPINCTRL class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler @@ -41,6 +40,16 @@ public: wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler); }; +class WXDLLIMPEXP_XRC wxSpinCtrlDoubleXmlHandler : public wxXmlResourceHandler +{ +public: + wxSpinCtrlDoubleXmlHandler(); + virtual wxObject *DoCreateResource() wxOVERRIDE; + virtual bool CanHandle(wxXmlNode *node) wxOVERRIDE; + + wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlDoubleXmlHandler); +}; + #endif // wxUSE_SPINCTRL #endif // wxUSE_XRC diff --git a/misc/schema/xrc_schema.rnc b/misc/schema/xrc_schema.rnc index b298088e45..e4617452f6 100644 --- a/misc/schema/xrc_schema.rnc +++ b/misc/schema/xrc_schema.rnc @@ -214,6 +214,7 @@ builtinWindowClasses = | wxSlider | wxSpinButton | wxSpinCtrl + | wxSpinCtrlDouble | wxSplitterWindow | wxSearchCtrl | wxStatusBar @@ -310,6 +311,7 @@ builtinClassesNames = | "wxSlider" | "wxSpinButton" | "wxSpinCtrl" + | "wxSpinCtrlDouble" | "wxSplitterWindow" | "wxSearchCtrl" | "wxStatusBar" @@ -1413,6 +1415,18 @@ wxSpinCtrl = } +wxSpinCtrlDouble = + element object { + attribute class { "wxSpinCtrlDouble" } & + stdObjectNodeAttributes & + stdWindowProperties & + [xrc:p="o"] element value {_, t_float }* & + [xrc:p="o"] element min {_, t_float }* & + [xrc:p="o"] element max {_, t_float }* & + [xrc:p="o"] element inc {_, t_float}* + } + + wxSplitterWindow = element object { attribute class { "wxSplitterWindow" } & diff --git a/src/xrc/xh_spin.cpp b/src/xrc/xh_spin.cpp index ebd452e7ae..1e7a04affc 100644 --- a/src/xrc/xh_spin.cpp +++ b/src/xrc/xh_spin.cpp @@ -67,6 +67,8 @@ bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node) #include "wx/spinctrl.h" +static const float DEFAULT_INC = 1.; + wxIMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler); wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() @@ -109,6 +111,46 @@ bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node) return IsOfClass(node, wxT("wxSpinCtrl")); } + +wxIMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlDoubleXmlHandler, wxXmlResourceHandler); + +wxSpinCtrlDoubleXmlHandler::wxSpinCtrlDoubleXmlHandler() + : 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 *wxSpinCtrlDoubleXmlHandler::DoCreateResource() +{ + XRC_MAKE_INSTANCE(control, wxSpinCtrlDouble) + + control->Create(m_parentAsWindow, + GetID(), + GetText(wxS("value")), + GetPosition(), GetSize(), + GetStyle(wxS("style"), wxSP_ARROW_KEYS | wxALIGN_RIGHT), + GetFloat(wxS("min"), (float)DEFAULT_MIN), + GetFloat(wxS("max"), (float)DEFAULT_MAX), + GetFloat(wxS("value"), (float)DEFAULT_VALUE), + GetFloat(wxS("inc"), DEFAULT_INC), + GetName()); + + SetupWindow(control); + + return control; +} + +bool wxSpinCtrlDoubleXmlHandler::CanHandle(wxXmlNode *node) +{ + return IsOfClass(node, wxS("wxSpinCtrlDouble")); +} + #endif // wxUSE_SPINCTRL #endif // wxUSE_XRC diff --git a/src/xrc/xmlrsall.cpp b/src/xrc/xmlrsall.cpp index 00c787a58f..0f67288385 100644 --- a/src/xrc/xmlrsall.cpp +++ b/src/xrc/xmlrsall.cpp @@ -165,6 +165,7 @@ void wxXmlResource::InitAllHandlers() #endif #if wxUSE_SPINCTRL AddHandler(new wxSpinCtrlXmlHandler); + AddHandler(new wxSpinCtrlDoubleXmlHandler); #endif #if wxUSE_SPLITTER AddHandler(new wxSplitterWindowXmlHandler); From 74cf8370ce6c617cb951af2ad0a6d532dbb8d017 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Jan 2018 17:31:23 +0100 Subject: [PATCH 2/3] Avoid code duplication between wxSpinCtrl XRC handlers Extract styles initialization into a function reused by both wxSpinCtrlXmlHandler and wxSpinCtrlDoubleXmlHandler. No real changes, this is a pure refactoring. --- src/xrc/xh_spin.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/xrc/xh_spin.cpp b/src/xrc/xh_spin.cpp index 1e7a04affc..314697d768 100644 --- a/src/xrc/xh_spin.cpp +++ b/src/xrc/xh_spin.cpp @@ -69,18 +69,23 @@ bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node) static const float DEFAULT_INC = 1.; +static void AddSpinCtrlStyles(wxXmlResourceHandler& handler) +{ + handler.XRC_ADD_STYLE(wxSP_HORIZONTAL); + handler.XRC_ADD_STYLE(wxSP_VERTICAL); + handler.XRC_ADD_STYLE(wxSP_ARROW_KEYS); + handler.XRC_ADD_STYLE(wxSP_WRAP); + handler.XRC_ADD_STYLE(wxALIGN_LEFT); + handler.XRC_ADD_STYLE(wxALIGN_CENTER); + handler.XRC_ADD_STYLE(wxALIGN_RIGHT); +} + wxIMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler); wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() -: wxXmlResourceHandler() + : 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); + AddSpinCtrlStyles(*this); } wxObject *wxSpinCtrlXmlHandler::DoCreateResource() @@ -117,13 +122,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlDoubleXmlHandler, wxXmlResourceHandler); wxSpinCtrlDoubleXmlHandler::wxSpinCtrlDoubleXmlHandler() : 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); + AddSpinCtrlStyles(*this); } wxObject *wxSpinCtrlDoubleXmlHandler::DoCreateResource() From c3c8a2198db04c00063979a467add3bee4353e41 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Jan 2018 17:35:34 +0100 Subject: [PATCH 3/3] Document the recently added wxSpinCtrlDouble XRC handler Update XRC reference documentation after adding a new handler too. --- docs/doxygen/overviews/xrc_format.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index 7a1a25fe8e..abffacb471 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -1906,6 +1906,19 @@ wxWidgets 2.9.5, another one: @endTable +@subsubsection xrc_wxspinctrldouble wxSpinCtrlDouble + +wxSpinCtrlDouble supports the same properties as @ref xrc_wxspinbutton but @c +value, @c min and @a max are all of type float instead of int. There is one +additional property: +@beginTable +@row3col{inc, float, + The amount by which the number is changed by a single arrow press.} +@endTable + +This handler was added in wxWidgets 3.1.1. + + @subsubsection xrc_wxsplitterwindow wxSplitterWindow @beginTable