]>
Commit | Line | Data |
---|---|---|
78d14f80 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/xrc/xh_spin.cpp |
b5d6954b | 3 | // Purpose: XRC resource for wxSpinButton |
78d14f80 VS |
4 | // Author: Bob Mitchell |
5 | // Created: 2000/03/21 | |
78d14f80 VS |
6 | // Copyright: (c) 2000 Bob Mitchell and Verant Interactive |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
f80ea77b | 9 | |
78d14f80 VS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
033508e1 | 17 | #if wxUSE_XRC |
a1e4ec87 | 18 | |
78d14f80 | 19 | #include "wx/xrc/xh_spin.h" |
2ae23cc5 WS |
20 | |
21 | #if wxUSE_SPINBTN | |
22 | ||
23 | #include "wx/spinbutt.h" | |
78d14f80 | 24 | |
033508e1 VS |
25 | static const long DEFAULT_VALUE = 0; |
26 | static const long DEFAULT_MIN = 0; | |
27 | static const long DEFAULT_MAX = 100; | |
28 | ||
854e189f VS |
29 | IMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler) |
30 | ||
f80ea77b WS |
31 | wxSpinButtonXmlHandler::wxSpinButtonXmlHandler() |
32 | : wxXmlResourceHandler() | |
78d14f80 | 33 | { |
544fee32 VS |
34 | XRC_ADD_STYLE(wxSP_HORIZONTAL); |
35 | XRC_ADD_STYLE(wxSP_VERTICAL); | |
36 | XRC_ADD_STYLE(wxSP_ARROW_KEYS); | |
37 | XRC_ADD_STYLE(wxSP_WRAP); | |
78d14f80 VS |
38 | AddWindowStyles(); |
39 | } | |
40 | ||
41 | wxObject *wxSpinButtonXmlHandler::DoCreateResource() | |
f80ea77b | 42 | { |
544fee32 | 43 | XRC_MAKE_INSTANCE(control, wxSpinButton) |
f2588180 VS |
44 | |
45 | control->Create(m_parentAsWindow, | |
46 | GetID(), | |
47 | GetPosition(), GetSize(), | |
48 | GetStyle(wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS), | |
49 | GetName()); | |
78d14f80 | 50 | |
033508e1 VS |
51 | control->SetValue(GetLong( wxT("value"), DEFAULT_VALUE)); |
52 | control->SetRange(GetLong( wxT("min"), DEFAULT_MIN), | |
53 | GetLong(wxT("max"), DEFAULT_MAX)); | |
78d14f80 | 54 | SetupWindow(control); |
f80ea77b | 55 | |
78d14f80 VS |
56 | return control; |
57 | } | |
58 | ||
78d14f80 VS |
59 | bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node) |
60 | { | |
61 | return IsOfClass(node, wxT("wxSpinButton")); | |
62 | } | |
63 | ||
64 | #endif // wxUSE_SPINBTN | |
65 | ||
66 | #if wxUSE_SPINCTRL | |
67 | ||
2ae23cc5 WS |
68 | #include "wx/spinctrl.h" |
69 | ||
854e189f VS |
70 | IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler) |
71 | ||
f80ea77b WS |
72 | wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() |
73 | : wxXmlResourceHandler() | |
78d14f80 | 74 | { |
544fee32 VS |
75 | XRC_ADD_STYLE(wxSP_HORIZONTAL); |
76 | XRC_ADD_STYLE(wxSP_VERTICAL); | |
77 | XRC_ADD_STYLE(wxSP_ARROW_KEYS); | |
78 | XRC_ADD_STYLE(wxSP_WRAP); | |
f1ddb476 VZ |
79 | XRC_ADD_STYLE(wxALIGN_LEFT); |
80 | XRC_ADD_STYLE(wxALIGN_CENTER); | |
81 | XRC_ADD_STYLE(wxALIGN_RIGHT); | |
78d14f80 VS |
82 | } |
83 | ||
84 | wxObject *wxSpinCtrlXmlHandler::DoCreateResource() | |
f80ea77b | 85 | { |
544fee32 | 86 | XRC_MAKE_INSTANCE(control, wxSpinCtrl) |
f80ea77b | 87 | |
544fee32 VS |
88 | control->Create(m_parentAsWindow, |
89 | GetID(), | |
90 | GetText(wxT("value")), | |
91 | GetPosition(), GetSize(), | |
f1ddb476 | 92 | GetStyle(wxT("style"), wxSP_ARROW_KEYS | wxALIGN_RIGHT), |
033508e1 VS |
93 | GetLong(wxT("min"), DEFAULT_MIN), |
94 | GetLong(wxT("max"), DEFAULT_MAX), | |
95 | GetLong(wxT("value"), DEFAULT_VALUE), | |
544fee32 | 96 | GetName()); |
78d14f80 | 97 | |
9e565667 VZ |
98 | const long base = GetLong(wxS("base"), 10); |
99 | if ( base != 10 ) | |
100 | control->SetBase(base); | |
101 | ||
78d14f80 | 102 | SetupWindow(control); |
f80ea77b | 103 | |
78d14f80 VS |
104 | return control; |
105 | } | |
106 | ||
78d14f80 VS |
107 | bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node) |
108 | { | |
109 | return IsOfClass(node, wxT("wxSpinCtrl")); | |
110 | } | |
111 | ||
2ae23cc5 WS |
112 | #endif // wxUSE_SPINCTRL |
113 | ||
621be1ec | 114 | #endif // wxUSE_XRC |