Beispiel #1
0
void GfxSquareBrush::drawStyle(GnomeCanvasItem *rb, GdkBitmap *stipple,
			    GdkBitmap *stubble, const guint32 &black,
			    const guint32 &white, const Coord &current) {
  GnomeCanvasPoints *pts = gnome_canvas_points_new(4);
  pts->coords[0] = current(0) - size;
  pts->coords[1] = current(1) + size;
  pts->coords[2] = current(0) - size;
  pts->coords[3] = current(1) - size;
  pts->coords[4] = current(0) + size;
  pts->coords[5] = current(1) - size;
  pts->coords[6] = current(0) + size;
  pts->coords[7] = current(1) + size;
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
					  gnome_canvas_polygon_get_type(),
					  "points", pts,
					  "outline_color_rgba", black,
					  "width_pixels", 0,
					  "outline_stipple", stipple,
					  NULL);
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
					  gnome_canvas_polygon_get_type(),
					  "points", pts,
					  "outline_color_rgba", white,
					  "width_pixels", 0,
					  "outline_stipple", stubble,
					  NULL);
}
Beispiel #2
0
static void
create_rect_and_text (ETableClickToAdd *etcta)
{
	GtkWidget *widget;
	GdkColor fg, bg;

	widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etcta)->canvas);

	e_utils_get_theme_color_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg);
	e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &bg);

	if (!etcta->rect)
		etcta->rect = gnome_canvas_item_new (
			GNOME_CANVAS_GROUP (etcta),
			gnome_canvas_rect_get_type (),
			"x1", (gdouble) 0,
			"y1", (gdouble) 1,
			"x2", (gdouble) etcta->width,
			"y2", (gdouble) etcta->height,
			"fill_color_gdk", &bg,
			NULL);

	if (!etcta->text)
		etcta->text = gnome_canvas_item_new (
			GNOME_CANVAS_GROUP (etcta),
			e_text_get_type (),
			"text", etcta->message ? etcta->message : "",
			"width", etcta->width - 4,
			"fill_color_gdk", &fg,
			NULL);
}
Beispiel #3
0
static gboolean
bst_canvas_link_build_async (gpointer data)
{
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (data);
  if (gnome_canvas_item_check_undisposed (item))
    {
      BstCanvasLink *clink = BST_CANVAS_LINK (item);
      if (!clink->arrow)
        clink->arrow = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                                GNOME_TYPE_CANVAS_POLYGON,
                                                                "outline_color_rgba", 0x000000ff,
                                                                "fill_color_rgba", 0xff0000ff,
                                                                NULL),
                                         "signal::destroy", gtk_widget_destroyed, &clink->arrow,
                                         "swapped_signal::event", bst_canvas_link_child_event, clink,
                                         NULL);
      if (!clink->tag_start)
        clink->tag_start = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                                    GNOME_TYPE_CANVAS_ELLIPSE,
                                                                    "outline_color_rgba", 0x000000ff, // xffff00ff,
                                                                    "fill_color_rgba", 0xffff00ff,
                                                                    NULL),
                                             "signal::destroy", gtk_widget_destroyed, &clink->tag_start,
                                             "swapped_signal::event", bst_canvas_link_child_event, clink,
                                             NULL);
      if (!clink->tag_end)
        {
          gboolean is_jchannel = FALSE;
          if (clink->icsource)
            is_jchannel = bst_canvas_source_is_jchannel (clink->icsource, clink->ichannel);
          clink->tag_end = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                                    GNOME_TYPE_CANVAS_ELLIPSE,
                                                                    "outline_color_rgba", 0x000000ff, // 0xff0000ff,
                                                                    "fill_color_rgba", is_jchannel ? 0x00ff00ff : 0xff0000ff,
                                                                    NULL),
                                             "signal::destroy", gtk_widget_destroyed, &clink->tag_end,
                                             "swapped_signal::event", bst_canvas_link_child_event, clink,
                                             NULL);
        }
      if (!clink->line)
        clink->line = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                               GNOME_TYPE_CANVAS_LINE,
                                                               "fill_color", "black",
                                                               NULL),
                                        "signal::destroy", gtk_widget_destroyed, &clink->line,
                                        "swapped_signal::notify", bst_canvas_link_adjust_arrow, clink,
                                        "swapped_signal::notify", bst_canvas_link_adjust_tags, clink,
                                        NULL);
      bst_canvas_link_update (clink);
    }
  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
  g_object_unref (item);
  if (canvas)
    g_object_unref (canvas);      /* canvases don't properly protect their items */
  return FALSE;
}
static ETableGroupContainerChildNode *
create_child_node (ETableGroupContainer *etgc, void *val)
{
	ETableGroup *child;
	ETableGroupContainerChildNode *child_node;
	ETableGroup *etg = E_TABLE_GROUP(etgc);

	child_node = g_new (ETableGroupContainerChildNode, 1);
	child_node->rect = gnome_canvas_item_new (GNOME_CANVAS_GROUP (etgc),
						  gnome_canvas_rect_get_type (),
						  "fill_color", "grey70",
						  "outline_color", "grey50",
						  NULL);
	child_node->text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (etgc),
						  e_text_get_type (),
						  "anchor", GTK_ANCHOR_SW,
						  "fill_color", "black",
						  "draw_background", FALSE,
						  NULL);
	child = e_table_group_new (GNOME_CANVAS_GROUP (etgc), etg->full_header,
				   etg->header, etg->model, etgc->sort_info, etgc->n + 1);
	gnome_canvas_item_set(GNOME_CANVAS_ITEM(child),
			      "alternating_row_colors", etgc->alternating_row_colors,
			      "horizontal_draw_grid", etgc->horizontal_draw_grid,
			      "vertical_draw_grid", etgc->vertical_draw_grid,
			      "drawfocus", etgc->draw_focus,
			      "cursor_mode", etgc->cursor_mode,
			      "selection_model", etgc->selection_model,
			      "length_threshold", etgc->length_threshold,
			      "uniform_row_height", etgc->uniform_row_height,
			      "minimum_width", etgc->minimum_width - GROUP_INDENT,
			      NULL);

	g_signal_connect (child, "cursor_change",
			  G_CALLBACK (child_cursor_change), etgc);
	g_signal_connect (child, "cursor_activated",
			  G_CALLBACK (child_cursor_activated), etgc);
	g_signal_connect (child, "double_click",
			  G_CALLBACK (child_double_click), etgc);
	g_signal_connect (child, "right_click",
			  G_CALLBACK (child_right_click), etgc);
	g_signal_connect (child, "click",
			  G_CALLBACK (child_click), etgc);
	g_signal_connect (child, "key_press",
			  G_CALLBACK (child_key_press), etgc);
	g_signal_connect (child, "start_drag",
			  G_CALLBACK (child_start_drag), etgc);
	child_node->child = child;
	child_node->key = e_table_model_duplicate_value (etg->model, etgc->ecol->col_idx, val);
	child_node->string = e_table_model_value_to_string (etg->model, etgc->ecol->col_idx, val);
	child_node->count = 0;

	return child_node;
}
Beispiel #5
0
GtkWidget *
gnc_header_new (GnucashSheet *sheet)
{
    GnomeCanvasGroup *group;
    GnomeCanvasItem *item;
    GtkWidget *canvas;

    canvas = gnome_canvas_new ();

    g_signal_connect (G_OBJECT (canvas), "realize",
                      G_CALLBACK (gnc_header_realized),
                      NULL);

    group = GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root);

    item = gnome_canvas_item_new (group,
                                  gnc_header_get_type (),
                                  "sheet", sheet,
                                  "cursor_name", CURSOR_HEADER,
                                  NULL);

    sheet->header_item = item;

    gtk_widget_show (canvas);

    return canvas;
}
Beispiel #6
0
static void
e_canvas_item_invoke_reflow (GnomeCanvasItem *item, int flags)
{
	GnomeCanvasGroup *group;
	GList *list;
	GnomeCanvasItem *child;

	if (GNOME_IS_CANVAS_GROUP (item)) {
		group = GNOME_CANVAS_GROUP (item);
		for (list = group->item_list; list; list = list->next) {
			child = GNOME_CANVAS_ITEM (list->data);
			if (child->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW)
				e_canvas_item_invoke_reflow (child, flags);
		}
	}

	if (item->object.flags & E_CANVAS_ITEM_NEEDS_REFLOW) {
		ECanvasItemReflowFunc func;
		func = (ECanvasItemReflowFunc)
			g_object_get_data (G_OBJECT (item),
					   "ECanvasItem::reflow_callback");
		if (func)
			func (item, flags);
	}

	item->object.flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW;
	item->object.flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW;
}
Beispiel #7
0
static GtkWidget *
zenity_create_monk (void)
{
  GtkWidget *canvas_board;
  GnomeCanvasItem *canvas_item;
  GdkPixbuf *pixbuf;
  GdkColor color = { 0, 0xffff, 0xffff, 0xffff };

  canvas_board = gnome_canvas_new ();

  gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0,
                                  ZENITY_CANVAS_X, ZENITY_CANVAS_Y);

  gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y);

  gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)),
                            &color, FALSE, TRUE);

  gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color);

  pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL);

  canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
                                       GNOME_TYPE_CANVAS_PIXBUF,
                                       "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0,
                                       "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0,
                                       "pixbuf", pixbuf,
                                       "anchor", GTK_ANCHOR_NW,
                                       NULL);

  zenity_create_clothes (canvas_board);

  return canvas_board;
}
Beispiel #8
0
static void
bst_canvas_source_destroy (GtkObject *object)
{
  BstCanvasSource *csource = BST_CANVAS_SOURCE (object);
  GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (object);

  if (csource->in_move)
    {
      csource->in_move = FALSE;
      bse_item_ungroup_undo (csource->source);
    }

  while (csource->channel_hints)
    gtk_object_destroy (csource->channel_hints->data);
  while (group->item_list)
    gtk_object_destroy (group->item_list->data);

  if (csource->source)
    {
      bse_proxy_disconnect (csource->source,
			    "any_signal", gtk_object_destroy, csource,
			    "any_signal", source_channels_changed, csource,
			    "any_signal", source_name_changed, csource,
			    "any_signal", source_pos_changed, csource,
			    "any_signal", source_icon_changed, csource,
			    NULL);
      bse_item_unuse (csource->source);
      csource->source = 0;
    }

  GTK_OBJECT_CLASS (bst_canvas_source_parent_class)->destroy (object);
}
Beispiel #9
0
static void
cursor_changed (ESelectionModel *selection, int row, int col, EReflow *reflow)
{
	int count = reflow->count;
	int old_cursor = reflow->cursor_row;

	if (old_cursor < count && old_cursor >= 0) {
		if (reflow->items[old_cursor]) {
			g_object_set (reflow->items[old_cursor],
				      "has_cursor", FALSE,
				      NULL);
		}
	}

	reflow->cursor_row = row;

	if (row < count && row >= 0) {
		if (reflow->items[row]) {
			g_object_set (reflow->items[row],
				      "has_cursor", TRUE,
				      NULL);
		} else {
			reflow->items[row] = e_reflow_model_incarnate (reflow->model, row, GNOME_CANVAS_GROUP (reflow));
			g_object_set (reflow->items[row],
				      "has_cursor", TRUE,
				      "width", (double) reflow->column_width,
				      NULL);
		}
	}

	if (reflow->do_adjustment_idle_id == 0)
		reflow->do_adjustment_idle_id = g_idle_add (do_adjustment, reflow);

}
static void
etgl_realize (GnomeCanvasItem *item)
{
	ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (item);

	if (GNOME_CANVAS_ITEM_CLASS (e_table_group_leaf_parent_class)->realize)
		GNOME_CANVAS_ITEM_CLASS (e_table_group_leaf_parent_class)->realize (item);

	etgl->item = E_TABLE_ITEM (gnome_canvas_item_new (
		GNOME_CANVAS_GROUP (etgl),
		e_table_item_get_type (),
		"ETableHeader", E_TABLE_GROUP (etgl)->header,
		"ETableModel", etgl->ets,
		"alternating_row_colors", etgl->alternating_row_colors,
		"horizontal_draw_grid", etgl->horizontal_draw_grid,
		"vertical_draw_grid", etgl->vertical_draw_grid,
		"drawfocus", etgl->draw_focus,
		"cursor_mode", etgl->cursor_mode,
		"minimum_width", etgl->minimum_width,
		"length_threshold", etgl->length_threshold,
		"selection_model", etgl->selection_model,
		"uniform_row_height", etgl->uniform_row_height,
		NULL));

	etgl->etgl_cursor_change_id = g_signal_connect (
		etgl->item, "cursor_change",
		G_CALLBACK (etgl_cursor_change), etgl);

	etgl->etgl_cursor_activated_id = g_signal_connect (
		etgl->item, "cursor_activated",
		G_CALLBACK (etgl_cursor_activated), etgl);

	etgl->etgl_double_click_id = g_signal_connect (
		etgl->item, "double_click",
		G_CALLBACK (etgl_double_click), etgl);

	etgl->etgl_right_click_id = g_signal_connect (
		etgl->item, "right_click",
		G_CALLBACK (etgl_right_click), etgl);

	etgl->etgl_click_id = g_signal_connect (
		etgl->item, "click",
		G_CALLBACK (etgl_click), etgl);

	etgl->etgl_key_press_id = g_signal_connect (
		etgl->item, "key_press",
		G_CALLBACK (etgl_key_press), etgl);

	etgl->etgl_start_drag_id = g_signal_connect (
		etgl->item, "start_drag",
		G_CALLBACK (etgl_start_drag), etgl);

	etgl->notify_is_editing_id = e_signal_connect_notify (
		etgl->item, "notify::is-editing",
		G_CALLBACK (etgl_item_is_editing_changed_cb), etgl);

	e_canvas_item_request_reflow (item);
}
Beispiel #11
0
void GfxCircleBrush::drawStyle(GnomeCanvasItem *rb, GdkBitmap *stipple,
			    GdkBitmap *stubble, const guint32 &black,
			    const guint32 &white, const Coord &current) {
  // Circle
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
 		      gnome_canvas_ellipse_get_type(),
 		      "x1", current(0)-r, "y1", (current(1)-r),
 		      "x2", current(0)+r, "y2", (current(1)+r),
 		      "outline_color_rgba", black,
 		      "outline_stipple", stipple,
 		      "width_pixels", 0,
 		      NULL);
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
 		      gnome_canvas_ellipse_get_type(),
 		      "x1", current(0)-r, "y1", (current(1)-r),
 		      "x2", current(0)+r, "y2", (current(1)+r),
 		      "outline_color_rgba", white,
 		      "outline_stipple", stubble,
 		      "width_pixels", 0,
 		      NULL);
}
Beispiel #12
0
static void
finish_editing (ETableClickToAdd *etcta)
{
	if (etcta->row) {
		ETableModel *one;

		e_table_item_leave_edit (E_TABLE_ITEM (etcta->row));
		e_table_one_commit (E_TABLE_ONE (etcta->one));
		etcta_drop_one (etcta);
		g_object_run_dispose (G_OBJECT (etcta->row));
		etcta->row = NULL;

		if (etcta->text) {
			g_object_run_dispose (G_OBJECT (etcta->text));
			etcta->text = NULL;
		}
		if (etcta->rect) {
			g_object_run_dispose (G_OBJECT (etcta->rect));
			etcta->rect = NULL;
		}

		one = e_table_one_new (etcta->model);
		etcta_add_one (etcta, one);
		g_object_unref (one);

		e_selection_model_clear (E_SELECTION_MODEL (etcta->selection));

		etcta->row = gnome_canvas_item_new (
			GNOME_CANVAS_GROUP (etcta),
			e_table_item_get_type (),
			"ETableHeader", etcta->eth,
			"ETableModel", etcta->one,
			"minimum_width", etcta->width,
			"horizontal_draw_grid", TRUE,
			"vertical_draw_grid", TRUE,
			"selection_model", etcta->selection,
			"cursor_mode", E_CURSOR_SPREADSHEET,
			NULL);

		g_signal_connect (
			etcta->row, "key_press",
			G_CALLBACK (item_key_press), etcta);

		e_signal_connect_notify (
			etcta->row, "notify::is-editing",
			G_CALLBACK (table_click_to_add_row_is_editing_changed_cb), etcta);

		set_initial_selection (etcta);

		g_object_notify (G_OBJECT (etcta), "is-editing");
	}
}
Beispiel #13
0
static void
items_inserted (EReflowModel *model, int position, int count, EReflow *reflow)
{
	int i, oldcount;

	if (position < 0 || position > reflow->count)
		return;

	oldcount = reflow->count;

	reflow->count += count;

	if (reflow->count > reflow->allocated_count) {
		while (reflow->count > reflow->allocated_count)
			reflow->allocated_count += 256;
		reflow->heights = g_renew (int, reflow->heights, reflow->allocated_count);
		reflow->items = g_renew (GnomeCanvasItem *, reflow->items, reflow->allocated_count);
	}
	memmove (reflow->heights + position + count, reflow->heights + position, (reflow->count - position - count) * sizeof (int));
	memmove (reflow->items + position + count, reflow->items + position, (reflow->count - position - count) * sizeof (GnomeCanvasItem *));
	for (i = position; i < position + count; i++) {
		reflow->items[i] = NULL;
		reflow->heights[i] = e_reflow_model_height (reflow->model, i, GNOME_CANVAS_GROUP (reflow));
	}

	e_selection_model_simple_set_row_count (E_SELECTION_MODEL_SIMPLE (reflow->selection), reflow->count);
	if (position == oldcount)
		e_sorter_array_append (reflow->sorter, count);
	else
		e_sorter_array_set_count (reflow->sorter, reflow->count);

	for (i = position; i < position + count; i ++) {
		int sorted = e_sorter_model_to_sorted (E_SORTER (reflow->sorter), i);
		int c;

		for (c = reflow->column_count - 1; c >= 0; c--) {
			int start_of_column = reflow->columns[c];

			if (start_of_column <= sorted) {
				if (reflow->reflow_from_column == -1
				    || reflow->reflow_from_column > c) {
					reflow->reflow_from_column = c;
				}
				break;
			}
		}
	}

	reflow->need_reflow_columns = TRUE;
	set_empty (reflow);
	e_canvas_item_request_reflow(GNOME_CANVAS_ITEM (reflow));
}
Beispiel #14
0
static void
e_minicard_label_realize (GnomeCanvasItem *item)
{
	EMinicardLabel *e_minicard_label;
	GnomeCanvasGroup *group;

	e_minicard_label = E_MINICARD_LABEL (item);
	group = GNOME_CANVAS_GROUP ( item );

	if (GNOME_CANVAS_ITEM_CLASS ( parent_class )->realize)
		(* GNOME_CANVAS_ITEM_CLASS ( parent_class )->realize) (item);

	e_canvas_item_request_reflow (item);

	e_minicard_label->rect =
	  gnome_canvas_item_new ( group,
				 gnome_canvas_rect_get_type (),
				 "x1", (double) 0,
				 "y1", (double) 0,
				 "x2", (double) e_minicard_label->width - 1,
				 "y2", (double) e_minicard_label->height - 1,
				 "outline_color", NULL,
				 NULL );
	e_minicard_label->fieldname =
	  gnome_canvas_item_new ( group,
				 e_text_get_type (),
				 "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
				 "clip", TRUE,
				 "use_ellipsis", TRUE,
				 "fill_color", "black",
				 "draw_background", FALSE,
				 "im_context", E_CANVAS (item->canvas)->im_context,
				 NULL );
	e_canvas_item_move_absolute (e_minicard_label->fieldname, 2, 1);

	e_minicard_label->field =
	  gnome_canvas_item_new ( group,
				 e_text_get_type (),
				 "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
				 "clip", TRUE,
				 "use_ellipsis", TRUE,
				 "fill_color", "black",
				 "editable", FALSE, /* e_minicard_label->editable, */
				 "draw_background", FALSE,
				 "im_context", E_CANVAS (item->canvas)->im_context,
				 NULL );
	e_canvas_item_move_absolute (e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);

	set_colors (e_minicard_label);

	e_canvas_item_request_reflow (item);
}
Beispiel #15
0
void G_cont_create( int cont, GnomeCanvasGroup *root )
{
	if(!initialized)
		G_cont_init();

	G_conts[cont].cont_group = GNOME_CANVAS_GROUP(
			gnome_canvas_item_new (
				root,
				gnome_canvas_group_get_type (),
				"x", (double) G_conts[cont].x,
				"y", (double) G_conts[cont].y,
				NULL));
}
Beispiel #16
0
static void
item_changed (EReflowModel *model, int i, EReflow *reflow)
{
	if (i < 0 || i >= reflow->count)
		return;

	reflow->heights[i] = e_reflow_model_height (reflow->model, i, GNOME_CANVAS_GROUP (reflow));
	if (reflow->items[i] != NULL)
		e_reflow_model_reincarnate (model, i, reflow->items[i]);
	e_sorter_array_clean (reflow->sorter);
	reflow->reflow_from_column = -1;
	reflow->need_reflow_columns = TRUE;
	e_canvas_item_request_reflow(GNOME_CANVAS_ITEM (reflow));
}
Beispiel #17
0
static void
bst_canvas_link_destroy (GtkObject *object)
{
  BstCanvasLink *clink = BST_CANVAS_LINK (object);
  GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (object);
  
  while (group->item_list)
    gtk_object_destroy (group->item_list->data);
  
  bst_canvas_link_set_ocsource (clink, NULL, 0);
  bst_canvas_link_set_icsource (clink, NULL, 0);
  
  GTK_OBJECT_CLASS (bst_canvas_link_parent_class)->destroy (object);
}
Beispiel #18
0
GnomeCanvasItem *
gnucash_cursor_new (GnomeCanvasGroup *parent)
{
    GnomeCanvasItem *item;
    GnomeCanvasItem *cursor_item;
    GnucashCursor *cursor;
    GnucashItemCursor *item_cursor;

    g_return_val_if_fail (parent != NULL, NULL);
    g_return_val_if_fail (GNOME_IS_CANVAS_GROUP(parent), NULL);

    item = gnome_canvas_item_new (parent,
                                  gnucash_cursor_get_type(),
                                  NULL);

    cursor = GNUCASH_CURSOR(item);

    cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
                                         gnucash_item_cursor_get_type(),
                                         NULL);

    item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
    item_cursor->type = GNUCASH_CURSOR_CELL;

    cursor->cursor[GNUCASH_CURSOR_CELL] = cursor_item;

    cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
                                         gnucash_item_cursor_get_type(),
                                         NULL);

    item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
    item_cursor->type = GNUCASH_CURSOR_BLOCK;

    cursor->cursor[GNUCASH_CURSOR_BLOCK] = cursor_item;

    return item;
}
Beispiel #19
0
static inline void
e_reflow_update_selection_row (EReflow *reflow, int row)
{
	if (reflow->items[row]) {
		g_object_set(reflow->items[row],
			     "selected", e_selection_model_is_row_selected(E_SELECTION_MODEL(reflow->selection), row),
			     NULL);
	} else if (e_selection_model_is_row_selected (E_SELECTION_MODEL (reflow->selection), row)) {
		reflow->items[row] = e_reflow_model_incarnate (reflow->model, row, GNOME_CANVAS_GROUP (reflow));
		g_object_set (reflow->items[row],
			      "selected", e_selection_model_is_row_selected(E_SELECTION_MODEL(reflow->selection), row),
			      "width", (double) reflow->column_width,
			      NULL);
	}
}
Beispiel #20
0
static void
ec_style_set_recursive (GnomeCanvasItem *item, GtkStyle *previous_style)
{
	guint signal_id = g_signal_lookup ("style_set", G_OBJECT_TYPE (item));
	if (signal_id >= 1) {
		GSignalQuery query;
		g_signal_query (signal_id, &query);
		if (query.return_type == G_TYPE_NONE && query.n_params == 1 && query.param_types[0] == GTK_TYPE_STYLE) {
			g_signal_emit (item, signal_id, 0, previous_style);
		}
	}

	if (GNOME_IS_CANVAS_GROUP (item) ) {
		GList *items = GNOME_CANVAS_GROUP (item)->item_list;
		for (; items; items = items->next)
			ec_style_set_recursive (items->data, previous_style);
	}
}
Beispiel #21
0
static void
incarnate (EReflow *reflow)
{
	int column_width;
	int first_column;
	int last_column;
	int first_cell;
	int last_cell;
	int i;
	GtkAdjustment *adjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (GNOME_CANVAS_ITEM (reflow)->canvas));

	column_width = reflow->column_width;

	first_column = adjustment->value - 1 + E_REFLOW_BORDER_WIDTH;
	first_column /= column_width + E_REFLOW_FULL_GUTTER;

	last_column = adjustment->value + adjustment->page_size + 1 - E_REFLOW_BORDER_WIDTH - E_REFLOW_DIVIDER_WIDTH;
	last_column /= column_width + E_REFLOW_FULL_GUTTER;
	last_column ++;

	if (first_column >= 0 && first_column < reflow->column_count)
		first_cell = reflow->columns[first_column];
	else
		first_cell = 0;

	if (last_column >= 0 && last_column < reflow->column_count)
		last_cell = reflow->columns[last_column];
	else
		last_cell = reflow->count;

	for (i = first_cell; i < last_cell; i++) {
		int unsorted = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), i);
		if (reflow->items[unsorted] == NULL) {
			if (reflow->model) {
				reflow->items[unsorted] = e_reflow_model_incarnate (reflow->model, unsorted, GNOME_CANVAS_GROUP (reflow));
				g_object_set (reflow->items[unsorted],
					      "selected", e_selection_model_is_row_selected(E_SELECTION_MODEL(reflow->selection), unsorted),
					      "width", (double) reflow->column_width,
					      NULL);
			}
		}
	}
	reflow->incarnate_idle_id = 0;
}
Beispiel #22
0
static void
set_empty(EReflow *reflow)
{
	if (reflow->count == 0) {
		if (reflow->empty_text) {
			if (reflow->empty_message) {
				gnome_canvas_item_set(reflow->empty_text,
						      "width", reflow->minimum_width,
						      "text", reflow->empty_message,
						      NULL);
				e_canvas_item_move_absolute(reflow->empty_text,
							    reflow->minimum_width / 2,
							    0);
			} else {
				gtk_object_destroy(GTK_OBJECT(reflow->empty_text));
				reflow->empty_text = NULL;
			}
		} else {
			if (reflow->empty_message) {
				reflow->empty_text =
					gnome_canvas_item_new(GNOME_CANVAS_GROUP(reflow),
							      e_text_get_type(),
							      "anchor", GTK_ANCHOR_N,
							      "width", reflow->minimum_width,
							      "clip", TRUE,
							      "use_ellipsis", TRUE,
							      "justification", GTK_JUSTIFY_CENTER,
							      "text", reflow->empty_message,
							      "draw_background", FALSE,
							      NULL);
				e_canvas_item_move_absolute(reflow->empty_text,
							    reflow->minimum_width / 2,
							    0);
			}
		}
	} else {
		if (reflow->empty_text) {
			gtk_object_destroy(GTK_OBJECT(reflow->empty_text));
			reflow->empty_text = NULL;
		}
	}
}
static void
etfci_update (GnomeCanvasItem *item,
              const cairo_matrix_t *i2c,
              gint flags)
{
	ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
	gdouble x1, y1, x2, y2;

	if (GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->update)
		GNOME_CANVAS_ITEM_CLASS (e_table_field_chooser_item_parent_class)->update (
			item, i2c, flags);

	x1 = y1 = 0;
	x2 = etfci->width;
	y2 = etfci->height;

	gnome_canvas_matrix_transform_rect (i2c, &x1, &y1, &x2, &y2);

	if (item->x1 != x1 ||
	    item->y1 != y1 ||
	    item->x2 != x2 ||
	    item->y2 != y2)
		{
			gnome_canvas_request_redraw (
				item->canvas, item->x1,
				item->y1, item->x2, item->y2);
			item->x1 = x1;
			item->y1 = y1;
			item->x2 = x2;
			item->y2 = y2;
/* FIXME: Group Child bounds !? */
#if 0
			gnome_canvas_group_child_bounds (
				GNOME_CANVAS_GROUP (item->parent), item);
#endif
		}
	gnome_canvas_request_redraw (
		item->canvas, item->x1, item->y1, item->x2, item->y2);
}
Beispiel #24
0
static void
zenity_create_clothes (GtkWidget *canvas_board)
{
  GdkPixbuf *pixbuf;
  GnomeCanvasItem *canvas_item;
  gchar *pixbuf_path;
  size_t i;

  for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) {
    pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); 
    pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL);

    canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
                                         GNOME_TYPE_CANVAS_PIXBUF,
                                         "x", monk_clothes[i].x,
                                         "y", monk_clothes[i].y,
                                         "pixbuf", pixbuf,
                                         "anchor", GTK_ANCHOR_NW,
                                          NULL);
    g_signal_connect (G_OBJECT (canvas_item), "event",
                      G_CALLBACK (zenity_move_clothes_event), NULL);
  }
}
Beispiel #25
0
static void
bst_canvas_source_build (BstCanvasSource *csource)
{
  GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
  /* put an outer rectangle, make it transparent in aa mode,
   * so we can receive mouse events everywhere
   */
  GnomeCanvasItem *rect = gnome_canvas_item_new (group,
                                                 GNOME_TYPE_CANVAS_RECT,
                                                 "outline_color_rgba", RGBA_BLACK, /* covers buggy canvas lines */
                                                 "x1", 0.0,
                                                 "y1", 0.0,
                                                 "x2", TOTAL_WIDTH (csource),
                                                 "y2", TOTAL_HEIGHT (csource),
                                                 (GNOME_CANVAS_ITEM (csource)->canvas->aa
                                                  ? "fill_color_rgba"
                                                  : NULL), 0x00000000,
                                                 NULL);
  g_object_connect (rect,
                    "swapped_signal::event", bst_canvas_source_child_event, csource,
                    NULL);
  /* make sure no items are left over */
  while (csource->channel_items)
    gtk_object_destroy (csource->channel_items->data);
  while (csource->channel_hints)
    gtk_object_destroy (csource->channel_hints->data);
  csource->built_ichannels = FALSE;
  csource->built_ochannels = FALSE;
  csource->built_ihints = FALSE;
  csource->built_ohints = FALSE;
  /* asynchronously rebuild contents */
  GnomeCanvasItem *csource_item = GNOME_CANVAS_ITEM (csource);
  /* work around stale canvas pointers, see #340437 */
  g_object_set_data_full (csource_item, "bst-workaround-canvas-ref", g_object_ref (csource_item->canvas), g_object_unref);
  bst_background_handler2_add (bst_canvas_source_build_async, g_object_ref (csource), NULL);
}
Beispiel #26
0
static void
model_changed (EReflowModel *model, EReflow *reflow)
{
	int i;
	int count;
	int oldcount;

	count = reflow->count;
	oldcount = count;

	for (i = 0; i < count; i++) {
		if (reflow->items[i])
			gtk_object_destroy (GTK_OBJECT (reflow->items[i]));
	}
	g_free (reflow->items);
	g_free (reflow->heights);
	reflow->count = e_reflow_model_count (model);
	reflow->allocated_count = reflow->count;
	reflow->items = g_new (GnomeCanvasItem *, reflow->count);
	reflow->heights = g_new (int, reflow->count);

	count = reflow->count;
	for (i = 0; i < count; i++) {
		reflow->items[i] = NULL;
		reflow->heights[i] = e_reflow_model_height (reflow->model, i, GNOME_CANVAS_GROUP (reflow));
	}

	e_selection_model_simple_set_row_count (E_SELECTION_MODEL_SIMPLE (reflow->selection), count);
	e_sorter_array_set_count (reflow->sorter, reflow->count);

	reflow->need_reflow_columns = TRUE;
	if (oldcount > reflow->count)
		reflow_columns (reflow);
	set_empty (reflow);
	e_canvas_item_request_reflow(GNOME_CANVAS_ITEM (reflow));
}
Beispiel #27
0
static gboolean
bst_canvas_source_build_async (gpointer data)
{
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (data);
  if (gnome_canvas_item_check_undisposed (item))
    {
      BstCanvasSource *csource = BST_CANVAS_SOURCE (item);
      GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
      
      /* keep in mind, that creation order affects stacking */

      /* add input and output channel items */
      if (!csource->built_ichannels)
        {
          csource->built_ichannels = TRUE;
          bst_canvas_source_build_channels (csource,
                                            TRUE,               /* input channels */
                                            0xffff00, 0x808000,	/* ichannels */
                                            0x00afff, 0x005880, /* jchannels */
                                            TRUE, FALSE);
          return TRUE;
        }
      if (!csource->built_ochannels)
        {
          csource->built_ochannels = TRUE;
          bst_canvas_source_build_channels (csource,
                                            FALSE,              /* output channels */
                                            0xff0000, 0x800000, /* ochannels */
                                            0, 0,               /* unused */
                                            TRUE, FALSE);
          return TRUE;
        }

      /* add icon to group */
      if (!csource->icon_item)
        {
          csource->icon_item = g_object_connect (gnome_canvas_item_new (group,
                                                                        GNOME_TYPE_CANVAS_PIXBUF,
                                                                        "x", ICON_X (csource),
                                                                        "y", ICON_Y (csource),
                                                                        "width", ICON_WIDTH (csource),
                                                                        "height", ICON_HEIGHT (csource),
                                                                        NULL),
                                                 "signal::destroy", gtk_widget_destroyed, &csource->icon_item,
                                                 "swapped_signal::event", bst_canvas_source_child_event, csource,
                                                 NULL);
          source_icon_changed (csource);
          return TRUE;
        }
      
      if (!csource->text)
        {
          /* add text item, invoke name_changed callback to setup the text value */
          guint ocolor = csource->source && bse_item_internal (csource->source) ? RGBA_INTERNAL : RGBA_BLACK;
          csource->text = gnome_canvas_item_new (group,
                                                 GNOME_TYPE_CANVAS_TEXT,
                                                 "fill_color_rgba", ocolor,
                                                 "anchor", GTK_ANCHOR_NORTH,
                                                 "justification", GTK_JUSTIFY_CENTER,
                                                 "x", TEXT_X (csource),
                                                 "y", TEXT_Y (csource),
                                                 "font", TEXT_FONT,
                                                 NULL);
          g_object_connect (csource->text,
                            "signal::destroy", gtk_widget_destroyed, &csource->text,
                            "swapped_signal::event", bst_canvas_source_child_event, csource,
                            NULL);
          gnome_canvas_text_set_zoom_size (GNOME_CANVAS_TEXT (csource->text), FONT_HEIGHT);
          source_name_changed (csource);
          return TRUE;
        }

      /* add input and output channel hints */
      if (!csource->built_ihints)
        {
          csource->built_ihints = TRUE;
          bst_canvas_source_build_channels (csource,
                                            TRUE,               /* input channels */
                                            0xffff00, 0x808000,	/* ichannels */
                                            0x00afff, 0x005880, /* jchannels */
                                            FALSE, TRUE);
          return TRUE;
        }
      if (!csource->built_ohints)
        {
          csource->built_ohints = TRUE;
          bst_canvas_source_build_channels (csource,
                                            FALSE,              /* output channels */
                                            0xff0000, 0x800000, /* ochannels */
                                            0, 0,               /* unused */
                                            FALSE, TRUE);
          return TRUE;
        }
    }
  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
  g_object_unref (item);
  if (canvas)
    g_object_unref (canvas);      /* canvases don't properly protect their items */
  return FALSE;
}
Beispiel #28
0
static void
bst_canvas_source_build_channels (BstCanvasSource *csource,
				  gboolean         is_input,
				  gint             color1,
				  gint		   color1_fade,
				  gint		   color2,
				  gint		   color2_fade,
                                  gboolean         build_channel_items,
                                  gboolean         build_channel_hints)
{
  GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
  const guint alpha = 0xa0;
  gint n_channels, color1_delta = 0, color2_delta = 0;
  gdouble x1, x2, y1, y2;
  gdouble d_y;
  gboolean east_channel = CHANNEL_EAST (csource, is_input);
  guint i;

  if (is_input)
    {
      n_channels = bse_source_n_ichannels (csource->source);
      x1 = ICHANNEL_X (csource);
      y1 = ICHANNEL_Y (csource);
    }
  else
    {
      n_channels = bse_source_n_ochannels (csource->source);
      x1 = OCHANNEL_X (csource);
      y1 = OCHANNEL_Y (csource);
    }
  x2 = x1 + CHANNEL_WIDTH (csource);
  y2 = y1 + CHANNEL_HEIGHT (csource);
  d_y = y2 - y1;
  if (n_channels)
    d_y /= n_channels;

  if (n_channels > 1)
    {
      gint cd_red, cd_blue, cd_green;

      cd_red = ((color1_fade & 0xff0000) - (color1 & 0xff0000)) / (n_channels - 1);
      cd_green = ((color1_fade & 0x00ff00) - (color1 & 0x00ff00)) / (n_channels - 1);
      cd_blue = ((color1_fade & 0x0000ff) - (color1 & 0x0000ff)) / (n_channels - 1);
      color1_delta = (cd_red & ~0xffff) + (cd_green & ~0xff) + cd_blue;

      cd_red = ((color2_fade & 0xff0000) - (color2 & 0xff0000)) / (n_channels - 1);
      cd_green = ((color2_fade & 0x00ff00) - (color2 & 0x00ff00)) / (n_channels - 1);
      cd_blue = ((color2_fade & 0x0000ff) - (color2 & 0x0000ff)) / (n_channels - 1);
      color2_delta = (cd_red & ~0xffff) + (cd_green & ~0xff) + cd_blue;
    }
  else if (n_channels == 0)
    {
      GnomeCanvasItem *item;
      if (build_channel_items)
        {
          item = g_object_connect (gnome_canvas_item_new (group,
                                                          GNOME_TYPE_CANVAS_RECT,
                                                          "fill_color_rgba", (0xc3c3c3 << 8) | alpha,
                                                          "outline_color_rgba", RGBA_BLACK,
                                                          "x1", x1,
                                                          "y1", y1,
                                                          "x2", x2,
                                                          "y2", y2,
                                                          NULL),
                                   "swapped_signal::destroy", channel_item_remove, csource,
                                   "swapped_signal::event", bst_canvas_source_child_event, csource,
                                   NULL);
          csource->channel_items = g_slist_prepend (csource->channel_items, item);
        }
    }
  
  for (i = 0; i < n_channels; i++)
    {
      GnomeCanvasItem *item;
      gboolean is_jchannel = is_input && bse_source_is_joint_ichannel_by_id (csource->source, i);
      const gchar *label = (is_input ? bse_source_ichannel_label : bse_source_ochannel_label) (csource->source, i);
      guint tmp_color = is_jchannel ? color2 : color1;

      y2 = y1 + d_y;
      if (build_channel_items)
        {
          item = gnome_canvas_item_new (group,
                                        GNOME_TYPE_CANVAS_RECT,
                                        "fill_color_rgba", (tmp_color << 8) | alpha,
                                        "outline_color_rgba", RGBA_BLACK,
                                        "x1", x1,
                                        "y1", y1,
                                        "x2", x2,
                                        "y2", y2,
                                        NULL);
          g_object_connect (item,
                            "swapped_signal::destroy", channel_item_remove, csource,
                            "swapped_signal::event", bst_canvas_source_child_event, csource,
                            NULL);
          csource->channel_items = g_slist_prepend (csource->channel_items, item);
        }

      if (build_channel_hints)
        {
          item = gnome_canvas_item_new (group,
                                        GNOME_TYPE_CANVAS_TEXT,
                                        "fill_color_rgba", (0x000000 << 8) | 0x80,
                                        "anchor", east_channel ? GTK_ANCHOR_WEST : GTK_ANCHOR_EAST,
                                        "justification", GTK_JUSTIFY_RIGHT,
                                        "x", east_channel ? TOTAL_WIDTH (csource) + BORDER_PAD * 2. : -BORDER_PAD,
                                        "y", (y1 + y2) / 2.,
                                        "font", CHANNEL_FONT,
                                        "text", csource->show_hints ? label : "",
                                        NULL);
          g_object_connect (item,
                            "swapped_signal::destroy", channel_name_remove, csource,
                            NULL);
          gnome_canvas_text_set_zoom_size (GNOME_CANVAS_TEXT (item), FONT_HEIGHT);
          g_object_set_data_full (G_OBJECT (item), "hint_text", g_strdup (label), g_free);
          csource->channel_hints = g_slist_prepend (csource->channel_hints, item);
        }

      color1 += color1_delta;
      color2 += color2_delta;
      y1 = y2;
    }
}
Beispiel #29
0
GtkWidget *
ghack_init_map_window()
{
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *table;
    GtkWidget *frame;
    GtkWidget *w;
    GtkWidget *hSeparator;
    GtkAdjustment *adj;
    GnomeCanvasImage *bg;
    double width, height, x, y;
    int i;

    width = COLNO * ghack_glyph_width();
    height = ROWNO * ghack_glyph_height();

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

    /* Add in a horiz seperator */
    hSeparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox), hSeparator, FALSE, FALSE, 2);
    gtk_widget_show(hSeparator);

    hbox = gtk_hbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show(hbox);

    /* Create the Zoom spinbutton.
    */
    ghack_map.zoom = 1.0;
    w = gtk_label_new("Zoom:");
    gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
    gtk_widget_show(w);
    adj =
        GTK_ADJUSTMENT(gtk_adjustment_new(1.00, 0.5, 3.00, 0.05, 0.50, 0.50));
    w = gtk_spin_button_new(adj, 0.5, 2);
    gtk_widget_set_usize(w, 50, 0);
    gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
    gtk_widget_show(w);

    /* Canvas and scrollbars
    */
    gtk_widget_push_visual(gdk_imlib_get_visual());
    gtk_widget_push_colormap(gdk_imlib_get_colormap());
    ghack_map.canvas = GNOME_CANVAS(gnome_canvas_new());
    // gtk_widget_push_visual(gdk_rgb_get_visual());
    // gtk_widget_push_colormap(gdk_rgb_get_cmap());
    // ghack_map.canvas = GNOME_CANVAS (gnome_canvas_new_aa());

    gtk_widget_pop_colormap();
    gtk_widget_pop_visual();
    gtk_widget_show(GTK_WIDGET(ghack_map.canvas));

    table = gtk_table_new(2, 2, FALSE);
    gtk_table_set_row_spacings(GTK_TABLE(table), 4);
    gtk_table_set_col_spacings(GTK_TABLE(table), 4);
    gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
    gtk_widget_show(table);

    frame = gtk_frame_new(NULL);
    ghack_map.frame = frame;
    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
    gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
    gtk_widget_show(frame);

    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(ghack_map.canvas));
    gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
                                   width + 2 * ghack_glyph_width(),
                                   height + 2 * ghack_glyph_height());

    gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(ghack_map.canvas), 1.0);

    w = gtk_hscrollbar_new(GTK_LAYOUT(ghack_map.canvas)->hadjustment);
    gtk_table_attach(GTK_TABLE(table), w, 0, 1, 1, 2,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
    gtk_widget_show(w);

    w = gtk_vscrollbar_new(GTK_LAYOUT(ghack_map.canvas)->vadjustment);
    gtk_table_attach(GTK_TABLE(table), w, 1, 2, 0, 1, GTK_FILL,
                     GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0);
    gtk_widget_show(w);

    myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
                                           gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
                                           gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));

    /* Tile the map background with a pretty image */
    background = gdk_imlib_load_image((char *) "mapbg.xpm");
    if (background == NULL) {
        g_warning(
            "Bummer! Failed to load the map background image (mapbg.xpm)!");
    } else {
        gdk_imlib_render(background, background->rgb_width,
                         background->rgb_height);

        /* Tile the map background */
        for (y = 0; y < height + background->rgb_height;
                y += background->rgb_height) {
            for (x = 0; x < width + background->rgb_width;
                    x += background->rgb_width) {
                bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                            myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                            (double) x, "y", (double) y, "width",
                                            (double) background->rgb_width, "height",
                                            (double) background->rgb_height, "image", background,
                                            "anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
                gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
            }
        }
    }

    /* ghack_map.map is an array of canvas images.  Each cell of
     * the array will contain one tile.  Here, we create the
     * space for the cells and then create the cells for easy
     * access later.
    */
    for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
        for (x = 0; x < width; x += ghack_glyph_width()) {
            ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                    myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
                    "y", (double) y, "width", (double) ghack_glyph_width(),
                    "height", (double) ghack_glyph_height(), "anchor",
                    GTK_ANCHOR_NORTH_WEST, NULL));
        }
    }

    /* Set up the pet mark image */
    petmark = gdk_imlib_create_image_from_xpm_data(pet_mark_xpm);
    if (petmark == NULL) {
        g_warning("Bummer! Failed to load the pet_mark image!");
    } else {
        gdk_imlib_render(petmark, petmark->rgb_width, petmark->rgb_height);

        /* ghack_map.overlay is an array of canvas images used to
         * overlay tile images...
         */
        for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
            for (x = 0; x < width; x += ghack_glyph_width()) {
                ghack_map.overlay[i] =
                    GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                           myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                           (double) x, "y", (double) y, "width",
                                           (double) petmark->rgb_width, "height",
                                           (double) petmark->rgb_height, "image", petmark,
                                           "anchor", GTK_ANCHOR_NORTH_WEST, NULL));
                gnome_canvas_item_lower_to_bottom(
                    GNOME_CANVAS_ITEM(ghack_map.overlay[i++]));
            }
        }
    }

    /* Resize the canvas when the spinbutton changes
    */
    gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
                       (GtkSignalFunc) ghack_map_window_zoom,
                       ghack_map.canvas);

    /* Game signals
    */
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_curs",
                       GTK_SIGNAL_FUNC(ghack_map_cursor_to), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_putstr",
                       GTK_SIGNAL_FUNC(ghack_map_putstr), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_print_glyph",
                       GTK_SIGNAL_FUNC(ghack_map_print_glyph), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_clear",
                       GTK_SIGNAL_FUNC(ghack_map_clear), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_display",
                       GTK_SIGNAL_FUNC(ghack_map_display), NULL);
    gtk_signal_connect(GTK_OBJECT(vbox), "ghack_cliparound",
                       GTK_SIGNAL_FUNC(ghack_map_cliparound), NULL);
    gtk_signal_connect(GTK_OBJECT(ghack_map.canvas), "button_press_event",
                       GTK_SIGNAL_FUNC(ghack_handle_button_press), NULL);
    gtk_signal_connect(GTK_OBJECT(ghack_map.canvas), "gnome_delay_output",
                       GTK_SIGNAL_FUNC(ghack_delay), NULL);

    return GTK_WIDGET(vbox);
}
Beispiel #30
0
/* Handles the events on the ETableClickToAdd, particularly
 * it creates the ETableItem and passes in some events. */
