Example #1
0
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;
}
Example #2
0
GpImage * 
gp_image_new_from_pixmap ( GdkPixmap* pixmap, GdkRectangle *rect, gboolean has_alpha  )
{
    GpImage			*image;
	GdkRectangle	r;

	g_return_val_if_fail ( GDK_IS_PIXMAP (pixmap), NULL);

	if ( rect == NULL )
	{
		r.x = r.y = 0;
		gdk_drawable_get_size ( pixmap, &r.width, &r.height );
	}
	else
	{
		r.x		=   rect->x;
		r.y		=   rect->y;
		r.width =   rect->width;
		r.height=   rect->height;
	}
	
	image   = gp_image_new( r.width, r.height, has_alpha );
	g_return_val_if_fail ( image != NULL, NULL);
	
    gdk_pixbuf_get_from_drawable(
                image->priv->pixbuf,
                pixmap,
                gdk_drawable_get_colormap ( pixmap ), 
                r.x, r.y,
                0, 0,
                r.width, r.height);
    return image;
}
Example #3
0
/**
 * gdk_pixmap_get_gl_pixmap:
 * @pixmap: a #GdkPixmap.
 *
 * Returns the #GdkGLPixmap held by the @pixmap.
 *
 * Return value: the #GdkGLPixmap.
 **/
GdkGLPixmap *
gdk_pixmap_get_gl_pixmap (GdkPixmap *pixmap)
{
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);

  return g_object_get_qdata (G_OBJECT (pixmap), quark_gl_pixmap);
}
Example #4
0
/**
 * gdk_pixmap_is_gl_capable:
 * @pixmap: a #GdkPixmap.
 *
 * Returns whether the @pixmap is OpenGL-capable.
 *
 * Return value: TRUE if the @pixmap is OpenGL-capable, FALSE otherwise.
 **/
gboolean
gdk_pixmap_is_gl_capable (GdkPixmap *pixmap)
{
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), FALSE);

  return g_object_get_qdata (G_OBJECT (pixmap), quark_gl_pixmap) != NULL ? TRUE : FALSE;
}
Example #5
0
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;
}
Example #6
0
void
vkb_button_set_bg_pixmap(GtkWidget *widget, GdkPixmap *pixmap)
{
	GtkVkbButton *button;

	g_return_if_fail(GTK_IS_VKB_BUTTON(widget));

	button = GTK_VKB_BUTTON(widget);

	if (button->bg_pixmap != NULL) {
		g_object_unref(button->bg_pixmap);
	}

	if (GDK_IS_PIXMAP(pixmap))
		button->bg_pixmap = g_object_ref(pixmap);
	else
		button->bg_pixmap = NULL;

	if (widget->window)
		gdk_window_set_back_pixmap(widget->window, pixmap, FALSE);
}
Example #7
0
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;
}
Example #8
0
/**
 * gdk_pixmap_set_gl_capability:
 * @pixmap: the #GdkPixmap to be used as the rendering area.
 * @glconfig: a #GdkGLConfig.
 * @attrib_list: this must be set to NULL or empty (first attribute of None).
 *
 * Set the OpenGL-capability to the @pixmap.
 * This function creates a new #GdkGLPixmap held by the @pixmap.
 * attrib_list is currently unused. This must be set to NULL or empty
 * (first attribute of None).
 *
 * Return value: the #GdkGLPixmap used by the @pixmap if it is successful,
 *               NULL otherwise.
 **/
GdkGLPixmap *
gdk_pixmap_set_gl_capability (GdkPixmap   *pixmap,
                              GdkGLConfig *glconfig,
                              const int   *attrib_list)
{
  GdkGLPixmap *glpixmap;

  GDK_GL_NOTE_FUNC ();

  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);
  g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), NULL);

  if (quark_gl_pixmap == 0)
    quark_gl_pixmap = g_quark_from_static_string (quark_gl_pixmap_string);

  /* If already set */
  glpixmap = g_object_get_qdata (G_OBJECT (pixmap), quark_gl_pixmap);
  if (glpixmap != NULL)
    return glpixmap;

  /*
   * Create GdkGLPixmap
   */

  glpixmap = gdk_gl_pixmap_new (glconfig, pixmap, attrib_list);
  if (glpixmap == NULL)
    {
      g_warning ("cannot create GdkGLPixmap\n");
      return NULL;
    }

  g_object_set_qdata_full (G_OBJECT (pixmap), quark_gl_pixmap, glpixmap,
                           (GDestroyNotify) g_object_unref);

  return glpixmap;
}
Example #9
0
/**
 * gdk_gl_pixmap_new:
 * @glconfig: a #GdkGLConfig.
 * @pixmap: the #GdkPixmap to be used as the rendering area.
 * @attrib_list: this must be set to NULL or empty (first attribute of None).
 *
 * Creates an off-screen rendering area.
 * attrib_list is currently unused. This must be set to NULL or empty
 * (first attribute of None). See GLX 1.3 spec.
 *
 * Return value: the new #GdkGLPixmap.
 **/
