Example #1
0
void show_alert_dialog(){
   SsdWidget box;
   SsdWidget bitmap, text;
   char TextStr[200];
   int 	alertId;
   BOOL is_cancelable;
   const char * iconName;


   alertId = roadmap_alerter_get_active_alert_id();
   roadmap_square_set_current(the_active_alert.square);

   sprintf(TextStr, "%s",roadmap_lang_get((* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_string)) (alertId) ));

   dialog =  ssd_popup_new("Alert_Dlg", TextStr, NULL, SSD_MAX_SIZE, SSD_MIN_SIZE,NULL, SSD_PERSISTENT|SSD_ROUNDED_BLACK | SSD_HEADER_BLACK);

   box = ssd_container_new ("box", NULL, SSD_MIN_SIZE,SSD_MIN_SIZE,SSD_WIDGET_SPACE);
   ssd_widget_set_color(box, NULL, NULL);
   ssd_widget_add (box, space(1));
   sprintf(TextStr,"%s: %d %s", roadmap_lang_get("In"), the_active_alert.distance_to_alert, roadmap_lang_get(roadmap_math_distance_unit()));

   text = ssd_text_new ("Distance", TextStr, 14,0);
   ssd_widget_set_color(text, "#ffffff", "#ffffff");
   ssd_widget_add (box, text);
   ssd_widget_add (dialog, box);

   if (the_active_alert.alert_type == ALERT){
      iconName =  (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_alert_icon)) (alertId);
   }
   else {
      iconName =  (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_warning_icon)) (alertId);
   }
   bitmap = ssd_bitmap_new("alert_Icon",iconName, SSD_ALIGN_RIGHT);
   ssd_widget_add (box, bitmap);

   is_cancelable = (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->is_cancelable)) (alertId);
#ifdef TOUCH_SCREEN
   ssd_widget_add (dialog,
         ssd_button_label ("Hide", roadmap_lang_get ("Hide"),
            SSD_WS_TABSTOP|SSD_ALIGN_CENTER, alert_dialog_buttons_callback));

   if (is_cancelable){
      ssd_widget_add (dialog,
            ssd_button_label ("Irrelevant", roadmap_lang_get ("Not there"),
               SSD_WS_TABSTOP|SSD_ALIGN_CENTER, alert_dialog_buttons_callback));
   }

#else
   if (is_cancelable)
      set_softkey();
#endif
   ssd_dialog_activate ("Alert_Dlg", NULL);

}
Example #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");
        }
    }
}
Example #3
0
void show_alert_dialog(){
   SsdWidget box;
   SsdWidget title;
   SsdWidget bitmap, text;
   char TextStr[200];
   int 	alertId;
   BOOL is_cancelable;
   BOOL can_send_thumbs_up;
   const char * iconName;


   alertId = roadmap_alerter_get_active_alert_id();
   roadmap_square_set_current(the_active_alert.square);

   sprintf(TextStr, "%s",roadmap_lang_get((* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_string)) (alertId) ));

   dialog =  ssd_popup_new("Alert_Dlg", TextStr, on_popup_close, SSD_MAX_SIZE, SSD_MIN_SIZE,NULL, SSD_PERSISTENT|SSD_ROUNDED_BLACK, DIALOG_ANIMATION_FROM_TOP);

   title = ssd_widget_get(dialog, "popuup_text");
   if (title)
      ssd_widget_set_color(title,"#f6a201", "#f6a201");

   box = ssd_container_new ("box", NULL, SSD_MIN_SIZE,SSD_MIN_SIZE,SSD_WIDGET_SPACE);
   if (box){
         ssd_widget_set_color(box, NULL, NULL);
         ssd_widget_add (box, space(1));
   }

   if (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_additional_string != NULL){
      const  char *additional_text = (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_additional_string)) (alertId);
      if (additional_text){
         text = ssd_text_new ("AdditionalText", additional_text, 16,SSD_END_ROW);
         ssd_widget_set_color(text, "#ffffff", "#ffffff");
         ssd_widget_add (box, text);
         ssd_widget_add (box, space(1));
      }
   }

   if ((RoadMapAlertProviders.provider[the_active_alert.alert_provider]->show_distance != NULL) && ((*(RoadMapAlertProviders.provider[the_active_alert.alert_provider]->show_distance))(alertId)))
      sprintf(TextStr,"%s %d %s", roadmap_lang_get("In"), (the_active_alert.distance_to_alert/10)*10, roadmap_lang_get(roadmap_math_distance_unit()));

   text = ssd_text_new ("Distance", TextStr, 16,0);
   ssd_widget_set_color(text, "#ffffff", "#ffffff");
   ssd_widget_add (box, text);
   ssd_widget_add (dialog, box);

   if (the_active_alert.alert_type == ALERT){
      iconName =  (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_alert_icon)) (alertId);
   }
   else {
      iconName =  (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->get_warning_icon)) (alertId);
   }
   bitmap = ssd_bitmap_new("alert_Icon",iconName, SSD_ALIGN_RIGHT|SSD_ALIGN_VCENTER);
   ssd_widget_set_offset(bitmap, 0, -20);
   ssd_widget_add (box, bitmap);

   is_cancelable = (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->is_cancelable) && (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->is_cancelable)) (alertId);

   can_send_thumbs_up = (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->can_send_thumbs_up) && (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->can_send_thumbs_up)) (alertId);

#ifdef TOUCH_SCREEN
   ssd_widget_add (dialog,
         ssd_button_label ("Close", roadmap_lang_get ("Close"),
            SSD_WS_TABSTOP|SSD_ALIGN_CENTER, alert_dialog_buttons_callback));

   if (can_send_thumbs_up){
      char *icon[3];
      SsdWidget button;
      icon[0] = "thumbs_up_button";
      icon[1] = "thumbs_up_button_down";
      icon[2] = NULL;
      button = ssd_button_new( "ThumbsUp", "Thumbs up", (const char**) &icon[0], 2, SSD_ALIGN_CENTER, alert_dialog_buttons_callback );
      ssd_widget_add(dialog, button);
   }

   if (is_cancelable){
      ssd_widget_add (dialog,
            ssd_button_label ("Irrelevant", roadmap_lang_get ("Not there"),
               SSD_WS_TABSTOP|SSD_ALIGN_CENTER|SSD_END_ROW, alert_dialog_buttons_callback));
   }

   if (can_send_thumbs_up){
      SsdWidget text;
      text = ssd_text_new("ThumbsUpText",roadmap_lang_get("Thanks sent to user"), -1, SSD_ALIGN_CENTER);
      ssd_text_set_color(text, "#f6a201");
      ssd_widget_hide(text);
      ssd_widget_add(dialog, text);
   }

#else
   if (is_cancelable)
      set_softkey();
#endif
   ssd_dialog_activate ("Alert_Dlg", NULL);

   if (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->on_alerter_start != NULL)
      (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->on_alerter_start))(the_active_alert.active_alert_id);

}