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