eb0536 | 2005-11-05 | Henrik Grubbström (Grubba) | | /* -*- C -*- */
|
1a0554 | 2005-07-28 | Martin Nilsson | | class GDK2.Pixmap;
inherit GDK2.Drawable;
//! This class creates a GDK2.Pixmap from either an GDK2.Image or
//! Image.image object (or a numeric ID, see your X-manual for XIDs).
//! <p> The GDK2.Pixmap object can be used in a lot
//! of different GTK widgets. The most notable is the W(Pixmap)
//! widget.</p>
//!
//! NOIMG
%{
#ifdef __NT__
|
acacdd | 2008-07-19 | Martin Stjernholm | | #include <gdk/gdkwin32.h>
|
1a0554 | 2005-07-28 | Martin Nilsson | | #else
#include <gdk/gdkx.h>
#endif
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | GdkImage *pgtk2_pixmap_setup(struct object *o, int *free)
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
if (get_gdkobject(o,image))
return get_gdkobject(o,image);
else {
*free=1;
return gdkimage_from_pikeimage(o,GDK_IMAGE_FASTEST,0);
}
}
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | void pgtk2__pixmap_draw(GdkImage *i)
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
GdkGC *gc;
if (THIS->extra_data)
gc=THIS->extra_data;
else
|
3d7663 | 2005-11-03 | Lance Dillon | | THIS->extra_data=gc=gdk_gc_new(GDK_DRAWABLE(THIS->obj));
gdk_draw_image(GDK_DRAWABLE(THIS->obj),gc,i,0,0,0,0,
|
1a0554 | 2005-07-28 | Martin Nilsson | | i->width,i->height);
}
%}
void create(int|object image)
//! Create a new GDK2.Pixmap object.
//! Argument is a GDK2.Image object or a Image.Image object
{
GdkImage *i;
int f=0;
struct object *o;
|
3d7663 | 2005-11-03 | Lance Dillon | | GdkPixmap *gp;
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_setup();
pgtk2_verify_not_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | |
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if (TYPEOF(Pike_sp[-args]) == PIKE_T_OBJECT) {
|
1a0554 | 2005-07-28 | Martin Nilsson | | get_all_args("create",args,"%o",&o);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | i=pgtk2_pixmap_setup(o,&f);
|
1a0554 | 2005-07-28 | Martin Nilsson | |
|
3d7663 | 2005-11-03 | Lance Dillon | | gp=gdk_pixmap_new(0,i->width,i->height,i->depth);
THIS->obj=G_OBJECT(gp);
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (!THIS->obj) {
if (f)
g_object_unref(i);
Pike_error("Failed to create pixmap.\n");
}
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2__pixmap_draw(i);
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (f)
g_object_unref(i);
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | } else if (args && TYPEOF(Pike_sp[-1]) == PIKE_T_INT) {
|
3d7663 | 2005-11-03 | Lance Dillon | | gp=gdk_pixmap_foreign_new(Pike_sp[-1].u.integer);
THIS->obj=G_OBJECT(gp);
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (!THIS->obj)
Pike_error("Failed to find remote pixmap\n");
}
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
pgtk2__init_this_object();
|
1a0554 | 2005-07-28 | Martin Nilsson | | }
void set(GDK2.Image|Image.Image image)
//! Argument is a GDK2.Image object or an Image.image object.
//! It is much faster to use an gdkImage object, especially one
//! allocated in shared memory. This is only an issue if you are
//! going to change the contents of the pixmap often, toggling between
//! a small number of images.
{
struct object *o;
int f=0;
GdkImage *i;
get_all_args("set", args, "%o", &o );
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2__pixmap_draw(i=pgtk2_pixmap_setup(o,&f));
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (f)
g_object_unref(i);
RETURN_THIS();
}
void destroy()
{
|
2edd4f | 2008-01-30 | Per Hedbor | | /*
if (THIS->obj)
g_object_unref(THIS->obj);
THIS->obj=0;
Done by g.object
*/
|
1a0554 | 2005-07-28 | Martin Nilsson | |
if (THIS->extra_data)
g_object_unref(THIS->extra_data);
THIS->extra_data=0;
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
3d7663 | 2005-11-03 | Lance Dillon | | push_int(0);
|
1a0554 | 2005-07-28 | Martin Nilsson | | }
void ref()
//! Ref this object.
{
g_object_ref(THIS->obj);
RETURN_THIS();
}
void unref()
//! Unref this object.
{
g_object_unref(THIS->obj);
RETURN_THIS();
}
|