Add XRC handler for wxSpinCtrlDouble

Create wxSpinCtrlDoubleXmlHandler class similar to the existing
wxSpinCtrlXmlHandler and update the XRC schema to account for it.
This commit is contained in:
Trylz
2018-01-10 17:26:24 +01:00
committed by Vadim Zeitlin
parent e2a31ef3db
commit 80f4c8cde3
5 changed files with 69 additions and 2 deletions

View File

@@ -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).

View File

@@ -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

View File

@@ -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" } &

View File

@@ -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

View File

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