Main Page - Header
Author: The Inti Development Team

Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# color.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 The Inti 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 INTI_GDK_COLOR_H
    00025 #define INTI_GDK_COLOR_H
    00026
    00027 #ifndef INTI_G_BOXED_H
    00028 #include <inti/glib/boxed.h>
    00029 #endif
    00030
    00031 #ifndef INTI_G_OBJECT_H
    00032 #include <inti/glib/object.h>
    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 Inti {
    00048
    00049 namespace Gdk {
    00050
    00051 class ColormapClass;
    00052 class Screen;
    00053 class Visual;
    00054
    00059
    00060 class Color : public G::Boxed
    00061 {
    00062 public:
    00065
    00066         Color();
    00068
    00069         explicit Color(const char *spec);
    00078
    00079         explicit Color(unsigned short value);
    00082
    00083         Color(unsigned short r, unsigned short g, unsigned short b);
    00088
    00089         explicit Color(GdkColor *color);
    00097
    00098         Color(GdkColor *color, bool copy);
    00109
    00110         Color(const Color& src);
    00113
    00114         ~Color();
    00116
    00117         Color& operator=(const Color& src);
    00120
    00124
    00125         GdkColor* gdk_color() const { return (GdkColor*)boxed_; }
    00127
    00128         operator GdkColor* () const;
    00130
    00131         unsigned short get_red() const;
    00134
    00135         unsigned short get_green() const;
    00137
    00138         unsigned short get_blue() const;
    00140
    00141         unsigned long get_pixel() const;
    00143
    00144         void get(unsigned short& r, unsigned short& g, unsigned short& b) const;
    00149
    00150         bool equal(const Color& other) const;
    00154
    00155         bool operator==(const Color& other);
    00159
    00160         bool operator!=(const Color& other);
    00164
    00168
    00169         void set_red(unsigned short r);
    00172
    00173         void set_green(unsigned short g);
    00176
    00177         void set_blue(unsigned short b);
    00180
    00181         void set_pixel(unsigned long p);
    00184
    00185         void set_grey(unsigned short value);
    00188
    00189         void set(unsigned short r, unsigned short g, unsigned short b);
    00194
    00195         bool parse(const char *spec);
    00204
    00205         unsigned int hash() const;
    00208
    00209         bool allocate(const Screen *screen = 0);
    00213
    00214         void free(const Screen *screen = 0);
    00218
    00220 };
    00221
    00240
    00241 class Colormap : public G::Object
    00242 {
    00243         friend class G::Object;
    00244         friend class ColormapClass;
    00245
    00246         Colormap(const Colormap&);
    00247         Colormap& operator=(const Colormap&);
    00248
    00249 protected:
    00252
    00253         explicit Colormap(GdkColormap *colormap, bool reference = true);
    00260
    00262
    00263 public:
    00266
    00267         Colormap(const Visual& visual, bool allocate = false);
    00272
    00273         virtual ~Colormap();
    00275
    00277
    00278         static Colormap* get_system(const Screen *screen = 0);
    00282
    00285
    00286         GdkColormap* gdk_colormap() const { return (GdkColormap*)instance; }
    00288
    00289         GdkColormapClass* gdk_colormap_class() const;
    00291
    00292         operator GdkColormap* () const;
    00294
    00295         const Visual* get_visual() const;
    00298
    00299         Screen* get_screen() const;
    00302
    00306
    00307         bool alloc_color(Color& color, bool best_match = true, bool writeable = false);
    00317
    00318         int alloc_colors(const std::vector<Color>& colors, std::vector<bool>& successes, bool best_match = true, bool writeable = false);
    00333
    00334         void free_color(const Color& color);
    00337
    00338         void free_colors(const std::vector<Color>& colors);
    00341
    00342         void query_color(unsigned long pixel, Color& result) const;
    00354
    00355         Color query_color(unsigned long pixel) const;
    00367
    00371
    00372         void rgb_find_color(Color& color) const;
    00386
    00388 };
    00389
    00390 } // namespace Gdk
    00391
    00392 } // namespace Inti
    00393
    00394 #endif // INTI_GDK_COLORMAP_H
    00395

Main Page - Footer