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 | #import "CTBadge.h"
|
---|
24 |
|
---|
25 | #define sLatestVersionURL @"http://web.sabi.net/nriley/software/AntiRSI-version.txt"
|
---|
26 | #define sURL @"http://web.sabi.net/nriley/software/#antirsi"
|
---|
27 | #define sVersion @"1.4njr3"
|
---|
28 |
|
---|
29 | typedef enum _AntiRSIState {
|
---|
30 | s_normal = 0,
|
---|
31 | s_taking_micro_pause,
|
---|
32 | s_taking_work_break,
|
---|
33 | } AntiRSIState;
|
---|
34 |
|
---|
35 | @interface AntiRSI : NSObject
|
---|
36 | {
|
---|
37 | // views to display current status in
|
---|
38 | IBOutlet AntiRSIView *view;
|
---|
39 | IBOutlet NSLevelIndicator *progress;
|
---|
40 | IBOutlet NSButton *postpone;
|
---|
41 | IBOutlet NSTextField *time;
|
---|
42 | IBOutlet NSTextField *next_break;
|
---|
43 | IBOutlet NSTextField *session_time;
|
---|
44 | IBOutlet NSTextField *status;
|
---|
45 | IBOutlet NSTextField *version; // XXX unused?
|
---|
46 | IBOutlet NSDatePicker *reset_session_time;
|
---|
47 |
|
---|
48 | // dock menu
|
---|
49 | IBOutlet NSMenu *dock_menu;
|
---|
50 | IBOutlet NSMenuItem *session_time_item;
|
---|
51 |
|
---|
52 | // dock icon image
|
---|
53 | NSImage* dock_image;
|
---|
54 | NSImage* original_dock_image;
|
---|
55 | CTBadge* dock_badge;
|
---|
56 |
|
---|
57 | // window to display the views in
|
---|
58 | NSWindow *main_window;
|
---|
59 |
|
---|
60 | // timer that ticks every second to update
|
---|
61 | NSTimer *mtimer;
|
---|
62 |
|
---|
63 | // various timers
|
---|
64 | double micro_pause_t;
|
---|
65 | double work_break_t;
|
---|
66 | double micro_pause_taking_t;
|
---|
67 | double work_break_taking_t;
|
---|
68 | double work_break_taking_cached_t;
|
---|
69 | double work_break_taking_cached_date;
|
---|
70 | double session_t;
|
---|
71 | double date;
|
---|
72 | double reset_session_date;
|
---|
73 |
|
---|
74 | // various timing lengths
|
---|
75 | int micro_pause_period;
|
---|
76 | int micro_pause_duration;
|
---|
77 | int work_break_period;
|
---|
78 | int work_break_duration;
|
---|
79 |
|
---|
80 | double sample_interval;
|
---|
81 |
|
---|
82 | // verious other options
|
---|
83 | bool lock_focus;
|
---|
84 | bool draw_dock_image;
|
---|
85 | bool draw_dock_badge;
|
---|
86 | bool draw_dock_image_q;
|
---|
87 | bool reset_session_timer_daily;
|
---|
88 | bool reset_session_timer_after;
|
---|
89 | NSCalendarDate *reset_session_timer_time;
|
---|
90 | int reset_session_timer_after_hours;
|
---|
91 |
|
---|
92 | // various colors
|
---|
93 | NSColor* taking;
|
---|
94 | NSColor* elapsed;
|
---|
95 | NSColor* background;
|
---|
96 | NSColor* darkbackground;
|
---|
97 |
|
---|
98 | // state we are in
|
---|
99 | AntiRSIState state;
|
---|
100 |
|
---|
101 | // history filter
|
---|
102 | double h0;
|
---|
103 | double h1;
|
---|
104 | double h2;
|
---|
105 | }
|
---|
106 |
|
---|
107 | //bindings
|
---|
108 | - (void)setMicro_pause_duration:(float)f;
|
---|
109 | - (void)setMicro_pause_period:(float)f;
|
---|
110 | - (void)setWork_break_period:(float)f;
|
---|
111 | - (void)setWork_break_period:(float)f;
|
---|
112 | - (void)setSample_interval:(NSString *)s;
|
---|
113 | - (void)setDraw_dock_image:(BOOL)b;
|
---|
114 | - (void)setBackground:(NSColor *)c;
|
---|
115 |
|
---|
116 | // goto website button
|
---|
117 | - (IBAction)gotoWebsite:(id)sender;
|
---|
118 |
|
---|
119 | // check updates
|
---|
120 | - (IBAction)checkForUpdate:(id)sender;
|
---|
121 |
|
---|
122 | // postpone button
|
---|
123 | - (IBAction)postpone:(id)sender;
|
---|
124 |
|
---|
125 | // workbreak now menu item
|
---|
126 | - (IBAction)breakNow:(id)sender;
|
---|
127 |
|
---|
128 | // reset session time menu item
|
---|
129 | - (IBAction)resetSession:(id)sender;
|
---|
130 |
|
---|
131 | // returns string of the form "Session: 12:34:56"
|
---|
132 | - (NSString *)sessionTimeString;
|
---|
133 |
|
---|
134 | // one second ticks away ...
|
---|
135 | - (void)tick:(NSTimer *)timer;
|
---|
136 |
|
---|
137 | // reset all timers
|
---|
138 | - (void)resetTimers;
|
---|
139 |
|
---|
140 | // draw the dock icon
|
---|
141 | - (void)drawDockImage;
|
---|
142 |
|
---|
143 | // run the micro pause window
|
---|
144 | - (void)doMicroPause;
|
---|
145 |
|
---|
146 | // run the work break window
|
---|
147 | - (void)doWorkBreak;
|
---|
148 |
|
---|
149 | // stop micro pause or work break
|
---|
150 | - (void)endBreak;
|
---|
151 |
|
---|
152 | // update window
|
---|
153 | - (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak;
|
---|
154 |
|
---|
155 | @end |
---|