File:  [mozdev] / chimera / SplashScreenWindow.m
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Mar 10 07:36:38 2002 UTC (17 years, 8 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

    1: //
    2: //  SplashScreenWindow.m
    3: //  Chimera
    4: //
    5: //  Created by Matt L.  Judy on Sat Mar 09 2002.
    6: //  Copyright (c) 2001 __MyCompanyName__. All rights reserved.
    7: //
    8: 
    9: #import "SplashScreenWindow.h"
   10: 
   11: 
   12: @implementation SplashScreenWindow
   13: 
   14: -(id)splash;
   15: {
   16:     NSRect		 splashRect;
   17:     NSImageView *contentImageView;
   18:     
   19:     if ( ! [self splashImage] ) {
   20:         [self setSplashImage:[NSImage imageNamed:@"splash"]];
   21:     }
   22: 
   23:     splashRect		  = NSMakeRect(0, 0, [[self splashImage] size].width, [[self splashImage] size].height);
   24:     contentImageView  = [[NSImageView alloc] initWithFrame:splashRect];
   25: 
   26:     [self initWithContentRect:splashRect
   27:                     styleMask:NSBorderlessWindowMask
   28:                       backing:NSBackingStoreBuffered
   29:                         defer:NO];
   30:     
   31:     [contentImageView setImage:[self splashImage]];
   32:     [self setContentView:contentImageView];
   33:     [self setHasShadow:YES];
   34:     [self setReleasedWhenClosed:YES];
   35:     [self center];
   36:     
   37:     if ( [self fades] ) {
   38:         [self fadeIn];
   39:     } else {
   40:         [self makeKeyAndOrderFront:self];
   41:     }
   42: 
   43:     return self;
   44: }
   45: 
   46: -(BOOL)fades
   47: {
   48:     return _fades;
   49: }
   50: 
   51: -(void)setFades:(BOOL)fadeFlag;
   52: {
   53:     _fades = fadeFlag;
   54: }
   55: 
   56: -(NSImage *)splashImage
   57: {
   58:     return _splashImage;
   59: }
   60: 
   61: -(void)setSplashImage:(NSImage *)newImage;
   62: {
   63:     [_splashImage autorelease];
   64:     _splashImage = [newImage copy];
   65: }
   66: 
   67: -(void)fadeIn
   68: {
   69:     [self setAlphaValue:0.5];
   70:     [self makeKeyAndOrderFront:self];
   71: 
   72:     if (!_fadeTimer) {
   73:         _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:.10
   74:                                                       target:self
   75:                                                     selector:@selector(fadeStepUp:)
   76:                                                     userInfo:nil
   77:                                                      repeats:YES];
   78:     }
   79: }
   80: 
   81: -(void)fadeStepUp:(NSTimer *)aTimer
   82: {
   83:     NSLog(@"Fade up");
   84:     [self setAlphaValue:([self alphaValue] + 0.05)];
   85: 
   86:     if ( [self alphaValue] == 1.0 ) {
   87:         [_fadeTimer invalidate];
   88:     }
   89: }
   90: 
   91: -(void)fadeOut
   92: {
   93:     if (!_fadeTimer) {
   94:         _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:.10
   95:                                                       target:self
   96:                                                     selector:@selector(fadeStepDown:)
   97:                                                     userInfo:nil
   98:                                                      repeats:YES];
   99:     }
  100: }
  101: 
  102: -(void)fadeStepDown:(NSTimer *)aTimer
  103: {
  104:     [self setAlphaValue:([self alphaValue] - 0.05)];
  105: 
  106:     if ( [self alphaValue] == 0.0 ) {
  107:         [_fadeTimer invalidate];
  108:     }
  109: }
  110: 
  111: -(void)close
  112: {
  113:     if ( [self fades] ) {
  114:         [self fadeOut];
  115:     }
  116:     [super close];
  117: }
  118: 
  119: -(void)dealloc
  120: {
  121:     if (_splashImage) {
  122:         [_splashImage release];
  123:     }
  124:     [super dealloc];
  125: }
  126: 
  127: 
  128: @end

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>