예제 #1
0
static void _draw_bar(SsdWidget widget, RoadMapGuiRect *rect, int flags) {

	static RoadMapImage bar_image = NULL;

	if (!bar_image)
		bar_image = roadmap_res_get(RES_BITMAP, RES_SKIN | RES_NOCACHE, "events_on_route_bar");

	if (bar_image) {
		RoadMapGuiPoint sign_bottom, sign_top;
		RoadMapGuiPoint position;
		sign_top.x = rect->minx + ADJ_SCALE(15);
		sign_top.y = rect->miny;
		position.x = roadmap_canvas_image_width(bar_image) / 2;
		position.y = roadmap_canvas_image_height(bar_image) / 2;
		sign_bottom.x = rect->maxx - ADJ_SCALE(15);
		sign_bottom.y = rect->miny + roadmap_canvas_image_height(bar_image);
		if (flags & SSD_GET_SIZE) {
			rect->maxy = rect->miny + roadmap_canvas_image_height(bar_image) + 5;
			rect->minx = rect->minx + ADJ_SCALE(15);
			rect->maxx = rect->maxx - ADJ_SCALE(15);
			return;
		}
		else {
			roadmap_canvas_draw_image_stretch(bar_image, &sign_top, &sign_bottom, &position, 0,
					IMAGE_NORMAL);
		}
	}
}
예제 #2
0
static int set_value (SsdWidget widget, const char *value) {
   struct ssd_button_data *data = (struct ssd_button_data *) widget->data;
   RoadMapImage bmp = NULL;
	int max_width = 0;
	int max_height = 0;
	int is_different = 0;
   int i;

   if (widget->value && *widget->value) free (widget->value);

   if (*value) widget->value = strdup(value);
   else widget->value = "";

   if (widget->flags & SSD_VAR_SIZE) {
   	widget->size.height = -1;
   	widget->size.width  = -1;
      return 0;
   }

	for (i=0; i<MAX_STATES; i++)
	{
      if (data->bitmap_images[i])
    	  bmp = data->bitmap_images[i];
      if ( !bmp )
    	  bmp = roadmap_res_get ( RES_BITMAP, RES_SKIN, data->bitmap_names[i] );

      if (!bmp) continue;

      if ( !max_width || !max_height )
      {
         max_width  = roadmap_canvas_image_width(bmp);
         max_height = roadmap_canvas_image_height(bmp);
      }
      else {
         int val = roadmap_canvas_image_width(bmp);
         if (max_width != val) {
            is_different = 1;
            if (val > max_width) max_width = val;
         }

         val = roadmap_canvas_image_height(bmp);
         if (max_height != val) {
            is_different = 1;
            if (val > max_height) max_height = val;
         }
      }
   }

	widget->size.height = max_height;
  	widget->size.width  = max_width;

   return 0;
}
예제 #3
0
void roadmap_bar_draw_bottom_bar (BOOL draw_bg) {
	int i;
	int num_images;
	int image_width, image_height;
	int screen_width, screen_height;

	screen_width = roadmap_canvas_width ();
	screen_height = roadmap_canvas_height();

	if (!bar_initialized)
		return;

   if (gHideBottomBar)
      return;
	image_width = roadmap_canvas_image_width(BottomBarBgImage);
	image_height = roadmap_canvas_image_height(BottomBarBgImage);

	if (BottomBarObjectTable.draw_bg && draw_bg){
		num_images = screen_width / image_width;
		for (i = 0; i < num_images; i++){
			RoadMapGuiPoint BarLocation;
			BarLocation.y = screen_height - image_height;
			BarLocation.x = i * image_width;
		   roadmap_canvas_draw_image (BottomBarBgImage, &BarLocation, 0,
	         IMAGE_NORMAL);
		}
	}
	draw_objects(&BottomBarObjectTable);

}
예제 #4
0
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);
	}

}
예제 #5
0
int roadmap_bar_top_height(){
	if (TopBarBgImage == NULL){
		return 0;
	}
	else
		return roadmap_canvas_image_height(TopBarBgImage);
}
예제 #6
0
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
}
예제 #7
0
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
}
예제 #8
0
static RoadMapImage createBGImage (RoadMapImage BarBgImage) {

   RoadMapImage image;
   int width = roadmap_canvas_width ();
   int height = roadmap_canvas_height();
   int num_images;
   int image_width;
   int i;

   if (height > width){
      width = width*2;
   }

   image = roadmap_canvas_new_image (width,
               roadmap_canvas_image_height(BarBgImage));

   image_width = roadmap_canvas_image_width(BarBgImage);

   num_images = width / image_width ;

   RoadMapGuiRect *rect = malloc(sizeof(RoadMapGuiRect));
   rect->minx = num_images;
   rect->miny = 0;

//   for (i = 0; i < num_images; i++){
      RoadMapGuiPoint BarLocation;
      BarLocation.y = 0;
      BarLocation.x = 0;//i * image_width;
         roadmap_canvas_copy_image
         (image, &BarLocation, rect, BarBgImage ,CANVAS_COPY_NORMAL);
//   }
   return image;
}
예제 #9
0
BOOL roadmap_border_initialize()
{
   int   i;

   for( i=0; i<border_img__count; i++)
   {
      const char* image_filename = get_img_filename(i);

      assert(NULL != image_filename);

      s_images[i].image = (RoadMapImage)roadmap_res_get(
                                    RES_BITMAP,
                                    RES_SKIN|RES_NOCACHE,
                                    image_filename);

      if( !s_images[i].image)
      {
         roadmap_log(ROADMAP_ERROR,
                     "load_border_images::load_border_images() - Failed to load image file '%s.png'",
                     image_filename);
         return FALSE;
      }

      s_images[i].height = roadmap_canvas_image_height(s_images[i].image);
      s_images[i].width = roadmap_canvas_image_width(s_images[i].image);

   }

#ifdef __ROADMAP_BORDER_CACHE__
   border_cached_table.count = 0;
#endif // __ROADMAP_BORDER_CACHE__

   return TRUE;
}
예제 #10
0
int roadmap_bar_bottom_height(){
	if (BottomBarBgImage == NULL){
		return 0;
	}
	else
		return roadmap_canvas_image_height(BottomBarBgImage);
}
예제 #11
0
void roadmap_ticker_initialize(void){
   RoadMapImage image;
   gInitialized = FALSE;

	if ( roadmap_screen_is_hd_screen() )
	{
		gTickerTopBarOffset = -5;
	}

	roadmap_config_declare_enumeration ("user", &ShowTickerCfg, NULL, "yes", "no", NULL);

   image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TICKER_MIDDLE_IMAGE);
   if ( image == NULL){
		roadmap_log (ROADMAP_ERROR, "roadmap_ticker - cannot load %s image ", TICKER_MIDDLE_IMAGE);
		return;
    }

   gMiddleImageSize.width = roadmap_canvas_image_width( image );
   gMiddleImageSize.height = roadmap_canvas_image_height( image );


	OpenIconRct.miny = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset();
	OpenIconRct.maxy = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + gMiddleImageSize.height;

	RoadMapTickerPen = roadmap_canvas_create_pen ("Ticker_pen");
   roadmap_canvas_set_foreground (TICKER_FOREGROUND);
   show_close_icon();
   roadmap_pointer_register_pressed
         (roadmap_ticker_key_pressed, POINTER_HIGH);
   roadmap_pointer_register_short_click(roadmap_ticker_short_click, POINTER_HIGH);

   gInitialized = TRUE;
}
예제 #12
0
int ssd_button_change_images( SsdWidget widget, RoadMapImage* bitmap_images,
											const char **bitmap_names, int num_bitmaps )
{
	int i;
	RoadMapImage bmp;
	struct ssd_button_data *data = (struct ssd_button_data *) widget->data;
	for (i=0; i<num_bitmaps; i++)
	{
		set_bitmap_name( data, i, bitmap_names[i] );
		data->bitmap_images[i] = bitmap_images[i];
	}

	bmp = data->bitmap_images[0];
    if ( !bmp )
    {
    	bmp = roadmap_res_get ( RES_BITMAP, RES_SKIN, bitmap_names[0] );
    }

    if ( !bmp )
    {
      widget->size.height = widget->size.width = 0;
      return -1;
    }

    widget->size.height = roadmap_canvas_image_height( bmp );
    widget->size.width  = roadmap_canvas_image_width( bmp );

    return 0;
}
예제 #13
0
static RoadMapImage create_title_bar_image (RoadMapImage header_image, RoadMapGuiRect *rect) {

   RoadMapImage image;
   int width = roadmap_canvas_width ();
   int num_images;
   int image_width;
   RoadMapGuiPoint point;
   int i;

   image = roadmap_canvas_new_image (width,
               roadmap_canvas_image_height(header_image));
   image_width = roadmap_canvas_image_width(header_image);

   num_images = width / image_width;

   num_images = (rect->maxx/image_width)+1;
   if (header_image){
      for (i=0;i<=num_images;i++){
             point.x = i * image_width;
             point.y = 0;
             roadmap_canvas_copy_image (image, &point, NULL, header_image, CANVAS_COPY_NORMAL);
       }
    }

   return image;
}
예제 #14
0
void roadmap_bar_set_mode (int flags) {
   int x_offset;
   int y_offset;

   x_offset = 0;
   y_offset = roadmap_canvas_image_height (TopBarBgImage);

   if (flags & TOPBAR_FLAG) {
      roadmap_screen_obj_global_offset (x_offset, y_offset);
      roadmap_screen_move_center ((-y_offset / 2)+15);
   }

   if (flags & BOTTOM_BAR_FLAG){
      roadmap_screen_obj_global_offset (-x_offset, -y_offset);
      roadmap_screen_move_center (y_offset / 2);
   }

}
예제 #15
0
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);
			}
		}
	}
}
예제 #16
0
void roadmap_bar_initialize(void){
	int width;
	int i;
	const char *cursor;
    RoadMapFileContext file;
    RoadMapImage topBarBgImg, bottomBarBgImg;

	TopBarObjectTable.count = 0;

	for (i=0; i< MAX_OBJECTS;i++){
		TopBarObjectTable.object[i] = NULL;
		BottomBarObjectTable.object[i] = NULL;
	}
	TopBarObjectTable.draw_bg = TRUE;
	BottomBarObjectTable.draw_bg = TRUE;

	width = roadmap_canvas_width ();
	/*
	 * The bar images not in cache (persistent). Possible memory optimization point
	 * AGA
	 */
	topBarBgImg = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, TOP_BAR_IMAGE);
	if (topBarBgImg == NULL){
		return;
	}
	TopBarBgImageSize.width = roadmap_canvas_image_width( topBarBgImg );
	TopBarBgImageSize.height = roadmap_canvas_image_height( topBarBgImg );

	bottomBarBgImg = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, BOTTOM_BAR_IMAGE);
	if (bottomBarBgImg == NULL){
		return;
	}
	BottomBarBgImageSize.width = roadmap_canvas_image_width( bottomBarBgImg );
	BottomBarBgImageSize.height = roadmap_canvas_image_height( bottomBarBgImg );


