1 | /*
|
---|
2 | author: Onne Gorter
|
---|
3 |
|
---|
4 | This file is part of AntiRSI.
|
---|
5 |
|
---|
6 | AntiRSI is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2 of the License, or
|
---|
9 | (at your option) any later version.
|
---|
10 |
|
---|
11 | AntiRSI is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with AntiRSI; if not, write to the Free Software
|
---|
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
19 | */
|
---|
20 |
|
---|
21 | #import <Cocoa/Cocoa.h>
|
---|
22 | #import "AntiRSIView.h"
|
---|
23 |
|
---|
24 | #define sLatestVersionURL @"http://tech.inhelsinki.nl/antirsi/antirsi_version.txt"
|
---|
25 | #define sURL @"http://tech.inhelsinki.nl/antirsi/"
|
---|
26 | #define sVersion @"1.4"
|
---|
27 |
|
---|
28 | typedef enum _AntiRSIState {
|
---|
29 | s_normal = 0,
|
---|
30 | s_taking_micro_pause,
|
---|
31 | s_taking_work_break,
|
---|
32 | } AntiRSIState;
|
---|
33 |
|
---|
34 | @interface AntiRSI : NSObject
|
---|
35 | {
|
---|
36 | // views to display current status in
|
---|
37 | IBOutlet AntiRSIView *view;
|
---|
38 | IBOutlet NSLevelIndicator *progress;
|
---|
39 | IBOutlet NSButton *postpone;
|
---|
40 | IBOutlet NSTextField *time;
|
---|
41 | IBOutlet NSTextField *next_break;
|
---|
42 | IBOutlet NSTextField *status;
|
---|
43 | IBOutlet NSTextField *version;
|
---|
44 |
|
---|
45 | // dock icon image
|
---|
46 | NSImage* dock_image;
|
---|
47 | NSImage* original_dock_image;
|
---|
48 |
|
---|
49 | // window to display the views in
|
---|
50 | NSWindow *main_window;
|
---|
51 |
|
---|
52 | // timer that ticks every second to update
|
---|
53 | NSTimer *mtimer;
|
---|
54 |
|
---|
55 | // various timers
|
---|
56 | double micro_pause_t;
|
---|
57 | double work_break_t;
|
---|
58 | double micro_pause_taking_t;
|
---|
59 | double work_break_taking_t;
|
---|
60 | double work_break_taking_cached_t;
|
---|
61 | double work_break_taking_cached_date;
|
---|
62 | double date;
|
---|
63 |
|
---|
64 | // various timing lengths
|
---|
65 | int micro_pause_period;
|
---|
66 | int micro_pause_duration;
|
---|
67 | int work_break_period;
|
---|
68 | int work_break_duration;
|
---|
69 |
|
---|
70 | double sample_interval;
|
---|
71 |
|
---|
72 | // verious other options
|
---|
73 | bool lock_focus;
|
---|
74 | bool draw_dock_image;
|
---|
75 | bool draw_dock_image_q;
|
---|
76 |
|
---|
77 | // various colors
|
---|
78 | NSColor* taking;
|
---|
79 | NSColor* elapsed;
|
---|
80 | NSColor* background;
|
---|
81 | NSColor* darkbackground;
|
---|
82 |
|
---|
83 | // state we are in
|
---|
84 | AntiRSIState state;
|
---|
85 |
|
---|
86 | // history filter
|
---|
87 | double h0;
|
---|
88 | double h1;
|
---|
89 | double h2;
|
---|
90 | }
|
---|
91 |
|
---|
92 | //bindings
|
---|
93 | - (void)setMicro_pause_duration:(float)f;
|
---|
94 | - (void)setMicro_pause_period:(float)f;
|
---|
95 | - (void)setWork_break_period:(float)f;
|
---|
96 | - (void)setWork_break_period:(float)f;
|
---|
97 | - (void)setSample_interval:(NSString *)s;
|
---|
98 | - (void)setDraw_dock_image:(BOOL)b;
|
---|
99 | - (void)setBackground:(NSColor *)c;
|
---|
100 |
|
---|
101 | // goto website button
|
---|
102 | - (IBAction)gotoWebsite:(id)sender;
|
---|
103 |
|
---|
104 | // check updates
|
---|
105 | - (IBAction)checkForUpdate:(id)sender;
|
---|
106 |
|
---|
107 | // postpone button
|
---|
108 | - (IBAction)postpone:(id)sender;
|
---|
109 |
|
---|
110 | // workbreak now menu item
|
---|
111 | - (IBAction)breakNow:(id)sender;
|
---|
112 |
|
---|
113 | // one second ticks away ...
|
---|
114 | - (void)tick:(NSTimer *)timer;
|
---|
115 |
|
---|
116 | // draw the dock icon
|
---|
117 | - (void)drawDockImage;
|
---|
118 |
|
---|
119 | // run the micro pause window
|
---|
120 | - (void)doMicroPause;
|
---|
121 |
|
---|
122 | // run the work break window
|
---|
123 | - (void)doWorkBreak;
|
---|
124 |
|
---|
125 | // stop micro pause or work break
|
---|
126 | - (void)endBreak;
|
---|
127 |
|
---|
128 | // time left string
|
---|
129 | - (void)drawTimeLeft:(double)seconds;
|
---|
130 |
|
---|
131 | // time to next break string
|
---|
132 | - (void)drawNextBreak:(int)seconds;
|
---|
133 |
|
---|
134 | @end
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|