コード例 #1
0
ファイル: roadmap_bar.c プロジェクト: Priednis/WazeWP7
static BarObject *roadmap_bar_by_pos (RoadMapGuiPoint *point, BarObjectTable_s *table) {

   int i;
   int condition;

   for (i = 0; i < table->count; i++) {

      RoadMapGuiPoint pos;
      roadmap_bar_pos(table->object[i], &pos);

      if ((point->x >= (pos.x + table->object[i]->bbox.minx)) &&
          (point->x <= (pos.x + table->object[i]->bbox.maxx)) &&
          (point->y >= (pos.y + table->object[i]->bbox.miny)) &&
          (point->y <= (pos.y + table->object[i]->bbox.maxy))) {

			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;
    		}

         return table->object[i];
      }
   }

   return NULL;
}
コード例 #2
0
ファイル: roadmap_bar.c プロジェクト: NNN-zz/Freemap-waze
static BarObject *roadmap_bar_by_pos (RoadMapGuiPoint *point, BarObjectTable_s *table) {

   int i;
   int condition;
   
   for (i = 0; i < table->count; i++) {

      RoadMapGuiPoint pos;
      roadmap_bar_pos(table->object[i], &pos);

      if ((point->x >= (pos.x + table->object[i]->bbox.minx)) &&
          (point->x <= (pos.x + table->object[i]->bbox.maxx)) &&
          (point->y >= (pos.y + table->object[i]->bbox.miny)) &&
          (point->y <= (pos.y + table->object[i]->bbox.maxy))) {

			if (table->object[i]->condition_fn){
				condition = (*table->object[i]->condition_fn) ();
    			if (condition !=  table->object[i]->condition_value)
    			continue;
    		}
				
         return table->object[i];
      }
   }

   return NULL;
}
コード例 #3
0
ファイル: roadmap_bar.c プロジェクト: Priednis/WazeWP7
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);
			}
		}
	}
}
コード例 #4
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);
			}
    	}
    }
}