static void _draw_alert(SsdWidget widget, RoadMapGuiRect *rect, int flags) { event_on_route_info *data = (event_on_route_info *) widget->data; RoadMapImage image; int width = widget->parent->cached_size.width - ADJ_SCALE(38); image = roadmap_res_get(RES_BITMAP, RES_SKIN, RTAlerts_Get_Map_Icon_By_Type(data->iType)); if (!image) return; if (flags & SSD_GET_SIZE) { rect->maxx = rect->minx; rect->maxy = rect->miny + roadmap_canvas_image_height(image); } else { RoadMapGuiPoint position; if (ssd_widget_rtl(NULL)) position.x = rect->minx - (width * data->iStart / 100) - roadmap_canvas_image_width(image) / 2 ; else position.x = rect->minx + (width * data->iStart / 100) - roadmap_canvas_image_width(image) / 2 + ADJ_SCALE(10); position.y = rect->miny - ADJ_SCALE(13); roadmap_canvas_draw_image(image, &position, 0, IMAGE_NORMAL); } }
static void draw_search_box(SsdWidget widget, RoadMapGuiRect *rect){ int i; int num_images; /* * AGA TODO:: Check if theses images should be cached for the memory optimizations * */ static RoadMapImage left; static RoadMapImage middle; static RoadMapImage right; RoadMapImage image_left; RoadMapImage image_middle; RoadMapImage image_right; RoadMapGuiPoint point; int width_left, width_right, width_middle; if (!left) left = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "SearchBox_left"); if (!right) right = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "SearchBox_right"); if (!middle) middle = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "SearchBox_middle"); image_left = left; image_right = right; image_middle = middle; width_left = roadmap_canvas_image_width(image_left); width_right = roadmap_canvas_image_width(image_right); width_middle = roadmap_canvas_image_width(image_middle); point.x = rect->minx; point.y = rect->miny; roadmap_canvas_draw_image (image_left, &point, 0, IMAGE_NORMAL); num_images = (rect->maxx - rect->minx - width_right - width_left)/width_middle; for (i = 0; i < num_images; i++){ point.x = +rect-> minx + width_right + i * width_middle; point.y = rect->miny; roadmap_canvas_draw_image (image_middle, &point, 0, IMAGE_NORMAL); } point.x = rect->maxx - width_right; point.y = rect->miny; roadmap_canvas_draw_image (image_right, &point, 0, IMAGE_NORMAL); }
static int set_value (SsdWidget widget, const char *value) { struct ssd_button_data *data = (struct ssd_button_data *) widget->data; RoadMapImage bmp = NULL; int max_width = 0; int max_height = 0; int is_different = 0; int i; if (widget->value && *widget->value) free (widget->value); if (*value) widget->value = strdup(value); else widget->value = ""; if (widget->flags & SSD_VAR_SIZE) { widget->size.height = -1; widget->size.width = -1; return 0; } for (i=0; i<MAX_STATES; i++) { if (data->bitmap_images[i]) bmp = data->bitmap_images[i]; if ( !bmp ) bmp = roadmap_res_get ( RES_BITMAP, RES_SKIN, data->bitmap_names[i] ); if (!bmp) continue; if ( !max_width || !max_height ) { max_width = roadmap_canvas_image_width(bmp); max_height = roadmap_canvas_image_height(bmp); } else { int val = roadmap_canvas_image_width(bmp); if (max_width != val) { is_different = 1; if (val > max_width) max_width = val; } val = roadmap_canvas_image_height(bmp); if (max_height != val) { is_different = 1; if (val > max_height) max_height = val; } } } widget->size.height = max_height; widget->size.width = max_width; return 0; }
void roadmap_bar_draw_bottom_bar (BOOL draw_bg) { int i; int num_images; int image_width, image_height; int screen_width, screen_height; screen_width = roadmap_canvas_width (); screen_height = roadmap_canvas_height(); if (!bar_initialized) return; if (gHideBottomBar) return; image_width = roadmap_canvas_image_width(BottomBarBgImage); image_height = roadmap_canvas_image_height(BottomBarBgImage); if (BottomBarObjectTable.draw_bg && draw_bg){ num_images = screen_width / image_width; for (i = 0; i < num_images; i++){ RoadMapGuiPoint BarLocation; BarLocation.y = screen_height - image_height; BarLocation.x = i * image_width; roadmap_canvas_draw_image (BottomBarBgImage, &BarLocation, 0, IMAGE_NORMAL); } } draw_objects(&BottomBarObjectTable); }
int ssd_button_change_images( SsdWidget widget, RoadMapImage* bitmap_images, const char **bitmap_names, int num_bitmaps ) { int i; RoadMapImage bmp; struct ssd_button_data *data = (struct ssd_button_data *) widget->data; for (i=0; i<num_bitmaps; i++) { set_bitmap_name( data, i, bitmap_names[i] ); data->bitmap_images[i] = bitmap_images[i]; } bmp = data->bitmap_images[0]; if ( !bmp ) { bmp = roadmap_res_get ( RES_BITMAP, RES_SKIN, bitmap_names[0] ); } if ( !bmp ) { widget->size.height = widget->size.width = 0; return -1; } widget->size.height = roadmap_canvas_image_height( bmp ); widget->size.width = roadmap_canvas_image_width( bmp ); return 0; }
void roadmap_ticker_initialize(void){ RoadMapImage image; gInitialized = FALSE; if ( roadmap_screen_is_hd_screen() ) { gTickerTopBarOffset = -5; } roadmap_config_declare_enumeration ("user", &ShowTickerCfg, NULL, "yes", "no", NULL); image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TICKER_MIDDLE_IMAGE); if ( image == NULL){ roadmap_log (ROADMAP_ERROR, "roadmap_ticker - cannot load %s image ", TICKER_MIDDLE_IMAGE); return; } gMiddleImageSize.width = roadmap_canvas_image_width( image ); gMiddleImageSize.height = roadmap_canvas_image_height( image ); OpenIconRct.miny = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset(); OpenIconRct.maxy = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + gMiddleImageSize.height; RoadMapTickerPen = roadmap_canvas_create_pen ("Ticker_pen"); roadmap_canvas_set_foreground (TICKER_FOREGROUND); show_close_icon(); roadmap_pointer_register_pressed (roadmap_ticker_key_pressed, POINTER_HIGH); roadmap_pointer_register_short_click(roadmap_ticker_short_click, POINTER_HIGH); gInitialized = TRUE; }
BOOL roadmap_border_initialize() { int i; for( i=0; i<border_img__count; i++) { const char* image_filename = get_img_filename(i); assert(NULL != image_filename); s_images[i].image = (RoadMapImage)roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, image_filename); if( !s_images[i].image) { roadmap_log(ROADMAP_ERROR, "load_border_images::load_border_images() - Failed to load image file '%s.png'", image_filename); return FALSE; } s_images[i].height = roadmap_canvas_image_height(s_images[i].image); s_images[i].width = roadmap_canvas_image_width(s_images[i].image); } #ifdef __ROADMAP_BORDER_CACHE__ border_cached_table.count = 0; #endif // __ROADMAP_BORDER_CACHE__ return TRUE; }
void roadmap_splash_display (void) { #if !defined(ANDROID) && !defined(IPHONE) && !defined(GTK2_OGL) int height, width; RoadMapImage image; RoadMapGuiPoint pos; height = roadmap_canvas_height (); width = roadmap_canvas_width (); if (height > width) image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, "welcome"); else image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, "welcome_wide"); if( !image) return; pos.x = (width - roadmap_canvas_image_width(image)) / 2; pos.y = (height - roadmap_canvas_image_height(image)) / 2; roadmap_canvas_draw_image (image, &pos, 0, IMAGE_NORMAL); roadmap_canvas_free_image (image); roadmap_canvas_refresh (); #endif }
static RoadMapImage createBGImage (RoadMapImage BarBgImage) { RoadMapImage image; int width = roadmap_canvas_width (); int height = roadmap_canvas_height(); int num_images; int image_width; int i; if (height > width){ width = width*2; } image = roadmap_canvas_new_image (width, roadmap_canvas_image_height(BarBgImage)); image_width = roadmap_canvas_image_width(BarBgImage); num_images = width / image_width ; RoadMapGuiRect *rect = malloc(sizeof(RoadMapGuiRect)); rect->minx = num_images; rect->miny = 0; // for (i = 0; i < num_images; i++){ RoadMapGuiPoint BarLocation; BarLocation.y = 0; BarLocation.x = 0;//i * image_width; roadmap_canvas_copy_image (image, &BarLocation, rect, BarBgImage ,CANVAS_COPY_NORMAL); // } return image; }
static RoadMapImage create_title_bar_image (RoadMapImage header_image, RoadMapGuiRect *rect) { RoadMapImage image; int width = roadmap_canvas_width (); int num_images; int image_width; RoadMapGuiPoint point; int i; image = roadmap_canvas_new_image (width, roadmap_canvas_image_height(header_image)); image_width = roadmap_canvas_image_width(header_image); num_images = width / image_width; num_images = (rect->maxx/image_width)+1; if (header_image){ for (i=0;i<=num_images;i++){ point.x = i * image_width; point.y = 0; roadmap_canvas_copy_image (image, &point, NULL, header_image, CANVAS_COPY_NORMAL); } } return image; }
static void draw_title_bar_image ( RoadMapImage header_image, RoadMapGuiRect *rect, const RoadMapGuiPoint* pos ) { int width = roadmap_canvas_width (); int num_images; int image_width; RoadMapGuiPoint point, bottom_right_point; int i; #ifdef OPENGL bottom_right_point.x = rect->maxx+1; bottom_right_point.y = rect->maxy; roadmap_canvas_draw_image_scaled( header_image, pos, &bottom_right_point, 0, IMAGE_NOBLEND ); #else image_width = roadmap_canvas_image_width(header_image); num_images = width / image_width; num_images = (rect->maxx/image_width)+1; if (header_image) { for ( i=0; i<=num_images; i++ ) { point.x = pos->x + i * image_width; point.y = pos->y; roadmap_canvas_draw_image( header_image, &point, 0, IMAGE_NOBLEND ); } } #endif }
static void drawBarBGImage( const char* res, const RoadMapGuiPoint* pos ) { RoadMapImage image; int width = roadmap_canvas_width (); int height = roadmap_canvas_height(); int num_images; int image_width, image_height; int i; RoadMapGuiPoint bottom_right_pos, BarLocation; RoadMapImage bgImage = (RoadMapImage) roadmap_res_get( RES_BITMAP, RES_SKIN, res ); image_width = roadmap_canvas_image_width( bgImage ); image_height = roadmap_canvas_image_height( bgImage ); bottom_right_pos.x = roadmap_canvas_width (); bottom_right_pos.y = pos->y + image_height; #ifdef OPENGL roadmap_canvas_draw_image_scaled( bgImage, pos, &bottom_right_pos, 0, IMAGE_NORMAL ); #else num_images = width / image_width ; BarLocation.y = pos->y; for ( i = 0; i < num_images; i++ ) { BarLocation.x = pos->x + i * image_width; roadmap_canvas_draw_image( bgImage, &BarLocation, 0, IMAGE_NORMAL); } #endif }
void roadmap_bar_draw_top_bar (BOOL draw_bg) { int i; int num_images; static int image_width = -1; int width; width = roadmap_canvas_width (); if (!bar_initialized) return; if ( gHideTopBar ) return; if (TopBarObjectTable.draw_bg && draw_bg){ if (image_width == -1) image_width = roadmap_canvas_image_width(TopBarBgImage); num_images = width / image_width + 1; for (i = 0; i < num_images; i++){ RoadMapGuiPoint BarLocation; BarLocation.y = 0; BarLocation.x = i * image_width; roadmap_canvas_draw_image (TopBarBgImage, &BarLocation, 0,IMAGE_NORMAL); } } draw_objects(&TopBarObjectTable); }
static void _draw_bar(SsdWidget widget, RoadMapGuiRect *rect, int flags) { static RoadMapImage bar_image = NULL; if (!bar_image) bar_image = roadmap_res_get(RES_BITMAP, RES_SKIN | RES_NOCACHE, "events_on_route_bar"); if (bar_image) { RoadMapGuiPoint sign_bottom, sign_top; RoadMapGuiPoint position; sign_top.x = rect->minx + ADJ_SCALE(15); sign_top.y = rect->miny; position.x = roadmap_canvas_image_width(bar_image) / 2; position.y = roadmap_canvas_image_height(bar_image) / 2; sign_bottom.x = rect->maxx - ADJ_SCALE(15); sign_bottom.y = rect->miny + roadmap_canvas_image_height(bar_image); if (flags & SSD_GET_SIZE) { rect->maxy = rect->miny + roadmap_canvas_image_height(bar_image) + 5; rect->minx = rect->minx + ADJ_SCALE(15); rect->maxx = rect->maxx - ADJ_SCALE(15); return; } else { roadmap_canvas_draw_image_stretch(bar_image, &sign_top, &sign_bottom, &position, 0, IMAGE_NORMAL); } } }
static void draw (SsdWidget widget, RoadMapGuiRect *rect, int flags) { RoadMapGuiPoint points[5]; int count = 5; #ifdef OPENGL RoadMapGuiPoint position; RoadMapGuiPoint sign_bottom, sign_top; static RoadMapImage focus_image; #endif const char* background = widget->bg_color; if (!(flags & SSD_GET_SIZE)) { if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else if (widget->background_focus) background = "#8a8a8a"; if (background) { if (widget->flags & SSD_ROUNDED_CORNERS){ RoadMapGuiRect erase_rect; erase_rect.minx = rect->minx + SSD_ROUNDED_CORNER_WIDTH; erase_rect.miny = rect->miny + SSD_ROUNDED_CORNER_HEIGHT; erase_rect.maxx = rect->maxx - SSD_ROUNDED_CORNER_WIDTH; erase_rect.maxy = rect->maxy - SSD_ROUNDED_CORNER_HEIGHT; roadmap_canvas_select_pen (bg); roadmap_canvas_set_foreground (background); //roadmap_canvas_erase_area (&erase_rect); } else{ if (!(widget->flags & SSD_DIALOG_TRANSPARENT)){ roadmap_canvas_select_pen (bg); roadmap_canvas_set_foreground (background); if ((widget->flags & SSD_CONTAINER_TXT_BOX) || (widget->flags & SSD_CONTAINER_SEARCH_BOX)){ rect->minx += 10; rect->maxx -= 10; } else roadmap_canvas_erase_area (rect); #if defined(OPENGL) && !defined(_WIN32) if (widget->in_focus && widget->focus_highlight ){ if (!focus_image) focus_image = roadmap_res_get( RES_BITMAP, RES_SKIN, "focus" ); if (focus_image){ sign_top.x = rect->minx; sign_top.y = rect->miny; position.x = roadmap_canvas_image_width(focus_image)/2; position.y = roadmap_canvas_image_height(focus_image) / 2; sign_bottom.x = rect->maxx; sign_bottom.y = rect->maxy; roadmap_canvas_draw_image_stretch( focus_image, &sign_top, &sign_bottom, &position, 0, IMAGE_NORMAL ); } } #endif } } } if ((widget->flags & SSD_SHADOW_BG) ) { draw_shadow_bg(); } if ((widget->flags & SSD_CONTAINER_TITLE) && !(widget->flags & SSD_DIALOG_FLOAT) && !(widget->flags & SSD_DIALOG_TRANSPARENT) ) { draw_bg(rect); } } if (widget->flags & SSD_CONTAINER_BORDER) { points[0].x = rect->minx + 1; #ifndef TOUCH_SCREEN points[0].y = rect->miny + 1; points[1].y = rect->miny + 1; points[4].y = rect->miny + 1; #else points[0].y = rect->miny; points[1].y = rect->miny; points[4].y = rect->miny ; #endif points[1].x = rect->maxx - 0; points[2].x = rect->maxx - 0; points[2].y = rect->maxy - 0; points[3].x = rect->minx + 1; points[3].y = rect->maxy - 0; points[4].x = rect->minx + 1; if (!(flags & SSD_GET_SIZE)) { const char *color = default_fg; RoadMapPosition *position = NULL; roadmap_canvas_select_pen (border); if (widget->fg_color) color = widget->fg_color; roadmap_canvas_set_foreground (color); if (widget->flags & SSD_ROUNDED_CORNERS){ int pointer_type = POINTER_NONE; int header_type = HEADER_NONE; int style = STYLE_NORMAL; int position_offset = widget->offset_y; #ifdef TOUCH_SCREEN widget->flags &= ~SSD_POINTER_MENU; #endif if (widget->flags & SSD_POINTER_MENU){ pointer_type = POINTER_MENU; #ifndef OPENGL points[2].y -= 17; #endif } else if (widget->flags & SSD_POINTER_COMMENT){ pointer_type = POINTER_COMMENT; #ifdef OPENGL points[2].y += 20; /* The height of the pointer */ #else points[2].y -= 7; #endif } else if (widget->flags & SSD_POINTER_NONE){ pointer_type = POINTER_NONE; if (!((widget->flags & SSD_ROUNDED_WHITE) || (widget->flags & SSD_ROUNDED_BLACK))) points[2].y -= 10; } if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else if ((widget->flags & SSD_POINTER_COMMENT) | (widget->flags & SSD_POINTER_MENU) | (widget->flags & SSD_POINTER_NONE)) background = "#e4f1f9"; else background = "#f3f3f5"; background = "#d2dfef"; header_type = HEADER_NONE; if (widget->flags & SSD_ROUNDED_WHITE){ style = STYLE_WHITE; if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else background = "#ffffff"; } if (widget->flags & SSD_ROUNDED_BLACK){ style = STYLE_BLACK; if (widget->in_focus && widget->focus_highlight ) background = "#b0d504"; else background = "#000000"; } if (widget->flags & SSD_POINTER_LOCATION){ if (widget->context != NULL){ pointer_type = POINTER_POSITION; position = (RoadMapPosition *)widget->context; //position_offset = ADJ_SCALE(-40); } } if (widget->flags & SSD_POINTER_FIXED_LOCATION){ if (widget->context != NULL){ pointer_type = POINTER_FIXED_POSITION; position = (RoadMapPosition *)widget->context; } } roadmap_display_border(style, header_type, pointer_type, &points[2], &points[0], background, position, position_offset); } else roadmap_canvas_draw_multiple_lines (1, &count, points, 1); } if (widget->flags & SSD_ROUNDED_CORNERS){ if (widget->flags & SSD_ROUNDED_WHITE){ rect->minx += 4; rect->miny += 4; rect->maxx -= 4; rect->maxy -= 4; } else{ rect->minx += 10; if ((widget->flags & SSD_CONTAINER_TITLE) || (widget->flags & SSD_POINTER_MENU) || (widget->flags & SSD_POINTER_NONE)) rect->miny += 10; else rect->miny += 4; rect->maxx -= 10; rect->maxy -= 10; } } else{ rect->minx += 2; rect->miny += 2; rect->maxx -= 2; rect->maxy -= 2; } } if (widget->flags & SSD_CONTAINER_TXT_BOX){ if (!(flags & SSD_GET_SIZE)){ if (background){ rect->minx -= 10; rect->maxx += 10; } draw_text_box(widget, rect); } rect->minx += 20; rect->miny += 10; rect->maxx -= 20; rect->maxy -= 10; } if (widget->flags & SSD_CONTAINER_SEARCH_BOX){ if (!(flags & SSD_GET_SIZE)){ if (background){ rect->minx -= 10; rect->maxx += 10; } draw_search_box(widget, rect); } rect->minx += 20; rect->miny += 10; rect->maxx -= 20; rect->maxy -= 10; } if (widget->flags & SSD_CONTAINER_TITLE){ ssd_widget_set_left_softkey_text(widget, widget->left_softkey); ssd_widget_set_right_softkey_text(widget, widget->right_softkey); } if ((flags & SSD_GET_CONTAINER_SIZE) && (widget->flags & SSD_CONTAINER_TITLE)) { SsdWidget title; title = ssd_widget_get (widget, "title_bar"); if (title) { SsdSize title_size; SsdSize max_size; max_size.width = rect->maxx - rect->minx + 1; max_size.height = rect->maxy - rect->miny + 1; ssd_widget_get_size (title, &title_size, &max_size); rect->miny += title_size.height; } } }
void roadmap_bar_initialize(void){ int width; int image_width; int i; const char *cursor; RoadMapFileContext file; TopBarObjectTable.count = 0; for (i=0; i< MAX_OBJECTS;i++){ TopBarObjectTable.object[i] = NULL; BottomBarObjectTable.object[i] = NULL; } TopBarObjectTable.draw_bg = TRUE; BottomBarObjectTable.draw_bg = TRUE; width = roadmap_canvas_width (); TopBarBgImage = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TOP_BAR_IMAGE); if (TopBarBgImage == NULL){ return; } BottomBarBgImage = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, BOTTOM_BAR_IMAGE); if (BottomBarBgImage == NULL){ return; } // Load top bar cursor = roadmap_file_map ("skin", "top_bar", NULL, "r", &file); if (cursor == NULL){ roadmap_log (ROADMAP_ERROR, "roadmap bar top_bar file is missing"); return; } roadmap_bar_load(roadmap_file_base(file), roadmap_file_size(file), &TopBarObjectTable); roadmap_file_unmap (&file); // Load bottom bar cursor = roadmap_file_map ("skin", "bottom_bar", NULL, "r", &file); if (cursor == NULL){ roadmap_log (ROADMAP_ERROR, "roadmap bottom top_bar file is missing"); return; } roadmap_bar_load(roadmap_file_base(file), roadmap_file_size(file), &BottomBarObjectTable); roadmap_file_unmap (&file); image_width = roadmap_canvas_image_width(TopBarBgImage); roadmap_bar_set_mode(TOPBAR_FLAG); roadmap_pointer_register_short_click (roadmap_bar_short_click, POINTER_HIGH); roadmap_pointer_register_long_click (roadmap_bar_long_click, POINTER_HIGH); roadmap_pointer_register_pressed (roadmap_bar_obj_pressed, POINTER_HIGH); roadmap_pointer_register_released (roadmap_bar_obj_released, POINTER_HIGH); roadmap_skin_register (roadmap_bar_switch_skins); bar_initialized = TRUE; }
static void draw_text_box(SsdWidget widget, RoadMapGuiRect *rect){ int i; int num_images; #ifdef OPENGL RoadMapImage txt_box_img = roadmap_res_get( RES_BITMAP, RES_SKIN, "txt_box" ); RoadMapImage txt_box_s_img = roadmap_res_get( RES_BITMAP, RES_SKIN, "txt_box_s" ); RoadMapImage cur_img; RoadMapGuiPoint top_left_pos; RoadMapGuiPoint bottom_right_pos; top_left_pos.x = rect->minx; top_left_pos.y = rect->miny; bottom_right_pos.x = rect->maxx; bottom_right_pos.y = rect->maxy; if ( widget->in_focus && widget->focus_highlight ) { cur_img = txt_box_s_img; } else { cur_img = txt_box_img; } roadmap_canvas_draw_image_middle_stretch( cur_img, &top_left_pos, &bottom_right_pos, 0, IMAGE_NORMAL ); #else /* * AGA TODO:: Check if theses images should be cached for the memory optimizations * */ static RoadMapImage left; static RoadMapImage middle; static RoadMapImage right; static RoadMapImage left_s; static RoadMapImage middle_s; static RoadMapImage right_s; RoadMapImage image_left; RoadMapImage image_middle; RoadMapImage image_right; RoadMapGuiPoint point; int width_left, width_right, width_middle; if (!left) left = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "Txtbox_left"); if (!right) right = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "Txtbox_right"); if (!middle) middle = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "Txtbox_middle"); if (!left_s) left_s = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "Txtbox_left_selected"); if (!right_s) right_s = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "Txtbox_right_selected"); if (!middle_s) middle_s = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "Txtbox_middle_selected"); if ( widget->in_focus && widget->focus_highlight ){ image_left = left_s; image_right = right_s; image_middle = middle_s; } else{ image_left = left; image_right = right; image_middle = middle; } width_left = roadmap_canvas_image_width(image_left); width_right = roadmap_canvas_image_width(image_right); width_middle = roadmap_canvas_image_width(image_middle); point.x = rect->minx; point.y = rect->miny; roadmap_canvas_draw_image (image_left, &point, 0, IMAGE_NORMAL); num_images = (rect->maxx - rect->minx - width_right - width_left)/width_middle; for (i = 0; i < num_images; i++){ point.x = +rect-> minx + width_right + i * width_middle; point.y = rect->miny; roadmap_canvas_draw_image (image_middle, &point, 0, IMAGE_NORMAL); } point.x = rect->maxx - width_right; point.y = rect->miny; roadmap_canvas_draw_image (image_right, &point, 0, IMAGE_NORMAL); #endif }
static void draw_objects(BarObjectTable_s *table){ int font_size; int i; int state, condition; RoadMapGuiPoint TextLocation; RoadMapImage image; int text_flag = ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP ; for (i=0; i < table->count; i++) { RoadMapGuiPoint ObjectLocation; RoadMapGuiPoint BgFocusLocation; if (table->object[i] == NULL) continue; if (table->object[i]->condition_fn[0]){ int j; BOOL cond = TRUE; for (j=0; j< table->object[i]->num_conditions;j++){ condition = (*table->object[i]->condition_fn[j]) (); if (condition != table->object[i]->condition_value[j]) cond = FALSE; } if (!cond) continue; } roadmap_bar_pos(table->object[i], &ObjectLocation); if (table->object[i]->state_fn) { state = (*table->object[i]->state_fn) (); if ((state < 0) || (state >= MAX_STATES)){ } else{ if (table->object[i]->images[state] != NULL){ if (table->object[i]->image_state == IMAGE_STATE_SELECTED){ if (table->object[i]->image_selected[state] != NULL){ image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->image_selected[state] ); roadmap_canvas_draw_image ( image, &ObjectLocation, 0,IMAGE_NORMAL); } else{ #ifdef TOUCH_SCREEN if (TopBarSelectedBg){ image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[state] ); BgFocusLocation.x = ObjectLocation.x - (roadmap_canvas_image_width(TopBarSelectedBg) -roadmap_canvas_image_width( image ))/2; BgFocusLocation.y = ObjectLocation.y - (roadmap_canvas_image_height(TopBarSelectedBg) -roadmap_canvas_image_height( image ))/4*3; roadmap_canvas_draw_image ( TopBarSelectedBg, &BgFocusLocation, 0,IMAGE_NORMAL ); } #endif image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[state] ); roadmap_canvas_draw_image ( image, &ObjectLocation, 0,IMAGE_NORMAL); } } else{ image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[state] ); roadmap_canvas_draw_image ( image, &ObjectLocation, 0,IMAGE_NORMAL); } } } } else{ if (table->object[i]->image_state == IMAGE_STATE_SELECTED){ if (table->object[i]->image_selected[0] != NULL){ image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->image_selected[0] ); roadmap_canvas_draw_image ( image, &ObjectLocation, 0,IMAGE_NORMAL); } else{ #ifdef TOUCH_SCREEN if (TopBarSelectedBg){ image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[0] ); BgFocusLocation.x = ObjectLocation.x - (roadmap_canvas_image_width(TopBarSelectedBg) -roadmap_canvas_image_width( image ))/2; BgFocusLocation.y = ObjectLocation.y - (roadmap_canvas_image_height(TopBarSelectedBg) -roadmap_canvas_image_height( image ))/4*3; roadmap_canvas_draw_image ( TopBarSelectedBg, &BgFocusLocation, 0,IMAGE_NORMAL ); } #endif image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[0] ); roadmap_canvas_draw_image (image, &ObjectLocation, 0,IMAGE_NORMAL); } } else if (table->object[i]->images[0] ) { image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[0] ); roadmap_canvas_draw_image ( image , &ObjectLocation, 0,IMAGE_NORMAL); } } if (table->object[i]->bar_image_fn){ const char *image_name = NULL; image_name = table->object[i]->bar_image_fn->bar_text_fn(); if (image_name && *image_name){ image = roadmap_res_get (RES_BITMAP, RES_SKIN, image_name ); if (image){ roadmap_canvas_draw_image ( image , &ObjectLocation, 0,IMAGE_NORMAL); } } } if (table->object[i]->bar_text){ if (table->object[i]->font_size != 0) font_size = table->object[i]->font_size; else font_size = 10; if (table->object[i]->text_alling != -1){ text_flag = table->object[i]->text_alling; } else if (table->object[i]->pos_x < 0){ text_flag = ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP; } if (!table->object[i]->bar_text->pen) { table->object[i]->bar_text->pen = roadmap_canvas_create_pen (table->object[i]->bar_text->name, FALSE); if (table->object[i]->text_color){ roadmap_canvas_set_foreground (table->object[i]->text_color); } } else { roadmap_canvas_select_pen (table->object[i]->bar_text->pen); } if (!table->object[i]->text_color){ if (roadmap_skin_state()) roadmap_canvas_set_foreground ("#ffffff"); else roadmap_canvas_set_foreground (table->object[i]->bar_text->default_foreground); } if (table->object[i]->state_fn) { state = (*table->object[i]->state_fn) (); if (state >0){ if (table->object[i]->images[state]) { image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[state] ); TextLocation.x = ObjectLocation.x + roadmap_canvas_image_width( image )/2; TextLocation.y = ObjectLocation.y + roadmap_canvas_image_height( image )/2; } else roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,(*table->object[i]->bar_text->bar_text_fn)()); } } else{ if (table->object[i]->images[0]){ image = roadmap_bar_load_image( table->object[i]->name, table->object[i]->images[0] ); TextLocation.x = ObjectLocation.x + roadmap_canvas_image_width( image )/2; TextLocation.y = ObjectLocation.y + roadmap_canvas_image_height( image )/2 -2; } else roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,(*table->object[i]->bar_text->bar_text_fn)()); } } if (table->object[i]->fixed_text){ if (table->object[i]->font_size != 0) font_size = table->object[i]->font_size; else font_size = 10; if (table->object[i]->text_alling != -1){ text_flag = table->object[i]->text_alling; } else if (table->object[i]->pos_x < 0){ text_flag = ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP; } roadmap_canvas_create_pen (table->object[i]->name, FALSE); if (table->object[i]->text_color){ roadmap_canvas_set_foreground (table->object[i]->text_color); } else{ if (roadmap_skin_state()) roadmap_canvas_set_foreground ("#ffffff"); else roadmap_canvas_set_foreground ("#000000"); } if (table->object[i]->state_fn) { state = (*table->object[i]->state_fn) (); if (state >0){ roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,table->object[i]->fixed_text); } } else{ roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,table->object[i]->fixed_text); } } } }
void roadmap_bar_initialize(void){ int width; int i; const char *cursor; RoadMapFileContext file; RoadMapImage topBarBgImg, bottomBarBgImg; TopBarObjectTable.count = 0; for (i=0; i< MAX_OBJECTS;i++){ TopBarObjectTable.object[i] = NULL; BottomBarObjectTable.object[i] = NULL; } TopBarObjectTable.draw_bg = TRUE; BottomBarObjectTable.draw_bg = TRUE; width = roadmap_canvas_width (); /* * The bar images not in cache (persistent). Possible memory optimization point * AGA */ topBarBgImg = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, TOP_BAR_IMAGE); if (topBarBgImg == NULL){ return; } TopBarBgImageSize.width = roadmap_canvas_image_width( topBarBgImg ); TopBarBgImageSize.height = roadmap_canvas_image_height( topBarBgImg ); bottomBarBgImg = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, BOTTOM_BAR_IMAGE); if (bottomBarBgImg == NULL){ return; } BottomBarBgImageSize.width = roadmap_canvas_image_width( bottomBarBgImg ); BottomBarBgImageSize.height = roadmap_canvas_image_height( bottomBarBgImg ); #ifdef TOUCH_SCREEN TopBarSelectedBg = ( RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, TOP_BAR_SELECTED_BG_IMAGE ); #endif #if ! (defined(OPENGL)) // Draw directly TopBarFullBg = createBGImage( topBarBgImg ); BottomBarFullBg = createBGImage( bottomBarBgImg ); #endif /* * Deallocate the source images */ roadmap_canvas_free_image( topBarBgImg ); roadmap_canvas_free_image( bottomBarBgImg ); // Load top bar cursor = roadmap_file_map ("skin", "top_bar", NULL, "r", &file); if (cursor == NULL){ roadmap_log (ROADMAP_ERROR, "roadmap bar top_bar file is missing"); return; } roadmap_bar_load(roadmap_file_base(file), roadmap_file_size(file), &TopBarObjectTable); roadmap_file_unmap (&file); #ifndef J2ME // Load bottom bar cursor = roadmap_file_map ("skin", "bottom_bar", NULL, "r", &file); if (cursor == NULL){ roadmap_log (ROADMAP_ERROR, "roadmap bottom top_bar file is missing"); return; } roadmap_bar_load(roadmap_file_base(file), roadmap_file_size(file), &BottomBarObjectTable); roadmap_file_unmap (&file); #endif roadmap_bar_set_mode(TOPBAR_FLAG); roadmap_pointer_register_short_click (roadmap_bar_short_click, POINTER_HIGH); roadmap_pointer_register_long_click (roadmap_bar_long_click, POINTER_HIGH); roadmap_pointer_register_pressed (roadmap_bar_obj_pressed, POINTER_HIGH); roadmap_pointer_register_drag_start (roadmap_bar_drag_start, POINTER_HIGHEST); roadmap_pointer_register_released (roadmap_bar_obj_released, POINTER_HIGH); roadmap_skin_register (roadmap_bar_switch_skins); #ifdef ANDROID roadmap_androidmenu_initialize(); #endif bar_initialized = TRUE; }
void roadmap_display_sign_pop_up(RoadMapSign *sign) { RoadMapGuiPoint text_position; RoadMapGuiPoint top, bottom; int text_height = 0; RoadMapGuiPoint icon_screen_point; int width, ascent, descent; int lines = 1; int screen_width; int sign_width; int i; int allign = ROADMAP_CANVAS_TOPLEFT; if (ssd_widget_rtl (NULL)) allign = ROADMAP_CANVAS_TOPRIGHT; roadmap_canvas_get_text_extents (sign->content, -1, &width, &ascent, &descent, NULL); text_height = ascent + descent + 5; screen_width = roadmap_canvas_width(); for (i = 0; sign->content[i] != '\0'; i++) if (sign->content[i]=='\n') lines++; if (lines < 2) lines = 2; sign->deadline = -1; top.x = 1; top.y = roadmap_bar_top_height()+1; bottom.x = screen_width; #ifdef TOUCH_SCREEN bottom.y = (lines) * 21 + top.y + 8; sign_width = roadmap_display_border(sign->style, sign->header_type, sign->pointer_type, &bottom, &top, "#d2dfef", &sign->position,0); #else bottom.y = (lines) * 21 + top.y; sign_width = roadmap_display_border(sign->style, sign->header_type, sign->pointer_type, &bottom, &top, "#e4f1f9", &sign->position,0); #endif if (sign->image != NULL){ RoadMapImage close; RoadMapImage image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, sign->image); if (image){ if (ssd_widget_rtl (NULL)) icon_screen_point.x = top.x + 12; else icon_screen_point.x = top.x + sign_width - 12 - roadmap_canvas_image_width(image); icon_screen_point.y = bottom.y - roadmap_canvas_image_height(image) -12; roadmap_canvas_draw_image (image, &icon_screen_point, 0, IMAGE_NORMAL); } close = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, "rm_quit"); if (close){ icon_screen_point.y = top.y + 4; if (ssd_widget_rtl (NULL)) icon_screen_point.x = top.x + 2; else icon_screen_point.x = top.x + sign_width - 12 - roadmap_canvas_image_width(close); roadmap_canvas_draw_image (close, &icon_screen_point, 0, IMAGE_NORMAL); } } roadmap_canvas_select_pen (sign->foreground); if (ssd_widget_rtl (NULL)) text_position.x = sign_width - 10 ; else text_position.x = 10; #ifdef TOUCH_SCREEN text_position.y = roadmap_bar_top_height() + 5 ; #else text_position.y = roadmap_bar_top_height() + 9 ; #endif roadmap_display_string (sign->content, lines, text_height, &text_position, allign); }
static void roadmap_speedometer_after_refresh (void){ RoadMapGuiPoint image_position; RoadMapGuiPoint text_position; RoadMapGuiPoint units_position; RoadMapGpsPosition pos; RoadMapPen speedometer_pen; char str[30]; char unit_str[30]; int font_size = 20; int font_size_units = 10; int speed_offset = 6; int units_offset = 6; int speed; #ifdef IPHONE_NATIVE font_size = 18; font_size_units = 8; #else if ( roadmap_lang_rtl() ) font_size_units--; // Longer text for units #endif if (SpeedometerImage == NULL){ return; } if (gHideSpeedometer){ after_refresh_callback(); return; } if (!roadmap_map_settings_isShowSpeedometer()){ after_refresh_callback(); return; } if (roadmap_screen_is_hd_screen()){ speed_offset *= 1.5; units_offset *= 1.5; } roadmap_navigate_get_current (&pos, NULL, NULL); speed = pos.speed; if ((speed == -1) || !roadmap_gps_have_reception()){ after_refresh_callback(); return; } speedometer_pen = roadmap_canvas_create_pen ("speedometer_pen"); if (roadmap_skin_state() == 1) roadmap_canvas_set_foreground(SPEEDOMETER_SPEED_COLOR_NIGHT); else roadmap_canvas_set_foreground(SPEEDOMETER_SPEED_COLOR_DAY); image_position.x = roadmap_canvas_width() - roadmap_canvas_image_width(SpeedometerImage); image_position.y = roadmap_canvas_height() - roadmap_canvas_image_height(SpeedometerImage) - roadmap_bar_bottom_height() - gOffset; roadmap_canvas_draw_image (SpeedometerImage, &image_position, 0, IMAGE_NORMAL); text_position.y = image_position.y + roadmap_canvas_image_height(SpeedometerImage) *.8; units_position.y = image_position.y + roadmap_canvas_image_height(SpeedometerImage)*.8; if (speed != -1){ if (!roadmap_gps_is_show_raw()) { snprintf (str, sizeof(str), "%3d", roadmap_math_to_speed_unit(speed)); snprintf (unit_str, sizeof(unit_str), "%s", roadmap_lang_get(roadmap_math_speed_unit())); } else { snprintf (str, sizeof(str), "%3d", pos.accuracy); snprintf (unit_str, sizeof(unit_str), "%s", "ac"); } if (ssd_widget_rtl(NULL)){ text_position.x = roadmap_canvas_width() -speed_offset; roadmap_canvas_draw_string_size(&text_position, ROADMAP_CANVAS_BOTTOMRIGHT, font_size, str); units_position.x = image_position.x + units_offset; roadmap_canvas_draw_string_size(&units_position, ROADMAP_CANVAS_BOTTOMLEFT, font_size_units, unit_str); } else{ text_position.x = image_position.x + speed_offset; roadmap_canvas_draw_string_size(&text_position, ROADMAP_CANVAS_BOTTOMLEFT, font_size, str); units_position.x = roadmap_canvas_width() -units_offset; roadmap_canvas_draw_string_size(&units_position, ROADMAP_CANVAS_BOTTOMRIGHT, font_size_units, unit_str); } } after_refresh_callback(); }
void roadmap_ticker_display() { char text[256]; char points[20]; char rank[20]; int text_width, ascent, descent; RoadMapGuiPoint position; RoadMapGuiPoint text_position; RoadMapImage image; int start,end, start_x; int iMyTotalPoints; int iMyRanking; int allign; int width; int text_offset_y = 25; int point_start_x = 190; int rank_start_x = 270; int new_pnts_start_x = 50; RoadMapImage x_image = NULL; const char * point_text = NULL; if ( roadmap_screen_is_hd_screen() ) { text_offset_y = 22; point_start_x = 200; rank_start_x = 280; new_pnts_start_x = 65; } width = roadmap_canvas_width(); if (!gInitialized) return ; if (!ticker_cfg_on() && !gTickerSupressHide){ gTickerOn = FALSE; return; } if (gTickerHide ){ gTickerOn = FALSE; return; } if (!roadmap_message_format (text, sizeof(text), "%X|%*")) { if (gTickerSupressHide){ roadmap_message_set('*', "%d", 0); roadmap_message_format (text, sizeof(text), "%*"); } else{ show_close_icon(); gTickerOn = FALSE; return; } } gTickerOn = TRUE; roadmap_canvas_get_text_extents (text, 14, &text_width, &ascent, &descent, NULL); roadmap_canvas_select_pen (RoadMapTickerPen); end = roadmap_canvas_width(); start = 1; start_x = 1; image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TICKER_MIDDLE_IMAGE); if ( image ) { while (start < end){ position.x = start; position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset(); roadmap_canvas_draw_image ( image, &position, 0, IMAGE_NORMAL); start += roadmap_canvas_image_width( image ); } } position.x = 0; if (ssd_widget_rtl(NULL)){ allign = ROADMAP_CANVAS_RIGHT; text_position.x = roadmap_canvas_width() -4; } else{ allign = ROADMAP_CANVAS_LEFT; text_position.x = 4; } text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2; roadmap_canvas_draw_string_size (&text_position, allign |ROADMAP_CANVAS_TOP, 14,roadmap_lang_get("Your Points (updated daily)")); text_position.x = 4; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2 +TICKER_TOP_BAR_TEXT_OFFSET; switch( gLastUpdateEvent ) { case default_event: point_text = roadmap_lang_get("New points"); break; case report_event: point_text = roadmap_lang_get("Road report"); break; case comment_event: point_text = roadmap_lang_get("Event comment"); break; case confirm_event: point_text= roadmap_lang_get("Prompt response"); break; case road_munching_event : point_text= roadmap_lang_get("Road munching"); break; case user_contribution_event : point_text= roadmap_lang_get("Traffic detection"); break; case bonus_points : point_text= roadmap_lang_get("Bonus points"); break; } roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,point_text); image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TICKER_DIVIDER); if ( image ) { position.y = roadmap_bar_top_height() + TICKER_TOP_BAR_DIVIDER_OFFSET; position.x = width /3 +4 + 30; roadmap_canvas_draw_image ( image, &position, 0, IMAGE_NORMAL); position.y = roadmap_bar_top_height() + TICKER_TOP_BAR_DIVIDER_OFFSET; position.x = 2*width/3+4 +15; roadmap_canvas_draw_image ( image, &position, 0, IMAGE_NORMAL); } text_position.x = (width/3) + (width/3)/4 + 30; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2 + TICKER_TOP_BAR_TEXT_OFFSET; roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,roadmap_lang_get("Total")); text_position.x = (width/3) + (width/3)/4+ 30; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET; iMyTotalPoints = editor_points_get_total_points(); if (iMyTotalPoints != -1){ if (iMyTotalPoints < 10000){ sprintf(points,"%d", iMyTotalPoints); } else{ sprintf(points,"%dK", (int)iMyTotalPoints/1000); } } else{ strcpy(points,""); } roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,points); text_position.x = width - (width/3) + (width/3)/4+ 15; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2 +TICKER_TOP_BAR_TEXT_OFFSET; iMyRanking = RealTime_GetMyRanking(); if (iMyRanking == -1) strcpy(rank,""); else sprintf(rank, "%d", iMyRanking); roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,roadmap_lang_get("Rank")); text_position.x = width - (width/3) + (width/3)/4+ 12; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET; roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,rank); if (strcmp(text,"0")){ text_position.x = new_pnts_start_x - start_x + 30; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET; roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,"+"); text_position.x = new_pnts_start_x - start_x + 40; text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET; roadmap_canvas_draw_string_size (&text_position, ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP, 14,text); } #ifdef TOUCH_SCREEN x_image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, "x_close"); if ( x_image ) { position.x = roadmap_canvas_width() - roadmap_canvas_image_width(x_image) - 5; position.y = roadmap_bar_top_height() + gMiddleImageSize.height -roadmap_canvas_image_height(x_image) -5; roadmap_canvas_draw_image ( x_image, &position, 0, IMAGE_NORMAL); } #endif }
static void draw (SsdWidget widget, RoadMapGuiRect *rect, int flags) { struct ssd_button_data *data = (struct ssd_button_data *) widget->data; RoadMapImage image = NULL; RoadMapGuiPoint point; int image_state; int state; point.x = rect->minx; point.y = rect->miny; get_state(widget, &state, &image, &image_state); if ((flags & SSD_GET_SIZE)) { if ( data->bitmap_images[state] != NULL ) image = data->bitmap_images[state]; else image = roadmap_res_get ( RES_BITMAP, RES_SKIN, data->bitmap_names[state] ); if ( !image ) image = data->bitmap_images[0]; if ( !image ) image = roadmap_res_get ( RES_BITMAP, RES_SKIN, data->bitmap_names[0] ); if (!image ) { widget->size.height = widget->size.width = 0; return; } rect->maxx = rect->minx + roadmap_canvas_image_width(image); rect->maxy = rect->miny + roadmap_canvas_image_height(image); return; } if (!image) { roadmap_log (ROADMAP_ERROR, "SSD - Can't get image for button widget: %s", widget->name); return; } switch (state) { case BUTTON_STATE_NORMAL: roadmap_canvas_draw_image (image, &point, 0, IMAGE_NORMAL); break; case BUTTON_STATE_DISABLED: roadmap_canvas_draw_image (image, &point, 0, IMAGE_NORMAL); break; case BUTTON_STATE_SELECTED: if (image_state == state) { roadmap_canvas_draw_image (image, &point, 0, IMAGE_NORMAL); } else { roadmap_canvas_draw_image (image, &point, 0, IMAGE_SELECTED); } break; } }
static void _draw_traffic(SsdWidget widget, RoadMapGuiRect *rect, int flags) { event_on_route_info *data = (event_on_route_info *) widget->data; static RoadMapImage events_divider; static RoadMapImage events_traffic_1 = NULL; static RoadMapImage events_traffic_2 = NULL; static RoadMapImage events_traffic_3 = NULL; RoadMapImage event_traffic; int width = widget->parent->cached_size.width - ADJ_SCALE(34); if (ssd_widget_rtl(NULL)) rect->minx -= ADJ_SCALE(17); else rect->minx += ADJ_SCALE(17); if (!events_divider) events_divider = roadmap_res_get(RES_BITMAP, RES_SKIN | RES_NOCACHE, "events_divider"); if (!events_traffic_1) events_traffic_1 = roadmap_res_get(RES_BITMAP, RES_SKIN | RES_NOCACHE, "events_traffic_1"); if (!events_traffic_2) events_traffic_2 = roadmap_res_get(RES_BITMAP, RES_SKIN | RES_NOCACHE, "events_traffic_2"); if (!events_traffic_3) events_traffic_3 = roadmap_res_get(RES_BITMAP, RES_SKIN | RES_NOCACHE, "events_traffic_3"); switch (data->iSeverity) { case JAM_TYPE_MODERATE_TRAFFIC: event_traffic = events_traffic_1; break; case JAM_TYPE_HEAVY_TRAFFIC: event_traffic = events_traffic_2; break; case JAM_TYPE_STAND_STILL_TRAFFIC: event_traffic = events_traffic_3; break; default: return; } if (flags & SSD_GET_SIZE) { rect->maxx = rect->minx;//.+ 2 ; rect->maxy = rect->miny + roadmap_canvas_image_height(events_divider); } else { if ((data->iPrecentage * width / 100) > roadmap_canvas_image_width(events_divider)*2+2) { RoadMapGuiPoint position; RoadMapGuiPoint sign_top; RoadMapGuiPoint sign_bottom; if (ssd_widget_rtl(NULL)) position.x = rect->minx - (width * data->iStart / 100) - roadmap_canvas_image_width( events_divider); else position.x = rect->minx + (width * data->iStart / 100); position.y = rect->miny; roadmap_canvas_draw_image(events_divider, &position, 0, IMAGE_NORMAL); if (ssd_widget_rtl(NULL)) position.x = rect->minx - (width * data->iStart / 100) - (width * data->iPrecentage / 100) + roadmap_canvas_image_width(events_divider); else position.x = rect->minx + (width * data->iStart / 100) + (width * data->iPrecentage / 100) - 2 * roadmap_canvas_image_width(events_divider); position.y = rect->miny; roadmap_canvas_draw_image(events_divider, &position, 0, IMAGE_NORMAL); if (ssd_widget_rtl(NULL)) sign_bottom.x = rect->minx - (width * data->iStart / 100) - roadmap_canvas_image_width( events_divider); else sign_top.x = rect->minx + (width * data->iStart / 100) + roadmap_canvas_image_width( events_divider); sign_top.y = rect->miny; position.x = roadmap_canvas_image_width(event_traffic) / 2; position.y = roadmap_canvas_image_height(event_traffic) / 2; if (ssd_widget_rtl(NULL)) sign_top.x = rect->minx - (width * data->iStart / 100) - (width * data->iPrecentage / 100) + 2 * roadmap_canvas_image_width(events_divider); else sign_bottom.x = rect->minx + (width * data->iStart / 100) + (width * data->iPrecentage / 100) - 2 * roadmap_canvas_image_width(events_divider); sign_bottom.y = rect->miny + roadmap_canvas_image_height(event_traffic); roadmap_canvas_draw_image_stretch(event_traffic, &sign_top, &sign_bottom, &position, 0, IMAGE_NORMAL); } } }
// 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"); } } }
void draw_objects(BarObjectTable_s *table){ int font_size; int i; int state, condition; RoadMapGuiPoint TextLocation; int text_flag = ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP ; for (i=0; i < table->count; i++) { RoadMapGuiPoint ObjectLocation; if (table->object[i] == NULL) continue; if (table->object[i]->condition_fn[0]){ int j; BOOL cond = TRUE; for (j=0; j< table->object[i]->num_conditions;j++){ condition = (*table->object[i]->condition_fn[j]) (); if (condition != table->object[i]->condition_value[j]) cond = FALSE; } if (!cond) continue; } roadmap_bar_pos(table->object[i], &ObjectLocation); if (table->object[i]->state_fn) { state = (*table->object[i]->state_fn) (); if ((state < 0) || (state >= MAX_STATES)){ } else{ if (table->object[i]->images[state] != NULL){ if ((table->object[i]->image_state == IMAGE_STATE_SELECTED) && (table->object[i]->image_selected[state] != NULL)) roadmap_canvas_draw_image (table->object[i]->image_selected[state], &ObjectLocation, 0,IMAGE_NORMAL); else roadmap_canvas_draw_image (table->object[i]->images[state], &ObjectLocation, 0,IMAGE_NORMAL); } } } else{ if ((table->object[i]->image_state == IMAGE_STATE_SELECTED) && (table->object[i]->image_selected[0] != NULL)){ roadmap_canvas_draw_image (table->object[i]->image_selected[0], &ObjectLocation, 0,IMAGE_NORMAL); } else if (table->object[i]->images[0]) roadmap_canvas_draw_image (table->object[i]->images[0], &ObjectLocation, 0,IMAGE_NORMAL); } if (table->object[i]->bar_text){ if (table->object[i]->font_size != 0) font_size = table->object[i]->font_size; else font_size = 10; if (table->object[i]->text_alling != -1){ text_flag = table->object[i]->text_alling; } else if (table->object[i]->pos_x < 0){ text_flag = ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP; } roadmap_canvas_create_pen (table->object[i]->bar_text->name); if (table->object[i]->text_color){ roadmap_canvas_set_foreground (table->object[i]->text_color); } else{ roadmap_canvas_set_foreground (table->object[i]->bar_text->default_foreground); } if (table->object[i]->state_fn) { state = (*table->object[i]->state_fn) (); if (state >0){ if (table->object[i]->images[state]){ TextLocation.x = ObjectLocation.x + roadmap_canvas_image_width(table->object[i]->images[state])/2; TextLocation.y = ObjectLocation.y + roadmap_canvas_image_height(table->object[i]->images[state])/2; } else roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,(*table->object[i]->bar_text->bar_text_fn)()); } } else{ if (table->object[i]->images[0]){ TextLocation.x = ObjectLocation.x + roadmap_canvas_image_width(table->object[i]->images[0])/2; TextLocation.y = ObjectLocation.y + roadmap_canvas_image_height(table->object[i]->images[0])/2 -2; } else roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,(*table->object[i]->bar_text->bar_text_fn)()); } } if (table->object[i]->fixed_text){ if (table->object[i]->font_size != 0) font_size = table->object[i]->font_size; else font_size = 10; if (table->object[i]->text_alling != -1){ text_flag = table->object[i]->text_alling; } else if (table->object[i]->pos_x < 0){ text_flag = ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP; } roadmap_canvas_create_pen (table->object[i]->name); if (table->object[i]->text_color){ roadmap_canvas_set_foreground (table->object[i]->text_color); } else{ if (roadmap_skin_state()) roadmap_canvas_set_foreground ("#ffffff"); else roadmap_canvas_set_foreground ("#000000"); } if (table->object[i]->state_fn) { state = (*table->object[i]->state_fn) (); if (state >0){ roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,table->object[i]->fixed_text); } } else{ roadmap_bar_pos(table->object[i], &TextLocation); roadmap_canvas_draw_string_size (&TextLocation, text_flag, font_size,table->object[i]->fixed_text); } } } }
static void roadmap_display_sign (RoadMapSign *sign) { RoadMapGuiPoint points[7]; RoadMapGuiPoint text_position; int width, height, ascent, descent; int screen_width; int sign_width, sign_height, text_height; int count; int i; int lines; RoadMapGuiPoint icon_screen_point; RoadMapImage image; roadmap_log_push ("roadmap_display_sign"); roadmap_canvas_get_text_extents (sign->content, 12, &width, &ascent, &descent, NULL); width += 8; /* Keep some room around the text. */ height = roadmap_canvas_height(); screen_width = roadmap_canvas_width(); /* Check if the text fits into one line, or if we need to use * more than one. */ if (width + 10 < screen_width) { sign_width = width; lines = 1; } else { sign_width = screen_width - 10; lines = 1 + ((width + 10) / screen_width); } for (i = 0; sign->content[i] != '\0'; i++) if (sign->content[i]=='\n') lines++; text_height = ascent + descent + 4; sign_height = lines * text_height ; // screen_width = roadmap_canvas_width(); if (sign->has_position) { int visible = roadmap_math_point_is_visible (&sign->position); if (sign->was_visible && (! visible)) { sign->deadline = 0; roadmap_log_pop (); return; } sign->was_visible = visible; roadmap_math_coordinate (&sign->position, points); roadmap_math_rotate_project_coordinate ( points ); if (sign->where == SIGN_TOP) { points[1].x = 5 + (screen_width - sign_width) / 2; points[2].x = points[1].x - 5; points[4].x = (screen_width + sign_width) / 2; points[6].x = points[1].x + 10; text_position.x = points[2].x + 4; } else if (points[0].x < screen_width / 2) { points[1].x = 10; points[2].x = 5; points[4].x = sign_width + 5; points[6].x = 20; text_position.x = 9; } else { points[1].x = screen_width - 10; points[2].x = screen_width - 5; points[4].x = screen_width - sign_width - 5; points[6].x = screen_width - 20; text_position.x = points[4].x + 4; } points[3].x = points[2].x; points[5].x = points[4].x; if (sign->where == SIGN_TOP || (points[0].y > height / 2)) { points[1].y = sign_height + roadmap_bar_top_height() +roadmap_ticker_height()+roadmap_message_ticker_height()+5; if (points[0].y < points[1].y){ points[0].x = points[1].x; points[0].y = points[1].y; } points[3].y = roadmap_bar_top_height() +roadmap_ticker_height()+roadmap_message_ticker_height()+5; text_position.y = roadmap_bar_top_height() + roadmap_ticker_height()+roadmap_message_ticker_height()+8; } else { points[1].y = height - sign_height - roadmap_bar_bottom_height() - 5; points[3].y = height - roadmap_bar_bottom_height() - 5; text_position.y = points[1].y + 3; } points[2].y = points[1].y; points[4].y = points[3].y; points[5].y = points[1].y; points[6].y = points[1].y; count = 7; roadmap_display_highlight (&sign->endpoint[0]); roadmap_display_highlight (&sign->endpoint[1]); } else { points[0].x = (screen_width - sign_width) / 2; points[1].x = (screen_width + sign_width) / 2; points[0].x = 2; points[1].x = 2+sign_width; points[2].x = points[1].x; points[3].x = points[0].x; switch (sign->where) { case SIGN_BOTTOM: points[0].y = height - sign_height - roadmap_bar_bottom_height(); break; case SIGN_TOP: points[0].y = roadmap_bar_top_height() +roadmap_ticker_height()+roadmap_message_ticker_height()+3; break; case SIGN_RIGHT: points[0].y = roadmap_bar_top_height() +roadmap_ticker_height()+roadmap_message_ticker_height()+3; points[0].x = 2; points[1].x = 2+sign_width; points[2].x = points[1].x; points[3].x = points[0].x; break; case SIGN_CENTER: points[0].y = (height - sign_height) / 2; break; } points[1].y = points[0].y; points[2].y = points[0].y + sign_height; points[3].y = points[2].y; text_position.x = points[0].x + 4; text_position.y = points[0].y + 1; count = 4; } roadmap_canvas_select_pen (sign->background); roadmap_canvas_set_opacity(181); roadmap_canvas_draw_multiple_polygons (1, &count, points, 1, 0); roadmap_canvas_select_pen (RoadMapMessageContour); roadmap_canvas_draw_multiple_polygons (1, &count, points, 0, 0); if (sign->image != NULL){ image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, sign->image); icon_screen_point.x = points[3].x + 2; icon_screen_point.y = points[3].y+sign_height/2 - roadmap_canvas_image_width(image)/2; roadmap_canvas_draw_image (image, &icon_screen_point, 0, IMAGE_NORMAL); } roadmap_canvas_select_pen (sign->foreground); roadmap_display_string (sign->content, lines, text_height, &text_position, ROADMAP_CANVAS_TOPLEFT); roadmap_log_pop (); }