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
|
/*
***
***** LA CALLBACK QUI FAIT LE "BUTTON DOWN" ou "BUTTON UP"
***
*/
static void GraphInputCB ( Widget w, XtPointer *cdata,
XmDrawingAreaCallbackStruct *call_data )
{
MyStruct *idata = (MyStruct*)cdata ;
XEvent *event=(XEvent *)NULL ;
XButtonEvent *sevent=(XButtonEvent *)NULL ;
int dx, dy, Margin = 2 ;
if ( call_data->event == (XEvent *)NULL ) return ;
event = (XEvent *)call_data->event ;
if ( (event->type != ButtonPress) &&
(event->type != ButtonRelease) ) return ;
sevent = (XButtonEvent *)call_data->event ;
/*
==== ON DEBUTE UNE ACTION
*/
if ( sevent->type == ButtonPress )
{
if ( sevent->button == Button1 )
{
idata->Graph_Mode = MODE_TRACKING ;
}
else
if ( sevent->button == Button3 )
{
idata->Graph_Mode = MODE_ROI_DEFINITION ;
idata->loc_x1 = sevent->x ;
idata->loc_y1 = sevent->y ;
idata->loc_x2 = sevent->x ;
idata->loc_y2 = sevent->y ;
}
}
else
/*
==== ON TERMINE UNE ACTION
*/
if ( (sevent->type == ButtonRelease) && (idata->Graph_Mode != NO_MODE) )
{
if ( idata->Graph_Mode == MODE_ROI_DEFINITION )
{
dx = idata->loc_x2 - idata->loc_x1 ;
dy = idata->loc_y2 - idata->loc_y1 ;
if ( (abs(dx) <= Margin) && (abs(dy) <= Margin) )
Dezoom ( idata );
else
{
/* Efface le dernier rectangle */
Draw_Rectangle ( idata,
idata->loc_x1,
idata->loc_y1,
idata->loc_x2,
idata->loc_y2);
Zoom ( idata,
idata->loc_x1,
idata->loc_y1,
idata->loc_x2,
idata->loc_y2);
}
}
idata->Graph_Mode = NO_MODE ;
}
}
/*
***
***** LA CALLBACK QUI FAIT LE "MOVE" ou "DRAG"
***
*/
static void GraphMoveEH ( Widget w, XtPointer *cdata,
XEvent *sevent, Boolean *cont )
{
MyStruct *idata = (MyStruct*)cdata ;
int rx, ry, x, y, n ;
unsigned int keys;
Window root, child;
XQueryPointer ( xdata->GUI_Params.dpy, XtWindow(w),
&root, &child, &rx, &ry, &x, &y, &keys );
/*
--- AREA SELECTION : definition of zoom or selection area
*/
if ( idata->Graph_Mode == MODE_ROI_DEFINITION )
{
/* Efface l'ancien rectabgle */
Draw_Rectangle ( idata,
idata->loc_x1,
idata->loc_y1,
idata->loc_x2,
idata->loc_y2);
idata->loc_x2 = x ;
idata->loc_y2 = y ;
/* Trace le nouveau */
Draw_Rectangle ( idata,
idata->loc_x1,
idata->loc_y1,
idata->loc_x2,
idata->loc_y2);
}
/*
--- Affiche la position
*/
Affiche_Position (idata, x, y );
} |
Partager