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

CDesktop.h

00001 /**********************************************************************
00002 
00003 Copyright (c) 2005, TomTom B.V.
00004 
00005 All rights reserved
00006 
00007 
00008 ***********************************************************************/
00009 
00011 // CDesktop.h: interface for the CDesktop class.
00012 //
00014 
00015 #ifndef __CDESKTOP_H__
00016 #define __CDESKTOP_H__
00017 
00018 #include <assert.h>
00019 
00020 #include "MFrameBuffer.h" 
00021 
00035 class CDesktop  
00036 {
00037  public:        
00038   typedef unsigned int TColor; 
00040  public:
00047   static TColor GetNearestColor( unsigned int aR, unsigned int aG, unsigned int aB );
00048 
00051   static void   PutPixel( MFrameBuffer& aFrameBuffer, unsigned int aX, unsigned int aY, TColor aColor );
00052 
00055   static TColor GetPixel( MFrameBuffer& aFrameBuffer, unsigned int aX, unsigned int aY );
00056 
00059   static void   HLine( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aY, unsigned int aXTo, TColor aColor );
00060 
00063   static void   VLine( MFrameBuffer& aFrameBuffer, unsigned int aX, unsigned int aYFrom, unsigned int aYTo, TColor aColor );
00064 
00070   static void   Line( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aYFrom, unsigned int aXTo,unsigned int aYTo, TColor aColor );
00071 
00074   static void   Rect( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aYFrom, unsigned int aXTo, unsigned int aYTo, TColor aColor);
00075 
00087   static void   RectFill( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aYFrom, unsigned int aXTo, unsigned int aYTo, TColor aColor, unsigned int aRounding );
00088 
00089 
00091 
00092   static const TColor ColorBlack;
00093   static const TColor ColorWhite;
00094   static const TColor ColorLightGray;
00095   static const TColor ColorDarkGray;
00096   static const TColor ColorYellow;
00097   static const TColor ColorVeryLightBlue;
00098   static const TColor ColorLightBlue;
00099   static const TColor ColorCyan;
00100   static const TColor ColorRed;
00101   static const TColor ColorGreen;
00102   static const TColor ColorBrown;
00103   static const TColor ColorLightGreen;
00104   static const TColor ColorBlue;
00105   static const TColor ColorPink;
00106   static const TColor ColorDarkPink;
00107   static const TColor ColorOrange;
00109   
00110  private:
00111   CDesktop();
00112   CDesktop( const CDesktop& );
00113   CDesktop& operator=( CDesktop& );
00114 
00115  private:
00116   static char* GetPixelAddress( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY );
00117 };
00118 
00119 inline char* CDesktop::GetPixelAddress( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY )
00120 {
00121 /* assert( aX < aFrameBuffer.GetWidth() );
00122  assert( aY < aFrameBuffer.GetHeight() );
00123 */
00124     
00125  return aFrameBuffer.GetScreenBuffer() + aFrameBuffer.GetPixelAddressOffset( aX, aY );
00126 }
00127 
00128 inline void CDesktop::PutPixel( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY, CDesktop::TColor aColor )
00129 {
00130 /* assert( aX < aFrameBuffer.GetWidth() );
00131  assert( aY < aFrameBuffer.GetHeight() );
00132  assert( aFrameBuffer.GetBitsPerPixel() == 16 ); // Currently only support for 16 bpp
00133 */
00134  *reinterpret_cast< unsigned short *>( GetPixelAddress( aFrameBuffer, aX, aY ) ) =
00135    static_cast< unsigned short >( aColor ); 
00136 }
00137 
00138 inline CDesktop::TColor CDesktop::GetPixel( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY )
00139 {
00140 /* assert( aX < aFrameBuffer.GetWidth() );
00141  assert( aY < aFrameBuffer.GetHeight() );
00142  assert( aFrameBuffer.GetBitsPerPixel() == 16 ); // Currently only support for 16 bpp
00143 */
00144  return 
00145   *reinterpret_cast< unsigned short *>( GetPixelAddress( aFrameBuffer, aX, aY ) );
00146 }
00147 
00148 inline CDesktop::TColor CDesktop::GetNearestColor( unsigned int aR, unsigned int aG, unsigned int aB )
00149 {
00150  // Currently only support for 16 bpp
00151 
00152  //return ( ( TColor )( ( ( aB ) >> 3 ) + ( ( ( aG ) >> 2) * 32 ) + ( ( ( aR ) >> 3 ) * 2048 ) ) );
00153  
00154  return ( ( aR & 0xF8 ) << 8 ) | 
00155             ( ( aG & 0xFC ) << 3 ) |
00156                 ( ( aB & 0xF8 ) >> 3 );
00157 }
00158 
00159 
00160 #endif // __CDESKTOP_H__

Generated on Fri Jul 15 16:46:44 2005 for TomTom GO User Interface library by doxygen 1.3.5