]> Pileus Git - ~andy/gtk/blob - gdk/gdkcolor.h
Seal gdk
[~andy/gtk] / gdk / gdkcolor.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
28 #error "Only <gdk/gdk.h> can be included directly."
29 #endif
30
31 #ifndef __GDK_COLOR_H__
32 #define __GDK_COLOR_H__
33
34 #include <cairo.h>
35 #include <gdk/gdktypes.h>
36
37 G_BEGIN_DECLS
38
39 /* The color type.
40  *   A color consists of red, green and blue values in the
41  *    range 0-65535 and a pixel value. The pixel value is highly
42  *    dependent on the depth and colormap which this color will
43  *    be used to draw into. Therefore, sharing colors between
44  *    colormaps is a bad idea.
45  */
46 struct _GdkColor
47 {
48   guint32 pixel;
49   guint16 red;
50   guint16 green;
51   guint16 blue;
52 };
53
54 /* The colormap type.
55  */
56
57 typedef struct _GdkColormapClass GdkColormapClass;
58
59 #define GDK_TYPE_COLORMAP              (gdk_colormap_get_type ())
60 #define GDK_COLORMAP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_COLORMAP, GdkColormap))
61 #define GDK_COLORMAP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_COLORMAP, GdkColormapClass))
62 #define GDK_IS_COLORMAP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_COLORMAP))
63 #define GDK_IS_COLORMAP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_COLORMAP))
64 #define GDK_COLORMAP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_COLORMAP, GdkColormapClass))
65
66 #define GDK_TYPE_COLOR                 (gdk_color_get_type ())
67
68 struct _GdkColormap
69 {
70   /*< private >*/
71   GObject parent_instance;
72
73   /*< public >*/
74   gint      GSEAL (size);
75   GdkColor *GSEAL (colors);
76
77   /*< private >*/
78   GdkVisual *GSEAL (visual);
79   
80   gpointer GSEAL (windowing_data);
81 };
82
83 struct _GdkColormapClass
84 {
85   GObjectClass parent_class;
86
87 };
88
89 GType        gdk_colormap_get_type (void) G_GNUC_CONST;
90
91 GdkColormap* gdk_colormap_new     (GdkVisual   *visual,
92                                    gboolean     allocate);
93
94 #ifndef GDK_DISABLE_DEPRECATED
95 GdkColormap* gdk_colormap_ref     (GdkColormap *cmap);
96 void         gdk_colormap_unref   (GdkColormap *cmap);
97 #endif 
98
99 #ifndef GDK_MULTIHEAD_SAFE
100 GdkColormap* gdk_colormap_get_system            (void);
101 #endif
102
103 GdkScreen *gdk_colormap_get_screen (GdkColormap *cmap);
104
105 #ifndef GDK_DISABLE_DEPRECATED
106 gint gdk_colormap_get_system_size  (void);
107 #endif
108
109 #if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
110 /* Used by gdk_colors_store () */
111 void gdk_colormap_change (GdkColormap   *colormap,
112                           gint           ncolors);
113 #endif 
114
115 gint  gdk_colormap_alloc_colors   (GdkColormap    *colormap,
116                                    GdkColor       *colors,
117                                    gint            n_colors,
118                                    gboolean        writeable,
119                                    gboolean        best_match,
120                                    gboolean       *success);
121 gboolean gdk_colormap_alloc_color (GdkColormap    *colormap,
122                                    GdkColor       *color,
123                                    gboolean        writeable,
124                                    gboolean        best_match);
125 void     gdk_colormap_free_colors (GdkColormap    *colormap,
126                                    const GdkColor *colors,
127                                    gint            n_colors);
128 void     gdk_colormap_query_color (GdkColormap    *colormap,
129                                    gulong          pixel,
130                                    GdkColor       *result);
131
132 GdkVisual *gdk_colormap_get_visual (GdkColormap *colormap);
133
134 GdkColor *gdk_color_copy      (const GdkColor *color);
135 void      gdk_color_free      (GdkColor       *color);
136 gboolean  gdk_color_parse     (const gchar    *spec,
137                                GdkColor       *color);
138 guint     gdk_color_hash      (const GdkColor *colora);
139 gboolean  gdk_color_equal     (const GdkColor *colora,
140                                const GdkColor *colorb);
141 gchar *   gdk_color_to_string (const GdkColor *color);
142
143 GType     gdk_color_get_type (void) G_GNUC_CONST;
144
145 /* The following functions are deprecated */
146 #ifndef GDK_DISABLE_DEPRECATED
147 void gdk_colors_store    (GdkColormap   *colormap,
148                           GdkColor      *colors,
149                           gint           ncolors);
150 gint gdk_color_white     (GdkColormap   *colormap,
151                           GdkColor      *color);
152 gint gdk_color_black     (GdkColormap   *colormap,
153                           GdkColor      *color);
154 gint gdk_color_alloc     (GdkColormap   *colormap,
155                           GdkColor      *color);
156 gint gdk_color_change    (GdkColormap   *colormap,
157                           GdkColor      *color);
158 #endif /* GDK_DISABLE_DEPRECATED */
159
160 #if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
161 /* Used by gdk_rgb_try_colormap () */
162 gint gdk_colors_alloc    (GdkColormap   *colormap,
163                           gboolean       contiguous,
164                           gulong        *planes,
165                           gint           nplanes,
166                           gulong        *pixels,
167                           gint           npixels);
168 void gdk_colors_free     (GdkColormap   *colormap,
169                           gulong        *pixels,
170                           gint           npixels,
171                           gulong         planes);
172 #endif /* !GDK_DISABLE_DEPRECATED || GDK_COMPILATION */
173
174 G_END_DECLS
175
176 #endif /* __GDK_COLOR_H__ */