-
Notifications
You must be signed in to change notification settings - Fork 1
/
NixieClock.H
113 lines (96 loc) · 3.94 KB
/
NixieClock.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef _NIXIECLOCK_H
#define _NIXIECLOCK_H
/************************************************************************
NixieClock.H - a class to manage clock oriented time keeping
Copyright (C) 2000,2020 Greg Ercolano, [email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*************************************************************************/
#include "NixieDisplay.H"
#include <FL/Fl_Menu_Button.H>
class NixieClock : public NixieDisplay {
char _timestr[256];
int _verbose;
int _above;
int _geometryforce;
int _border;
int _justupdate;
float _tickspeed;
time_t _countdown;
int _nosave;
char _errmsg[512];
// MENU CALLBACKS
static void AlwaysTopWindow_CB(Fl_Widget *w, void *userdata);
static void RegularWindow_CB(Fl_Widget *w, void *userdata);
static void Quit_CB(Fl_Widget *w, void *userdata);
static void TimeFormatDefault_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HMS_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_DMY_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_MDY_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_A_MDY_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_D_M_MDY(Fl_Widget *w, void *userdata);
static void TimeFormat_MDY_HM_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_A_MDY_HM_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_ABMY_CB(Fl_Widget *w, void *userdata);
static void TimeFormat_HM_AB_MDY_CB(Fl_Widget *w, void *userdata);
static void TimeFormatUnix_CB(Fl_Widget *w, void *userdata);
static void TimeFormatLocale_CB(Fl_Widget *w, void *userdata);
// OTHER CALLBACKS
static void Tick_CB(void *data);
void Init();
int TimeStringWidth();
int Load(const char *filename);
int Save(const char *filename);
int Exists(const char *filename);
int GetSettingsFilename(char *filename, int filenamesz);
const char *GetTimeStr() const { return(_timestr); }
public:
// CTOR
NixieClock(int X,int Y,int W,int H,const char*L):NixieDisplay(X,Y,W,H,L) {
Init();
}
// CTOR
NixieClock(int W,int H,const char*L):NixieDisplay(W,H,L) {
Init();
}
void SetVerbose(int val);
void SetGeometryForce(int val);
void SetTickSpeed(float val);
void SetBorder(int val);
void SetAbove(int val);
void SetTimeString(const char *val);
void SetCountdown(time_t val) { _countdown = val; }
void SetNoSave(int val) { _nosave = val; }
void UpdateTime();
int GetAbove() const { return(_above); }
int LoadSettings();
int SaveSettings();
int handle(int e);
const char *GetErrmsg() const {
return(_errmsg);
}
// intercept redraws
// Most of the time we're redrawn by the timer tick.
// But sometimes we're redrawn when a machine wakes up from a long sleep
// (notebook lid opened). If so, _justupdate won't be set, so force call
// to UpdateTime() to get rid of the stale time from the display.
//
void draw() {
if ( !_justupdate ) {
UpdateTime(); // makes sure clock quickly updates time if machine just woken up
}
NixieDisplay::draw();
_justupdate = 0;
}
};
#endif