当前位置: 首页>>代码示例>>C++>>正文


C++ GOO_CANVAS函数代码示例

本文整理汇总了C++中GOO_CANVAS函数的典型用法代码示例。如果您正苦于以下问题:C++ GOO_CANVAS函数的具体用法?C++ GOO_CANVAS怎么用?C++ GOO_CANVAS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GOO_CANVAS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create_clipping_page

GtkWidget *
create_clipping_page (void)
{
  GtkWidget *vbox, *scrolled_win, *canvas;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
  g_object_set (vbox, "margin", 4, NULL);
  gtk_widget_show (vbox);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_win);
  gtk_widget_set_halign (scrolled_win, GTK_ALIGN_FILL);
  gtk_widget_set_valign (scrolled_win, GTK_ALIGN_FILL);
  gtk_widget_set_hexpand (scrolled_win, TRUE);
  gtk_widget_set_vexpand (scrolled_win, TRUE);

  canvas = goo_canvas_new ();
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  setup_canvas (GOO_CANVAS (canvas));

  return vbox;
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:29,代码来源:mv-demo-clipping.c

示例2: sheet_change_zoom

void
sheet_change_zoom (const Sheet *sheet, gdouble rate)
{
	gdouble scale;
	
	sheet->priv->zoom *= rate;
	scale = goo_canvas_get_scale (GOO_CANVAS (sheet));
	scale = scale * rate;
	goo_canvas_set_scale (GOO_CANVAS (sheet), scale);
}
开发者ID:dionysos-sf,项目名称:oregano,代码行数:10,代码来源:sheet.c

示例3: main

int
main ()
{
  GtkWidget *window, *scrolled_win, *canvas;
  GooCanvasItem *root, *rect_item, *text_item;

  /* Initialize GTK+. */
  gtk_init ();

  /* Create the window and widgets. */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
  gtk_widget_show (window);
  g_signal_connect (window, "delete_event", G_CALLBACK (on_delete_event),
		    NULL);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_container_add (GTK_CONTAINER (window), scrolled_win);

  canvas = goo_canvas_new ();
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  /* Add a few simple items. */
  rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
				   "line-width", 10.0,
				   "radius-x", 20.0,
				   "radius-y", 10.0,
				   "stroke-color", "yellow",
				   "fill-color", "red",
				   NULL);

  text_item = goo_canvas_text_new (root, "Hello World", 300, 300, -1,
				   GOO_CANVAS_ANCHOR_CENTER,
				   "font", "Sans 24",
				   NULL);
  goo_canvas_item_rotate (text_item, 45, 300, 300);

  /* Connect a signal handler for the rectangle item. */
  g_signal_connect (rect_item, "button_press_event",
		    G_CALLBACK (on_rect_button_press), NULL);

  /* Pass control to the GTK+ main event loop. */
  gtk_main ();

  return 0;
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:54,代码来源:simple-demo.c

示例4: setup_canvas

void
setup_canvas (GtkWidget *canvas)
{
  GooCanvasItemModel *root;

  root = goo_canvas_group_model_new (NULL, NULL);
  goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);

  g_print ("\nTable at default size...\n");
  create_table1 (canvas, root, 50, 50, -1, -1, FALSE);

  g_print ("\nTable at reduced size...\n");
  create_table1 (canvas, root, 250, 50, 30, 30, FALSE);

  g_print ("\nTable at enlarged size...\n");
  create_table1 (canvas, root, 450, 50, 100, 100, FALSE);

  g_print ("\nTable with grid lines at default size...\n");
  create_table1 (canvas, root, 50, 250, -1, -1, TRUE);

  g_print ("\nTable with grid lines at reduced size...\n");
  create_table1 (canvas, root, 250, 250, 30, 30, TRUE);

  g_print ("\nTable with grid lines at enlarged size...\n");
  create_table1 (canvas, root, 450, 250, 150, 150, TRUE);

  g_print ("Multispanning table with grid lines at default size...\n");
  create_table2 (canvas, root, 50, 450, -1, -1, TRUE);

  g_print ("Multispanning table with grid lines at reduced size...\n");
  create_table2 (canvas, root, 250, 450, 30, 30, TRUE);

  g_print ("Multispanning table with grid lines at enlarged size...\n");
  create_table2 (canvas, root, 450, 450, 150, 150, TRUE);
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:35,代码来源:mv-table-demo.c

