3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
24 #include "gdkprivate-quartz.h"
27 gdk_colormap_get_type (void)
29 static GType object_type = 0;
33 static const GTypeInfo object_info =
35 sizeof (GdkColormapClass),
37 (GBaseFinalizeFunc) NULL,
38 (GClassInitFunc) NULL,
39 NULL, /* class_finalize */
40 NULL, /* class_data */
43 (GInstanceInitFunc) NULL,
46 object_type = g_type_register_static (G_TYPE_OBJECT,
56 gdk_colormap_new (GdkVisual *visual,
59 g_return_val_if_fail (visual != NULL, NULL);
61 /* FIXME: Implement */
66 gdk_screen_get_system_colormap (GdkScreen *screen)
68 static GdkColormap *colormap = NULL;
70 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
74 colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
76 colormap->visual = gdk_visual_get_system ();
77 colormap->size = colormap->visual->colormap_size;
85 gdk_screen_get_rgba_colormap (GdkScreen *screen)
87 static GdkColormap *colormap = NULL;
89 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
93 colormap = g_object_new (GDK_TYPE_COLORMAP, NULL);
95 colormap->visual = gdk_screen_get_rgba_visual (screen);
96 colormap->size = colormap->visual->colormap_size;
103 gdk_colormap_get_system_size (void)
105 /* FIXME: Implement */
110 gdk_colormap_change (GdkColormap *colormap,
113 /* FIXME: Implement */
117 gdk_colormap_free_colors (GdkColormap *colormap,
121 /* This function shouldn't do anything since
122 * colors are neve allocated.
127 gdk_colormap_alloc_colors (GdkColormap *colormap,
136 for (i = 0; i < ncolors; i++)
138 colors[i].pixel = ((colors[i].red >> 8) & 0xff) << 16 |
139 ((colors[i].green >> 8) & 0xff) << 8 |
140 ((colors[i].blue >> 8) & 0xff);
147 gdk_colormap_query_color (GdkColormap *colormap,
151 result->red = pixel >> 16 & 0xff;
152 result->red += result->red << 8;
154 result->green = pixel >> 8 & 0xff;
155 result->green += result->green << 8;
157 result->blue = pixel & 0xff;
158 result->blue += result->blue << 8;
162 gdk_colormap_get_screen (GdkColormap *cmap)
164 g_return_val_if_fail (cmap != NULL, NULL);
166 return gdk_screen_get_default ();
170 _gdk_quartz_set_context_fill_color_from_pixel (CGContextRef context, GdkColormap *colormap, guint32 pixel)
172 float red, green, blue, alpha;
174 red = (pixel >> 16 & 0xff) / 255.0;
175 green = (pixel >> 8 & 0xff) / 255.0;
176 blue = (pixel & 0xff) / 255.0;
178 if (colormap && gdk_colormap_get_visual (colormap)->depth == 32)
179 alpha = (pixel >> 24 & 0xff) / 255.0;
183 CGContextSetRGBFillColor (context, red, green, blue, alpha);
187 _gdk_quartz_set_context_stroke_color_from_pixel (CGContextRef context, GdkColormap *colormap, guint32 pixel)
189 float red, green, blue, alpha;
191 red = (pixel >> 16 & 0xff) / 255.0;
192 green = (pixel >> 8 & 0xff) / 255.0;
193 blue = (pixel & 0xff) / 255.0;
195 if (colormap && gdk_colormap_get_visual (colormap)->depth == 32)
196 alpha = (pixel >> 24 & 0xff) / 255.0;
200 CGContextSetRGBStrokeColor (context, red, green, blue, 1.0);
204 gdk_color_change (GdkColormap *colormap,
207 /* FIXME: Implement */