int clip_GTK_DRAGSETICONPIXMAP(ClipMachine * cm) { C_object *ccontext = _fetch_co_arg(cm); C_object *ccolormap = _fetch_cobject(cm, _clip_spar(cm, 2)); C_object *cpixmap = _fetch_cobject(cm, _clip_spar(cm, 3)); C_object *cmask = _fetch_cobject(cm, _clip_spar(cm, 4)); gint hot_x = _clip_parni(cm, 5); gint hot_y = _clip_parni(cm, 6); if (!ccontext || ccontext->type != GDK_TYPE_DRAG_CONTEXT) goto err; CHECKCOBJ(ccolormap, GDK_IS_COLORMAP(ccolormap->object)); CHECKCOBJ(cpixmap, GDK_IS_PIXMAP(cpixmap->object)); CHECKCOBJ(cmask, GDK_IS_BITMAP(cmask)); CHECKARG(5, NUMERIC_t); CHECKARG(6, NUMERIC_t); gtk_drag_set_icon_pixmap((GdkDragContext*)ccontext->object, GDK_COLORMAP(ccolormap->object), GDK_PIXMAP(cpixmap->object), GDK_BITMAP(cmask->object), hot_x, hot_y ); return 0; err: return 1; }
/** * gdk_pixbuf_render_pixmap_and_mask_for_colormap: * @pixbuf: A pixbuf. * @colormap: A #GdkColormap * @pixmap_return: Location to store a pointer to the created pixmap, * or %NULL if the pixmap is not needed. * @mask_return: Location to store a pointer to the created mask, * or %NULL if the mask is not needed. * @alpha_threshold: Threshold value for opacity values. * * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return * and @mask_return arguments, respectively, and renders a pixbuf and its * corresponding tresholded alpha mask to them. This is merely a convenience * function; applications that need to render pixbufs with dither offsets or to * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha(). * * The pixmap that is created uses the #GdkColormap specified by @colormap. * This colormap must match the colormap of the window where the pixmap * will eventually be used or an error will result. * * If the pixbuf does not have an alpha channel, then *@mask_return will be set * to %NULL. **/ void gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, GdkColormap *colormap, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold) { GdkScreen *screen; g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); g_return_if_fail (GDK_IS_COLORMAP (colormap)); screen = gdk_colormap_get_screen (colormap); if (pixmap_return) { GdkGC *gc; *pixmap_return = gdk_pixmap_new (gdk_screen_get_root_window (screen), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_colormap_get_visual (colormap)->depth); gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap); gc = _gdk_drawable_get_scratch_gc (*pixmap_return, FALSE); /* If the pixbuf has an alpha channel, using gdk_pixbuf_draw would give * random pixel values in the area that are within the mask, but semi- * transparent. So we treat the pixbuf like a pixbuf without alpha channel; * see bug #487865. */ if (gdk_pixbuf_get_has_alpha (pixbuf)) gdk_draw_rgb_32_image (*pixmap_return, gc, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_rowstride (pixbuf)); else gdk_draw_pixbuf (*pixmap_return, gc, pixbuf, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, 0, 0); } if (mask_return) { if (gdk_pixbuf_get_has_alpha (pixbuf)) { *mask_return = gdk_pixmap_new (gdk_screen_get_root_window (screen), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), 1); gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), alpha_threshold); } else *mask_return = NULL; } }
void gdk_screen_set_default_colormap (GdkScreen *screen, GdkColormap *colormap) { GdkColormap *old_colormap; ENTER(); g_return_if_fail(GDK_IS_SCREEN(screen)); g_return_if_fail(GDK_IS_COLORMAP(colormap)); old_colormap = default_colormap; default_colormap = g_object_ref(colormap); if (old_colormap) { g_object_unref(old_colormap); } LEAVE(); }
void gdk_screen_set_default_colormap (GdkScreen *screen, GdkColormap *colormap) { GdkColormap *old_colormap; g_return_if_fail (screen == _gdk_screen); g_return_if_fail (GDK_IS_COLORMAP (colormap)); old_colormap = default_colormap; default_colormap = g_object_ref (colormap); if (old_colormap) g_object_unref (old_colormap); }
GdkColor query_color (GtkWidget * win, GdkColor c) { GdkColor real_color; GdkColormap *cmap; cmap = gtk_widget_get_colormap (GTK_WIDGET (win)); if (cmap && GDK_IS_COLORMAP (cmap)) { gdk_colormap_query_color (cmap, c.pixel, &real_color); return real_color; } else { return c; } }
int clip_GTK_DRAGSOURCESETICON(ClipMachine * cm) { C_widget *cwid = _fetch_cw_arg(cm); C_object *ccolormap = _fetch_cobject(cm, _clip_spar(cm, 2)); C_object *cpixmap = _fetch_cobject(cm, _clip_spar(cm, 3)); C_object *cmask = _fetch_cobject(cm, _clip_spar(cm, 4)); CHECKCWID(cwid, GTK_IS_WIDGET); CHECKCOBJ(ccolormap, GDK_IS_COLORMAP(ccolormap->object)); CHECKCOBJ(cpixmap, GDK_IS_PIXMAP(cpixmap->object)); CHECKCOBJ(cmask, GDK_IS_BITMAP(cmask)); gtk_drag_source_set_icon(GTK_WIDGET(cwid->widget), GDK_COLORMAP(ccolormap->object), GDK_PIXMAP(cpixmap->object), GDK_BITMAP(cmask->object)); return 0; err: return 1; }
int clip_GTK_DRAGSETDEFAULTICON(ClipMachine * cm) { C_object *ccolormap = _fetch_co_arg(cm); C_object *cpixmap = _fetch_cobject(cm, _clip_spar(cm, 2)); C_object *cmask = _fetch_cobject(cm, _clip_spar(cm, 3)); gint hot_x = _clip_parni(cm, 4); gint hot_y = _clip_parni(cm, 5); CHECKCOBJ(ccolormap, GDK_IS_COLORMAP(ccolormap->object)); CHECKCOBJ(cpixmap, GDK_IS_PIXMAP(cpixmap->object)); CHECKCOBJ(cmask, GDK_IS_PIXMAP(cmask)); CHECKARG(5, NUMERIC_t); CHECKARG(4, NUMERIC_t); gtk_drag_set_default_icon(GDK_COLORMAP(ccolormap->object), GDK_PIXMAP(cpixmap->object), GDK_BITMAP(cmask->object), hot_x, hot_y ); return 0; err: return 1; }