Commit af4419bb authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

add sheet_object_group add selector to cmd_object_raise ditto use

2002-04-25  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* src/gnumeric-canvas.[ch] : add sheet_object_group
	* src/commands.c : add selector to cmd_object_raise
	* src/commands.h : ditto
	* src/sheet-object-container.c : use sheet_object_group
	* src/sheet-object-graphic.c : ditto
	* src/sheet-object-image.c : ditto
	* src/sheet-object-item.c : ditto
	* src/sheet-object.c (cb_sheet_object_raise_to_top) : new
	(cb_sheet_object_lower_to_bottom) : new
	(sheet_object_populate_menu) : add raise to top/lower to bottom
	  menu items
parent d5569958
2002-04-25 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gnumeric-canvas.[ch] : add sheet_object_group
* src/commands.c : add selector to cmd_object_raise
* src/commands.h : ditto
* src/sheet-object-container.c : use sheet_object_group
* src/sheet-object-graphic.c : ditto
* src/sheet-object-image.c : ditto
* src/sheet-object-item.c : ditto
* src/sheet-object.c (cb_sheet_object_raise_to_top) : new
(cb_sheet_object_lower_to_bottom) : new
(sheet_object_populate_menu) : add raise to top/lower to bottom
menu items
2002-04-24 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/item-grid.c (ig_obj_create_finish) : don't unref the sheet
......
......@@ -35,6 +35,7 @@ Andreas:
* Fix http://bugzilla.gnome.org/show_bug.cgi?id=76474
* Add lowering and raising of sheet objects (except widgets).
* Fix http://bugzilla.gnome.org/show_bug.cgi?id=79809
* Add lowering and raising of sheet objects (except widgets) to top and bottom.
Jody:
* Add password dialog to support encrypted input.
......
2002-04-25 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gnumeric-canvas.[ch] : add sheet_object_group
* src/commands.c : add selector to cmd_object_raise
* src/commands.h : ditto
* src/sheet-object-container.c : use sheet_object_group
* src/sheet-object-graphic.c : ditto
* src/sheet-object-image.c : ditto
* src/sheet-object-item.c : ditto
* src/sheet-object.c (cb_sheet_object_raise_to_top) : new
(cb_sheet_object_lower_to_bottom) : new
(sheet_object_populate_menu) : add raise to top/lower to bottom
menu items
2002-04-24 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/item-grid.c (ig_obj_create_finish) : don't unref the sheet
......
2002-04-25 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gnumeric-canvas.[ch] : add sheet_object_group
* src/commands.c : add selector to cmd_object_raise
* src/commands.h : ditto
* src/sheet-object-container.c : use sheet_object_group
* src/sheet-object-graphic.c : ditto
* src/sheet-object-image.c : ditto
* src/sheet-object-item.c : ditto
* src/sheet-object.c (cb_sheet_object_raise_to_top) : new
(cb_sheet_object_lower_to_bottom) : new
(sheet_object_populate_menu) : add raise to top/lower to bottom
menu items
2002-04-24 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/item-grid.c (ig_obj_create_finish) : don't unref the sheet
......
......@@ -4898,8 +4898,8 @@ typedef struct
{
GnumericCommand parent;
SheetObject *so;
gint dir;
gint undo_dir;
CmdObjectRaiseSelector dir;
gint changed_positions;
} CmdObjectRaise;
GNUMERIC_MAKE_COMMAND (CmdObjectRaise, cmd_object_raise);
......@@ -4908,7 +4908,20 @@ static gboolean
cmd_object_raise_redo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdObjectRaise *me = CMD_OBJECT_RAISE (cmd);
me->undo_dir = - sheet_object_raise (me->so, me->dir);
switch (me->dir) {
case cmd_object_raise_up:
me->changed_positions = sheet_object_raise (me->so, 1);
break;
case cmd_object_raise_down:
me->changed_positions = sheet_object_raise (me->so, -1);
break;
case cmd_object_raise_top:
me->changed_positions = sheet_object_raise_top (me->so);
break;
case cmd_object_raise_bottom:
me->changed_positions = sheet_object_lower_bottom (me->so);
break;
}
return FALSE;
}
......@@ -4916,7 +4929,8 @@ static gboolean
cmd_object_raise_undo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdObjectRaise *me = CMD_OBJECT_RAISE (cmd);
me->dir = - sheet_object_raise (me->so, me->undo_dir);
if (me->changed_positions != 0)
sheet_object_raise (me->so, - me->changed_positions);
return FALSE;
}
......@@ -4929,7 +4943,7 @@ cmd_object_raise_finalize (GObject *cmd)
}
gboolean
cmd_object_raise (WorkbookControl *wbc, SheetObject *so, gint dir)
cmd_object_raise (WorkbookControl *wbc, SheetObject *so, CmdObjectRaiseSelector dir)
{
GObject *object;
CmdObjectRaise *me;
......@@ -4944,10 +4958,22 @@ cmd_object_raise (WorkbookControl *wbc, SheetObject *so, gint dir)
me->parent.sheet = sheet_object_get_sheet (so);
me->parent.size = 1;
me->parent.cmd_descriptor = ((dir == 1) ? g_strdup (_("Raise object"))
: g_strdup (_("Lower object")));
switch (dir) {
case cmd_object_raise_up:
me->parent.cmd_descriptor = g_strdup (_("Raise object"));
break;
case cmd_object_raise_down:
me->parent.cmd_descriptor = g_strdup (_("Lower object"));
break;
case cmd_object_raise_top:
me->parent.cmd_descriptor = g_strdup (_("Raise object to top"));
break;
case cmd_object_raise_bottom:
me->parent.cmd_descriptor = g_strdup (_("Lower object to bottom"));
break;
}
me->dir = dir;
me->undo_dir = - dir;
me->changed_positions = 0;
return command_push_undo (wbc, object);
}
......
......@@ -108,6 +108,12 @@ gboolean cmd_merge_data (WorkbookControl *wbc, Sheet *sheet,
gboolean cmd_change_summary (WorkbookControlGUI *wbcg, GSList *sin_changes);
gboolean cmd_object_raise (WorkbookControl *wbc, SheetObject *so, gint dir);
typedef enum {
cmd_object_raise_up ,
cmd_object_raise_down,
cmd_object_raise_top,
cmd_object_raise_bottom
} CmdObjectRaiseSelector;
gboolean cmd_object_raise (WorkbookControl *wbc, SheetObject *so, CmdObjectRaiseSelector dir);
#endif /* GNUMERIC_COMMANDS_H */
......@@ -637,6 +637,10 @@ gnumeric_canvas_new (SheetControlGUI *scg, GnumericPane *pane)
root_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (gcanvas)->root);
gcanvas->anted_group = root_group;
gcanvas->object_group = root_group;
gcanvas->sheet_object_group = GNOME_CANVAS_GROUP (gnome_canvas_item_new (
root_group,
GNOME_TYPE_CANVAS_GROUP,
NULL));
return gcanvas;
}
......
......@@ -24,6 +24,7 @@ struct _GnumericCanvas {
GnomeCanvasGroup *anted_group;
GnomeCanvasGroup *object_group;
GnomeCanvasGroup *sheet_object_group;
#if 0
/* Input context for dead key support */
......
......@@ -60,8 +60,9 @@ sheet_object_container_new_view (SheetObject *so, SheetControlGUI *scg)
}
view_widget = bonobo_view_frame_get_wrapper (view_frame);
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM (gcanvas->sheet_object_group));
view_item = gnome_canvas_item_new (
gcanvas->object_group,
gcanvas->sheet_object_group,
gnome_canvas_widget_get_type (),
"widget", view_widget,
"size_pixels", FALSE,
......
......@@ -137,10 +137,12 @@ sheet_object_graphic_new_view (SheetObject *so, SheetControlGUI *scg)
fill_color = (sog->fill_color != NULL) ? &sog->fill_color->color : NULL;
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM (gcanvas->sheet_object_group));
switch (sog->type) {
case SHEET_OBJECT_LINE:
item = gnome_canvas_item_new (
gcanvas->object_group,
gcanvas->sheet_object_group,
gnome_canvas_line_get_type (),
"fill_color_gdk", fill_color,
"width_units", sog->width,
......@@ -149,7 +151,7 @@ sheet_object_graphic_new_view (SheetObject *so, SheetControlGUI *scg)
case SHEET_OBJECT_ARROW:
item = gnome_canvas_item_new (
gcanvas->object_group,
gcanvas->sheet_object_group,
gnome_canvas_line_get_type (),
"fill_color_gdk", fill_color,
"width_units", sog->width,
......@@ -736,7 +738,9 @@ sheet_object_filled_new_view (SheetObject *so, SheetControlGUI *scg)
fill_color = (sog->fill_color != NULL) ? &sog->fill_color->color : NULL;
outline_color = (sof->outline_color != NULL) ? &sof->outline_color->color : NULL;
item = gnome_canvas_item_new (gcanvas->object_group,
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM (gcanvas->sheet_object_group));
item = gnome_canvas_item_new (gcanvas->sheet_object_group,
(sog->type == SHEET_OBJECT_OVAL) ?
GNOME_TYPE_CANVAS_ELLIPSE :
GNOME_TYPE_CANVAS_RECT,
......
......@@ -193,14 +193,15 @@ sheet_object_image_new_view (SheetObject *so, SheetControlGUI *scg)
g_return_val_if_fail (IS_SHEET_OBJECT_IMAGE (so), NULL);
g_return_val_if_fail (IS_SHEET_CONTROL_GUI (scg), NULL);
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM (gcanvas->sheet_object_group));
pixbuf = soi_get_pixbuf (soi, 1.);
if (pixbuf != NULL)
item = gnome_canvas_item_new (gcanvas->object_group,
item = gnome_canvas_item_new (gcanvas->sheet_object_group,
GNOME_TYPE_CANVAS_PIXBUF,
"pixbuf", pixbuf,
NULL);
else
item = gnome_canvas_item_new (gcanvas->object_group,
item = gnome_canvas_item_new (gcanvas->sheet_object_group,
GNOME_TYPE_CANVAS_RECT,
"fill_color", "white",
"outline_color", "black",
......
......@@ -28,10 +28,11 @@ sheet_object_item_new_view (SheetObject *so, SheetControlGUI *scg)
GnumericCanvas *gcanvas = scg_pane (scg, 0);
GnomeCanvasItem *so_view = NULL;
gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM (gcanvas->sheet_object_group));
so_view = bonobo_client_site_new_item (
SHEET_OBJECT_BONOBO (so)->control_frame,
bonobo_ui_component_get_container (scg->wbcg->uic),
gcanvas->object_group);
gcanvas->sheet_object_group);
scg_object_register (so, so_view);
return GTK_OBJECT (so_view);
......
......@@ -49,7 +49,21 @@ cb_sheet_object_raise (GtkWidget *widget, GObject *so_view)
scg = sheet_object_view_control (so_view);
wbc = sc_wbc (SHEET_CONTROL (scg));
cmd_object_raise (wbc, so, 1);
cmd_object_raise (wbc, so, cmd_object_raise_up);
}
static void
cb_sheet_object_raise_to_top (GtkWidget *widget, GObject *so_view)
{
SheetObject *so;
SheetControlGUI *scg;
WorkbookControl *wbc;
so = sheet_object_view_obj (so_view);
scg = sheet_object_view_control (so_view);
wbc = sc_wbc (SHEET_CONTROL (scg));
cmd_object_raise (wbc, so, cmd_object_raise_top);
}
static void
......@@ -63,7 +77,21 @@ cb_sheet_object_lower (GtkWidget *widget, GObject *so_view)
scg = sheet_object_view_control (so_view);
wbc = sc_wbc (SHEET_CONTROL (scg));
cmd_object_raise (wbc, so, -1);
cmd_object_raise (wbc, so, cmd_object_raise_down);
}
static void
cb_sheet_object_lower_to_bottom (GtkWidget *widget, GObject *so_view)
{
SheetObject *so;
SheetControlGUI *scg;
WorkbookControl *wbc;
so = sheet_object_view_obj (so_view);
scg = sheet_object_view_control (so_view);
wbc = sc_wbc (SHEET_CONTROL (scg));
cmd_object_raise (wbc, so, cmd_object_raise_bottom);
}
static void
......@@ -118,16 +146,26 @@ sheet_object_populate_menu (SheetObject *so,
gtk_menu_append (menu, item);
}
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GOTO_TOP, NULL);
gtk_menu_append (menu, item);
g_signal_connect (G_OBJECT (item),
"activate",
G_CALLBACK (cb_sheet_object_raise_to_top), obj_view);
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GO_UP, NULL);
gtk_menu_append (menu, item);
g_signal_connect (G_OBJECT (item),
"activate",
G_CALLBACK (cb_sheet_object_raise), obj_view);
"activate",
G_CALLBACK (cb_sheet_object_raise), obj_view);
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GO_DOWN, NULL);
gtk_menu_append (menu, item);
g_signal_connect (G_OBJECT (item),
"activate",
G_CALLBACK (cb_sheet_object_lower), obj_view);
"activate",
G_CALLBACK (cb_sheet_object_lower), obj_view);
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GOTO_BOTTOM, NULL);
gtk_menu_append (menu, item);
g_signal_connect (G_OBJECT (item),
"activate",
G_CALLBACK (cb_sheet_object_lower_to_bottom), obj_view);
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, NULL);
gtk_menu_append (menu, item);
g_signal_connect (G_OBJECT (item),
......@@ -1024,20 +1062,65 @@ sheet_object_anchor_init (SheetObjectAnchor *anchor,
}
gint
sheet_object_raise (SheetObject *so, gint dir)
sheet_object_raise (SheetObject *so, gint positions)
{
GList *l;
gint before = -1;
gint after = -1;
for (l = so->realized_list; l; l = l->next) {
switch (dir) {
case 1:
gnome_canvas_item_raise (GNOME_CANVAS_ITEM (l->data), 1);
break;
case -1:
default:
gnome_canvas_item_lower (GNOME_CANVAS_ITEM (l->data), 1);
break;
}
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (l->data);
GnomeCanvasGroup *parent = GNOME_CANVAS_GROUP (item->parent);
GList *link = g_list_find (parent->item_list, item);
before = g_list_position (parent->item_list, link);
if (positions > 0)
gnome_canvas_item_raise (item, positions);
else
gnome_canvas_item_lower (item, - positions);
link = g_list_find (parent->item_list, item);
after = g_list_position (parent->item_list, link);
}
return ((before == -1 || after == -1) ? positions : (after - before));
}
gint
sheet_object_raise_top (SheetObject *so)
{
GList *l;
gint before = -1;
gint after = -1;
for (l = so->realized_list; l; l = l->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (l->data);
GnomeCanvasGroup *parent = GNOME_CANVAS_GROUP (item->parent);
GList *link = g_list_find (parent->item_list, item);
before = g_list_position (parent->item_list, link);
gnome_canvas_item_raise_to_top (item);
link = g_list_find (parent->item_list, item);
after = g_list_position (parent->item_list, link);
}
return ((before == -1 || after == -1) ? 0 : (after - before));
}
gint
sheet_object_lower_bottom (SheetObject *so)
{
GList *l;
gint before = -1;
gint after = -1;
for (l = so->realized_list; l; l = l->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (l->data);
GnomeCanvasGroup *parent = GNOME_CANVAS_GROUP (item->parent);
GList *link = g_list_find (parent->item_list, item);
before = g_list_position (parent->item_list, link);
gnome_canvas_item_lower_to_bottom (item);
link = g_list_find (parent->item_list, item);
after = g_list_position (parent->item_list, link);
}
return dir;
return ((before == -1 || after == -1) ? 0 : (after - before));
}
......@@ -79,7 +79,9 @@ void sheet_object_position_pixels_get (SheetObject const *so,
SheetControl const *sc, double *pos);
void sheet_object_position_pixels_set (SheetObject const *so,
SheetControl const *sc, double const *pos);
gint sheet_object_raise (SheetObject *so, gint dir);
gint sheet_object_raise (SheetObject *so, gint positions);
gint sheet_object_raise_top (SheetObject *so);
gint sheet_object_lower_bottom (SheetObject *so);
/* Object Management */
void sheet_objects_relocate (GnmExprRelocateInfo const *rinfo, gboolean update);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment