Debian Codegraph @

wxcrafter/controls/scrolled_window_wrapper.cpp

raw
1 #include "scrolled_window_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxgui_defs.h"
4 #include "wxgui_helpers.h"
5 #include "xmlutils.h"
6 #include <wx/scrolwin.h>
7
8 ScrolledWindowWrapper::ScrolledWindowWrapper()
9 : wxcWidget(ID_WXSCROLLEDWIN)
10 {
11 EnableStyle(wxT("wxHSCROLL"), true);
12 EnableStyle(wxT("wxVSCROLL"), true);
13
14 SetPropertyString(_("Common Settings"), "wxScrolledWindow");
15 AddProperty(
16 new StringProperty(PROP_SCROLL_RATE_X, wxT("5"), _("Pixels per scroll unit in the horizontal direction")));
17 AddProperty(
18 new StringProperty(PROP_SCROLL_RATE_Y, wxT("5"), _("Pixels per scroll unit in the vertical direction")));
19
20 RegisterEvent("wxEVT_SCROLLWIN_TOP", "wxScrollWinEvent",
21 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_TOP scroll-to-top events"));
22 RegisterEvent("wxEVT_SCROLLWIN_BOTTOM", "wxScrollWinEvent",
23 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events"));
24 RegisterEvent("wxEVT_SCROLLWIN_LINEUP", "wxScrollWinEvent",
25 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_LINEUP line up events."));
26 RegisterEvent("wxEVT_SCROLLWIN_LINEDOWN", "wxScrollWinEvent",
27 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_LINEDOWN line down events"));
28 RegisterEvent("wxEVT_SCROLLWIN_PAGEUP", "wxScrollWinEvent",
29 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_PAGEUP page up events"));
30 RegisterEvent("wxEVT_SCROLLWIN_PAGEDOWN", "wxScrollWinEvent",
31 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_PAGEDOWN page down events"));
32 RegisterEvent("wxEVT_SCROLLWIN_THUMBTRACK", "wxScrollWinEvent",
33 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events (frequent events sent "
34 "as the user drags the thumbtrack)"));
35 RegisterEvent("wxEVT_SCROLLWIN_THUMBRELEASE", "wxScrollWinEvent",
36 _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_THUMBRELEASE thumb release events"));
37 m_namePattern = wxT("m_scrollWin");
38 SetName(GenerateName());
39 }
40
41 ScrolledWindowWrapper::~ScrolledWindowWrapper() {}
42
43 wxcWidget* ScrolledWindowWrapper::Clone() const { return new ScrolledWindowWrapper(); }
44
45 wxString ScrolledWindowWrapper::CppCtorCode() const
46 {
47 wxString code;
48 code << CPPStandardWxCtor(wxT("wxHSCROLL | wxVSCROLL"));
49
50 code << GetName() << wxT("->SetScrollRate(") << PropertyString(PROP_SCROLL_RATE_X) << wxT(", ")
51 << PropertyString(PROP_SCROLL_RATE_Y) << wxT(");\n");
52 return code;
53 }
54
55 void ScrolledWindowWrapper::GetIncludeFile(wxArrayString& headers) const
56 {
57 headers.Add(wxT("#include <wx/scrolwin.h>"));
58 }
59
60 wxString ScrolledWindowWrapper::GetWxClassName() const { return wxT("wxScrolledWindow"); }
61
62 void ScrolledWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const
63 {
64 int xx = wxCrafter::ToNumber(PropertyString(PROP_SCROLL_RATE_X), 5);
65 int yy = wxCrafter::ToNumber(PropertyString(PROP_SCROLL_RATE_Y), 5);
66 text << XRCPrefix() << XRCCommonAttributes() << XRCStyle() << XRCSize() << wxT("<scrollrate>") << xx << wxT(",")
67 << yy << wxT("</scrollrate>");
68
69 ChildrenXRC(text, type);
70
71 text << XRCSuffix();
72 }
73
74 void ScrolledWindowWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
75 {
76 // First call the base-class for the standard things
77 wxcWidget::LoadPropertiesFromXRC(node);
78
79 // Neither XRCed nor wxFB nor wxSmith actually produce any property here, but the doc says:
80 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("scrollrate"));
81 if(propertynode) {
82 wxSize size = wxCrafter::DecodeSize(propertynode->GetNodeContent());
83 if(size.x != -1) { SetPropertyString(PROP_SCROLL_RATE_X, wxCrafter::ToString(size.x)); }
84 if(size.y != -1) { SetPropertyString(PROP_SCROLL_RATE_Y, wxCrafter::ToString(size.y)); }
85 }
86 }
87
88 void ScrolledWindowWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
89 {
90 // First call the base-class for the standard things
91 wxcWidget::LoadPropertiesFromwxFB(node);
92
93 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "scroll_rate_x");
94 if(propertynode) { SetPropertyString(PROP_SCROLL_RATE_X, propertynode->GetNodeContent()); }
95
96 propertynode = XmlUtils::FindNodeByName(node, "property", "scroll_rate_y");
97 if(propertynode) { SetPropertyString(PROP_SCROLL_RATE_Y, propertynode->GetNodeContent()); }
98 }