示例5: create_focus_page

GtkWidget *
create_focus_page (void)
{
  GtkWidget *vbox, *label, *scrolled_win, *canvas;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
  gtk_widget_show (vbox);

  label = gtk_label_new ("Use Tab, Shift+Tab or the arrow keys to move the keyboard focus between the canvas items.");
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);

  canvas = goo_canvas_new ();
  gtk_widget_set_can_focus (canvas, TRUE);
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  g_signal_connect (canvas, "item_created",
		    G_CALLBACK (on_item_created), NULL);

  setup_canvas (canvas);

  return vbox;
}
开发者ID:anderflash,项目名称:goocanvas,代码行数:33,代码来源:mv-demo-focus.c

示例6: setup_canvas

static void
setup_canvas (GtkWidget *canvas)
{
  GooCanvasItemModel *root;

  root = goo_canvas_group_model_new (NULL, NULL);
  goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
  g_object_unref (root);

  create_focus_box (canvas, 110, 80, 50, 30, "red");
  create_focus_box (canvas, 300, 160, 50, 30, "orange");
  create_focus_box (canvas, 500, 50, 50, 30, "yellow");
  create_focus_box (canvas, 70, 400, 50, 30, "blue");
  create_focus_box (canvas, 130, 200, 50, 30, "magenta");
  create_focus_box (canvas, 200, 160, 50, 30, "green");
  create_focus_box (canvas, 450, 450, 50, 30, "cyan");
  create_focus_box (canvas, 300, 350, 50, 30, "grey");
  create_focus_box (canvas, 900, 900, 50, 30, "gold");
  create_focus_box (canvas, 800, 150, 50, 30, "thistle");
  create_focus_box (canvas, 600, 800, 50, 30, "azure");
  create_focus_box (canvas, 700, 250, 50, 30, "moccasin");
  create_focus_box (canvas, 500, 100, 50, 30, "cornsilk");
  create_focus_box (canvas, 200, 750, 50, 30, "plum");
  create_focus_box (canvas, 400, 800, 50, 30, "orchid");
}
开发者ID:anderflash,项目名称:goocanvas,代码行数:25,代码来源:mv-demo-focus.c

示例7: boundedScroll

static scrollvalue boundedScroll(canvas_goocanvas *gcanvas, scrollvalue d)
{
  /* get size of visible area in canvas units (meters) */
  canvas_dimensions dim = gcanvas->get_viewport_dimensions() / 2;

  // Data rect minimum and maximum
  // limit stops - prevent scrolling beyond these
  gdouble min_sy_cu = 0.95 * (gcanvas->bounds.min.y - dim.height);
  gdouble min_sx_cu = 0.95 * (gcanvas->bounds.min.x - dim.width);
  gdouble max_sy_cu = 0.95 * (gcanvas->bounds.max.y + dim.height);
  gdouble max_sx_cu = 0.95 * (gcanvas->bounds.max.x + dim.width);

  scrollvalue ret(std::min(std::max(d.x, min_sx_cu), max_sx_cu),
                  std::min(std::max(d.y, min_sy_cu), max_sy_cu));

  /* adjust to screen center */
  GooCanvas *gc = GOO_CANVAS(gcanvas->widget);
  gdouble zoom = goo_canvas_get_scale(gc);
  gdouble offx = gcanvas->widget->allocation.width / (2 * zoom);
  gdouble offy = gcanvas->widget->allocation.height / (2 * zoom);

  goo_canvas_scroll_to(gc, ret.x - offx, ret.y - offy);

  return ret;
}
开发者ID:AMDmi3,项目名称:osm2go,代码行数:25,代码来源:canvas_goocanvas.cpp

示例8: printf

