Browse Source

Recreated original context menu. Can now hide date.

Thomas Buck 9 years ago
parent
commit
bd5522305a

+ 150
- 21
OtaClock/Base.lproj/MainMenu.xib View File

83
                 </connections>
83
                 </connections>
84
             </view>
84
             </view>
85
             <connections>
85
             <connections>
86
+                <outlet property="alarmDatePicker" destination="A2I-e6-ur5" id="wh1-Z1-r9q"/>
86
                 <outlet property="changeSize1" destination="Acr-Ff-Lm2" id="qUp-XP-Ffo"/>
87
                 <outlet property="changeSize1" destination="Acr-Ff-Lm2" id="qUp-XP-Ffo"/>
88
+                <outlet property="changeSize10" destination="eMz-8d-XLg" id="Ppm-Gu-5xS"/>
87
                 <outlet property="changeSize2" destination="sRn-WM-cKW" id="luN-Dk-xw4"/>
89
                 <outlet property="changeSize2" destination="sRn-WM-cKW" id="luN-Dk-xw4"/>
88
                 <outlet property="changeSize3" destination="Ynv-fd-dtQ" id="QeL-wH-eAC"/>
90
                 <outlet property="changeSize3" destination="Ynv-fd-dtQ" id="QeL-wH-eAC"/>
89
                 <outlet property="changeSize4" destination="rKj-Pe-N3u" id="tmN-AZ-egV"/>
91
                 <outlet property="changeSize4" destination="rKj-Pe-N3u" id="tmN-AZ-egV"/>
90
                 <outlet property="changeSize5" destination="Qji-aB-KLD" id="a79-d3-RIN"/>
92
                 <outlet property="changeSize5" destination="Qji-aB-KLD" id="a79-d3-RIN"/>
91
-                <outlet property="keepOnTopItem" destination="bk2-WG-9eq" id="vBf-vA-eXc"/>
92
-                <outlet property="lockPositionItem" destination="YfQ-b7-bXC" id="CYs-rk-6GP"/>
93
+                <outlet property="changeSize6" destination="RvN-WU-vpJ" id="hlG-6e-JmA"/>
94
+                <outlet property="changeSize7" destination="7sp-5h-kYL" id="ore-Fs-2W9"/>
95
+                <outlet property="changeSize8" destination="WnO-2m-uXI" id="jKZ-CW-zyj"/>
96
+                <outlet property="changeSize9" destination="NhP-qX-OsO" id="yL9-ON-q1Y"/>
97
+                <outlet property="keepOnTopItem" destination="LVI-ch-nme" id="lL1-Yi-zMN"/>
98
+                <outlet property="lockPositionItem" destination="ShL-8K-SbX" id="ppY-l8-Bda"/>
93
                 <outlet property="mainView" destination="EiT-Mj-1SZ" id="sQZ-BE-YrX"/>
99
                 <outlet property="mainView" destination="EiT-Mj-1SZ" id="sQZ-BE-YrX"/>
100
+                <outlet property="setAlarmItem" destination="IRB-i7-bez" id="V2f-2Y-Eyh"/>
101
+                <outlet property="showDateItem" destination="0Cy-4I-9bF" id="T7y-ik-8nT"/>
94
             </connections>
102
             </connections>
95
-            <point key="canvasLocation" x="129.5" y="81"/>
103
+            <point key="canvasLocation" x="-147.5" y="74"/>
96
         </window>
104
         </window>
97
         <menu id="v1Z-w4-vhP">
105
         <menu id="v1Z-w4-vhP">
98
             <items>
106
             <items>
99
-                <menuItem title="Change Size" id="msY-7t-C9j">
107
+                <menuItem title="View" id="aaw-ha-cZ9">
100
                     <modifierMask key="keyEquivalentModifierMask"/>
108
                     <modifierMask key="keyEquivalentModifierMask"/>
101
-                    <menu key="submenu" title="Change Size" id="b3j-Lp-Mui">
109
+                    <menu key="submenu" title="View" id="xOl-as-LSf">
102
                         <items>
110
                         <items>
