| 1 |
#include "spin_button_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "wxgui_defs.h" |
| 4 |
#include "wxgui_helpers.h" |
| 5 |
#include "xmlutils.h" |
| 6 |
#include <wx/spinbutt.h> |
| 7 |
|
| 8 |
SpinButtonWrapper::SpinButtonWrapper() |
| 9 |
: SpinWrapperBase(ID_WXSPINBUTTON) |
| 10 |
{ |
| 11 |
PREPEND_STYLE_FALSE(wxSP_HORIZONTAL); |
| 12 |
PREPEND_STYLE_TRUE(wxSP_VERTICAL); |
| 13 |
PREPEND_STYLE_FALSE(wxSP_ARROW_KEYS); |
| 14 |
PREPEND_STYLE_FALSE(wxSP_WRAP); |
| 15 |
|
| 16 |
RegisterEvent(wxT("wxEVT_SPIN_UP"), wxT("wxSpinEvent"), _("Generated when left/up arrow is pressed.")); |
| 17 |
RegisterEvent(wxT("wxEVT_SPIN_DOWN"), wxT("wxSpinEvent"), _("Generated when right/down arrow is pressed.")); |
| 18 |
RegisterEvent(wxT("wxEVT_SPIN"), wxT("wxSpinEvent"), _("Generated whenever an arrow is pressed.")); |
| 19 |
|
| 20 |
SetPropertyString(_("Common Settings"), "wxSpinButton"); |
| 21 |
AddProperty(new StringProperty(PROP_VALUE, wxT("0"), _("The initial value"))); |
| 22 |
AddProperty(new StringProperty(PROP_MINVALUE, wxT("0"), _("Minimal value"))); |
| 23 |
AddProperty(new StringProperty(PROP_MAXVALUE, wxT("100"), _("Maximal value"))); |
| 24 |
|
| 25 |
m_namePattern = wxT("m_spinButton"); |
| 26 |
SetName(GenerateName()); |
| 27 |
} |
| 28 |
|
| 29 |
SpinButtonWrapper::~SpinButtonWrapper() {} |
| 30 |
|
| 31 |
wxcWidget* SpinButtonWrapper::Clone() const { return new SpinButtonWrapper(); } |
| 32 |
|
| 33 |
wxString SpinButtonWrapper::CppCtorCode() const |
| 34 |
{ |
| 35 |
wxString code; |
| 36 |
wxString min, max; |
| 37 |
int imin, imax, val; |
| 38 |
EnsureSaneValues(min, max, imin, imax, val); |
| 39 |
|
| 40 |
code << CPPStandardWxCtor(wxT("wxSP_VERTICAL")); |
| 41 |
code << GetName() << wxT("->SetRange(") << min << wxT(", ") << max << wxT(");\n"); |
| 42 |
code << GetName() << wxT("->SetValue(") << val << wxT(");\n"); |
| 43 |
|
| 44 |
return code; |
| 45 |
} |
| 46 |
void SpinButtonWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/spinbutt.h>")); } |
| 47 |
|
| 48 |
wxString SpinButtonWrapper::GetWxClassName() const { return wxT("wxSpinButton"); } |
| 49 |
|
| 50 |
void SpinButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 51 |
{ |
| 52 |
wxString min, max; |
| 53 |
int imin, imax, val; |
| 54 |
EnsureSaneValues(min, max, imin, imax, val); |
| 55 |
|
| 56 |
text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes() << wxT("<value>") |
| 57 |
<< wxCrafter::XMLEncode(wxCrafter::ToString(val)) << wxT("</value>") << wxT("<min>") |
| 58 |
<< wxCrafter::XMLEncode(min) << wxT("</min>") << wxT("<max>") << wxCrafter::XMLEncode(max) << wxT("</max>") |
| 59 |
<< XRCSuffix(); |
| 60 |
} |