double canvas_t::set_zoom(double zoom) {
  /* Limit a proposed zoom factor to sane ranges.
   * Specifically the map is allowed to be no smaller than the viewport. */

  canvas_goocanvas *gcanvas = static_cast<canvas_goocanvas *>(this);
  /* get size of visible area in pixels and convert to meters of intended */
  /* zoom by dividing by zoom (which is basically pix/m) */
  const GtkAllocation &dim = widget->allocation;

  double limit;
  int delta;

  if (dim.height < dim.width) {
    limit = dim.height;
    delta = gcanvas->bounds.max.y - gcanvas->bounds.min.y;
  } else {
    limit = dim.width;
    delta = gcanvas->bounds.max.x - gcanvas->bounds.min.x;
  }
  limit *= 0.95 / zoom;

  if (delta < limit) {
    zoom /= (delta / limit);

    printf("Can't zoom further out (%f)\n", zoom);
  }

  goo_canvas_set_scale(GOO_CANVAS(widget), zoom);

  return zoom;
}
开发者ID:AMDmi3,项目名称:osm2go,代码行数:31,代码来源:canvas_goocanvas.cpp

示例9: create_focus_box

static void
create_focus_box (GtkWidget     *canvas,
		  gdouble        x,
		  gdouble        y,
		  gdouble        width,
		  gdouble        height,
		  gchar         *color)
{
  GooCanvasItem *root, *item;

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
  item = goo_canvas_rect_new (root, x, y, width, height,
			      "stroke-pattern", NULL,
			      "fill-color", color,
			      "line-width", 5.0,
			      "can-focus", TRUE,
			      NULL);
  g_object_set_data (G_OBJECT (item), "id", color);

  g_signal_connect (item, "focus_in_event",
		    G_CALLBACK (on_focus_in), NULL);
  g_signal_connect (item, "focus_out_event",
		    G_CALLBACK (on_focus_out), NULL);

  g_signal_connect (item, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);

  g_signal_connect (item, "key_press_event",
		    G_CALLBACK (on_key_press), NULL);
}
开发者ID:GNOME,项目名称:goocanvas,代码行数:30,代码来源:widgets-demo.c

示例10: goo_canvas_accessible_ref_child