#ifdef TOUCH_SCREEN
   TopBarSelectedBg = ( RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN|RES_NOCACHE, TOP_BAR_SELECTED_BG_IMAGE );
#endif

#if ! (defined(OPENGL))   // Draw directly 
   TopBarFullBg = createBGImage( topBarBgImg );

   BottomBarFullBg = createBGImage( bottomBarBgImg );
#endif

   /*
    * Deallocate the source images
    */
   roadmap_canvas_free_image( topBarBgImg );
   roadmap_canvas_free_image( bottomBarBgImg );


   // Load top bar
	cursor = roadmap_file_map ("skin", "top_bar", NULL, "r", &file);
	if (cursor == NULL){
		roadmap_log (ROADMAP_ERROR, "roadmap bar top_bar file is missing");
		return;
	}

    roadmap_bar_load(roadmap_file_base(file), roadmap_file_size(file), &TopBarObjectTable);

    roadmap_file_unmap (&file);

#ifndef J2ME
    // Load bottom bar
    cursor = roadmap_file_map ("skin", "bottom_bar", NULL, "r", &file);
	if (cursor == NULL){
		roadmap_log (ROADMAP_ERROR, "roadmap bottom top_bar file is missing");
		return;
	}

    roadmap_bar_load(roadmap_file_base(file), roadmap_file_size(file), &BottomBarObjectTable);

    roadmap_file_unmap (&file);
