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