Drawing Area Coordinates
- From: "James J Hayes III" <JJHayesIII hotmail com>
- To: <gtk-app-devel-list gnome org>
- Subject: Drawing Area Coordinates
- Date: Thu, 8 May 2003 16:14:26 -0400
I'm trying to show a tooltip on my drawing area that displays the
coordinates of the pointer. This is what I have:
static gint motion_notify_event( GtkWidget *widget,
GdkEventMotion *event )
{
gint x, y;
gfloat x2, y2;
char tmp[20];
GdkModifierType state;
if (event->is_hint)
gdk_window_get_pointer (event->window, &x, &y, &state);
else
{
x = event->x;
y = event->y;
state = event->state;
}
x2 = toscreenx(MaxDataX,MinDataX,MaxScreenX,MinScreenX,(gfloat)x);
y2 = toscreeny(MaxDataY,MinDataY,MaxScreenY,MinScreenY,(gfloat)y);
sscanf(tmp, "X=%f Y=%f",&x2,&y2);
fprintf(stderr," %s ",tmp);
gtk_tooltips_set_tip(GTK_TOOLTIPS(DataTT),drawing_area,tmp,NULL);
if(GTK_WIDGET_NO_WINDOW(drawing_area)) fprintf(stderr,"NO WINDOW!");
return TRUE;
}
I've added the events to the drawing_area, which is global....
Thanks in advance!
JJ Hayes
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]