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

CAUGuiMeter.cpp

Go to the documentation of this file.
00001 /*
00002  *  CAUGuiDisplay.cpp
00003  *  CoreGraphics AudioUnit GUI framework
00004  *
00005  *  Created by Urs Heckmann on Sun Oct 27 2002.
00006  *  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
00007  *
00008  */
00009 
00010 #include "CAUGuiMeter.h"
00011 
00012 CAUGuiMeter::CAUGuiMeter (  CAUGuiMan*              theChief,
00013                             UInt32                  internalIndex, 
00014                             eRect*                  theWhere,
00015                             CAUGuiResolution        theRes, 
00016                             CAUGuiGraphic*          theForeGround, 
00017                             CAUGuiGraphic*          theBackground)
00018                         
00019                         :   CAUGuiCtrl ( theChief, theWhere, theRes )
00020                             
00021 {
00022         
00023     ForeGround = theForeGround;
00024     BackGround = theBackground;
00025     internalParamIndex = internalIndex;
00026     setType ( kCAUGui_Meter );
00027 
00028 }
00029 
00030 
00031 
00032 CAUGuiMeter::~CAUGuiMeter ()
00033 {
00034     ForeGround = NULL;
00035     BackGround = NULL;
00036 
00037 }
00038 
00039 void CAUGuiMeter::idle()
00040 {
00041     float fValue = Chief->getInternalParameter ( internalParamIndex );
00042     
00043     //printf ( "idling %d - %d - %f\n", (int)getID(), (int)internalParamIndex, fValue );
00044     
00045     if ( fValue > 1.f ) fValue = 1.f;
00046     if ( fValue < 0.f ) fValue = 0.f;
00047     
00048     ControlRef carbonControl = getCarbonControl();
00049     
00050     if ( carbonControl != NULL )
00051     {
00052         UInt32 max = GetControl32BitMaximum(carbonControl);
00053         UInt32 val = (UInt32)((float)max * fValue );
00054         SetControl32BitValue ( carbonControl, val );
00055     }
00056     
00057     //printf ( "idling %d\n", (int)getID() );
00058     
00059     CAUGuiCtrl::idle();
00060 }
00061 
00062 void CAUGuiMeter::draw(CGContextRef context, UInt32 portHeight )
00063 {
00064     ControlRef carbonControl = getCarbonControl();
00065     
00066     UInt32 max = GetControl32BitMaximum(carbonControl);
00067     UInt32 val = GetControl32BitValue( carbonControl );
00068 
00069     CGImageRef theBack = NULL;
00070     
00071     CGRect bounds;
00072     
00073     getBounds()->to( &bounds, portHeight );
00074     
00075     if ( BackGround != NULL )
00076         theBack = BackGround->getImage();
00077         
00078     if ( theBack != NULL )
00079         CGContextDrawImage( context, bounds, theBack );
00080     
00081     
00082     if ( ForeGround != NULL )
00083     {
00084         float valNorm = (float) val / (float) max;
00085         
00086         ForeGround->draw ( context, portHeight, getForeBounds(), valNorm );
00087         
00088     }
00089 }
00090 

(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