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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
PROGRAM(GdkDrawable);
#define TWIN ((GdkWindow *)THIS->obj)
#define GC(X) (get_gdkobject(X, GC))
FUNCTION(copy_area, "function(object,int,int,object,int,int,int,int:object)");
RETURNS(GDK.Widget);
ARGS(GDK.GC,int,int,GTK.Widget,int,int,int,int);
NAME_ARGS(gc,xdest,ydest,source,xsource,ysource,width,height);
// Copies the rectangle defined by xsource,ysource and width,height
// from the source widget, and places the results at xdest,ydest in
// the widget in which this function is called.
{
struct object *gc, *source;
GdkWindow *win;
int xd, yd, xs, ys, w, h;
get_all_args("copy_area",args, "%o%d%d%o%d%d%d%d",
&gc, &xd, &yd, &source, &xs, &ys, &w, &h);
if(get_gdkobject( source, Drawable ))
win = get_gdkobject( source, Drawable );
else
win = GTK_WIDGET( get_gtkobject( source ) )->window;
gdk_window_copy_area( TWIN, GC(gc), xd, yd, win, xs, ys, w, h);
RETURN_THIS();
}
FUNCTION(clear, "function(int|void,int|void,int|void,int|void:object)");
NAME_ARGS(x,y,width,height);
// either clears the rectangle defined by the arguments, of if no
// arguments are specified, the whole area
{
int x=0, y=0, w=0, h=0;
if(args==4)
get_all_args("clear", args, "%d%d%d%d", &x, &y, &w, &h);
if(h)
gdk_window_clear_area(TWIN, x,y,w,h);
else
gdk_window_clear(TWIN);
RETURN_THIS();
}
FUNCTION(draw_point, "function(object,int,int:object)");
ARGS(GDK.GC,int,int);
NAME_ARGS(gc,x,y);
// gc, x, y
// img_begin
// w = GTK.Drawing_area()->set_usize(10,10);
// delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) );
// delay: for(int x = 0; x<10; x++) w->draw_point(g, x, x);
// img_end
{
struct object *g;
int x, y;
get_all_args("draw_point", args, "%o%d%d", &g, &x, &y);
gdk_draw_point( TWIN, GC(g), x, y );
RETURN_THIS();
}
FUNCTION(draw_line, "function(object,int,int,int,int:object)");
ARGS(GDK.GC,int,int,int,int);
NAME_ARGS(gc,x1,y1,x2,y2);
// img_begin
// w = GTK.Drawing_area()->set_usize(100,100);
// delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) );
// delay: for(int x = 0; x<10; x++) w->draw_line(g,x*10,0,100-x*10,99);
// img_end
{
struct object *g;
int x, y, x2, y2;
get_all_args("draw_line", args, "%o%d%d%d%d", &g, &x, &y, &x2, &y2);
gdk_draw_line( TWIN, GC(g), x, y, x2, y2 );
RETURN_THIS();
}
FUNCTION(draw_rectangle, "function(object,int,int,int,int,int:object)");
ARGS(GDK.GC,int,int,int,int,int);
NAME_ARGS(gc,filledp,x1,y1,x2,y2);
// img_begin
// w = GTK.Drawing_area()->set_usize(100,100);
// delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) );
// delay: for(int x = 0; x<10; x++) w->draw_rectangle(g,0,x*10,0,100-x*10,99);
// img_end
// img_begin
// w = GTK.Drawing_area()->set_usize(100,100);
// delay: g = GDK.GC(w);
// delay: for(int x = 0; x<30; x++) {
// delay: g->set_foreground(GDK.Color(random(255),random(255),random(255)) );
// delay: w->draw_rectangle(g,1,x*10,0,100-x*10,99);
// delay: }
// img_end
{
struct object *g;
int f, x, y, x2, y2;
get_all_args("draw_rectangle",args, "%o%d%d%d%d%d",&g, &f, &x, &y, &x2, &y2);
gdk_draw_rectangle( TWIN, GC(g), f, x, y, x2, y2 );
RETURN_THIS();
}
FUNCTION(draw_arc, "function(object,int,int,int,int,int,int,int:object)");
ARGS(GDK.GC,int,int,int,int,int,int,int);
NAME_ARGS(gc,filledp,x1,y1,x2,y2,angle1,angle2);
{
struct object *g;
int f, x, y, x2, y2, a1, a2;
get_all_args("draw_arc",args, "%o%d%d%d%d%d%d%d",&g, &f, &x, &y, &x2, &y2,
&a1, &a2);
gdk_draw_arc( TWIN, GC(g), f, x, y, x2, y2, a1, a2 );
RETURN_THIS();
}
FUNCTION(draw_text, "function(object, object, int, int, string,int|void:object)");
ARGS(GDK.GC,GDK.Font,int,int,string,int|void);
NAME_ARGS(gc,font,x,y,text,forcewide);
// y is used as the baseline for the text.
// If forcewide is true, the string will be expanded to a wide string
// even if it is not already one. This is useful when writing text
// using either unicode or some other 16 bit font.
{
struct object *g,*f;
int x, y, force_wide=0;
struct pike_string *s;
char *swapped;
get_all_args("draw_text",args, "%o%o%d%d%W",&g,&f, &x, &y, &s);
if(swapped = get_swapped_string( s,args>5 ))
{
gdk_draw_text( TWIN,get_gdkobject(f,Font), get_gdkobject(g,GC),
x, y, swapped, s->len<<s->size_shift );
free(swapped);
} else {
gdk_draw_text( TWIN, get_gdkobject(f,Font), get_gdkobject(g,GC),
x, y, s->str, s->len<<s->size_shift );
}
RETURN_THIS();
}
FUNCTION(draw_pixmap, "function(object,object,int,int,int,int,int,int:object)");
ARGS(GDK.GC,GDK.Pixmap,int,int,int,int,int,int);
NAME_ARGS(gc,pixmap,xsrc,ysrc,xdest,ydest,width,height);
{
struct object *g, *p;
int xs, ys, xd, yd, w, h;
get_all_args("draw_pixmap",args,"%o%o%d%d%d%d%d%d",
&g,&p,&xs,&ys,&xd,&yd,&w,&h);
gdk_draw_pixmap(TWIN,GC(g),get_gdkobject(p,Drawable),xs,ys,xd,yd,w,h);
RETURN_THIS();
}
FUNCTION(draw_bitmap, "function(object,object,int,int,int,int,int,int:object)");
ARGS(GDK.GC,GDK.Bitmap,int,int,int,int,int,int);
NAME_ARGS(gc,bitmap,xsrc,ysrc,xdest,ydest,width,height);
{
struct object *g, *p;
int xs, ys, xd, yd, w, h;
get_all_args("draw_pixmap",args,"%o%o%d%d%d%d%d%d",
&g,&p,&xs,&ys,&xd,&yd,&w,&h);
/* Hm. gdk_draw_bitmap does not exist? Not that it matters. */
gdk_draw_pixmap(TWIN,GC(g),get_gdkobject(p,Drawable),xs,ys,xd,yd,w,h);
RETURN_THIS();
}
FUNCTION(draw_image, "function(object,object,int,int,int,int,int,int:object)");
ARGS(GDK.GC,GDK.Image,int,int,int,int,int,int);
NAME_ARGS(gc,image,xsrc,ysrc,xdest,ydest,width,height);
{
struct object *g, *p;
int xs, ys, xd, yd, w, h;
get_all_args("draw_pixmap",args,"%o%o%d%d%d%d%d%d",
&g,&p,&xs,&ys,&xd,&yd,&w,&h);
gdk_draw_image(TWIN,GC(g),get_gdkobject(p,Image),xs,ys,xd,yd,w,h);
RETURN_THIS();
}
FUNCTION(xsize, "function(void:int)");
{
int s;
gdk_window_get_size( TWIN, &s, 0 );
push_int( s );
}
FUNCTION(ysize, "function(void:int)");
{
int s;
gdk_window_get_size( TWIN, 0, &s );
push_int( s );
}
FUNCTION(get_geometry, "function(void:mapping(string:int))");
// Get width, height position and depth of the drawable.
{
int x=0, y=0;
int w=0, h=0, d=0;
gdk_window_get_geometry( TWIN, &x, &y, &w, &h, &d );
push_text("x"); push_int(x);
push_text("y"); push_int(y);
push_text("width"); push_int(w);
push_text("height"); push_int(h);
push_text("depth"); push_int(d);
f_aggregate_mapping( 10 );
}
|