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