Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CAUGuiPoof.cpp

Go to the documentation of this file.
00001 /*
00002  *  CAUGuiPoof.cpp
00003  *  RumblenceAU
00004  *
00005  *  Created by Urs Heckmann on Mon Oct 28 2002.
00006  *  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
00007  *
00008  */
00009 
00010 #include "CAUGuiPoof.h"
00011 
00012 #define POOF_ICON_WIDTH             42.0
00013 #define POOF_ICON_HEIGHT            52.0
00014 #define POOF_ANIMATION_DELAY        (1.0 / 15.0)
00015 #define NUMBER_OF_POOF_ANIM_FRAMES  5
00016 
00017 
00018 PoofButton::PoofButton (
00019                                 CAUGuiMan*          theChief,
00020                                 CAAUParameter       &theAuvp, 
00021                                 eRect*              theWhere,
00022                                 CAUGuiGraphic*      theForeGround, 
00023                                 CAUGuiGraphic*      theBackground,
00024                                 CAUGuiBottonMode    theMode,
00025                                 CAUGuiGraphic*      poof )
00026                                 
00027                             :   CAUGuiButton (  theChief,
00028                                                 theAuvp, 
00029                                                 theWhere,
00030                                                 theForeGround, 
00031                                                 theBackground,
00032                                                 theMode)
00033 {
00034     thePoof = poof;
00035     poofWindow = NULL;
00036     frame = 0;
00037     box.origin.x = box.origin.y = 0;
00038     box.size.width = CGImageGetWidth( poof->getImage() );
00039     box.size.height = CGImageGetHeight( poof->getImage() );
00040 
00041 }
00042 
00043 
00044 PoofButton::~PoofButton ()
00045 {
00046     thePoof = NULL;
00047     poofWindow = NULL;
00048 }
00049     
00050 
00051 void PoofButton::mouseDown(Point *P, bool with_option, bool with_shift)
00052 {
00053     poofPoint.v = P->v + getBounds()->x;
00054     poofPoint.h = P->h + getBounds()->y;
00055 
00056     
00057 
00058     CAUGuiButton::mouseDown( P, with_option, with_shift);
00059     
00060     if ( poofWindow == NULL )
00061     {
00062         frame = 0;
00063             
00064         float windowWidth = CGImageGetWidth( thePoof->getImage() ) ;
00065         float windowHeight = CGImageGetHeight( thePoof->getImage() ) / 5.0;
00066     
00067         Rect bounds;
00068 
00069         bounds.top = poofPoint.v - (SInt16)(windowHeight / 2);
00070         bounds.left = poofPoint.h - (SInt16)(windowWidth / 2);
00071         bounds.bottom = bounds.top + (SInt16)windowHeight;
00072         bounds.right = bounds.left + (SInt16)windowWidth;
00073     
00074         CreateNewWindow( kOverlayWindowClass, 0, &bounds, &poofWindow );
00075         ShowWindow( poofWindow );
00076     }
00077 }
00078 
00079 
00080 void PoofButton::mouseUp(Point *P, bool with_option, bool with_shift)
00081 {
00082     CAUGuiButton::mouseUp( P, with_option, with_shift);
00083     
00084     
00085     
00086 }
00087 
00088 
00089 void PoofButton::idle()
00090 {
00091     if ( poofWindow != NULL )
00092     {
00093         
00094         CGContextRef context;
00095         
00096         float windowHeight = CGImageGetHeight( thePoof->getImage() ) / 5.0;
00097                 
00098         box.origin.y = windowHeight * ( -4 + frame);
00099         
00100         CreateCGContextForPort( GetWindowPort( poofWindow ), &context );
00101         
00102         CGContextClearRect( context, box );
00103         CGContextDrawImage( context, box, thePoof->getImage() );
00104         CGContextFlush( context );
00105     
00106         CGContextRelease( context );
00107         
00108         frame++;
00109         
00110         if ( frame == 5 )
00111         {
00112             frame = 0;
00113             DisposeWindow( poofWindow );
00114             poofWindow = NULL;
00115         }
00116     }
00117     
00118     CAUGuiButton::idle();
00119 
00120 }
00121 

(c) 2002 - 2003 by Urs Heckmann www.u-he.com
Generated on Thu May 6 15:13:14 2004 for CAUGui by doxygen 1.3.6