*
* GtkSheet is a matrix widget for GTK+. It consists of an scrollable grid of
* cells where you can allocate text. Cell contents can be edited interactively
- * through a specially designed entry, GtkItemEntry. It is also a container
- * subclass, allowing you to display buttons, curves, pixmaps and any other
- * widgets in it.
+ * through a specially designed entry, GtkItemEntry.
*
- * You can also set many attributes as: border, foreground and background color,
- * text justification, and more.
- *
- * The testgtksheet program shows how easy is to create a spreadsheet-like GUI
- * using this widget.
*/
#include <config.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtksignal.h>
-#include <gtk/gtklabel.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkadjustment.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbox.h>
-#include <gtk/gtkmain.h>
#include <gtk/gtktypeutils.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkcontainer.h>
/* sheet flags */
enum
{
- GTK_SHEET_IS_FROZEN = 1 << 1,
- GTK_SHEET_IN_XDRAG = 1 << 2,
- GTK_SHEET_IN_YDRAG = 1 << 3,
- GTK_SHEET_IN_DRAG = 1 << 4,
- GTK_SHEET_IN_SELECTION = 1 << 5,
- GTK_SHEET_IN_RESIZE = 1 << 6,
- GTK_SHEET_REDRAW_PENDING = 1 << 7,
+ GTK_SHEET_REDRAW_PENDING = 1 << 0,
+ GTK_SHEET_IN_XDRAG = 1 << 1,
+ GTK_SHEET_IN_YDRAG = 1 << 2,
+ GTK_SHEET_IN_DRAG = 1 << 3,
+ GTK_SHEET_IN_SELECTION = 1 << 4,
+ GTK_SHEET_IN_RESIZE = 1 << 5
};
#define GTK_SHEET_FLAGS(sheet) (GTK_SHEET (sheet)->flags)
#define GTK_SHEET_SET_FLAGS(sheet,flag) (GTK_SHEET_FLAGS (sheet) |= (flag))
#define GTK_SHEET_UNSET_FLAGS(sheet,flag) (GTK_SHEET_FLAGS (sheet) &= ~ (flag))
-#define GTK_SHEET_IS_FROZEN(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IS_FROZEN)
#define GTK_SHEET_IN_XDRAG(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_XDRAG)
#define GTK_SHEET_IN_YDRAG(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_YDRAG)
#define GTK_SHEET_IN_DRAG(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_DRAG)
#define GTK_SHEET_REDRAW_PENDING(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_REDRAW_PENDING)
#define CELL_SPACING 1
-#define DRAG_WIDTH 6
+
#define TIMEOUT_HOVER 300
#define COLUMN_MIN_WIDTH 10
-#define CELLOFFSET 4
+#define COLUMN_TITLES_HEIGHT 4
#define DEFAULT_COLUMN_WIDTH 80
static void gtk_sheet_update_primary_selection (GtkSheet *sheet);
static void gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row);
-static gboolean gtk_sheet_cell_empty (const GtkSheet *sheet, gint row, gint col);
+static gboolean gtk_sheet_cell_empty (const GtkSheet *, gint, gint);
+
+static void destroy_hover_window (GtkSheetHoverTitle *);
+static GtkSheetHoverTitle *create_hover_window (void);
static inline void
dispose_string (const GtkSheet *sheet, gchar *text)
pango_font_metrics_unref (metrics);
- return PANGO_PIXELS (val) + 2 * CELLOFFSET;
+ return PANGO_PIXELS (val) + 2 * COLUMN_TITLES_HEIGHT;
}
}
}
-static gint
-yyy_row_is_visible (const GtkSheet *sheet, gint row)
-{
- GSheetRow *row_geo = sheet->row_geometry;
-
- return g_sheet_row_get_visibility (row_geo, row);
-}
-
-
-static gint
-yyy_row_is_sensitive (const GtkSheet *sheet, gint row)
-{
- GSheetRow *row_geo = sheet->row_geometry;
-
- return g_sheet_row_get_sensitivity (row_geo, row);
-}
-
-
-
-static inline gint
-yyy_row_count (const GtkSheet *sheet)
-{
- GSheetRow *row_geo = sheet->row_geometry;
-
- return g_sheet_row_get_row_count (row_geo);
-}
-
-static inline gint
-yyy_row_height (const GtkSheet *sheet, gint row)
-{
- GSheetRow *row_geo = sheet->row_geometry;
-
- return g_sheet_row_get_height (row_geo, row);
-}
-
-static gint
-yyy_row_top_ypixel (const GtkSheet *sheet, gint row)
-{
- GSheetRow *geo = sheet->row_geometry;
-
- gint y = g_sheet_row_start_pixel (geo, row);
-
- if ( sheet->column_titles_visible )
- y += sheet->column_title_area.height;
-
- return y;
-}
-
-
/* Return the row containing pixel Y */
static gint
yyy_row_ypixel_to_row (const GtkSheet *sheet, gint y)
{
GSheetRow *geo = sheet->row_geometry;
- gint cy = sheet->voffset;
-
- if (sheet->column_titles_visible)
- cy += sheet->column_title_area.height;
-
- if (y < cy) return 0;
-
- return g_sheet_row_pixel_to_row (geo, y - cy);
-}
-
-
-/* gives the top pixel of the given row in context of
- * the sheet's voffset */
-static inline gint
-ROW_TOP_YPIXEL (const GtkSheet *sheet, gint row)
-{
- return (sheet->voffset + yyy_row_top_ypixel (sheet, row));
-}
-
-
-/* returns the row index from a y pixel location in the
- * context of the sheet's voffset */
-static inline gint
-ROW_FROM_YPIXEL (const GtkSheet *sheet, gint y)
-{
- return (yyy_row_ypixel_to_row (sheet, y));
-}
-
-static inline GtkSheetButton *
-xxx_column_button (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
- if ( col < 0 ) return NULL ;
-
- return g_sheet_column_get_button (col_geo, col);
-}
-
-
-static inline gint
-xxx_column_left_xpixel (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *geo = sheet->column_geometry;
-
- gint x = g_sheet_column_start_pixel (geo, col);
-
- if ( sheet->row_titles_visible )
- x += sheet->row_title_area.width;
-
- return x;
-}
-
-static inline gint
-xxx_column_width (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- return g_sheet_column_get_width (col_geo, col);
-}
-
-
-static inline void
-xxx_set_column_width (GtkSheet *sheet, gint col, gint width)
-{
- if ( sheet->column_geometry )
- g_sheet_column_set_width (sheet->column_geometry, col, width);
-}
-
-static inline void
-xxx_column_set_left_column (GtkSheet *sheet, gint col, gint i)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- g_sheet_column_set_left_text_column (col_geo, col, i);
-}
-
-static inline gint
-xxx_column_left_column (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- return g_sheet_column_get_left_text_column (col_geo, col);
-}
-
-static inline void
-xxx_column_set_right_column (GtkSheet *sheet, gint col, gint i)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- g_sheet_column_set_right_text_column (col_geo, col, i);
-}
-
-static inline gint
-xxx_column_right_column (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- return g_sheet_column_get_right_text_column (col_geo, col);
-}
+ if (y < 0) return -1;
-static inline GtkJustification
-xxx_column_justification (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- return g_sheet_column_get_justification (col_geo, col);
+ return g_sheet_row_pixel_to_row (geo, y);
}
-static inline gint
-xxx_column_is_visible (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- return g_sheet_column_get_visibility (col_geo, col);
-}
+#define MIN_VISIBLE_ROW(sheet) yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value)
-static inline gint
-xxx_column_is_sensitive (const GtkSheet *sheet, gint col)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
+#define MAX_VISIBLE_ROW(sheet) \
+ yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value + sheet->vadjustment->page_size)
- return g_sheet_column_get_sensitivity (col_geo, col);
-}
+#define MIN_VISIBLE_COLUMN(sheet) COLUMN_FROM_XPIXEL (sheet, sheet->hadjustment->value)
+#define MAX_VISIBLE_COLUMN(sheet) \
+ COLUMN_FROM_XPIXEL (sheet, sheet->hadjustment->value + sheet->hadjustment->page_size)
/* gives the left pixel of the given column in context of
* the sheet's hoffset */
static inline gint
COLUMN_LEFT_XPIXEL (const GtkSheet *sheet, gint ncol)
{
- return (sheet->hoffset + xxx_column_left_xpixel (sheet, ncol));
+ return g_sheet_column_start_pixel (sheet->column_geometry, ncol);
}
-static inline gint
-xxx_column_count (const GtkSheet *sheet)
-{
- GSheetColumn *col_geo = sheet->column_geometry;
-
- return g_sheet_column_get_column_count (col_geo);
-}
-/* returns the column index from a x pixel location in the
- * context of the sheet's hoffset */
+/* returns the column index from a x pixel location */
static inline gint
-COLUMN_FROM_XPIXEL (const GtkSheet * sheet,
- gint x)
+COLUMN_FROM_XPIXEL (const GtkSheet *sheet, gint x)
{
- gint i, cx;
-
- cx = sheet->hoffset;
- if ( sheet->row_titles_visible )
- cx += sheet->row_title_area.width;
+ gint i;
+ gint cx = 0;
- if (x < cx) return 0;
- for (i = 0; i < xxx_column_count (sheet); i++)
+ if (x < 0) return -1;
+ for (i = 0;
+ i < g_sheet_column_get_column_count (sheet->column_geometry); i++)
{
- if (x >= cx && x <= (cx + xxx_column_width (sheet, i)) &&
- xxx_column_is_visible (sheet, i))
+ if (x >= cx &&
+ x <= (cx + g_sheet_column_get_width (sheet->column_geometry, i)) &&
+ g_sheet_column_get_visibility (sheet->column_geometry, i))
return i;
- if ( xxx_column_is_visible (sheet, i))
- cx += xxx_column_width (sheet, i);
+ if ( g_sheet_column_get_visibility (sheet->column_geometry, i))
+ cx += g_sheet_column_get_width (sheet->column_geometry, i);
}
/* no match */
- return xxx_column_count (sheet) - 1;
-}
-
-/* returns the total height of the sheet */
-static inline gint SHEET_HEIGHT (GtkSheet *sheet)
-{
- const gint n_rows = yyy_row_count (sheet);
-
- return yyy_row_top_ypixel (sheet, n_rows - 1) +
- yyy_row_height (sheet, n_rows - 1);
-}
-
-
-static inline GtkSheetButton *
-yyy_row_button (GtkSheet *sheet, gint row)
-{
- GSheetRow *row_geo = sheet->row_geometry;
-
- return g_sheet_row_get_button (row_geo, row);
+ return g_sheet_column_get_column_count (sheet->column_geometry) - 1;
}
+/* The size of the region (in pixels) around the row/column boundaries
+ where the height/width may be grabbed to change size */
+#define DRAG_WIDTH 6
-
-
-static inline void
-yyy_set_row_height (GtkSheet *sheet, gint row, gint height)
+static gboolean
+on_column_boundary (const GtkSheet *sheet, gint x, gint *column)
{
- if ( sheet->row_geometry )
- g_sheet_row_set_height (sheet->row_geometry, row, height);
-}
+ gint col;
+ x += sheet->hadjustment->value;
+ col = COLUMN_FROM_XPIXEL (sheet, x);
-/* returns the total width of the sheet */
-static inline gint SHEET_WIDTH (GtkSheet *sheet)
+ if ( COLUMN_FROM_XPIXEL (sheet, x - DRAG_WIDTH / 2) < col )
{
- gint i, cx;
-
- cx = ( sheet->row_titles_visible ? sheet->row_title_area.width : 0);
-
- for (i = 0; i < xxx_column_count (sheet); i++)
- if (xxx_column_is_visible (sheet, i))
- cx += xxx_column_width (sheet, i);
-
- return cx;
+ *column = col - 1;
+ return TRUE;
}
-#define MIN_VISIBLE_ROW(sheet) \
- ROW_FROM_YPIXEL (sheet, sheet->column_title_area.height + 1)
-
-#define MAX_VISIBLE_ROW(sheet) \
- ROW_FROM_YPIXEL (sheet, sheet->sheet_window_height - 1)
-
-#define MIN_VISIBLE_COLUMN(sheet) \
- COLUMN_FROM_XPIXEL (sheet, sheet->row_title_area.width + 1)
-
-#define MAX_VISIBLE_COLUMN(sheet) \
- COLUMN_FROM_XPIXEL (sheet, sheet->sheet_window_width)
-
-
-
-static inline gboolean
-POSSIBLE_XDRAG (const GtkSheet *sheet, gint x, gint *drag_column)
-{
- gint column, xdrag;
-
- column = COLUMN_FROM_XPIXEL (sheet, x);
- *drag_column = column;
-
- xdrag = COLUMN_LEFT_XPIXEL (sheet, column) + CELL_SPACING;
- if (x <= xdrag + DRAG_WIDTH / 2 && column != 0)
+ if ( COLUMN_FROM_XPIXEL (sheet, x + DRAG_WIDTH / 2) > col )
{
- while (! xxx_column_is_visible (sheet, column - 1) && column > 0) column--;
- *drag_column = column - 1;
- return xxx_column_is_sensitive (sheet, column - 1);
+ *column = col;
+ return TRUE;
}
- xdrag += xxx_column_width (sheet, column);
- if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2)
- return xxx_column_is_sensitive (sheet, column);
-
return FALSE;
}
POSSIBLE_YDRAG (const GtkSheet *sheet, gint y, gint *drag_row)
{
gint row, ydrag;
- row = ROW_FROM_YPIXEL (sheet, y);
+
+ y += sheet->vadjustment->value;
+ row = yyy_row_ypixel_to_row (sheet, y);
*drag_row = row;
- ydrag = ROW_TOP_YPIXEL (sheet, row)+CELL_SPACING;
+ ydrag = g_sheet_row_start_pixel (sheet->row_geometry, row) + CELL_SPACING;
if (y <= ydrag + DRAG_WIDTH / 2 && row != 0)
{
- while (!yyy_row_is_visible (sheet, row - 1) && row > 0) row--;
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row - 1) && row > 0) row--;
*drag_row = row - 1;
- return yyy_row_is_sensitive (sheet, row - 1);
+ return g_sheet_row_get_sensitivity (sheet->row_geometry, row - 1);
}
- ydrag +=yyy_row_height (sheet, row);
+ ydrag += g_sheet_row_get_height (sheet->row_geometry, row);
if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2)
- return yyy_row_is_sensitive (sheet, row);
-
+ return g_sheet_row_get_sensitivity (sheet->row_geometry, row);
return FALSE;
}
return FALSE;
*drag_column = COLUMN_FROM_XPIXEL (sheet, x);
- *drag_row = ROW_FROM_YPIXEL (sheet, y);
+ *drag_row = yyy_row_ypixel_to_row (sheet, y);
if (x >= COLUMN_LEFT_XPIXEL (sheet, sheet->range.col0) - DRAG_WIDTH / 2 &&
x <= COLUMN_LEFT_XPIXEL (sheet, sheet->range.coli) +
- xxx_column_width (sheet, sheet->range.coli) + DRAG_WIDTH / 2)
+ g_sheet_column_get_width (sheet->column_geometry, sheet->range.coli) + DRAG_WIDTH / 2)
{
- ydrag = ROW_TOP_YPIXEL (sheet, sheet->range.row0);
+ ydrag = g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.row0);
if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2)
{
*drag_row = sheet->range.row0;
return TRUE;
}
- ydrag = ROW_TOP_YPIXEL (sheet, sheet->range.rowi) +
- yyy_row_height (sheet, sheet->range.rowi);
+ ydrag = g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.rowi) +
+ g_sheet_row_get_height (sheet->row_geometry, sheet->range.rowi);
if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2)
{
*drag_row = sheet->range.rowi;
}
}
- if (y >= ROW_TOP_YPIXEL (sheet, sheet->range.row0) - DRAG_WIDTH / 2 &&
- y <= ROW_TOP_YPIXEL (sheet, sheet->range.rowi) +
- yyy_row_height (sheet, sheet->range.rowi) + DRAG_WIDTH / 2)
+ if (y >= g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.row0) - DRAG_WIDTH / 2 &&
+ y <= g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.rowi) +
+ g_sheet_row_get_height (sheet->row_geometry, sheet->range.rowi) + DRAG_WIDTH / 2)
{
xdrag = COLUMN_LEFT_XPIXEL (sheet, sheet->range.col0);
if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2)
return TRUE;
}
xdrag = COLUMN_LEFT_XPIXEL (sheet, sheet->range.coli) +
- xxx_column_width (sheet, sheet->range.coli);
+ g_sheet_column_get_width (sheet->column_geometry, sheet->range.coli);
if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2)
{
*drag_column = sheet->range.coli;
return FALSE;
xdrag = COLUMN_LEFT_XPIXEL (sheet, sheet->range.coli)+
- xxx_column_width (sheet, sheet->range.coli);
+ g_sheet_column_get_width (sheet->column_geometry, sheet->range.coli);
- ydrag = ROW_TOP_YPIXEL (sheet, sheet->range.rowi)+
- yyy_row_height (sheet, sheet->range.rowi);
+ ydrag = g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.rowi) +
+ g_sheet_row_get_height (sheet->row_geometry, sheet->range.rowi);
if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
- ydrag = ROW_TOP_YPIXEL (sheet, MIN_VISIBLE_ROW (sheet));
+ ydrag = g_sheet_row_start_pixel (sheet->row_geometry, MIN_VISIBLE_ROW (sheet));
if (sheet->state == GTK_SHEET_ROW_SELECTED)
xdrag = COLUMN_LEFT_XPIXEL (sheet, MIN_VISIBLE_COLUMN (sheet));
*drag_column = COLUMN_FROM_XPIXEL (sheet, x);
- *drag_row = ROW_FROM_YPIXEL (sheet, y);
+ *drag_row = yyy_row_ypixel_to_row (sheet, y);
if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2 &&
y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2) return TRUE;
GdkEventButton * event);
static gint gtk_sheet_motion (GtkWidget * widget,
GdkEventMotion * event);
+static gboolean gtk_sheet_crossing_notify (GtkWidget *widget,
+ GdkEventCrossing *event);
static gint gtk_sheet_entry_key_press (GtkWidget *widget,
GdkEventKey *key);
static gint gtk_sheet_key_press (GtkWidget *widget,
GtkSheetRange *range);
static void gtk_sheet_draw_border (GtkSheet *sheet,
GtkSheetRange range);
-static void gtk_sheet_draw_corners (GtkSheet *sheet,
- GtkSheetRange range);
-
/* Active Cell handling */
/* Backing Pixmap */
-static void gtk_sheet_make_backing_pixmap (GtkSheet *sheet,
- guint width, guint height);
+static void gtk_sheet_make_backing_pixmap (GtkSheet *sheet);
+
static void gtk_sheet_draw_backing_pixmap (GtkSheet *sheet,
GtkSheetRange range);
/* Scrollbars */
GtkRequisition *requisition);
/* Attributes routines */
-static void init_attributes (const GtkSheet *sheet, gint col,
+static void init_attributes (const GtkSheet *sheet,
+ gint col,
GtkSheetCellAttr *attributes);
gint column);
-/* Container Functions */
-static void gtk_sheet_remove (GtkContainer *container,
- GtkWidget *widget);
-static void gtk_sheet_realize_child (GtkSheet *sheet,
- GtkSheetChild *child);
-static void gtk_sheet_position_child (GtkSheet *sheet,
- GtkSheetChild *child);
-static void gtk_sheet_position_children (GtkSheet *sheet);
-static void gtk_sheet_child_show (GtkSheetChild *child);
-static void gtk_sheet_child_hide (GtkSheetChild *child);
static void gtk_sheet_column_size_request (GtkSheet *sheet,
gint col,
guint *requisition);
(GInstanceInitFunc) gtk_sheet_init,
NULL,
};
+
sheet_type =
- g_type_register_static (GTK_TYPE_CONTAINER, "GtkSheet",
+ g_type_register_static (GTK_TYPE_BIN, "GtkSheet",
&sheet_info, 0);
}
return sheet_type;
}
-static void column_titles_changed (GtkWidget *w, gint first, gint n_columns, gpointer data);
+static void column_titles_changed (GtkWidget *w, gint first, gint n_columns,
+ gpointer data);
/* Properties */
enum
GParamSpec *col_geo_spec ;
GParamSpec *model_spec ;
- GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
- GtkContainerClass *container_class = (GtkContainerClass *) klass;
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
container_class->add = NULL;
- container_class->remove = gtk_sheet_remove;
+ container_class->remove = NULL;
container_class->forall = gtk_sheet_forall;
object_class->dispose = gtk_sheet_dispose;
widget_class->button_press_event = gtk_sheet_button_press;
widget_class->button_release_event = gtk_sheet_button_release;
widget_class->motion_notify_event = gtk_sheet_motion;
+ widget_class->enter_notify_event = gtk_sheet_crossing_notify;
+ widget_class->leave_notify_event = gtk_sheet_crossing_notify;
widget_class->key_press_event = gtk_sheet_key_press;
widget_class->expose_event = gtk_sheet_expose;
widget_class->size_request = gtk_sheet_size_request;
sheet->column_geometry = NULL;
sheet->row_geometry = NULL;
- sheet->children = NULL;
-
sheet->flags = 0;
sheet->selection_mode = GTK_SELECTION_NONE;
- sheet->freeze_count = 0;
sheet->state = GTK_SHEET_NORMAL;
GTK_WIDGET_UNSET_FLAGS (sheet, GTK_NO_WINDOW);
sheet->entry_container = NULL;
sheet->button = NULL;
- sheet->hoffset = 0;
- sheet->voffset = 0;
-
sheet->hadjustment = NULL;
sheet->vadjustment = NULL;
- sheet->cursor_drag = gdk_cursor_new (GDK_PLUS);
+ sheet->cursor_drag = NULL;
+
sheet->xor_gc = NULL;
sheet->fg_gc = NULL;
sheet->bg_gc = NULL;
sheet->x_drag = 0;
sheet->y_drag = 0;
- gdk_color_parse ("white", &sheet->bg_color);
- gdk_colormap_alloc_color (gdk_colormap_get_system (), &sheet->bg_color, FALSE,
- TRUE);
- gdk_color_parse ("gray", &sheet->grid_color);
- gdk_colormap_alloc_color (gdk_colormap_get_system (), &sheet->grid_color, FALSE,
- TRUE);
-
sheet->show_grid = TRUE;
sheet->motion_timer = 0;
*/
range.col0 = first_column;
range.row0 = 0;
- range.coli = xxx_column_count (sheet) - 1;
- range.rowi = yyy_row_count (sheet) - 1;
+ range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
adjust_scrollbars (sheet);
*/
range.row0 = first_row;
range.col0 = 0;
- range.rowi = yyy_row_count (sheet) - 1;
- range.coli = xxx_column_count (sheet) - 1;
+ range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
adjust_scrollbars (sheet);
if ( n_columns == -1 )
{
extremity = TRUE;
- n_columns = xxx_column_count (sheet) - 1 ;
+ n_columns = g_sheet_column_get_column_count (sheet->column_geometry) - 1 ;
}
- if (!GTK_SHEET_IS_FROZEN (sheet))
{
gint i;
for ( i = first ; i <= first + n_columns ; ++i )
sheet->show_grid = show;
- if (!GTK_SHEET_IS_FROZEN (sheet))
gtk_sheet_range_draw (sheet, NULL);
}
else
sheet->bg_color = *color;
- if (!GTK_SHEET_IS_FROZEN (sheet))
gtk_sheet_range_draw (sheet, NULL);
}
else
sheet->grid_color = *color;
- if (!GTK_SHEET_IS_FROZEN (sheet))
gtk_sheet_range_draw (sheet, NULL);
}
g_return_val_if_fail (sheet != NULL, 0);
g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
- return xxx_column_count (sheet);
+ return g_sheet_column_get_column_count (sheet->column_geometry);
}
guint
g_return_val_if_fail (sheet != NULL, 0);
g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
- return yyy_row_count (sheet);
-}
-
-gint
-gtk_sheet_get_state (GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, 0);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
-
- return (sheet->state);
+ return g_sheet_row_get_row_count (sheet->row_geometry);
}
void
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column >= xxx_column_count (sheet) || column < 0) return;
+ if (column >= g_sheet_column_get_column_count (sheet->column_geometry) || column < 0) return;
- for (row = 0; row < yyy_row_count (sheet); row++)
+ for (row = 0; row < g_sheet_row_get_row_count (sheet->row_geometry); row++)
{
gchar *text = gtk_sheet_cell_get_text (sheet, row, column);
if (text && strlen (text) > 0)
gint width = STRING_WIDTH (GTK_WIDGET (sheet),
attributes.font_desc,
text)
- + 2 * CELLOFFSET + attributes.border.width;
+ + 2 * COLUMN_TITLES_HEIGHT + attributes.border.width;
text_width = MAX (text_width, width);
}
}
dispose_string (sheet, text);
}
- if (text_width > xxx_column_width (sheet, column) )
+ if (text_width > g_sheet_column_get_width (sheet->column_geometry, column) )
{
gtk_sheet_set_column_width (sheet, column, text_width);
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING);
}
-
-void
-gtk_sheet_freeze (GtkSheet *sheet)
-{
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- sheet->freeze_count++;
- GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IS_FROZEN);
-}
-
-void
-gtk_sheet_thaw (GtkSheet *sheet)
-{
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- if (sheet->freeze_count == 0) return;
-
- sheet->freeze_count--;
- if (sheet->freeze_count > 0) return;
-
- adjust_scrollbars (sheet);
-
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IS_FROZEN);
-
- sheet->old_vadjustment = -1.;
- sheet->old_hadjustment = -1.;
-
- if (sheet->hadjustment)
- g_signal_emit_by_name (sheet->hadjustment,
- "value_changed");
- if (sheet->vadjustment)
- g_signal_emit_by_name (sheet->vadjustment,
- "value_changed");
-
- if (sheet->state == GTK_STATE_NORMAL)
- if (sheet->entry_widget && GTK_WIDGET_MAPPED (sheet->entry_widget))
- {
- gtk_sheet_activate_cell (sheet, sheet->active_cell.row,
- sheet->active_cell.col);
- }
-
-}
-
void
gtk_sheet_set_row_titles_width (GtkSheet *sheet, guint width)
{
adjust_scrollbars (sheet);
- sheet->old_hadjustment = -1.;
if (sheet->hadjustment)
g_signal_emit_by_name (sheet->hadjustment,
"value_changed");
adjust_scrollbars (sheet);
- sheet->old_vadjustment = -1.;
if (sheet->vadjustment)
g_signal_emit_by_name (sheet->vadjustment,
"value_changed");
void
gtk_sheet_show_column_titles (GtkSheet *sheet)
{
- gint col;
-
if (sheet->column_titles_visible) return;
sheet->column_titles_visible = TRUE;
+ if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
+ return;
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- {
gdk_window_show (sheet->column_title_window);
gdk_window_move_resize (sheet->column_title_window,
sheet->column_title_area.x,
sheet->column_title_area.width,
sheet->column_title_area.height);
- for (col = MIN_VISIBLE_COLUMN (sheet);
- col <= MAX_VISIBLE_COLUMN (sheet);
- col++)
- {
- GtkSheetButton *button = xxx_column_button (sheet, col);
- GtkSheetChild *child = button->child;
- if (child)
- gtk_sheet_child_show (child);
- gtk_sheet_button_free (button);
- }
adjust_scrollbars (sheet);
- }
- sheet->old_vadjustment = -1.;
if (sheet->vadjustment)
g_signal_emit_by_name (sheet->vadjustment,
"value_changed");
void
gtk_sheet_show_row_titles (GtkSheet *sheet)
{
- gint row;
-
if (sheet->row_titles_visible) return;
sheet->row_titles_visible = TRUE;
sheet->row_title_area.width,
sheet->row_title_area.height);
- for (row = MIN_VISIBLE_ROW (sheet);
- row <= MAX_VISIBLE_ROW (sheet);
- row++)
- {
- const GtkSheetButton *button = yyy_row_button (sheet, row);
- GtkSheetChild *child = button->child;
-
- if (child)
- {
- gtk_sheet_child_show (child);
- }
- }
adjust_scrollbars (sheet);
}
- sheet->old_hadjustment = -1.;
if (sheet->hadjustment)
g_signal_emit_by_name (sheet->hadjustment,
"value_changed");
void
gtk_sheet_hide_column_titles (GtkSheet *sheet)
{
- gint col;
-
if (!sheet->column_titles_visible) return;
sheet->column_titles_visible = FALSE;
if (GTK_WIDGET_VISIBLE (sheet->button))
gtk_widget_hide (sheet->button);
- for (col = MIN_VISIBLE_COLUMN (sheet);
- col <= MAX_VISIBLE_COLUMN (sheet);
- col++)
- {
- GtkSheetButton *button = xxx_column_button (sheet, col);
- GtkSheetChild *child = button->child;
- if (child)
- gtk_sheet_child_hide (child);
- gtk_sheet_button_free (button);
- }
adjust_scrollbars (sheet);
}
- sheet->old_vadjustment = -1.;
if (sheet->vadjustment)
g_signal_emit_by_name (sheet->vadjustment,
"value_changed");
void
gtk_sheet_hide_row_titles (GtkSheet *sheet)
{
- gint row;
-
if (!sheet->row_titles_visible) return;
sheet->row_titles_visible = FALSE;
-
if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
{
if (sheet->row_title_window)
gdk_window_hide (sheet->row_title_window);
+
if (GTK_WIDGET_VISIBLE (sheet->button))
gtk_widget_hide (sheet->button);
- for (row = MIN_VISIBLE_ROW (sheet);
- row <= MAX_VISIBLE_ROW (sheet);
- row++)
- {
- const GtkSheetButton *button = yyy_row_button (sheet, row);
- GtkSheetChild *child = button->child;
- if (child)
- gtk_sheet_child_hide (child);
- }
adjust_scrollbars (sheet);
}
- sheet->old_hadjustment = -1.;
if (sheet->hadjustment)
g_signal_emit_by_name (sheet->hadjustment,
"value_changed");
}
-gboolean
-gtk_sheet_column_titles_visible (GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
- return sheet->column_titles_visible;
-}
-
-gboolean
-gtk_sheet_row_titles_visible (GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
- return sheet->row_titles_visible;
-}
void
gtk_sheet_moveto (GtkSheet *sheet,
g_return_if_fail (sheet->hadjustment != NULL);
g_return_if_fail (sheet->vadjustment != NULL);
- if (row < 0 || row >= yyy_row_count (sheet))
+ if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry))
return;
- if (column < 0 || column >= xxx_column_count (sheet))
+ if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry))
return;
height = sheet->sheet_window_height;
/* adjust vertical scrollbar */
if (row >= 0 && row_align >= 0.0)
{
- y = ROW_TOP_YPIXEL (sheet, row) - sheet->voffset
+ y = g_sheet_row_start_pixel (sheet->row_geometry, row)
- (gint) ( row_align * height + (1.0 - row_align)
- * yyy_row_height (sheet, row));
+ * g_sheet_row_get_height (sheet->row_geometry, row));
/* This forces the sheet to scroll when you don't see the entire cell */
min_row = row;
{
while (min_row >= 0 && min_row > MIN_VISIBLE_ROW (sheet))
{
- if (yyy_row_is_visible (sheet, min_row))
- adjust += yyy_row_height (sheet, min_row);
+ if (g_sheet_row_get_visibility (sheet->row_geometry, min_row))
+ adjust += g_sheet_row_get_height (sheet->row_geometry, min_row);
if (adjust >= height)
{
min_row ++;
- y = ROW_TOP_YPIXEL (sheet, min_row) - sheet->voffset +
- yyy_row_height (sheet, min_row) - 1;
+ y = g_sheet_row_start_pixel (sheet->row_geometry, min_row) +
+ g_sheet_row_get_height (sheet->row_geometry, min_row) - 1;
}
if (y < 0)
else
sheet->vadjustment->value = y;
- sheet->old_vadjustment = -1.;
g_signal_emit_by_name (sheet->vadjustment,
"value_changed");
/* adjust horizontal scrollbar */
if (column >= 0 && col_align >= 0.0)
{
- x = COLUMN_LEFT_XPIXEL (sheet, column) - sheet->hoffset
+ x = COLUMN_LEFT_XPIXEL (sheet, column)
- (gint) ( col_align*width + (1.0 - col_align)*
- xxx_column_width (sheet, column));
+ g_sheet_column_get_width (sheet->column_geometry, column));
/* This forces the sheet to scroll when you don't see the entire cell */
min_col = column;
{
while (min_col >= 0 && min_col > MIN_VISIBLE_COLUMN (sheet))
{
- if (xxx_column_is_visible (sheet, min_col))
- adjust += xxx_column_width (sheet, min_col);
+ if (g_sheet_column_get_visibility (sheet->column_geometry, min_col))
+ adjust += g_sheet_column_get_width (sheet->column_geometry, min_col);
if (adjust >= width)
{
min_col--;
}
min_col = MAX (min_col, 0);
- x = COLUMN_LEFT_XPIXEL (sheet, min_col) - sheet->hoffset +
- xxx_column_width (sheet, min_col) - 1;
+ x = COLUMN_LEFT_XPIXEL (sheet, min_col) +
+ g_sheet_column_get_width (sheet->column_geometry, min_col) - 1;
}
if (x < 0)
else
sheet->hadjustment->value = x;
- sheet->old_vadjustment = -1.;
g_signal_emit_by_name (sheet->hadjustment,
"value_changed");
}
void
-gtk_sheet_select_row (GtkSheet * sheet,
- gint row)
+gtk_sheet_select_row (GtkSheet *sheet, gint row)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (row < 0 || row >= yyy_row_count (sheet))
+ if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry))
return;
if (sheet->state != GTK_SHEET_NORMAL)
sheet->range.row0 = row;
sheet->range.col0 = 0;
sheet->range.rowi = row;
- sheet->range.coli = xxx_column_count (sheet) - 1;
+ sheet->range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
sheet->active_cell.row = row;
sheet->active_cell.col = 0;
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column < 0 || column >= xxx_column_count (sheet))
+ if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry))
return;
if (sheet->state != GTK_SHEET_NORMAL)
sheet->state = GTK_SHEET_COLUMN_SELECTED;
sheet->range.row0 = 0;
sheet->range.col0 = column;
- sheet->range.rowi = yyy_row_count (sheet) - 1;
+ sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
sheet->range.coli = column;
sheet->active_cell.row = 0;
sheet->active_cell.col = column;
{
g_return_val_if_fail (sheet != NULL, FALSE);
- if (range.row0 < 0 || range.row0 >= yyy_row_count (sheet))
+ if (range.row0 < 0 || range.row0 >= g_sheet_row_get_row_count (sheet->row_geometry))
return FALSE;
- if (range.rowi < 0 || range.rowi >= yyy_row_count (sheet))
+ if (range.rowi < 0 || range.rowi >= g_sheet_row_get_row_count (sheet->row_geometry))
return FALSE;
- if (range.col0 < 0 || range.col0 >= xxx_column_count (sheet))
+ if (range.col0 < 0 || range.col0 >= g_sheet_column_get_column_count (sheet->column_geometry))
return FALSE;
- if (range.coli < 0 || range.coli >= xxx_column_count (sheet))
+ if (range.coli < 0 || range.coli >= g_sheet_column_get_column_count (sheet->column_geometry))
return FALSE;
if (range.rowi < MIN_VISIBLE_ROW (sheet))
range->coli = MAX_VISIBLE_COLUMN (sheet);
}
-GtkAdjustment *
-gtk_sheet_get_vadjustment (GtkSheet * sheet)
+
+static void
+gtk_sheet_set_scroll_adjustments (GtkSheet *sheet,
+ GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment)
{
- g_return_val_if_fail (sheet != NULL, NULL);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
+ if ( sheet->vadjustment != vadjustment )
+{
+ if (sheet->vadjustment)
+ g_object_unref (sheet->vadjustment);
+ sheet->vadjustment = vadjustment;
+ g_object_ref (vadjustment);
- return sheet->vadjustment;
-}
+ g_signal_connect (sheet->vadjustment, "value_changed",
+ G_CALLBACK (vadjustment_value_changed),
+ sheet);
+ }
-GtkAdjustment *
-gtk_sheet_get_hadjustment (GtkSheet * sheet)
+ if ( sheet->hadjustment != hadjustment )
{
- g_return_val_if_fail (sheet != NULL, NULL);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
+ if (sheet->hadjustment)
+ g_object_unref (sheet->hadjustment);
+ sheet->hadjustment = hadjustment;
+ g_object_ref (hadjustment);
- return sheet->hadjustment;
-}
-
-void
-gtk_sheet_set_vadjustment (GtkSheet *sheet,
- GtkAdjustment *adjustment)
-{
- GtkAdjustment *old_adjustment;
-
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
- if (adjustment)
- g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
- if (sheet->vadjustment == adjustment)
- return;
-
- old_adjustment = sheet->vadjustment;
-
- if (sheet->vadjustment)
- {
- g_signal_handlers_disconnect_matched (sheet->vadjustment,
- G_SIGNAL_MATCH_DATA,
- 0, 0, 0, 0,
- sheet);
- g_object_unref (sheet->vadjustment);
- }
-
- sheet->vadjustment = adjustment;
-
- if (sheet->vadjustment)
- {
- g_object_ref (sheet->vadjustment);
- g_object_ref_sink (sheet->vadjustment);
-
- g_signal_connect (sheet->vadjustment, "value_changed",
- G_CALLBACK (vadjustment_value_changed),
- sheet);
- }
-
- if (!sheet->vadjustment || !old_adjustment)
- {
- gtk_widget_queue_resize (GTK_WIDGET (sheet));
- return;
- }
-
- sheet->old_vadjustment = sheet->vadjustment->value;
-}
-
-void
-gtk_sheet_set_hadjustment (GtkSheet *sheet,
- GtkAdjustment *adjustment)
-{
- GtkAdjustment *old_adjustment;
-
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
- if (adjustment)
- g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
- if (sheet->hadjustment == adjustment)
- return;
-
- old_adjustment = sheet->hadjustment;
-
- if (sheet->hadjustment)
- {
- g_signal_handlers_disconnect_matched (sheet->hadjustment,
- G_SIGNAL_MATCH_DATA,
- 0, 0, 0, 0,
- sheet);
- g_object_unref (sheet->hadjustment);
- }
-
- sheet->hadjustment = adjustment;
-
- if (sheet->hadjustment)
- {
- g_object_ref (sheet->hadjustment);
- g_object_ref_sink (sheet->hadjustment);
-
- g_signal_connect (sheet->hadjustment, "value_changed",
- G_CALLBACK (hadjustment_value_changed),
- sheet);
- }
-
- if (!sheet->hadjustment || !old_adjustment)
- {
- gtk_widget_queue_resize (GTK_WIDGET (sheet));
- return;
- }
-
- sheet->old_hadjustment = sheet->hadjustment->value;
-}
-
-static void
-gtk_sheet_set_scroll_adjustments (GtkSheet *sheet,
- GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment)
-{
- if (sheet->hadjustment != hadjustment)
- gtk_sheet_set_hadjustment (sheet, hadjustment);
-
- if (sheet->vadjustment != vadjustment)
- gtk_sheet_set_vadjustment (sheet, vadjustment);
+ g_signal_connect (sheet->hadjustment, "value_changed",
+ G_CALLBACK (hadjustment_value_changed),
+ sheet);
+ }
}
static void
gtk_sheet_dispose (GObject *object)
{
GtkSheet *sheet = GTK_SHEET (object);
- GList *children;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_SHEET (object));
sheet->vadjustment = NULL;
}
- children = sheet->children;
- while (children)
- {
- GtkSheetChild *child = (GtkSheetChild *)children->data;
- if (child && child->widget)
- gtk_sheet_remove (GTK_CONTAINER (sheet), child->widget);
- children = sheet->children;
- }
- sheet->children = NULL;
-
if (G_OBJECT_CLASS (parent_class)->dispose)
(*G_OBJECT_CLASS (parent_class)->dispose) (object);
}
gint attributes_mask;
GdkGCValues values, auxvalues;
GdkColormap *colormap;
- GtkSheetChild *child;
- GList *children;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SHEET (widget));
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_KEY_PRESS_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP |
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ gdk_color_parse ("white", &sheet->bg_color);
+ gdk_colormap_alloc_color (gdk_colormap_get_system (), &sheet->bg_color, FALSE,
+ TRUE);
+ gdk_color_parse ("gray", &sheet->grid_color);
+ gdk_colormap_alloc_color (gdk_colormap_get_system (), &sheet->grid_color, FALSE,
+ TRUE);
+
attributes.x = 0;
- if (sheet->row_titles_visible)
- attributes.x = sheet->row_title_area.width;
attributes.y = 0;
attributes.width = sheet->column_title_area.width;
attributes.height = sheet->column_title_area.height;
+
/* column - title window */
- sheet->column_title_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ sheet->column_title_window =
+ gdk_window_new (widget->window, &attributes, attributes_mask);
gdk_window_set_user_data (sheet->column_title_window, sheet);
- gtk_style_set_background (widget->style, sheet->column_title_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (widget->style, sheet->column_title_window,
+ GTK_STATE_NORMAL);
+
attributes.x = 0;
attributes.y = 0;
- if (sheet->column_titles_visible)
- attributes.y = sheet->column_title_area.height;
attributes.width = sheet->row_title_area.width;
attributes.height = sheet->row_title_area.height;
/* row - title window */
- sheet->row_title_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ sheet->row_title_window = gdk_window_new (widget->window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (sheet->row_title_window, sheet);
- gtk_style_set_background (widget->style, sheet->row_title_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (widget->style, sheet->row_title_window,
+ GTK_STATE_NORMAL);
/* sheet - window */
attributes.cursor = gdk_cursor_new (GDK_PLUS);
attributes.x = 0;
attributes.y = 0;
- attributes.width = sheet->sheet_window_width,
+ attributes.width = sheet->sheet_window_width;
attributes.height = sheet->sheet_window_height;
- sheet->sheet_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ sheet->sheet_window = gdk_window_new (widget->window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (sheet->sheet_window, sheet);
gdk_cursor_unref (attributes.cursor);
gdk_window_show (sheet->sheet_window);
/* backing_pixmap */
- gtk_sheet_make_backing_pixmap (sheet, 0, 0);
+ gtk_sheet_make_backing_pixmap (sheet);
/* GCs */
- if (sheet->fg_gc)
- g_object_unref (sheet->fg_gc);
- if (sheet->bg_gc)
- g_object_unref (sheet->bg_gc);
sheet->fg_gc = gdk_gc_new (widget->window);
sheet->bg_gc = gdk_gc_new (widget->window);
values.foreground = widget->style->white;
values.function = GDK_INVERT;
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
- if (sheet->xor_gc)
- g_object_unref (sheet->xor_gc);
+ values.line_width = 3;
+
sheet->xor_gc = gdk_gc_new_with_values (widget->window,
&values,
GDK_GC_FOREGROUND |
GDK_GC_FUNCTION |
- GDK_GC_SUBWINDOW);
+ GDK_GC_SUBWINDOW |
+ GDK_GC_LINE_WIDTH
+ );
gtk_widget_set_parent_window (sheet->entry_widget, sheet->sheet_window);
gtk_widget_set_parent (sheet->button, GTK_WIDGET (sheet));
- gdk_cursor_unref (sheet->cursor_drag);
sheet->cursor_drag = gdk_cursor_new (GDK_PLUS);
if (sheet->column_titles_visible)
if (sheet->row_titles_visible)
gdk_window_show (sheet->row_title_window);
+ sheet->hover_window = create_hover_window ();
+
size_allocate_row_title_buttons (sheet);
size_allocate_column_title_buttons (sheet);
- children = sheet->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- gtk_sheet_realize_child (sheet, child);
- }
-
gtk_sheet_update_primary_selection (sheet);
}
sheet = GTK_SHEET (widget);
gdk_cursor_unref (sheet->cursor_drag);
+ sheet->cursor_drag = NULL;
+
+ gdk_colormap_free_colors (gdk_colormap_get_system (),
+ &sheet->bg_color, 1);
+
+ gdk_colormap_free_colors (gdk_colormap_get_system (),
+ &sheet->grid_color, 1);
g_object_unref (sheet->xor_gc);
g_object_unref (sheet->fg_gc);
g_object_unref (sheet->bg_gc);
+ destroy_hover_window (sheet->hover_window);
+
gdk_window_destroy (sheet->sheet_window);
gdk_window_destroy (sheet->column_title_window);
gdk_window_destroy (sheet->row_title_window);
sheet->pixmap = NULL;
}
- sheet->column_title_window = NULL;
- sheet->sheet_window = NULL;
- sheet->xor_gc = NULL;
- sheet->fg_gc = NULL;
- sheet->bg_gc = NULL;
-
gtk_widget_unparent (sheet->entry_widget);
if (sheet->button != NULL)
gtk_widget_unparent (sheet->button);
gtk_sheet_map (GtkWidget * widget)
{
GtkSheet *sheet = GTK_SHEET (widget);
- GtkSheetChild *child;
- GList *children;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SHEET (widget));
gtk_sheet_activate_cell (sheet,
sheet->active_cell.row,
sheet->active_cell.col);
-
- children = sheet->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- !GTK_WIDGET_MAPPED (child->widget))
- {
- gtk_widget_map (child->widget);
- gtk_sheet_position_child (sheet, child);
- }
- }
-
}
}
static void
gtk_sheet_unmap (GtkWidget * widget)
{
- GtkSheet *sheet;
- GtkSheetChild *child;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_SHEET (widget));
+ GtkSheet *sheet = GTK_SHEET (widget);
- sheet = GTK_SHEET (widget);
+ if (!GTK_WIDGET_MAPPED (widget))
+ return;
- if (GTK_WIDGET_MAPPED (widget))
- {
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
gdk_window_hide (sheet->sheet_window);
if (GTK_WIDGET_MAPPED (sheet->button))
gtk_widget_unmap (sheet->button);
-
- children = sheet->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- GTK_WIDGET_MAPPED (child->widget))
- {
- gtk_widget_unmap (child->widget);
- }
- }
-
- }
}
static void
gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col)
{
- GtkWidget *widget;
GdkGC *fg_gc, *bg_gc;
GtkSheetCellAttr attributes;
GdkRectangle area;
/* bail now if we arn't drawable yet */
if (!GTK_WIDGET_DRAWABLE (sheet)) return;
- if (row < 0 || row >= yyy_row_count (sheet)) return;
- if (col < 0 || col >= xxx_column_count (sheet)) return;
- if (! xxx_column_is_visible (sheet, col)) return;
- if (! yyy_row_is_visible (sheet, row)) return;
-
- widget = GTK_WIDGET (sheet);
+ if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
+ if (col < 0 || col >= g_sheet_column_get_column_count (sheet->column_geometry)) return;
+ if (! g_sheet_column_get_visibility (sheet->column_geometry, col)) return;
+ if (! g_sheet_row_get_visibility (sheet->row_geometry, row)) return;
gtk_sheet_get_attributes (sheet, row, col, &attributes);
fg_gc = sheet->fg_gc;
bg_gc = sheet->bg_gc;
- area.x = COLUMN_LEFT_XPIXEL (sheet, col);
- area.y = ROW_TOP_YPIXEL (sheet, row);
- area.width= xxx_column_width (sheet, col);
- area.height = yyy_row_height (sheet, row);
+ area.x = g_sheet_column_start_pixel (sheet->column_geometry, col);
+ area.x -= sheet->hadjustment->value;
+
+ area.y = g_sheet_row_start_pixel (sheet->row_geometry, row);
+ area.y -= sheet->vadjustment->value;
- gdk_draw_rectangle (sheet->pixmap,
- bg_gc,
- TRUE,
- area.x,
- area.y,
- area.width,
- area.height);
+ area.width= g_sheet_column_get_width (sheet->column_geometry, col);
+ area.height = g_sheet_row_get_height (sheet->row_geometry, row);
gdk_gc_set_line_attributes (sheet->fg_gc, 1, 0, 0, 0);
}
}
+
static void
gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
{
if (!label)
return;
- if (row < 0 || row >= yyy_row_count (sheet)) return;
- if (col < 0 || col >= xxx_column_count (sheet)) return;
- if (! xxx_column_is_visible (sheet, col)) return;
- if (!yyy_row_is_visible (sheet, row)) return;
-
+ if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
+ if (col < 0 || col >= g_sheet_column_get_column_count (sheet->column_geometry)) return;
+ if (! g_sheet_column_get_visibility (sheet->column_geometry, col)) return;
+ if (!g_sheet_row_get_visibility (sheet->row_geometry, row)) return;
widget = GTK_WIDGET (sheet);
fg_gc = sheet->fg_gc;
bg_gc = sheet->bg_gc;
- area.x = COLUMN_LEFT_XPIXEL (sheet, col);
- area.y = ROW_TOP_YPIXEL (sheet, row);
- area.width = xxx_column_width (sheet, col);
- area.height = yyy_row_height (sheet, row);
+ area.x = g_sheet_column_start_pixel (sheet->column_geometry, col);
+ area.x -= sheet->hadjustment->value;
+
+ area.y = g_sheet_row_start_pixel (sheet->row_geometry, row);
+ area.y -= sheet->vadjustment->value;
+
+ area.width = g_sheet_column_get_width (sheet->column_geometry, col);
+ area.height = g_sheet_row_get_height (sheet->row_geometry, row);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), label);
y_pos = area.height - logical_rect.height;
if (logical_rect.height > area.height)
- y_pos = (logical_rect.height - area.height - 2 * CELLOFFSET) / 2;
+ y_pos = (logical_rect.height - area.height - 2 * COLUMN_TITLES_HEIGHT) / 2;
else if (y_pos < 0)
y_pos = 0;
else if (y_pos + logical_rect.height > area.height)
text_width = rect.width;
text_height = rect.height;
- y = area.y + y_pos - CELLOFFSET;
+ y = area.y + y_pos - COLUMN_TITLES_HEIGHT;
switch (attributes.justification)
{
for (i = col - 1; i >= MIN_VISIBLE_COLUMN (sheet); i--)
{
if ( !gtk_sheet_cell_empty (sheet, row, i)) break;
- if (size >= text_width + CELLOFFSET) break;
- size +=xxx_column_width (sheet, i);
- xxx_column_set_right_column (sheet, i,
+ if (size >= text_width + COLUMN_TITLES_HEIGHT) break;
+ size += g_sheet_column_get_width (sheet->column_geometry, i);
+ g_sheet_column_set_right_text_column (sheet->column_geometry, i,
MAX (col,
- xxx_column_right_column (sheet, i)));
+ g_sheet_column_get_right_text_column (sheet->column_geometry, i)));
}
area.width = size;
}
area.x -= size;
- xoffset += area.width - text_width - 2 * CELLOFFSET -
+ xoffset += area.width - text_width - 2 * COLUMN_TITLES_HEIGHT -
attributes.border.width / 2;
break;
case GTK_JUSTIFY_CENTER:
{
if ( ! gtk_sheet_cell_empty (sheet, row, i)) break;
if (sizer >= text_width / 2) break;
- sizer += xxx_column_width (sheet, i);
- xxx_column_set_left_column (sheet, i,
+ sizer += g_sheet_column_get_width (sheet->column_geometry, i);
+ g_sheet_column_set_left_text_column (sheet->column_geometry, i,
MIN (
col,
- xxx_column_left_column (sheet, i)));
+ g_sheet_column_get_left_text_column (sheet->column_geometry, i)));
}
for (i = col - 1; i >= MIN_VISIBLE_COLUMN (sheet); i--)
{
if ( ! gtk_sheet_cell_empty (sheet, row, i)) break;
if (sizel >= text_width / 2) break;
- sizel +=xxx_column_width (sheet, i);
- xxx_column_set_right_column (sheet, i,
+ sizel += g_sheet_column_get_width (sheet->column_geometry, i);
+ g_sheet_column_set_right_text_column (sheet->column_geometry, i,
MAX (col,
- xxx_column_right_column (sheet, i)));
+ g_sheet_column_get_right_text_column (sheet->column_geometry, i)));
}
size = MIN (sizel, sizer);
}
area.x -= sizel;
- xoffset += sizel - text_width / 2 - CELLOFFSET;
+ xoffset += sizel - text_width / 2 - COLUMN_TITLES_HEIGHT;
area.width = sizel + sizer;
break;
case GTK_JUSTIFY_LEFT:
for (i = col + 1; i <= MAX_VISIBLE_COLUMN (sheet); i++)
{
if (! gtk_sheet_cell_empty (sheet, row, i)) break;
- if (size >= text_width + CELLOFFSET) break;
- size +=xxx_column_width (sheet, i);
- xxx_column_set_left_column (sheet, i,
+ if (size >= text_width + COLUMN_TITLES_HEIGHT) break;
+ size += g_sheet_column_get_width (sheet->column_geometry, i);
+ g_sheet_column_set_left_text_column (sheet->column_geometry, i,
MIN (
col,
- xxx_column_left_column (sheet, i)));
+ g_sheet_column_get_left_text_column (sheet->column_geometry, i)));
}
area.width = size;
gdk_draw_layout (sheet->pixmap, fg_gc,
- area.x + xoffset + CELLOFFSET,
- y,
+ area.x + xoffset + COLUMN_TITLES_HEIGHT,
+ area.y,
layout);
gdk_gc_set_clip_rectangle (fg_gc, NULL);
g_object_unref (layout);
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- area.x,
- area.y,
- area.x,
- area.y,
- area.width,
- area.height);
-
}
static void
{
gint i, j;
GtkSheetRange drawing_range;
- GdkRectangle area;
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_SHEET (sheet));
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
if (!GTK_WIDGET_MAPPED (GTK_WIDGET (sheet))) return;
+ if (sheet->sheet_window_width <= 0) return;
+ if (sheet->sheet_window_height <=0) return;
+
+ if (sheet->pixmap == NULL) return ;
+
if (range == NULL)
{
drawing_range.row0 = MIN_VISIBLE_ROW (sheet);
drawing_range.col0 = MIN_VISIBLE_COLUMN (sheet);
drawing_range.rowi = MIN (MAX_VISIBLE_ROW (sheet),
- yyy_row_count (sheet) - 1);
+ g_sheet_row_get_row_count (sheet->row_geometry) - 1);
drawing_range.coli = MAX_VISIBLE_COLUMN (sheet);
-
gdk_draw_rectangle (sheet->pixmap,
GTK_WIDGET (sheet)->style->white_gc,
TRUE,
drawing_range.coli = MIN (range->coli, MAX_VISIBLE_COLUMN (sheet));
}
- if (drawing_range.coli == xxx_column_count (sheet) - 1)
- {
- area.x = COLUMN_LEFT_XPIXEL (sheet,
- xxx_column_count (sheet) - 1) +
- xxx_column_width (sheet, xxx_column_count (sheet) - 1) + 1;
-
- area.y = 0;
-
- gdk_gc_set_foreground (sheet->fg_gc, &sheet->bg_color);
-
- gdk_draw_rectangle (sheet->pixmap,
- sheet->fg_gc,
- TRUE,
- area.x, area.y,
- sheet->sheet_window_width - area.x,
- sheet->sheet_window_height);
-
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- area.x,
- area.y,
- area.x,
- area.y,
- sheet->sheet_window_width - area.x,
- sheet->sheet_window_height);
- }
-
- if (drawing_range.rowi == yyy_row_count (sheet) - 1)
- {
- area.x = 0;
- area.y = ROW_TOP_YPIXEL (sheet,
- yyy_row_count (sheet) - 1) +
- yyy_row_height (sheet, yyy_row_count (sheet) - 1) + 1;
-
- gdk_gc_set_foreground (sheet->fg_gc, &sheet->bg_color);
-
- gdk_draw_rectangle (sheet->pixmap,
- sheet->fg_gc,
- TRUE,
- area.x, area.y,
- sheet->sheet_window_width,
- sheet->sheet_window_height - area.y);
-
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- area.x,
- area.y,
- area.x,
- area.y,
- sheet->sheet_window_width,
- sheet->sheet_window_height - area.y);
- }
-
for (i = drawing_range.row0; i <= drawing_range.rowi; i++)
for (j = drawing_range.col0; j <= drawing_range.coli; j++)
{
{
if (gtk_sheet_cell_get_state (sheet, i, j) == GTK_STATE_SELECTED &&
- xxx_column_is_visible (sheet, j) && yyy_row_is_visible (sheet, i))
+ g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i))
{
-
area.x = COLUMN_LEFT_XPIXEL (sheet, j);
- area.y = ROW_TOP_YPIXEL (sheet, i);
- area.width= xxx_column_width (sheet, j);
- area.height = yyy_row_height (sheet, i);
+ if ( sheet->row_titles_visible)
+ area.x += sheet->row_title_area.width;
+
+ area.x -= sheet->hadjustment->value;
+
+ area.y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ if ( sheet->column_titles_visible)
+ area.y += sheet->column_title_area.height;
+
+ area.y -= sheet->vadjustment->value;
+
+
+ area.width= g_sheet_column_get_width (sheet->column_geometry, j);
+ area.height = g_sheet_row_get_height (sheet->row_geometry, i);
if (i == sheet->range.row0)
{
static void
gtk_sheet_draw_backing_pixmap (GtkSheet *sheet, GtkSheetRange range)
{
- gint x, y, width, height;
+ gint width, height;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
- x = COLUMN_LEFT_XPIXEL (sheet, range.col0);
- y = ROW_TOP_YPIXEL (sheet, range.row0);
- width = COLUMN_LEFT_XPIXEL (sheet, range.coli) - x +
- xxx_column_width (sheet, range.coli);
-
- height = ROW_TOP_YPIXEL (sheet, range.rowi)- y + yyy_row_height (sheet, range.rowi);
-
- if (range.row0 == sheet->range.row0)
- {
- y = y - 5;
- height = height + 5;
- }
- if (range.rowi == sheet->range.rowi) height = height + 5;
- if (range.col0 == sheet->range.col0)
- {
- x = x - 5;
- width = width + 5;
- }
- if (range.coli == sheet->range.coli) width = width + 5;
-
- width = MIN (width, sheet->sheet_window_width - x);
- height = MIN (height, sheet->sheet_window_height - y);
+ if ( sheet->pixmap == NULL) return;
- x--;
- y--;
- width +=2;
- height +=2;
-
- x = (sheet->row_titles_visible)
- ? MAX (x, sheet->row_title_area.width) : MAX (x, 0);
- y = (sheet->column_titles_visible)
- ? MAX (y, sheet->column_title_area.height) : MAX (y, 0);
-
- if (range.coli == xxx_column_count (sheet) - 1)
- width = sheet->sheet_window_width - x;
- if (range.rowi == yyy_row_count (sheet) - 1)
- height = sheet->sheet_window_height - y;
+ gdk_drawable_get_size (sheet->pixmap, &width, &height);
gdk_draw_drawable (sheet->sheet_window,
GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
sheet->pixmap,
- x,
- y,
- x,
- y,
- width + 1,
- height + 1);
+ 0, 0, /* src */
+ sheet->row_titles_visible ? sheet->row_title_area.width : 0,
+ sheet->column_titles_visible ? sheet->column_title_area.height : 0,
+ width, height);
}
+static void gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col,
+ GtkJustification justification,
+ const gchar *text);
-void
-gtk_sheet_set_cell_text (GtkSheet *sheet, gint row, gint col, const gchar *text)
-{
- GtkSheetCellAttr attributes;
-
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
- if (col >= xxx_column_count (sheet) || row >= yyy_row_count (sheet)) return;
- if (col < 0 || row < 0) return;
-
- gtk_sheet_get_attributes (sheet, row, col, &attributes);
- gtk_sheet_set_cell (sheet, row, col, attributes.justification, text);
-}
static inline gint
safe_strcmp (const gchar *s1, const gchar *s2)
return strcmp (s1, s2);
}
-void
+static void
gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col,
GtkJustification justification,
const gchar *text)
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (col >= xxx_column_count (sheet) || row >= yyy_row_count (sheet)) return;
+ if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
if (col < 0 || row < 0) return;
gtk_sheet_get_attributes (sheet, row, col, &attributes);
range.coli = MAX_VISIBLE_COLUMN (sheet);
if (gtk_sheet_autoresize (sheet) &&
- text_width > xxx_column_width (sheet, col) -
- 2 * CELLOFFSET- attributes.border.width)
+ text_width > g_sheet_column_get_width (sheet->column_geometry, col) -
+ 2 * COLUMN_TITLES_HEIGHT- attributes.border.width)
{
- gtk_sheet_set_column_width (sheet, col, text_width + 2 * CELLOFFSET
+ gtk_sheet_set_column_width (sheet, col, text_width + 2 * COLUMN_TITLES_HEIGHT
+ attributes.border.width);
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING);
}
else
- if (!GTK_SHEET_IS_FROZEN (sheet))
gtk_sheet_range_draw (sheet, &range);
}
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column >= xxx_column_count (sheet) ||
- row >= yyy_row_count (sheet)) return;
+ if (column >= g_sheet_column_get_column_count (sheet->column_geometry) ||
+ row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
if (column < 0 || row < 0) return;
gtk_sheet_real_cell_clear (sheet, row, column);
- if (!GTK_SHEET_IS_FROZEN (sheet))
- {
gtk_sheet_range_draw (sheet, &range);
}
-}
static void
gtk_sheet_real_cell_clear (GtkSheet *sheet, gint row, gint column)
if (!range)
{
clear.row0 = 0;
- clear.rowi = yyy_row_count (sheet) - 1;
+ clear.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
clear.col0 = 0;
- clear.coli = xxx_column_count (sheet) - 1;
+ clear.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
}
else
clear=*range;
clear.row0 = MAX (clear.row0, 0);
clear.col0 = MAX (clear.col0, 0);
- clear.rowi = MIN (clear.rowi, yyy_row_count (sheet) - 1 );
- clear.coli = MIN (clear.coli, xxx_column_count (sheet) - 1 );
+ clear.rowi = MIN (clear.rowi, g_sheet_row_get_row_count (sheet->row_geometry) - 1 );
+ clear.coli = MIN (clear.coli, g_sheet_column_get_column_count (sheet->column_geometry) - 1 );
for (i = clear.row0; i <= clear.rowi; i++)
for (j = clear.col0; j <= clear.coli; j++)
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
- if (col >= xxx_column_count (sheet) || row >= yyy_row_count (sheet))
+ if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry))
return NULL;
if (col < 0 || row < 0) return NULL;
g_return_val_if_fail (sheet != NULL, 0);
g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
- if (col >= xxx_column_count (sheet) || row >= yyy_row_count (sheet)) return 0;
+ if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return 0;
if (col < 0 || row < 0) return 0;
state = sheet->state;
return GTK_STATE_NORMAL;
}
-/* Convert X, Y (in pixels) to *ROW, *COLUMN (in cell coords)
- -1 indicates the title buttons.
+/* Convert X, Y (in pixels) to *ROW, *COLUMN
If the function returns FALSE, then the results will be unreliable.
*/
-gboolean
+static gboolean
gtk_sheet_get_pixel_info (GtkSheet *sheet,
gint x,
gint y,
if (x < 0)
return FALSE;
- if ( y < sheet->column_title_area.height + sheet->column_title_area.y)
- *row = -1;
+ if ( sheet->column_titles_visible)
+ y -= sheet->column_title_area.height;
- else
- {
- trow = ROW_FROM_YPIXEL (sheet, y);
- if (trow > yyy_row_count (sheet))
+ y += sheet->vadjustment->value;
+
+ trow = yyy_row_ypixel_to_row (sheet, y);
+ if (trow > g_sheet_row_get_row_count (sheet->row_geometry))
return FALSE;
*row = trow;
- }
- if ( x < sheet->row_title_area.width + sheet->row_title_area.x)
- *column = -1;
- else
- {
+ if ( sheet->row_titles_visible)
+ x -= sheet->row_title_area.width;
+
+ x += sheet->hadjustment->value;
+
tcol = COLUMN_FROM_XPIXEL (sheet, x);
- if (tcol > xxx_column_count (sheet))
+ if (tcol > g_sheet_column_get_column_count (sheet->column_geometry))
return FALSE;
*column = tcol;
- }
return TRUE;
}
g_return_val_if_fail (sheet != NULL, 0);
g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
- if (row >= yyy_row_count (sheet) || column >= xxx_column_count (sheet))
+ if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= g_sheet_column_get_column_count (sheet->column_geometry))
return FALSE;
- area->x = (column == -1) ? 0 : (COLUMN_LEFT_XPIXEL (sheet, column) -
- (sheet->row_titles_visible
- ? sheet->row_title_area.width
- : 0));
- area->y = (row == -1) ? 0 : (ROW_TOP_YPIXEL (sheet, row) -
- (sheet->column_titles_visible
- ? sheet->column_title_area.height
- : 0));
+ area->x = (column == -1) ? 0 : COLUMN_LEFT_XPIXEL (sheet, column);
+ area->y = (row == -1) ? 0 : g_sheet_row_start_pixel (sheet->row_geometry, row);
+
area->width= (column == -1) ? sheet->row_title_area.width
- : xxx_column_width (sheet, column);
+ : g_sheet_column_get_width (sheet->column_geometry, column);
area->height= (row == -1) ? sheet->column_title_area.height
- : yyy_row_height (sheet, row);
+ : g_sheet_row_get_height (sheet->row_geometry, row);
return TRUE;
}
g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
if (row < - 1 || column < - 1) return FALSE;
- if (row >= yyy_row_count (sheet) || column >= xxx_column_count (sheet))
+ if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= g_sheet_column_get_column_count (sheet->column_geometry))
return FALSE;
if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)));
- GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IS_FROZEN);
-
if (text && strlen (text) > 0)
{
gtk_sheet_get_attributes (sheet, row, col, &attributes);
gtk_sheet_set_cell (sheet, row, col, justification, text);
}
- if (sheet->freeze_count == 0)
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IS_FROZEN);
-
sheet->active_cell.row = row;;
sheet->active_cell.col = col;
}
if (row < 0 || col < 0) return;
- if (sheet->freeze_count == 0)
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IS_FROZEN);
-
text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)));
gtk_sheet_get_attributes (sheet, row, col, &attributes);
gtk_widget_hide (sheet->entry_widget);
gtk_widget_unmap (sheet->entry_widget);
- if (row != -1 && col != -1)
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- COLUMN_LEFT_XPIXEL (sheet, col)- 1,
- ROW_TOP_YPIXEL (sheet, row)- 1,
- COLUMN_LEFT_XPIXEL (sheet, col)- 1,
- ROW_TOP_YPIXEL (sheet, row)- 1,
- xxx_column_width (sheet, col) + 4,
- yyy_row_height (sheet, row)+4);
-
gtk_widget_grab_focus (GTK_WIDGET (sheet));
GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (sheet->entry_widget), GTK_VISIBLE);
-
}
static gboolean
if (row < 0 || col < 0) return FALSE;
- if ( row > yyy_row_count (sheet) || col > xxx_column_count (sheet))
+ if ( row > g_sheet_row_get_row_count (sheet->row_geometry) || col > g_sheet_column_get_column_count (sheet->column_geometry))
return FALSE;
if (!veto) return FALSE;
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
+
+
gtk_sheet_show_active_cell (sheet);
g_signal_connect (gtk_sheet_get_entry (sheet),
}
+
static void
-gtk_sheet_make_backing_pixmap (GtkSheet *sheet, guint width, guint height)
+gtk_sheet_make_backing_pixmap (GtkSheet *sheet)
{
gint pixmap_width, pixmap_height;
+ gint width, height;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
- if (width == 0 && height == 0)
- {
- width = sheet->sheet_window_width + 80;
- height = sheet->sheet_window_height + 80;
- }
+ width = sheet->sheet_window_width ;
+ height = sheet->sheet_window_height ;
+
+
+ if ( width <= 0) return;
+ if ( height <= 0) return;
if (!sheet->pixmap)
{
sheet->pixmap = gdk_pixmap_new (sheet->sheet_window,
width, height,
- 1);
- if (!GTK_SHEET_IS_FROZEN (sheet)) gtk_sheet_range_draw (sheet, NULL);
+
+ gtk_sheet_range_draw (sheet, NULL);
}
else
{
sheet->pixmap = gdk_pixmap_new (sheet->sheet_window,
width, height,
- 1);
- if (!GTK_SHEET_IS_FROZEN (sheet)) gtk_sheet_range_draw (sheet, NULL);
+ gtk_sheet_range_draw (sheet, NULL);
}
}
}
j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE;
if (state == GTK_STATE_SELECTED && selected &&
- xxx_column_is_visible (sheet, j) && yyy_row_is_visible (sheet, i) &&
+ g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i) &&
(i == sheet->range.row0 || i == sheet->range.rowi ||
j == sheet->range.col0 || j == sheet->range.coli ||
i == new_range.row0 || i == new_range.rowi ||
if (mask1 != mask2)
{
x = COLUMN_LEFT_XPIXEL (sheet, j);
- y = ROW_TOP_YPIXEL (sheet, i);
+ y = g_sheet_row_start_pixel (sheet->row_geometry, i);
width = COLUMN_LEFT_XPIXEL (sheet, j)- x+
- xxx_column_width (sheet, j);
- height = ROW_TOP_YPIXEL (sheet, i)- y + yyy_row_height (sheet, i);
+ g_sheet_column_get_width (sheet->column_geometry, j);
+ height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == sheet->range.row0)
{
}
if (j == sheet->range.coli) width = width + 3;
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- x + 1,
- y + 1,
- x + 1,
- y + 1,
- width,
- height);
-
if (i != sheet->active_cell.row || j != sheet->active_cell.col)
{
x = COLUMN_LEFT_XPIXEL (sheet, j);
- y = ROW_TOP_YPIXEL (sheet, i);
+ y = g_sheet_row_start_pixel (sheet->row_geometry, i);
width = COLUMN_LEFT_XPIXEL (sheet, j)- x+
- xxx_column_width (sheet, j);
+ g_sheet_column_get_width (sheet->column_geometry, j);
- height = ROW_TOP_YPIXEL (sheet, i)- y + yyy_row_height (sheet, i);
+ height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == new_range.row0)
{
j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE;
if (state == GTK_STATE_SELECTED && !selected &&
- xxx_column_is_visible (sheet, j) && yyy_row_is_visible (sheet, i))
+ g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i))
{
x = COLUMN_LEFT_XPIXEL (sheet, j);
- y = ROW_TOP_YPIXEL (sheet, i);
- width = COLUMN_LEFT_XPIXEL (sheet, j)- x+ xxx_column_width (sheet, j);
- height = ROW_TOP_YPIXEL (sheet, i)- y + yyy_row_height (sheet, i);
+ y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ width = COLUMN_LEFT_XPIXEL (sheet, j) - x + g_sheet_column_get_width (sheet->column_geometry, j);
+ height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == sheet->range.row0)
{
}
if (j == sheet->range.coli) width = width + 3;
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- x + 1,
- y + 1,
- x + 1,
- y + 1,
- width,
- height);
}
}
}
j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE;
if (state != GTK_STATE_SELECTED && selected &&
- xxx_column_is_visible (sheet, j) && yyy_row_is_visible (sheet, i) &&
+ g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i) &&
(i != sheet->active_cell.row || j != sheet->active_cell.col))
{
x = COLUMN_LEFT_XPIXEL (sheet, j);
- y = ROW_TOP_YPIXEL (sheet, i);
- width = COLUMN_LEFT_XPIXEL (sheet, j)- x+ xxx_column_width (sheet, j);
- height = ROW_TOP_YPIXEL (sheet, i)- y + yyy_row_height (sheet, i);
+ y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ width = COLUMN_LEFT_XPIXEL (sheet, j) - x + g_sheet_column_get_width (sheet->column_geometry, j);
+ height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == new_range.row0)
{
for (j = aux_range.col0; j <= aux_range.coli; j++)
{
- if (xxx_column_is_visible (sheet, j) && yyy_row_is_visible (sheet, i))
+ if (g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i))
{
state = gtk_sheet_cell_get_state (sheet, i, j);
if (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED))
{
x = COLUMN_LEFT_XPIXEL (sheet, j);
- y = ROW_TOP_YPIXEL (sheet, i);
- width = xxx_column_width (sheet, j);
- height = yyy_row_height (sheet, i);
+ y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ width = g_sheet_column_get_width (sheet->column_geometry, j);
+ height = g_sheet_row_get_height (sheet->row_geometry, i);
if (mask2 & 1)
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
*range = new_range;
- gtk_sheet_draw_corners (sheet, new_range);
-
}
static void
gtk_sheet_draw_border (GtkSheet *sheet, GtkSheetRange new_range)
{
- GtkWidget *widget;
GdkRectangle area;
- gint i;
- gint x, y, width, height;
+ gint width, height;
- widget = GTK_WIDGET (sheet);
+ gint x = COLUMN_LEFT_XPIXEL (sheet, new_range.col0);
+ gint y = g_sheet_row_start_pixel (sheet->row_geometry, new_range.row0);
+
+ if ( sheet->row_titles_visible)
+ x += sheet->row_title_area.width;
+
+ x -= sheet->hadjustment->value;
+
+ if ( sheet->column_titles_visible)
+ y += sheet->column_title_area.height;
+
+ y -= sheet->vadjustment->value;
- x = COLUMN_LEFT_XPIXEL (sheet, new_range.col0);
- y = ROW_TOP_YPIXEL (sheet, new_range.row0);
- width = COLUMN_LEFT_XPIXEL (sheet, new_range.coli) - x +
- xxx_column_width (sheet, new_range.coli);
+ width = COLUMN_LEFT_XPIXEL (sheet, new_range.coli) -
+ COLUMN_LEFT_XPIXEL (sheet, new_range.col0)
+ +
+ g_sheet_column_get_width (sheet->column_geometry, new_range.coli);
- height = ROW_TOP_YPIXEL (sheet, new_range.rowi) - y +
- yyy_row_height (sheet, new_range.rowi);
+ height = g_sheet_row_start_pixel (sheet->row_geometry, new_range.rowi) -
+ g_sheet_row_start_pixel (sheet->row_geometry, new_range.row0)
+ +
+ g_sheet_row_get_height (sheet->row_geometry, new_range.rowi);
area.x = COLUMN_LEFT_XPIXEL (sheet, MIN_VISIBLE_COLUMN (sheet));
- area.y = ROW_TOP_YPIXEL (sheet, MIN_VISIBLE_ROW (sheet));
+ if ( sheet->row_titles_visible)
+ area.x += sheet->row_title_area.width;
+
+ area.x -= sheet->hadjustment->value;
+
+ area.y = g_sheet_row_start_pixel (sheet->row_geometry, MIN_VISIBLE_ROW (sheet));
+ if ( sheet->column_titles_visible)
+ area.y += sheet->column_title_area.height;
+
+ area.y -= sheet->vadjustment->value;
+
+
area.width = sheet->sheet_window_width;
area.height = sheet->sheet_window_height;
- if (x < 0)
- {
- width = width + x;
- x = 0;
- }
- if (width > area.width) width = area.width + 10;
- if (y < 0)
- {
- height = height + y;
- y = 0;
- }
- if (height > area.height) height = area.height + 10;
-
gdk_gc_set_clip_rectangle (sheet->xor_gc, &area);
- for (i = -1; i <= 1; ++i)
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
- FALSE,
- x + i,
- y + i,
- width - 2 * i,
- height - 2 * i);
+ gdk_draw_rectangle (sheet->sheet_window,
+ sheet->xor_gc,
+ FALSE,
+ x, y,
+ width - 2,
+ height - 2);
gdk_gc_set_clip_rectangle (sheet->xor_gc, NULL);
-
-
- gtk_sheet_draw_corners (sheet, new_range);
}
+
static void
-gtk_sheet_draw_corners (GtkSheet *sheet, GtkSheetRange range)
-{
- gint x, y;
- guint width = 1;
-
- if (gtk_sheet_cell_isvisible (sheet, range.row0, range.col0))
- {
- x = COLUMN_LEFT_XPIXEL (sheet, range.col0);
- y = ROW_TOP_YPIXEL (sheet, range.row0);
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- x - 1,
- y - 1,
- x - 1,
- y - 1,
- 3,
- 3);
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
- TRUE,
- x - 1, y - 1,
- 3, 3);
- }
-
- if (gtk_sheet_cell_isvisible (sheet, range.row0, range.coli) ||
- sheet->state == GTK_SHEET_COLUMN_SELECTED)
- {
- x = COLUMN_LEFT_XPIXEL (sheet, range.coli)+
- xxx_column_width (sheet, range.coli);
- y = ROW_TOP_YPIXEL (sheet, range.row0);
- width = 1;
- if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
- {
- y = ROW_TOP_YPIXEL (sheet, MIN_VISIBLE_ROW (sheet))+3;
- width = 3;
- }
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- x - width,
- y - width,
- x - width,
- y - width,
- 2 * width + 1,
- 2 * width + 1);
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
- TRUE,
- x - width + width / 2, y - width + width / 2,
- 2 + width, 2 + width);
- }
-
- if (gtk_sheet_cell_isvisible (sheet, range.rowi, range.col0) ||
- sheet->state == GTK_SHEET_ROW_SELECTED)
- {
- x = COLUMN_LEFT_XPIXEL (sheet, range.col0);
- y = ROW_TOP_YPIXEL (sheet, range.rowi)+
- yyy_row_height (sheet, range.rowi);
- width = 1;
- if (sheet->state == GTK_SHEET_ROW_SELECTED)
- {
- x = COLUMN_LEFT_XPIXEL (sheet, MIN_VISIBLE_COLUMN (sheet))+3;
- width = 3;
- }
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- x - width,
- y - width,
- x - width,
- y - width,
- 2 * width + 1,
- 2 * width + 1);
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
- TRUE,
- x - width + width / 2, y - width + width / 2,
- 2 + width, 2 + width);
- }
-
- if (gtk_sheet_cell_isvisible (sheet, range.rowi, range.coli))
- {
- x = COLUMN_LEFT_XPIXEL (sheet, range.coli)+
- xxx_column_width (sheet, range.coli);
- y = ROW_TOP_YPIXEL (sheet, range.rowi)+
- yyy_row_height (sheet, range.rowi);
- width = 1;
- if (sheet->state == GTK_SHEET_RANGE_SELECTED) width = 3;
- if (sheet->state == GTK_SHEET_NORMAL) width = 3;
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- x - width,
- y - width,
- x - width,
- y - width,
- 2 * width + 1,
- 2 * width + 1);
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
- TRUE,
- x - width + width / 2, y - width + width / 2,
- 2 + width, 2 + width);
-
- }
-
-}
-
-
-static void
-gtk_sheet_real_select_range (GtkSheet * sheet,
- const GtkSheetRange * range)
+gtk_sheet_real_select_range (GtkSheet * sheet,
+ const GtkSheetRange * range)
{
gint state;
void
-gtk_sheet_get_selected_range (GtkSheet *sheet,
- GtkSheetRange *range)
+gtk_sheet_get_selected_range (GtkSheet *sheet, GtkSheetRange *range)
{
g_return_if_fail (sheet != NULL);
*range = sheet->range;
sheet->state = GTK_SHEET_RANGE_SELECTED;
gtk_sheet_real_select_range (sheet, NULL);
-
}
void
sheet->range.rowi = -1;
sheet->range.col0 = -1;
sheet->range.coli = -1;
-
- gtk_sheet_position_children (sheet);
}
g_return_val_if_fail (GTK_IS_SHEET (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
+ g_print ("%s %p\n", __FUNCTION__, widget);
sheet = GTK_SHEET (widget);
if (GTK_WIDGET_DRAWABLE (widget))
{
- range.row0 = ROW_FROM_YPIXEL (sheet, event->area.y);
+ range.row0 = yyy_row_ypixel_to_row (sheet, event->area.y);
range.col0 = COLUMN_FROM_XPIXEL (sheet, event->area.x);
- range.rowi = ROW_FROM_YPIXEL (sheet, event->area.y + event->area.height);
- range.coli = COLUMN_FROM_XPIXEL (sheet, event->area.x + event->area.width);
+ range.rowi = yyy_row_ypixel_to_row (sheet,
+ event->area.y + event->area.height);
+
+ range.coli = COLUMN_FROM_XPIXEL (sheet,
+ event->area.x + event->area.width);
+
+ g_print ("Redrawing rows %d--%d, columns %d--%d\n",
+ range.row0, range.rowi, range.col0, range.coli);
+
/* exposure events on the sheet */
if (event->window == sheet->row_title_window &&
sheet->column_titles_visible)
{
gint i;
- for (i = MIN_VISIBLE_COLUMN (sheet); i <= MAX_VISIBLE_COLUMN (sheet); i++)
+ for (i = MIN_VISIBLE_COLUMN (sheet);
+ i <= MAX_VISIBLE_COLUMN (sheet);
+ ++i)
gtk_sheet_column_title_button_draw (sheet, i);
}
if (event->window == sheet->column_title_window &&
gtk_sheet_columns_resizable (sheet))
{
+#if 0
gtk_widget_get_pointer (widget, &sheet->x_drag, NULL);
- if (POSSIBLE_XDRAG (sheet, sheet->x_drag, &sheet->drag_cell.col))
+ if ( sheet->row_titles_visible)
+ sheet->x_drag -= sheet->row_title_area.width;
+#endif
+
+ sheet->x_drag = event->x;
+
+ if (on_column_boundary (sheet, sheet->x_drag, &sheet->drag_cell.col))
{
guint req;
if (event->type == GDK_2BUTTON_PRESS)
if (event->window == sheet->column_title_window)
{
gtk_widget_get_pointer (widget, &x, &y);
+ if ( sheet->row_titles_visible)
+ x -= sheet->row_title_area.width;
+
+ x += sheet->hadjustment->value;
+
column = COLUMN_FROM_XPIXEL (sheet, x);
- if (xxx_column_is_sensitive (sheet, column))
+ if (g_sheet_column_get_sensitivity (sheet->column_geometry, column))
{
gtk_sheet_click_cell (sheet, - 1, column, &veto);
gtk_grab_add (GTK_WIDGET (sheet));
if (event->window == sheet->row_title_window)
{
gtk_widget_get_pointer (widget, &x, &y);
- row = ROW_FROM_YPIXEL (sheet, y);
- if (yyy_row_is_sensitive (sheet, row))
+ if ( sheet->column_titles_visible)
+ y -= sheet->column_title_area.height;
+
+ y += sheet->vadjustment->value;
+
+ row = yyy_row_ypixel_to_row (sheet, y);
+ if (g_sheet_row_get_sensitivity (sheet->row_geometry, row))
{
gtk_sheet_click_cell (sheet, row, - 1, &veto);
gtk_grab_add (GTK_WIDGET (sheet));
{
*veto = TRUE;
- if (row >= yyy_row_count (sheet) || column >= xxx_column_count (sheet))
+ if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= g_sheet_column_get_column_count (sheet->column_geometry))
{
*veto = FALSE;
return;
}
if (column >= 0 && row >= 0)
- if (! xxx_column_is_visible (sheet, column) || !yyy_row_is_visible (sheet, row))
+ {
+ if (! g_sheet_column_get_visibility (sheet->column_geometry, column)
+ || !g_sheet_row_get_visibility (sheet->row_geometry, row))
{
*veto = FALSE;
return;
}
+ }
_gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals[TRAVERSE],
sheet->active_cell.row, sheet->active_cell.col,
{
sheet->range.row0 = 0;
sheet->range.col0 = 0;
- sheet->range.rowi = yyy_row_count (sheet) - 1;
- sheet->range.coli = xxx_column_count (sheet) - 1;
+ sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ sheet->range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
sheet->active_cell.row = 0;
sheet->active_cell.col = 0;
gtk_sheet_select_range (sheet, NULL);
gtk_sheet_button_release (GtkWidget * widget,
GdkEventButton * event)
{
- GtkSheet *sheet;
- gint x, y;
+ gint y;
- sheet = GTK_SHEET (widget);
+ GtkSheet *sheet = GTK_SHEET (widget);
/* release on resize windows */
if (GTK_SHEET_IN_XDRAG (sheet))
{
+ gint xpos = event->x;
+ gint width;
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_XDRAG);
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
- gtk_widget_get_pointer (widget, &x, NULL);
+
gdk_pointer_ungrab (event->time);
draw_xor_vline (sheet);
- gtk_sheet_set_column_width (sheet, sheet->drag_cell.col,
- new_column_width (sheet, sheet->drag_cell.col, &x));
- sheet->old_hadjustment = -1.;
- g_signal_emit_by_name (sheet->hadjustment, "value_changed");
+ width = new_column_width (sheet, sheet->drag_cell.col, &xpos);
+
+ gtk_sheet_set_column_width (sheet, sheet->drag_cell.col, width);
return TRUE;
}
gdk_pointer_ungrab (event->time);
draw_xor_hline (sheet);
- gtk_sheet_set_row_height (sheet, sheet->drag_cell.row, new_row_height (sheet, sheet->drag_cell.row, &y));
- sheet->old_vadjustment = -1.;
+ gtk_sheet_set_row_height (sheet, sheet->drag_cell.row,
+ new_row_height (sheet, sheet->drag_cell.row, &y));
g_signal_emit_by_name (sheet->vadjustment, "value_changed");
return TRUE;
}
return TRUE;
}
+\f
+
+
/* Shamelessly lifted from gtktooltips */
static gboolean
gtk_sheet_subtitle_paint_window (GtkWidget *tip_window)
return FALSE;
}
+static void
+destroy_hover_window (GtkSheetHoverTitle *h)
+{
+ gtk_widget_destroy (h->window);
+ g_free (h);
+}
+
static GtkSheetHoverTitle *
create_hover_window (void)
{
- GtkSheetHoverTitle *hw = malloc (sizeof (*hw));
+ GtkSheetHoverTitle *hw = g_malloc (sizeof (*hw));
hw->window = gtk_window_new (GTK_WINDOW_POPUP);
if ( ! subtitle )
return;
- if ( ! sheet->hover_window)
- {
- sheet->hover_window = create_hover_window ();
- gtk_widget_add_events (GTK_WIDGET (sheet), GDK_LEAVE_NOTIFY_MASK);
-
- g_signal_connect_swapped (sheet, "leave-notify-event",
- G_CALLBACK (gtk_widget_hide),
- sheet->hover_window->window);
- }
-
gtk_label_set_text (GTK_LABEL (sheet->hover_window->label),
subtitle);
if ( gtk_sheet_get_pixel_info (sheet, x, y, &row, &column) )
{
- if ( column == -1 && row == -1 )
- return FALSE;
-
- if ( column == -1)
+ if (sheet->row_title_under)
{
GSheetRow *row_geo = sheet->row_geometry;
gchar *text;
text = g_sheet_row_get_subtitle (row_geo, row);
- show_subtitle (sheet, row, column, text);
+ show_subtitle (sheet, row, -1, text);
g_free (text);
}
- if ( row == -1)
+ if (sheet->column_title_under)
{
GSheetColumn *col_geo = sheet->column_geometry;
gchar *text;
text = g_sheet_column_get_subtitle (col_geo, column);
- show_subtitle (sheet, row, column, text );
+ show_subtitle (sheet, -1, column, text );
g_free (text);
}
return FALSE;
}
-static gint
-gtk_sheet_motion (GtkWidget * widget,
- GdkEventMotion * event)
+static gboolean
+gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event)
{
GtkSheet *sheet;
GdkModifierType mods;
x = event->x;
y = event->y;
- if (!sheet->hover_window || ! GTK_WIDGET_VISIBLE (sheet->hover_window->window))
+ if (!GTK_WIDGET_VISIBLE (sheet->hover_window->window))
{
if ( sheet->motion_timer > 0 )
g_source_remove (sheet->motion_timer);
- sheet->motion_timer = g_timeout_add (TIMEOUT_HOVER, motion_timeout_callback, sheet);
+ sheet->motion_timer =
+ g_timeout_add (TIMEOUT_HOVER, motion_timeout_callback, sheet);
}
else
{
if (event->window == sheet->column_title_window &&
gtk_sheet_columns_resizable (sheet))
{
- gtk_widget_get_pointer (widget, &x, &y);
if (!GTK_SHEET_IN_SELECTION (sheet) &&
- POSSIBLE_XDRAG (sheet, x, &column))
+ on_column_boundary (sheet, x, &column))
{
new_cursor = GDK_SB_H_DOUBLE_ARROW;
if (new_cursor != sheet->cursor_drag->type)
if (event->window == sheet->row_title_window &&
gtk_sheet_rows_resizable (sheet))
{
- gtk_widget_get_pointer (widget, &x, &y);
if (!GTK_SHEET_IN_SELECTION (sheet) && POSSIBLE_YDRAG (sheet, y, &column))
{
new_cursor = GDK_SB_V_DOUBLE_ARROW;
new_cursor = GDK_TOP_LEFT_ARROW;
if ( event->window == sheet->sheet_window &&
- ! (POSSIBLE_RESIZE (sheet, x, y, &row, &column) || GTK_SHEET_IN_RESIZE (sheet)) && (POSSIBLE_DRAG (sheet, x, y, &row, &column) || GTK_SHEET_IN_DRAG (sheet)) &&
-
+ ! (POSSIBLE_RESIZE (sheet, x, y, &row, &column) ||
+ GTK_SHEET_IN_RESIZE (sheet)) &&
+ (POSSIBLE_DRAG (sheet, x, y, &row, &column) ||
+ GTK_SHEET_IN_DRAG (sheet)) &&
new_cursor != sheet->cursor_drag->type)
{
gdk_cursor_unref (sheet->cursor_drag);
if (GTK_SHEET_IN_XDRAG (sheet))
{
- if (event->is_hint || event->window != widget->window)
- gtk_widget_get_pointer (widget, &x, NULL);
- else
x = event->x;
new_column_width (sheet, sheet->drag_cell.col, &x);
+#if 0
if (x != sheet->x_drag)
{
draw_xor_vline (sheet);
sheet->x_drag = x;
draw_xor_vline (sheet);
}
+#endif
return TRUE;
}
{
GtkSheetRange aux;
column = COLUMN_FROM_XPIXEL (sheet, x)- sheet->drag_cell.col;
- row = ROW_FROM_YPIXEL (sheet, y)- sheet->drag_cell.row;
+ row = yyy_row_ypixel_to_row (sheet, y) - sheet->drag_cell.row;
if (sheet->state == GTK_SHEET_COLUMN_SELECTED) row = 0;
if (sheet->state == GTK_SHEET_ROW_SELECTED) column = 0;
sheet->x_drag = x;
sheet->y_drag = y;
aux = sheet->range;
- if (aux.row0 + row >= 0 && aux.rowi + row < yyy_row_count (sheet) &&
- aux.col0 + column >= 0 && aux.coli + column < xxx_column_count (sheet))
+ if (aux.row0 + row >= 0 && aux.rowi + row < g_sheet_row_get_row_count (sheet->row_geometry) &&
+ aux.col0 + column >= 0 && aux.coli + column < g_sheet_column_get_column_count (sheet->column_geometry))
{
aux = sheet->drag_range;
sheet->drag_range.row0 = sheet->range.row0 + row;
GtkSheetRange aux;
gint v_h, current_col, current_row, col_threshold, row_threshold;
v_h = 1;
-
if (abs (x - COLUMN_LEFT_XPIXEL (sheet, sheet->drag_cell.col)) >
- abs (y - ROW_TOP_YPIXEL (sheet, sheet->drag_cell.row))) v_h = 2;
+ abs (y - g_sheet_row_start_pixel (sheet->row_geometry, sheet->drag_cell.row))) v_h = 2;
current_col = COLUMN_FROM_XPIXEL (sheet, x);
- current_row = ROW_FROM_YPIXEL (sheet, y);
+ current_row = yyy_row_ypixel_to_row (sheet, y);
column = current_col - sheet->drag_cell.col;
row = current_row - sheet->drag_cell.row;
/*use half of column width resp. row height as threshold to
expand selection*/
col_threshold = COLUMN_LEFT_XPIXEL (sheet, current_col) +
- xxx_column_width (sheet, current_col) / 2;
+ g_sheet_column_get_width (sheet->column_geometry, current_col) / 2;
if (column > 0)
{
if (x < col_threshold)
if (x > col_threshold)
column +=1;
}
- row_threshold = ROW_TOP_YPIXEL (sheet, current_row) +
- yyy_row_height (sheet, current_row)/2;
+ row_threshold = g_sheet_row_start_pixel (sheet->row_geometry, current_row) +
+ g_sheet_row_get_height (sheet->row_geometry, current_row)/2;
if (row > 0)
{
if (y < row_threshold)
else
row = 0;
- if (aux.row0 + row >= 0 && aux.rowi + row < yyy_row_count (sheet) &&
- aux.col0 + column >= 0 && aux.coli + column < xxx_column_count (sheet))
+ if (aux.row0 + row >= 0 && aux.rowi + row < g_sheet_row_get_row_count (sheet->row_geometry) &&
+ aux.col0 + column >= 0 && aux.coli + column < g_sheet_column_get_column_count (sheet->column_geometry))
{
aux = sheet->drag_range;
sheet->drag_range = sheet->range;
return TRUE;
}
+static gboolean
+gtk_sheet_crossing_notify (GtkWidget *widget,
+ GdkEventCrossing *event)
+{
+ GtkSheet *sheet = GTK_SHEET (widget);
+
+ if (event->window == sheet->column_title_window)
+ sheet->column_title_under = event->type == GDK_ENTER_NOTIFY;
+ else if (event->window == sheet->row_title_window)
+ sheet->row_title_under = event->type == GDK_ENTER_NOTIFY;
+
+ return TRUE;
+}
+
+
static gboolean
gtk_sheet_move_query (GtkSheet *sheet, gint row, gint column)
{
- gint row_move, column_move;
- gfloat row_align, col_align;
guint height, width;
gint new_row = row;
gint new_col = column;
- row_move = FALSE;
- column_move = FALSE;
- row_align = -1.;
- col_align = -1.;
+ gint row_move = FALSE;
+ gint column_move = FALSE;
+ gfloat row_align = -1.0;
+ gfloat col_align = -1.0;
height = sheet->sheet_window_height;
width = sheet->sheet_window_width;
if (row >= MAX_VISIBLE_ROW (sheet) && sheet->state != GTK_SHEET_COLUMN_SELECTED)
{
row_align = 1.;
- new_row = MIN (yyy_row_count (sheet) - 1, row + 1);
+ new_row = MIN (g_sheet_row_get_row_count (sheet->row_geometry) - 1, row + 1);
row_move = TRUE;
- if (MAX_VISIBLE_ROW (sheet) == yyy_row_count (sheet) - 1 &&
- ROW_TOP_YPIXEL (sheet, yyy_row_count (sheet)- 1) +
- yyy_row_height (sheet, yyy_row_count (sheet)- 1) < height)
+ if (MAX_VISIBLE_ROW (sheet) == g_sheet_row_get_row_count (sheet->row_geometry) - 1 &&
+ g_sheet_row_start_pixel (sheet->row_geometry, g_sheet_row_get_row_count (sheet->row_geometry) - 1) +
+ g_sheet_row_get_height (sheet->row_geometry, g_sheet_row_get_row_count (sheet->row_geometry) - 1) < height)
{
row_move = FALSE;
row_align = -1.;
if (column >= MAX_VISIBLE_COLUMN (sheet) && sheet->state != GTK_SHEET_ROW_SELECTED)
{
col_align = 1.;
- new_col = MIN (xxx_column_count (sheet) - 1, column + 1);
+ new_col = MIN (g_sheet_column_get_column_count (sheet->column_geometry) - 1, column + 1);
column_move = TRUE;
- if (MAX_VISIBLE_COLUMN (sheet) == (xxx_column_count (sheet) - 1) &&
- COLUMN_LEFT_XPIXEL (sheet, xxx_column_count (sheet) - 1) +
- xxx_column_width (sheet, xxx_column_count (sheet) - 1) < width)
+ if (MAX_VISIBLE_COLUMN (sheet) == (g_sheet_column_get_column_count (sheet->column_geometry) - 1) &&
+ COLUMN_LEFT_XPIXEL (sheet, g_sheet_column_get_column_count (sheet->column_geometry) - 1) +
+ g_sheet_column_get_width (sheet->column_geometry, g_sheet_column_get_column_count (sheet->column_geometry) - 1) < width)
{
column_move = FALSE;
col_align = -1.;
}
if (column < MIN_VISIBLE_COLUMN (sheet) && sheet->state != GTK_SHEET_ROW_SELECTED)
{
- col_align = 0.;
+ col_align = 0.0;
column_move = TRUE;
}
switch (sheet->state)
{
case GTK_SHEET_ROW_SELECTED:
- column = xxx_column_count (sheet) - 1;
+ column = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
break;
case GTK_SHEET_COLUMN_SELECTED:
- row = yyy_row_count (sheet) - 1;
+ row = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
break;
case GTK_SHEET_NORMAL:
sheet->state = GTK_SHEET_RANGE_SELECTED;
sheet->range.row0 = r;
sheet->range.coli = c;
sheet->range.rowi = r;
- gdk_draw_drawable (sheet->sheet_window,
- GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
- sheet->pixmap,
- COLUMN_LEFT_XPIXEL (sheet, c)- 1,
- ROW_TOP_YPIXEL (sheet, r)- 1,
- COLUMN_LEFT_XPIXEL (sheet, c)- 1,
- ROW_TOP_YPIXEL (sheet, r)- 1,
- xxx_column_width (sheet, c)+4,
- yyy_row_height (sheet, r)+4);
gtk_sheet_range_draw_selection (sheet, sheet->range);
case GTK_SHEET_RANGE_SELECTED:
sheet->state = GTK_SHEET_RANGE_SELECTED;
row = MIN_VISIBLE_ROW (sheet)- 1;
if (sheet->state == GTK_SHEET_ROW_SELECTED)
col = MIN_VISIBLE_COLUMN (sheet);
- if (row < yyy_row_count (sheet) - 1)
+ if (row < g_sheet_row_get_row_count (sheet->row_geometry) - 1)
{
row = row + scroll;
- while (!yyy_row_is_visible (sheet, row) && row < yyy_row_count (sheet)- 1)
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row < g_sheet_row_get_row_count (sheet->row_geometry) - 1)
row++;
}
gtk_sheet_click_cell (sheet, row, col, &veto);
if (col > 0)
{
col = col - scroll;
- while (! xxx_column_is_visible (sheet, col) && col > 0) col--;
+ while (! g_sheet_column_get_visibility (sheet->column_geometry, col) && col > 0) col--;
col = MAX (0, col);
}
gtk_sheet_click_cell (sheet, row, col, &veto);
col = MIN_VISIBLE_COLUMN (sheet)- 1;
if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
row = MIN_VISIBLE_ROW (sheet);
- if (col < xxx_column_count (sheet) - 1)
+ if (col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
{
col = col + scroll;
- while (! xxx_column_is_visible (sheet, col) &&
- col < xxx_column_count (sheet) - 1)
+ while (! g_sheet_column_get_visibility (sheet->column_geometry, col) &&
+ col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
col++;
}
gtk_sheet_click_cell (sheet, row, col, &veto);
if (sheet->selection_cell.row > 0)
{
row = sheet->selection_cell.row - scroll;
- while (!yyy_row_is_visible (sheet, row) && row > 0) row--;
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row > 0) row--;
row = MAX (0, row);
gtk_sheet_extend_selection (sheet, row, sheet->selection_cell.col);
}
if (state == GTK_SHEET_ROW_SELECTED)
col = MIN_VISIBLE_COLUMN (sheet);
row = row - scroll;
- while (!yyy_row_is_visible (sheet, row) && row > 0) row--;
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row > 0) row--;
row = MAX (0, row);
gtk_sheet_click_cell (sheet, row, col, &veto);
extend_selection = FALSE;
gtk_sheet_click_cell (sheet, row, col, &veto);
if (!veto) break;
}
- if (sheet->selection_cell.row < yyy_row_count (sheet)- 1)
+ if (sheet->selection_cell.row < g_sheet_row_get_row_count (sheet->row_geometry) - 1)
{
row = sheet->selection_cell.row + scroll;
- while (!yyy_row_is_visible (sheet, row) && row < yyy_row_count (sheet)- 1) row++;
- row = MIN (yyy_row_count (sheet)- 1, row);
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row < g_sheet_row_get_row_count (sheet->row_geometry) - 1) row++;
+ row = MIN (g_sheet_row_get_row_count (sheet->row_geometry) - 1, row);
gtk_sheet_extend_selection (sheet, row, sheet->selection_cell.col);
}
return TRUE;
}
col = sheet->active_cell.col;
row = sheet->active_cell.row;
- if (sheet->active_cell.row < yyy_row_count (sheet)- 1)
+ if (sheet->active_cell.row < g_sheet_row_get_row_count (sheet->row_geometry) - 1)
{
if (state == GTK_SHEET_COLUMN_SELECTED)
row = MIN_VISIBLE_ROW (sheet)- 1;
if (state == GTK_SHEET_ROW_SELECTED)
col = MIN_VISIBLE_COLUMN (sheet);
row = row + scroll;
- while (!yyy_row_is_visible (sheet, row) && row < yyy_row_count (sheet)- 1) row++;
- row = MIN (yyy_row_count (sheet)- 1, row);
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row < g_sheet_row_get_row_count (sheet->row_geometry) - 1) row++;
+ row = MIN (g_sheet_row_get_row_count (sheet->row_geometry) - 1, row);
}
gtk_sheet_click_cell (sheet, row, col, &veto);
extend_selection = FALSE;
gtk_sheet_click_cell (sheet, row, col, &veto);
if (!veto) break;
}
- if (sheet->selection_cell.col < xxx_column_count (sheet) - 1)
+ if (sheet->selection_cell.col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
{
col = sheet->selection_cell.col + 1;
- while (! xxx_column_is_visible (sheet, col) && col < xxx_column_count (sheet) - 1)
+ while (! g_sheet_column_get_visibility (sheet->column_geometry, col) && col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
col++;
gtk_sheet_extend_selection (sheet, sheet->selection_cell.row, col);
}
}
col = sheet->active_cell.col;
row = sheet->active_cell.row;
- if (sheet->active_cell.col < xxx_column_count (sheet) - 1)
+ if (sheet->active_cell.col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
{
col ++;
if (state == GTK_SHEET_ROW_SELECTED)
col = MIN_VISIBLE_COLUMN (sheet)- 1;
if (state == GTK_SHEET_COLUMN_SELECTED)
row = MIN_VISIBLE_ROW (sheet);
- while (! xxx_column_is_visible (sheet, col) && col < xxx_column_count (sheet) - 1) col++;
+ while (! g_sheet_column_get_visibility (sheet->column_geometry, col) && col < g_sheet_column_get_column_count (sheet->column_geometry) - 1) col++;
if (strlen (gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)))) == 0
|| force_move)
{
if (sheet->selection_cell.col > 0)
{
col = sheet->selection_cell.col - 1;
- while (! xxx_column_is_visible (sheet, col) && col > 0) col--;
+ while (! g_sheet_column_get_visibility (sheet->column_geometry, col) && col > 0) col--;
gtk_sheet_extend_selection (sheet, sheet->selection_cell.row, col);
}
return TRUE;
col = MIN_VISIBLE_COLUMN (sheet)- 1;
if (state == GTK_SHEET_COLUMN_SELECTED)
row = MIN_VISIBLE_ROW (sheet);
- while (! xxx_column_is_visible (sheet, col) && col > 0) col--;
+ while (! g_sheet_column_get_visibility (sheet->column_geometry, col) && col > 0) col--;
col = MAX (0, col);
if (strlen (gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)))) == 0
break;
case GDK_Home:
row = 0;
- while (!yyy_row_is_visible (sheet, row) && row < yyy_row_count (sheet) - 1) row++;
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row < g_sheet_row_get_row_count (sheet->row_geometry) - 1) row++;
gtk_sheet_click_cell (sheet, row, sheet->active_cell.col, &veto);
extend_selection = FALSE;
break;
case GDK_End:
- row = yyy_row_count (sheet) - 1;
- while (!yyy_row_is_visible (sheet, row) && row > 0) row--;
+ row = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row > 0) row--;
gtk_sheet_click_cell (sheet, row, sheet->active_cell.col, &veto);
extend_selection = FALSE;
break;
GtkRequisition * requisition)
{
GtkSheet *sheet;
- GList *children;
- GtkSheetChild *child;
- GtkRequisition child_requisition;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SHEET (widget));
/* compute the size of the row title area */
if (sheet->row_titles_visible)
requisition->width += sheet->row_title_area.width;
-
- children = sheet->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- gtk_widget_size_request (child->widget, &child_requisition);
- }
}
/* position the window which holds the column title buttons */
sheet->column_title_area.x = 0;
sheet->column_title_area.y = 0;
+
if (sheet->row_titles_visible)
+ {
sheet->column_title_area.x = sheet->row_title_area.width;
- sheet->column_title_area.width = sheet_allocation.width -
- sheet->column_title_area.x;
+ sheet->sheet_window_width -= sheet->row_title_area.width;
+ }
+
+ sheet->column_title_area.width = sheet_allocation.width ;
+
+
if (GTK_WIDGET_REALIZED (widget) && sheet->column_titles_visible)
gdk_window_move_resize (sheet->column_title_window,
sheet->column_title_area.x,
sheet->column_title_area.width,
sheet->column_title_area.height);
- sheet->sheet_window_width = sheet_allocation.width;
- sheet->sheet_window_height = sheet_allocation.height;
/* column button allocation */
size_allocate_column_title_buttons (sheet);
sheet->row_title_area.x = 0;
sheet->row_title_area.y = 0;
if (sheet->column_titles_visible)
+ {
sheet->row_title_area.y = sheet->column_title_area.height;
+ sheet->sheet_window_height -= sheet->column_title_area.height;
+ }
+
sheet->row_title_area.height = sheet_allocation.height -
sheet->row_title_area.y;
size_allocate_column_title_buttons (sheet);
/* re - scale backing pixmap */
- gtk_sheet_make_backing_pixmap (sheet, 0, 0);
- gtk_sheet_position_children (sheet);
+ gtk_sheet_make_backing_pixmap (sheet);
/* set the scrollbars adjustments */
adjust_scrollbars (sheet);
if (!GTK_WIDGET_REALIZED (sheet))
return;
+
width = sheet->sheet_window_width;
x = 0;
if (sheet->row_titles_visible)
{
- width -= sheet->row_title_area.width;
x = sheet->row_title_area.width;
}
sheet->column_title_area.height);
}
-
- if (MAX_VISIBLE_COLUMN (sheet) == xxx_column_count (sheet) - 1)
+ if (MAX_VISIBLE_COLUMN (sheet) == g_sheet_column_get_column_count (sheet->column_geometry) - 1)
gdk_window_clear_area (sheet->column_title_window,
0, 0,
sheet->column_title_area.width,
if (sheet->column_titles_visible)
{
- height -= sheet->column_title_area.height;
y = sheet->column_title_area.height;
}
sheet->row_title_area.width,
sheet->row_title_area.height);
}
- if (MAX_VISIBLE_ROW (sheet) == yyy_row_count (sheet)- 1)
+ if (MAX_VISIBLE_ROW (sheet) == g_sheet_row_get_row_count (sheet->row_geometry) - 1)
gdk_window_clear_area (sheet->row_title_window,
0, 0,
sheet->row_title_area.width,
for (i = MIN_VISIBLE_ROW (sheet); i <= MAX_VISIBLE_ROW (sheet); i++)
{
- if ( i >= yyy_row_count (sheet))
+ if ( i >= g_sheet_row_get_row_count (sheet->row_geometry))
break;
gtk_sheet_row_title_button_draw (sheet, i);
}
if (text && strlen (text) > 0)
text_size = STRING_WIDTH (GTK_WIDGET (sheet), attributes.font_desc, text);
- column_width = xxx_column_width (sheet, sheet->active_cell.col);
+ column_width = g_sheet_column_get_width (sheet->column_geometry, sheet->active_cell.col);
size = MIN (text_size, max_size);
- size = MAX (size, column_width - 2 * CELLOFFSET);
+ size = MAX (size, column_width - 2 * COLUMN_TITLES_HEIGHT);
row = sheet->active_cell.row;
col = sheet->active_cell.col;
shentry_allocation.x = COLUMN_LEFT_XPIXEL (sheet, sheet->active_cell.col);
- shentry_allocation.y = ROW_TOP_YPIXEL (sheet, sheet->active_cell.row);
+ shentry_allocation.y = g_sheet_row_start_pixel (sheet->row_geometry, sheet->active_cell.row);
+ if ( sheet->column_titles_visible)
+ shentry_allocation.y += sheet->column_title_area.height;
+
+ shentry_allocation.y -= sheet->vadjustment->value;
+
+ if ( sheet->row_titles_visible)
+ shentry_allocation.x += sheet->row_title_area.width;
+
+ shentry_allocation.x -= sheet->hadjustment->value;
+
shentry_allocation.width = column_width;
- shentry_allocation.height = yyy_row_height (sheet, sheet->active_cell.row);
+ shentry_allocation.height = g_sheet_row_get_height (sheet->row_geometry, sheet->active_cell.row);
if (GTK_IS_ITEM_ENTRY (sheet->entry_widget))
{
- shentry_allocation.height -= 2 * CELLOFFSET;
- shentry_allocation.y += CELLOFFSET;
+ shentry_allocation.height -= 2 * COLUMN_TITLES_HEIGHT;
+ shentry_allocation.y += COLUMN_TITLES_HEIGHT;
shentry_allocation.width = size;
switch (GTK_ITEM_ENTRY (sheet_entry)->justification)
shentry_allocation.x += column_width / 2 - size / 2;
break;
case GTK_JUSTIFY_RIGHT:
- shentry_allocation.x += column_width - size - CELLOFFSET;
+ shentry_allocation.x += column_width - size - COLUMN_TITLES_HEIGHT;
break;
case GTK_JUSTIFY_LEFT:
case GTK_JUSTIFY_FILL:
- shentry_allocation.x += CELLOFFSET;
+ shentry_allocation.x += COLUMN_TITLES_HEIGHT;
break;
}
}
g_free (s);
break;
}
- size +=xxx_column_width (sheet, i);
+ size +=g_sheet_column_get_width (sheet->column_geometry, i);
}
size = MIN (size, sheet->sheet_window_width - COLUMN_LEFT_XPIXEL (sheet, col));
break;
g_free (s);
break;
}
- size +=xxx_column_width (sheet, i);
+ size +=g_sheet_column_get_width (sheet->column_geometry, i);
}
break;
case GTK_JUSTIFY_CENTER:
for (i = col + 1; i <= MAX_VISIBLE_COLUMN (sheet); i++)
{
- sizer += xxx_column_width (sheet, i);
+ sizer += g_sheet_column_get_width (sheet->column_geometry, i);
}
for (i = col - 1; i >= MIN_VISIBLE_COLUMN (sheet); i--)
{
g_free (s);
break;
}
- sizel +=xxx_column_width (sheet, i);
+ sizel +=g_sheet_column_get_width (sheet->column_geometry, i);
}
size = 2 * MIN (sizel, sizer);
break;
}
if (size != 0)
- size += xxx_column_width (sheet, col);
+ size += g_sheet_column_get_width (sheet->column_geometry, col);
GTK_ITEM_ENTRY (sheet->entry_widget)->text_max_size = size;
}
{
GtkWidget *parent;
GtkWidget *entry = NULL;
- GtkTableChild *table_child;
- GtkBoxChild *box_child;
- GList *children = NULL;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
parent = sheet->entry_container;
- if (GTK_IS_TABLE (parent)) children = GTK_TABLE (parent)->children;
- if (GTK_IS_BOX (parent)) children = GTK_BOX (parent)->children;
-
if (GTK_IS_CONTAINER (parent))
{
gtk_container_forall (GTK_CONTAINER (parent), find_entry, &entry);
return entry;
}
- if (!children) return NULL;
-
- while (children)
- {
- if (GTK_IS_TABLE (parent))
- {
- table_child = children->data;
- entry = table_child->widget;
- }
- if (GTK_IS_BOX (parent))
- {
- box_child = children->data;
- entry = box_child->widget;
- }
-
- if (GTK_IS_ENTRY (entry))
- break;
- children = children->next;
- }
-
-
if (!GTK_IS_ENTRY (entry)) return NULL;
return (entry);
{
GtkShadowType shadow_type;
gint text_width = 0, text_height = 0;
- GtkSheetChild *child = NULL;
PangoAlignment align = PANGO_ALIGN_LEFT;
gboolean rtl ;
g_return_if_fail (sheet != NULL);
g_return_if_fail (button != NULL);
+
rtl = gtk_widget_get_direction (GTK_WIDGET (sheet)) == GTK_TEXT_DIR_RTL;
gdk_window_clear_area (window,
if (button->label_visible)
{
- text_height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet))- 2 * CELLOFFSET;
+ text_height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet)) -
+ 2 * COLUMN_TITLES_HEIGHT;
gdk_gc_set_clip_rectangle (GTK_WIDGET (sheet)->style->fg_gc[button->state],
&allocation);
- gdk_gc_set_clip_rectangle (GTK_WIDGET (sheet)->style->white_gc, &allocation);
+ gdk_gc_set_clip_rectangle (GTK_WIDGET (sheet)->style->white_gc,
+ &allocation);
allocation.y += 2 * sheet->button->style->ythickness;
switch (button->justification)
{
case GTK_JUSTIFY_LEFT:
- real_x = allocation.x + CELLOFFSET;
+ real_x = allocation.x + COLUMN_TITLES_HEIGHT;
align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
break;
case GTK_JUSTIFY_RIGHT:
- real_x = allocation.x + allocation.width - text_width - CELLOFFSET;
+ real_x = allocation.x + allocation.width - text_width - COLUMN_TITLES_HEIGHT;
align = rtl ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
break;
case GTK_JUSTIFY_CENTER:
}
- if ((child = button->child) && (child->widget))
- {
- child->x = allocation.x;
- child->y = allocation.y;
-
- child->x += (allocation.width - child->widget->requisition.width) / 2;
- child->y += (allocation.height - child->widget->requisition.height) / 2;
- allocation.x = child->x;
- allocation.y = child->y;
- allocation.width = child->widget->requisition.width;
- allocation.height = child->widget->requisition.height;
-
- allocation.x = child->x;
- allocation.y = child->y;
-
- gtk_widget_set_state (child->widget, button->state);
-
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) &&
- GTK_WIDGET_MAPPED (child->widget))
- {
- gtk_widget_size_allocate (child->widget,
- &allocation);
- gtk_widget_queue_draw (child->widget);
- }
- }
-
gtk_sheet_button_free (button);
}
-
-/* COLUMN value of - 1 indicates that the area to the right of the rightmost
- button should be redrawn */
static void
gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column)
{
- GdkWindow *window = NULL;
GdkRectangle allocation;
-
+ GtkSheetButton *button = NULL;
gboolean is_sensitive = FALSE;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
- if (column >= 0 && ! xxx_column_is_visible (sheet, column)) return;
- if (column >= 0 && !sheet->column_titles_visible) return;
- if (column >= 0 && column < MIN_VISIBLE_COLUMN (sheet)) return;
- if (column >= 0 && column > MAX_VISIBLE_COLUMN (sheet)) return;
-
- window = sheet->column_title_window;
- allocation.y = 0;
- allocation.height = sheet->column_title_area.height;
+ if (!sheet->column_titles_visible) return;
+ if (!g_sheet_column_get_visibility (sheet->column_geometry, column)) return;
- if ( column == -1 )
- {
- const gint cols = xxx_column_count (sheet) ;
- allocation.x = COLUMN_LEFT_XPIXEL (sheet, cols - 1)
- ;
- allocation.width = sheet->column_title_area.width
- + sheet->column_title_area.x
- - allocation.x;
+ if (column < MIN_VISIBLE_COLUMN (sheet)) return;
+ if (column > MAX_VISIBLE_COLUMN (sheet)) return;
- gdk_window_clear_area (window,
- allocation.x, allocation.y,
- allocation.width, allocation.height);
- }
- else
- {
- GtkSheetButton *button = xxx_column_button (sheet, column);
+ button = g_sheet_column_get_button (sheet->column_geometry, column);
+ allocation.y = 0;
allocation.x = COLUMN_LEFT_XPIXEL (sheet, column) + CELL_SPACING;
- if (sheet->row_titles_visible)
- allocation.x -= sheet->row_title_area.width;
-
- allocation.width = xxx_column_width (sheet, column);
+ allocation.x -= sheet->hadjustment->value;
- is_sensitive = xxx_column_is_sensitive (sheet, column);
- gtk_sheet_button_draw (sheet, window, button,
- is_sensitive, allocation);
-
- /* FIXME: Not freeing this button is correct (sort of),
- because in PSPP the model always returns a static copy */
-
- /* gtk_sheet_button_free (button); */
+ allocation.height = sheet->column_title_area.height;
+ allocation.width = g_sheet_column_get_width (sheet->column_geometry, column);
+ is_sensitive = g_sheet_column_get_sensitivity (sheet->column_geometry, column);
+ gtk_sheet_button_draw (sheet, sheet->column_title_window,
+ button, is_sensitive, allocation);
}
-}
+
static void
gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row)
{
- GdkWindow *window = NULL;
GdkRectangle allocation;
GtkSheetButton *button = NULL;
gboolean is_sensitive = FALSE;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
- if (row >= 0 && !yyy_row_is_visible (sheet, row)) return;
- if (row >= 0 && !sheet->row_titles_visible) return;
- if (row >= 0 && row < MIN_VISIBLE_ROW (sheet)) return;
- if (row >= 0 && row > MAX_VISIBLE_ROW (sheet)) return;
+ if (!sheet->row_titles_visible) return;
+ if (!g_sheet_row_get_visibility (sheet->row_geometry, row)) return;
+ if (row < MIN_VISIBLE_ROW (sheet)) return;
+ if (row > MAX_VISIBLE_ROW (sheet)) return;
- window = sheet->row_title_window;
- button = yyy_row_button (sheet, row);
+ button = g_sheet_row_get_button (sheet->row_geometry, row);
allocation.x = 0;
- allocation.y = ROW_TOP_YPIXEL (sheet, row) + CELL_SPACING;
- if (sheet->column_titles_visible)
- allocation.y -= sheet->column_title_area.height;
+ allocation.y = g_sheet_row_start_pixel (sheet->row_geometry, row) + CELL_SPACING;
+ allocation.y -= sheet->vadjustment->value;
+
allocation.width = sheet->row_title_area.width;
- allocation.height = yyy_row_height (sheet, row);
- is_sensitive = yyy_row_is_sensitive (sheet, row);
+ allocation.height = g_sheet_row_get_height (sheet->row_geometry, row);
+ is_sensitive = g_sheet_row_get_sensitivity (sheet->row_geometry, row);
- gtk_sheet_button_draw (sheet, window, button, is_sensitive, allocation);
+ gtk_sheet_button_draw (sheet, sheet->row_title_window,
+ button, is_sensitive, allocation);
}
/* SCROLLBARS
{
if (sheet->vadjustment)
{
- sheet->vadjustment->page_size = sheet->sheet_window_height;
- sheet->vadjustment->page_increment = sheet->sheet_window_height / 2;
- sheet->vadjustment->step_increment = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+ sheet->vadjustment->step_increment =
+ 1 ; // DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+
+ sheet->vadjustment->page_increment =
+ sheet->sheet_window_height - DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+
+ sheet->vadjustment->upper = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet))
+ * g_sheet_row_get_row_count (sheet->row_geometry);
+
+
sheet->vadjustment->lower = 0;
- sheet->vadjustment->upper = SHEET_HEIGHT (sheet) + 80;
- g_signal_emit_by_name (sheet->vadjustment, "changed");
+ sheet->vadjustment->page_size = sheet->sheet_window_height;
+ g_signal_emit_by_name (sheet->vadjustment, "changed");
}
if (sheet->hadjustment)
{
- sheet->hadjustment->page_size = sheet->sheet_window_width;
- sheet->hadjustment->page_increment = sheet->sheet_window_width / 2;
- sheet->hadjustment->step_increment = DEFAULT_COLUMN_WIDTH;
+ gint last_col;
+ sheet->hadjustment->step_increment = 1 ; //DEFAULT_COLUMN_WIDTH;
+
+ sheet->hadjustment->page_increment = sheet->sheet_window_width ;
+
+ last_col = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+
+ sheet->hadjustment->upper =
+ g_sheet_column_start_pixel (sheet->column_geometry, last_col)
+ +
+ g_sheet_column_get_width (sheet->column_geometry, last_col)
+ ;
+
sheet->hadjustment->lower = 0;
- sheet->hadjustment->upper = SHEET_WIDTH (sheet)+ 80;
- g_signal_emit_by_name (sheet->hadjustment, "changed");
+ sheet->hadjustment->page_size = sheet->sheet_window_width;
+ g_signal_emit_by_name (sheet->hadjustment, "changed");
}
}
vadjustment_value_changed (GtkAdjustment * adjustment,
gpointer data)
{
- GtkSheet *sheet;
- gint diff, value, old_value;
- gint row, new_row;
- gint y = 0;
+ GtkSheet *sheet = GTK_SHEET (data);
g_return_if_fail (adjustment != NULL);
- g_return_if_fail (data != NULL);
- g_return_if_fail (GTK_IS_SHEET (data));
-
- sheet = GTK_SHEET (data);
-
- if (GTK_SHEET_IS_FROZEN (sheet)) return;
-
- row = ROW_FROM_YPIXEL (sheet, CELL_SPACING);
-
- old_value = - sheet->voffset;
-
- new_row = g_sheet_row_pixel_to_row (sheet->row_geometry,
- adjustment->value);
- y = g_sheet_row_start_pixel (sheet->row_geometry, new_row);
+ if ( ! GTK_WIDGET_REALIZED (sheet)) return;
- if (adjustment->value > sheet->old_vadjustment && sheet->old_vadjustment > 0. &&
- yyy_row_height (sheet, row) > sheet->vadjustment->step_increment)
- {
- /* This avoids embarrassing twitching */
- if (row == new_row && row != yyy_row_count (sheet) - 1 &&
- adjustment->value - sheet->old_vadjustment >=
- sheet->vadjustment->step_increment &&
- new_row + 1 != MIN_VISIBLE_ROW (sheet))
- {
- new_row +=1;
- y = y+yyy_row_height (sheet, row);
- }
- }
+ gtk_widget_hide (sheet->entry_widget);
+ gtk_sheet_range_draw (sheet, NULL);
+ size_allocate_row_title_buttons (sheet);
+ // size_allocate_global_button (sheet);
+}
- /* Negative old_adjustment enforces the redraw, otherwise avoid
- spureous redraw */
- if (sheet->old_vadjustment >= 0. && row == new_row)
- {
- sheet->old_vadjustment = sheet->vadjustment->value;
- return;
- }
- sheet->old_vadjustment = sheet->vadjustment->value;
- adjustment->value = y;
+static void
+hadjustment_value_changed (GtkAdjustment * adjustment,
+ gpointer data)
+{
+ GtkSheet *sheet = GTK_SHEET (data);
+ g_return_if_fail (adjustment != NULL);
- if (new_row == 0)
- {
- sheet->vadjustment->step_increment = yyy_row_height (sheet, 0);
- }
- else
- {
- sheet->vadjustment->step_increment =
- MIN (yyy_row_height (sheet, new_row), yyy_row_height (sheet, new_row - 1));
- }
+ if ( ! GTK_WIDGET_REALIZED (sheet)) return;
- sheet->vadjustment->value = adjustment->value;
+ gtk_widget_hide (sheet->entry_widget);
+ gtk_sheet_range_draw (sheet, NULL);
+ size_allocate_column_title_buttons (sheet);
+ // size_allocate_global_button (sheet);
+}
- value = adjustment->value;
- if (value >= - sheet->voffset)
- {
- /* scroll down */
- diff = value + sheet->voffset;
- }
- else
- {
- /* scroll up */
- diff = - sheet->voffset - value;
- }
+/* COLUMN RESIZING */
+static void
+draw_xor_vline (GtkSheet * sheet)
+{
+ gint xpos = sheet->x_drag;
- sheet->voffset = - value;
+ if (sheet->row_titles_visible)
+ xpos += sheet->row_title_area.width;
- if (GTK_WIDGET_REALIZED (sheet->entry_widget) &&
- sheet->state == GTK_SHEET_NORMAL &&
- sheet->active_cell.row >= 0 && sheet->active_cell.col >= 0 &&
- !gtk_sheet_cell_isvisible (sheet, sheet->active_cell.row,
- sheet->active_cell.col))
- {
- const gchar *text;
+ gdk_draw_line (GTK_WIDGET (sheet)->window, sheet->xor_gc,
+ xpos,
+ sheet->column_title_area.height,
+ xpos,
+ sheet->sheet_window_height + CELL_SPACING);
+}
- text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)));
+/* ROW RESIZING */
+static void
+draw_xor_hline (GtkSheet * sheet)
- if (!text || strlen (text) == 0)
- gtk_sheet_cell_clear (sheet,
- sheet->active_cell.row,
- sheet->active_cell.col);
- gtk_widget_unmap (sheet->entry_widget);
- }
+{
+ gint ypos = sheet->y_drag;
- gtk_sheet_position_children (sheet);
+ if (sheet->column_titles_visible)
+ ypos += sheet->column_title_area.height;
- gtk_sheet_range_draw (sheet, NULL);
- size_allocate_row_title_buttons (sheet);
- size_allocate_global_button (sheet);
+ gdk_draw_line (GTK_WIDGET (sheet)->window, sheet->xor_gc,
+ sheet->row_title_area.width,
+ ypos,
+ sheet->sheet_window_width + CELL_SPACING,
+ ypos);
}
+/* SELECTED RANGE */
static void
-hadjustment_value_changed (GtkAdjustment * adjustment,
- gpointer data)
+draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range)
{
- GtkSheet *sheet;
- gint i, diff, value, old_value;
- gint column, new_column;
- gint x = 0;
-
- g_return_if_fail (adjustment != NULL);
- g_return_if_fail (data != NULL);
- g_return_if_fail (GTK_IS_SHEET (data));
-
- sheet = GTK_SHEET (data);
+ gint i = 0;
+ GdkRectangle clip_area, area;
+ GdkGCValues values;
- if (GTK_SHEET_IS_FROZEN (sheet)) return;
+ area.x = COLUMN_LEFT_XPIXEL (sheet, range.col0);
+ area.y = g_sheet_row_start_pixel (sheet->row_geometry, range.row0);
+ area.width = COLUMN_LEFT_XPIXEL (sheet, range.coli)- area.x+
+ g_sheet_column_get_width (sheet->column_geometry, range.coli);
+ area.height = g_sheet_row_start_pixel (sheet->row_geometry, range.rowi)- area.y +
+ g_sheet_row_get_height (sheet->row_geometry, range.rowi);
- column = COLUMN_FROM_XPIXEL (sheet, CELL_SPACING);
+ clip_area.x = sheet->row_title_area.width;
+ clip_area.y = sheet->column_title_area.height;
+ clip_area.width = sheet->sheet_window_width;
+ clip_area.height = sheet->sheet_window_height;
- old_value = - sheet->hoffset;
+ if (!sheet->row_titles_visible) clip_area.x = 0;
+ if (!sheet->column_titles_visible) clip_area.y = 0;
- for (i = 0; i < xxx_column_count (sheet); i++)
- {
- if (xxx_column_is_visible (sheet, i)) x += xxx_column_width (sheet, i);
- if (x > adjustment->value) break;
- }
- x -= xxx_column_width (sheet, i);
- new_column = i;
-
- if (adjustment->value > sheet->old_hadjustment && sheet->old_hadjustment > 0 &&
- xxx_column_width (sheet, i) > sheet->hadjustment->step_increment)
- {
- /* This avoids embarrassing twitching */
- if (column == new_column && column != xxx_column_count (sheet) - 1 &&
- adjustment->value - sheet->old_hadjustment >=
- sheet->hadjustment->step_increment &&
- new_column + 1 != MIN_VISIBLE_COLUMN (sheet))
- {
- new_column += 1;
- x += xxx_column_width (sheet, column);
- }
- }
-
- /* Negative old_adjustment enforces the redraw, otherwise avoid spureous redraw */
- if (sheet->old_hadjustment >= 0. && new_column == column)
- {
- sheet->old_hadjustment = sheet->hadjustment->value;
- return;
- }
-
- sheet->old_hadjustment = sheet->hadjustment->value;
- adjustment->value = x;
-
- if (new_column == 0)
- {
- sheet->hadjustment->step_increment = xxx_column_width (sheet, 0);
- }
- else
- {
- sheet->hadjustment->step_increment =
- MIN (xxx_column_width (sheet, new_column), xxx_column_width (sheet, new_column - 1));
- }
-
-
- sheet->hadjustment->value = adjustment->value;
-
- value = adjustment->value;
-
- if (value >= - sheet->hoffset)
- {
- /* scroll right */
- diff = value + sheet->hoffset;
- }
- else
- {
- /* scroll left */
- diff = - sheet->hoffset - value;
- }
-
- sheet->hoffset = - value;
- if (GTK_WIDGET_REALIZED (sheet->entry_widget) &&
- sheet->state == GTK_SHEET_NORMAL &&
- sheet->active_cell.row >= 0 && sheet->active_cell.col >= 0 &&
- !gtk_sheet_cell_isvisible (sheet, sheet->active_cell.row,
- sheet->active_cell.col))
- {
- const gchar *text;
-
- text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)));
- if (!text || strlen (text) == 0)
- gtk_sheet_cell_clear (sheet,
- sheet->active_cell.row,
- sheet->active_cell.col);
-
- gtk_widget_unmap (sheet->entry_widget);
- }
-
- gtk_sheet_position_children (sheet);
-
- gtk_sheet_range_draw (sheet, NULL);
- size_allocate_column_title_buttons (sheet);
-}
-
-
-/* COLUMN RESIZING */
-static void
-draw_xor_vline (GtkSheet * sheet)
-{
- GtkWidget *widget;
-
- g_return_if_fail (sheet != NULL);
-
- widget = GTK_WIDGET (sheet);
-
- gdk_draw_line (widget->window, sheet->xor_gc,
- sheet->x_drag,
- sheet->column_title_area.height,
- sheet->x_drag,
- sheet->sheet_window_height + 1);
-}
-
-/* ROW RESIZING */
-static void
-draw_xor_hline (GtkSheet * sheet)
-{
- GtkWidget *widget;
-
- g_return_if_fail (sheet != NULL);
-
- widget = GTK_WIDGET (sheet);
-
- gdk_draw_line (widget->window, sheet->xor_gc,
- sheet->row_title_area.width,
- sheet->y_drag,
-
- sheet->sheet_window_width + 1,
- sheet->y_drag);
-}
-
-/* SELECTED RANGE */
-static void
-draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range)
-{
- gint i;
- GdkRectangle clip_area, area;
- GdkGCValues values;
-
- area.x = COLUMN_LEFT_XPIXEL (sheet, range.col0);
- area.y = ROW_TOP_YPIXEL (sheet, range.row0);
- area.width = COLUMN_LEFT_XPIXEL (sheet, range.coli)- area.x+
- xxx_column_width (sheet, range.coli);
- area.height = ROW_TOP_YPIXEL (sheet, range.rowi)- area.y+
- yyy_row_height (sheet, range.rowi);
-
- clip_area.x = sheet->row_title_area.width;
- clip_area.y = sheet->column_title_area.height;
- clip_area.width = sheet->sheet_window_width;
- clip_area.height = sheet->sheet_window_height;
-
- if (!sheet->row_titles_visible) clip_area.x = 0;
- if (!sheet->column_titles_visible) clip_area.y = 0;
-
- if (area.x < 0)
+ if (area.x < 0)
{
area.width = area.width + area.x;
area.x = 0;
gdk_gc_set_clip_rectangle (sheet->xor_gc, &clip_area);
- for (i = -1; i <= 1; ++i)
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
FALSE,
gdk_gc_set_clip_rectangle (sheet->xor_gc, NULL);
gdk_gc_set_foreground (sheet->xor_gc, &values.foreground);
-
}
/* this function returns the new width of the column being resized given
- * the column and x position of the cursor; the x cursor position is passed
- * in as a pointer and automaticaly corrected if it's beyond min / max limits */
+ * the COLUMN and X position of the cursor; the x cursor position is passed
+ * in as a pointer and automaticaly corrected if it's outside the acceptable
+ * range */
static guint
-new_column_width (GtkSheet * sheet,
- gint column,
- gint * x)
+new_column_width (GtkSheet *sheet, gint column, gint *x)
{
- gint cx, width;
- guint min_width;
-
- cx = *x;
+ gint left_pos = COLUMN_LEFT_XPIXEL (sheet, column)
+ - sheet->hadjustment->value;
- min_width = sheet->column_requisition;
+ gint width = *x - left_pos;
- /* you can't shrink a column to less than its minimum width */
- if (cx < COLUMN_LEFT_XPIXEL (sheet, column) + min_width)
+ if ( width < sheet->column_requisition)
{
- *x = cx = COLUMN_LEFT_XPIXEL (sheet, column) + min_width;
+ width = sheet->column_requisition;
+ *x = left_pos + width;
}
- /* calculate new column width making sure it doesn't end up
- * less than the minimum width */
- width = cx - COLUMN_LEFT_XPIXEL (sheet, column);
- if (width < min_width)
- width = min_width;
+ g_sheet_column_set_width (sheet->column_geometry, column, width);
- xxx_set_column_width (sheet, column, width);
size_allocate_column_title_buttons (sheet);
return width;
* the row and y position of the cursor; the y cursor position is passed
* in as a pointer and automaticaly corrected if it's beyond min / max limits */
static guint
-new_row_height (GtkSheet * sheet,
- gint row,
- gint * y)
+new_row_height (GtkSheet *sheet, gint row, gint *y)
{
- gint cy, height;
+ gint height;
guint min_height;
- cy = *y;
+ gint cy = *y;
min_height = sheet->row_requisition;
/* you can't shrink a row to less than its minimum height */
- if (cy < ROW_TOP_YPIXEL (sheet, row) + min_height)
+ if (cy < g_sheet_row_start_pixel (sheet->row_geometry, row) + min_height)
{
- *y = cy = ROW_TOP_YPIXEL (sheet, row) + min_height;
+ *y = cy = g_sheet_row_start_pixel (sheet->row_geometry, row) + min_height;
}
/* calculate new row height making sure it doesn't end up
* less than the minimum height */
- height = (cy - ROW_TOP_YPIXEL (sheet, row));
+ height = (cy - g_sheet_row_start_pixel (sheet->row_geometry, row));
if (height < min_height)
height = min_height;
- yyy_set_row_height (sheet, row, height);
+ g_sheet_row_set_height (sheet->row_geometry, row, height);
size_allocate_row_title_buttons (sheet);
return height;
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column < 0 || column >= xxx_column_count (sheet))
+ if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry))
return;
gtk_sheet_column_size_request (sheet, column, &min_width);
if (width < min_width) return;
- xxx_set_column_width (sheet, column, width);
+ g_sheet_column_set_width (sheet->column_geometry, column, width);
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) && !GTK_SHEET_IS_FROZEN (sheet))
+ if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
{
size_allocate_column_title_buttons (sheet);
adjust_scrollbars (sheet);
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (row < 0 || row >= yyy_row_count (sheet))
+ if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry))
return;
gtk_sheet_row_size_request (sheet, row, &min_height);
if (height < min_height) return;
- yyy_set_row_height (sheet, row, height);
+ g_sheet_row_set_height (sheet->row_geometry, row, height);
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) && !GTK_SHEET_IS_FROZEN (sheet))
+ if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) )
{
size_allocate_row_title_buttons (sheet);
adjust_scrollbars (sheet);
colormap = gdk_colormap_get_system ();
attributes->background = sheet->bg_color;
}
- attributes->justification = xxx_column_justification (sheet, col);
+ attributes->justification = g_sheet_column_get_justification (sheet->column_geometry, col);
attributes->border.width = 0;
attributes->border.line_style = GDK_LINE_SOLID;
attributes->border.cap_style = GDK_CAP_NOT_LAST;
attributes->font_desc = GTK_WIDGET (sheet)->style->font_desc;
}
-
-/********************************************************************
- * Container Functions:
- * gtk_sheet_add
- * gtk_sheet_put
- * gtk_sheet_attach
- * gtk_sheet_remove
- * gtk_sheet_move_child
- * gtk_sheet_position_child
- * gtk_sheet_position_children
- * gtk_sheet_realize_child
- * gtk_sheet_get_child_at
- ********************************************************************/
-
-GtkSheetChild *
-gtk_sheet_put (GtkSheet *sheet, GtkWidget *child, gint x, gint y)
-{
- GtkRequisition child_requisition;
- GtkSheetChild *child_info;
-
- g_return_val_if_fail (sheet != NULL, NULL);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
- g_return_val_if_fail (child != NULL, NULL);
- g_return_val_if_fail (child->parent == NULL, NULL);
-
- child_info = g_new (GtkSheetChild, 1);
- child_info->widget = child;
- child_info->x = x;
- child_info->y = y;
- child_info->attached_to_cell = FALSE;
- child_info->floating = TRUE;
- child_info->xpadding = child_info->ypadding = 0;
- child_info->xexpand = child_info->yexpand = FALSE;
- child_info->xshrink = child_info->yshrink = FALSE;
- child_info->xfill = child_info->yfill = FALSE;
-
- sheet->children = g_list_append (sheet->children, child_info);
-
- gtk_widget_set_parent (child, GTK_WIDGET (sheet));
-
- gtk_widget_size_request (child, &child_requisition);
-
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (sheet)))
- {
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) &&
- (!GTK_WIDGET_REALIZED (child) || GTK_WIDGET_NO_WINDOW (child)))
- gtk_sheet_realize_child (sheet, child_info);
-
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (sheet)) &&
- !GTK_WIDGET_MAPPED (child))
- gtk_widget_map (child);
- }
-
- gtk_sheet_position_child (sheet, child_info);
-
- /* This will avoid drawing on the titles */
-
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- {
- if (sheet->row_titles_visible)
- gdk_window_show (sheet->row_title_window);
- if (sheet->column_titles_visible)
- gdk_window_show (sheet->column_title_window);
- }
-
- return (child_info);
-}
-
-void
-gtk_sheet_attach_floating (GtkSheet *sheet,
- GtkWidget *widget,
- gint row, gint col)
-{
- GdkRectangle area;
- GtkSheetChild *child;
-
- if (row < 0 || col < 0)
- {
- gtk_sheet_button_attach (sheet, widget, row, col);
- return;
- }
-
- gtk_sheet_get_cell_area (sheet, row, col, &area);
- child = gtk_sheet_put (sheet, widget, area.x, area.y);
- child->attached_to_cell = TRUE;
- child->row = row;
- child->col = col;
-}
-
-void
-gtk_sheet_attach_default (GtkSheet *sheet,
- GtkWidget *widget,
- gint row, gint col)
-{
- if (row < 0 || col < 0)
- {
- gtk_sheet_button_attach (sheet, widget, row, col);
- return;
- }
-
- gtk_sheet_attach (sheet, widget, row, col,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-}
-
-void
-gtk_sheet_attach (GtkSheet *sheet,
- GtkWidget *widget,
- gint row, gint col,
- gint xoptions,
- gint yoptions,
- gint xpadding,
- gint ypadding)
-{
- GdkRectangle area;
- GtkSheetChild *child = NULL;
-
- if (row < 0 || col < 0)
- {
- gtk_sheet_button_attach (sheet, widget, row, col);
- return;
- }
-
- child = g_new0 (GtkSheetChild, 1);
- child->attached_to_cell = TRUE;
- child->floating = FALSE;
- child->widget = widget;
- child->row = row;
- child->col = col;
- child->xpadding = xpadding;
- child->ypadding = ypadding;
- child->xexpand = (xoptions & GTK_EXPAND) != 0;
- child->yexpand = (yoptions & GTK_EXPAND) != 0;
- child->xshrink = (xoptions & GTK_SHRINK) != 0;
- child->yshrink = (yoptions & GTK_SHRINK) != 0;
- child->xfill = (xoptions & GTK_FILL) != 0;
- child->yfill = (yoptions & GTK_FILL) != 0;
-
- sheet->children = g_list_append (sheet->children, child);
-
- gtk_sheet_get_cell_area (sheet, row, col, &area);
-
- child->x = area.x + child->xpadding;
- child->y = area.y + child->ypadding;
-
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (sheet)))
- {
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) &&
- (!GTK_WIDGET_REALIZED (widget) || GTK_WIDGET_NO_WINDOW (widget)))
- gtk_sheet_realize_child (sheet, child);
-
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (sheet)) &&
- !GTK_WIDGET_MAPPED (widget))
- gtk_widget_map (widget);
- }
-
- gtk_sheet_position_child (sheet, child);
-
- /* This will avoid drawing on the titles */
-
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- {
- if (GTK_SHEET_ROW_TITLES_VISIBLE (sheet))
- gdk_window_show (sheet->row_title_window);
- if (GTK_SHEET_COL_TITLES_VISIBLE (sheet))
- gdk_window_show (sheet->column_title_window);
- }
-
-}
-
-void
-gtk_sheet_button_attach (GtkSheet *sheet,
- GtkWidget *widget,
- gint row, gint col)
-{
- GtkSheetButton *button = 0;
- GtkSheetChild *child;
- GtkRequisition button_requisition;
-
- if (row >= 0 && col >= 0) return;
- if (row < 0 && col < 0) return;
-
- child = g_new (GtkSheetChild, 1);
- child->widget = widget;
- child->x = 0;
- child->y = 0;
- child->attached_to_cell = TRUE;
- child->floating = FALSE;
- child->row = row;
- child->col = col;
- child->xpadding = child->ypadding = 0;
- child->xshrink = child->yshrink = FALSE;
- child->xfill = child->yfill = FALSE;
-
-
- sheet->children = g_list_append (sheet->children, child);
-
- gtk_sheet_button_size_request (sheet, button, &button_requisition);
-
-
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (sheet)))
- {
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) &&
- (!GTK_WIDGET_REALIZED (widget) || GTK_WIDGET_NO_WINDOW (widget)))
- gtk_sheet_realize_child (sheet, child);
-
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (sheet)) &&
- !GTK_WIDGET_MAPPED (widget))
- gtk_widget_map (widget);
- }
-
- if (row == -1) size_allocate_column_title_buttons (sheet);
- if (col == -1) size_allocate_row_title_buttons (sheet);
-
-}
-
static void
label_size_request (GtkSheet *sheet, gchar *label, GtkRequisition *req)
{
gchar *words;
gchar word[1000];
gint n = 0;
- gint row_height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet)) - 2 * CELLOFFSET + 2;
+ gint row_height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet)) - 2 * COLUMN_TITLES_HEIGHT + 2;
req->height = 0;
req->width = 0;
if (gtk_sheet_autoresize (sheet) && button->label && strlen (button->label) > 0)
{
label_size_request (sheet, button->label, &label_requisition);
- label_requisition.width += 2 * CELLOFFSET;
- label_requisition.height += 2 * CELLOFFSET;
+ label_requisition.width += 2 * COLUMN_TITLES_HEIGHT;
+ label_requisition.height += 2 * COLUMN_TITLES_HEIGHT;
}
else
{
label_requisition.width = COLUMN_MIN_WIDTH;
}
- if (button->child)
- {
- gtk_widget_size_request (button->child->widget, &requisition);
- requisition.width += 2 * button->child->xpadding;
- requisition.height += 2 * button->child->ypadding;
- requisition.width += 2 * sheet->button->style->xthickness;
- requisition.height += 2 * sheet->button->style->ythickness;
- }
- else
- {
requisition.height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
requisition.width = COLUMN_MIN_WIDTH;
- }
+
*button_requisition = requisition;
button_requisition->width = MAX (requisition.width, label_requisition.width);
guint *requisition)
{
GtkRequisition button_requisition;
- GList *children;
gtk_sheet_button_size_request (sheet,
- yyy_row_button (sheet, row),
+ g_sheet_row_get_button (sheet->row_geometry, row),
&button_requisition);
*requisition = button_requisition.height;
- children = sheet->children;
- while (children)
- {
- GtkSheetChild *child = (GtkSheetChild *)children->data;
- GtkRequisition child_requisition;
-
- if (child->attached_to_cell && child->row == row && child->col != -1 && !child->floating && !child->yshrink)
- {
- gtk_widget_get_child_requisition (child->widget, &child_requisition);
-
- if (child_requisition.height + 2 * child->ypadding > *requisition)
- *requisition = child_requisition.height + 2 * child->ypadding;
- }
- children = children->next;
- }
-
sheet->row_requisition = * requisition;
}
guint *requisition)
{
GtkRequisition button_requisition;
- GList *children;
- GtkSheetButton *button = xxx_column_button (sheet, col);
+
+ GtkSheetButton *button = g_sheet_column_get_button (sheet->column_geometry, col);
gtk_sheet_button_size_request (sheet,
button,
*requisition = button_requisition.width;
- children = sheet->children;
- while (children)
- {
- GtkSheetChild *child = (GtkSheetChild *)children->data;
- GtkRequisition child_requisition;
-
- if (child->attached_to_cell && child->col == col && child->row != -1 && !child->floating && !child->xshrink)
- {
- gtk_widget_get_child_requisition (child->widget, &child_requisition);
-
- if (child_requisition.width + 2 * child->xpadding > *requisition)
- *requisition = child_requisition.width + 2 * child->xpadding;
- }
- children = children->next;
- }
-
sheet->column_requisition = *requisition;
}
-void
-gtk_sheet_move_child (GtkSheet *sheet, GtkWidget *widget, gint x, gint y)
-{
- GtkSheetChild *child;
- GList *children;
-
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- children = sheet->children;
- while (children)
- {
- child = children->data;
-
- if (child->widget == widget)
- {
- child->x = x;
- child->y = y;
- child->row = ROW_FROM_YPIXEL (sheet, y);
- child->col = COLUMN_FROM_XPIXEL (sheet, x);
- gtk_sheet_position_child (sheet, child);
- return;
- }
-
- children = children->next;
- }
-
- g_warning ("Widget must be a GtkSheet child");
-
-}
-
-static void
-gtk_sheet_position_child (GtkSheet *sheet, GtkSheetChild *child)
-{
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
- gint xoffset = 0;
- gint yoffset = 0;
- gint x = 0, y = 0;
- GdkRectangle area;
-
- gtk_widget_get_child_requisition (child->widget, &child_requisition);
-
- if (sheet->column_titles_visible)
- yoffset = sheet->column_title_area.height;
-
- if (sheet->row_titles_visible)
- xoffset = sheet->row_title_area.width;
-
- if (child->attached_to_cell)
- {
- gtk_sheet_get_cell_area (sheet, child->row, child->col, &area);
- child->x = area.x + child->xpadding;
- child->y = area.y + child->ypadding;
-
- if (!child->floating)
- {
- if (child_requisition.width + 2 * child->xpadding <= xxx_column_width (sheet, child->col))
- {
- if (child->xfill)
- {
- child_requisition.width = child_allocation.width = xxx_column_width (sheet, child->col) - 2 * child->xpadding;
- }
- else
- {
- if (child->xexpand)
- {
- child->x = area.x + xxx_column_width (sheet, child->col) / 2 -
- child_requisition.width / 2;
- }
- child_allocation.width = child_requisition.width;
- }
- }
- else
- {
- if (!child->xshrink)
- {
- gtk_sheet_set_column_width (sheet, child->col, child_requisition.width + 2 * child->xpadding);
- }
- child_allocation.width = xxx_column_width (sheet, child->col) - 2 * child->xpadding;
- }
-
- if (child_requisition.height +
- 2 * child->ypadding <= yyy_row_height (sheet, child->row))
- {
- if (child->yfill)
- {
- child_requisition.height = child_allocation.height =
- yyy_row_height (sheet, child->row) - 2 * child->ypadding;
- }
- else
- {
- if (child->yexpand)
- {
- child->y = area.y + yyy_row_height (sheet, child->row) / 2
- - child_requisition.height / 2;
- }
- child_allocation.height = child_requisition.height;
- }
- }
- else
- {
- if (!child->yshrink)
- {
- gtk_sheet_set_row_height (sheet, child->row, child_requisition.height + 2 * child->ypadding);
- }
- child_allocation.height = yyy_row_height (sheet, child->row) -
- 2 * child->ypadding;
- }
- }
- else
- {
- child_allocation.width = child_requisition.width;
- child_allocation.height = child_requisition.height;
- }
-
- x = child_allocation.x = child->x + xoffset;
- y = child_allocation.y = child->y + yoffset;
- }
- else
- {
- x = child_allocation.x = child->x + sheet->hoffset + xoffset;
- x = child_allocation.x = child->x + xoffset;
- y = child_allocation.y = child->y + sheet->voffset + yoffset;
- y = child_allocation.y = child->y + yoffset;
- child_allocation.width = child_requisition.width;
- child_allocation.height = child_requisition.height;
- }
-
- gtk_widget_size_allocate (child->widget, &child_allocation);
- gtk_widget_queue_draw (child->widget);
-}
static void
gtk_sheet_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data)
{
- GtkSheet *sheet;
- GtkSheetChild *child;
- GList *children;
+ GtkSheet *sheet = GTK_SHEET (container);
- g_return_if_fail (GTK_IS_SHEET (container));
g_return_if_fail (callback != NULL);
- sheet = GTK_SHEET (container);
- children = sheet->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- (* callback) (child->widget, callback_data);
- }
-
if (sheet->button && sheet->button->parent)
(* callback) (sheet->button, callback_data);
}
-static void
-gtk_sheet_position_children (GtkSheet *sheet)
-{
- GList *children;
- GtkSheetChild *child;
-
- children = sheet->children;
-
- while (children)
- {
- child = (GtkSheetChild *)children->data;
-
- if (child->col != -1 && child->row != -1)
- gtk_sheet_position_child (sheet, child);
-
- if (child->row == -1)
- {
- if (child->col < MIN_VISIBLE_COLUMN (sheet) ||
- child->col > MAX_VISIBLE_COLUMN (sheet))
- gtk_sheet_child_hide (child);
- else
- gtk_sheet_child_show (child);
- }
- if (child->col == -1)
- {
- if (child->row < MIN_VISIBLE_ROW (sheet) ||
- child->row > MAX_VISIBLE_ROW (sheet))
- gtk_sheet_child_hide (child);
- else
- gtk_sheet_child_show (child);
- }
-
- children = children->next;
- }
-}
-
-static void
-gtk_sheet_remove (GtkContainer *container, GtkWidget *widget)
-{
- GtkSheet *sheet;
- GList *children;
- GtkSheetChild *child = 0;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GTK_IS_SHEET (container));
-
- sheet = GTK_SHEET (container);
-
- children = sheet->children;
-
- while (children)
- {
- child = (GtkSheetChild *)children->data;
-
- if (child->widget == widget) break;
-
- children = children->next;
- }
-
- if (children)
- {
- gtk_widget_unparent (widget);
- child->widget = NULL;
-
- sheet->children = g_list_remove_link (sheet->children, children);
- g_list_free_1 (children);
- g_free (child);
- }
-
- gtk_widget_unparent (sheet->button);
-}
-
-static void
-gtk_sheet_realize_child (GtkSheet *sheet, GtkSheetChild *child)
-{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (sheet);
-
- if (GTK_WIDGET_REALIZED (widget))
- {
- if (child->row == -1)
- gtk_widget_set_parent_window (child->widget, sheet->column_title_window);
- else if (child->col == -1)
- gtk_widget_set_parent_window (child->widget, sheet->row_title_window);
- else
- gtk_widget_set_parent_window (child->widget, sheet->sheet_window);
- }
-
- gtk_widget_set_parent (child->widget, widget);
-}
-
-
-
-GtkSheetChild *
-gtk_sheet_get_child_at (GtkSheet *sheet, gint row, gint col)
-{
- GList *children;
- GtkSheetChild *child = 0;
-
- g_return_val_if_fail (sheet != NULL, NULL);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
-
- children = sheet->children;
-
- while (children)
- {
- child = (GtkSheetChild *)children->data;
-
- if (child->attached_to_cell)
- if (child->row == row && child->col == col) break;
-
- children = children->next;
- }
-
- if (children) return child;
-
- return NULL;
-}
-
-static void
-gtk_sheet_child_hide (GtkSheetChild *child)
-{
- g_return_if_fail (child != NULL);
- gtk_widget_hide (child->widget);
-}
-
-static void
-gtk_sheet_child_show (GtkSheetChild *child)
-{
- g_return_if_fail (child != NULL);
-
- gtk_widget_show (child->widget);
-}
-
GSheetModel *
gtk_sheet_get_model (const GtkSheet *sheet)
{
button->state = GTK_STATE_NORMAL;
button->label = NULL;
button->label_visible = TRUE;
- button->child = NULL;
button->justification = GTK_JUSTIFY_FILL;
return button;
g_free (celltext);
}
+
static GString *
range_to_text (const GtkSheet *sheet)
{
gtk_clipboard_clear (clipboard);
}
}
-