timer.cpp

Go to the documentation of this file.
00001 /*
00002   libwt - Vassilis Virvilis Toolkit - a widget library
00003   Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm>
00004  
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the
00017   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018   Boston, MA  02111-1307, SA.
00019 */
00020 
00021 #include "timer.h"
00022 
00023 namespace Wt {
00024 
00025 Timer::Timer(Object *parent, const std::string& name) :
00026         Object(parent, name),
00027         timerid_(0),
00028         sshot_(false),
00029 delivered_(0) {}
00030 
00031 int Timer::start(int msec, bool sshot) {
00032     stop();
00033     timerid_ = startTimer(msec);
00034     sshot_ = sshot;
00035     delivered_ = 0;
00036     return timerid_;
00037 }
00038 
00039 void Timer::changeInterval(int msec) {
00040     stop();
00041     start(msec, sshot_);
00042 }
00043 
00044 void Timer::stop() {
00045     if (timerid_) {
00046         killTimer(timerid_);
00047         timerid_ = 0;
00048     }
00049 }
00050 
00051 void Timer::timerEvent(TimerEvent *e) {
00052     Object::timerEvent(e);
00053     if (sshot_)
00054         stop();
00055     if (!sshot_ || (sshot_ && !delivered_)) {
00056         timeout();
00057         delivered_++;
00058     }
00059 }
00060 
00061 } // namespace

Generated Fri Jul 28 19:23:01 2006.
Copyright © 1998-2003 by the respective authors.

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.