103
-                            <menuItem title="1x" id="Acr-Ff-Lm2">
111
+                            <menuItem title="Military Time" id="Cgd-DK-xB0">
112
+                                <modifierMask key="keyEquivalentModifierMask"/>
113
+                            </menuItem>
114
+                            <menuItem title="Alarm Mode" id="S8W-ak-RY9">
115
+                                <modifierMask key="keyEquivalentModifierMask"/>
116
+                            </menuItem>
117
+                            <menuItem title="Show Date" id="0Cy-4I-9bF">
118
+                                <modifierMask key="keyEquivalentModifierMask"/>
119
+                                <connections>
120
+                                    <action selector="showDate:" target="QvC-M9-y7g" id="BSR-q0-DhH"/>
121
+                                </connections>
122
+                            </menuItem>
123
+                            <menuItem title="Always on Top" id="LVI-ch-nme">
124
+                                <modifierMask key="keyEquivalentModifierMask"/>
125
+                                <connections>
126
+                                    <action selector="keepOnTop:" target="QvC-M9-y7g" id="vsX-bh-Qvw"/>
127
+                                </connections>
128
+                            </menuItem>
129
+                            <menuItem title="Fix Location" id="ShL-8K-SbX">
130
+                                <modifierMask key="keyEquivalentModifierMask"/>
131
+                                <connections>
132
+                                    <action selector="lockPosition:" target="QvC-M9-y7g" id="FPS-80-FZS"/>
133
+                                </connections>
134
+                            </menuItem>
135
+                            <menuItem title="Drop Shadow" id="4eS-hA-ECa">
136
+                                <modifierMask key="keyEquivalentModifierMask"/>
137
+                            </menuItem>
138
+                        </items>
139
+                    </menu>
140
+                </menuItem>
141
+                <menuItem title="Size" id="msY-7t-C9j">
142
+                    <modifierMask key="keyEquivalentModifierMask"/>
143
+                    <menu key="submenu" title="Size" id="b3j-Lp-Mui">
144
+                        <items>
145
+                            <menuItem title="x1" id="Acr-Ff-Lm2">
104
                                 <modifierMask key="keyEquivalentModifierMask"/>
146
                                 <modifierMask key="keyEquivalentModifierMask"/>
105
                                 <connections>
147
                                 <connections>
106
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="LdY-jb-6Tw"/>
148
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="LdY-jb-6Tw"/>
107
                                 </connections>
149
                                 </connections>
108
                             </menuItem>
150
                             </menuItem>
109
-                            <menuItem title="2x" id="sRn-WM-cKW">
151
+                            <menuItem title="x2" id="sRn-WM-cKW">
110
                                 <modifierMask key="keyEquivalentModifierMask"/>
152
                                 <modifierMask key="keyEquivalentModifierMask"/>
111
                                 <connections>
153
                                 <connections>
112
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="Nvd-gD-ixJ"/>
154
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="Nvd-gD-ixJ"/>
113
                                 </connections>
155
                                 </connections>
114
                             </menuItem>
156
                             </menuItem>
115
-                            <menuItem title="3x" id="Ynv-fd-dtQ">
157
+                            <menuItem title="x3" id="Ynv-fd-dtQ">
116
                                 <modifierMask key="keyEquivalentModifierMask"/>
158
                                 <modifierMask key="keyEquivalentModifierMask"/>
117
                                 <connections>
159
                                 <connections>
118
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="Nrc-zM-1sT"/>
160
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="Nrc-zM-1sT"/>
119
                                 </connections>
161
                                 </connections>
120
                             </menuItem>
162
                             </menuItem>
121
-                            <menuItem title="4x" id="rKj-Pe-N3u">
163
+                            <menuItem title="x4" id="rKj-Pe-N3u">
122
                                 <modifierMask key="keyEquivalentModifierMask"/>
164
                                 <modifierMask key="keyEquivalentModifierMask"/>
123
                                 <connections>
165
                                 <connections>
124
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="QoN-cm-k5P"/>
166
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="QoN-cm-k5P"/>
125
                                 </connections>
167
                                 </connections>
126
                             </menuItem>
168
                             </menuItem>
127
-                            <menuItem title="5x" id="Qji-aB-KLD">
169
+                            <menuItem title="x5" id="Qji-aB-KLD">
128
                                 <modifierMask key="keyEquivalentModifierMask"/>
170
                                 <modifierMask key="keyEquivalentModifierMask"/>
129
                                 <connections>
171
                                 <connections>
130
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="Y9P-XF-cjZ"/>
172
                                     <action selector="changeSize:" target="QvC-M9-y7g" id="Y9P-XF-cjZ"/>
131
                                 </connections>
173
                                 </connections>
132
                             </menuItem>
174
                             </menuItem>
175
+                            <menuItem title="x6" id="RvN-WU-vpJ">
176
+                                <modifierMask key="keyEquivalentModifierMask"/>
177
+                                <connections>
178
+                                    <action selector="changeSize:" target="QvC-M9-y7g" id="ZKN-ZR-4XG"/>
179
+                                </connections>
180
+                            </menuItem>
181
+                            <menuItem title="x7" id="7sp-5h-kYL">
182
+                                <modifierMask key="keyEquivalentModifierMask"/>
183
+                                <connections>
184
+                                    <action selector="changeSize:" target="QvC-M9-y7g" id="0n8-RW-SYP"/>
185
+                                </connections>
186
+                            </menuItem>
187
+                            <menuItem title="x8" id="WnO-2m-uXI">
188
+                                <modifierMask key="keyEquivalentModifierMask"/>
189
+                                <connections>
190
+                                    <action selector="changeSize:" target="QvC-M9-y7g" id="Qpk-3l-vRh"/>
191
+                                </connections>
192
+                            </menuItem>
193
+                            <menuItem title="x9" id="NhP-qX-OsO">
194
+                                <modifierMask key="keyEquivalentModifierMask"/>
195
+                                <connections>
196
+                                    <action selector="changeSize:" target="QvC-M9-y7g" id="yBZ-92-wf1"/>
197
+                                </connections>
198
+                            </menuItem>
199
+                            <menuItem title="x10" id="eMz-8d-XLg">
200
+                                <modifierMask key="keyEquivalentModifierMask"/>
201
+                                <connections>
202
+                                    <action selector="changeSize:" target="QvC-M9-y7g" id="Rkk-RZ-7ki"/>
203
+                                </connections>
204
+                            </menuItem>
133
                         </items>
