[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"
|
---|
[332] | 23 | #import "CTBadge.h"
|
---|
[325] | 24 |
|
---|
[332] | 25 | #define sLatestVersionURL @"http://web.sabi.net/nriley/software/AntiRSI-version.txt"
|
---|
| 26 | #define sURL @"http://web.sabi.net/nriley/software/#antirsi"
|
---|
[371] | 27 | #define sVersion @"1.4njr4"
|
---|
[329] | 28 |
|
---|
[325] | 29 | typedef enum _AntiRSIState {
|
---|
[346] | 30 | s_normal = 0,
|
---|
| 31 | s_taking_micro_pause,
|
---|
| 32 | s_taking_work_break,
|
---|
[325] | 33 | } AntiRSIState;
|
---|
| 34 |
|
---|
| 35 | @interface AntiRSI : NSObject
|
---|
| 36 | {
|
---|
[346] | 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;
|
---|
[330] | 43 | IBOutlet NSTextField *session_time;
|
---|
[325] | 44 | IBOutlet NSTextField *status;
|
---|
[346] | 45 | IBOutlet NSTextField *version; // XXX unused?
|
---|
[332] | 46 | IBOutlet NSDatePicker *reset_session_time;
|
---|
[325] | 47 |
|
---|
[330] | 48 | // dock menu
|
---|
| 49 | IBOutlet NSMenu *dock_menu;
|
---|
| 50 | IBOutlet NSMenuItem *session_time_item;
|
---|
| 51 |
|
---|
[346] | 52 | // dock icon image
|
---|
| 53 | NSImage* dock_image;
|
---|
| 54 | NSImage* original_dock_image;
|
---|
[332] | 55 | CTBadge* dock_badge;
|
---|
[325] | 56 |
|
---|
[346] | 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;
|
---|
[330] | 70 | double session_t;
|
---|
[346] | 71 | double date;
|
---|
[332] | 72 | double reset_session_date;
|
---|
[325] | 73 |
|
---|
[346] | 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 |
|
---|
[370] | 82 | // various other options
|
---|
[346] | 83 | bool lock_focus;
|
---|
| 84 | bool draw_dock_image;
|
---|
| 85 | bool draw_dock_badge;
|
---|
| 86 | bool draw_dock_image_q;
|
---|
[332] | 87 | bool reset_session_timer_daily;
|
---|
| 88 | bool reset_session_timer_after;
|
---|
[333] | 89 | NSCalendarDate *reset_session_timer_time;
|
---|
[332] | 90 | int reset_session_timer_after_hours;
|
---|
[325] | 91 |
|
---|
[346] | 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;
|
---|
[325] | 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 |
|
---|
[329] | 116 | // goto website button
|
---|
| 117 | - (IBAction)gotoWebsite:(id)sender;
|
---|
[325] | 118 |
|
---|
[329] | 119 | // check updates
|
---|
| 120 | - (IBAction)checkForUpdate:(id)sender;
|
---|
| 121 |
|
---|
[325] | 122 | // postpone button
|
---|
| 123 | - (IBAction)postpone:(id)sender;
|
---|
| 124 |
|
---|
| 125 | // workbreak now menu item
|
---|
| 126 | - (IBAction)breakNow:(id)sender;
|
---|
| 127 |
|
---|
[330] | 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 |
|
---|
[325] | 134 | // one second ticks away ...
|
---|
| 135 | - (void)tick:(NSTimer *)timer;
|
---|
| 136 |
|
---|
[331] | 137 | // reset all timers
|
---|
| 138 | - (void)resetTimers;
|
---|
| 139 |
|
---|
[325] | 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 |
|
---|
[330] | 152 | // update window
|
---|
| 153 | - (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak;
|
---|
[325] | 154 |
|
---|
[346] | 155 | @end |
---|