Debian Codegraph @

wxcrafter/controls/slider_wrapper.cpp

raw
1 #include "slider_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "xmlutils.h"
4 #include <wx/slider.h>
5
6 SliderWrapper::SliderWrapper()
7 : wxcWidget(ID_WXSLIDER)
8 {
9 SetPropertyString(_("Common Settings"), "wxSlider");
10 AddProperty(new StringProperty(PROP_VALUE, wxT("50"), _("Value")));
11 AddProperty(new StringProperty(PROP_MINVALUE, wxT("0"), _("Minimum slider value")));
12 AddProperty(new StringProperty(PROP_MAXVALUE, wxT("100"), _("Maximum slider value")));
13
14 PREPEND_STYLE(wxSL_HORIZONTAL, true);
15 PREPEND_STYLE(wxSL_VERTICAL, false);
16 PREPEND_STYLE(wxSL_AUTOTICKS, false);
17 PREPEND_STYLE(wxSL_LABELS, false);
18 PREPEND_STYLE(wxSL_LEFT, false);
19 PREPEND_STYLE(wxSL_RIGHT, false);
20 PREPEND_STYLE(wxSL_TOP, false);
21 PREPEND_STYLE(wxSL_BOTTOM, false);
22 PREPEND_STYLE(wxSL_SELRANGE, false);
23 PREPEND_STYLE(wxSL_INVERSE, false);
24
25 RegisterEvent(wxT("wxEVT_SCROLL_TOP"), wxT("wxScrollEvent"),
26 _("Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position)"));
27 RegisterEvent(wxT("wxEVT_SCROLL_BOTTOM"), wxT("wxScrollEvent"),
28 _("Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position)."));
29 RegisterEvent(wxT("wxEVT_SCROLL_LINEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_LINEUP line up events."));
30 RegisterEvent(wxT("wxEVT_SCROLL_LINEDOWN"), wxT("wxScrollEvent"),
31 _("Process wxEVT_SCROLL_LINEDOWN line down events."));
32 RegisterEvent(wxT("wxEVT_SCROLL_PAGEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_PAGEUP page up events."));
33 RegisterEvent(wxT("wxEVT_SCROLL_PAGEDOWN"), wxT("wxScrollEvent"),
34 _("Process wxEVT_SCROLL_PAGEDOWN page down events"));
35 RegisterEvent(wxT("wxEVT_SCROLL_THUMBTRACK"), wxT("wxScrollEvent"),
36 _("Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the user drags the "
37 "thumbtrack)."));
38 RegisterEvent(wxT("wxEVT_SCROLL_THUMBRELEASE"), wxT("wxScrollEvent"),
39 _("Process wxEVT_SCROLL_THUMBRELEASE thumb release events."));
40 RegisterEvent(wxT("wxEVT_SCROLL_CHANGED"), wxT("wxScrollEvent"),
41 _("Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only)."));
42
43 m_namePattern = wxT("m_slider");
44 SetName(GenerateName());
45 }
46
47 SliderWrapper::~SliderWrapper() {}
48
49 wxcWidget* SliderWrapper::Clone() const { return new SliderWrapper(); }
50
51 wxString SliderWrapper::CppCtorCode() const
52 {
53 // m_slider3 = new wxSlider( m_panel11, wxID_ANY, 150, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
54 wxString code;
55 code << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID()
56 << wxT(", ") << PropertyString(PROP_VALUE) << wxT(", ") << PropertyString(PROP_MINVALUE) << wxT(", ")
57 << PropertyString(PROP_MAXVALUE) << wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ")
58 << StyleFlags(wxT("0")) << wxT(");\n");
59 code << CPPCommonAttributes();
60 return code;
61 }
62
63 void SliderWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/slider.h>")); }
64
65 wxString SliderWrapper::GetWxClassName() const { return wxT("wxSlider"); }
66
67 void SliderWrapper::ToXRC(wxString& text, XRC_TYPE type) const
68 {
69 text << XRCPrefix() << XRCStyle() << XRCCommonAttributes() << wxT("<min>") << PropertyString(PROP_MINVALUE)
70 << wxT("</min>") << wxT("<max>") << PropertyString(PROP_MAXVALUE) << wxT("</max>") << XRCValue() << XRCSize()
71 << XRCSuffix();
72 }
73
74 void SliderWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
75 {
76 // First call the base-class for the standard things
77 wxcWidget::LoadPropertiesFromXRC(node);
78
79 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("min"));
80 if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); }
81
82 propertynode = XmlUtils::FindFirstByTagName(node, wxT("max"));
83 if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); }
84
85 propertynode = XmlUtils::FindFirstByTagName(node, wxT("value"));
86 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
87 }
88
89 void SliderWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node)
90 {
91 // First call the base-class for the standard things
92 wxcWidget::LoadPropertiesFromwxSmith(node);
93
94 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("min"));
95 if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); }
96
97 propertynode = XmlUtils::FindFirstByTagName(node, wxT("max"));
98 if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); }
99
100 propertynode = XmlUtils::FindFirstByTagName(node, wxT("value"));
101 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
102 }
103
104 void SliderWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
105 {
106 // First call the base-class for the standard things
107 wxcWidget::LoadPropertiesFromwxFB(node);
108
109 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "minValue");
110 if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); }
111
112 propertynode = XmlUtils::FindNodeByName(node, "property", "maxValue");
113 if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); }
114
115 propertynode = XmlUtils::FindNodeByName(node, "property", "value");
116 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
117 }