Re: selection rectangle



This is exactly what I did for drawing a selection box in the preview area of a
scanner interface.

I first initialized a "graphic context" this way:

 invert_gc = gdk_gc_new(image_area->window);
 gdk_gc_copy(invert_gc,image_area->style->black_gc);
 gdk_gc_set_function(invert_gc,GDK_INVERT);

... then draw / undraw with something like this:

 gdk_draw_rectangle(pixmap,invert_gc,FALSE,
  last_rect.x, last_rect.y,
  last_rect.width, last_rect.height);

An other option would be to dig in the Gimp code for the "marching ants", but
I'm not sure it's simple.

Hoping this helps.

Regards,

Patrice St-Gelais
____________________________________

Johan Bondeson a écrit :

I saw an example somewere were the selection rectangle was drawn just by
inverting the pixels that the rectangle consisted of. To erease the
rectangle it was only inverted once again and the original colors were back,
however I think this was a Windows (excuse the bad language) and I have no
idea how to do this using GTK.

----Original Message Follows----
From: Rok Roskar <rroskar artsci wustl edu>
To: <gtk-app-devel-list gnome org>
Subject: selection rectangle
Date: Sat, 12 Jan 2002 13:43:16 -0600 (CST)

is there an easy way to draw a selection rectangle (one that the user can
drag) onto a pixmap in drawing_area? The only way I can come up with is
one where I draw a rectangle each time the user movesthe mouse, but that
means  that Ihave to erase the one previously drawn and it's becoming
rather cumbersome.... any ideas?

Rok

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]