static void draw_bg(RoadMapGuiRect *rect){ static RoadMapPen day_pen = NULL; static RoadMapPen night_pen = NULL; if (roadmap_skin_state()){ if (night_pen == NULL){ night_pen = roadmap_canvas_create_pen("container_bg_pen_night"); roadmap_canvas_set_foreground ("#74859b"); roadmap_canvas_set_thickness (1); } else{ roadmap_canvas_select_pen(night_pen); } } else{ if (day_pen == NULL){ day_pen = roadmap_canvas_create_pen("container_bg_pen_day"); roadmap_canvas_set_foreground ("#70bfea"); roadmap_canvas_set_thickness (1); } else{ roadmap_canvas_select_pen(day_pen); } } roadmap_canvas_erase_area(rect); }
void roadmap_canvas_draw_image (RoadMapImage image, const RoadMapGuiPoint *pos, int opacity, int mode) { if (!image){ assert(1); return; } if ( !roadmap_canvas_check_cached( image ) ) { return; } if ((mode == IMAGE_SELECTED) || (opacity <= 0) || (opacity >= 255)) { opacity = 255; } agg_renb.blend_from(image->pixfmt, 0, pos->x, pos->y, opacity); if (mode == IMAGE_SELECTED) { static RoadMapPen selection; if (!selection) { selection = roadmap_canvas_create_pen("selection"); roadmap_canvas_set_foreground ("#000000"); } RoadMapGuiPoint points[5] = { {pos->x, pos->y}, {pos->x + image->rbuf.width(), pos->y}, {pos->x + image->rbuf.width(), pos->y + image->rbuf.height()}, {pos->x, pos->y + image->rbuf.height()}, {pos->x, pos->y}}; int num_points = 5; RoadMapPen current = roadmap_canvas_select_pen (selection); roadmap_canvas_draw_multiple_lines (1, &num_points, points, 0); roadmap_canvas_select_pen (current); } // AGA DEBUG if ( image->full_path ) { // roadmap_canvas_free_image_buffer( image ); } }
void roadmap_canvas_set_foreground (const char *color) { if (!CurrentPen) return; CurrentPen->color = roadmap_canvas_agg_parse_color(color); roadmap_canvas_select_pen(CurrentPen); }
RoadMapPen roadmap_canvas_create_pen (const char *name) { struct roadmap_canvas_pen *pen; for (pen = RoadMapPenList; pen != NULL; pen = pen->next) { if (strcmp(pen->name, name) == 0) break; } if (pen == NULL) { pen = new roadmap_canvas_pen(); roadmap_check_allocated(pen); pen->name = strdup (name); pen->color = agg::rgba8(0, 0, 0); pen->thickness = 1; pen->next = RoadMapPenList; RoadMapPenList = pen; } roadmap_canvas_select_pen (pen); roadmap_canvas_set_thickness (pen->thickness); return pen; }
void roadmap_sprite_draw (const char *name, RoadMapGuiPoint *location, int orientation) { RoadMapSprite sprite = roadmap_sprite_search (name); RoadMapSpritePlane *plane; if (sprite == NULL) return; for (plane = &(sprite->first); plane != NULL; plane = plane->next) { roadmap_canvas_select_pen (plane->pen); if (plane->polygons.object_count > 0) { roadmap_sprite_place (&(plane->polygons), location, orientation); roadmap_canvas_draw_multiple_polygons (plane->polygons.object_count, plane->polygons.objects, RoadMapSpritePoints, 1, 0); } if (plane->disks.object_count > 0) { roadmap_sprite_place (&(plane->disks), location, orientation); roadmap_canvas_draw_multiple_circles (plane->disks.object_count, RoadMapSpritePoints, plane->disks.objects, 1, 0); } if (plane->lines.object_count > 0) { roadmap_sprite_place (&(plane->lines), location, orientation); roadmap_canvas_draw_multiple_lines (plane->lines.object_count, plane->lines.objects, RoadMapSpritePoints, 0); } if (plane->circles.object_count > 0) { roadmap_sprite_place (&(plane->circles), location, orientation); roadmap_canvas_draw_multiple_circles (plane->circles.object_count, RoadMapSpritePoints, plane->circles.objects, 0, 0); } } }
void roadmap_layer_adjust (void) { int i; int j; int k; int future_thickness; int thickness; struct roadmap_canvas_category *category; if (last_zoom == roadmap_math_get_zoom()) return; if (!RoadMapCategoryCount) return; last_zoom = roadmap_math_get_zoom(); for (i = RoadMapCategoryCount; i > 0; --i) { category = RoadMapCategory + i; for (k=0; k<LAYER_PROJ_AREAS; k++) { if (roadmap_layer_is_visible(i, k)) { thickness = roadmap_math_thickness (category->thickness, category->declutter, k+1, category->pen_count > 1); if (thickness <= 0) thickness = 1; #ifdef VIEW_MODE_3D_OGL if (roadmap_screen_get_view_mode() == VIEW_MODE_3D) thickness *= 2; #endif if (thickness > 40) thickness = 40; #if !defined (OPENGL) && !defined (J2ME) if (roadmap_screen_fast_refresh()) { if (thickness && (thickness <= 4)) thickness = 1; #elif defined(J2ME) if (thickness && (thickness <= 4)) { thickness = 1; } else #endif { /* As a matter of taste, I do dislike roads with a filler * of 1 pixel. Lets force at least a filler of 2. */ future_thickness = thickness; for (j = 1; j < category->pen_count; ++j) { if (category->delta_thickness[j] > 0) break; future_thickness = category->thickness + category->delta_thickness[j]; if (future_thickness == 1) { thickness += 1; } } } #if !defined (OPENGL) && !defined (J2ME) } #endif if (k == 0) { roadmap_plugin_adjust_layer (i, thickness, category->pen_count); } if (thickness > 0) { roadmap_canvas_select_pen (category->pen[k][0]); roadmap_canvas_set_thickness (thickness); } category->in_use[k][0] = 1; for (j = 1; j < category->pen_count; ++j) { /* The previous thickness was already the minimum: * the pens that follow should not be used. */ if (thickness <= 1) { category->in_use[k][j] = 0; continue; } if (category->delta_thickness[j] < 0) { thickness += category->delta_thickness[j]; #ifdef VIEW_MODE_3D_OGL if (roadmap_screen_get_view_mode() == VIEW_MODE_3D/* && !roadmap_screen_fast_refresh()*/) thickness += category->delta_thickness[j]*2; //increase the delta #endif } else { /* Don't end with a road mostly drawn with the latter * pen. */ if ((category->delta_thickness[j] >= thickness / 2) && (j != 2)) { category->in_use[k][j] = 0; thickness = 1; continue; } thickness = category->delta_thickness[j]; } /* If this pen is not visible, there is no reason * to draw it. */ if (thickness < 1) { category->in_use[k][j] = 0; continue; } roadmap_canvas_select_pen (category->pen[k][j]); roadmap_canvas_set_thickness (thickness); category->in_use[k][j] = 1; } } } } }
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; } } }
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_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 RealtimeTrafficInfoScreenRepaint (int max_pen) { int i; int iNumLines; int width = TRAFFIC_PEN_WIDTH; int previous_with = -1; int previous_type = -1; if (!isDisplayingTrafficInfoOn()) return; if (RTTrafficInfo_IsEmpty()) return; iNumLines = RTTrafficInfo_GetNumLines(); for (i=0; i<iNumLines; i++) { RTTrafficInfoLines *pTrafficLine = RTTrafficInfo_GetLine(i); RoadMapGuiPoint seg_middle; RoadMapPen previous_pen; RoadMapPen layer_pen; roadmap_square_set_current(pTrafficLine->pluginLine.square); if (!roadmap_layer_is_visible (pTrafficLine->pluginLine.cfcc, 0)) continue; if (!roadmap_math_line_is_visible (&pTrafficLine->positionFrom, &pTrafficLine->positionTo)) continue; layer_pen = roadmap_layer_get_pen (pTrafficLine->pluginLine.cfcc, 0, 0); if (layer_pen) width = roadmap_canvas_get_thickness (layer_pen)+1; else width = TRAFFIC_PEN_WIDTH; if (width < TRAFFIC_PEN_WIDTH) { width = TRAFFIC_PEN_WIDTH; } previous_pen = roadmap_canvas_select_pen (pens[pTrafficLine->iType]); roadmap_canvas_set_thickness (width); if (previous_pen) { roadmap_canvas_select_pen (previous_pen); } if ((width != previous_with) || (previous_type != pTrafficLine->iType)) roadmap_screen_draw_flush(); previous_with = width; previous_type = pTrafficLine->iType; roadmap_screen_draw_one_line (&pTrafficLine->positionFrom, &pTrafficLine->positionTo, 0, &pTrafficLine->positionFrom, pTrafficLine->iFirstShape, pTrafficLine->iLastShape, roadmap_shape_get_position, &pens[pTrafficLine->iType], 1, -1, NULL, &seg_middle, NULL); if (width >= 4){ static const char *direction_colors[3] = {"#fd9f0b", "#FFF380", "#FFFFFF"}; roadmap_screen_draw_line_direction (&pTrafficLine->positionFrom, &pTrafficLine->positionTo, &pTrafficLine->positionFrom, pTrafficLine->iFirstShape, pTrafficLine->iLastShape, roadmap_shape_get_position, width, pTrafficLine->iDirection, direction_colors[pTrafficLine->iType]); } } }
void roadmap_canvas_set_opacity (int opacity) { if (!CurrentPen) return; CurrentPen->color.a = opacity; roadmap_canvas_select_pen(CurrentPen); }
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_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 (); }
static void roadmap_display_console_box (int type, int corner, const char *format) { char text[256]; int count; int width, ascent, descent; int warning_font_size = 13; int offset = 62; #ifdef ANDROID warning_font_size = 15; #endif RoadMapGuiPoint frame[4]; #ifdef _WIN32 offset = 33; #endif count = 4; if (! roadmap_message_format (text, sizeof(text), format)) { return; } #ifdef QTMOBILITY { roadmap_display_set_message(text); return; } #endif if ( type == ROADMAP_CONSOLE_WARNING ){ roadmap_canvas_get_text_extents (text, warning_font_size, &width, &ascent, &descent, NULL); while (width > (roadmap_canvas_width()-10)){ warning_font_size--; roadmap_canvas_get_text_extents (text, warning_font_size, &width, &ascent, &descent, NULL); } } else if (type == ROADMAP_CONSOLE_ACTIVITY ){ roadmap_canvas_get_text_extents (text, 12, &width, &ascent, &descent, NULL); } else { roadmap_canvas_get_text_extents (text, 16, &width, &ascent, &descent, NULL); } if (roadmap_screen_is_hd_screen()) offset = 94; if (type == ROADMAP_CONSOLE_ACTIVITY) { #ifdef TOUCH_SCREEN if (roadmap_horizontal_screen_orientation()) frame[2].x = roadmap_canvas_width() - offset; else #endif frame[2].x = roadmap_canvas_width() ; frame[0].x = frame[2].x - width - 4; } else if (corner & ROADMAP_CANVAS_RIGHT) { #ifdef TOUCH_SCREEN if (roadmap_horizontal_screen_orientation()) frame[2].x = roadmap_canvas_width() - 5-offset; else #endif frame[2].x = roadmap_canvas_width() - 1 ; frame[0].x = frame[2].x - width - 6; } else { frame[0].x = 5; frame[2].x = frame[0].x + width + 6; } frame[1].x = frame[0].x; frame[3].x = frame[2].x; if (corner & ROADMAP_CANVAS_BOTTOM) { frame[0].y = roadmap_canvas_height () - ascent - descent - 11 - 22; frame[1].y = roadmap_canvas_height () - 6 - 22; } else { if ( type == ROADMAP_CONSOLE_ACTIVITY || type == ROADMAP_CONSOLE_WARNING ) { frame[0].y = roadmap_bar_top_height() + roadmap_ticker_height()+ roadmap_message_ticker_height()+1; } else { frame[0].y = 40; } frame[1].y = ascent + descent + frame[0].y + 6; } frame[2].y = frame[1].y; frame[3].y = frame[0].y; count = 4; if (type == ROADMAP_CONSOLE_WARNING ) { roadmap_canvas_select_pen (RoadMapWarningBackground); roadmap_canvas_set_opacity(181); } else if (type == ROADMAP_CONSOLE_ACTIVITY) { roadmap_canvas_select_pen (RoadMapActivityBackground); } else { roadmap_canvas_select_pen (RoadMapConsoleBackground); } roadmap_canvas_draw_multiple_polygons (1, &count, frame, 1, 0); if (type == ROADMAP_CONSOLE_WARNING) { roadmap_canvas_select_pen (RoadMapWarningForeground); } else if (type == ROADMAP_CONSOLE_ACTIVITY) { roadmap_canvas_select_pen (RoadMapActivityForeground); } else { roadmap_canvas_select_pen (RoadMapConsoleForeground); } if (type != ROADMAP_CONSOLE_WARNING ) roadmap_canvas_draw_multiple_polygons (1, &count, frame, 0, 0); frame[0].x = frame[3].x - 3; frame[0].y = frame[3].y + 1; if (type == ROADMAP_CONSOLE_WARNING ) { roadmap_canvas_draw_string_size (frame, ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP, warning_font_size,text); } else if (type == ROADMAP_CONSOLE_ACTIVITY) roadmap_canvas_draw_string_size (frame, ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP, 12,text); else roadmap_canvas_draw_string (frame, ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP, text); }