Changeset 370 for trunk/Cocoa
- Timestamp:
- 12/08/07 06:07:14 (17 years ago)
- Location:
- trunk/Cocoa/AntiRSI
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/AntiRSI.h
r346 r370 80 80 double sample_interval; 81 81 82 // v erious other options82 // various other options 83 83 bool lock_focus; 84 84 bool draw_dock_image; -
trunk/Cocoa/AntiRSI/AntiRSI.m
r348 r370 24 24 #include <ApplicationServices/ApplicationServices.h> 25 25 26 // 10.5-only 27 enum { 28 NSWindowCollectionBehaviorDefault = 0, 29 NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0, 30 NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1 31 }; 32 typedef unsigned NSWindowCollectionBehavior; 33 @interface NSWindow (NSWindowCollectionBehavior) 34 - (void)setCollectionBehavior:(NSWindowCollectionBehavior)behavior; 35 @end 36 26 37 extern CFTimeInterval CGSSecondsSinceLastInputEvent(unsigned long eventType); 27 38 … … 194 205 [main_window setHasShadow:NO]; 195 206 [main_window setMovableByWindowBackground:YES]; 207 if ([main_window respondsToSelector:@selector(setCollectionBehavior:)]) 208 [main_window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces]; 209 196 210 [main_window center]; 197 211 [main_window setContentView:view]; … … 235 249 [dc setInitialValues:initial]; 236 250 237 // bind to defaul s controller251 // bind to defaults controller 238 252 [self bind:@"micro_pause_period" toObject:dc withKeyPath:@"values.micro_pause_period" options:nil]; 239 253 [self bind:@"micro_pause_duration" toObject:dc withKeyPath:@"values.micro_pause_duration" options:nil]; … … 550 564 } 551 565 566 static ProcessSerialNumber frontmostApp; 567 552 568 // done with micro pause or work break 553 569 - (void)endBreak 554 570 { 555 571 [main_window orderOut:NULL]; 572 if (lock_focus && (frontmostApp.highLongOfPSN != 0 || frontmostApp.lowLongOfPSN != 0)) { 573 SetFrontProcess(&frontmostApp); 574 frontmostApp.highLongOfPSN = kNoProcess; 575 } 556 576 state = s_normal; 557 577 // reset time interval to user's choice 558 578 [self installTimer:sample_interval]; 579 } 580 581 // bring app to front, saving previous app 582 - (void)focus 583 { 584 NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication]; 585 if (lock_focus) { 586 frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue]; 587 frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue]; 588 } 589 [self tick: nil]; 590 [main_window center]; 591 [main_window orderFrontRegardless]; 559 592 } 560 593 … … 570 603 [postpone setHidden:YES]; 571 604 state = s_taking_micro_pause; 572 [self tick: nil]; 573 [main_window center]; 574 [main_window orderFrontRegardless]; 605 [self focus]; 575 606 } 576 607 … … 591 622 [postpone setHidden:NO]; 592 623 state = s_taking_work_break; 593 [self tick: nil]; 594 [main_window center]; 595 [main_window orderFrontRegardless]; 624 [self focus]; 596 625 } 597 626 … … 656 685 int r = NSRunInformationalAlertPanel( 657 686 @"New Version", 658 [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to the website now?", latest_version],687 [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to its Web site now?", latest_version], 659 688 @"Goto Website", @"Cancel", nil); 660 689 if (r == NSOKButton) { -
trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj
r348 r370 27 27 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; 28 28 E1203BFC0894184900759E75 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1203BFB0894184900759E75 /* ApplicationServices.framework */; }; 29 E128CD160D0A40660031ACD5 /* AntiRSIButton.h in Headers */ = {isa = PBXBuildFile; fileRef = E128CD140D0A40660031ACD5 /* AntiRSIButton.h */; }; 30 E128CD170D0A40660031ACD5 /* AntiRSIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = E128CD150D0A40660031ACD5 /* AntiRSIButton.m */; }; 29 31 E1F60361098592D800806C3B /* AntiRSILevelIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F6035F098592D800806C3B /* AntiRSILevelIndicator.m */; }; 30 32 E1F60362098592D800806C3B /* AntiRSILevelIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */; }; … … 42 44 464D9ADB0C6A622B005A0582 /* CTBadge.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = CTBadge.m; path = CTBadge/CTBadge.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; }; 43 45 464D9ADC0C6A622B005A0582 /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CTGradient.h; path = CTBadge/CTGradient.h; sourceTree = "<group>"; }; 44 464D9ADD0C6A622B005A0582 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CTGradient.m; path = CTBadge/CTGradient.m; sourceTree = "<group>"; };46 464D9ADD0C6A622B005A0582 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = CTGradient.m; path = CTBadge/CTGradient.m; sourceTree = "<group>"; tabWidth = 4; }; 45 47 464D9B750C6A760B005A0582 /* CTBadge_1.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_1.pdf; sourceTree = "<group>"; }; 46 48 464D9B760C6A760B005A0582 /* CTBadge_3.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_3.pdf; sourceTree = "<group>"; }; … … 55 57 8D1107320486CEB800E47090 /* AntiRSI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AntiRSI.app; sourceTree = BUILT_PRODUCTS_DIR; }; 56 58 E1203BFB0894184900759E75 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; }; 59 E128CD140D0A40660031ACD5 /* AntiRSIButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AntiRSIButton.h; sourceTree = "<group>"; }; 60 E128CD150D0A40660031ACD5 /* AntiRSIButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AntiRSIButton.m; sourceTree = "<group>"; }; 57 61 E1F6035F098592D800806C3B /* AntiRSILevelIndicator.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = AntiRSILevelIndicator.m; sourceTree = "<group>"; }; 58 62 E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AntiRSILevelIndicator.h; sourceTree = "<group>"; }; … … 79 83 4DF73F66061E136200B0D9C9 /* AntiRSIView.h */, 80 84 4DF73F65061E136200B0D9C9 /* AntiRSIView.m */, 85 E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */, 81 86 E1F6035F098592D800806C3B /* AntiRSILevelIndicator.m */, 82 E1F60360098592D800806C3B /* AntiRSILevelIndicator.h */, 87 E128CD140D0A40660031ACD5 /* AntiRSIButton.h */, 88 E128CD150D0A40660031ACD5 /* AntiRSIButton.m */, 83 89 ); 84 90 name = Classes; … … 190 196 464D9ADE0C6A622B005A0582 /* CTBadge.h in Headers */, 191 197 464D9AE00C6A622B005A0582 /* CTGradient.h in Headers */, 198 E128CD160D0A40660031ACD5 /* AntiRSIButton.h in Headers */, 192 199 ); 193 200 runOnlyForDeploymentPostprocessing = 0; … … 267 274 464D9ADF0C6A622B005A0582 /* CTBadge.m in Sources */, 268 275 464D9AE10C6A622B005A0582 /* CTGradient.m in Sources */, 276 E128CD170D0A40660031ACD5 /* AntiRSIButton.m in Sources */, 269 277 ); 270 278 runOnlyForDeploymentPostprocessing = 0; … … 406 414 ); 407 415 GCC_C_LANGUAGE_STANDARD = c99; 416 MACOSX_DEPLOYMENT_TARGET = 10.4; 408 417 PREBINDING = NO; 409 418 SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; -
trunk/Cocoa/AntiRSI/CTBadge/CTGradient.m
r332 r370 779 779 - (void)setBlendingMode:(CTGradientBlendingMode)mode; 780 780 { 781 blendingMode = mode;782 783 781 //Choose what blending function to use 784 782 void *evaluationFunction; 785 switch( blendingMode)783 switch(mode) 786 784 { 787 785 case CTLinearBlendingMode: … … 791 789 case CTInverseChromaticBlendingMode: 792 790 evaluationFunction = &inverseChromaticEvaluation; break; 793 } 794 791 default: 792 NSParameterAssert("blending mode not supported" && NO); 793 return; // unreachable, satisfy compiler 794 } 795 796 blendingMode = mode; 797 795 798 //replace the current CoreGraphics Function with new one 796 799 if(gradientFunction != NULL) … … 1183 1186 1184 1187 1185 void transformRGB_HSV(float *components) //H,S,B -> R,G,B 1186 { 1187 float H, S, V; 1188 void transformRGB_HSV(float *components) //H,S,B <- R,G,B 1189 { 1188 1190 float R = components[0], 1189 1191 G = components[1], … … 1193 1195 MIN = R < G ? (R < B ? R : B) : (G < B ? G : B); 1194 1196 1195 if(MAX == MIN) 1196 H = NAN; 1197 else if(MAX == R) 1198 if(G >= B) 1199 H = 60*(G-B)/(MAX-MIN)+0; 1200 else 1201 H = 60*(G-B)/(MAX-MIN)+360; 1202 else if(MAX == G) 1203 H = 60*(B-R)/(MAX-MIN)+120; 1204 else if(MAX == B) 1205 H = 60*(R-G)/(MAX-MIN)+240; 1206 1207 S = MAX == 0 ? 0 : 1 - MIN/MAX; 1208 V = MAX; 1197 float H = NAN; 1198 1199 if(MAX != MIN) 1200 { 1201 if(MAX == R) 1202 if(G >= B) 1203 H = 60*(G-B)/(MAX-MIN)+0; 1204 else 1205 H = 60*(G-B)/(MAX-MIN)+360; 1206 else if(MAX == G) 1207 H = 60*(B-R)/(MAX-MIN)+120; 1208 else if(MAX == B) 1209 H = 60*(R-G)/(MAX-MIN)+240; 1210 } 1211 1212 float S = MAX == 0 ? 0 : 1 - MIN/MAX; 1213 float V = MAX; 1209 1214 1210 1215 components[0] = H; … … 1234 1239 case 4: R=t;G=p;B=V; break; 1235 1240 case 5: R=V;G=p;B=q; break; 1241 default: R=0;G=0;B=0; // unreachable, satisfy compiler 1236 1242 } 1237 1243 -
trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib
r332 r370 1 { 2 IBClasses = ( 3 { 4 ACTIONS = { 5 breakNow = id; 6 checkForUpdate = id; 7 gotoWebsite = id; 8 postpone = id; 9 resetSession = id; 10 }; 11 CLASS = AntiRSI; 12 LANGUAGE = ObjC; 13 OUTLETS = { 14 "dock_menu" = NSMenu; 15 "next_break" = NSTextField; 16 postpone = NSButton; 17 progress = NSLevelIndicator; 18 "reset_session_time" = NSDatePicker; 19 "session_time" = NSTextField; 20 "session_time_item" = NSMenuItem; 21 status = NSTextField; 22 time = NSTextField; 23 version = NSTextField; 24 view = AntiRSIView; 25 }; 26 SUPERCLASS = NSObject; 27 }, 28 { 29 CLASS = AntiRSILevelIndicator; 30 LANGUAGE = ObjC; 31 SUPERCLASS = NSLevelIndicator; 32 }, 33 {CLASS = AntiRSIView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, 34 {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 35 {CLASS = NSDatePicker; LANGUAGE = ObjC; SUPERCLASS = NSControl; }, 36 {CLASS = NSLevelIndicator; LANGUAGE = ObjC; SUPERCLASS = NSControl; } 37 ); 38 IBVersion = 1; 39 } 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 <plist version="1.0"> 4 <dict> 5 <key>IBClasses</key> 6 <array> 7 <dict> 8 <key>CLASS</key> 9 <string>NSLevelIndicator</string> 10 <key>LANGUAGE</key> 11 <string>ObjC</string> 12 <key>SUPERCLASS</key> 13 <string>NSControl</string> 14 </dict> 15 <dict> 16 <key>CLASS</key> 17 <string>AntiRSIButton</string> 18 <key>LANGUAGE</key> 19 <string>ObjC</string> 20 <key>SUPERCLASS</key> 21 <string>NSButton</string> 22 </dict> 23 <dict> 24 <key>ACTIONS</key> 25 <dict> 26 <key>breakNow</key> 27 <string>id</string> 28 <key>checkForUpdate</key> 29 <string>id</string> 30 <key>gotoWebsite</key> 31 <string>id</string> 32 <key>postpone</key> 33 <string>id</string> 34 <key>resetSession</key> 35 <string>id</string> 36 </dict> 37 <key>CLASS</key> 38 <string>AntiRSI</string> 39 <key>LANGUAGE</key> 40 <string>ObjC</string> 41 <key>OUTLETS</key> 42 <dict> 43 <key>dock_menu</key> 44 <string>NSMenu</string> 45 <key>next_break</key> 46 <string>NSTextField</string> 47 <key>postpone</key> 48 <string>NSButton</string> 49 <key>progress</key> 50 <string>NSLevelIndicator</string> 51 <key>reset_session_time</key> 52 <string>NSDatePicker</string> 53 <key>session_time</key> 54 <string>NSTextField</string> 55 <key>session_time_item</key> 56 <string>NSMenuItem</string> 57 <key>status</key> 58 <string>NSTextField</string> 59 <key>time</key> 60 <string>NSTextField</string> 61 <key>version</key> 62 <string>NSTextField</string> 63 <key>view</key> 64 <string>AntiRSIView</string> 65 </dict> 66 <key>SUPERCLASS</key> 67 <string>NSObject</string> 68 </dict> 69 <dict> 70 <key>CLASS</key> 71 <string>FirstResponder</string> 72 <key>LANGUAGE</key> 73 <string>ObjC</string> 74 <key>SUPERCLASS</key> 75 <string>NSObject</string> 76 </dict> 77 <dict> 78 <key>CLASS</key> 79 <string>NSDatePicker</string> 80 <key>LANGUAGE</key> 81 <string>ObjC</string> 82 <key>SUPERCLASS</key> 83 <string>NSControl</string> 84 </dict> 85 <dict> 86 <key>CLASS</key> 87 <string>AntiRSIView</string> 88 <key>LANGUAGE</key> 89 <string>ObjC</string> 90 <key>SUPERCLASS</key> 91 <string>NSView</string> 92 </dict> 93 <dict> 94 <key>CLASS</key> 95 <string>AntiRSILevelIndicator</string> 96 <key>LANGUAGE</key> 97 <string>ObjC</string> 98 <key>SUPERCLASS</key> 99 <string>NSLevelIndicator</string> 100 </dict> 101 </array> 102 <key>IBVersion</key> 103 <string>1</string> 104 </dict> 105 </plist> -
trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib
r332 r370 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 3 <plist version="1.0"> 4 4 <dict> 5 <key>IBDocumentLocation</key>6 <string>70 16 441 309 0 0 1680 1028 </string>7 <key>IBEditorPositions</key>8 <dict>9 <key>259</key>10 <string>668 524 300 322 0 0 1680 1028 </string>11 <key>29</key>12 <string>276 845 249 44 0 0 1680 1028 </string>13 <key>343</key>14 <string>241 262 145 99 0 0 1680 1028 </string>15 </dict>16 5 <key>IBFramework Version</key> 17 <string>446.1</string> 6 <string>629</string> 7 <key>IBLastKnownRelativeProjectPath</key> 8 <string>../../AntiRSI.xcodeproj</string> 18 9 <key>IBOldestOS</key> 19 <integer> 4</integer>10 <integer>5</integer> 20 11 <key>IBOpenObjects</key> 21 12 <array> … … 23 14 </array> 24 15 <key>IBSystem Version</key> 25 <string>8R2232</string> 16 <string>9B18</string> 17 <key>targetFramework</key> 18 <string>IBCocoaFramework</string> 26 19 </dict> 27 20 </plist> -
trunk/Cocoa/AntiRSI/Info.plist
r346 r370 18 18 <string>ONNE</string> 19 19 <key>CFBundleVersion</key> 20 <string>1.4njr 3</string>20 <string>1.4njr4</string> 21 21 <key>NSMainNibFile</key> 22 22 <string>MainMenu</string>
Note:
See TracChangeset
for help on using the changeset viewer.