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 46 47 48 49 50 51 52 53 54 55 56 57
|
PROGRAM(GdkRectangle);
FUNCTION(create, "function(int,int,int,int:void)");
NAME_ARGS(x,y,width,height);
{
GdkRectangle *r;
THIS->obj = (void *)(r=malloc(sizeof(GdkRectangle)));
get_all_args( "GDK.Rectangle", args, "%d%d%d%d", &r->x, &r->y,
&r->width, &r->height );
}
FUNCTION(set, "function(int,int,int,int:object)");
RETURNS(GDK.Rectangle);
NAME_ARGS(x,y,width,height);
{
GdkRectangle *r = (GdkRectangle *)THIS->obj;
get_all_args( "GDK.Rectangle->set", args, "%d%d%d%d", &r->x, &r->y,
&r->width, &r->height );
RETURN_THIS();
}
FUNCTION(cast, "function(string:mixed)");
// Normally used like (mapping)rectangle or (array)rectangle.
{
char *type;
GdkRectangle *r = (GdkRectangle *)THIS->obj;
get_all_args( "cast", args, "%s", &type );
if(!strcmp(type, "mapping"))
{
pop_n_elems(args);
push_text( "x" );
push_int( r->x );
push_text( "y" );
push_int( r->y );
push_text( "width" );
push_int( r->width );
push_text( "height" );
push_int( r->height );
f_aggregate_mapping( 8 );
} else if(!strcmp(type, "array")) {
pop_n_elems(args);
push_int( r->x );
push_int( r->y );
push_int( r->width );
push_int( r->height );
f_aggregate( 4 );
} else {
error("Cannot cast to %s.\n", type );
}
}
FUNCTION(destroy, "function(void:void)")
{
free(THIS->obj);
}
/* TODO: gdk_region_polygon (GdkPoint *points, ...*/
|