Debian Codegraph @

wxcrafter/controls/scroll_bar_wrapper.cpp

raw
1 #include "scroll_bar_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxgui_defs.h"
4 #include "wxgui_helpers.h"
5 #include "xmlutils.h"
6 #include <wx/scrolbar.h>
7
8 ScrollBarWrapper::ScrollBarWrapper()
9 : wxcWidget(ID_WXSCROLLBAR)
10 {
11 PREPEND_STYLE_STR(wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL, true);
12 PREPEND_STYLE_STR(wxT("wxSB_VERTICAL"), wxSB_VERTICAL, false);
13
14 RegisterEvent(wxT("wxEVT_SCROLL_TOP"), wxT("wxScrollEvent"),
15 _("Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position)"));
16 RegisterEvent(wxT("wxEVT_SCROLL_BOTTOM"), wxT("wxScrollEvent"),
17 _("Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position)."));
18 RegisterEvent(wxT("wxEVT_SCROLL_LINEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_LINEUP line up events."));
19 RegisterEvent(wxT("wxEVT_SCROLL_LINEDOWN"), wxT("wxScrollEvent"),
20 _("Process wxEVT_SCROLL_LINEDOWN line down events."));
21 RegisterEvent(wxT("wxEVT_SCROLL_PAGEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_PAGEUP page up events."));
22 RegisterEvent(wxT("wxEVT_SCROLL_PAGEDOWN"), wxT("wxScrollEvent"),
23 _("Process wxEVT_SCROLL_PAGEDOWN page down events"));
24 RegisterEvent(wxT("wxEVT_SCROLL_THUMBTRACK"), wxT("wxScrollEvent"),
25 _("Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the user drags the "
26 "thumbtrack)."));
27 RegisterEvent(wxT("wxEVT_SCROLL_THUMBRELEASE"), wxT("wxScrollEvent"),
28 _("Process wxEVT_SCROLL_THUMBRELEASE thumb release events."));
29 RegisterEvent(wxT("wxEVT_SCROLL_CHANGED"), wxT("wxScrollEvent"),
30 _("Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only)."));
31
32 SetPropertyString(_("Common Settings"), "wxScrollBar");
33 AddProperty(new StringProperty(PROP_VALUE, wxT("0"), _("The position of the scrollbar in scroll units.")));
34 AddProperty(new StringProperty(PROP_THUMBSIZE, wxT("1"),
35 _("The size of the thumb, or visible portion of the scrollbar, in scroll units.")));
36 AddProperty(new StringProperty(PROP_RANGE, wxT("10"), _("The maximum position of the scrollbar.")));
37 AddProperty(
38 new StringProperty(PROP_PAGESIZE, wxT("1"),
39 _("The size of the page size in scroll units. This is the number of units the scrollbar "
40 "will scroll when it is paged up or down.\nOften it is the same as the thumb size.")));
41
42 m_namePattern = wxT("m_scrollBar");
43 SetName(GenerateName());
44 }
45
46 ScrollBarWrapper::~ScrollBarWrapper() {}
47
48 wxcWidget* ScrollBarWrapper::Clone() const { return new ScrollBarWrapper(); }
49
50 wxString ScrollBarWrapper::CppCtorCode() const
51 {
52 wxString code;
53 code << CPPStandardWxCtor(wxT("wxSB_HORIZONTAL"));
54 code << GetName() << wxT("->SetScrollbar(") << PropertyString(PROP_VALUE) << wxT(", ")
55 << PropertyString(PROP_THUMBSIZE) << wxT(", ") << PropertyString(PROP_RANGE) << wxT(", ")
56 << PropertyString(PROP_PAGESIZE) << wxT(");\n");
57 return code;
58 }
59
60 void ScrollBarWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/scrolbar.h>")); }
61
62 wxString ScrollBarWrapper::GetWxClassName() const { return wxT("wxScrollBar"); }
63
64 void ScrollBarWrapper::ToXRC(wxString& text, XRC_TYPE type) const
65 {
66 text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << wxT("<value>")
67 << wxCrafter::XMLEncode(PropertyString(PROP_VALUE)) << wxT("</value>") << wxT("<thumbsize>")
68 << wxCrafter::XMLEncode(PropertyString(PROP_THUMBSIZE)) << wxT("</thumbsize>") << wxT("<range>")
69 << wxCrafter::XMLEncode(PropertyString(PROP_RANGE)) << wxT("</range>") << wxT("<pagesize>")
70 << wxCrafter::XMLEncode(PropertyString(PROP_RANGE)) << wxT("</pagesize>") << XRCSuffix();
71 }
72
73 void ScrollBarWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
74 {
75 // First call the base-class for the standard things
76 wxcWidget::LoadPropertiesFromXRC(node);
77
78 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("thumbsize"));
79 if(propertynode) { SetPropertyString(PROP_THUMBSIZE, propertynode->GetNodeContent()); }
80
81 propertynode = XmlUtils::FindFirstByTagName(node, wxT("range"));
82 if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); }
83
84 propertynode = XmlUtils::FindFirstByTagName(node, wxT("pagesize"));
85 if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); }
86
87 propertynode = XmlUtils::FindFirstByTagName(node, wxT("value"));
88 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
89 }
90
91 void ScrollBarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
92 {
93 // First call the base-class for the standard things
94 wxcWidget::LoadPropertiesFromwxFB(node);
95
96 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "thumbsize");
97 if(propertynode) { SetPropertyString(PROP_THUMBSIZE, propertynode->GetNodeContent()); }
98
99 propertynode = XmlUtils::FindNodeByName(node, "property", "range");
100 if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); }
101
102 propertynode = XmlUtils::FindNodeByName(node, "property", "pagesize");
103 if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); }
104
105 propertynode = XmlUtils::FindNodeByName(node, "property", "value");
106 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
107 }