205
                         </items>
134
                     </menu>
206
                     </menu>
135
                 </menuItem>
207
                 </menuItem>
136
-                <menuItem isSeparatorItem="YES" id="reI-n6-U2e"/>
137
-                <menuItem title="Lock position" id="YfQ-b7-bXC">
208
+                <menuItem title="Alarm" id="nsi-HU-yLS">
138
                     <modifierMask key="keyEquivalentModifierMask"/>
209
                     <modifierMask key="keyEquivalentModifierMask"/>
139
-                    <connections>
140
-                        <action selector="lockPosition:" target="QvC-M9-y7g" id="l9S-pc-JSb"/>
141
-                    </connections>
210
+                    <menu key="submenu" title="Alarm" id="9Ra-Fc-lVu">
211
+                        <items>
212
+                            <menuItem title="&quot;LAUGH&quot;" id="62g-Ai-pTm">
213
+                                <modifierMask key="keyEquivalentModifierMask"/>
214
+                            </menuItem>
215
+                            <menuItem title="&quot;OK&quot;" id="Nn9-Q1-6Xe">
216
+                                <modifierMask key="keyEquivalentModifierMask"/>
217
+                            </menuItem>
218
+                            <menuItem isSeparatorItem="YES" id="cE8-kx-VzJ"/>
219
+                            <menuItem title="WAVE File" id="gKE-dz-bZ5">
220
+                                <modifierMask key="keyEquivalentModifierMask"/>
221
+                            </menuItem>
222
+                            <menuItem title="WAVE File (LOOP)" id="4Hq-h0-hMx">
223
+                                <modifierMask key="keyEquivalentModifierMask"/>
224
+                            </menuItem>
225
+                            <menuItem isSeparatorItem="YES" id="AKe-eD-qSj"/>
226
+                            <menuItem title="Alarm Buzzer Duration" id="sgQ-pO-ctj">
227
+                                <modifierMask key="keyEquivalentModifierMask"/>
228
+                                <menu key="submenu" title="Alarm Buzzer Duration" id="d9P-wR-AG3">
229
+                                    <items>
230
+                                        <menuItem title="5 sec" id="vDE-9f-4z8">
231
+                                            <modifierMask key="keyEquivalentModifierMask"/>
232
+                                        </menuItem>
233
+                                        <menuItem title="10 sec" id="lT0-pq-3Z3">
234
+                                            <modifierMask key="keyEquivalentModifierMask"/>
235
+                                        </menuItem>
236
+                                        <menuItem title="30 sec" id="qaN-tN-4mB">
237
+                                            <modifierMask key="keyEquivalentModifierMask"/>
238
+                                        </menuItem>
239
+                                        <menuItem title="60 sec" id="Wqq-BO-KhH">
240
+                                            <modifierMask key="keyEquivalentModifierMask"/>
241
+                                        </menuItem>
242
+                                    </items>
243
+                                </menu>
244
+                            </menuItem>
245
+                        </items>
246
+                    </menu>
142
                 </menuItem>
247
                 </menuItem>
143
-                <menuItem title="Keep on top" id="bk2-WG-9eq">
248
+                <menuItem isSeparatorItem="YES" id="reI-n6-U2e"/>
249
+                <menuItem title="Set Alarm" id="Xnn-ra-5vW">
144
                     <modifierMask key="keyEquivalentModifierMask"/>
250
                     <modifierMask key="keyEquivalentModifierMask"/>
145
-                    <connections>
146
-                        <action selector="keepOnTop:" target="QvC-M9-y7g" id="b6a-ad-4oz"/>
147
-                    </connections>
251
+                    <menu key="submenu" title="Set Alarm" id="wYe-EL-D4t">
252
+                        <items>
253
+                            <menuItem title="Item" id="IRB-i7-bez">
254
+                                <modifierMask key="keyEquivalentModifierMask"/>
255
+                            </menuItem>
256
+                        </items>
257
+                    </menu>
148
                 </menuItem>
258
                 </menuItem>