GdkGLPixmap *
gdk_gl_pixmap_new (GdkGLConfig *glconfig,
                   GdkPixmap   *pixmap,
                   const int   *attrib_list)
{
  GdkGLPixmap *glpixmap;
  GdkGLPixmapImplX11 *impl;

  Display *xdisplay;
  XVisualInfo *xvinfo;
  Pixmap xpixmap;
  GLXPixmap glxpixmap;

  Window root_return;
  int x_return, y_return;
  unsigned int width_return, height_return;
  unsigned int border_width_return;
  unsigned int depth_return;

  GdkGL_GLX_MESA_pixmap_colormap *mesa_ext;

  GDK_GL_NOTE_FUNC ();

  g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_X11 (glconfig), NULL);
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);

  xdisplay = GDK_GL_CONFIG_XDISPLAY (glconfig);
  xvinfo = GDK_GL_CONFIG_XVINFO (glconfig);

  /*
   * Get X Pixmap.
   */

  xpixmap = GDK_DRAWABLE_XID (GDK_DRAWABLE (pixmap));

  /*
   * Check depth of the X pixmap.
   */

  if (!XGetGeometry (xdisplay, xpixmap,
                     &root_return,
                     &x_return, &y_return,
                     &width_return, &height_return,
                     &border_width_return,
                     &depth_return))
    return NULL;

  if (depth_return != (unsigned int) xvinfo->depth)
    return NULL;

  /*
   * Create GLXPixmap.
   */

  mesa_ext = gdk_gl_get_GLX_MESA_pixmap_colormap (glconfig);
  if (mesa_ext)
    {
      /* If GLX_MESA_pixmap_colormap is supported. */

      GDK_GL_NOTE_FUNC_IMPL ("glXCreateGLXPixmapMESA");

      glxpixmap = mesa_ext->glXCreateGLXPixmapMESA (xdisplay,
                                                    xvinfo,
                                                    xpixmap,
                                                    GDK_GL_CONFIG_XCOLORMAP (glconfig));
    }
  else
    {
      GDK_GL_NOTE_FUNC_IMPL ("glXCreateGLXPixmap");

      glxpixmap = glXCreateGLXPixmap (xdisplay,
                                      xvinfo,
                                      xpixmap);
    }

  if (glxpixmap == None)
    return NULL;

  /*
   * Instantiate the GdkGLPixmapImplX11 object.
   */

  glpixmap = g_object_new (GDK_TYPE_GL_PIXMAP_IMPL_X11, NULL);
  impl = GDK_GL_PIXMAP_IMPL_X11 (glpixmap);

  glpixmap->drawable = GDK_DRAWABLE (pixmap);
  g_object_add_weak_pointer (G_OBJECT (glpixmap->drawable),
                             (gpointer *) &(glpixmap->drawable));

  impl->glxpixmap = glxpixmap;

  impl->glconfig = glconfig;
  g_object_ref (G_OBJECT (impl->glconfig));

  impl->is_destroyed = FALSE;

  return glpixmap;
}
Example #10
0
/*
 * attrib_list is currently unused. This must be set to NULL or empty
 * (first attribute of None). See GLX 1.3 spec.
 */
