Re: XForms: group selection

James D. Stegeman (stegeman@grc.nasa.gov)
Fri, 13 Aug 1999 14:25:38 -0400

# To subscribers of the xforms list from "James D. Stegeman" <stegeman@grc.nasa.gov> :

Steve,

It wasn't as bad as I thought. I had to implement a posthandler routine
for the objects in the group. I've included it below if anyone is
interested. You must first select the group you want to move by
clicking the middle mouse button on an element in the group. The
routine finds the first element in the group and saves it in 'junk'. To
move the group, you must then click the left mouse button over an
element in the group.

Regards,

Jim Stegeman

static int group_mov(FL_OBJECT *ob, int ev, FL_Coord mx, FL_Coord my,
int key, void *xev)
{
static int DRAGGING;
static FL_Coord ox=0, oy=0;
FL_Coord x, y, w, h, dx, dy;
static FL_OBJECT* junk;
float wx, wy, fx, fy;

if(ev == FL_PUSH)
{
switch(fl_mouse_button())
{
case FL_LEFT_MOUSE: ox = mx;
oy = my;
DRAGGING = 1;
break;
case FL_MIDDLE_MOUSE:

if(ob->objclass != FL_TEXT) return;
for(junk = ob; junk->objclass != FL_BEGIN_GROUP; junk = junk->prev) ;

junk = junk->next; /* the above for loop moves 1 element before the
first text element in the group */
/* this is a product of how xforms constructs the
object list and keeps track of */
/* groups, order of placement and event
handling */

break;
case FL_RIGHT_MOUSE: ;
printf("in group_mov... Right_Mouse has been clicked. Pop up menu's
now...\n");
default: ;
}

}
if(DRAGGING && xev != NULL && ev != FL_ENTER)
{
dx = mx - ox;
dy = my - oy;
ox = mx;
oy = my;
for(ob = junk; ob->objclass == FL_TEXT; ob=ob->next)
{
fl_get_object_geometry(ob, &x,&y,&w,&h);
if( (x+dx) < 0 || (x+w+dx) >= ob->form->w) dx = -dx;
if( (y+dy) < 0 || (y+h+dy) >= ob->form->h) dy = -dy;

x += dx;
y += dy;

fl_set_object_position(ob, x, y);
}
}

if(ev == FL_RELEASE) DRAGGING = 0;

}

James D. Stegeman wrote:
>
> # To subscribers of the xforms list from "James D. Stegeman" <stegeman@grc.nasa.gov> :
>
> Thanks for the tip. I'll give it a shot and let you know.
>
> Regards,
>
> Jim Stegeman
>
> Steve Lamont wrote:
> >
> > # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
> >
> > > Is there a way to capture the mouse click for a group and move the group
> > > around as part of an application?
> >
> > Not really. Probably the most straightforward way to do this is to
> > determine whether the object belongs to a group (by searching through
> > the object list -- you can chain through the object list by following
> > the `prev' and/or `next' pointers in the FL_OBJECT structure) and then
> > applying your transformation to all the members of the group.
> >
> > Not pretty but it should work.
> >
> > spl
> > _________________________________________________
> > To unsubscribe, send the message "unsubscribe" to
> > xforms-request@bob.usuhs.mil or see
> > http://bob.usuhs.mil/mailserv/xforms.html
> > XForms Home Page: http://bragg.phys.uwm.edu/xforms
> > List Archive: http://bob.usuhs.mil/mailserv/list-archives/
>
> --
> -------------------------------------------------------------------------------
>
> James D. Stegeman | This space for rent:
> NASA Glenn Research Center |
> Lewis Field |
> 21000 Brookpark Rd. MS 142-4 | Phone: 1-216-433-3389
> Cleveland, Ohio 44135 | Fax: 1-216-433-8000
> | e-mail: stegeman@grc.nasa.gov
> -------------------------------------------------------------------------------
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/

-- 
-------------------------------------------------------------------------------

James D. Stegeman | This space for rent: NASA Glenn Research Center | Lewis Field | 21000 Brookpark Rd. MS 142-4 | Phone: 1-216-433-3389 Cleveland, Ohio 44135 | Fax: 1-216-433-8000 | e-mail: stegeman@grc.nasa.gov ------------------------------------------------------------------------------- _________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuhs.mil or see http://bob.usuhs.mil/mailserv/xforms.html XForms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuhs.mil/mailserv/list-archives/