#include <timer.h>
Inheritance diagram for Wt::Timer:
Public Types | |
typedef std::list< Object * > | List |
Public Member Functions | |
Timer (Object *parent=0, const std::string &name="Timer::anon") | |
Create a timer. | |
bool | isActive () const |
int | start (int msec, bool sshot=false) |
void | changeInterval (int msec) |
void | stop () |
int | timerId () const |
Object * | parent () const |
const List & | children () const |
List & | children () |
bool | isDescendant (const Object *p) const |
virtual void | insertChild (Object *obj) |
virtual void | removeChild (Object *obj) |
void | reparent (Object *new_parent) |
template<typename T> | |
void | deleteFirstChild () |
template<typename T> | |
void | deleteLastChild () |
template<typename T> | |
void | deleteAllChildren () |
Object * | topParent () const |
returns top level parent: it may return itself | |
const std::string & | name () const |
void | installEventFilter (const Object *filterObj) |
void | removeEventFilter (const Object *obj) |
virtual bool | eventFilter (Object *, Event *) |
int | startTimer (int interval) |
void | killTimer (int id) |
void | killTimers () |
virtual bool | event (Event *e) |
event handling | |
Public Attributes | |
sigc::signal< void > | timeout |
Emitted when the timer is triggered. | |
Signal01< void, const Object * > | destroyed |
signals | |
Protected Member Functions | |
virtual void | childEvent (ChildEvent *) |
event handling specialization | |
virtual void | customEvent (CustomEvent *) |
bool | filterEvent (Event *) |
Private Member Functions | |
virtual void | timerEvent (TimerEvent *e) |
Private Attributes | |
int | timerid_ |
bool | sshot_ |
int | delivered_ |
Definition at line 29 of file timer.h.
typedef std::list<Object*> Wt::Object::List [inherited] |
Wt::Timer::Timer | ( | Object * | parent = 0 , |
|
const std::string & | name = "Timer::anon" | |||
) |
void Wt::Timer::changeInterval | ( | int | msec | ) |
virtual void Wt::Object::childEvent | ( | ChildEvent * | ) | [inline, protected, virtual, inherited] |
event handling specialization
Reimplemented in Wt::Window::Frame.
Definition at line 146 of file object.h.
Referenced by Wt::Object::event().
List& Wt::Object::children | ( | ) | [inline, inherited] |
Definition at line 61 of file object.h.
References Wt::Object::children_.
00061 { 00062 return children_; 00063 }
const List& Wt::Object::children | ( | ) | const [inline, inherited] |
Definition at line 57 of file object.h.
References Wt::Object::children_.
Referenced by Wt::RootWindow::blit_region_ex(), Wt::Widget::childAt(), Wt::Object::deleteAllChildren(), Wt::Object::deleteFirstChild(), Wt::Object::deleteLastChild(), Wt::Widget::focusNextPrevChild(), Wt::Widget::fontChange(), Wt::Widget::lower(), Wt::postLayoutHintEventRecursively(), and Wt::Widget::raise().
00057 { 00058 return children_; 00059 }
virtual void Wt::Object::customEvent | ( | CustomEvent * | ) | [inline, protected, virtual, inherited] |
void Wt::Object::deleteAllChildren | ( | ) | [inline, inherited] |
Definition at line 106 of file object.h.
References Wt::Object::children().
00106 { 00107 List::iterator it(children().begin()); 00108 List::iterator end(children().end()); 00109 00110 while (it != end) { 00111 T *t = dynamic_cast<T *>(*it); 00112 // before iteration invalidation 00113 ++it; 00114 // this will invalidate the iterator 00115 if (t) { 00116 delete t; 00117 } 00118 } 00119 }
Here is the call graph for this function:
void Wt::Object::deleteFirstChild | ( | ) | [inline, inherited] |
Definition at line 72 of file object.h.
References Wt::Object::children().
00072 { 00073 List::iterator it(children().begin()); 00074 List::iterator end(children().end()); 00075 00076 while (it != end) { 00077 T *t = dynamic_cast<T *>(*it); 00078 // before iteration invalidation 00079 ++it; 00080 // this will invalidate the iterator 00081 if (t) { 00082 delete t; 00083 break; 00084 } 00085 } 00086 }
Here is the call graph for this function:
void Wt::Object::deleteLastChild | ( | ) | [inline, inherited] |
Definition at line 89 of file object.h.
References Wt::Object::children().
00089 { 00090 List::reverse_iterator it(children().rbegin()); 00091 List::reverse_iterator end(children().rend()); 00092 00093 while (it != end) { 00094 T *t = dynamic_cast<T *>(*it); 00095 // before iteration invalidation 00096 ++it; 00097 // this will invalidate the iterator 00098 if (t) { 00099 delete t; 00100 break; 00101 } 00102 } 00103 }
Here is the call graph for this function:
bool Wt::Object::event | ( | Event * | e | ) | [virtual, inherited] |
event handling
Reimplemented in Wt::Application, and Wt::Widget.
Definition at line 173 of file object.cpp.
References Wt::Object::childEvent(), Wt::Event::ChildInserted, Wt::Event::ChildRemoved, Wt::Object::customEvent(), Wt::Object::filterEvent(), Wt::SDLTimer::scheduleNext(), Wt::Object::timer(), Wt::Event::Timer, Wt::Object::timerEvent(), Wt::Event::type(), and Wt::Event::User.
Referenced by Wt::Widget::event(), Wt::Application::notify(), and Wt::Application::postEvent().
00173 { 00174 bool handled = true; 00175 00176 if (filterEvent(e)) 00177 return true; 00178 00179 switch (e->type()) { 00180 case Event::Timer: { 00181 TimerEvent *te = static_cast<TimerEvent *>(e); 00182 int id = te->timerid(); 00183 if (timer(id)) { 00184 timerEvent(te); 00185 } 00186 // if it is signle shot it may have been killed 00187 // during eventhandling 00188 SDLTimer *t = timer(id); 00189 if (t) 00190 t->scheduleNext(); 00191 } 00192 break; 00193 case Event::ChildInserted: 00194 case Event::ChildRemoved: 00195 childEvent(static_cast<ChildEvent *>(e)); 00196 break; 00197 default: 00198 if (e->type() >= Event::User) { 00199 customEvent(static_cast<CustomEvent *>(e)); 00200 } else { 00201 handled = false; 00202 } 00203 break; 00204 } 00205 00206 return handled; 00207 }
Here is the call graph for this function:
Reimplemented in Wt::Layout.
Definition at line 130 of file object.h.
Referenced by Wt::Layout::eventFilter().
bool Wt::Object::filterEvent | ( | Event * | ) | [protected, inherited] |
Definition at line 164 of file object.cpp.
References Wt::Object::eventFilters_.
Referenced by Wt::Object::event(), and Wt::Application::event().
00164 { 00165 for (List::iterator filter(eventFilters_.begin()), 00166 end(eventFilters_.end()); filter != end; ++filter) { 00167 if ((*filter)->eventFilter(this, e)) 00168 return true; 00169 } 00170 return false; 00171 }
void Wt::Object::insertChild | ( | Object * | obj | ) | [virtual, inherited] |
Definition at line 81 of file object.cpp.
References Wt::Event::ChildInserted, Wt::Object::children_, Wt::Object::parent_, and Wt::Application::postEvent().
Referenced by Wt::Object::Object(), and Wt::Object::reparent().
00081 { 00082 children_.push_back(obj); 00083 obj->parent_ = this; 00084 Event *child_event = new ChildEvent(Event::ChildInserted, obj); 00085 Application::postEvent(this, child_event); 00086 }
Here is the call graph for this function:
void Wt::Object::installEventFilter | ( | const Object * | filterObj | ) | [inherited] |
Definition at line 124 of file object.cpp.
References Wt::Object::destroyed, Wt::Object::eventFilters_, and Wt::Object::removeEventFilter().
Referenced by Wt::Widget::setLayout().
00124 { 00125 // we have to deconstify here. We cannot deliver event to const objects 00126 Object *obj = const_cast<Object *>(filterObj); 00127 eventFilters_.push_back(obj); 00128 obj->destroyed.connect(sigc::slot1<void, const Object *>( 00129 sigc::mem_fun(*this, &Object::removeEventFilter))); 00130 }
Here is the call graph for this function:
bool Wt::Timer::isActive | ( | ) | const [inline] |
bool Wt::Object::isDescendant | ( | const Object * | p | ) | const [inherited] |
Definition at line 67 of file object.cpp.
References Wt::Object::parent().
Referenced by Wt::SDLInput::EventInfo::EventInfo(), and Wt::SDLInput::handleKeyEvent().
00067 { 00068 if (!p) 00069 return false; 00070 00071 const Object *q = this; 00072 00073 do { 00074 if (p == q) 00075 return true; 00076 } while ((q = q->parent())); 00077 00078 return false; 00079 }
Here is the call graph for this function:
void Wt::Object::killTimer | ( | int | id | ) | [inherited] |
void Wt::Object::killTimers | ( | ) | [inherited] |
Definition at line 150 of file object.cpp.
References Wt::Object::timers_.
Referenced by Wt::Object::~Object().
00150 { 00151 uint n = timers_.size() + 1; 00152 for (uint i = 1; i < n; i++) { 00153 delete timers_[i]; 00154 } 00155 timers_.clear(); 00156 }
const std::string& Wt::Object::name | ( | ) | const [inline, inherited] |
Definition at line 124 of file object.h.
References Wt::Object::name_.
Referenced by Wt::operator<<(), Wt::Application::parseArgs(), and Wt::PushButton::setButtonSize().
00124 { 00125 return name_; 00126 }
Object* Wt::Object::parent | ( | ) | const [inline, inherited] |
Definition at line 53 of file object.h.
References Wt::Object::parent_.
Referenced by Wt::Widget::event(), Wt::Widget::focusNextPrevChild(), Wt::Window::Frame::Frame(), Wt::Widget::is_hidden(), Wt::Object::isDescendant(), Wt::Layout::isTopLevel(), Wt::Layout::Layout(), Wt::Widget::lower(), Wt::Layout::mainWidget(), Wt::operator<<(), Wt::Widget::paintEvent(), Wt::Widget::parentWidget(), Wt::Application::postEvent(), Wt::Widget::raise(), Wt::Widget::updateGeometry(), Wt::Widget::Widget(), Wt::Window::Window(), Wt::Layout::~Layout(), and Wt::Widget::~Widget().
00053 { 00054 return parent_; 00055 };
void Wt::Object::removeChild | ( | Object * | obj | ) | [virtual, inherited] |
Definition at line 88 of file object.cpp.
References Wt::Event::ChildRemoved, Wt::Object::children_, Wt::Object::parent_, and Wt::Application::postEvent().
Referenced by Wt::Object::reparent(), and Wt::Object::~Object().
00088 { 00089 List::iterator end = children_.end(); 00090 List::iterator p = find(children_.begin(), end, obj); 00091 00092 if (p != end) { 00093 children_.erase(p); 00094 obj->parent_ = 0; 00095 Event *child_event = new ChildEvent(Event::ChildRemoved, obj); 00096 Application::postEvent(this, child_event); 00097 } 00098 }
Here is the call graph for this function:
void Wt::Object::removeEventFilter | ( | const Object * | obj | ) | [inherited] |
Definition at line 132 of file object.cpp.
References Wt::Object::eventFilters_.
Referenced by Wt::Object::installEventFilter().
00132 { 00133 List::iterator p, end(eventFilters_.end()); 00134 p = find(eventFilters_.begin(), end, obj); 00135 if (p != end) 00136 eventFilters_.erase(p); 00137 }
void Wt::Object::reparent | ( | Object * | new_parent | ) | [inherited] |
Definition at line 100 of file object.cpp.
References Wt::Object::insertChild(), Wt::Object::parent_, Wt::Object::removeChild(), and trace.
Referenced by Wt::Layout::addItem(), Wt::Widget::reparent(), and Wt::Widget::setLayout().
00100 { 00101 if (parent_ == new_parent) 00102 return; 00103 trace("obj") << "Reparenting " << this << std::endl; 00104 00105 if (parent_) { 00106 trace("obj") << " Leaving parent " << parent_ << std::endl; 00107 parent_->removeChild(this); 00108 } 00109 if (new_parent) { 00110 trace("obj") << " Going to new parent " << new_parent << std::endl; 00111 new_parent->insertChild(this); 00112 } 00113 parent_ = new_parent; 00114 }
Here is the call graph for this function:
Definition at line 31 of file timer.cpp.
References delivered_, sshot_, Wt::Object::startTimer(), stop(), and timerid_.
Referenced by changeInterval().
00031 { 00032 stop(); 00033 timerid_ = startTimer(msec); 00034 sshot_ = sshot; 00035 delivered_ = 0; 00036 return timerid_; 00037 }
Here is the call graph for this function:
Definition at line 139 of file object.cpp.
References Wt::Object::timers_.
Referenced by start().
00139 { 00140 int id = timers_.size() + 1; 00141 timers_[id] = new SDLTimer(this, id, interval); 00142 return id; 00143 }
void Wt::Timer::stop | ( | ) |
Definition at line 44 of file timer.cpp.
References Wt::Object::killTimer(), and timerid_.
Referenced by changeInterval(), start(), and timerEvent().
Here is the call graph for this function:
void Wt::Timer::timerEvent | ( | TimerEvent * | e | ) | [private, virtual] |
Reimplemented from Wt::Object.
Definition at line 51 of file timer.cpp.
References delivered_, sshot_, stop(), timeout, and Wt::Object::timerEvent().
00051 { 00052 Object::timerEvent(e); 00053 if (sshot_) 00054 stop(); 00055 if (!sshot_ || (sshot_ && !delivered_)) { 00056 timeout(); 00057 delivered_++; 00058 } 00059 }
Here is the call graph for this function:
int Wt::Timer::timerId | ( | ) | const [inline] |
Object * Wt::Object::topParent | ( | ) | const [inherited] |
returns top level parent: it may return itself
Definition at line 116 of file object.cpp.
References Wt::Object::parent_.
Referenced by Wt::Widget::topParentWidget().
00116 { 00117 const Object *p = this; 00118 while (p->parent_) { 00119 p = p->parent_; 00120 } 00121 return const_cast<Object *>(p); 00122 }
int Wt::Timer::delivered_ [private] |
Signal01<void, const Object *> Wt::Object::destroyed [inherited] |
signals
Definition at line 139 of file object.h.
Referenced by Wt::Layout::addItem(), Wt::Object::installEventFilter(), and Wt::Object::~Object().
bool Wt::Timer::sshot_ [private] |
sigc::signal<void> Wt::Timer::timeout |
Emitted when the timer is triggered.
Definition at line 47 of file timer.h.
Referenced by timerEvent().
int Wt::Timer::timerid_ [private] |
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.