aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-08-07 06:07:28 +0800
committerChris Lahey <clahey@src.gnome.org>2001-08-07 06:07:28 +0800
commitba57a90d939acce8ddc2b480f22de64be5c7a7f8 (patch)
tree9f260b685c9b89c42b37d4cafc681cd867cb4c3b /widgets/table
parent58e53223b1999d4b2207db0464f02e1cad9d4618 (diff)
downloadgsoc2013-evolution-ba57a90d939acce8ddc2b480f22de64be5c7a7f8.tar.gz
gsoc2013-evolution-ba57a90d939acce8ddc2b480f22de64be5c7a7f8.tar.zst
gsoc2013-evolution-ba57a90d939acce8ddc2b480f22de64be5c7a7f8.zip
Implemented these functions.
2001-08-06 Christopher James Lahey <clahey@ximian.com> * e-table.c, e-table.h (e_table_drag_highlight, e_table_drag_unhighlight): Implemented these functions. * e-tree.c (e_tree_drag_highlight, e_tree_drag_unhighlight): Implemented these functions. svn path=/trunk/; revision=11713
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-table.c38
-rw-r--r--widgets/table/e-table.h1
-rw-r--r--widgets/table/e-tree.c77
3 files changed, 110 insertions, 6 deletions
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 83296059c8..166f864348 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -1666,6 +1666,39 @@ e_table_drag_highlight (ETable *table,
{
g_return_if_fail(table != NULL);
g_return_if_fail(E_IS_TABLE(table));
+
+ if (row != -1) {
+ int x, y, width, height;
+ if (col == -1) {
+ e_table_get_cell_geometry (table, row, 0, &x, &y, &width, &height);
+ x = 0;
+ width = GTK_WIDGET (table->table_canvas)->allocation.width;
+ } else {
+ e_table_get_cell_geometry (table, row, col, &x, &y, &width, &height);
+ x += GTK_LAYOUT(table->table_canvas)->hadjustment->value;
+ }
+ y += GTK_LAYOUT(table->table_canvas)->vadjustment->value;
+
+ if (table->drop_highlight == NULL) {
+ table->drop_highlight =
+ gnome_canvas_item_new (gnome_canvas_root (table->table_canvas),
+ gnome_canvas_rect_get_type (),
+ "fill_color", NULL,
+ /* "outline_color", "black",
+ "width_pixels", 1,*/
+ "outline_color_gdk", &(GTK_WIDGET (table)->style->fg[GTK_STATE_NORMAL]),
+ NULL);
+ }
+ gnome_canvas_item_set (table->drop_highlight,
+ "x1", (double) x,
+ "x2", (double) x + width - 1,
+ "y1", (double) y,
+ "y2", (double) y + height - 1,
+ NULL);
+ } else {
+ gtk_object_destroy (GTK_OBJECT (table->drop_highlight));
+ table->drop_highlight = NULL;
+ }
}
void
@@ -1673,6 +1706,11 @@ e_table_drag_unhighlight (ETable *table)
{
g_return_if_fail(table != NULL);
g_return_if_fail(E_IS_TABLE(table));
+
+ if (table->drop_highlight) {
+ gtk_object_destroy (GTK_OBJECT (table->drop_highlight));
+ table->drop_highlight = NULL;
+ }
}
void e_table_drag_dest_set (ETable *table,
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index 829b8ffcaf..0cd63a58ab 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -94,6 +94,7 @@ typedef struct {
int drop_row;
int drop_col;
+ GnomeCanvasItem *drop_highlight;
int drag_row;
int drag_col;
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 527f0e1057..884ac8971b 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -123,6 +123,8 @@ struct ETreePriv {
ETreePath drop_path;
int drop_col;
+ GnomeCanvasItem *drop_highlight;
+
int drag_row;
ETreePath drag_path;
int drag_col;
@@ -249,8 +251,8 @@ et_destroy (GtkObject *object)
static void
e_tree_init (GtkObject *object)
{
- ETree *e_tree = E_TREE (object);
- GtkTable *gtk_table = GTK_TABLE (object);
+ ETree *e_tree = E_TREE (object);
+ GtkTable *gtk_table = GTK_TABLE (object);
GTK_WIDGET_SET_FLAGS (e_tree, GTK_CAN_FOCUS);
@@ -269,7 +271,7 @@ e_tree_init (GtkObject *object)
e_tree->priv->sorter = NULL;
e_tree->priv->reflow_idle_id = 0;
- e_tree->priv->alternating_row_colors = 1;
+ e_tree->priv->alternating_row_colors = 1;
e_tree->priv->horizontal_draw_grid = 1;
e_tree->priv->vertical_draw_grid = 1;
e_tree->priv->draw_focus = 1;
@@ -282,6 +284,7 @@ e_tree_init (GtkObject *object)
e_tree->priv->drop_row = -1;
e_tree->priv->drop_path = NULL;
e_tree->priv->drop_col = -1;
+ e_tree->priv->drop_highlight = NULL;
e_tree->priv->drag_row = -1;
e_tree->priv->drag_path = NULL;
@@ -1592,6 +1595,29 @@ e_tree_drag_get_data (ETree *tree,
}
+#if 0
+static void
+e_tree_request_hightlight_redraw (ETree *tree)
+{
+ int row = tree->drop_highlight_row;
+ int col = tree->drop_highlight_col;
+
+ if (row != -1) {
+ int x, y, width, height;
+ if (col == -1) {
+ e_tree_get_cell_geometry (tree, row, 0, &x, &y, &width, &height);
+ x = 0;
+ width = tree->allocation.width;
+ } else {
+ e_tree_get_cell_geometry (tree, row, col, &x, &y, &width, &height);
+ x += GTK_LAYOUT(tree->priv->table_canvas)->hadjustment->value;
+ }
+ y += GTK_LAYOUT(tree->priv->table_canvas)->vadjustment->value;
+ gnome_canvas_request_redraw (tree->priv->table_canvas, x, y, x + width - 1, y + height - 1);
+ }
+}
+#endif
+
/**
* e_tree_drag_highlight:
* @tree:
@@ -1599,14 +1625,48 @@ e_tree_drag_get_data (ETree *tree,
* @col:
*
* Set col to -1 to highlight the entire row.
+ * Set row to -1 to turn off the highlight.
*/
void
e_tree_drag_highlight (ETree *tree,
- int row,
- int col)
+ int row,
+ int col)
{
g_return_if_fail(tree != NULL);
g_return_if_fail(E_IS_TREE(tree));
+
+ if (row != -1) {
+ int x, y, width, height;
+ if (col == -1) {
+ e_tree_get_cell_geometry (tree, row, 0, &x, &y, &width, &height);
+ x = 0;
+ width = GTK_WIDGET (tree->priv->table_canvas)->allocation.width;
+ } else {
+ e_tree_get_cell_geometry (tree, row, col, &x, &y, &width, &height);
+ x += GTK_LAYOUT(tree->priv->table_canvas)->hadjustment->value;
+ }
+ y += GTK_LAYOUT(tree->priv->table_canvas)->vadjustment->value;
+
+ if (tree->priv->drop_highlight == NULL) {
+ tree->priv->drop_highlight =
+ gnome_canvas_item_new (gnome_canvas_root (tree->priv->table_canvas),
+ gnome_canvas_rect_get_type (),
+ "fill_color", NULL,
+ /* "outline_color", "black",
+ "width_pixels", 1,*/
+ "outline_color_gdk", &(GTK_WIDGET (tree)->style->fg[GTK_STATE_NORMAL]),
+ NULL);
+ }
+ gnome_canvas_item_set (tree->priv->drop_highlight,
+ "x1", (double) x,
+ "x2", (double) x + width - 1,
+ "y1", (double) y,
+ "y2", (double) y + height - 1,
+ NULL);
+ } else {
+ gtk_object_destroy (GTK_OBJECT (tree->priv->drop_highlight));
+ tree->priv->drop_highlight = NULL;
+ }
}
void
@@ -1614,6 +1674,11 @@ e_tree_drag_unhighlight (ETree *tree)
{
g_return_if_fail(tree != NULL);
g_return_if_fail(E_IS_TREE(tree));
+
+ if (tree->priv->drop_highlight) {
+ gtk_object_destroy (GTK_OBJECT (tree->priv->drop_highlight));
+ tree->priv->drop_highlight = NULL;
+ }
}
void e_tree_drag_dest_set (ETree *tree,
@@ -1925,7 +1990,7 @@ et_drag_motion(GtkWidget *widget,
y,
&row,
&col);
- if (row != et->priv->drop_row && col != et->priv->drop_row) {
+ if (row != et->priv->drop_row && col != et->priv->drop_col) {
gtk_signal_emit (GTK_OBJECT (et),
et_signals [TREE_DRAG_LEAVE],
et->priv->drop_row,