Re: How to move widgets around a window?
- From: John Cupitt <john cupitt ng-london org uk>
- To: "David J. Topper" <topper virginia edu>
- Cc: gtk-list gnome org
- Subject: Re: How to move widgets around a window?
- Date: Thu, 22 Feb 2001 11:11:54 +0000
"David J. Topper" wrote:
> Does anyone know / or have a good example of how to move (drag w/ mouse)
> widgets (eg., range widgets, buttons, boxes, etc ...) around a window?
> I've tried using the gnome canvas, but it doesn't work properly (ie.,
> event signals don't always make it to the widget).
Hi David,
I do this by putting my widgets in a gtk_layout. I attach a handle to
each widget, catch mouse events, and use gtk_layout_move() to shift them
around.
There are a couple of other tricks ... I do a gdk_pointer_grab to stop
other widgets activating as I track the drag, and I have a background
timer which pans the window if you drag off the left or right. You need
to think about how to change the size of the layout as widgets move too.
My app is up at:
http://www.vips.ecs.soton.ac.uk
if you want to try cutting out any code. Download vips-7.7.3.tar.gz, and
take a look at vips-7.7.3/contrib/ip/src_gtk2/columnset.c (the layout
window widget), and column.c (the thing that gets dragged around).
The only problem with this approach is flicker: gtk_layout_move() does a
queue_resize to move the widget, even if you are careful to put the
widget in its own event_box. As a result, the widget gets completely
redrawn on every move. I don't know a fix for this. Maybe you could
think about adding an outline drag option if you're trying to drag
'heavy' widgets around.
HTH, John
--
John Cupitt, john cupitt ng-london org uk, +44 (0)20 7747 2570
VASARI Lab, The National Gallery, Trafalgar Square, London, WC2N 5DN
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]