00001 /* 00002 libwt - Vassilis Virvilis Toolkit - a widget library 00003 Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the 00017 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, SA. 00019 */ 00020 00021 #ifndef WT_SDLPALETTE_H 00022 #define WT_SDLPALETTE_H 00023 00024 #include <SDL/SDL_video.h> 00025 00026 #include "sdlcolor.h" 00027 00028 namespace Wt { 00029 00030 /*! 00031 \note SDLPalette encapsulates a pointer and not the direct struct 00032 as opposed to SDLRect, SDLColor. 00033 */ 00034 class SDLPalette { 00035 public: 00036 /// copy constructor 00037 SDLPalette(SDL_Palette* palette) 00038 : sdl_palette(palette) { 00039 assert(sizeof(SDLPalette) == sizeof(SDL_Palette*)); 00040 } 00041 00042 /// assign operator 00043 SDLPalette& operator=(SDL_Palette* palette) { 00044 sdl_palette = palette; 00045 return *this; 00046 } 00047 00048 //cast operators for automatic downcasting of our childs 00049 operator const SDL_Palette* () const { 00050 return sdl_palette; 00051 } 00052 00053 operator SDL_Palette* () { 00054 return sdl_palette; 00055 } 00056 00057 int size() const { 00058 return sdl_palette->ncolors; 00059 } 00060 00061 SDLColor operator[](int i) const { 00062 return sdl_palette->colors[i]; 00063 } 00064 00065 typedef enum { 00066 Logical = SDL_LOGPAL, 00067 Physical = SDL_PHYSPAL 00068 } Type; 00069 00070 private: 00071 /// private constructor 00072 SDLPalette() {} 00073 00074 SDL_Palette *sdl_palette; 00075 }; 00076 00077 } 00078 00079 #endif // WT_SDLPALETTE_H
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.