Beispiel #1
0
// Draw the warning on the screen
void roadmap_alerter_display(void){
   if (alert_should_be_visible) {
      if (the_active_alert.active_alert_id == -1){
         return;
      }
      if ((!alert_active) || (prev_alert.active_alert_id != the_active_alert.active_alert_id)){
         if (alert_active)
            hide_alert_dialog();
         kill_timer();
         prev_alert.active_alert_id = the_active_alert.active_alert_id;
         show_alert_dialog();
         if (the_active_alert.alert_type == ALERT)
            roadmap_alerter_audio();
         alert_active = TRUE;
      }
      else{
         update_alert();
      }
   } else {
      if (alert_active && !alert_should_be_visible) {
         if (AlerterTimerCallback == NULL){
            SsdWidget text = ssd_widget_get(dialog, "Distance");
            ssd_text_set_text(text, " ");
            g_seconds = 5;
            AlerterTimerCallback = hide_alert_timeout;
            roadmap_main_set_periodic (1000, AlerterTimerCallback);
         }
      }
   }
}
Beispiel #2
0
// Draw the warning on the screen
void roadmap_alerter_display(void) {
    const char * iconName;
    int 	alertId;
    char AlertStr[200];
    RoadMapGuiPoint AlertIconLocation;
    int opacity;
    char distance_str[100];
//	RoadMapGpsPosition pos;
    RoadMapImage theIcon;
    BOOL is_cancelable;

    AlertStr[0] = 0;

    if (alert_should_be_visible) {


        if (!alert_active && the_active_alert.alert_type == ALERT) {

            roadmap_alerter_audio();
        }

        alertId = roadmap_alerter_get_active_alert_id();
        is_cancelable = (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->is_cancelable)) (alertId);
        if (!alert_active && is_cancelable)
            set_softkey();

//		alert_active = TRUE;
//
//		if (the_active_alert.alert_type == ALERT){
//				iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_alert_icon)) (alertId);
//		}
//		else {
//				iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_warning_icon)) (alertId);
//		}
//
//        snprintf(AlertStr + strlen(AlertStr), sizeof(AlertStr)
//                - strlen(AlertStr), "<b1>%s%s\n",roadmap_lang_get("Approaching"), roadmap_lang_get((* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_string)) (alertId) ));
//
//        snprintf(AlertStr + strlen(AlertStr), sizeof(AlertStr)
//                - strlen(AlertStr), roadmap_lang_get("%s: %d %s\n"),roadmap_lang_get("In"), the_active_alert.distance_to_alert, roadmap_lang_get(roadmap_math_distance_unit()));
//
// 		roadmap_navigate_get_current (&pos, NULL, NULL);
//        snprintf(AlertStr + strlen(AlertStr), sizeof(AlertStr)
//                - strlen(AlertStr), roadmap_lang_get("%d %s"),roadmap_math_to_speed_unit(pos.speed), roadmap_lang_get(roadmap_math_speed_unit()));
//
//	    roadmap_display_pop_up("Approach Alert", iconName , NULL, AlertStr);

        alertId = roadmap_alerter_get_active_alert_id();

        if (the_active_alert.alert_type == ALERT) {
            iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_alert_icon)) (alertId);
            if (iconName == NULL) {
                return;
            }
            theIcon = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, iconName );
            if (theIcon == NULL) {
                roadmap_log( ROADMAP_ERROR, "Alerts - Icon Not found (%s)", iconName);
                return;
            }
            alert_active = TRUE;
        }
        else {
            iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_warning_icon)) (alertId);
            theIcon = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, iconName);
            if (theIcon == NULL) {
                roadmap_log( ROADMAP_ERROR, "Alerts - Icon Not found (%s)", iconName);
                return;
            }
            alert_active = TRUE;
        }

        AlertIconLocation.x = roadmap_canvas_width () - roadmap_canvas_image_width(theIcon);
        AlertIconLocation.y = roadmap_canvas_height ()/2 - roadmap_canvas_image_height(theIcon)/2 ;
        opacity = 0;

        sprintf(distance_str, "%d %s",  the_active_alert.distance_to_alert, roadmap_math_distance_unit());
        roadmap_display_text("Distance To Alert", distance_str);
        roadmap_canvas_draw_image (theIcon, &AlertIconLocation,opacity, IMAGE_NORMAL);


    } else {
        if (alert_active && !alert_should_be_visible) {
            alert_active = FALSE;
            if ((* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->is_cancelable)) (roadmap_alerter_get_active_alert_id()))
                remove_softkey();
            the_active_alert.active_alert_id = -1;
            roadmap_display_hide("Distance To Alert");
        }
    }
}