#endif

	roadmap_bar_set_mode(TOPBAR_FLAG);

	roadmap_pointer_register_short_click
      (roadmap_bar_short_click, POINTER_HIGH);

	roadmap_pointer_register_long_click
      (roadmap_bar_long_click, POINTER_HIGH);

	roadmap_pointer_register_pressed
 		(roadmap_bar_obj_pressed, POINTER_HIGH);

   roadmap_pointer_register_drag_start
      (roadmap_bar_drag_start, POINTER_HIGHEST);

   roadmap_pointer_register_released
      (roadmap_bar_obj_released, POINTER_HIGH);

	roadmap_skin_register (roadmap_bar_switch_skins);

#ifdef ANDROID
	roadmap_androidmenu_initialize();
#endif

	bar_initialized = TRUE;
}
예제 #17
0
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);
		}
	}

}
예제 #18
0
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);
			}
    	}
    }
}
예제 #19
0
// Draw the warning on the screen
void roadmap_alerter_display(void) {
    const char * iconName;
    int 	alertId;
    char AlertStr[200];
    RoadMapGuiPoint AlertIconLocation;
    int opacity;
    char distance_str[100];
//	RoadMapGpsPosition pos;
    RoadMapImage theIcon;
    BOOL is_cancelable;

    AlertStr[0] = 0;

    if (alert_should_be_visible) {


        if (!alert_active && the_active_alert.alert_type == ALERT) {

            roadmap_alerter_audio();
        }

        alertId = roadmap_alerter_get_active_alert_id();
        is_cancelable = (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->is_cancelable)) (alertId);
        if (!alert_active && is_cancelable)
            set_softkey();

//		alert_active = TRUE;
//
//		if (the_active_alert.alert_type == ALERT){
//				iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_alert_icon)) (alertId);
//		}
//		else {
//				iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_warning_icon)) (alertId);
//		}
//
//        snprintf(AlertStr + strlen(AlertStr), sizeof(AlertStr)
//                - strlen(AlertStr), "<b1>%s%s\n",roadmap_lang_get("Approaching"), roadmap_lang_get((* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_string)) (alertId) ));
//
//        snprintf(AlertStr + strlen(AlertStr), sizeof(AlertStr)
//                - strlen(AlertStr), roadmap_lang_get("%s: %d %s\n"),roadmap_lang_get("In"), the_active_alert.distance_to_alert, roadmap_lang_get(roadmap_math_distance_unit()));
//
// 		roadmap_navigate_get_current (&pos, NULL, NULL);
//        snprintf(AlertStr + strlen(AlertStr), sizeof(AlertStr)
//                - strlen(AlertStr), roadmap_lang_get("%d %s"),roadmap_math_to_speed_unit(pos.speed), roadmap_lang_get(roadmap_math_speed_unit()));
//
//	    roadmap_display_pop_up("Approach Alert", iconName , NULL, AlertStr);

        alertId = roadmap_alerter_get_active_alert_id();

        if (the_active_alert.alert_type == ALERT) {
            iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_alert_icon)) (alertId);
            if (iconName == NULL) {
                return;
            }
            theIcon = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, iconName );
            if (theIcon == NULL) {
                roadmap_log( ROADMAP_ERROR, "Alerts - Icon Not found (%s)", iconName);
                return;
            }
            alert_active = TRUE;
        }
        else {
            iconName =  (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->get_warning_icon)) (alertId);
            theIcon = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, iconName);
            if (theIcon == NULL) {
                roadmap_log( ROADMAP_ERROR, "Alerts - Icon Not found (%s)", iconName);
                return;
            }
            alert_active = TRUE;
        }

        AlertIconLocation.x = roadmap_canvas_width () - roadmap_canvas_image_width(theIcon);
        AlertIconLocation.y = roadmap_canvas_height ()/2 - roadmap_canvas_image_height(theIcon)/2 ;
        opacity = 0;

        sprintf(distance_str, "%d %s",  the_active_alert.distance_to_alert, roadmap_math_distance_unit());
        roadmap_display_text("Distance To Alert", distance_str);
        roadmap_canvas_draw_image (theIcon, &AlertIconLocation,opacity, IMAGE_NORMAL);


    } else {
        if (alert_active && !alert_should_be_visible) {
            alert_active = FALSE;
            if ((* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->is_cancelable)) (roadmap_alerter_get_active_alert_id()))
                remove_softkey();
            the_active_alert.active_alert_id = -1;
            roadmap_display_hide("Distance To Alert");
        }
    }
}
예제 #20
0
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);

}
예제 #21
0
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;

      }

   }
}
예제 #22
0
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

}
예제 #23
0
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();
}
예제 #24
0
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;

}
예제 #25
0
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;
   }
}