Debian Codegraph @

wxcrafter/controls/radio_button_wrapper.cpp

raw
1 #include "radio_button_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "bool_property.h"
4 #include "string_property.h"
5 #include "xmlutils.h"
6
7 RadioButtonWrapper::RadioButtonWrapper()
8 : wxcWidget(ID_WXRADIOBUTTON)
9 {
10 PREPEND_STYLE(wxRB_GROUP, false);
11 PREPEND_STYLE(wxRB_SINGLE, false);
12
13 SetPropertyString(_("Common Settings"), "wxRadioButton");
14 AddProperty(new StringProperty(PROP_LABEL, _("My RadioButton"), _("Label")));
15 AddProperty(new BoolProperty(PROP_VALUE, true, _("Initial value")));
16
17 RegisterEventCommand(wxT("wxEVT_COMMAND_RADIOBUTTON_SELECTED"),
18 _("Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED event, when the radiobutton is clicked."));
19
20 m_namePattern = wxT("m_radioButton");
21 SetName(GenerateName());
22 }
23
24 RadioButtonWrapper::~RadioButtonWrapper() {}
25
26 wxcWidget* RadioButtonWrapper::Clone() const { return new RadioButtonWrapper(); }
27
28 wxString RadioButtonWrapper::CppCtorCode() const
29 {
30 // m_radioBtn3 = new wxRadioButton( m_panel11, wxID_ANY, wxT("RadioBtn"), wxDefaultPosition, wxDefaultSize,
31 // wxRB_USE_CHECKBOX ); m_radioBtn3->SetValue( true );
32
33 wxString code;
34 code << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID()
35 << wxT(", ") << Label() << wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ")
36 << StyleFlags(wxT("0")) << wxT(");\n");
37 code << CPPCommonAttributes();
38 code << GetName() << wxT("->SetValue(") << PropertyString(PROP_VALUE) << wxT(");\n");
39 return code;
40 }
41
42 void RadioButtonWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/radiobut.h>")); }
43
44 wxString RadioButtonWrapper::GetWxClassName() const { return wxT("wxRadioButton"); }
45
46 void RadioButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const
47 {
48 text << XRCPrefix() << XRCStyle() << XRCLabel() << XRCCommonAttributes() << XRCValue() << XRCSuffix();
49 }
50
51 void RadioButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
52 {
53 // First call the base-class for the standard things
54 wxcWidget::LoadPropertiesFromXRC(node);
55
56 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value"));
57 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
58 }
59
60 void RadioButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node)
61 {
62 // First call the base-class for the standard things
63 wxcWidget::LoadPropertiesFromwxSmith(node);
64
65 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("label"));
66 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
67 propertynode = XmlUtils::FindFirstByTagName(node, wxT("selected"));
68 if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); }
69 }
70
71 void RadioButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
72 {
73 // First call the base-class for the standard things
74 wxcWidget::LoadPropertiesFromwxFB(node);
75
76 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value");
77 if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); }
78 }