forked from AuroraMiddleware/gtk
Remove deprecatedd code from GdkColor
https://bugzilla.gnome.org/show_bug.cgi?id=619649
This commit is contained in:
parent
a18f23c478
commit
2ace397eb5
@ -3124,7 +3124,7 @@ like this:</para>
|
||||
* displays. Therefore, this call is required so that GDK and X can
|
||||
* give us the closest color available in the colormap
|
||||
*/
|
||||
gdk_color_alloc(gtk_widget_get_colormap(widget), color);
|
||||
gdk_colormap_alloc_color(gtk_widget_get_colormap(widget), color, FALSE, TRUE);
|
||||
|
||||
/* set the foreground to our color */
|
||||
gdk_gc_set_foreground(gc, color);
|
||||
|
@ -365,27 +365,16 @@ gdk_pixbuf_get_from_image
|
||||
GdkColor
|
||||
GdkColormap
|
||||
gdk_colormap_new
|
||||
gdk_colormap_ref
|
||||
gdk_colormap_unref
|
||||
gdk_colormap_get_system
|
||||
gdk_colormap_get_system_size
|
||||
gdk_colormap_change
|
||||
gdk_colormap_alloc_colors
|
||||
gdk_colormap_alloc_color
|
||||
gdk_colormap_free_colors
|
||||
gdk_colormap_query_color
|
||||
gdk_colormap_get_visual
|
||||
gdk_colormap_get_screen
|
||||
gdk_colors_store
|
||||
gdk_color_copy
|
||||
gdk_color_free
|
||||
gdk_colors_alloc
|
||||
gdk_colors_free
|
||||
gdk_color_white
|
||||
gdk_color_black
|
||||
gdk_color_parse
|
||||
gdk_color_alloc
|
||||
gdk_color_change
|
||||
gdk_color_equal
|
||||
gdk_color_hash
|
||||
gdk_color_to_string
|
||||
|
@ -32,10 +32,7 @@ directly.
|
||||
In previous revisions of this interface, a number
|
||||
of functions that take a #GdkColormap parameter
|
||||
were replaced with functions whose names began
|
||||
with "gdk_colormap_". This process will probably
|
||||
be extended somewhat in the future -
|
||||
gdk_color_white(), gdk_color_black(), and
|
||||
gdk_color_change() will probably become aliases.
|
||||
with "gdk_colormap_".
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
@ -78,23 +75,6 @@ The colormap structure contains the following public fields.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colormap_ref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmap:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colormap_unref ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmap:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colormap_get_system ##### -->
|
||||
<para>
|
||||
</para>
|
||||
@ -103,22 +83,6 @@ The colormap structure contains the following public fields.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colormap_get_system_size ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@void:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colormap_change ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@ncolors:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colormap_alloc_colors ##### -->
|
||||
<para>
|
||||
</para>
|
||||
@ -179,15 +143,6 @@ The colormap structure contains the following public fields.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colors_store ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@colors:
|
||||
@ncolors:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_copy ##### -->
|
||||
<para>
|
||||
</para>
|
||||
@ -203,47 +158,6 @@ The colormap structure contains the following public fields.
|
||||
@color:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colors_alloc ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@contiguous:
|
||||
@planes:
|
||||
@nplanes:
|
||||
@pixels:
|
||||
@npixels:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_colors_free ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@pixels:
|
||||
@npixels:
|
||||
@planes:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_white ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@color:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_black ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@color:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_parse ##### -->
|
||||
<para>
|
||||
</para>
|
||||
@ -253,24 +167,6 @@ The colormap structure contains the following public fields.
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_alloc ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@color:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_change ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@colormap:
|
||||
@color:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_color_equal ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
@ -218,45 +218,6 @@ gdk_screen_get_system_colormap (GdkScreen *screen)
|
||||
return colormap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
|
||||
visual = gdk_visual_get_system ();
|
||||
|
||||
return visual->colormap_size;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
g_message ("gdk_colormap_change() is deprecated and unimplemented");
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gboolean contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
/* g_message ("gdk_colors_alloc() is deprecated and unimplemented"); */
|
||||
|
||||
return TRUE; /* return TRUE here to make GdkRGB happy */
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *in_pixels,
|
||||
gint in_npixels,
|
||||
gulong planes)
|
||||
{
|
||||
/* g_message ("gdk_colors_free() is deprecated and unimplemented"); */
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_free_colors (GdkColormap *colormap,
|
||||
const GdkColor *colors,
|
||||
@ -344,44 +305,6 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivateDirectFB *private;
|
||||
IDirectFBPalette *palette;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
private = colormap->windowing_data;
|
||||
if (!private)
|
||||
return FALSE;
|
||||
|
||||
palette = private->palette;
|
||||
if (!palette)
|
||||
return FALSE;
|
||||
|
||||
if (color->pixel < 0 || color->pixel >= colormap->size)
|
||||
return FALSE;
|
||||
|
||||
if (private->info[color->pixel].flags & GDK_COLOR_WRITEABLE)
|
||||
{
|
||||
DFBColor entry = { 0xFF,
|
||||
color->red >> 8,
|
||||
color->green >> 8,
|
||||
color->blue >> 8 };
|
||||
|
||||
if (palette->SetEntries (palette, &entry, 1, color->pixel) != DFB_OK)
|
||||
return FALSE;
|
||||
|
||||
colormap->colors[color->pixel] = *color;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_query_color (GdkColormap *colormap,
|
||||
gulong pixel,
|
||||
|
@ -354,12 +354,6 @@ gdk_cairo_region
|
||||
|
||||
#if IN_HEADER(__GDK_COLOR_H__)
|
||||
#if IN_FILE(__GDK_COLOR_C__)
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_colors_store
|
||||
gdk_color_white
|
||||
gdk_color_black
|
||||
gdk_color_alloc
|
||||
#endif
|
||||
gdk_color_copy
|
||||
gdk_color_equal
|
||||
gdk_color_free
|
||||
@ -368,10 +362,6 @@ gdk_color_hash
|
||||
gdk_colormap_alloc_color
|
||||
gdk_colormap_get_system
|
||||
gdk_colormap_get_visual
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_colormap_ref
|
||||
gdk_colormap_unref
|
||||
#endif
|
||||
gdk_color_parse
|
||||
gdk_color_to_string
|
||||
#endif
|
||||
@ -381,13 +371,6 @@ gdk_color_to_string
|
||||
#if IN_FILE(__GDK_COLOR_X11_C__)
|
||||
gdk_colormap_new
|
||||
gdk_colormap_get_type G_GNUC_CONST
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_colormap_change
|
||||
gdk_colors_alloc
|
||||
gdk_colors_free
|
||||
gdk_colormap_get_system_size
|
||||
gdk_color_change
|
||||
#endif
|
||||
gdk_colormap_alloc_colors
|
||||
gdk_colormap_free_colors
|
||||
gdk_colormap_query_color
|
||||
|
152
gdk/gdkcolor.c
152
gdk/gdkcolor.c
@ -32,36 +32,6 @@
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
/**
|
||||
* gdk_colormap_ref:
|
||||
* @cmap: a #GdkColormap
|
||||
*
|
||||
* Deprecated function; use g_object_ref() instead.
|
||||
*
|
||||
* Return value: the colormap
|
||||
*
|
||||
* Deprecated: 2.0: Use g_object_ref() instead.
|
||||
**/
|
||||
GdkColormap*
|
||||
gdk_colormap_ref (GdkColormap *cmap)
|
||||
{
|
||||
return (GdkColormap *) g_object_ref (cmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_colormap_unref:
|
||||
* @cmap: a #GdkColormap
|
||||
*
|
||||
* Deprecated function; use g_object_unref() instead.
|
||||
*
|
||||
* Deprecated: 2.0: Use g_object_unref() instead.
|
||||
**/
|
||||
void
|
||||
gdk_colormap_unref (GdkColormap *cmap)
|
||||
{
|
||||
g_object_unref (cmap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gdk_colormap_get_visual:
|
||||
@ -79,34 +49,6 @@ gdk_colormap_get_visual (GdkColormap *colormap)
|
||||
return colormap->visual;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_colors_store:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @colors: the new color values.
|
||||
* @ncolors: the number of colors to change.
|
||||
*
|
||||
* Changes the value of the first @ncolors colors in
|
||||
* a private colormap. This function is obsolete and
|
||||
* should not be used. See gdk_color_change().
|
||||
**/
|
||||
void
|
||||
gdk_colors_store (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint ncolors)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
colormap->colors[i].pixel = colors[i].pixel;
|
||||
colormap->colors[i].red = colors[i].red;
|
||||
colormap->colors[i].green = colors[i].green;
|
||||
colormap->colors[i].blue = colors[i].blue;
|
||||
}
|
||||
|
||||
gdk_colormap_change (colormap, ncolors);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_copy:
|
||||
* @color: a #GdkColor.
|
||||
@ -143,70 +85,6 @@ gdk_color_free (GdkColor *color)
|
||||
g_slice_free (GdkColor, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_white:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @color: the location to store the color.
|
||||
*
|
||||
* Returns the white color for a given colormap. The resulting
|
||||
* value has already allocated been allocated.
|
||||
*
|
||||
* Return value: %TRUE if the allocation succeeded.
|
||||
**/
|
||||
gboolean
|
||||
gdk_color_white (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->red = 65535;
|
||||
color->green = 65535;
|
||||
color->blue = 65535;
|
||||
|
||||
return_val = gdk_colormap_alloc_color (colormap, color, FALSE, TRUE);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_black:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @color: the location to store the color.
|
||||
*
|
||||
* Returns the black color for a given colormap. The resulting
|
||||
* value has already been allocated.
|
||||
*
|
||||
* Return value: %TRUE if the allocation succeeded.
|
||||
**/
|
||||
gboolean
|
||||
gdk_color_black (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gint return_val;
|
||||
|
||||
g_return_val_if_fail (colormap != NULL, FALSE);
|
||||
|
||||
if (color)
|
||||
{
|
||||
color->red = 0;
|
||||
color->green = 0;
|
||||
color->blue = 0;
|
||||
|
||||
return_val = gdk_colormap_alloc_color (colormap, color, FALSE, TRUE);
|
||||
}
|
||||
else
|
||||
return_val = FALSE;
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
/********************
|
||||
* Color allocation *
|
||||
********************/
|
||||
@ -217,14 +95,13 @@ gdk_color_black (GdkColormap *colormap,
|
||||
* @color: the color to allocate. On return the
|
||||
* <structfield>pixel</structfield> field will be
|
||||
* filled in if allocation succeeds.
|
||||
* @writeable: If %TRUE, the color is allocated writeable
|
||||
* (their values can later be changed using gdk_color_change()).
|
||||
* Writeable colors cannot be shared between applications.
|
||||
* @writeable: this parameter has no effect, and it's here for mere
|
||||
* compatibility.
|
||||
* @best_match: If %TRUE, GDK will attempt to do matching against
|
||||
* existing colors if the color cannot be allocated as requested.
|
||||
*
|
||||
* Allocates a single color from a colormap.
|
||||
*
|
||||
*
|
||||
* Return value: %TRUE if the allocation succeeded.
|
||||
**/
|
||||
gboolean
|
||||
@ -241,29 +118,6 @@ gdk_colormap_alloc_color (GdkColormap *colormap,
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_alloc:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @color: The color to allocate. On return, the
|
||||
* <structfield>pixel</structfield> field will be filled in.
|
||||
*
|
||||
* Allocates a single color from a colormap.
|
||||
*
|
||||
* Return value: %TRUE if the allocation succeeded.
|
||||
*
|
||||
* Deprecated: 2.2: Use gdk_colormap_alloc_color() instead.
|
||||
**/
|
||||
gboolean
|
||||
gdk_color_alloc (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
gboolean success;
|
||||
|
||||
gdk_colormap_alloc_colors (colormap, color, 1, FALSE, TRUE, &success);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_hash:
|
||||
* @colora: a #GdkColor.
|
||||
|
@ -91,27 +91,12 @@ GType gdk_colormap_get_type (void) G_GNUC_CONST;
|
||||
GdkColormap* gdk_colormap_new (GdkVisual *visual,
|
||||
gboolean allocate);
|
||||
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
|
||||
void gdk_colormap_unref (GdkColormap *cmap);
|
||||
#endif
|
||||
|
||||
#ifndef GDK_MULTIHEAD_SAFE
|
||||
GdkColormap* gdk_colormap_get_system (void);
|
||||
#endif
|
||||
|
||||
GdkScreen *gdk_colormap_get_screen (GdkColormap *cmap);
|
||||
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gint gdk_colormap_get_system_size (void);
|
||||
#endif
|
||||
|
||||
#if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
|
||||
/* Used by gdk_colors_store () */
|
||||
void gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors);
|
||||
#endif
|
||||
|
||||
gint gdk_colormap_alloc_colors (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint n_colors,
|
||||
@ -142,34 +127,6 @@ gchar * gdk_color_to_string (const GdkColor *color);
|
||||
|
||||
GType gdk_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* The following functions are deprecated */
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
void gdk_colors_store (GdkColormap *colormap,
|
||||
GdkColor *colors,
|
||||
gint ncolors);
|
||||
gint gdk_color_white (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_black (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_alloc (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
gint gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
#endif /* GDK_DISABLE_DEPRECATED */
|
||||
|
||||
#if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
|
||||
/* Used by gdk_rgb_try_colormap () */
|
||||
gint gdk_colors_alloc (GdkColormap *colormap,
|
||||
gboolean contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels);
|
||||
void gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes);
|
||||
#endif /* !GDK_DISABLE_DEPRECATED || GDK_COMPILATION */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -99,39 +99,6 @@ gdk_screen_get_rgba_colormap (GdkScreen *screen)
|
||||
return colormap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gboolean contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_free_colors (GdkColormap *colormap,
|
||||
const GdkColor *colors,
|
||||
@ -213,14 +180,3 @@ _gdk_quartz_colormap_get_rgba_from_pixel (GdkColormap *colormap,
|
||||
else
|
||||
*alpha = 1.0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
if (color->pixel < 0 || color->pixel >= colormap->size)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -195,8 +195,6 @@ test_colourmaps (void)
|
||||
static void
|
||||
test_colours (void)
|
||||
{
|
||||
ASSERT (gdk_color_white (system_colourmap, &white));
|
||||
ASSERT (gdk_color_black (system_colourmap, &black));
|
||||
red.red = 65535;
|
||||
red.green = red.blue = 0;
|
||||
TEST (gdk_colormap_alloc_color (system_colourmap, &red, FALSE, TRUE));
|
||||
|
@ -570,9 +570,6 @@ gdk_colormap_new (GdkVisual *visual,
|
||||
if (private_cmap)
|
||||
{
|
||||
sync_colors (colormap);
|
||||
#if 0 /* XXX is this needed or not? Seems redundant */
|
||||
gdk_colormap_change (colormap, colormap->size);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@ -640,82 +637,7 @@ gdk_screen_get_system_colormap (GdkScreen *screen)
|
||||
return colormap;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
return gdk_colormap_get_system ()->size;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
GdkColormapPrivateWin32 *cmapp;
|
||||
PALETTEENTRY *pe;
|
||||
int i;
|
||||
|
||||
g_return_if_fail (GDK_IS_COLORMAP (colormap));
|
||||
|
||||
cmapp = GDK_WIN32_COLORMAP_DATA (colormap);
|
||||
|
||||
GDK_NOTE (COLORMAP, g_print ("gdk_colormap_change: hpal=%p ncolors=%d\n",
|
||||
cmapp->hpal, ncolors));
|
||||
|
||||
switch (colormap->visual->type)
|
||||
{
|
||||
case GDK_VISUAL_GRAYSCALE:
|
||||
case GDK_VISUAL_PSEUDO_COLOR:
|
||||
pe = g_new (PALETTEENTRY, ncolors);
|
||||
|
||||
for (i = 0; i < ncolors; i++)
|
||||
{
|
||||
pe[i].peRed = (colormap->colors[i].red >> 8);
|
||||
pe[i].peGreen = (colormap->colors[i].green >> 8);
|
||||
pe[i].peBlue = (colormap->colors[i].blue >> 8);
|
||||
pe[i].peFlags = 0;
|
||||
}
|
||||
|
||||
GDI_CALL (SetPaletteEntries, (cmapp->hpal, 0, ncolors, pe));
|
||||
g_free (pe);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gboolean contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
GdkColormapPrivateWin32 *private;
|
||||
gint return_val;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
|
||||
|
||||
private = GDK_WIN32_COLORMAP_DATA (colormap);
|
||||
|
||||
return_val = alloc_color_cells (colormap, contiguous,
|
||||
planes, nplanes, pixels, npixels);
|
||||
|
||||
if (return_val)
|
||||
{
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
private->info[pixels[i]].ref_count++;
|
||||
private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
|
||||
}
|
||||
}
|
||||
|
||||
return return_val != 0;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *in_pixels,
|
||||
gint in_npixels,
|
||||
@ -1236,33 +1158,6 @@ gdk_colormap_query_color (GdkColormap *colormap,
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivateWin32 *private;
|
||||
PALETTEENTRY pe;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
private = GDK_WIN32_COLORMAP_DATA (colormap);
|
||||
|
||||
if (color->pixel < 0 || color->pixel >= colormap->size)
|
||||
return FALSE;
|
||||
|
||||
if (private->use[color->pixel] == GDK_WIN32_PE_STATIC)
|
||||
return FALSE;
|
||||
|
||||
pe.peRed = color->red >> 8;
|
||||
pe.peGreen = color->green >> 8;
|
||||
pe.peBlue = color->blue >> 8;
|
||||
|
||||
GDI_CALL (SetPaletteEntries, (private->hpal, color->pixel, 1, &pe));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_colormap_match_color (GdkColormap *cmap,
|
||||
GdkColor *color,
|
||||
|
@ -68,6 +68,9 @@ static void gdk_colormap_sync (GdkColormap *colormap,
|
||||
|
||||
static void gdk_colormap_finalize (GObject *object);
|
||||
|
||||
static void gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors);
|
||||
|
||||
G_DEFINE_TYPE (GdkColormap, gdk_colormap, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
@ -408,23 +411,7 @@ gdk_screen_get_system_colormap (GdkScreen *screen)
|
||||
return colormap;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_colormap_get_system_size:
|
||||
*
|
||||
* Returns the size of the system's default colormap.
|
||||
* (See the description of struct #GdkColormap for an
|
||||
* explanation of the size of a colormap.)
|
||||
*
|
||||
* Return value: the size of the system's default colormap.
|
||||
**/
|
||||
gint
|
||||
gdk_colormap_get_system_size (void)
|
||||
{
|
||||
return DisplayCells (GDK_SCREEN_XDISPLAY (gdk_screen_get_default()),
|
||||
GDK_SCREEN_X11 (gdk_screen_get_default())->screen_num);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* gdk_colormap_change:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @ncolors: the number of colors to change.
|
||||
@ -432,9 +419,9 @@ gdk_colormap_get_system_size (void)
|
||||
* Changes the value of the first @ncolors in a private colormap
|
||||
* to match the values in the <structfield>colors</structfield>
|
||||
* array in the colormap. This function is obsolete and
|
||||
* should not be used. See gdk_color_change().
|
||||
**/
|
||||
void
|
||||
* should not be used.
|
||||
*/
|
||||
static void
|
||||
gdk_colormap_change (GdkColormap *colormap,
|
||||
gint ncolors)
|
||||
{
|
||||
@ -523,123 +510,6 @@ gdk_colormap_change (GdkColormap *colormap,
|
||||
g_free (palette);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_colors_alloc:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @contiguous: if %TRUE, the colors should be allocated
|
||||
* in contiguous color cells.
|
||||
* @planes: an array in which to store the plane masks.
|
||||
* @nplanes: the number of planes to allocate. (Or zero,
|
||||
* to indicate that the color allocation should not be planar.)
|
||||
* @pixels: an array into which to store allocated pixel values.
|
||||
* @npixels: the number of pixels in each plane to allocate.
|
||||
*
|
||||
* Allocates colors from a colormap. This function
|
||||
* is obsolete. See gdk_colormap_alloc_colors().
|
||||
* For full documentation of the fields, see
|
||||
* the Xlib documentation for <function>XAllocColorCells()</function>.
|
||||
*
|
||||
* Return value: %TRUE if the allocation was successful
|
||||
**/
|
||||
gboolean
|
||||
gdk_colors_alloc (GdkColormap *colormap,
|
||||
gboolean contiguous,
|
||||
gulong *planes,
|
||||
gint nplanes,
|
||||
gulong *pixels,
|
||||
gint npixels)
|
||||
{
|
||||
GdkColormapPrivateX11 *private;
|
||||
gint return_val;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
|
||||
|
||||
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
|
||||
|
||||
if (private->screen->closed)
|
||||
return FALSE;
|
||||
|
||||
return_val = XAllocColorCells (GDK_SCREEN_XDISPLAY (private->screen),
|
||||
private->xcolormap,contiguous, planes,
|
||||
nplanes, pixels, npixels);
|
||||
if (return_val)
|
||||
{
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
private->info[pixels[i]].ref_count++;
|
||||
private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
|
||||
}
|
||||
}
|
||||
|
||||
return return_val != 0;
|
||||
}
|
||||
|
||||
/* This is almost identical to gdk_colormap_free_colors.
|
||||
* Keep them in sync!
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* gdk_colors_free:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @pixels: the pixel values of the colors to free.
|
||||
* @npixels: the number of values in @pixels.
|
||||
* @planes: the plane masks for all planes to free, OR'd together.
|
||||
*
|
||||
* Frees colors allocated with gdk_colors_alloc(). This
|
||||
* function is obsolete. See gdk_colormap_free_colors().
|
||||
**/
|
||||
void
|
||||
gdk_colors_free (GdkColormap *colormap,
|
||||
gulong *pixels,
|
||||
gint npixels,
|
||||
gulong planes)
|
||||
{
|
||||
GdkColormapPrivateX11 *private;
|
||||
gulong *pixels_to_free;
|
||||
gint npixels_to_free = 0;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GDK_IS_COLORMAP (colormap));
|
||||
g_return_if_fail (pixels != NULL);
|
||||
|
||||
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
|
||||
|
||||
if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
|
||||
(colormap->visual->type != GDK_VISUAL_GRAYSCALE))
|
||||
return;
|
||||
|
||||
pixels_to_free = g_new (gulong, npixels);
|
||||
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
gulong pixel = pixels[i];
|
||||
|
||||
if (private->info[pixel].ref_count)
|
||||
{
|
||||
private->info[pixel].ref_count--;
|
||||
|
||||
if (private->info[pixel].ref_count == 0)
|
||||
{
|
||||
pixels_to_free[npixels_to_free++] = pixel;
|
||||
if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
|
||||
g_hash_table_remove (private->hash, &colormap->colors[pixel]);
|
||||
private->info[pixel].flags = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (npixels_to_free && !private->private_val && !private->screen->closed)
|
||||
XFreeColors (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap,
|
||||
pixels_to_free, npixels_to_free, planes);
|
||||
g_free (pixels_to_free);
|
||||
}
|
||||
|
||||
/* This is almost identical to gdk_colors_free.
|
||||
* Keep them in sync!
|
||||
*/
|
||||
|
||||
/**
|
||||
* gdk_colormap_free_colors:
|
||||
* @colormap: a #GdkColormap.
|
||||
@ -1039,17 +909,16 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
|
||||
* @colors: The color values to allocate. On return, the pixel
|
||||
* values for allocated colors will be filled in.
|
||||
* @n_colors: The number of colors in @colors.
|
||||
* @writeable: If %TRUE, the colors are allocated writeable
|
||||
* (their values can later be changed using gdk_color_change()).
|
||||
* Writeable colors cannot be shared between applications.
|
||||
* @writeable: this parameter has no effect, and it's here for mere
|
||||
* compatibility.
|
||||
* @best_match: If %TRUE, GDK will attempt to do matching against
|
||||
* existing colors if the colors cannot be allocated as requested.
|
||||
* @success: An array of length @ncolors. On return, this
|
||||
* indicates whether the corresponding color in @colors was
|
||||
* successfully allocated or not.
|
||||
*
|
||||
*
|
||||
* Allocates colors from a colormap.
|
||||
*
|
||||
*
|
||||
* Return value: The number of colors that were not successfully
|
||||
* allocated.
|
||||
**/
|
||||
@ -1208,44 +1077,6 @@ gdk_colormap_query_color (GdkColormap *colormap,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_color_change:
|
||||
* @colormap: a #GdkColormap.
|
||||
* @color: a #GdkColor, with the color to change
|
||||
* in the <structfield>pixel</structfield> field,
|
||||
* and the new value in the remaining fields.
|
||||
*
|
||||
* Changes the value of a color that has already
|
||||
* been allocated. If @colormap is not a private
|
||||
* colormap, then the color must have been allocated
|
||||
* using gdk_colormap_alloc_colors() with the
|
||||
* @writeable set to %TRUE.
|
||||
*
|
||||
* Return value: %TRUE if the color was successfully changed.
|
||||
**/
|
||||
gboolean
|
||||
gdk_color_change (GdkColormap *colormap,
|
||||
GdkColor *color)
|
||||
{
|
||||
GdkColormapPrivateX11 *private;
|
||||
XColor xcolor;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
xcolor.pixel = color->pixel;
|
||||
xcolor.red = color->red;
|
||||
xcolor.green = color->green;
|
||||
xcolor.blue = color->blue;
|
||||
xcolor.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
private = GDK_COLORMAP_PRIVATE_DATA (colormap);
|
||||
if (!private->screen->closed)
|
||||
XStoreColor (GDK_SCREEN_XDISPLAY (private->screen), private->xcolormap, &xcolor);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_colormap_foreign_new:
|
||||
* @visual: a #GdkVisual
|
||||
|
Loading…
Reference in New Issue
Block a user