The SimpleCxxLib package


#include "gevents.h"

class GTimerEvent : public GEvent

This event subclass represents a timer event. Timer events are generated by a GTimer object, which produces a new event at a fixed interval measured in milliseconds. As an example, the following program generates a timer event every two seconds, stopping when the user clicks somewhere in the window:
   int main() {
      cout << "This program generates timer events." << endl;
      GTimer timer(2000);
      timer.start();
      while (true) {
         GEvent e = waitForEvent(CLICK_EVENT | TIMER_EVENT);
         if (e.getEventType() == MOUSE_CLICKED) break;
         cout << "Timer ticked" << endl;
      }
      return 0;
   }
Constructor
GTimerEvent(type, timer) Creates a GTimerEvent for the specified timer.
Methods
getGTimer() Returns the timer that generated this event.
toString() Converts the event to a human-readable representation of the event.

Constructor detail


GTimerEvent(EventType type, const GTimer & timer);
Creates a GTimerEvent for the specified timer.

Usage:

GTimerEvent timerEvent(type, timer);

Method detail


GTimer getGTimer() const;
Returns the timer that generated this event.

Usage:

GTimer timer = e.getGTimer();

string toString() const;
Converts the event to a human-readable representation of the event.

Usage:

string str = e.toString();