From eed0eb6a476d54ce19aeff137984aa981d9e3976 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 15 Jun 2010 00:59:57 -0700 Subject: Upgrading to iup 3.1 --- iup/test/canvas.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'iup/test/canvas.c') diff --git a/iup/test/canvas.c b/iup/test/canvas.c index d13945c..b01e5a6 100755 --- a/iup/test/canvas.c +++ b/iup/test/canvas.c @@ -58,19 +58,31 @@ static unsigned char pixmap_cursor [ ] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } ; -//#define USE_GTK +//#define USE_GDK /* draw a rectangle that has w=600 always, white background and a red X */ -#ifdef USE_GTK +#ifdef USE_GDK #include static void drawTest(Ihandle *ih, int posx) { GtkWidget* widget = (GtkWidget*)IupGetAttribute(ih, "WID"); - gdk_draw_arc (widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - TRUE, - 0, 0, widget->allocation.width, widget->allocation.height, - 0, 64 * 360); + GdkGC* gc = widget->style->fg_gc[GTK_WIDGET_STATE(widget)]; + int w, h; + GdkColor color; + + IupGetIntInt(ih, "DRAWSIZE", &w, &h); + + /* white background */ + color.red = 65535; color.green = 65535; color.blue = 65535; + gdk_gc_set_rgb_fg_color(gc, &color); + gdk_draw_rectangle(widget->window, gc, TRUE, 0, 0, w, h); + + /* red X */ + w = 600; /* virtual size */ + color.red = 65535; color.green = 0; color.blue = 0; + gdk_gc_set_rgb_fg_color(gc, &color); + gdk_draw_line(widget->window, gc, -posx, 0, w-posx, h); + gdk_draw_line(widget->window, gc, -posx, h, w-posx, 0); } #else #ifdef WIN32 @@ -232,6 +244,18 @@ static int wheel_cb(Ihandle *ih,float delta,int x,int y,char* status) static int motion_cb(Ihandle *ih,int x,int y,char* status) { printf("MOTION_CB(x=%d, y=%d [%s])\n",x,y, status); + + { + static int count=0; +#ifdef WIN32 + Sleep(1000); +#else + sleep(1); //or do anything that takes some time +#endif + count++; + printf("count(%d)\n",count); + } + return IUP_DEFAULT; } @@ -295,7 +319,7 @@ void CanvasTest(void) IupSetCallback(canvas, "MAP_CB", (Icallback)map_cb); IupSetCallback(canvas, "KEYPRESS_CB", (Icallback)keypress_cb); - IupSetCallback(canvas, "K_ANY", (Icallback)k_any); +// IupSetCallback(canvas, "K_ANY", (Icallback)k_any); IupSetCallback(canvas, "HELP_CB", (Icallback)help_cb); IupSetCallback(canvas, "GETFOCUS_CB", (Icallback)getfocus_cb); -- cgit v1.2.3