Merge branch 'xrc-spinctrldouble'

Add XRC handler for wxSpinCtrlDouble.

Closes https://github.com/wxWidgets/wxWidgets/pull/665
This commit is contained in:
Vadim Zeitlin
2018-01-10 17:45:08 +01:00
6 changed files with 89 additions and 10 deletions

View File

@@ -115,6 +115,7 @@ All (GUI):
- Add support for loading fonts from external files (Arthur Norman). - Add support for loading fonts from external files (Arthur Norman).
- Improve wxSVGFileDC to support more of wxDC API (Maarten Bent). - Improve wxSVGFileDC to support more of wxDC API (Maarten Bent).
- Add support for wxAuiManager and wxAuiPaneInfo to XRC (Andrea Zanellato). - 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). - Add support for wxSL_MIN_MAX_LABELS and wxSL_VALUE_LABEL to XRC (ousnius).
- Update Scintilla to v3.7.2 (NewPagodi, Paul Kulchenko). - Update Scintilla to v3.7.2 (NewPagodi, Paul Kulchenko).
- Update bundled libpng to 1.6.28 (Catalin Raceanu). - Update bundled libpng to 1.6.28 (Catalin Raceanu).

View File

@@ -1906,6 +1906,19 @@ wxWidgets 2.9.5, another one:
@endTable @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 @subsubsection xrc_wxsplitterwindow wxSplitterWindow
@beginTable @beginTable

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/xrc/xh_spin.h // 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 // Author: Bob Mitchell
// Created: 2000/03/21 // Created: 2000/03/21
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
@@ -28,7 +28,6 @@ public:
#endif // wxUSE_SPINBTN #endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler
@@ -41,6 +40,16 @@ public:
wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler); 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_SPINCTRL
#endif // wxUSE_XRC #endif // wxUSE_XRC

View File

@@ -214,6 +214,7 @@ builtinWindowClasses =
| wxSlider | wxSlider
| wxSpinButton | wxSpinButton
| wxSpinCtrl | wxSpinCtrl
| wxSpinCtrlDouble
| wxSplitterWindow | wxSplitterWindow
| wxSearchCtrl | wxSearchCtrl
| wxStatusBar | wxStatusBar
@@ -310,6 +311,7 @@ builtinClassesNames =
| "wxSlider" | "wxSlider"
| "wxSpinButton" | "wxSpinButton"
| "wxSpinCtrl" | "wxSpinCtrl"
| "wxSpinCtrlDouble"
| "wxSplitterWindow" | "wxSplitterWindow"
| "wxSearchCtrl" | "wxSearchCtrl"
| "wxStatusBar" | "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 = wxSplitterWindow =
element object { element object {
attribute class { "wxSplitterWindow" } & attribute class { "wxSplitterWindow" } &

View File

@@ -67,18 +67,25 @@ bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node)
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
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); wxIMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler);
wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxSP_HORIZONTAL); AddSpinCtrlStyles(*this);
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() wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
@@ -109,6 +116,40 @@ bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node)
return IsOfClass(node, wxT("wxSpinCtrl")); return IsOfClass(node, wxT("wxSpinCtrl"));
} }
wxIMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlDoubleXmlHandler, wxXmlResourceHandler);
wxSpinCtrlDoubleXmlHandler::wxSpinCtrlDoubleXmlHandler()
: wxXmlResourceHandler()
{
AddSpinCtrlStyles(*this);
}
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_SPINCTRL
#endif // wxUSE_XRC #endif // wxUSE_XRC

View File

@@ -165,6 +165,7 @@ void wxXmlResource::InitAllHandlers()
#endif #endif
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
AddHandler(new wxSpinCtrlXmlHandler); AddHandler(new wxSpinCtrlXmlHandler);
AddHandler(new wxSpinCtrlDoubleXmlHandler);
#endif #endif
#if wxUSE_SPLITTER #if wxUSE_SPLITTER
AddHandler(new wxSplitterWindowXmlHandler); AddHandler(new wxSplitterWindowXmlHandler);