| 1 |
#include "toggle_button_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "bool_property.h" |
| 4 |
#include "string_property.h" |
| 5 |
#include "wxgui_defs.h" |
| 6 |
#include "xmlutils.h" |
| 7 |
#include <wx/button.h> |
| 8 |
|
| 9 |
ToggleButtonWrapper::ToggleButtonWrapper() |
| 10 |
: wxcWidget(ID_WXTOGGLEBUTTON) |
| 11 |
{ |
| 12 |
SetPropertyString(_("Common Settings"), "wxToggleButton"); |
| 13 |
AddProperty(new StringProperty(PROP_LABEL, _("My Button"), _("The button label"))); |
| 14 |
AddProperty(new BoolProperty(PROP_CHECKED, false, _("The button initial state"))); |
| 15 |
|
| 16 |
PREPEND_STYLE(wxBU_BOTTOM, false); |
| 17 |
PREPEND_STYLE(wxBU_EXACTFIT, false); |
| 18 |
PREPEND_STYLE(wxBU_LEFT, false); |
| 19 |
PREPEND_STYLE(wxBU_RIGHT, false); |
| 20 |
PREPEND_STYLE(wxBU_TOP, false); |
| 21 |
|
| 22 |
RegisterEventCommand(wxT("wxEVT_COMMAND_TOGGLEBUTTON_CLICKED"), _("Handles a toggle button click event.")); |
| 23 |
|
| 24 |
m_namePattern = wxT("m_toggleButton"); |
| 25 |
SetName(GenerateName()); |
| 26 |
} |
| 27 |
|
| 28 |
ToggleButtonWrapper::~ToggleButtonWrapper() {} |
| 29 |
|
| 30 |
wxcWidget* ToggleButtonWrapper::Clone() const { return new ToggleButtonWrapper(); } |
| 31 |
|
| 32 |
wxString ToggleButtonWrapper::CppCtorCode() const |
| 33 |
{ |
| 34 |
wxString cpp; |
| 35 |
cpp << CPPStandardWxCtorWithLabel(wxT("0")); |
| 36 |
cpp << GetName() << wxT("->SetValue(") << PropertyBool(PROP_CHECKED) << wxT(");\n"); |
| 37 |
return cpp; |
| 38 |
} |
| 39 |
|
| 40 |
void ToggleButtonWrapper::GetIncludeFile(wxArrayString& headers) const |
| 41 |
{ |
| 42 |
headers.Add(wxT("#include <wx/tglbtn.h>")); |
| 43 |
headers.Add(wxT("#include <wx/button.h>")); |
| 44 |
} |
| 45 |
|
| 46 |
wxString ToggleButtonWrapper::GetWxClassName() const { return wxT("wxToggleButton"); } |
| 47 |
|
| 48 |
void ToggleButtonWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 49 |
{ |
| 50 |
text << XRCPrefix() << XRCStyle() << XRCSize() << XRCLabel() << XRCCommonAttributes() << wxT("<checked>") |
| 51 |
<< PropertyString(PROP_CHECKED) << wxT("</checked>") << XRCSuffix(); |
| 52 |
} |
| 53 |
|
| 54 |
void ToggleButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 55 |
{ |
| 56 |
// First call the base-class for the standard things |
| 57 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 58 |
|
| 59 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); |
| 60 |
if(propertynode) { SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); } |
| 61 |
} |
| 62 |
|
| 63 |
void ToggleButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) |
| 64 |
{ |
| 65 |
// First call the base-class for the standard things |
| 66 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 67 |
|
| 68 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); |
| 69 |
if(propertynode) { SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); } |
| 70 |
} |
| 71 |
|
| 72 |
void ToggleButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 73 |
{ |
| 74 |
// First call the base-class for the standard things |
| 75 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 76 |
|
| 77 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); |
| 78 |
if(propertynode) { SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); } |
| 79 |
} |