| 1 |
#include "timer_wrapper.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "bool_property.h" |
| 5 |
#include "category_property.h" |
| 6 |
#include "int_property.h" |
| 7 |
#include "wxgui_helpers.h" |
| 8 |
|
| 9 |
TimerWrapper::TimerWrapper() |
| 10 |
: wxcWidget(ID_WXTIMER) |
| 11 |
{ |
| 12 |
m_styles.Clear(); |
| 13 |
m_properties.DeleteValues(); |
| 14 |
m_sizerFlags.Clear(); |
| 15 |
|
| 16 |
SetPropertyString(_("Common Settings"), "wxTimer"); |
| 17 |
AddProperty(new CategoryProperty(_("wxTimer"))); |
| 18 |
AddProperty(new StringProperty(PROP_NAME, "", _("Control name"))); |
| 19 |
AddProperty(new IntProperty(PROP_INTERVAL, 1000, _("Sets the current interval for the timer (in milliseconds)"))); |
| 20 |
AddProperty(new BoolProperty(PROP_START_TIMER, true, _("Start the timer"))); |
| 21 |
AddProperty( |
| 22 |
new BoolProperty(PROP_ONE_SHOT_TIMER, false, |
| 23 |
_("A one shot timer - sets whether the timer event is called repeatedly or only once"))); |
| 24 |
RegisterEvent("wxEVT_TIMER", "wxTimerEvent", _("Process a timer event")); |
| 25 |
|
| 26 |
m_namePattern = "m_timer"; |
| 27 |
SetName(GenerateName()); |
| 28 |
} |
| 29 |
|
| 30 |
TimerWrapper::~TimerWrapper() {} |
| 31 |
|
| 32 |
wxcWidget* TimerWrapper::Clone() const { return new TimerWrapper(); } |
| 33 |
|
| 34 |
wxString TimerWrapper::CppCtorCode() const |
| 35 |
{ |
| 36 |
int interval = wxCrafter::ToNumber(PropertyString(PROP_INTERVAL), 1000); |
| 37 |
wxString cppCode; |
| 38 |
cppCode << GetName() << " = new " << GetRealClassName() << ";\n"; |
| 39 |
if(PropertyBool(PROP_START_TIMER) == "true") { |
| 40 |
cppCode << GetName() << "->Start(" << interval << ", " << PropertyBool(PROP_ONE_SHOT_TIMER) << ");\n"; |
| 41 |
} |
| 42 |
return cppCode; |
| 43 |
} |
| 44 |
|
| 45 |
void TimerWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/timer.h>"); } |
| 46 |
|
| 47 |
wxString TimerWrapper::GetWxClassName() const { return "wxTimer"; } |
| 48 |
|
| 49 |
void TimerWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 50 |
{ |
| 51 |
// Not supported |
| 52 |
wxUnusedVar(text); |
| 53 |
wxUnusedVar(type); |
| 54 |
} |
| 55 |
|
| 56 |
wxString TimerWrapper::CppDtorCode() const |
| 57 |
{ |
| 58 |
wxString cppCode; |
| 59 |
cppCode << " " << GetName() << "->Stop();\n"; |
| 60 |
cppCode << " wxDELETE( " << GetName() << " );\n"; |
| 61 |
return cppCode; |
| 62 |
} |