Exemplo n.º 1
0
Arquivo: display.c Projeto: bert/depcb
static void
show_point(PcbItem *item, int layer)
{
#define rad 3.0
#define siz 3.5
	if (item->flags & PCB_POI)
		item->canvas_item[layer] =
		    goo_canvas_rect_new(pcb.layer[layer].olay,
			item->p.x - siz, item->p.y - siz, siz * 2, siz * 2,
			"stroke-color", "black", "fill-color",
			item->flags & PCB_SELECTED ? "red" : "yellow", NULL);
	else if (item->flags & PCB_BEND)
		item->canvas_item[layer] =
		    goo_canvas_ellipse_new(pcb.layer[layer].olay,
			item->p.x, item->p.y, 2, 2,
			"stroke-color", "black", "fill-color",
			item->flags & PCB_SELECTED ? "green" : "black", NULL);
	else
		item->canvas_item[layer] =
		    goo_canvas_ellipse_new(pcb.layer[layer].olay,
			item->p.x, item->p.y, rad, rad,
			"stroke-color", "black", "fill-color",
			item->flags & PCB_SELECTED ? "green" : "white", NULL);
#undef rad
#undef siz
}
Exemplo n.º 2
0
static void node_item_init (NodeItem *item)
{
	item->priv = g_new0 (NodeItemPriv, 1);
	item->priv->dot_item =
	    goo_canvas_ellipse_new (GOO_CANVAS_ITEM (item), 0.0, 0.0, 2.0, 2.0, "fill-color", "black",
	                            "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
	item->priv->circle_item = goo_canvas_ellipse_new (
	    GOO_CANVAS_ITEM (item), 0.0, 0.0, 3.0, 3.0, "stroke-color-rgba", 0x3399FFFF, "line-width",
	    1.0, "visibility",
	    oregano_options_debug_dots () ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
}
Exemplo n.º 3
0
static void launch_dart(double item_x, double item_y)
{

  animate_item_x	= item_x;
  animate_item_y	= item_y;
  animate_item_size	= MAX_DART_SIZE;
  animate_item_distance	= targetDefinition[gcomprisBoard->level-1].target_distance/10;

  gc_sound_play_ogg ("sounds/line_end.wav", NULL);

  animate_item = goo_canvas_ellipse_new (boardRootItem,
					(double)item_x,
					(double)item_y,
					(double)MAX_DART_SIZE,
					(double)MAX_DART_SIZE,
					"fill_color_rgba", 0xFF80FFFF,
					"stroke-color", "white",
					"line-width", (double)1,
					NULL);
  /* Make sure the target values stay on top */
  goo_canvas_item_lower(animate_item, valueRootItem);
  animate_id = gtk_timeout_add (200, (GtkFunction) animate_items, NULL);

  if(--number_of_arrow == 0)
    {
      request_score();
    }

}
Exemplo n.º 4
0
static void
create_demo_table (GooCanvasItem *root,
		   gdouble        x,
		   gdouble        y,
		   gdouble        width,
		   gdouble        height)
{
  GooCanvasItem *table, *square, *circle, *triangle;

  table = goo_canvas_table_new (root,
                                "row-spacing", 4.0,
                                "column-spacing", 4.0,
				"width", width,
				"height", height,
                                NULL);
  goo_canvas_item_translate (table, x, y);

  square = goo_canvas_rect_new (table, 0.0, 0.0, 50.0, 50.0,
				"fill-color", "red",
				NULL);
  goo_canvas_item_set_child_properties (table, square,
					"row", 0,
					"column", 0,
					"x-shrink", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (square), "id", "Red square");
  g_signal_connect (square, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);

  circle = goo_canvas_ellipse_new (table, 0.0, 0.0, 25.0, 25.0,
				   "fill-color", "blue",
				   NULL);
  goo_canvas_item_set_child_properties (table, circle,
					"row", 0,
					"column", 1,
					"x-shrink", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (circle), "id", "Blue circle");
  g_signal_connect (circle, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);

  triangle = goo_canvas_polyline_new (table, TRUE, 3,
				      25.0, 0.0, 0.0, 50.0, 50.0, 50.0,
				      "fill-color", "yellow",
				      NULL);
  goo_canvas_item_set_child_properties (table, triangle,
					"row", 0,
					"column", 2,
					"x-shrink", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (triangle), "id", "Yellow triangle");
  g_signal_connect (triangle, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);
}
Exemplo n.º 5
0
static void
setup_canvas (GtkWidget *canvas)
{
  GooCanvasItem *root;

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  /* Absolute. */
  ellipse1 = goo_canvas_ellipse_new (root, 0, 0, 25, 15,
				     "fill-color", "blue",
				     NULL);
  goo_canvas_item_translate (ellipse1, 100, 100);
  g_signal_connect (ellipse1, "animation_finished",
		    G_CALLBACK (on_animation_finished), NULL);

  rect1 = goo_canvas_rect_new (root, -10, -10, 20, 20,
			       "fill-color", "blue",
			       NULL);
  goo_canvas_item_translate (rect1, 100, 200);

  rect3 = goo_canvas_rect_new (root, -10, -10, 20, 20,
			       "fill-color", "blue",
			       NULL);
  goo_canvas_item_translate (rect3, 200, 200);

  /* Relative. */
  ellipse2 = goo_canvas_ellipse_new (root, 0, 0, 25, 15,
				     "fill-color", "red",
				     NULL);
  goo_canvas_item_translate (ellipse2, 100, 400);

  rect2 = goo_canvas_rect_new (root, -10, -10, 20, 20,
			       "fill-color", "red",
			       NULL);
  goo_canvas_item_translate (rect2, 100, 500);

  rect4 = goo_canvas_rect_new (root, -10, -10, 20, 20,
			       "fill-color", "red",
			       NULL);
  goo_canvas_item_translate (rect4, 200, 500);
}
Exemplo n.º 6
0
static VALUE
rg_initialize(VALUE self, VALUE parent,
                          VALUE center_x, VALUE center_y,
                          VALUE radius_x, VALUE radius_y)
{
    GooCanvasItem *item;
    item = goo_canvas_ellipse_new(RVAL2GCI(parent),
                                  NUM2DBL(center_x),
                                  NUM2DBL(center_y),
                                  NUM2DBL(radius_x),
                                  NUM2DBL(radius_y),
                                  NULL);
    RB_GOO_CANVAS_ITEM_INITIALIZE(self, item);
    G_CHILD_ADD(parent, self);
    return Qnil;
}
Exemplo n.º 7
0
static void mark_pieces()
{
  guint i, j;
  guint x;
  Piece	*piece = NULL;
  guint nbgood = 0;
  guint nbmisplaced = 0;
  guint solution_tmp[MAX_PIECES];

  for(i=0; i<number_of_piece; i++)
    {
      solution_tmp[i] = solution[i];
    }

  gamewon = TRUE;

  /* Mark good placed */
  for(i=0; i<g_list_length(listPieces);  i++)
    {
      piece = g_list_nth_data(listPieces, i);
      GooCanvasItem *item = g_list_nth_data(piece->listitem,
					    piece->selecteditem);
      if(piece->selecteditem == solution_tmp[i])
	{
	  if(gcomprisBoard->level<LEVEL_MAX_FOR_HELP)
	    g_object_set (piece->good, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
	  nbgood++;
	  solution_tmp[i] = G_MAXINT;

	  g_object_set(item,
		       "tooltip", _("This item is well placed"), NULL);

	}
      else
	{
	  gamewon = FALSE;
	}

    }

  /* Mark misplaced */
  for(i=0; i<g_list_length(listPieces);  i++)
    {
      gboolean done;

      piece = g_list_nth_data(listPieces, i);
      GooCanvasItem *item = g_list_nth_data(piece->listitem,
					    piece->selecteditem);

      /* Search if this color is elsewhere */
      j = 0;
      done = FALSE;
      do {
	if(piece->selecteditem != solution[i] &&
	   piece->selecteditem == solution_tmp[j])
	  {
	    nbmisplaced++;
	    solution_tmp[j] = G_MAXINT;
	    if(gcomprisBoard->level<LEVEL_MAX_FOR_HELP)
	      g_object_set (piece->misplaced, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
	    g_object_set (item, "tooltip", _("This item is misplaced"), NULL);
	    done = TRUE;
	  }
      } while (!done && ++j!=number_of_piece);
    }

  /* Display the matermind information to the user */
  x = PLAYING_HELP_X;
  for(i=0; i<nbgood;  i++)
    {
      goo_canvas_ellipse_new (boardRootItem,
			      x + i*(PIECE_WIDTH + PIECE_GAP/2),
			      current_y_position,
			      PIECE_WIDTH/2,
			      PIECE_HEIGHT/2,
			      "fill-color", "black",
			      "stroke-color", "white",
			      "line-width", (double)1,
			      "tooltip", _("One item is well placed"),
			      NULL);
    }

  for(i=0; i<nbmisplaced;  i++)
    {
      goo_canvas_ellipse_new (boardRootItem,
			      x + i*(PIECE_WIDTH + PIECE_GAP/2),
			      current_y_position + PIECE_HEIGHT/2 + PIECE_GAP/3,
			      PIECE_WIDTH/2,
			      PIECE_HEIGHT/2,
			      "fill-color", "white",
			      "stroke-color", "black",
			      "line-width", (double)1,
			      "tooltip", _("One item is misplaced"),
			      NULL);
    }

  current_y_position -= Y_STEP;

  superbrain_create_item(boardRootItem);

}
Exemplo n.º 8
0
/* ==================================== */
static GooCanvasItem *superbrain_create_item(GooCanvasItem *parent)
{
  int i, j;
  double x;
  double x1, x2;
  GooCanvasItem *item = NULL;
  Piece *piece = NULL;

  listPiecesClear();

  if(current_y_position < SCROLL_LIMIT)
    {
      goo_canvas_item_translate(boardRootItem, 0.0, Y_STEP);
    }

  x = (BOARDWIDTH - number_of_piece*(PIECE_WIDTH*2+PIECE_GAP))/2 + PLAYING_AREA_X;

  /* Draw a line to separate cleanly */
  x1 = x + PIECE_WIDTH;
  x2 = (BOARDWIDTH + (number_of_piece-1)*(PIECE_WIDTH*2+PIECE_GAP))/2 - PIECE_WIDTH + PLAYING_AREA_X;

  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   x2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   "stroke-color", "white",
			   "line-width", 1.0,
			   NULL);


  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   x2 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   "stroke-color", "black",
			   "line-width", 1.0,
			   NULL);

  /* Continuing the line */
  x1 = PLAYING_HELP_X;
  x2 = x1 + number_of_piece*PIECE_WIDTH;


  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   x2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   "stroke-color", "white",
			   "line-width", 1.0,
			   NULL);


  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   x2 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   "stroke-color", "black",
			   "line-width", 1.0,
			   NULL);

  /* Draw the pieces */

  for(i=0; i<number_of_piece; i++)
    {

      piece = g_new(Piece, 1);
      piece->listitem = NULL;
      listPieces = g_list_append(listPieces, piece);

      piece->rootitem = goo_canvas_group_new (parent,
					      NULL);


      // Good
      piece->good = goo_canvas_rect_new (piece->rootitem,
					 x + i*(PIECE_WIDTH*2 + PIECE_GAP) - PIECE_WIDTH - PIECE_GAP_GOOD,
					 current_y_position - PIECE_HEIGHT - PIECE_GAP_GOOD,
					 PIECE_WIDTH*2 + PIECE_GAP_GOOD*2,
					 PIECE_HEIGHT*2 + PIECE_GAP_GOOD*2,
					 "fill_color_rgba", COLOR_GOOD,
					 "stroke-color", "white",
					 "line-width", 1.0,
					 "tooltip", _("This item is well placed"),
					 NULL);
      g_object_set (piece->good, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);

      // Misplaced
      piece->misplaced = goo_canvas_rect_new (piece->rootitem,
					      x + i*(PIECE_WIDTH*2 + PIECE_GAP) - PIECE_WIDTH - PIECE_GAP_GOOD,
					      current_y_position - PIECE_HEIGHT - PIECE_GAP_GOOD,
					      PIECE_WIDTH*2 + PIECE_GAP_GOOD*2,
					      PIECE_HEIGHT*2 + PIECE_GAP_GOOD*2,
					      "fill_color_rgba", COLOR_MISPLACED,
					      "stroke-color", "black",
					      "line-width", 1.0,
					      "tooltip", _("This item is misplaced"),
					      NULL);
      g_object_set (piece->misplaced, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);

      for(j=0; j<number_of_color; j++)
	{
	  item = goo_canvas_ellipse_new (piece->rootitem,
					 x + i*(PIECE_WIDTH*2 + PIECE_GAP),
					 current_y_position,
					 PIECE_WIDTH,
					 PIECE_HEIGHT,
					 "fill_color_rgba", colors[j],
					 "stroke-color", "white",
					 "line-width", (double)1,
					 NULL);
	  gc_item_focus_init(item, NULL);

	  g_object_set (item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
	  piece->listitem = g_list_append(piece->listitem, item);

	  g_signal_connect(item, "button-press-event",
			   (GCallback) item_event, piece);
	}

      piece->selecteditem = 0;
      item = g_list_nth_data(piece->listitem,
			     piece->selecteditem);
      g_object_set (item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);

    }

  return NULL;
}
Exemplo n.º 9
0
/* set initial values for the next level */
static void superbrain_next_level()
{
  guint i;
  gboolean selected_color[MAX_COLORS];

  gc_bar_set_level(gcomprisBoard);

  superbrain_destroy_all_items();
  gamewon = FALSE;

  /* Select level difficulty : should not go above MAX_PIECES */
  /* number_of_color must be upper than number_of_piece to allow unicity */

  if(gcomprisBoard->level < LEVEL_MAX_FOR_HELP)
    {
      number_of_piece = gcomprisBoard->level + 2;
      number_of_color = gcomprisBoard->level + 4;
    }
  else
    {
      number_of_piece = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 3;
      number_of_color = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 5;
    }


  current_y_position = BOARDHEIGHT - 50;

  /* Init a random solution : colors choosen are uniquely choosen */
  for(i=0; i<number_of_color; i++)
    {
      selected_color[i] = FALSE;
    }

  for(i=0; i<number_of_piece; i++)
    {
      guint j;

      j = (guint)g_random_int_range(0, number_of_color);
      while(selected_color[j])
	j = (guint)g_random_int_range(0, number_of_color);

      solution[i] = j;
      selected_color[j] = TRUE;
    }

  boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
					NULL);


  boardLogoItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
					NULL);

  /* The OK Button */
  GooCanvasItem *item = goo_canvas_svg_new (boardLogoItem,
					    gc_skin_rsvg_get(),
					    "svg-id", "#OK",
					    NULL);
  SET_ITEM_LOCATION(item, 270, 50);
  g_signal_connect(item, "button_press_event",
		   (GCallback) process_ok, NULL);
  gc_item_focus_init(item, NULL);

  /* The list of the pieces */
  for(i=0; i<number_of_color; i++)
    {
      goo_canvas_ellipse_new (boardLogoItem,
			      PIECE_DISPLAY_X,
			      PIECE_DISPLAY_Y + i*((PIECE_WIDTH*1.5)*2 + PIECE_GAP/2),
			      PIECE_WIDTH * 1.5,
			      PIECE_WIDTH * 1.5,
			      "fill_color_rgba", colors[i],
			      "stroke-color", "white",
			      "line-width", (double)1,
			      NULL);
    }


  superbrain_create_item(boardRootItem);
}
Exemplo n.º 10
0
GtkWidget *
create_canvas_features (void)
{
	GtkWidget *vbox;
	GtkWidget *w;
	GtkWidget *alignment;
	GtkWidget *frame;
	GtkWidget *canvas;
	GooCanvasItem *root, *item;
	GooCanvasItem *parent1;
	GooCanvasItem *parent2;
	GooCanvasItem *group;

	vbox = gtk_vbox_new (FALSE, 4);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
	gtk_widget_show (vbox);

	/* Instructions */

	w = gtk_label_new ("Reparent test:  click on the items to switch them between parents");
	gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
	gtk_widget_show (w);

	/* Frame and canvas */

	alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
	gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
	gtk_widget_show (alignment);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (alignment), frame);
	gtk_widget_show (frame);

	canvas = goo_canvas_new ();
	root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

	gtk_widget_set_size_request (canvas, 400, 200);
	goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 400, 200);
	gtk_container_add (GTK_CONTAINER (frame), canvas);
	gtk_widget_show (canvas);

	/* First parent and box */

	parent1 = goo_canvas_group_new (root, NULL);

	goo_canvas_rect_new (parent1, 0, 0, 200, 200,
			     "fill_color", "tan",
			     NULL);

	/* Second parent and box */

	parent2 = goo_canvas_group_new (root, NULL);
	goo_canvas_item_translate (parent2, 200, 0);

	goo_canvas_rect_new (parent2, 0, 0, 200, 200,
			     "fill_color", "#204060",
			     NULL);

	/* Big circle to be reparented */

	item = goo_canvas_ellipse_new (parent1, 100, 100, 90, 90,
				       "stroke_color", "black",
				       "fill_color", "mediumseagreen",
				       "line-width", 3.0,
				       NULL);
	g_object_set_data (G_OBJECT (item), "parent1", parent1);
	g_object_set_data (G_OBJECT (item), "parent2", parent2);
	g_signal_connect (item, "button_press_event",
			  G_CALLBACK (on_button_press), NULL);

	/* A group to be reparented */

	group = goo_canvas_group_new (parent2, NULL);
	goo_canvas_item_translate (group, 100, 100);

	goo_canvas_ellipse_new (group, 0, 0, 50, 50,
				"stroke_color", "black",
				"fill_color", "wheat",
				"line_width", 3.0,
				NULL);
	goo_canvas_ellipse_new (group, 0, 0, 25, 25,
				"fill_color", "steelblue",
				NULL);

	g_object_set_data (G_OBJECT (group), "parent1", parent1);
	g_object_set_data (G_OBJECT (group), "parent2", parent2);
	g_signal_connect (group, "button_press_event",
			  G_CALLBACK (on_button_press), NULL);

	return vbox;
}
Exemplo n.º 11
0
static void
create_canvas_items (GooCanvasGroup *group, LibraryPart *library_part)
{
	GooCanvasItem   *item;
	GooCanvasPoints *points;
	GSList		*objects;
	LibrarySymbol	*symbol;
	SymbolObject	*object;
	gdouble          height, width;
	GooCanvasBounds  bounds, group_bounds = {0,0,0,0};


	g_return_if_fail (group != NULL);
	g_return_if_fail (library_part != NULL);

	symbol = library_get_symbol (library_part->symbol_name);
	if (symbol ==  NULL) {
		g_warning ("Couldn't find the requested symbol %s for part %s in "
		           "library.\n",
			       library_part->symbol_name,
			       library_part->name);
		return;
	}

	for (objects = symbol->symbol_objects; objects; objects = objects->next) {
		object = (SymbolObject *)(objects->data);
		switch (object->type) {
			case SYMBOL_OBJECT_LINE:
				points = object->u.uline.line;
				item = goo_canvas_polyline_new (GOO_CANVAS_ITEM (group), 
			        FALSE,
			        0,
			       	"points", points,
			        "stroke-color", NORMAL_COLOR,
					"line-width", 0.5,
					NULL);
				if (object->u.uline.spline) {
					g_object_set (item, 
				              "smooth", TRUE, 
				              "spline_steps", 5, 
				              NULL);
				}
				break;
			case SYMBOL_OBJECT_ARC:
				item = goo_canvas_ellipse_new (GOO_CANVAS_ITEM (group), 
					(object->u.arc.x2 + object->u.arc.x1) / 2.0,
			        (object->u.arc.y1 + object->u.arc.y2) / 2.0,
			        (object->u.arc.x2 - object->u.arc.x1) / 2.0,
			        (object->u.arc.y1 - object->u.arc.y2) / 2.0,
			        "stroke-color", NORMAL_COLOR,
			        "line_width", 1.0,
			        NULL);
				break;
			case SYMBOL_OBJECT_TEXT:
				item = goo_canvas_text_new (GOO_CANVAS_ITEM (group), 
			        object->u.text.str, 
			     	(double) object->u.text.x, 
			        (double) object->u.text.y, 
			        -1,
			        GOO_CANVAS_ANCHOR_NORTH_EAST, 
			        "fill_color", LABEL_COLOR,
			        "font", "Sans 8", 
			        NULL);
			break;
			default:
				g_warning ("Unknown symbol object.\n");
				continue;
		}
		goo_canvas_item_get_bounds (item, &bounds);
		if (group_bounds.x1 > bounds.x1) group_bounds.x1 = bounds.x1;
		if (group_bounds.x2 < bounds.x2) group_bounds.x2 = bounds.x2;
		if (group_bounds.y1 > bounds.y1) group_bounds.y1 = bounds.y1;
		if (group_bounds.y2 < bounds.y2) group_bounds.y2 = bounds.y2;
		
	}
	
	g_object_get (group,
	              "width", &width,
	              "height", &height,
	              NULL);
	width = group_bounds.x2 - group_bounds.x1;
	height = group_bounds.y2 - group_bounds.y1;
	
	g_object_set (group,
	              "width", width,
	              "height", height,
	              NULL);
	
	g_slist_free_full (objects, g_object_unref);
}
Exemplo n.º 12
0
/* ==================================== */
static GooCanvasItem *target_create_item(GooCanvasItem *parent)
{
  int i;
  gchar *tmpstr;
  GooCanvasItem *item = NULL;

  boardRootItem = goo_canvas_group_new (parent, NULL);
  valueRootItem = goo_canvas_group_new (boardRootItem, NULL);
  goo_canvas_item_translate(boardRootItem,
			    TARGET_CENTER_X,
			    TARGET_CENTER_Y);

  for(i=0; i<MAX_NUMBER_OF_TARGET; i++)
    {
      if(targetDefinition[gcomprisBoard->level-1].target_width_value[i*2]>0)
	{
	  item = \
	    goo_canvas_ellipse_new (boardRootItem,
				    0.0,
				    0.0,
				    (double)targetDefinition[gcomprisBoard->level-1].target_width_value[i*2],
				    (double)targetDefinition[gcomprisBoard->level-1].target_width_value[i*2],
				    "fill_color_rgba", target_colors[i],
				    "stroke-color", "black",
				    "line-width", 1.0,
				    NULL);

	  goo_canvas_item_lower(item, NULL);
	  g_signal_connect(item, "button-press-event", (GtkSignalFunc) item_event, NULL);

	  /* Display the value for this target */
	  tmpstr = g_strdup_printf("%d",
				   targetDefinition[gcomprisBoard->level-1].target_width_value[i*2+1]);
	  item = goo_canvas_text_new (valueRootItem,
				      tmpstr,
				      (double) 0,
				      (double) targetDefinition[gcomprisBoard->level-1].target_width_value[i*2] - 10,
				      -1,
				      GTK_ANCHOR_CENTER,
				      "font", gc_skin_font_board_medium,
				      "fill-color", "white",
				      NULL);
	  g_free(tmpstr);

	  g_signal_connect(item, "button-press-event", (GtkSignalFunc) item_event, NULL);
	}
    }

  number_of_arrow = targetDefinition[gcomprisBoard->level-1].number_of_arrow;

  tmpstr = g_strdup_printf(_("Distance to target = %d meters"),
			   targetDefinition[gcomprisBoard->level-1].target_distance);
  goo_canvas_text_new (boardRootItem,
		       tmpstr,
		       (double) 0,
		       (double) BOARDHEIGHT-TARGET_CENTER_Y -45,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_board_medium,
		       "fill-color", "black",
		       NULL);
  g_free(tmpstr);

  display_windspeed();

  /* Tooltip */
  tooltipItem =
    goo_canvas_text_new (boardRootItem,
			 "",
			 150,
			 -140,
			 -1,
			 GTK_ANCHOR_CENTER,
			 "font", gc_skin_font_board_title_bold,
			 "fill-color", "white",
			 NULL);

  return NULL;
}
Exemplo n.º 13
0
/*
 * Display a random wind speed
 */
