event queue interrupt



Greetings all,
 
I am new to GTK. So far, lots of fun. I am developing a small application to view large images. One feature includes using a mouse button to pan the image within the viewing window. I have one problem.
   
1) On the release of the mouse button, I would like to interrupt the event queue, execute only the button release handler, and cancel all other remaining events. It is preferable if an event was being handled when the button was released, that the event be allowed to complete successfully.
 
The basic logic follows:
 
/* start snippet */
gint top,left,old_x,old_y,x,y;
 
guchar *imageArray;
 
redrawImage() {
    gtk_draw_rgb_image(...,top,left,...,imageArray,...);
}
 
moveImage(x,y) {
    left = adjust_left_by_x();
    top = adjust_top_by_y();
    redrawImage();
}
 
delete_event();
 
expose_event() {
    redrawImage();
}
 
button_press_event() {
    old_x = x = event->x;
    old_y = y = event->y;
}
 
motion_notify_event() {
    moveImage((event->x - old_x),(event->y - old_y);
    old_x = x;
    old_y = y;
 
button_release_event() {
    /*
     * How do I interrupt the event queue and process only this callback,
     * as soon as the button is released?
     */
    moveImage((event->x - old_x),(event->y - old_y);
}
 
main() {
    /* gtk init stuff, create a new window */
 
    drawArea = gtk_drawing_area_new();
    gtk_signal_connect(GTK_OBJECT(drawArea), "expose_event",
        GTK_SIGNAL_FUNC(expose_event), NULL);
    gtk_signal_connect(GTK_OBJECT(drawArea), "button_press_event",
        GTK_SIGNAL_FUNC(button_press_event), NULL);
    gtk_signal_connect(GTK_OBJECT(drawArea), "button_release_event",
        GTK_SIGNAL_FUNC(button_release_event), NULL);
    gtk_signal_connect(GTK_OBJECT(drawArea), "motion_notify_event",
        GTK_SIGNAL_FUNC(motion_notify_event), NULL);
 
    gtk_widget_set_events(drawArea,GDK_EXPOSURE_MASK
                                |GDK_BUTTON_PRESS_MASK
                                |GDK_BUTTON_RELEASE_MASK
                                |GDK_POINTER_MOTION_MASK);
    /* pack the drawArea into the window, show all, & run gtk_main(); */
}
/* end snippet */
 
Thanks,
Kevin Mullican
 


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