static gint
etcta_event (GnomeCanvasItem *item,
             GdkEvent *e)
{
	ETableClickToAdd *etcta = E_TABLE_CLICK_TO_ADD (item);

	switch (e->type) {
	case GDK_FOCUS_CHANGE:
		if (!e->focus_change.in)
			return TRUE;
		/* coverity[fallthrough] */

	case GDK_BUTTON_PRESS:
		if (etcta->text) {
			g_object_run_dispose (G_OBJECT (etcta->text));
			etcta->text = NULL;
		}
		if (etcta->rect) {
			g_object_run_dispose (G_OBJECT (etcta->rect));
			etcta->rect = NULL;
		}
		if (!etcta->row) {
			ETableModel *one;

			one = e_table_one_new (etcta->model);
			etcta_add_one (etcta, one);
			g_object_unref (one);

			e_selection_model_clear (E_SELECTION_MODEL (etcta->selection));

			etcta->row = gnome_canvas_item_new (
				GNOME_CANVAS_GROUP (item),
				e_table_item_get_type (),
				"ETableHeader", etcta->eth,
				"ETableModel", etcta->one,
				"minimum_width", etcta->width,
				"horizontal_draw_grid", TRUE,
				"vertical_draw_grid", TRUE,
				"selection_model", etcta->selection,
				"cursor_mode", E_CURSOR_SPREADSHEET,
				NULL);

			g_signal_connect (
				etcta->row, "key_press",
				G_CALLBACK (item_key_press), etcta);

			e_signal_connect_notify (
				etcta->row, "notify::is-editing",
				G_CALLBACK (table_click_to_add_row_is_editing_changed_cb), etcta);

			e_canvas_item_grab_focus (GNOME_CANVAS_ITEM (etcta->row), TRUE);

			set_initial_selection (etcta);

			g_object_notify (G_OBJECT (etcta), "is-editing");
		}
		break;

	case GDK_KEY_PRESS:
		switch (e->key.keyval) {
		case GDK_KEY_Tab:
		case GDK_KEY_KP_Tab:
		case GDK_KEY_ISO_Left_Tab:
			finish_editing (etcta);
			break;
		default:
			return FALSE;
		case GDK_KEY_Escape:
			if (etcta->row) {
				e_table_item_leave_edit (E_TABLE_ITEM (etcta->row));
				etcta_drop_one (etcta);
				g_object_run_dispose (G_OBJECT (etcta->row));
				etcta->row = NULL;
				create_rect_and_text (etcta);
				e_canvas_item_move_absolute (etcta->text, 3, 3);
			}
			break;
		}
		break;

	default:
		return FALSE;
	}
	return TRUE;
}