| 1 |
#include "check_box_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/checkbox.h> |
| 8 |
|
| 9 |
CheckBoxWrapper::CheckBoxWrapper() |
| 10 |
: wxcWidget(ID_WXCHECKBOX) |
| 11 |
{ |
| 12 |
SetPropertyString(_("Common Settings"), "wxCheckBox"); |
| 13 |
AddProperty(new StringProperty(PROP_LABEL, _("My CheckBox"), _("The Checkbox label"))); |
| 14 |
AddProperty(new BoolProperty(PROP_VALUE, false, _("Value"))); |
| 15 |
|
| 16 |
PREPEND_STYLE(wxCHK_2STATE, false); |
| 17 |
PREPEND_STYLE(wxCHK_3STATE, false); |
| 18 |
PREPEND_STYLE(wxCHK_ALLOW_3RD_STATE_FOR_USER, false); |
| 19 |
PREPEND_STYLE(wxALIGN_RIGHT, false); |
| 20 |
|
| 21 |
RegisterEventCommand(wxT("wxEVT_COMMAND_CHECKBOX_CLICKED"), |
| 22 |
_("Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked.")); |
| 23 |
m_namePattern = wxT("m_checkBox"); |
| 24 |
SetName(GenerateName()); |
| 25 |
} |
| 26 |
|
| 27 |
CheckBoxWrapper::~CheckBoxWrapper() {} |
| 28 |
|
| 29 |
wxcWidget* CheckBoxWrapper::Clone() const { return new CheckBoxWrapper(); } |
| 30 |
wxString CheckBoxWrapper::CppCtorCode() const |
| 31 |
{ |
| 32 |
wxString code; |
| 33 |
code << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID() |
| 34 |
<< wxT(", ") << Label() << wxT(", ") << wxT("wxDefaultPosition") << wxT(", ") << SizeAsString() << wxT(", ") |
| 35 |
<< StyleFlags(wxT("0")) << wxT(");\n"); |
| 36 |
|
| 37 |
if(PropertyString(PROP_VALUE) == wxT("1")) { |
| 38 |
code << GetName() << wxT("->SetValue(true);\n"); |
| 39 |
|
| 40 |
} else { |
| 41 |
code << GetName() << wxT("->SetValue(false);\n"); |
| 42 |
} |
| 43 |
code << CPPCommonAttributes(); |
| 44 |
return code; |
| 45 |
} |
| 46 |
|
| 47 |
void CheckBoxWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/checkbox.h>")); } |
| 48 |
|
| 49 |
wxString CheckBoxWrapper::GetWxClassName() const { return wxT("wxCheckBox"); } |
| 50 |
|
| 51 |
void CheckBoxWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 52 |
{ |
| 53 |
text << XRCPrefix() << XRCCommonAttributes() << XRCStyle() << XRCSize() << XRCLabel() << wxT("<checked>") |
| 54 |
<< PropertyString(PROP_VALUE) << wxT("</checked>") << XRCSuffix(); |
| 55 |
} |
| 56 |
|
| 57 |
void CheckBoxWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 58 |
{ |
| 59 |
// First call the base-class for the standard things |
| 60 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 61 |
|
| 62 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); |
| 63 |
if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } |
| 64 |
} |
| 65 |
|
| 66 |
void CheckBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) |
| 67 |
{ |
| 68 |
// First call the base-class for the standard things |
| 69 |
wxcWidget::LoadPropertiesFromwxSmith(node); |
| 70 |
|
| 71 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); |
| 72 |
if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } |
| 73 |
} |
| 74 |
|
| 75 |
void CheckBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 76 |
{ |
| 77 |
// First call the base-class for the standard things |
| 78 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 79 |
|
| 80 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", wxT("checked")); |
| 81 |
if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } |
| 82 |
} |