]> Pileus Git - ~andy/gtk/blob - gdk/gdkcolor.h
Translation updated by Ivar Smolin.
[~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 #ifndef __GDK_COLOR_H__
28 #define __GDK_COLOR_H__
29
30 #include <cairo.h>
31 #include <gdk/gdktypes.h>
32
33 G_BEGIN_DECLS
34
35 /* The color type.
36  *   A color consists of red, green and blue values in the
37  *    range 0-65535 and a pixel value. The pixel value is highly
38  *    dependent on the depth and colormap which this color will
39  *    be used to draw into. Therefore, sharing colors between
40  *    colormaps is a bad idea.
41  */
42 struct _GdkColor
43 {
44   guint32 pixel;
45   guint16 red;
46   guint16 green;
47   guint16 blue;
48 };
49
50 /* The colormap type.
51  */
52
53 typedef struct _GdkColormapClass GdkColormapClass;
54
55 #define GDK_TYPE_COLORMAP              (gdk_colormap_get_type ())
56 #define GDK_COLORMAP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_COLORMAP, GdkColormap))
57 #define GDK_COLORMAP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_COLORMAP, GdkColormapClass))
58 #define GDK_IS_COLORMAP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_COLORMAP))
59 #define GDK_IS_COLORMAP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_COLORMAP))
60 #define GDK_COLORMAP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_COLORMAP, GdkColormapClass))
61
62 #define GDK_TYPE_COLOR                 (gdk_color_get_type ())
63
64 struct _GdkColormap
65 {
66   /*< private >*/
67   GObject parent_instance;
68
69   /*< public >*/
70   gint      size;
71   GdkColor *colors;
72
73   /*< private >*/
74   GdkVisual *visual;
75   
76   gpointer windowing_data;
77 };
78
79 struct _GdkColormapClass
80 {
81   GObjectClass parent_class;
82
83 };
84
85 GType        gdk_colormap_get_type (void) G_GNUC_CONST;
86
87 GdkColormap* gdk_colormap_new     (GdkVisual   *visual,
88                                    gboolean     allocate);
89
90 #ifndef GDK_DISABLE_DEPRECATED
91 GdkColormap* gdk_colormap_ref     (GdkColormap *cmap);
92 void         gdk_colormap_unref   (GdkColormap *cmap);
93 #endif 
94
95 #ifndef GDK_MULTIHEAD_SAFE
96 GdkColormap* gdk_colormap_get_system            (void);
97 #endif
98
99 GdkScreen *gdk_colormap_get_screen (GdkColormap *cmap);
100
101 #ifndef GDK_DISABLE_DEPRECATED
102 gint gdk_colormap_get_system_size  (void);
103 #endif
104
105 #if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
106 /* Used by gdk_colors_store () */
107 void gdk_colormap_change (GdkColormap   *colormap,
108                           gint           ncolors);
109 #endif 
110
111 gint  gdk_colormap_alloc_colors   (GdkColormap *colormap,
112                                    GdkColor    *colors,
113                                    gint         ncolors,
114                                    gboolean     writeable,
115                                    gboolean     best_match,
116                                    gboolean    *success);
117 gboolean gdk_colormap_alloc_color (GdkColormap *colormap,
118                                    GdkColor    *color,
119                                    gboolean     writeable,
120                                    gboolean     best_match);
121 void     gdk_colormap_free_colors (GdkColormap *colormap,
122                                    GdkColor    *colors,
123                                    gint         ncolors);
124 void     gdk_colormap_query_color (GdkColormap *colormap,
125                                    gulong       pixel,
126                                    GdkColor    *result);
127
128 GdkVisual *gdk_colormap_get_visual (GdkColormap *colormap);
129      
130 GdkColor *gdk_color_copy  (const GdkColor *color);
131 void      gdk_color_free  (GdkColor       *color);
132 gint      gdk_color_parse (const gchar    *spec,
133                            GdkColor       *color);
134 guint     gdk_color_hash  (const GdkColor *colora);
135 gboolean  gdk_color_equal (const GdkColor *colora,
136                            const GdkColor *colorb);
137
138 GType     gdk_color_get_type (void) G_GNUC_CONST;
139
140 /* The following functions are deprecated */
141 #ifndef GDK_DISABLE_DEPRECATED
142 void gdk_colors_store    (GdkColormap   *colormap,
143                           GdkColor      *colors,
144                           gint           ncolors);
145 gint gdk_color_white     (GdkColormap   *colormap,
146                           GdkColor      *color);
147 gint gdk_color_black     (GdkColormap   *colormap,
148                           GdkColor      *color);
149 gint gdk_color_alloc     (GdkColormap   *colormap,
150                           GdkColor      *color);
151 gint gdk_color_change    (GdkColormap   *colormap,
152                           GdkColor      *color);
153 #endif /* GDK_DISABLE_DEPRECATED */
154
155 #if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
156 /* Used by gdk_rgb_try_colormap () */
157 gint gdk_colors_alloc    (GdkColormap   *colormap,
158                           gboolean       contiguous,
159                           gulong        *planes,
160                           gint           nplanes,
161                           gulong        *pixels,
162                           gint           npixels);
163 void gdk_colors_free     (GdkColormap   *colormap,
164                           gulong        *pixels,
165                           gint           npixels,
166                           gulong         planes);
167 #endif /* !GDK_DISABLE_DEPRECATED || GDK_COMPILATION */
168
169 G_END_DECLS
170
171 #endif /* __GDK_COLOR_H__ */