static AtkObject*
goo_canvas_accessible_ref_child (AtkObject *object,
				 gint       child_num)
{
  GtkAccessible *accessible;
  GtkWidget *widget;
  GooCanvasItem *root;
  AtkObject *atk_object;

  /* Canvas only has one child, so return NULL if index is non zero */
  if (child_num != 0)
    return NULL;

  accessible = GTK_ACCESSIBLE (object);
  widget = accessible->widget;

  /* Check if widget still exists. */
  if (widget == NULL)
    return NULL;

  root = goo_canvas_get_root_item (GOO_CANVAS (widget));
  if (!root)
    return NULL;

  atk_object = atk_gobject_accessible_for_object (G_OBJECT (root));
  g_object_ref (atk_object);

  return atk_object;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:29,代码来源:goocanvasatk.c

示例11: sheet_get_pointer

/**
 * get the pointer position in goocanvas coordinates
 *
 * @attention shall not be called in event callbacks,
 * except for GDK_MOTION_... where it is useless since
 * the event itself contains the cursor position
 */
gboolean sheet_get_pointer (Sheet *sheet, gdouble *x, gdouble *y)
{
	if (!sheet_get_pointer_pixel (sheet, x, y))
		return FALSE;
	goo_canvas_convert_from_pixels (GOO_CANVAS (sheet), x, y);
	return TRUE;
}
开发者ID:felipebetancur,项目名称:oregano,代码行数:14,代码来源:sheet.c

示例12: node_dot_added_callback

static void
node_dot_added_callback (Schematic *schematic, Coords *pos, Sheet *sheet)
{
	NodeItem *node_item;
	Coords *key;

	g_return_if_fail (sheet != NULL);
	g_return_if_fail (IS_SHEET (sheet));

	node_item = g_hash_table_lookup (sheet->priv->node_dots, pos);
	if (node_item == NULL) {
		node_item = NODE_ITEM (g_object_new (TYPE_NODE_ITEM, NULL));	
		g_object_set (node_item,
		              "parent", goo_canvas_get_root_item (GOO_CANVAS (sheet)),
		              "x", pos->x,
		              "y", pos->y,
		              NULL);
	}

	node_item_show_dot (node_item, TRUE);
	key = g_new0 (Coords, 1);
	key->x = pos->x;
	key->y = pos->y;

	g_hash_table_insert (sheet->priv->node_dots, key, node_item);
}
开发者ID:hriesz,项目名称:oregano-old,代码行数:26,代码来源:sheet.c

示例13: draw_canvas_get_item_at

static DrawCanvasItem *
draw_canvas_get_item_at (DrawCanvas *canvas,
                         gdouble     x,
                         gdouble     y,
                         gboolean    is_pointer_event)
{
   GooCanvasItem *item;

   g_return_val_if_fail(DRAW_IS_CANVAS(canvas), NULL);

   /*
    * Fetch the item underneath the pointer. If the item is not a
    * DrawCanvasItem or the item is part of a selection group, work our way
    * up until we find that top-most grabbable item.
    */

   item = goo_canvas_get_item_at(GOO_CANVAS(canvas), x, y, is_pointer_event);
   for (; item; item = goo_canvas_item_get_parent(item)) {
      /*
       * TODO: Check if part of a selection/group.
       */
      if (DRAW_IS_CANVAS_ITEM(item)) {
         return DRAW_CANVAS_ITEM(item);
      }
   }

   return NULL;
}
开发者ID:chergert,项目名称:simply-draw,代码行数:28,代码来源:draw-canvas.c

示例14: init_display

void
init_display()
{
	int	i;

	pcb.scale = 1.0;
	for (i = 0; i < pcb.layers; i++) {
		pcb.layer[i].canvas = GOO_CANVAS(goo_canvas_new());
		gtk_object_ref(GTK_OBJECT(pcb.layer[i].canvas));
		goo_canvas_set_bounds(pcb.layer[i].canvas,
		    0, 0, pcb.width, pcb.height);
		pcb.layer[i].root =
		    goo_canvas_get_root_item(pcb.layer[i].canvas);
		goo_canvas_image_new(pcb.layer[i].root, pcb.layer[i].img, 0, 0,
		    NULL);
		init_layer_events(pcb.layer[i].root);
		show_overlays(i);
	}

	pcb.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(pcb.window), 800, 600);
	gtk_window_set_title(GTK_WINDOW(pcb.window), pcb.filename);

	init_window_events(pcb.window);

	pcb.scrolled = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(pcb.scrolled);
	gtk_container_add(GTK_CONTAINER(pcb.window), pcb.scrolled);

	redisplay();
}
开发者ID:bert,项目名称:depcb,代码行数:31,代码来源:display.c

示例15: create_canvas

static void
create_canvas (GtkTable *table, gint row, gchar *text, gchar *id)
{
  GtkWidget *label, *canvas;
  GooCanvasItemModel *root, *rect;
  char *view_id;

  label = gtk_label_new (text);
  gtk_table_attach (table, label, 0, 1, row, row + 1,
		    0, 0, 0, 0);
  gtk_widget_show (label);

  canvas = goo_canvas_new ();

  g_signal_connect (canvas, "item_created",
		    G_CALLBACK (on_item_created), NULL);

  gtk_widget_set_size_request (canvas, 200, 100);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 200, 100);
  gtk_table_attach (table, canvas, 1, 2, row, row + 1, 0, 0, 0, 0);
  gtk_widget_show (canvas);

  root = goo_canvas_group_model_new (NULL, NULL);
  goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
  g_object_unref (root);

  rect = goo_canvas_rect_model_new (root, 0, 0, 200, 100,
				    "stroke-pattern", NULL,
				    "fill-color", "yellow",
				    NULL);
  view_id = g_strdup_printf ("%s-yellow", id);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  rect = goo_canvas_rect_model_new (root, 20, 20, 60, 60,
				    "stroke-pattern", NULL,
				    "fill-color", "blue",
				    NULL);
  view_id = g_strdup_printf ("%s-blue", id);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);

  rect = goo_canvas_rect_model_new (root, 120, 20, 60, 60,
				    "stroke-pattern", NULL,
				    "fill-color", "red",
				    NULL);
  view_id = g_strdup_printf ("%s-red", id);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:47,代码来源:mv-demo-grabs.c


注:本文中的GOO_CANVAS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。