Debian Codegraph @

wxcrafter/controls/status_bar_wrapper.cpp

raw
1 #include "status_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/statusbr.h>
7
8 StatusBarWrapper::StatusBarWrapper()
9 : wxcWidget(ID_WXSTATUSBAR)
10 {
11 PREPEND_STYLE_FALSE(wxSTB_SIZEGRIP);
12 PREPEND_STYLE_FALSE(wxSTB_SHOW_TIPS);
13 PREPEND_STYLE_FALSE(wxSTB_ELLIPSIZE_START);
14 PREPEND_STYLE_FALSE(wxSTB_ELLIPSIZE_MIDDLE);
15 PREPEND_STYLE_FALSE(wxSTB_ELLIPSIZE_END);
16 PREPEND_STYLE_TRUE(wxSTB_DEFAULT_STYLE);
17
18 SetPropertyString(_("Common Settings"), "wxStatusBar");
19 AddProperty(new StringProperty(PROP_FIELD_COUNT, wxT("1"), _("Sets the number of fields")));
20
21 m_namePattern = wxT("m_statusBar");
22 SetName(GenerateName());
23 }
24
25 StatusBarWrapper::~StatusBarWrapper() {}
26
27 wxcWidget* StatusBarWrapper::Clone() const { return new StatusBarWrapper(); }
28
29 wxString StatusBarWrapper::CppCtorCode() const
30 {
31 // wxStatusBar(wxWindow* parent, wxWindowID id = wxID_ANY, long style = wxST_SIZEGRIP, const wxString& name =
32 // "statusBar")
33 wxString code;
34 code << GetName() << wxT(" = new ") << GetRealClassName() << wxT("(") << GetWindowParent() << wxT(", ")
35 << WindowID() << wxT(", ") << StyleFlags(wxT("wxST_SIZEGRIP")) << wxT(");\n");
36 code << GetName() << wxT("->SetFieldsCount(") << wxCrafter::ToNumber(PropertyString(PROP_FIELD_COUNT), 1)
37 << wxT(");\n");
38 code << GetWindowParent() << wxT("->SetStatusBar(") << GetName() << wxT(");\n");
39 return code;
40 }
41
42 void StatusBarWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/statusbr.h>")); }
43
44 wxString StatusBarWrapper::GetWxClassName() const { return wxT("wxStatusBar"); }
45
46 void StatusBarWrapper::ToXRC(wxString& text, XRC_TYPE type) const
47 {
48 if(type == XRC_DESIGNER) { return; }
49
50 text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes() << wxT("<fields>")
51 << wxCrafter::ToNumber(PropertyString(PROP_FIELD_COUNT), 1) << wxT("</fields>") << XRCSuffix();
52 }
53
54 wxString StatusBarWrapper::DesignerXRC() const
55 {
56 wxString text;
57 text << wxT("<object class=\"") << GetWxClassName() << wxT("\" name=\"STATUS_BAR_ID\">");
58 text << wxT("<style>") << wxT("</style>") // No style
59 << XRCSize() << XRCCommonAttributes() << wxT("<fields>")
60 << wxCrafter::ToNumber(PropertyString(PROP_FIELD_COUNT), 1) << wxT("</fields>") << XRCSuffix();
61 return text;
62 }
63
64 void StatusBarWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
65 {
66 // First call the base-class for the standard things
67 wxcWidget::LoadPropertiesFromXRC(node);
68
69 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("fields"));
70 if(propertynode) { SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); }
71 }
72
73 void StatusBarWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node)
74 {
75 // First call the base-class for the standard things
76 wxcWidget::LoadPropertiesFromwxSmith(node);
77
78 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("fields"));
79 if(propertynode) { SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); }
80 }
81
82 void StatusBarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
83 {
84 // First call the base-class for the standard things
85 wxcWidget::LoadPropertiesFromwxFB(node);
86
87 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "fields");
88 if(propertynode) { SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); }
89 }