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_bar_switch_skins(void){ TopBarBgImage = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, TOP_BAR_IMAGE); BottomBarBgImage = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, BOTTOM_BAR_IMAGE); #ifdef IPHONE roadmap_main_adjust_skin (roadmap_skin_state()); #endif //IPHONE }
static void roadmap_bar_switch_skins(void){ // Only in case we want a different bg for day and night // if (TopBarBgImage) roadmap_canvas_free_image(TopBarBgImage); // TopBarBgImage = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, TOP_BAR_IMAGE); // // if (BottomBarBgImage) roadmap_canvas_free_image(BottomBarBgImage); // BottomBarBgImage = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, BOTTOM_BAR_IMAGE); // // if (TopBarFullBg) roadmap_canvas_free_image(TopBarFullBg); // TopBarFullBg = createBGImage(TopBarBgImage); // // if (BottomBarFullBg) roadmap_canvas_free_image(BottomBarFullBg); // BottomBarFullBg = createBGImage(BottomBarBgImage); #ifdef IPHONE roadmap_main_adjust_skin (roadmap_skin_state()); #endif //IPHONE }
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_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 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); } } } }