File: gdkbitmap.pre

package info (click to toggle)
pigtk 1.1.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,248 kB
  • ctags: 104
  • sloc: ansic: 1,087; sh: 152; makefile: 121
file content (45 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* -*- c -*- */

PROGRAM(GdkBitmap);
INHERIT(GdkDrawable);
// A bitmap is a black and white pixmap. Most commonly used as masks
// for images, widgets and pixmaps.
FUNCTION(create, "function(int|object,int|void,string|void:void)")
ARGS(object(Image.image)|int,void|int,void|string);
NAME_ARGS(image|xsize, void|ysize, void|xbitmapdata);
// Create a new gdkBitmap object. 
// Argument is either an Image.image object, or {xsisze,ysize,xbitmapdata}.
{
  int x, y;
  char *d;
  if(args == 3)
  {
    get_all_args("create", args, "%d%d%s", &x, &y, &d );
  } else if(args==1) {
    struct object *o;
    get_all_args("create", args, "%o", &o );
    apply(o, "xsize", 0);  get_all_args("internal", 1, "%d", &x ); pop_stack();
    apply(o, "ysize", 0);  get_all_args("internal", 1, "%d", &y ); pop_stack();

    /* Now we have the image size.. Lets create the bitmap... */
    apply(o, "tobitmap", 0);
    get_all_args( "internal", 1, "%s", &d );
    args=2; /* evil me.. */
  } else {
    error("Wrong number of arguments to GDK.Bitmap()\n");
  }

  THIS->obj = (void *)gdk_bitmap_create_from_data(0, d, x, y);
  if(!THIS->obj)
    error("Failed to create bitmap\n");
  pop_n_elems(args);
}

FUNCTION(destroy, "function(void:void)");
// Destructor. Destroys the bitmap. This will free the bitmap on the X-server.
{
  if(THIS->obj)
    gdk_bitmap_unref( (void *)THIS->obj );
  THIS->obj = 0;
}