- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

upalette.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/util/upalette.hpp 00008 begin : Fri Jun 11 2004 00009 $Id: upalette.hpp,v 1.6 2005/09/30 12:36:48 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UPALETTE_HPP 00029 #define UPALETTE_HPP 00030 00031 #include "../uobject.hpp" 00032 00033 #include "ucolor.hpp" 00034 00035 namespace ufo { 00036 00040 class UFO_EXPORT UPalette : public UObject { 00041 UFO_DECLARE_DYNAMIC_CLASS(UPalette) 00042 public: // Public types 00044 enum ColorGroup { 00045 Active, 00046 Inactive, 00047 Disabled, 00048 NColorGroupType 00049 }; 00051 enum ColorRole { 00053 Background, 00055 Foreground, 00057 Base , 00059 Text, 00062 Button, 00064 ButtonText, 00066 Light, 00068 MidLight, 00070 Dark, 00072 Mid, 00074 Highlight, 00076 HighlightedText, 00078 Link, 00080 LinkVisited, 00081 MaxColorRoles 00082 }; 00083 public: 00084 UPalette(); 00085 UPalette( 00086 const UColor & background, const UColor & foreground, 00087 const UColor & base, const UColor & text, 00088 const UColor & light, const UColor & midLight, 00089 const UColor & dark, const UColor & mid, 00090 const UColor & highlight, const UColor & highlightedText, 00091 const UColor & button, const UColor & buttonText, 00092 const UColor & link, const UColor & linkVisited 00093 ); 00094 UPalette( 00095 const UColor & background, const UColor & foreground, 00096 const UColor & base, const UColor & text, 00097 const UColor & highlight, const UColor & highlightedText 00098 ); 00099 virtual ~UPalette(); 00100 00101 00102 inline void setColor(ColorRole role, const UColor & color); 00103 inline const UColor & getColor(ColorRole role) const; 00104 00110 void transcribe(const UPalette & pal); 00116 void update(const UPalette & pal); 00117 00118 00119 const UColor & background() const { return getColor(Background); } 00120 const UColor & foreground() const { return getColor(Foreground); } 00121 const UColor & base() const { return getColor(Base); } 00122 const UColor & text() const { return getColor(Text); } 00123 00124 const UColor & button() const { return getColor(Button); } 00125 const UColor & buttonText() const { return getColor(ButtonText); } 00126 00127 const UColor & light() const { return getColor(Light); } 00128 const UColor & midLight() const { return getColor(MidLight); } 00129 const UColor & dark() const { return getColor(Dark); } 00130 const UColor & mid() const { return getColor(Mid); } 00131 const UColor & highlight() const { return getColor(Highlight); } 00132 const UColor & highlightedText() const { return getColor(HighlightedText); } 00133 00134 const UColor & link() const { return getColor(Link); } 00135 const UColor & linkVisited() const { return getColor(LinkVisited); } 00136 00138 const UColor & getColor(ColorGroup group, ColorRole role) const; 00140 void setColor(ColorGroup group, ColorRole role, const UColor & color); 00141 00142 00143 public: // Public operators 00144 bool operator==(const UPalette & pal) const; 00145 inline bool operator!=(const UPalette & pal) const; 00146 00147 protected: // Overrides UObject 00148 virtual std::ostream & paramString(std::ostream & os) const; 00149 00150 private: 00151 UColor m_colors[MaxColorRoles]; 00152 }; 00153 00154 00155 // 00156 // inline implementation 00157 // 00158 00159 inline void 00160 UPalette::setColor(ColorRole role, const UColor & color) { 00161 //detach(); 00162 m_colors[role] = color; 00163 } 00164 00165 inline const UColor & 00166 UPalette::getColor(ColorRole role) const { 00167 return m_colors[role]; 00168 } 00169 00170 inline bool 00171 UPalette::operator!=(const UPalette & pal) const { 00172 return !(operator==(pal)); 00173 } 00174 00175 } // namespace ufo 00176 00177 #endif // UPALETTE_HPP

The libUFO Project - written by Johannes Schmidt