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

CDesktop.h

00001 /**********************************************************************
00002 Copyright (c) 2005, TomTom B.V.
00003 All rights reserved
00004 ***********************************************************************/
00005 
00007 // CDesktop.h: interface for the CDesktop class.
00008 //
00010 
00011 #ifndef __CDESKTOP_H__
00012 #define __CDESKTOP_H__
00013 
00014 #include <assert.h>
00015 
00016 #include "MFrameBuffer.h" 
00017 
00029 class CDesktop  
00030 {
00031  public:        
00032   typedef unsigned int TColor; 
00034  public:
00039   static TColor GetNearestColor( unsigned int aR, unsigned int aG, unsigned int aB );
00040 
00043   static void   PutPixel( MFrameBuffer& aFrameBuffer, unsigned int aX, unsigned int aY, TColor aColor );
00044 
00047   static TColor GetPixel( MFrameBuffer& aFrameBuffer, unsigned int aX, unsigned int aY );
00048 
00051   static void   HLine( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aY, unsigned int aXTo, TColor aColor );
00052 
00055   static void   VLine( MFrameBuffer& aFrameBuffer, unsigned int aX, unsigned int aYFrom, unsigned int aYTo, TColor aColor );
00056 
00061   static void   Line( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aYFrom, unsigned int aXTo,unsigned int aYTo, TColor aColor );
00062 
00065   static void   Rect( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aYFrom, unsigned int aXTo, unsigned int aYTo, TColor aColor);
00066 
00077   static void   RectFill( MFrameBuffer& aFrameBuffer, unsigned int aXFrom, unsigned int aYFrom, unsigned int aXTo, unsigned int aYTo, TColor aColor, unsigned int aRounding );
00078 
00080 
00081   static const TColor ColorBlack;
00082   static const TColor ColorWhite;
00083   static const TColor ColorLightGray;
00084   static const TColor ColorDarkGray;
00085   static const TColor ColorYellow;
00086   static const TColor ColorVeryLightBlue;
00087   static const TColor ColorLightBlue;
00088   static const TColor ColorCyan;
00089   static const TColor ColorRed;
00090   static const TColor ColorGreen;
00091   static const TColor ColorBrown;
00092   static const TColor ColorLightGreen;
00093   static const TColor ColorBlue;
00094   static const TColor ColorPink;
00095   static const TColor ColorDarkPink;
00096   static const TColor ColorOrange;
00098 
00099  private:
00100   CDesktop();
00101   CDesktop( const CDesktop& );
00102   CDesktop& operator=( CDesktop& );
00103 
00104  private:
00105   static char* GetPixelAddress( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY );
00106 };
00107 
00108 
00109 inline char* CDesktop::GetPixelAddress( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY )
00110 {
00111 /* assert( aX < aFrameBuffer.GetWidth() );
00112   assert( aY < aFrameBuffer.GetHeight() );
00113 */
00114  return aFrameBuffer.GetScreenBuffer() + aFrameBuffer.GetPixelAddressOffset( aX, aY );
00115 }
00116 
00117 inline void CDesktop::PutPixel( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY, CDesktop::TColor aColor )
00118 {
00119   /* assert( aX < aFrameBuffer.GetWidth() );
00120      assert( aY < aFrameBuffer.GetHeight() );
00121      assert( aFrameBuffer.GetBitsPerPixel() == 16 ); // Currently only support for 16 bpp
00122    */
00123   if (aX < aFrameBuffer.GetWidth() && aY < aFrameBuffer.GetHeight() )
00124   {
00125     *reinterpret_cast< unsigned short *>( GetPixelAddress( aFrameBuffer, aX, aY ) ) =
00126       static_cast< unsigned short >( aColor ); 
00127   }
00128 }
00129 
00130 
00131 inline CDesktop::TColor CDesktop::GetPixel( MFrameBuffer& aFrameBuffer, unsigned int aX,unsigned int aY )
00132 {
00133 /* assert( aX < aFrameBuffer.GetWidth() );
00134  assert( aY < aFrameBuffer.GetHeight() );
00135  assert( aFrameBuffer.GetBitsPerPixel() == 16 ); // Currently only support for 16 bpp
00136 */
00137  return 
00138   *reinterpret_cast< unsigned short *>( GetPixelAddress( aFrameBuffer, aX, aY ) );
00139 }
00140 
00141 
00142 inline CDesktop::TColor CDesktop::GetNearestColor( unsigned int aR, unsigned int aG, unsigned int aB )
00143 {
00144  // Currently only support for 16 bpp
00145  //return ( ( TColor )( ( ( aB ) >> 3 ) + ( ( ( aG ) >> 2) * 32 ) + ( ( ( aR ) >> 3 ) * 2048 ) ) );
00146  return ( ( aR & 0xF8 ) << 8 ) | 
00147             ( ( aG & 0xFC ) << 3 ) |
00148                 ( ( aB & 0xF8 ) >> 3 );
00149 }
00150 
00151 #endif // __CDESKTOP_H__

Generated on Mon Dec 18 18:57:25 2006 for TomTom GO User Interface library by doxygen 1.3.5