149
-                <menuItem isSeparatorItem="YES" id="aVS-e6-OtM"/>
259
+                <menuItem isSeparatorItem="YES" id="MRz-da-sGL"/>
150
                 <menuItem title="About OtaClock" id="Tlq-91-8IJ">
260
                 <menuItem title="About OtaClock" id="Tlq-91-8IJ">
151
                     <modifierMask key="keyEquivalentModifierMask"/>
261
                     <modifierMask key="keyEquivalentModifierMask"/>
152
                     <connections>
262
                     <connections>
153
                         <action selector="orderFrontStandardAboutPanel:" target="-1" id="VRw-6e-aO6"/>
263
                         <action selector="orderFrontStandardAboutPanel:" target="-1" id="VRw-6e-aO6"/>
154
                     </connections>
264
                     </connections>
155
                 </menuItem>
265
                 </menuItem>
266
+                <menuItem isSeparatorItem="YES" id="aST-Bj-tTS"/>
156
                 <menuItem title="Quit OtaClock" keyEquivalent="q" id="BNj-pS-CpH">
267
                 <menuItem title="Quit OtaClock" keyEquivalent="q" id="BNj-pS-CpH">
157
                     <connections>
268
                     <connections>
158
                         <action selector="terminate:" target="-1" id="19f-sZ-hYK"/>
269
                         <action selector="terminate:" target="-1" id="19f-sZ-hYK"/>
159
                     </connections>
270
                     </connections>
160
                 </menuItem>
271
                 </menuItem>
161
             </items>
272
             </items>
162
-            <point key="canvasLocation" x="376" y="304.5"/>
273
+            <point key="canvasLocation" x="292.5" y="80.5"/>
163
         </menu>
274
         </menu>
275
+        <datePicker verticalHuggingPriority="750" id="A2I-e6-ur5">
276
+            <rect key="frame" x="0.0" y="0.0" width="278" height="148"/>
277
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
278
+            <datePickerCell key="cell" borderStyle="bezel" alignment="left" datePickerStyle="clockAndCalendar" id="aSU-YP-y5q">
279
+                <font key="font" metaFont="system"/>
280
+                <calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
281
+                    <!--1982-02-12 16:00:00 +0000-->
282
+                    <timeZone key="timeZone" name="US/Pacific"/>
283
+                </calendarDate>
284
+                <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
285
+                <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
286
+                <datePickerElements key="datePickerElements" year="YES" month="YES" day="YES" hour="YES" minute="YES" second="YES"/>
287
+            </datePickerCell>
288
+            <connections>
289
+                <action selector="alarmDateSelected:" target="QvC-M9-y7g" id="ghc-DM-FuW"/>
290
+            </connections>
291
+            <point key="canvasLocation" x="121.5" y="377"/>
292
+        </datePicker>
164
     </objects>
293
     </objects>
165
 </document>
294
 </document>

+ 21
- 0
OtaClock/Images.xcassets/blank.imageset/Contents.json View File

