void handle_event(lstate *state) { switch(state->event.type) { case GR_EVENT_TYPE_EXPOSURE: handle_exposure_event(state); break; case GR_EVENT_TYPE_BUTTON_DOWN: handle_mouse_event(state); break; case GR_EVENT_TYPE_CLOSE_REQ: break; case GR_EVENT_TYPE_SCREENSAVER: handle_screensaver_event(state); break; case GR_EVENT_TYPE_TIMER: handle_timer_event(state); break; case GR_EVENT_TYPE_NONE: case GR_EVENT_TYPE_CHLD_UPDATE: break; default: GrError("Got unknown event type %d\n", state->event.type); break; } }
/** * Runs this model. * * @param self the model. * @param herds a herd list. * @param zones a zone list. * @param event the event that caused the model to run. * @param rng a random number generator. * @param queue for any new events the model creates. */ void run (struct naadsm_model_t_ *self, HRD_herd_list_t * herds, ZON_zone_list_t * zones, EVT_event_t * event, RAN_gen_t * rng, EVT_event_queue_t * queue) { #if DEBUG g_debug ("----- ENTER run (%s)", MODEL_NAME); #endif switch (event->type) { case EVT_BeforeAnySimulations: handle_before_any_simulations_event (self, queue); break; case EVT_NewDay: handle_new_day_event (self); break; case EVT_Exposure: handle_exposure_event (self, &(event->u.exposure)); break; default: g_error ("%s has received a %s event, which it does not listen for. This should never happen. Please contact the developer.", MODEL_NAME, EVT_event_type_name[event->type]); } #if DEBUG g_debug ("----- EXIT run (%s)", MODEL_NAME); #endif }
void handle_event(nstate *state) { switch(state->event.type) { case GR_EVENT_TYPE_EXPOSURE: handle_exposure_event(state); break; case GR_EVENT_TYPE_BUTTON_DOWN: handle_mouse_event(state); break; case GR_EVENT_TYPE_KEY_DOWN: handle_keyboard_event(state); break; case GR_EVENT_TYPE_CLOSE_REQ: state->state = STATE_EXIT; break; case GR_EVENT_TYPE_TIMEOUT: break; default: fprintf(stderr, "Unhandled event type %d\n", state->event.type); break; } }