]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_slidr.cpp
XRC spec: document wxRibbon* XRC handler.
[wxWidgets.git] / src / xrc / xh_slidr.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_slidr.cpp
3 // Purpose: XRC resource for wxSlider
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 && wxUSE_SLIDER
18
19 #include "wx/xrc/xh_slidr.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/slider.h"
23 #endif
24
25 static const long DEFAULT_VALUE = 0;
26 static const long DEFAULT_MIN = 0;
27 static const long DEFAULT_MAX = 100;
28
29
30 IMPLEMENT_DYNAMIC_CLASS(wxSliderXmlHandler, wxXmlResourceHandler)
31
32 wxSliderXmlHandler::wxSliderXmlHandler()
33 :wxXmlResourceHandler()
34 {
35 XRC_ADD_STYLE(wxSL_HORIZONTAL);
36 XRC_ADD_STYLE(wxSL_VERTICAL);
37 XRC_ADD_STYLE(wxSL_AUTOTICKS);
38 XRC_ADD_STYLE(wxSL_LABELS);
39 XRC_ADD_STYLE(wxSL_LEFT);
40 XRC_ADD_STYLE(wxSL_TOP);
41 XRC_ADD_STYLE(wxSL_RIGHT);
42 XRC_ADD_STYLE(wxSL_BOTTOM);
43 XRC_ADD_STYLE(wxSL_BOTH);
44 XRC_ADD_STYLE(wxSL_SELRANGE);
45 XRC_ADD_STYLE(wxSL_INVERSE);
46 AddWindowStyles();
47 }
48
49 wxObject *wxSliderXmlHandler::DoCreateResource()
50 {
51 XRC_MAKE_INSTANCE(control, wxSlider)
52
53 control->Create(m_parentAsWindow,
54 GetID(),
55 GetLong(wxT("value"), DEFAULT_VALUE),
56 GetLong(wxT("min"), DEFAULT_MIN),
57 GetLong(wxT("max"), DEFAULT_MAX),
58 GetPosition(), GetSize(),
59 GetStyle(),
60 wxDefaultValidator,
61 GetName());
62
63 if( HasParam(wxT("tickfreq")))
64 {
65 control->SetTickFreq(GetLong(wxT("tickfreq")));
66 }
67 if( HasParam(wxT("pagesize")))
68 {
69 control->SetPageSize(GetLong(wxT("pagesize")));
70 }
71 if( HasParam(wxT("linesize")))
72 {
73 control->SetLineSize(GetLong(wxT("linesize")));
74 }
75 if( HasParam(wxT("thumb")))
76 {
77 control->SetThumbLength(GetLong(wxT("thumb")));
78 }
79 if( HasParam(wxT("tick")))
80 {
81 control->SetTick(GetLong(wxT("tick")));
82 }
83 if( HasParam(wxT("selmin")) && HasParam(wxT("selmax")))
84 {
85 control->SetSelection(GetLong(wxT("selmin")), GetLong(wxT("selmax")));
86 }
87
88 SetupWindow(control);
89
90 return control;
91 }
92
93 bool wxSliderXmlHandler::CanHandle(wxXmlNode *node)
94 {
95 return IsOfClass(node, wxT("wxSlider"));
96 }
97
98 #endif // wxUSE_XRC && wxUSE_SLIDER