1
+{
2
+  "images" : [
3
+    {
4
+      "idiom" : "universal",
5
+      "scale" : "1x",
6
+      "filename" : "blank.png"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "version" : 1,
19
+    "author" : "xcode"
20
+  }
21
+}

BIN
OtaClock/Images.xcassets/blank.imageset/blank.png View File


+ 1
- 1
OtaClock/Info.plist View File

19
 	<key>CFBundleSignature</key>
19
 	<key>CFBundleSignature</key>
20
 	<string>????</string>
20
 	<string>????</string>
21
 	<key>CFBundleVersion</key>
21
 	<key>CFBundleVersion</key>
22
-	<string>259</string>
22
+	<string>291</string>
23
 	<key>LSApplicationCategoryType</key>
23
 	<key>LSApplicationCategoryType</key>
24
 	<string>public.app-category.utilities</string>
24
 	<string>public.app-category.utilities</string>
25
 	<key>LSMinimumSystemVersion</key>
25
 	<key>LSMinimumSystemVersion</key>

+ 72
- 4
OtaClock/MainWindow.m View File

10
 #import "MainWindow.h"
10
 #import "MainWindow.h"
11
 
11
 
12
 #define RESIZE_START 1
12
 #define RESIZE_START 1
13
-#define RESIZE_END 5
13
+#define RESIZE_END 10
14
 #define RESIZE_STEP 1
14
 #define RESIZE_STEP 1
15
 
15
 
16
 #define CONFIG_START_SCALE @"window_scale"
16
 #define CONFIG_START_SCALE @"window_scale"
17
 #define CONFIG_KEEP_POSITION @"keep_position"
17
 #define CONFIG_KEEP_POSITION @"keep_position"
18
 #define CONFIG_KEEP_ON_TOP @"keep_on_top"
18
 #define CONFIG_KEEP_ON_TOP @"keep_on_top"
19
+#define CONFIG_MILITARY_TIME @"military_time"
20
+#define CONFIG_SHOW_DATE @"show_date"
21
+#define CONFIG_ALARM_TIME @"alarm_time"
19
 
22
 
20
 #define MOUSE_CENTER_X 67
23
 #define MOUSE_CENTER_X 67
21
 #define MOUSE_CENTER_Y 47
24
 #define MOUSE_CENTER_Y 47
34
 @property (assign) NSSize defaultSize;
37
 @property (assign) NSSize defaultSize;
35
 @property (assign) NSInteger startScale;
38
 @property (assign) NSInteger startScale;
36
 @property (assign) NSInteger lastEyeState;
39
 @property (assign) NSInteger lastEyeState;
37
-@property (assign) BOOL currentlyBlinking;
40
+@property (assign) BOOL currentlyBlinking, showDate;
38
 
41
 
39
 @property (weak) IBOutlet MainView *mainView;
42
 @property (weak) IBOutlet MainView *mainView;
43
+@property (weak) IBOutlet NSDatePicker *alarmDatePicker;
40
 
44
 
41
 @property (weak) IBOutlet NSMenuItem *lockPositionItem;
45
 @property (weak) IBOutlet NSMenuItem *lockPositionItem;
42
 @property (weak) IBOutlet NSMenuItem *keepOnTopItem;
46
 @property (weak) IBOutlet NSMenuItem *keepOnTopItem;
47
+@property (weak) IBOutlet NSMenuItem *setAlarmItem;
48
+@property (weak) IBOutlet NSMenuItem *showDateItem;
43
 
49
 
44
 @property (weak) IBOutlet NSMenuItem *changeSize1;
50
 @property (weak) IBOutlet NSMenuItem *changeSize1;
45
 @property (weak) IBOutlet NSMenuItem *changeSize2;
51
 @property (weak) IBOutlet NSMenuItem *changeSize2;
46
 @property (weak) IBOutlet NSMenuItem *changeSize3;
52
 @property (weak) IBOutlet NSMenuItem *changeSize3;
47
 @property (weak) IBOutlet NSMenuItem *changeSize4;
53
 @property (weak) IBOutlet NSMenuItem *changeSize4;
48
 @property (weak) IBOutlet NSMenuItem *changeSize5;
54
 @property (weak) IBOutlet NSMenuItem *changeSize5;
55
+@property (weak) IBOutlet NSMenuItem *changeSize6;
56
+@property (weak) IBOutlet NSMenuItem *changeSize7;
57
+@property (weak) IBOutlet NSMenuItem *changeSize8;
58
+@property (weak) IBOutlet NSMenuItem *changeSize9;
59
+@property (weak) IBOutlet NSMenuItem *changeSize10;
49
 
60
 
50
 @end
61
 @end
51
 
62
 
57
 @synthesize defaultSize;
68
 @synthesize defaultSize;
58
 @synthesize startScale;
69
 @synthesize startScale;
59
 @synthesize lastEyeState;
70
 @synthesize lastEyeState;
60
-@synthesize currentlyBlinking;
71
+@synthesize currentlyBlinking, showDate;
61
 
72
 
62
 - (id)initWithContentRect:(NSRect)contentRect
73
 - (id)initWithContentRect:(NSRect)contentRect
63
                styleMask:(NSUInteger)aStyle
74
                styleMask:(NSUInteger)aStyle
116
     if (startScale == 3) [self.changeSize3 setState:NSOnState];
127
     if (startScale == 3) [self.changeSize3 setState:NSOnState];
117
     if (startScale == 4) [self.changeSize4 setState:NSOnState];
128
     if (startScale == 4) [self.changeSize4 setState:NSOnState];
118
     if (startScale == 5) [self.changeSize5 setState:NSOnState];
129
     if (startScale == 5) [self.changeSize5 setState:NSOnState];
130
+    if (startScale == 6) [self.changeSize6 setState:NSOnState];
131
+    if (startScale == 7) [self.changeSize7 setState:NSOnState];
132
+    if (startScale == 8) [self.changeSize8 setState:NSOnState];
133
+    if (startScale == 9) [self.changeSize9 setState:NSOnState];
134
+    if (startScale == 10) [self.changeSize10 setState:NSOnState];
119
     
135
     
120
     [[self.mainView render] drawWithEye:lastEyeState]; // Initialize render image
136
     [[self.mainView render] drawWithEye:lastEyeState]; // Initialize render image
121
     [self unblink]; // Schedule next blinking
137
     [self unblink]; // Schedule next blinking
124
     [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateTime:) userInfo:nil repeats:YES];
140
     [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateTime:) userInfo:nil repeats:YES];
125
     [self updateTime:nil];
141
     [self updateTime:nil];
126
     
142
     
