Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

guitheme.h

00001 /***************************************************************************
00002                           guitheme.h  -  description
00003                              -------------------
00004     begin                : Thu Aug 28 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GUI_THEME_H
00019 #define GUI_THEME_H
00020 
00021 #include "../constants.h"
00022 #include "widget.h"
00023 #include <map>
00024 
00025 using namespace std;
00026 
00027 class ShapePalette;
00028 
00033 class ThemeElement {
00034  public:
00035   char textureFileName[40], north[40], south[40], east[40], west[40];
00036   GLuint texture, tex_north, tex_south, tex_east, tex_west;
00037   Color color;
00038   int width;
00039 
00040   ThemeElement() {}
00041   ~ThemeElement() {}
00042 
00043   void loadTextures( ShapePalette *shapePal );
00044 };
00045 
00046 class GuiTheme {
00047 private:
00048   char *name;
00049   ThemeElement *windowBack;
00050   ThemeElement *windowTop;
00051   ThemeElement *windowBorder;
00052   Color *windowTitleText;
00053   Color *windowText;
00054   ThemeElement *buttonBackground;
00055   ThemeElement *buttonSelectionBackground;
00056   ThemeElement *buttonHighlight;
00057   ThemeElement *buttonBorder;
00058   Color *buttonText;
00059   Color *buttonSelectionText;
00060   ThemeElement *listBackground;
00061   ThemeElement *inputBackground;
00062   Color *inputText;
00063   ThemeElement *selectionBackground;
00064   Color *selectionText;
00065   ThemeElement *selectedBorder;
00066 
00067   static map<string, GuiTheme*> themes;
00068 
00069 public: 
00070   GuiTheme( char *name );
00071   ~GuiTheme();
00072 
00073   static const char *DEFAULT_THEME;
00074 
00075   static void initThemes( ShapePalette *shapePal );
00076   static inline GuiTheme *getThemeByName( const char *name ) { 
00077         string s = name; 
00078         if( themes.find( s ) != themes.end() ) return themes[ s ]; 
00079         else {
00080           cerr << "*** error: can't find theme: " << s << endl;
00081           return NULL; 
00082         }
00083   }
00084 
00085   inline ThemeElement *getWindowBackground() { return windowBack; }
00086   inline ThemeElement *getWindowTop() { return windowTop; }
00087   inline ThemeElement *getWindowBorder() { return windowBorder; }
00088   inline Color *getWindowTitleText() { return windowTitleText; }
00089   inline Color *getWindowText() { return windowText; }  
00090   inline ThemeElement *getButtonBackground() { return buttonBackground; }
00091   inline ThemeElement *getButtonSelectionBackground() { return buttonSelectionBackground; }
00092   inline ThemeElement *getButtonHighlight() { return buttonHighlight; }
00093   inline ThemeElement *getButtonBorder() { return buttonBorder; }
00094   inline Color *getButtonText() { return buttonText; }
00095   inline Color *getButtonSelectionText() { return buttonSelectionText; }
00096   inline ThemeElement *getListBackground() { return listBackground; }
00097   inline ThemeElement *getInputBackground() { return inputBackground; }
00098   inline Color *getInputText() { return inputText; }
00099   inline ThemeElement *getSelectionBackground() { return selectionBackground; }
00100   inline Color *getSelectionText() { return selectionText; }
00101   inline ThemeElement *getSelectedBorder() { return selectedBorder; }
00102 
00103  protected:
00104   static ThemeElement *parseElement( char *line );
00105   static Color *parseColor( char *line );
00106 
00107   void loadTextures( ShapePalette *shapePal );
00108   
00109   inline void setWindowBackground( ThemeElement *element ) { this->windowBack = element; }
00110   inline void setWindowTop( ThemeElement *element ) { this->windowTop = element; }
00111   inline void setWindowBorder( ThemeElement *element ) { this->windowBorder = element; }
00112   inline void setWindowTitleText( Color *color ) { this->windowTitleText = color; }
00113   inline void setWindowText( Color *color ) { this->windowText = color; }
00114   inline void setButtonBackground( ThemeElement *element ) { this->buttonBackground = element; }
00115   inline void setButtonSelectionBackground( ThemeElement *element ) { this->buttonSelectionBackground = element; }
00116   inline void setButtonHighlight( ThemeElement *element ) { this->buttonHighlight = element; }
00117   inline void setButtonBorder( ThemeElement *element ) { this->buttonBorder = element; }
00118   inline void setButtonText( Color *color ) { this->buttonText = color; }
00119   inline void setButtonSelectionText( Color *color ) { this->buttonSelectionText = color; }
00120   inline void setListBackground( ThemeElement *element ) { this->listBackground = element; }
00121   inline void setInputBackground( ThemeElement *element ) { this->inputBackground = element; }
00122   inline void setInputText( Color *color ) { this->inputText = color; }
00123   inline void setSelectionBackground( ThemeElement *element ) { selectionBackground = element; }
00124   inline void setSelectionText( Color *color ) { this->selectionText = color; }
00125   inline void setSelectedBorder( ThemeElement *element ) { selectedBorder = element; }  
00126 };
00127 
00128 #endif
00129 

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0