Debian Codegraph @

wxcrafter/sizers/std_button_wrapper.cpp

raw
1 #include "std_button_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "bool_property.h"
4 #include "choice_property.h"
5 #include "multi_strings_property.h"
6 #include "wxgui_defs.h"
7 #include "xmlutils.h"
8
9 StdButtonWrapper::StdButtonWrapper()
10 : wxcWidget(ID_WXSTDBUTTON)
11 {
12 m_properties.DeleteValues();
13 wxArrayString ids;
14 ids.Add("wxID_OK");
15 ids.Add("wxID_YES");
16 ids.Add("wxID_SAVE");
17 ids.Add("wxID_APPLY");
18 ids.Add("wxID_CLOSE");
19 ids.Add("wxID_NO");
20 ids.Add("wxID_CANCEL");
21 ids.Add("wxID_HELP");
22 ids.Add("wxID_CONTEXT_HELP");
23
24 RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), wxT("wxCommandEvent"),
25 _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."),
26 wxT("wxCommandEventHandler"));
27
28 AddProperty(new CategoryProperty(_("Standard wxButton")));
29 AddProperty(new ChoiceProperty(PROP_WINDOW_ID, ids, 0, _("Button ID")));
30 AddProperty(new StringProperty(PROP_NAME, wxT(""), _("C++ member name")));
31 AddProperty(new MultiStringsProperty(PROP_TOOLTIP, _("Tooltip"), wxT("\\n"), _("Tooltip text:")));
32 AddProperty(new BoolProperty(PROP_DEFAULT_BUTTON, false, wxT("Make this button the default button")));
33 m_namePattern = "m_button";
34 SetName(GenerateName());
35 }
36
37 StdButtonWrapper::~StdButtonWrapper() {}
38
39 wxcWidget* StdButtonWrapper::Clone() const { return new StdButtonWrapper(); }
40
41 wxString StdButtonWrapper::CppCtorCode() const
42 {
43 wxString code;
44 code << CPPStandardWxCtorWithLabel("0");
45 if(PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { code << GetName() << wxT("->SetDefault();\n"); }
46 code << CPPCommonAttributes();
47 return code;
48 }
49
50 void StdButtonWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/button.h>")); }
51
52 wxString StdButtonWrapper::GetWxClassName() const { return "wxButton"; }
53
54 void StdButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const
55 {
56 text << "<object class=\"button\">" << wxT("<object class=\"") << GetWxClassName() << wxT("\" name=\"") << GetId()
57 << wxT("\">") << XRCLabel() << XRCStyle() << XRCSize() << XRCCommonAttributes() << wxT("<default>")
58 << PropertyString(PROP_DEFAULT_BUTTON) << wxT("</default>") << XRCSuffix() // wxButton
59 << XRCSuffix(); // button
60 }
61
62 void StdButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
63 {
64 // First call the base-class for the standard things
65 wxcWidget::LoadPropertiesFromXRC(node);
66
67 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("default"));
68 if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); }
69 }
70
71 // wxFB doesn't do anything here