143
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
144
+    
145
+    // load alarm date
146
+    if ([defaults objectForKey:CONFIG_ALARM_TIME] == nil) {
147
+        self.alarmDatePicker.dateValue = [NSDate date];
148
+    } else {
149
+        self.alarmDatePicker.dateValue = [defaults objectForKey:CONFIG_ALARM_TIME];
150
+    }
151
+    self.setAlarmItem.view = self.alarmDatePicker;
152
+    
153
+    // load show date state
154
+    if ([defaults objectForKey:CONFIG_SHOW_DATE] == nil) {
155
+        showDate = YES;
156
+    } else {
157
+        showDate = [defaults boolForKey:CONFIG_SHOW_DATE];
158
+    }
159
+    if (showDate == YES) {
160
+        self.showDateItem.state = NSOnState;
161
+    } else {
162
+        self.showDateItem.state = NSOffState;
163
+    }
164
+    
165
+    [[self.mainView render] drawDate:showDate];
166
+    
127
     [self setFrame:frame display:YES];
167
     [self setFrame:frame display:YES];
128
 }
168
 }
129
 
169
 
152
     [self performSelector:@selector(blink) withObject:nil afterDelay:(((float)rand() / RAND_MAX) * MAX_BLINK_DELAY)];
192
     [self performSelector:@selector(blink) withObject:nil afterDelay:(((float)rand() / RAND_MAX) * MAX_BLINK_DELAY)];
153
 }
193
 }
154
 
194
 