static void display_windspeed()
{
  guint second = 0;
  guint needle_zoom = 15;
  gchar *tmpstr;
  GooCanvasPoints *canvasPoints;
  canvasPoints = goo_canvas_points_new (2);

  if(speedRootItem!=NULL)
    goo_canvas_item_remove(speedRootItem);

  speedRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
					NULL);


  /* Speed orientation */
  second = g_random_int()%60;
  ang = second * M_PI / 30;

  /* Speed force */
  wind_speed = targetDefinition[gcomprisBoard->level-1].target_min_wind_speed \
    + g_random_int()%(targetDefinition[gcomprisBoard->level-1].target_max_wind_speed \
	      - targetDefinition[gcomprisBoard->level-1].target_min_wind_speed);

  canvasPoints->coords[0]=SPEED_CENTER_X;
  canvasPoints->coords[1]=SPEED_CENTER_Y;
  canvasPoints->coords[2]=SPEED_CENTER_X + wind_speed * sin(ang) * needle_zoom;
  canvasPoints->coords[3]=SPEED_CENTER_Y - wind_speed * cos(ang) * needle_zoom;
  double w = 4.0;
  goo_canvas_polyline_new (speedRootItem, FALSE, 0,
			   "points", canvasPoints,
			   "stroke-color-rgba", 0Xa05a2cffL,
			   "fill-color-rgba", 0Xa05a2cffL,
			   "line-width", w,
			   "end-arrow", TRUE,
			   "arrow-tip-length", 7.0,
			   "arrow-length", 5.0,
			   "arrow-width", 4.0,
			   NULL);

  goo_canvas_points_unref(canvasPoints);

  /* Draw the center of the speedometer */
  goo_canvas_ellipse_new (speedRootItem,
			 SPEED_CENTER_X,
			 SPEED_CENTER_Y,
			 10.0,
			 10.0,
			 "fill_color_rgba", 0Xa05a2cffL,
			 "stroke-color", "black",
			 "line-width", (double)2,
			 NULL);

  tmpstr = g_strdup_printf(_("Wind speed = %d\nkilometers/hour"), (guint)wind_speed);
  goo_canvas_text_new (speedRootItem,
		       tmpstr,
		       (double) SPEED_CENTER_X,
		       (double) SPEED_CENTER_Y + 110,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_board_medium,
		       "fill-color", "white",
		       NULL);
  g_free(tmpstr);

}