-
Notifications
You must be signed in to change notification settings - Fork 4
/
buzzwindow.h
58 lines (53 loc) · 1.6 KB
/
buzzwindow.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
#ifndef BUZZWINDOW_H
#define BUZZWINDOW_H
#include <Window.h>
#include <Button.h>
#include <StringView.h>
#include <FileGameSound.h>
#include <TextControl.h>
#include <String.h>
//------------------------------------------------------------------------
static bool Playing;
int32 TimerThread(void* data);
//------------------------------------------------------------------------
class AClock
{
private:
BFileGameSound* Sound;
bigtime_t Interval; //every 'Interval' ticks, we beep
int Second; //seconds elapsed
int Minute; //minutes elapsed
int Hour; //hour elapsed
bigtime_t Temps; //number of ticks elapsed
public :
AClock() {Sound=NULL; Interval=0; Second=0; Minute=0; Hour=0; Temps=0;}
void Restart() {Temps=0;}
void SetSound(BFileGameSound* s) {if(Sound!=NULL) delete Sound; Sound = s;}
bigtime_t GetInterval() {return Interval;}
void SetInterval(bigtime_t t) {Interval = t;}
void PlaySound() {if(Sound != NULL) Sound->StartPlaying();}
void AddTime(bigtime_t t) {Temps += t;}
short int GetHour() {return Temps/3600000000;}
short int GetMinute() {return (Temps/60000000) % 60;}
short int GetSecond() {return (Temps/1000000) % 60;}
};
//------------------------------------------------------------------------
class BuzzWindow : public BWindow
{
friend int32 TimerThread(void* data);
private:
BStringView* SoundName;
BStringView* Seconds;
BStringView* TimeElapsed;
BButton* TestButton;
BButton* StartButton;
BTextControl* IntervalControl;
AClock* MyClock;
thread_id ClockId;
void Start();
public:
BuzzWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
};
#endif