-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathclock.h
More file actions
152 lines (114 loc) · 3.62 KB
/
clock.h
File metadata and controls
152 lines (114 loc) · 3.62 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
eboard - chess client
http://www.bergo.eng.br/eboard
https://github.com/fbergo/eboard
Copyright (C) 2000-2016 Felipe Bergo
fbergo/at/gmail/dot/com
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CLOCK_H
#define CLOCK_H 1
#include <sys/time.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include <time.h>
#include "stl.h"
#include "eboard.h"
#include "util.h"
#include "widgetproxy.h"
class ClockHost {
public:
virtual void updateClock()=0;
};
// values for getActive()
#define CLK_WHITE_STOPPED -2
#define CLK_WHITE_RUNNING -1
#define CLK_STOPPED 0
#define CLK_BLACK_RUNNING 1
#define CLK_BLACK_STOPPED 2
class ChessClock : public UpdateInterface {
public:
ChessClock();
virtual ~ChessClock();
void setClock2(int whitemsec,int blackmsec,int activep,int countdown);
void setHost(ClockHost *hostp);
void setAnotherHost(ClockHost *hostp);
void setMirror(ChessClock *dest);
int getActive();
int getValue2(int black);
// which= -1=white 0=active one 1=black
void incrementClock2(int which, int msecs);
bool lowTimeWarning(piece mycolor);
void update();
int id;
private:
int value[2],val_ref[2];
Timestamp t_ref[2];
int active;
int countdownf;
ClockHost *host, *host2;
ChessClock *mirror;
Timestamp LastWarning;
static int freeid;
};
class ClockMaster {
public:
ClockMaster();
void append(ChessClock *clockp);
void remove(ChessClock *clockp);
private:
void update();
list<ChessClock *> clocks;
int timeout_on;
int timeout_id;
friend gint clockmaster_timeout(gpointer data);
};
gint clockmaster_timeout(gpointer data);
#define TCF_GNUCHESS4QUIRK 0x01
class TimeControl {
public:
TimeControl();
TimeControl &operator=(TimeControl &src);
int operator==(TimeControl &src);
int operator!=(TimeControl &src);
void fromSerialization(const char *s);
static void secondsToString(char *dest, int maxlen, int secs, bool units=false);
static int stringToSeconds(const char *src);
void setSecondsPerMove(int seconds);
void setIcs(int base /* secs */, int increment /* secs */);
void setXMoves(int nmoves, int nsecs);
bool isRegressive();
int startValue();
void toXBoard(char *dest, int maxlen, int flags = 0);
void toString(char *dest, int maxlen);
void toShortString(char *dest, int maxlen);
void toPGN(char *dest, int maxlen); // format as a TimeControl tag
TimeControlMode mode;
int value[2];
};
class TimeControlEditDialog : public ModalDialog {
public:
TimeControlEditDialog(TimeControl *tc, bool allownone=true);
virtual ~TimeControlEditDialog() {}
void setUpdateListener(UpdateInterface *ui);
private:
GtkWidget *mi[4], *e[5], *f[3];
TimeControl *src;
TimeControl local;
UpdateInterface *listener;
friend void tced_ok(GtkWidget *w, gpointer data);
friend void tced_dropmenu(GtkMenuItem *w, gpointer data);
};
void tced_ok(GtkWidget *w, gpointer data);
void tced_dropmenu(GtkMenuItem *w, gpointer data);
#endif