| 1 |
#include "gauge_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "wxgui_defs.h" |
| 4 |
#include "wxgui_helpers.h" |
| 5 |
#include "xmlutils.h" |
| 6 |
#include <wx/gauge.h> |
| 7 |
|
| 8 |
GaugeWrapper::GaugeWrapper() |
| 9 |
: wxcWidget(ID_WXGAUGE) |
| 10 |
{ |
| 11 |
PREPEND_STYLE(wxGA_HORIZONTAL, true); |
| 12 |
PREPEND_STYLE(wxGA_VERTICAL, false); |
| 13 |
PREPEND_STYLE(wxGA_SMOOTH, false); |
| 14 |
|
| 15 |
AddProperty(new StringProperty( |
| 16 |
PROP_RANGE, wxT("100"), |
| 17 |
_("Integer range (maximum value) of the gauge. It is ignored when the gauge is used in indeterminate mode."))); |
| 18 |
AddProperty(new StringProperty(PROP_VALUE, wxT("10"), _("Sets the position of the gauge"))); |
| 19 |
|
| 20 |
m_namePattern = wxT("m_gauge"); |
| 21 |
SetName(GenerateName()); |
| 22 |
} |
| 23 |
|
| 24 |
GaugeWrapper::~GaugeWrapper() {} |
| 25 |
|
| 26 |
wxcWidget* GaugeWrapper::Clone() const { return new GaugeWrapper(); } |
| 27 |
|
| 28 |
wxString GaugeWrapper::CppCtorCode() const |
| 29 |
{ |
| 30 |
// wxGauge(wxWindow* parent, wxWindowID id, int range, const wxPoint& pos = wxDefaultPosition, const wxSize& size = |
| 31 |
// wxDefaultSize, long style = wxGA_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& |
| 32 |
// name = "gauge") |
| 33 |
wxString cpp; |
| 34 |
cpp << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID() |
| 35 |
<< wxT(", ") << PropertyString(PROP_RANGE) << wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() |
| 36 |
<< wxT(", ") << StyleFlags(wxT("wxGA_HORIZONTAL")) << wxT(");\n"); |
| 37 |
cpp << CPPCommonAttributes(); |
| 38 |
int pos = wxCrafter::ToNumber(PropertyString(PROP_VALUE), 0); |
| 39 |
cpp << GetName() << wxT("->SetValue(") << pos << wxT(");\n"); |
| 40 |
return cpp; |
| 41 |
} |
| 42 |
|
| 43 |
void GaugeWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/gauge.h>")); } |
| 44 |
|
| 45 |
wxString GaugeWrapper::GetWxClassName() const { return wxT("wxGauge"); } |
| 46 |
|
| 47 |
void GaugeWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 48 |
{ |
| 49 |
text << XRCPrefix() << wxT("<range>") << wxCrafter::ToNumber(PropertyString(PROP_RANGE), 100) << wxT("</range>") |
| 50 |
<< wxT("<value>") << wxCrafter::ToNumber(PropertyString(PROP_VALUE), 10) << wxT("</value>") << XRCStyle() |
| 51 |
<< XRCCommonAttributes() << XRCSize() << XRCSuffix(); |
| 52 |
} |
| 53 |
|
| 54 |
void GaugeWrapper::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("range")); |
| 60 |
if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } |
| 61 |
|
| 62 |
propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); |
| 63 |
if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } |
| 64 |
} |
| 65 |
|
| 66 |
void GaugeWrapper::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("range")); |
| 72 |
if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } |
| 73 |
|
| 74 |
propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); |
| 75 |
if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } |
| 76 |
} |
| 77 |
|
| 78 |
void GaugeWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 79 |
{ |
| 80 |
// First call the base-class for the standard things |
| 81 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 82 |
|
| 83 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "range"); |
| 84 |
if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } |
| 85 |
|
| 86 |
propertynode = XmlUtils::FindNodeByName(node, "property", "value"); |
| 87 |
if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } |
| 88 |
} |