195
+- (IBAction)alarmDateSelected:(id)sender {
196
+    // TODO do something with this alarm time...
197
+    
198
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
199
+    [defaults setObject:self.alarmDatePicker.dateValue forKey:CONFIG_ALARM_TIME];
200
+    [defaults synchronize];
201
+}
202
+
203
+- (IBAction)showDate:(id)sender {
204
+    if (showDate == YES) {
205
+        showDate = NO;
206
+        self.showDateItem.state = NSOffState;
207
+    } else {
208
+        showDate = YES;
209
+        self.showDateItem.state = NSOnState;
210
+    }
211
+    [[self.mainView render] drawDate:showDate];
212
+    
213
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
214
+    [defaults setBool:showDate forKey:CONFIG_SHOW_DATE];
215
+    [defaults synchronize];
216
+}
217
+
155
 - (IBAction)changeSize:(NSMenuItem *)sender {
218
 - (IBAction)changeSize:(NSMenuItem *)sender {
156
     NSRect frame = [self frame];
219
     NSRect frame = [self frame];
157
     
220
     
160
     [self.changeSize3 setState:NSOffState];
223
     [self.changeSize3 setState:NSOffState];
161
     [self.changeSize4 setState:NSOffState];
224
     [self.changeSize4 setState:NSOffState];
162
     [self.changeSize5 setState:NSOffState];
225
     [self.changeSize5 setState:NSOffState];
226
+    [self.changeSize6 setState:NSOffState];
227
+    [self.changeSize7 setState:NSOffState];
228
+    [self.changeSize8 setState:NSOffState];
229
+    [self.changeSize9 setState:NSOffState];
230
+    [self.changeSize10 setState:NSOffState];
163
     
231
     
164
     BOOL found = NO;
232
     BOOL found = NO;
165
     for (int i = RESIZE_START; i <= RESIZE_END; i += RESIZE_STEP) {
233
     for (int i = RESIZE_START; i <= RESIZE_END; i += RESIZE_STEP) {
166
-        NSString *title = [NSString stringWithFormat:@"%dx", i];
234
+        NSString *title = [NSString stringWithFormat:@"x%d", i];
167
         if ([[sender title] isEqualToString:title]) {
235
         if ([[sender title] isEqualToString:title]) {
168
             [sender setState:NSOnState];
236
             [sender setState:NSOnState];
169
             NSSize newSize = defaultSize;
237
             NSSize newSize = defaultSize;

+ 1
- 0
OtaClock/Render.h View File

15
 - (id)initWithParent:(MainView *)par;
15
 - (id)initWithParent:(MainView *)par;
16
 - (NSSize)baseSize;
16
 - (NSSize)baseSize;
17
 
17
 
18
+- (void)drawDate:(BOOL)draw;
18
 - (void)drawWithDate:(NSDate *)date;
19
 - (void)drawWithDate:(NSDate *)date;
19
 - (void)drawWithEye:(NSInteger)eyeIndex;
20
 - (void)drawWithEye:(NSInteger)eyeIndex;
20
 - (void)drawInto:(NSView *)view;
21
 - (void)drawInto:(NSView *)view;

+ 49
- 31
OtaClock/Render.m View File

60
 #define DOTS_ALARM_X_OFFSET 38
60
 #define DOTS_ALARM_X_OFFSET 38
61
 #define DOTS_ALARM_Y_OFFSET 57
61
 #define DOTS_ALARM_Y_OFFSET 57
62
 
62
 
63
+#define BLANK_OFFSET_X 13
64
+#define BLANK_OFFSET_Y 71
65
+
63
 @interface Render ()
66
 @interface Render ()
64
 
67
 
65
-@property (assign) CGImageRef otaconGraphic, bubbleGraphic, alarmGraphic;
68
+@property (assign) CGImageRef otaconGraphic, bubbleGraphic, alarmGraphic, blankGraphic;
66
 @property (assign) CGImageRef eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
69
 @property (assign) CGImageRef eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
67
 @property (assign) CGImageRef fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
70
 @property (assign) CGImageRef fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
68
 @property (assign) CGImageRef fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
71
 @property (assign) CGImageRef fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
72
 @property (assign) NSInteger dateDigit0, dateDigit1, dateDigit2, dateDigit3;
75
 @property (assign) NSInteger dateDigit0, dateDigit1, dateDigit2, dateDigit3;
73
 @property (assign) NSInteger alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
76
 @property (assign) NSInteger alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
74
 @property (assign) NSInteger timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
77
 @property (assign) NSInteger timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
75
-@property (assign) BOOL alarmSign, alarmDots, timeDots;
78
+@property (assign) BOOL alarmSign, alarmDots, timeDots, drawDate;
76
 
79
 
77
 @property (assign) NSSize fullSize;
80
 @property (assign) NSSize fullSize;
78
 @property (assign) CGContextRef drawContext;
81
 @property (assign) CGContextRef drawContext;
83
 
86
 
84
 @implementation Render
87
 @implementation Render
85
 
88
 
86
-@synthesize otaconGraphic, bubbleGraphic, alarmGraphic;
89
+@synthesize otaconGraphic, bubbleGraphic, alarmGraphic, blankGraphic;
87
 @synthesize eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
90
 @synthesize eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
88
 @synthesize fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
91
 @synthesize fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
89
 @synthesize fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
92
 @synthesize fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
93
 @synthesize dateDigit0, dateDigit1, dateDigit2, dateDigit3;
96
 @synthesize dateDigit0, dateDigit1, dateDigit2, dateDigit3;
94
 @synthesize alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
97
 @synthesize alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
95
 @synthesize timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
98
 @synthesize timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
96
-@synthesize alarmSign, alarmDots, timeDots;
99
+@synthesize alarmSign, alarmDots, timeDots, drawDate;
97
 
100
 
98
 @synthesize fullSize;
101
 @synthesize fullSize;
99
 @synthesize drawContext;
102
 @synthesize drawContext;
175
     NSImage *alarmImage = [NSImage imageNamed:@"alarm"];
178
     NSImage *alarmImage = [NSImage imageNamed:@"alarm"];
176
     NSImage *dotsSmallImage = [NSImage imageNamed:@"dots_small"];
179
     NSImage *dotsSmallImage = [NSImage imageNamed:@"dots_small"];
177
     NSImage *dotsLargeImage = [NSImage imageNamed:@"dots_large"];
180
     NSImage *dotsLargeImage = [NSImage imageNamed:@"dots_large"];
181
+    NSImage *blankImage = [NSImage imageNamed:@"blank"];
178
     
182
     
179
     NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithAttributes:nil];
183
     NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithAttributes:nil];
180
     
184
     
183
     alarmGraphic = [alarmImage CGImageForProposedRect:nil context:context hints:nil];
187
     alarmGraphic = [alarmImage CGImageForProposedRect:nil context:context hints:nil];
184
     dotSmallGraphic = [dotsSmallImage CGImageForProposedRect:nil context:context hints:nil];
188
     dotSmallGraphic = [dotsSmallImage CGImageForProposedRect:nil context:context hints:nil];
185
     dotLargeGraphic = [dotsLargeImage CGImageForProposedRect:nil context:context hints:nil];
189
     dotLargeGraphic = [dotsLargeImage CGImageForProposedRect:nil context:context hints:nil];
190
+    blankGraphic = [blankImage CGImageForProposedRect:nil context:context hints:nil];
186
     eye0 = [eye0Image CGImageForProposedRect:nil context:context hints:nil];
191
     eye0 = [eye0Image CGImageForProposedRect:nil context:context hints:nil];
187
     eye1 = [eye1Image CGImageForProposedRect:nil context:context hints:nil];
192
     eye1 = [eye1Image CGImageForProposedRect:nil context:context hints:nil];
188
     eye2 = [eye2Image CGImageForProposedRect:nil context:context hints:nil];
193
     eye2 = [eye2Image CGImageForProposedRect:nil context:context hints:nil];
315
     } \
320
     } \
316
 } while (0);
321
 } while (0);
317
 
322
 
