SDL++
C++wrapperfortheSDLlibrary.

misc/Color.h

Go to the documentation of this file.
00001 
00021 #ifndef SDL_MISC_COLOR_H
00022 #define SDL_MISC_COLOR_H
00023 
00024 #include <boost/shared_ptr.hpp>
00025 
00026 #include <SDL.h>
00027 
00028 namespace sdl {
00029 namespace misc {
00034     class Color {
00035         public:
00041             Color (SDL_Color* c) : color_ (c) {};
00042 
00051             Color (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
00052                 : color_ (new SDL_Color ()) {
00053                 color_->r = red;
00054                 color_->g = green;
00055                 color_->b = blue;
00056                 color_->unused = alpha;
00057             };
00058 
00059             /*
00060              * Return the underlying SDL_Color structure.
00061              *
00062              * @return The SDL_Color structure.
00063              */
00064             SDL_Color* operator* () const { 
00065                 return color_.get (); 
00066             };
00067 
00073             unsigned char red () const { 
00074                 return color_->r; 
00075             };
00076 
00084             Color& red (unsigned char r) {
00085                 color_->r = r;
00086                 return *this; 
00087             };
00088 
00094             unsigned char green () const { 
00095                 return color_->g; 
00096             };
00097 
00105             Color& green (unsigned char g) { 
00106                 color_->g = g;
00107                 return *this; 
00108             };
00109 
00115             unsigned char blue () const { 
00116                 return color_->b; 
00117             };
00118 
00126             Color& blue (unsigned char b) { 
00127                 color_->b = b;
00128                 return *this; 
00129             };
00130 
00136             unsigned char alpha () const { 
00137                 return color_->unused; 
00138             };
00139 
00145             Color& alpha (unsigned char a) { 
00146                 color_->unused = a;
00147                 return *this; 
00148             };
00149 
00150         private:
00151             /*
00152              * The SDL_Color structure.
00153              */
00154             boost::shared_ptr<SDL_Color> color_;
00155     }; //Color
00156 }; //misc
00157 }; //sdl
00158 
00159 #endif //SDL_MISC_COLOR_H
00160 
 All Classes Namespaces Files Functions Variables Typedefs