/* * clock.hpp * * Created: 2009, 2010 * Author: fischer * for use in Yale course CPSC 427a, Fall 2010 * * Derived from: * http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/drawingarea/clock * subject to the following license: * * gtkmm example Copyright (C) 2002 gtkmm development team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once #include class ClockWin; // forward // ------------------------------------------------------------------ class Clock { public: enum ColorBoxName { red_box, orange_box, yellow_box, green_box, blue_box }; private: bool check[5]; // state of color-check boxes bool blink; // state of the blink-check box bool powerSwitch; // state of the power switch time_t lastTime; // current clock time bool phase; // current 1/2 second clock phase (for flashing) public: Clock(); virtual ~Clock(); const bool* getCheck() const { return check; } const bool getBlink() const { return blink; } const bool getPowerSwitch() const { return powerSwitch; } const time_t getLastTime() const { return lastTime; } const bool getPhase() const { return phase; } void updateTime(); void toggleCheck(ColorBoxName c) { check[c] = !check[c]; } void toggleBlink() { blink = !blink; } void setPowerSwitch(bool state) { powerSwitch = state; } };