GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

color.hh

Go to the documentation of this file.
00001 /* GFC-UI: GTK+ Foundation Classes (User Interface Library) 00002 * Copyright (C) 2002-2004 The GFC Development Team. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00023 00024 #ifndef GFC_GDK_COLOR_HH 00025 #define GFC_GDK_COLOR_HH 00026 00027 #ifndef GFC_G_BOXED_HH 00028 #include <gfc/glib/boxed.hh> 00029 #endif 00030 00031 #ifndef GFC_G_OBJECT_HH 00032 #include <gfc/glib/object.hh> 00033 #endif 00034 00035 #ifndef __GDK_COLOR_H__ 00036 #include <gdk/gdkcolor.h> 00037 #endif 00038 00039 #ifndef _CPP_MAP 00040 #include <map> 00041 #endif 00042 00043 #ifndef _CPP_VECTOR 00044 #include <vector> 00045 #endif 00046 00047 namespace GFC { 00048 00049 namespace Gdk { 00050 00051 class Screen; 00052 class Visual; 00053 00058 00059 class Color : public G::Boxed 00060 { 00061 public: 00064 00065 Color(); 00067 00068 explicit Color(const char *spec); 00077 00078 explicit Color(unsigned short value); 00081 00082 Color(unsigned short r, unsigned short g, unsigned short b); 00087 00088 explicit Color(GdkColor *color); 00096 00097 Color(GdkColor *color, bool copy); 00108 00109 Color(const Color& src); 00112 00113 ~Color(); 00115 00116 Color& operator=(const Color& src); 00119 00123 00124 GdkColor* gdk_color() const; 00126 00127 operator GdkColor* () const; 00129 00130 unsigned short get_red() const; 00133 00134 unsigned short get_green() const; 00136 00137 unsigned short get_blue() const; 00139 00140 unsigned long get_pixel() const; 00142 00143 void get(unsigned short& r, unsigned short& g, unsigned short& b) const; 00148 00149 bool equal(const Color& other) const; 00153 00154 bool operator==(const Color& other); 00158 00159 bool operator!=(const Color& other); 00163 00167 00168 void set_red(unsigned short r); 00171 00172 void set_green(unsigned short g); 00175 00176 void set_blue(unsigned short b); 00179 00180 void set_pixel(unsigned long p); 00183 00184 void set_grey(unsigned short value); 00187 00188 void set(unsigned short r, unsigned short g, unsigned short b); 00193 00194 bool parse(const char *spec); 00203 00204 unsigned int hash() const; 00207 00208 bool allocate(const Screen *screen = 0); 00212 00213 void free(const Screen *screen = 0); 00217 00219 }; 00220 00239 00240 class Colormap : public G::Object 00241 { 00242 friend class G::Object; 00243 00244 Colormap(const Colormap&); 00245 Colormap& operator=(const Colormap&); 00246 00247 protected: 00250 00251 explicit Colormap(GdkColormap *colormap, bool owns_reference = true); 00258 00260 00261 public: 00264 00265 Colormap(const Visual& visual, bool allocate = false); 00270 00271 virtual ~Colormap(); 00273 00275 00276 static Colormap* get_system(const Screen *screen = 0); 00280 00283 00284 GdkColormap* gdk_colormap() const; 00286 00287 operator GdkColormap* () const; 00289 00290 const Visual* get_visual() const; 00293 00294 Screen* get_screen() const; 00297 00301 00302 bool alloc_color(Color& color, bool best_match = true, bool writeable = false); 00312 00313 int alloc_colors(const std::vector<Color>& colors, std::vector<bool>& successes, bool best_match = true, bool writeable = false); 00328 00329 void free_color(const Color& color); 00332 00333 void free_colors(const std::vector<Color>& colors); 00336 00337 void query_color(unsigned long pixel, Color& result) const; 00349 00350 Color query_color(unsigned long pixel) const; 00362 00366 00367 void rgb_find_color(Color& color) const; 00381 00383 }; 00384 00385 } // namespace Gdk 00386 00387 } // namespace GFC 00388 00389 #include <gfc/gdk/inline/color.inl> 00390 00391 #endif // GFC_GDK_COLORMAP_HH 00392

Generated on Tue Aug 24 00:34:30 2004 for GFC-UI by doxygen 1.3.8