GdkGLPixmap *
gdk_gl_pixmap_new (GdkGLConfig *glconfig,
                   GdkPixmap   *pixmap,
                   const int   *attrib_list)
{
  GdkGLPixmap *glpixmap;
  GdkGLPixmapImplWin32 *impl;

  gint width, height;
  gint depth;
  GdkPixmap *pixmap_gl = NULL;

  HBITMAP hbitmap_gl;
  HDC hdc_gl = NULL;
  PIXELFORMATDESCRIPTOR pfd;
  int pixel_format;

  HBITMAP hbitmap_gdk;
  HDC hdc_gdk = NULL;

  GDK_GL_NOTE_FUNC ();

  g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_WIN32 (glconfig), NULL);
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);

  /*
   * Create offscreen rendering area.
   */

  gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
  depth = gdk_drawable_get_depth (GDK_DRAWABLE (pixmap));

  pixmap_gl = gdk_pixmap_new (NULL, width, height, depth);
  if (pixmap_gl == NULL)
    goto FAIL;

  /*
   * Source (OpenGL) DIB
   */

  hbitmap_gl = (HBITMAP) gdk_win32_drawable_get_handle (GDK_DRAWABLE (pixmap_gl));

  /* Create a memory DC. */
  hdc_gl = CreateCompatibleDC (NULL);
  if (hdc_gl == NULL)
    {
      g_warning ("cannot create a memory DC");
      goto FAIL;
    }

  /* Select the bitmap. */
  if (SelectObject (hdc_gl, hbitmap_gl) == NULL)
    {
      g_warning ("cannot select DIB");
      goto FAIL;
    }

  /*
   * Choose pixel format.
   */

  pfd = *(GDK_GL_CONFIG_PFD (glconfig));
  /* Draw to bitmap */
  pfd.dwFlags &= ~PFD_DRAW_TO_WINDOW;
  pfd.dwFlags |= PFD_DRAW_TO_BITMAP;

  /* Request pfd.cColorBits should exclude alpha bitplanes. */
  pfd.cColorBits = pfd.cRedBits + pfd.cGreenBits + pfd.cBlueBits;

  GDK_GL_NOTE_FUNC_IMPL ("ChoosePixelFormat");

  pixel_format = ChoosePixelFormat (hdc_gl, &pfd);
  if (pixel_format == 0)
    {
      g_warning ("cannot choose pixel format");
      goto FAIL;
    }

  /*
   * Set pixel format.
   */

  GDK_GL_NOTE_FUNC_IMPL ("SetPixelFormat");

  if (!SetPixelFormat (hdc_gl, pixel_format, &pfd))
    {
      g_warning ("cannot set pixel format");
      goto FAIL;
    }

  DescribePixelFormat (hdc_gl, pixel_format, sizeof (pfd), &pfd);

  GDK_GL_NOTE (MISC, g_message (" -- impl->pixel_format = 0x%x", pixel_format));
  GDK_GL_NOTE (MISC, _gdk_win32_gl_print_pfd (&pfd));

  /*
   * Destination (GDK) DIB
   */

  hbitmap_gdk = (HBITMAP) gdk_win32_drawable_get_handle (GDK_DRAWABLE (pixmap));

  /* Create a memory DC. */
  hdc_gdk = CreateCompatibleDC (hdc_gl);
  if (hdc_gdk == NULL)
    {
      g_warning ("cannot create a memory DC");
      goto FAIL;
    }

  /*
   * Instantiate the GdkGLPixmapImplWin32 object.
   */

  glpixmap = g_object_new (GDK_TYPE_GL_PIXMAP_IMPL_WIN32, NULL);
  impl = GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap);

  glpixmap->drawable = GDK_DRAWABLE (pixmap);
  g_object_add_weak_pointer (G_OBJECT (glpixmap->drawable),
                             (gpointer *) &(glpixmap->drawable));

  impl->pixmap_gl = pixmap_gl;

  impl->width = width;
  impl->height = height;

  impl->pfd = pfd;
  impl->pixel_format = pixel_format;

  impl->glconfig = glconfig;
  g_object_ref (G_OBJECT (impl->glconfig));

  impl->hdc_gl = hdc_gl;

  impl->hdc_gdk = hdc_gdk;
  impl->hbitmap_gdk = hbitmap_gdk;

  impl->is_destroyed = FALSE;

  return glpixmap;

 FAIL:

  if (hdc_gdk != NULL)
    DeleteDC (hdc_gdk);

  if (hdc_gl != NULL)
    DeleteDC (hdc_gl);

  if (pixmap_gl != NULL)
    g_object_unref (G_OBJECT (pixmap_gl));

  return NULL;  
}