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 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); } }
void roadmap_bar_draw_bottom_bar (BOOL draw_bg) { int image_width, image_height; int screen_width, screen_height; if (!bar_initialized) return; if (gHideBottomBar) return; screen_width = roadmap_canvas_width (); screen_height = roadmap_canvas_height(); image_width = BottomBarBgImageSize.width; image_height = BottomBarBgImageSize.height; if (BottomBarObjectTable.draw_bg && draw_bg){ RoadMapGuiPoint BarLocation; BarLocation.y = screen_height - image_height; BarLocation.x = 0; if ( BottomBarFullBg ) { roadmap_canvas_draw_image (BottomBarFullBg, &BarLocation, 0, IMAGE_NORMAL); } else { drawBarBGImage( BOTTOM_BAR_IMAGE, &BarLocation ); } } draw_objects(&BottomBarObjectTable); }
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 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 draw_title_bar(RoadMapGuiRect *rect){ static RoadMapImage header_image; RoadMapGuiPoint point; static RoadMapImage cached_header_image; static int cached_width = -1; rect->miny -= 1; if (!header_image) header_image = roadmap_res_get( RES_BITMAP, RES_SKIN|RES_NOCACHE, "header"); point.x = rect->minx; point.y = rect->miny; #if defined( OPENGL ) draw_title_bar_image( header_image, rect, &point ); #else if ((cached_header_image == NULL) || (cached_width != roadmap_canvas_width())){ if (cached_header_image != NULL) roadmap_canvas_free_image(cached_header_image); cached_header_image = create_title_bar_image (header_image, rect); cached_width = roadmap_canvas_width(); } roadmap_canvas_draw_image (cached_header_image, &point, 0, IMAGE_NORMAL); #endif }
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); }
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); }
void roadmap_screen_obj_draw (void) { RoadMapScreenObj cursor; int height = roadmap_canvas_height (); int width = roadmap_canvas_width(); if (!initialized) return; if ((height != screen_height) && (width != screen_width)){ roadmap_screen_obj_reload(); } for (cursor = RoadMapObjectList; cursor != NULL; cursor = cursor->next) { int state = 0; int image_mode = IMAGE_NORMAL; RoadMapGuiPoint pos; if (cursor->state_fn) { state = (*cursor->state_fn) (); if ((state < 0) || (state >= MAX_STATES)) continue; } if (cursor == RoadMapScreenObjSelected) { image_mode = IMAGE_SELECTED; } roadmap_screen_obj_pos (cursor, &pos); if (cursor->images[state]) { roadmap_canvas_draw_image (cursor->images[state], &pos, cursor->opacity, image_mode); } if (cursor->sprites[state]) { if (cursor->flags & OBJ_FLAG_NO_ROTATE) { roadmap_sprite_draw (cursor->sprites[state], &pos, -roadmap_math_get_orientation()); } else { roadmap_sprite_draw (cursor->sprites[state], &pos, 0); } } } }
void roadmap_display_image_sign(RoadMapSign *sign) { int screen_width; int screen_height; RoadMapGuiPoint position; RoadMapImage image; screen_width = roadmap_canvas_width(); screen_height = roadmap_canvas_height(); if (sign->where == SIGN_TOP){ position.x = 3; position.y = roadmap_bar_top_height() + 3; } if (sign->image != NULL){ image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, sign->image); roadmap_canvas_draw_image (image, &position, 0, IMAGE_NORMAL); } }
static int roadmap_screen_obj_pressed (RoadMapGuiPoint *point) { int state = 0; RoadMapScreenObjSelected = roadmap_screen_obj_by_pos (point); if (!RoadMapScreenObjSelected) return 0; /* There is no draggable objects on the screen. In the future if there will be such an * objects the short/long click handling for the small drag has to be in the drag_end event * like in the ssd_dialog */ roadmap_pointer_cancel_dragging(); if (RoadMapScreenObjSelected->state_fn) { state = (*RoadMapScreenObjSelected->state_fn) (); if ((state < 0) || (state >= MAX_STATES)) return 1; } if (RoadMapScreenObjSelected->images[state]) { RoadMapGuiPoint pos; roadmap_screen_obj_pos (RoadMapScreenObjSelected, &pos); roadmap_canvas_draw_image (RoadMapScreenObjSelected->images[state], &pos, RoadMapScreenObjSelected->opacity, IMAGE_SELECTED); } roadmap_canvas_refresh (); if (RoadMapScreenObjSelected->flags & OBJ_FLAG_REPEAT) { if (RoadMapScreenObjSelected->action) { (*(RoadMapScreenObjSelected->action->callback)) (); } roadmap_main_set_periodic (OBJ_REPEAT_TIMEOUT, roadmap_screen_obj_repeat); } return 1; }
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_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); } } } }
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 (); }
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); }
// 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"); } } }
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); } } }
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 }
int roadmap_display_border(int style, int header, int pointer_type, RoadMapGuiPoint *bottom, RoadMapGuiPoint *top, const char* background, RoadMapPosition *position, int position_offset_y){ //static const char *fill_bg = "#f3f3f5";// "#e4f1f9"; RoadMapPen fill_pen; int screen_width, screen_height, sign_width, sign_height; RoadMapGuiPoint right_point, left_point, start_sides_point, point, new_point; int i, num_items; int count, start_pos_x, top_height; RoadMapGuiPoint sign_bottom, sign_top; RoadMapImage image; RoadMapGuiPoint points[3]; RoadMapGuiPoint fill_points[4]; screen_width = roadmap_canvas_width(); screen_height = roadmap_canvas_height(); if (top == NULL) { sign_top.x = 1; sign_top.y = roadmap_bar_top_height(); } else{ sign_top.x = top->x ; sign_top.y = top->y ; } if (bottom == NULL) { sign_bottom.x = screen_width-1; sign_bottom.y = screen_height - roadmap_bar_bottom_height(); } else{ sign_bottom.x = bottom->x ; sign_bottom.y = bottom->y ; } if ((pointer_type == POINTER_POSITION) || (pointer_type == POINTER_FIXED_POSITION)){ roadmap_math_coordinate (position, points); roadmap_math_rotate_project_coordinate ( points ); points[0].y += position_offset_y; } sign_width = sign_bottom.x - sign_top.x; sign_height = sign_bottom.y - sign_top.y; if (header != HEADER_NONE){ image = get_image(border_top, style, header, pointer_type, bottom, top, 0); roadmap_canvas_draw_image (image, &sign_top, 0, IMAGE_NORMAL); left_point.x = sign_top.x; right_point.x = left_point.x + sign_width - s_images[header+2].width ; start_sides_point.y = sign_top.y + s_images[header].height ; top_height = s_images[header].height+7; #ifndef __ROADMAP_BORDER_CACHE__ // Release after drawing roadmap_canvas_free_image( image ); #endif } else{ RoadMapImage image; left_point.x = sign_top.x; right_point.x = sign_bottom.x - s_images[border_white_right+style].width; start_sides_point.y = sign_top.y + s_images[border_white_top_right+style].height; left_point.y = sign_top.y ; image = get_image(border_top, style, header, pointer_type, bottom, top, 0); roadmap_canvas_draw_image (image, &left_point, 0, IMAGE_NORMAL); #ifndef __ROADMAP_BORDER_CACHE__ // Release after drawing roadmap_canvas_free_image( image ); #endif right_point.y = sign_top.y; if (style == STYLE_BLACK) top_height = s_images[border_white_top+style].height+7; else top_height = s_images[border_white_top+style].height; } num_items = ( sign_height - start_sides_point.y +sign_top.y - s_images[border_white_bottom+style].height ) / s_images[border_white_right+style].height; if (num_items < 0 ) return 0; image = get_image(border_sides, style, header, pointer_type, bottom, top, 1); for (i = 0; i < num_items; i++){ point.x = left_point.x; point.y = start_sides_point.y + i*s_images[border_white_right+style].height; roadmap_canvas_draw_image (image, &point, 0, IMAGE_NORMAL); } point.y += roadmap_canvas_image_height(image)-1; #ifndef __ROADMAP_BORDER_CACHE__ // Release after drawing roadmap_canvas_free_image( image ); #endif if (pointer_type == POINTER_NONE){ RoadMapImage image; left_point.y = point.y + s_images[border_white_left+style].height ; image = get_image(border_bottom, style, header, pointer_type, bottom, top, 0); roadmap_canvas_draw_image (image, &left_point, 0, IMAGE_NORMAL); #ifndef __ROADMAP_BORDER_CACHE__ // Release after drawing roadmap_canvas_free_image( image ); #endif } else{ left_point.y = point.y + s_images[border_white_left+style].height ; roadmap_canvas_draw_image (s_images[border_white_bottom_left+style].image, &left_point, 0, IMAGE_NORMAL); right_point.y = point.y + s_images[border_white_right+style].height; roadmap_canvas_draw_image (s_images[border_white_bottom_right+style].image, &right_point, 0, IMAGE_NORMAL); if (pointer_type == POINTER_MENU) num_items = 1; else if (pointer_type == POINTER_COMMENT){ num_items = ((right_point.x - left_point.x)/s_images[border_white_bottom+style].width)/4 -2; } else if (pointer_type == POINTER_FIXED_POSITION){ int pointer_draw_offset; pointer_draw_offset = points[0].x - 15 - left_point.x; if (pointer_draw_offset+sign_top.x > sign_bottom.x-52) pointer_draw_offset = sign_bottom.x-52-sign_top.x; if (pointer_draw_offset+sign_top.x < sign_top.x+30) pointer_draw_offset = 30; num_items = (pointer_draw_offset-21)/s_images[border_white_bottom+style].width; } else if (pointer_type == POINTER_POSITION) num_items = (right_point.x - left_point.x- 100)/s_images[border_white_bottom+style].width; else num_items = ((right_point.x - left_point.x)/s_images[border_white_bottom+style].width)/2 -2; for (i = 0; i<num_items; i++){ point.x = left_point.x + s_images[border_white_bottom_left+style].width + i * s_images[border_white_bottom+style].width ; point.y = left_point.y; roadmap_canvas_draw_image (s_images[border_white_bottom+style].image, &point, 0, IMAGE_NORMAL); } if ((pointer_type == POINTER_POSITION) || (pointer_type == POINTER_FIXED_POSITION)){ int visible = roadmap_math_point_is_visible (position); if (visible){ int count = 3; RoadMapPen pointer_pen; if (points[0].y > (point.y +10) ){ points[1].x = point.x; points[1].y = point.y+s_images[border_black_bottom_no_frame].height-3; points[2].x = point.x+42; points[2].y = point.y+s_images[border_black_bottom_no_frame].height-3; pointer_pen = roadmap_canvas_create_pen ("fill_pop_up_pen"); roadmap_canvas_set_foreground("#000000"); roadmap_canvas_set_opacity(181); count = 3; roadmap_canvas_draw_multiple_polygons (1, &count, points, 1, 0); for (i=0; i<40; i++){ point.x = point.x + s_images[border_black_bottom_no_frame].width ; point.y = point.y; roadmap_canvas_draw_image (s_images[border_black_bottom_no_frame].image, &point, 0, IMAGE_NORMAL); } } } start_pos_x = point.x+1; } else{ roadmap_canvas_draw_image (s_images[pointer_type].image, &point, 0, IMAGE_NORMAL); start_pos_x = point.x + s_images[pointer_type].width; } num_items = (right_point.x - start_pos_x )/s_images[border_white_bottom+style].width ; for (i = 0; i<num_items; i++){ new_point.x = start_pos_x + i * s_images[border_white_bottom+style].width ; new_point.y = point.y; roadmap_canvas_draw_image (s_images[border_white_bottom+style].image, &new_point, 0, IMAGE_NORMAL); } } //Fill the if ((style == STYLE_NORMAL) || (style == STYLE_BLACK)){ if ((pointer_type == POINTER_POSITION) || (pointer_type == POINTER_FIXED_POSITION)|| (pointer_type == POINTER_COMMENT)) point.y -= 1; fill_points[0].x =right_point.x ; fill_points[0].y =point.y +1; fill_points[1].x =right_point.x ; fill_points[1].y = top->y + top_height -7; fill_points[2].x = left_point.x + s_images[border_white_left+style].width ; fill_points[2].y = top->y + top_height - 7; fill_points[3].x =left_point.x + s_images[border_white_left+style].width ; fill_points[3].y = point.y +1; count = 4; } else{ fill_points[0].x =right_point.x+2 ; fill_points[0].y =point.y +2; fill_points[1].x =right_point.x +2; fill_points[1].y = top->y + top_height -2; fill_points[2].x = left_point.x + s_images[border_white_left+style].width -2; fill_points[2].y = top->y + top_height - 2; fill_points[3].x =left_point.x + s_images[border_white_left+style].width -2; fill_points[3].y = point.y +2; count = 4; } fill_pen = roadmap_canvas_create_pen ("fill_pop_up_pen"); roadmap_canvas_set_foreground(background); if (style == STYLE_BLACK) roadmap_canvas_set_opacity(181); roadmap_canvas_draw_multiple_polygons (1, &count, fill_points, 1,0 ); return sign_width; }
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); } } } }