00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
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
00122
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
00131
00132
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
00141
00142
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
00151
00152
00153
00154 return ( ( aR & 0xF8 ) << 8 ) |
00155 ( ( aG & 0xFC ) << 3 ) |
00156 ( ( aB & 0xF8 ) >> 3 );
00157 }
00158
00159
00160 #endif // __CDESKTOP_H__