Next: Source Code Example Up: Programmer's Reference for the Previous: Drawn Object Appearance

Event Handling

Interactive graphics is performed through the use of an event loop, which basically removes an event from the queue, processes it, then repeats. The events recognized are window movement and resize events, mouse, and keyboard events.


public  BOOLEAN  G_events_pending()

Returns TRUE if any graphics events are waiting in the queue to be processed.


public  Event_types  G_get_event(
    Gwindow        *window,
    int            *key_pressed )

Returns an event from the queue, and the window in which it occurred. If the event was a keyboard event, passes back the key involved. If there is no event in the queue, an event type of NO_EVENT is returned. Also, every fifth of a second a NO_EVENT is returned, to make it easy to perform such tasks as periodic update of the display. The length of this time interval is controlled by:


public  void  G_set_timer_event_interval(
    Real interval )

Sets the amount of time between artificially produced NO_EVENT events.


public  BOOLEAN  G_is_mouse_in_window(
    Gwindow window )

Returns TRUE if the mouse pointer is in the specified window.


public  BOOLEAN  G_get_mouse_position(
    Gwindow        window,
    int            *x_pixel_pos,
    int            *y_pixel_pos )

Gets the mouses position in the specified window. If the mouse is not within the window, a value of FALSE is returned. Otherwise, the position of the mouse in pixels relative to the bottom left corner of the window is passed back.


public  BOOLEAN  G_get_mouse_position_0_to_1(
    Gwindow        window,
    Real           *x_pos,
    Real           *y_pos )

Same as G_get_mouse_position(), but passes back the mouse position in the range 0 to 1, relative to the window width and height.


public  void  G_get_mouse_screen_position(
    int            *x_screen_pos,
    int            *y_screen_pos )

Same as G_get_mouse_position(), but passes back the mouse position relative to the bottom left corner of the entire screen.



Next: Source Code Example Up: Programmer's Reference for the Previous: Drawn Object Appearance


david@pet.mni.mcgill.ca
Fri Feb 17 15:39:43 EST 1995