From 8b8d63e3028561130e9e8679bfb283f4eeaa8f28 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Sat, 20 Apr 2002 02:15:19 +0000 Subject: [PATCH] Initial commit of the about box for chimera. NPOB. --- camino/AboutBox.nib/classes.nib | 13 ++ camino/AboutBox.nib/info.nib | 18 +++ camino/AboutBox.nib/objects.nib | Bin 0 -> 1466 bytes camino/CHAboutBox.h | 35 +++++ camino/CHAboutBox.m | 124 ++++++++++++++++++ camino/Chimera.pbproj/project.pbxproj | 4 +- camino/English.lproj/AboutBox.nib/classes.nib | 13 ++ camino/English.lproj/AboutBox.nib/info.nib | 18 +++ camino/English.lproj/AboutBox.nib/objects.nib | Bin 0 -> 1466 bytes .../projects/Chimera.pbproj/project.pbxproj | 4 +- .../English.lproj/AboutBox.nib/classes.nib | 13 ++ .../English.lproj/AboutBox.nib/info.nib | 18 +++ .../English.lproj/AboutBox.nib/objects.nib | Bin 0 -> 1466 bytes camino/src/application/AboutBox.h | 35 +++++ camino/src/application/AboutBox.m | 124 ++++++++++++++++++ chimera/AboutBox.nib/classes.nib | 13 ++ chimera/AboutBox.nib/info.nib | 18 +++ chimera/AboutBox.nib/objects.nib | Bin 0 -> 1466 bytes chimera/CHAboutBox.h | 35 +++++ chimera/CHAboutBox.m | 124 ++++++++++++++++++ chimera/Chimera.pbproj/project.pbxproj | 4 +- .../English.lproj/AboutBox.nib/classes.nib | 13 ++ chimera/English.lproj/AboutBox.nib/info.nib | 18 +++ .../English.lproj/AboutBox.nib/objects.nib | Bin 0 -> 1466 bytes .../projects/Chimera.pbproj/project.pbxproj | 4 +- .../English.lproj/AboutBox.nib/classes.nib | 13 ++ .../English.lproj/AboutBox.nib/info.nib | 18 +++ .../English.lproj/AboutBox.nib/objects.nib | Bin 0 -> 1466 bytes chimera/src/application/AboutBox.h | 35 +++++ chimera/src/application/AboutBox.m | 124 ++++++++++++++++++ 30 files changed, 830 insertions(+), 8 deletions(-) create mode 100644 camino/AboutBox.nib/classes.nib create mode 100644 camino/AboutBox.nib/info.nib create mode 100644 camino/AboutBox.nib/objects.nib create mode 100644 camino/CHAboutBox.h create mode 100644 camino/CHAboutBox.m create mode 100644 camino/English.lproj/AboutBox.nib/classes.nib create mode 100644 camino/English.lproj/AboutBox.nib/info.nib create mode 100644 camino/English.lproj/AboutBox.nib/objects.nib create mode 100644 camino/resources/localized/English.lproj/AboutBox.nib/classes.nib create mode 100644 camino/resources/localized/English.lproj/AboutBox.nib/info.nib create mode 100644 camino/resources/localized/English.lproj/AboutBox.nib/objects.nib create mode 100644 camino/src/application/AboutBox.h create mode 100644 camino/src/application/AboutBox.m create mode 100644 chimera/AboutBox.nib/classes.nib create mode 100644 chimera/AboutBox.nib/info.nib create mode 100644 chimera/AboutBox.nib/objects.nib create mode 100644 chimera/CHAboutBox.h create mode 100644 chimera/CHAboutBox.m create mode 100644 chimera/English.lproj/AboutBox.nib/classes.nib create mode 100644 chimera/English.lproj/AboutBox.nib/info.nib create mode 100644 chimera/English.lproj/AboutBox.nib/objects.nib create mode 100644 chimera/resources/localized/English.lproj/AboutBox.nib/classes.nib create mode 100644 chimera/resources/localized/English.lproj/AboutBox.nib/info.nib create mode 100644 chimera/resources/localized/English.lproj/AboutBox.nib/objects.nib create mode 100644 chimera/src/application/AboutBox.h create mode 100644 chimera/src/application/AboutBox.m diff --git a/camino/AboutBox.nib/classes.nib b/camino/AboutBox.nib/classes.nib new file mode 100644 index 00000000000..b87e9575942 --- /dev/null +++ b/camino/AboutBox.nib/classes.nib @@ -0,0 +1,13 @@ +{ + IBClasses = ( + { + ACTIONS = {showPanel = id; }; + CLASS = AboutBox; + LANGUAGE = ObjC; + OUTLETS = {creditsField = id; window = id; }; + SUPERCLASS = NSObject; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/camino/AboutBox.nib/info.nib b/camino/AboutBox.nib/info.nib new file mode 100644 index 00000000000..386fb2eb4ec --- /dev/null +++ b/camino/AboutBox.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 248.0 + IBLockedObjects + + 7 + + IBOpenObjects + + 5 + + IBSystem Version + 5Q45 + + diff --git a/camino/AboutBox.nib/objects.nib b/camino/AboutBox.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..c6baa8e57f47d50d0cb11340a91f1a474c370e70 GIT binary patch literal 1466 zcmZux&2Jk;6o2E7G#^gWmbM4Pfg6gDIP_4VTyWwlB8P4e8<7J-XuTds18c9fUgPAJ zacAd>v~m`26jY&d!m`vl7vKQMpei>&PziBDoGShTF0{NiYp1AUt^M$OZ+>rn@BQ8s zmcoM;ueHN~I}MqCtXNqob<4-BqQQEcc`|PJV+6aPdHJm+8m@g`|VA&PF83w+$dK{-IoJ3KC zQ6!LM)WIstJXYV+TBl@X= zaNRO6ggW0rg?k>dLVonMjujE22kZ%eDiAFUy@WnfHRSDg0++A$6U>gB30G9XEYh%D8MJ!?lPqfItb{vn;`(5Tmnx?Tk zd_Uabjh5$xT(XD8M$t3dYsc~Zw08w?6>cFy;_%PS>>1zB$Wy_PB_V0FATAQ9_@0kl z9L}jcam5JxpdIoCaass5)C6etu^*S(Z7$MFk_Ul?deMuGHz45yH-W;aBiuaSJ z@FsBZ;3Is7AixDjv3h9;Lq@kwAttmjV|rY^IhO2t4+hC$92tKWHI2o1FeNoaB>X&k z$0HC^fSvmQK@*F3WsBItb80tQk8yU5bazFw=AR2i zvcLOkSqOtc`YyZqoP@DczZkmkJV;yLJJUw<^if}V5R<^F>+%0FM@ z9^b=>B2hnjaAdH%rd(4Cr7yVwuZgg|DY#eD=!ntD=V*g~@1Xa$1`F ix;Xi5dGh + +@interface CHAboutBox : NSObject +{ + IBOutlet id creditsField; + IBOutlet id window; + NSTimer *scrollTimer; + float currentPosition; + float maxScrollHeight; + NSTimeInterval startTime; + BOOL restartAtTop; +} + ++ (CHAboutBox *)sharedInstance; +- (IBAction)showPanel:(id)sender; + +@end diff --git a/camino/CHAboutBox.m b/camino/CHAboutBox.m new file mode 100644 index 00000000000..6730a7b8314 --- /dev/null +++ b/camino/CHAboutBox.m @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +* +* The contents of this file are subject to the Mozilla Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/MPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is the Mozilla browser. +* +* The Initial Developer of the Original Code is Matt Judy. +* +* Contributor(s): +* Matt Judy (Original Author) +* David Hyatt +*/ + +#import "CHAboutBox.h" + +@implementation CHAboutBox + +static CHAboutBox *sharedInstance = nil; + ++ (CHAboutBox *)sharedInstance +{ + return sharedInstance ? sharedInstance : [[self alloc] init]; +} + +- (id)init +{ + if (sharedInstance) { + [self dealloc]; + } else { + sharedInstance = [super init]; + } + return sharedInstance; +} + +- (IBAction)showPanel:(id)sender +{ + if (!creditsField) { + NSString *creditsPath; + NSAttributedString *creditsString; + float fieldHeight; + float containerHeight; + + if (![NSBundle loadNibNamed:@"CHAboutBox" owner:self]) { + NSLog( @"Failed to load CHAboutBox.nib" ); + NSBeep(); + return; + } + + [window setTitle:@"About Navigator"]; + + creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; + creditsString = [[NSAttributedString alloc] initWithPath:creditsPath documentAttributes:nil]; + [creditsField replaceCharactersInRange:NSMakeRange( 0, 0 ) + withRTF:[creditsString RTFFromRange: + NSMakeRange( 0, [creditsString length] ) + documentAttributes:nil]]; + + fieldHeight = [creditsField frame].size.height; + + (void)[[creditsField layoutManager] glyphRangeForTextContainer:[creditsField textContainer]]; + containerHeight = [[creditsField layoutManager] usedRectForTextContainer: + [creditsField textContainer]].size.height; + maxScrollHeight = containerHeight - fieldHeight; + + [window setExcludedFromWindowsMenu:YES]; + [window setMenu:nil]; + [window center]; + } + + if (![window isVisible]) { + currentPosition = 0; + restartAtTop = NO; + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + } + + [window makeKeyAndOrderFront:nil]; +} + +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1/4 + target:self + selector:@selector(scrollCredits:) + userInfo:nil + repeats:YES]; +} + +- (void)windowDidResignKey:(NSNotification *)notification +{ + [scrollTimer invalidate]; +} + +- (void)scrollCredits:(NSTimer *)timer +{ + if ([NSDate timeIntervalSinceReferenceDate] >= startTime) { + + if (restartAtTop) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + restartAtTop = NO; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + return; + } + + if (currentPosition >= maxScrollHeight) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + currentPosition = 0; + restartAtTop = YES; + } else { + [creditsField scrollPoint:NSMakePoint( 0, currentPosition )]; + currentPosition += 0.01; + } + } +} + +@end diff --git a/camino/Chimera.pbproj/project.pbxproj b/camino/Chimera.pbproj/project.pbxproj index e13bcd17fb0..02df7c97777 100644 --- a/camino/Chimera.pbproj/project.pbxproj +++ b/camino/Chimera.pbproj/project.pbxproj @@ -1940,12 +1940,12 @@ }; F568C3CF023A4A5A010001CA = { isa = PBXFileReference; - path = AboutBox.h; + path = CHAboutBox.h; refType = 4; }; F568C3D0023A4A5A010001CA = { isa = PBXFileReference; - path = AboutBox.m; + path = CHAboutBox.m; refType = 4; }; F568C3D1023A4A5B010001CA = { diff --git a/camino/English.lproj/AboutBox.nib/classes.nib b/camino/English.lproj/AboutBox.nib/classes.nib new file mode 100644 index 00000000000..b87e9575942 --- /dev/null +++ b/camino/English.lproj/AboutBox.nib/classes.nib @@ -0,0 +1,13 @@ +{ + IBClasses = ( + { + ACTIONS = {showPanel = id; }; + CLASS = AboutBox; + LANGUAGE = ObjC; + OUTLETS = {creditsField = id; window = id; }; + SUPERCLASS = NSObject; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/camino/English.lproj/AboutBox.nib/info.nib b/camino/English.lproj/AboutBox.nib/info.nib new file mode 100644 index 00000000000..386fb2eb4ec --- /dev/null +++ b/camino/English.lproj/AboutBox.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 248.0 + IBLockedObjects + + 7 + + IBOpenObjects + + 5 + + IBSystem Version + 5Q45 + + diff --git a/camino/English.lproj/AboutBox.nib/objects.nib b/camino/English.lproj/AboutBox.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..c6baa8e57f47d50d0cb11340a91f1a474c370e70 GIT binary patch literal 1466 zcmZux&2Jk;6o2E7G#^gWmbM4Pfg6gDIP_4VTyWwlB8P4e8<7J-XuTds18c9fUgPAJ zacAd>v~m`26jY&d!m`vl7vKQMpei>&PziBDoGShTF0{NiYp1AUt^M$OZ+>rn@BQ8s zmcoM;ueHN~I}MqCtXNqob<4-BqQQEcc`|PJV+6aPdHJm+8m@g`|VA&PF83w+$dK{-IoJ3KC zQ6!LM)WIstJXYV+TBl@X= zaNRO6ggW0rg?k>dLVonMjujE22kZ%eDiAFUy@WnfHRSDg0++A$6U>gB30G9XEYh%D8MJ!?lPqfItb{vn;`(5Tmnx?Tk zd_Uabjh5$xT(XD8M$t3dYsc~Zw08w?6>cFy;_%PS>>1zB$Wy_PB_V0FATAQ9_@0kl z9L}jcam5JxpdIoCaass5)C6etu^*S(Z7$MFk_Ul?deMuGHz45yH-W;aBiuaSJ z@FsBZ;3Is7AixDjv3h9;Lq@kwAttmjV|rY^IhO2t4+hC$92tKWHI2o1FeNoaB>X&k z$0HC^fSvmQK@*F3WsBItb80tQk8yU5bazFw=AR2i zvcLOkSqOtc`YyZqoP@DczZkmkJV;yLJJUw<^if}V5R<^F>+%0FM@ z9^b=>B2hnjaAdH%rd(4Cr7yVwuZgg|DY#eD=!ntD=V*g~@1Xa$1`F ix;Xi5dGh + + + + IBFramework Version + 248.0 + IBLockedObjects + + 7 + + IBOpenObjects + + 5 + + IBSystem Version + 5Q45 + + diff --git a/camino/resources/localized/English.lproj/AboutBox.nib/objects.nib b/camino/resources/localized/English.lproj/AboutBox.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..c6baa8e57f47d50d0cb11340a91f1a474c370e70 GIT binary patch literal 1466 zcmZux&2Jk;6o2E7G#^gWmbM4Pfg6gDIP_4VTyWwlB8P4e8<7J-XuTds18c9fUgPAJ zacAd>v~m`26jY&d!m`vl7vKQMpei>&PziBDoGShTF0{NiYp1AUt^M$OZ+>rn@BQ8s zmcoM;ueHN~I}MqCtXNqob<4-BqQQEcc`|PJV+6aPdHJm+8m@g`|VA&PF83w+$dK{-IoJ3KC zQ6!LM)WIstJXYV+TBl@X= zaNRO6ggW0rg?k>dLVonMjujE22kZ%eDiAFUy@WnfHRSDg0++A$6U>gB30G9XEYh%D8MJ!?lPqfItb{vn;`(5Tmnx?Tk zd_Uabjh5$xT(XD8M$t3dYsc~Zw08w?6>cFy;_%PS>>1zB$Wy_PB_V0FATAQ9_@0kl z9L}jcam5JxpdIoCaass5)C6etu^*S(Z7$MFk_Ul?deMuGHz45yH-W;aBiuaSJ z@FsBZ;3Is7AixDjv3h9;Lq@kwAttmjV|rY^IhO2t4+hC$92tKWHI2o1FeNoaB>X&k z$0HC^fSvmQK@*F3WsBItb80tQk8yU5bazFw=AR2i zvcLOkSqOtc`YyZqoP@DczZkmkJV;yLJJUw<^if}V5R<^F>+%0FM@ z9^b=>B2hnjaAdH%rd(4Cr7yVwuZgg|DY#eD=!ntD=V*g~@1Xa$1`F ix;Xi5dGh + +@interface CHAboutBox : NSObject +{ + IBOutlet id creditsField; + IBOutlet id window; + NSTimer *scrollTimer; + float currentPosition; + float maxScrollHeight; + NSTimeInterval startTime; + BOOL restartAtTop; +} + ++ (CHAboutBox *)sharedInstance; +- (IBAction)showPanel:(id)sender; + +@end diff --git a/camino/src/application/AboutBox.m b/camino/src/application/AboutBox.m new file mode 100644 index 00000000000..6730a7b8314 --- /dev/null +++ b/camino/src/application/AboutBox.m @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +* +* The contents of this file are subject to the Mozilla Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/MPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is the Mozilla browser. +* +* The Initial Developer of the Original Code is Matt Judy. +* +* Contributor(s): +* Matt Judy (Original Author) +* David Hyatt +*/ + +#import "CHAboutBox.h" + +@implementation CHAboutBox + +static CHAboutBox *sharedInstance = nil; + ++ (CHAboutBox *)sharedInstance +{ + return sharedInstance ? sharedInstance : [[self alloc] init]; +} + +- (id)init +{ + if (sharedInstance) { + [self dealloc]; + } else { + sharedInstance = [super init]; + } + return sharedInstance; +} + +- (IBAction)showPanel:(id)sender +{ + if (!creditsField) { + NSString *creditsPath; + NSAttributedString *creditsString; + float fieldHeight; + float containerHeight; + + if (![NSBundle loadNibNamed:@"CHAboutBox" owner:self]) { + NSLog( @"Failed to load CHAboutBox.nib" ); + NSBeep(); + return; + } + + [window setTitle:@"About Navigator"]; + + creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; + creditsString = [[NSAttributedString alloc] initWithPath:creditsPath documentAttributes:nil]; + [creditsField replaceCharactersInRange:NSMakeRange( 0, 0 ) + withRTF:[creditsString RTFFromRange: + NSMakeRange( 0, [creditsString length] ) + documentAttributes:nil]]; + + fieldHeight = [creditsField frame].size.height; + + (void)[[creditsField layoutManager] glyphRangeForTextContainer:[creditsField textContainer]]; + containerHeight = [[creditsField layoutManager] usedRectForTextContainer: + [creditsField textContainer]].size.height; + maxScrollHeight = containerHeight - fieldHeight; + + [window setExcludedFromWindowsMenu:YES]; + [window setMenu:nil]; + [window center]; + } + + if (![window isVisible]) { + currentPosition = 0; + restartAtTop = NO; + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + } + + [window makeKeyAndOrderFront:nil]; +} + +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1/4 + target:self + selector:@selector(scrollCredits:) + userInfo:nil + repeats:YES]; +} + +- (void)windowDidResignKey:(NSNotification *)notification +{ + [scrollTimer invalidate]; +} + +- (void)scrollCredits:(NSTimer *)timer +{ + if ([NSDate timeIntervalSinceReferenceDate] >= startTime) { + + if (restartAtTop) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + restartAtTop = NO; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + return; + } + + if (currentPosition >= maxScrollHeight) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + currentPosition = 0; + restartAtTop = YES; + } else { + [creditsField scrollPoint:NSMakePoint( 0, currentPosition )]; + currentPosition += 0.01; + } + } +} + +@end diff --git a/chimera/AboutBox.nib/classes.nib b/chimera/AboutBox.nib/classes.nib new file mode 100644 index 00000000000..b87e9575942 --- /dev/null +++ b/chimera/AboutBox.nib/classes.nib @@ -0,0 +1,13 @@ +{ + IBClasses = ( + { + ACTIONS = {showPanel = id; }; + CLASS = AboutBox; + LANGUAGE = ObjC; + OUTLETS = {creditsField = id; window = id; }; + SUPERCLASS = NSObject; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/chimera/AboutBox.nib/info.nib b/chimera/AboutBox.nib/info.nib new file mode 100644 index 00000000000..386fb2eb4ec --- /dev/null +++ b/chimera/AboutBox.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 248.0 + IBLockedObjects + + 7 + + IBOpenObjects + + 5 + + IBSystem Version + 5Q45 + + diff --git a/chimera/AboutBox.nib/objects.nib b/chimera/AboutBox.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..c6baa8e57f47d50d0cb11340a91f1a474c370e70 GIT binary patch literal 1466 zcmZux&2Jk;6o2E7G#^gWmbM4Pfg6gDIP_4VTyWwlB8P4e8<7J-XuTds18c9fUgPAJ zacAd>v~m`26jY&d!m`vl7vKQMpei>&PziBDoGShTF0{NiYp1AUt^M$OZ+>rn@BQ8s zmcoM;ueHN~I}MqCtXNqob<4-BqQQEcc`|PJV+6aPdHJm+8m@g`|VA&PF83w+$dK{-IoJ3KC zQ6!LM)WIstJXYV+TBl@X= zaNRO6ggW0rg?k>dLVonMjujE22kZ%eDiAFUy@WnfHRSDg0++A$6U>gB30G9XEYh%D8MJ!?lPqfItb{vn;`(5Tmnx?Tk zd_Uabjh5$xT(XD8M$t3dYsc~Zw08w?6>cFy;_%PS>>1zB$Wy_PB_V0FATAQ9_@0kl z9L}jcam5JxpdIoCaass5)C6etu^*S(Z7$MFk_Ul?deMuGHz45yH-W;aBiuaSJ z@FsBZ;3Is7AixDjv3h9;Lq@kwAttmjV|rY^IhO2t4+hC$92tKWHI2o1FeNoaB>X&k z$0HC^fSvmQK@*F3WsBItb80tQk8yU5bazFw=AR2i zvcLOkSqOtc`YyZqoP@DczZkmkJV;yLJJUw<^if}V5R<^F>+%0FM@ z9^b=>B2hnjaAdH%rd(4Cr7yVwuZgg|DY#eD=!ntD=V*g~@1Xa$1`F ix;Xi5dGh + +@interface CHAboutBox : NSObject +{ + IBOutlet id creditsField; + IBOutlet id window; + NSTimer *scrollTimer; + float currentPosition; + float maxScrollHeight; + NSTimeInterval startTime; + BOOL restartAtTop; +} + ++ (CHAboutBox *)sharedInstance; +- (IBAction)showPanel:(id)sender; + +@end diff --git a/chimera/CHAboutBox.m b/chimera/CHAboutBox.m new file mode 100644 index 00000000000..6730a7b8314 --- /dev/null +++ b/chimera/CHAboutBox.m @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +* +* The contents of this file are subject to the Mozilla Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/MPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is the Mozilla browser. +* +* The Initial Developer of the Original Code is Matt Judy. +* +* Contributor(s): +* Matt Judy (Original Author) +* David Hyatt +*/ + +#import "CHAboutBox.h" + +@implementation CHAboutBox + +static CHAboutBox *sharedInstance = nil; + ++ (CHAboutBox *)sharedInstance +{ + return sharedInstance ? sharedInstance : [[self alloc] init]; +} + +- (id)init +{ + if (sharedInstance) { + [self dealloc]; + } else { + sharedInstance = [super init]; + } + return sharedInstance; +} + +- (IBAction)showPanel:(id)sender +{ + if (!creditsField) { + NSString *creditsPath; + NSAttributedString *creditsString; + float fieldHeight; + float containerHeight; + + if (![NSBundle loadNibNamed:@"CHAboutBox" owner:self]) { + NSLog( @"Failed to load CHAboutBox.nib" ); + NSBeep(); + return; + } + + [window setTitle:@"About Navigator"]; + + creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; + creditsString = [[NSAttributedString alloc] initWithPath:creditsPath documentAttributes:nil]; + [creditsField replaceCharactersInRange:NSMakeRange( 0, 0 ) + withRTF:[creditsString RTFFromRange: + NSMakeRange( 0, [creditsString length] ) + documentAttributes:nil]]; + + fieldHeight = [creditsField frame].size.height; + + (void)[[creditsField layoutManager] glyphRangeForTextContainer:[creditsField textContainer]]; + containerHeight = [[creditsField layoutManager] usedRectForTextContainer: + [creditsField textContainer]].size.height; + maxScrollHeight = containerHeight - fieldHeight; + + [window setExcludedFromWindowsMenu:YES]; + [window setMenu:nil]; + [window center]; + } + + if (![window isVisible]) { + currentPosition = 0; + restartAtTop = NO; + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + } + + [window makeKeyAndOrderFront:nil]; +} + +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1/4 + target:self + selector:@selector(scrollCredits:) + userInfo:nil + repeats:YES]; +} + +- (void)windowDidResignKey:(NSNotification *)notification +{ + [scrollTimer invalidate]; +} + +- (void)scrollCredits:(NSTimer *)timer +{ + if ([NSDate timeIntervalSinceReferenceDate] >= startTime) { + + if (restartAtTop) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + restartAtTop = NO; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + return; + } + + if (currentPosition >= maxScrollHeight) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + currentPosition = 0; + restartAtTop = YES; + } else { + [creditsField scrollPoint:NSMakePoint( 0, currentPosition )]; + currentPosition += 0.01; + } + } +} + +@end diff --git a/chimera/Chimera.pbproj/project.pbxproj b/chimera/Chimera.pbproj/project.pbxproj index e13bcd17fb0..02df7c97777 100644 --- a/chimera/Chimera.pbproj/project.pbxproj +++ b/chimera/Chimera.pbproj/project.pbxproj @@ -1940,12 +1940,12 @@ }; F568C3CF023A4A5A010001CA = { isa = PBXFileReference; - path = AboutBox.h; + path = CHAboutBox.h; refType = 4; }; F568C3D0023A4A5A010001CA = { isa = PBXFileReference; - path = AboutBox.m; + path = CHAboutBox.m; refType = 4; }; F568C3D1023A4A5B010001CA = { diff --git a/chimera/English.lproj/AboutBox.nib/classes.nib b/chimera/English.lproj/AboutBox.nib/classes.nib new file mode 100644 index 00000000000..b87e9575942 --- /dev/null +++ b/chimera/English.lproj/AboutBox.nib/classes.nib @@ -0,0 +1,13 @@ +{ + IBClasses = ( + { + ACTIONS = {showPanel = id; }; + CLASS = AboutBox; + LANGUAGE = ObjC; + OUTLETS = {creditsField = id; window = id; }; + SUPERCLASS = NSObject; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/chimera/English.lproj/AboutBox.nib/info.nib b/chimera/English.lproj/AboutBox.nib/info.nib new file mode 100644 index 00000000000..386fb2eb4ec --- /dev/null +++ b/chimera/English.lproj/AboutBox.nib/info.nib @@ -0,0 +1,18 @@ + + + + + IBFramework Version + 248.0 + IBLockedObjects + + 7 + + IBOpenObjects + + 5 + + IBSystem Version + 5Q45 + + diff --git a/chimera/English.lproj/AboutBox.nib/objects.nib b/chimera/English.lproj/AboutBox.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..c6baa8e57f47d50d0cb11340a91f1a474c370e70 GIT binary patch literal 1466 zcmZux&2Jk;6o2E7G#^gWmbM4Pfg6gDIP_4VTyWwlB8P4e8<7J-XuTds18c9fUgPAJ zacAd>v~m`26jY&d!m`vl7vKQMpei>&PziBDoGShTF0{NiYp1AUt^M$OZ+>rn@BQ8s zmcoM;ueHN~I}MqCtXNqob<4-BqQQEcc`|PJV+6aPdHJm+8m@g`|VA&PF83w+$dK{-IoJ3KC zQ6!LM)WIstJXYV+TBl@X= zaNRO6ggW0rg?k>dLVonMjujE22kZ%eDiAFUy@WnfHRSDg0++A$6U>gB30G9XEYh%D8MJ!?lPqfItb{vn;`(5Tmnx?Tk zd_Uabjh5$xT(XD8M$t3dYsc~Zw08w?6>cFy;_%PS>>1zB$Wy_PB_V0FATAQ9_@0kl z9L}jcam5JxpdIoCaass5)C6etu^*S(Z7$MFk_Ul?deMuGHz45yH-W;aBiuaSJ z@FsBZ;3Is7AixDjv3h9;Lq@kwAttmjV|rY^IhO2t4+hC$92tKWHI2o1FeNoaB>X&k z$0HC^fSvmQK@*F3WsBItb80tQk8yU5bazFw=AR2i zvcLOkSqOtc`YyZqoP@DczZkmkJV;yLJJUw<^if}V5R<^F>+%0FM@ z9^b=>B2hnjaAdH%rd(4Cr7yVwuZgg|DY#eD=!ntD=V*g~@1Xa$1`F ix;Xi5dGh + + + + IBFramework Version + 248.0 + IBLockedObjects + + 7 + + IBOpenObjects + + 5 + + IBSystem Version + 5Q45 + + diff --git a/chimera/resources/localized/English.lproj/AboutBox.nib/objects.nib b/chimera/resources/localized/English.lproj/AboutBox.nib/objects.nib new file mode 100644 index 0000000000000000000000000000000000000000..c6baa8e57f47d50d0cb11340a91f1a474c370e70 GIT binary patch literal 1466 zcmZux&2Jk;6o2E7G#^gWmbM4Pfg6gDIP_4VTyWwlB8P4e8<7J-XuTds18c9fUgPAJ zacAd>v~m`26jY&d!m`vl7vKQMpei>&PziBDoGShTF0{NiYp1AUt^M$OZ+>rn@BQ8s zmcoM;ueHN~I}MqCtXNqob<4-BqQQEcc`|PJV+6aPdHJm+8m@g`|VA&PF83w+$dK{-IoJ3KC zQ6!LM)WIstJXYV+TBl@X= zaNRO6ggW0rg?k>dLVonMjujE22kZ%eDiAFUy@WnfHRSDg0++A$6U>gB30G9XEYh%D8MJ!?lPqfItb{vn;`(5Tmnx?Tk zd_Uabjh5$xT(XD8M$t3dYsc~Zw08w?6>cFy;_%PS>>1zB$Wy_PB_V0FATAQ9_@0kl z9L}jcam5JxpdIoCaass5)C6etu^*S(Z7$MFk_Ul?deMuGHz45yH-W;aBiuaSJ z@FsBZ;3Is7AixDjv3h9;Lq@kwAttmjV|rY^IhO2t4+hC$92tKWHI2o1FeNoaB>X&k z$0HC^fSvmQK@*F3WsBItb80tQk8yU5bazFw=AR2i zvcLOkSqOtc`YyZqoP@DczZkmkJV;yLJJUw<^if}V5R<^F>+%0FM@ z9^b=>B2hnjaAdH%rd(4Cr7yVwuZgg|DY#eD=!ntD=V*g~@1Xa$1`F ix;Xi5dGh + +@interface CHAboutBox : NSObject +{ + IBOutlet id creditsField; + IBOutlet id window; + NSTimer *scrollTimer; + float currentPosition; + float maxScrollHeight; + NSTimeInterval startTime; + BOOL restartAtTop; +} + ++ (CHAboutBox *)sharedInstance; +- (IBAction)showPanel:(id)sender; + +@end diff --git a/chimera/src/application/AboutBox.m b/chimera/src/application/AboutBox.m new file mode 100644 index 00000000000..6730a7b8314 --- /dev/null +++ b/chimera/src/application/AboutBox.m @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +* +* The contents of this file are subject to the Mozilla Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/MPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is the Mozilla browser. +* +* The Initial Developer of the Original Code is Matt Judy. +* +* Contributor(s): +* Matt Judy (Original Author) +* David Hyatt +*/ + +#import "CHAboutBox.h" + +@implementation CHAboutBox + +static CHAboutBox *sharedInstance = nil; + ++ (CHAboutBox *)sharedInstance +{ + return sharedInstance ? sharedInstance : [[self alloc] init]; +} + +- (id)init +{ + if (sharedInstance) { + [self dealloc]; + } else { + sharedInstance = [super init]; + } + return sharedInstance; +} + +- (IBAction)showPanel:(id)sender +{ + if (!creditsField) { + NSString *creditsPath; + NSAttributedString *creditsString; + float fieldHeight; + float containerHeight; + + if (![NSBundle loadNibNamed:@"CHAboutBox" owner:self]) { + NSLog( @"Failed to load CHAboutBox.nib" ); + NSBeep(); + return; + } + + [window setTitle:@"About Navigator"]; + + creditsPath = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; + creditsString = [[NSAttributedString alloc] initWithPath:creditsPath documentAttributes:nil]; + [creditsField replaceCharactersInRange:NSMakeRange( 0, 0 ) + withRTF:[creditsString RTFFromRange: + NSMakeRange( 0, [creditsString length] ) + documentAttributes:nil]]; + + fieldHeight = [creditsField frame].size.height; + + (void)[[creditsField layoutManager] glyphRangeForTextContainer:[creditsField textContainer]]; + containerHeight = [[creditsField layoutManager] usedRectForTextContainer: + [creditsField textContainer]].size.height; + maxScrollHeight = containerHeight - fieldHeight; + + [window setExcludedFromWindowsMenu:YES]; + [window setMenu:nil]; + [window center]; + } + + if (![window isVisible]) { + currentPosition = 0; + restartAtTop = NO; + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + } + + [window makeKeyAndOrderFront:nil]; +} + +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1/4 + target:self + selector:@selector(scrollCredits:) + userInfo:nil + repeats:YES]; +} + +- (void)windowDidResignKey:(NSNotification *)notification +{ + [scrollTimer invalidate]; +} + +- (void)scrollCredits:(NSTimer *)timer +{ + if ([NSDate timeIntervalSinceReferenceDate] >= startTime) { + + if (restartAtTop) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + restartAtTop = NO; + [creditsField scrollPoint:NSMakePoint( 0, 0 )]; + return; + } + + if (currentPosition >= maxScrollHeight) { + startTime = [NSDate timeIntervalSinceReferenceDate] + 3.0; + currentPosition = 0; + restartAtTop = YES; + } else { + [creditsField scrollPoint:NSMakePoint( 0, currentPosition )]; + currentPosition += 0.01; + } + } +} + +@end