[325] | 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 |
|
---|
[329] | 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 |
|
---|
[325] | 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;
|
---|
[330] | 42 | IBOutlet NSTextField *session_time;
|
---|
[325] | 43 | IBOutlet NSTextField *status;
|
---|
[330] | 44 | IBOutlet NSTextField *version; // XXX unused?
|
---|
[325] | 45 |
|
---|
[330] | 46 | // dock menu
|
---|
| 47 | IBOutlet NSMenu *dock_menu;
|
---|
| 48 | IBOutlet NSMenuItem *session_time_item;
|
---|
| 49 |
|
---|
[325] | 50 | // dock icon image
|
---|
| 51 | NSImage* dock_image;
|
---|
| 52 | NSImage* original_dock_image;
|
---|
| 53 |
|
---|
| 54 | // window to display the views in
|
---|
| 55 | NSWindow *main_window;
|
---|
| 56 |
|
---|
| 57 | // timer that ticks every second to update
|
---|
| 58 | NSTimer *mtimer;
|
---|
| 59 |
|
---|
| 60 | // various timers
|
---|
| 61 | double micro_pause_t;
|
---|
| 62 | double work_break_t;
|
---|
| 63 | double micro_pause_taking_t;
|
---|
| 64 | double work_break_taking_t;
|
---|
[329] | 65 | double work_break_taking_cached_t;
|
---|
| 66 | double work_break_taking_cached_date;
|
---|
[330] | 67 | double session_t;
|
---|
[325] | 68 | double date;
|
---|
| 69 |
|
---|
| 70 | // various timing lengths
|
---|
| 71 | int micro_pause_period;
|
---|
| 72 | int micro_pause_duration;
|
---|
| 73 | int work_break_period;
|
---|
| 74 | int work_break_duration;
|
---|
| 75 |
|
---|
| 76 | double sample_interval;
|
---|
| 77 |
|
---|
| 78 | // verious other options
|
---|
| 79 | bool lock_focus;
|
---|
| 80 | bool draw_dock_image;
|
---|
| 81 | bool draw_dock_image_q;
|
---|
| 82 |
|
---|
| 83 | // various colors
|
---|
| 84 | NSColor* taking;
|
---|
| 85 | NSColor* elapsed;
|
---|
| 86 | NSColor* background;
|
---|
| 87 | NSColor* darkbackground;
|
---|
| 88 |
|
---|
| 89 | // state we are in
|
---|
| 90 | AntiRSIState state;
|
---|
| 91 |
|
---|
| 92 | // history filter
|
---|
| 93 | double h0;
|
---|
| 94 | double h1;
|
---|
| 95 | double h2;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | //bindings
|
---|
| 99 | - (void)setMicro_pause_duration:(float)f;
|
---|
| 100 | - (void)setMicro_pause_period:(float)f;
|
---|
| 101 | - (void)setWork_break_period:(float)f;
|
---|
| 102 | - (void)setWork_break_period:(float)f;
|
---|
| 103 | - (void)setSample_interval:(NSString *)s;
|
---|
| 104 | - (void)setDraw_dock_image:(BOOL)b;
|
---|
| 105 | - (void)setBackground:(NSColor *)c;
|
---|
| 106 |
|
---|
[329] | 107 | // goto website button
|
---|
| 108 | - (IBAction)gotoWebsite:(id)sender;
|
---|
[325] | 109 |
|
---|
[329] | 110 | // check updates
|
---|
| 111 | - (IBAction)checkForUpdate:(id)sender;
|
---|
| 112 |
|
---|
[325] | 113 | // postpone button
|
---|
| 114 | - (IBAction)postpone:(id)sender;
|
---|
| 115 |
|
---|
| 116 | // workbreak now menu item
|
---|
| 117 | - (IBAction)breakNow:(id)sender;
|
---|
| 118 |
|
---|
[330] | 119 | // reset session time menu item
|
---|
| 120 | - (IBAction)resetSession:(id)sender;
|
---|
| 121 |
|
---|
| 122 | // returns string of the form "Session: 12:34:56"
|
---|
| 123 | - (NSString *)sessionTimeString;
|
---|
| 124 |
|
---|
[325] | 125 | // one second ticks away ...
|
---|
| 126 | - (void)tick:(NSTimer *)timer;
|
---|
| 127 |
|
---|
[331] | 128 | // reset all timers
|
---|
| 129 | - (void)resetTimers;
|
---|
| 130 |
|
---|
[325] | 131 | // draw the dock icon
|
---|
| 132 | - (void)drawDockImage;
|
---|
| 133 |
|
---|
| 134 | // run the micro pause window
|
---|
| 135 | - (void)doMicroPause;
|
---|
| 136 |
|
---|
| 137 | // run the work break window
|
---|
| 138 | - (void)doWorkBreak;
|
---|
| 139 |
|
---|
| 140 | // stop micro pause or work break
|
---|
| 141 | - (void)endBreak;
|
---|
| 142 |
|
---|
[330] | 143 | // update window
|
---|
| 144 | - (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak;
|
---|
[325] | 145 |
|
---|
| 146 | @end
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 |
|
---|