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