323
+- (void)drawDate:(BOOL)draw {
324
+    drawDate = draw;
325
+}
326
+
318
 - (void)drawWithDate:(NSDate *)date {
327
 - (void)drawWithDate:(NSDate *)date {
319
     NSCalendarUnit comps = NSWeekdayCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
328
     NSCalendarUnit comps = NSWeekdayCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
320
     NSDateComponents *components = [[NSCalendar currentCalendar] components:comps fromDate:date];
329
     NSDateComponents *components = [[NSCalendar currentCalendar] components:comps fromDate:date];
344
     size.origin.y = BUBBLE_Y_OFFSET;
353
     size.origin.y = BUBBLE_Y_OFFSET;
345
     CGContextDrawImage(drawContext, size, bubbleGraphic);
354
     CGContextDrawImage(drawContext, size, bubbleGraphic);
346
 
355
 
347
-    // Draw Date
348
-    size.size.width = FONT_SMALL_WIDTH;
349
-    size.size.height = FONT_SMALL_HEIGHT;
350
-    size.origin.y = FONT_SMALL_DATE_Y_OFFSET;
351
-    if (dateDigit0 == 1) {
352
-        size.origin.x = FONT_SMALL_DATE_X0_OFFSET;
353
-        CGContextDrawImage(drawContext, size, fontSmall1);
356
+    if (drawDate == YES) {
357
+        // Draw Date
358
+        size.size.width = FONT_SMALL_WIDTH;
359
+        size.size.height = FONT_SMALL_HEIGHT;
360
+        size.origin.y = FONT_SMALL_DATE_Y_OFFSET;
361
+        if (dateDigit0 == 1) {
362
+            size.origin.x = FONT_SMALL_DATE_X0_OFFSET;
363
+            CGContextDrawImage(drawContext, size, fontSmall1);
364
+        }
365
+        if ((dateDigit1 >= 0) && (dateDigit1 <= 9)) {
366
+            size.origin.x = FONT_SMALL_DATE_X1_OFFSET;
367
+            CGContextDrawImage(drawContext, size, [self smallHelper:dateDigit1]);
368
+        }
369
+        if ((dateDigit2 >= 0) && (dateDigit2 <= 9)) {
370
+            size.origin.x = FONT_SMALL_DATE_X2_OFFSET;
371
+            CGContextDrawImage(drawContext, size, [self smallHelper:dateDigit2]);
372
+        }
373
+        if ((dateDigit3 >= 0) && (dateDigit3 <= 9)) {
374
+            size.origin.x = FONT_SMALL_DATE_X3_OFFSET;
375
+            CGContextDrawImage(drawContext, size, [self smallHelper:dateDigit3]);
376
+        }
377
+
378
+        // Draw Day of Week
379
+        CGImageRef day = [self dayHelper:dayOfWeek];
380
+        size.size.width = FONT_DAYS_WIDTH;
381
+        size.size.height = FONT_DAYS_HEIGHT;
382
+        size.origin.x = FONT_DAYS_X_OFFSET;
383
+        size.origin.y = FONT_DAYS_Y_OFFSET;
384
+        CGContextDrawImage(drawContext, size, day);
385
+    } else {
386
+        // Block unneeded date elements
387
+        size.size.width = CGImageGetWidth(blankGraphic);
388
+        size.size.height = CGImageGetHeight(blankGraphic);
389
+        size.origin.x = BLANK_OFFSET_X;
390
+        size.origin.y = BLANK_OFFSET_Y;
391
+        CGContextDrawImage(drawContext, size, blankGraphic);
354
     }
392
     }
355
-    if ((dateDigit1 >= 0) && (dateDigit1 <= 9)) {
356
-        size.origin.x = FONT_SMALL_DATE_X1_OFFSET;
357
-        CGContextDrawImage(drawContext, size, [self smallHelper:dateDigit1]);
358
-    }
359
-    if ((dateDigit2 >= 0) && (dateDigit2 <= 9)) {
360
-        size.origin.x = FONT_SMALL_DATE_X2_OFFSET;
361
-        CGContextDrawImage(drawContext, size, [self smallHelper:dateDigit2]);
362
-    }
363
-    if ((dateDigit3 >= 0) && (dateDigit3 <= 9)) {
364
-        size.origin.x = FONT_SMALL_DATE_X3_OFFSET;
365
-        CGContextDrawImage(drawContext, size, [self smallHelper:dateDigit3]);
366
-    }
367
-
368
-    // Draw Day of Week
369
-    CGImageRef day = [self dayHelper:dayOfWeek];
370
-    size.size.width = FONT_DAYS_WIDTH;
371
-    size.size.height = FONT_DAYS_HEIGHT;
372
-    size.origin.x = FONT_DAYS_X_OFFSET;
373
-    size.origin.y = FONT_DAYS_Y_OFFSET;
374
-    CGContextDrawImage(drawContext, size, day);
375
     
393
     
376
     // Draw Time
394
     // Draw Time
377
     size.size.width = FONT_LARGE_WIDTH;
395
     size.size.width = FONT_LARGE_WIDTH;

Loading…
Cancel
Save