From bf41b320c23b395b96a00e35375f7aeb7a9046d3 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 12 Jul 2008 13:48:37 +0800 Subject: [PATCH] Start of new branch involving major rewrite of lib/gtksheet/* Hopefully this should fix many bugs with the variable/data sheet display. --- lib/gtksheet/gsheet-column-iface.h | 3 +- lib/gtksheet/gsheet-hetero-column.c | 1 - lib/gtksheet/gsheet-row-iface.c | 1 - lib/gtksheet/gsheet-row-iface.h | 3 - lib/gtksheet/gtkextra-sheet.h | 22 - lib/gtksheet/gtksheet.c | 2962 +++++++-------------------- lib/gtksheet/gtksheet.h | 344 +--- po/en_GB.po | 444 ++-- src/ui/gui/psppire-data-editor.c | 49 + src/ui/gui/psppire-data-store.c | 8 +- 10 files changed, 1075 insertions(+), 2762 deletions(-) diff --git a/lib/gtksheet/gsheet-column-iface.h b/lib/gtksheet/gsheet-column-iface.h index 5503393a..4ad1d3fc 100644 --- a/lib/gtksheet/gsheet-column-iface.h +++ b/lib/gtksheet/gsheet-column-iface.h @@ -76,8 +76,7 @@ struct _GSheetColumnIface gboolean (*get_button_visibility)(const GSheetColumn *geo, glong col); - const GtkSheetChild * (*get_button_child)(const GSheetColumn *geo, - glong col); + GtkJustification * (*get_button_justification)(const GSheetColumn *geo, glong col); }; diff --git a/lib/gtksheet/gsheet-hetero-column.c b/lib/gtksheet/gsheet-hetero-column.c index ecc06cc5..1344b839 100644 --- a/lib/gtksheet/gsheet-hetero-column.c +++ b/lib/gtksheet/gsheet-hetero-column.c @@ -165,7 +165,6 @@ g_sheet_hetero_column_class_init (GSheetHeteroColumnClass *class) object_class->finalize = g_sheet_hetero_column_finalize; default_button.label=NULL; - default_button.child=NULL; default_button.state=GTK_STATE_NORMAL; default_button.justification=GTK_JUSTIFY_CENTER; default_button.label_visible = TRUE; diff --git a/lib/gtksheet/gsheet-row-iface.c b/lib/gtksheet/gsheet-row-iface.c index 1512737f..81bc56bb 100644 --- a/lib/gtksheet/gsheet-row-iface.c +++ b/lib/gtksheet/gsheet-row-iface.c @@ -96,7 +96,6 @@ g_sheet_row_base_init (gpointer g_class) default_button.state = GTK_STATE_NORMAL; default_button.label = NULL; default_button.label_visible = TRUE; - default_button.child = NULL; default_button.justification = GTK_JUSTIFY_FILL; initialized = TRUE; diff --git a/lib/gtksheet/gsheet-row-iface.h b/lib/gtksheet/gsheet-row-iface.h index 921f3699..ded46671 100644 --- a/lib/gtksheet/gsheet-row-iface.h +++ b/lib/gtksheet/gsheet-row-iface.h @@ -70,9 +70,6 @@ struct _GSheetRowIface gboolean (*get_button_visibility) (const GSheetRow *geo, glong row); - const GtkSheetChild * (*get_button_child) (const GSheetRow *geo, - glong row); - guint (*top_ypixel) (const GSheetRow *geo, glong row); glong (*pixel_to_row) (const GSheetRow *geo, guint pixel); }; diff --git a/lib/gtksheet/gtkextra-sheet.h b/lib/gtksheet/gtkextra-sheet.h index 0a5fb70f..ae13c6a9 100644 --- a/lib/gtksheet/gtkextra-sheet.h +++ b/lib/gtksheet/gtkextra-sheet.h @@ -32,34 +32,12 @@ struct _GtkSheet ; typedef struct _GtkSheet GtkSheet; -struct _GtkSheetChild -{ - GtkWidget *widget; - gint x,y ; - gboolean attached_to_cell; - gboolean floating; - gint row, col; - guint16 xpadding; - guint16 ypadding; - gboolean xexpand; - gboolean yexpand; - gboolean xshrink; - gboolean yshrink; - gboolean xfill; - gboolean yfill; -}; - -typedef struct _GtkSheetChild GtkSheetChild; - - - struct _GtkSheetButton { GtkStateType state; gchar *label; gboolean label_visible; - GtkSheetChild *child; GtkJustification justification; }; diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index 942b0233..ec8e3840 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -34,15 +34,8 @@ * * 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 @@ -53,12 +46,8 @@ #include #include #include -#include #include #include -#include -#include -#include #include #include #include @@ -72,20 +61,18 @@ /* 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) @@ -94,10 +81,10 @@ enum #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); @@ -106,7 +93,10 @@ static void gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column); 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) @@ -137,7 +127,7 @@ guint DEFAULT_ROW_HEIGHT (GtkWidget *widget) pango_font_metrics_unref (metrics); - return PANGO_PIXELS (val) + 2 * CELLOFFSET; + return PANGO_PIXELS (val) + 2 * COLUMN_TITLES_HEIGHT; } } @@ -192,306 +182,85 @@ guint DEFAULT_FONT_DESCENT (GtkWidget *widget) } -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; } @@ -499,22 +268,23 @@ static inline gboolean 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; } @@ -531,20 +301,20 @@ POSSIBLE_DRAG (const GtkSheet *sheet, gint x, gint y, 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; @@ -552,9 +322,9 @@ POSSIBLE_DRAG (const GtkSheet *sheet, gint x, gint y, } } - 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) @@ -563,7 +333,7 @@ POSSIBLE_DRAG (const GtkSheet *sheet, gint x, gint y, 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; @@ -586,19 +356,19 @@ POSSIBLE_RESIZE (const GtkSheet *sheet, gint x, gint y, 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; @@ -633,6 +403,8 @@ static gint gtk_sheet_button_release (GtkWidget * widget, 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, @@ -680,9 +452,6 @@ static void gtk_sheet_new_selection (GtkSheet *sheet, 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 */ @@ -701,8 +470,8 @@ static void gtk_sheet_click_cell (GtkSheet *sheet, /* 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 */ @@ -748,7 +517,8 @@ static void gtk_sheet_button_size_request (GtkSheet *sheet, GtkRequisition *requisition); /* Attributes routines */ -static void init_attributes (const GtkSheet *sheet, gint col, +static void init_attributes (const GtkSheet *sheet, + gint col, GtkSheetCellAttr *attributes); @@ -761,16 +531,6 @@ static void gtk_sheet_real_cell_clear (GtkSheet *sheet, 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); @@ -826,8 +586,9 @@ gtk_sheet_get_type () (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; @@ -872,7 +633,8 @@ gtk_sheet_range_get_type (void) } -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 @@ -968,8 +730,8 @@ gtk_sheet_class_init (GtkSheetClass * klass) 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); @@ -1176,7 +938,7 @@ gtk_sheet_class_init (GtkSheetClass * 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; @@ -1226,6 +988,8 @@ gtk_sheet_class_init (GtkSheetClass * klass) 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; @@ -1252,11 +1016,8 @@ gtk_sheet_init (GtkSheet *sheet) 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); @@ -1296,25 +1057,16 @@ gtk_sheet_init (GtkSheet *sheet) 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; @@ -1357,8 +1109,8 @@ columns_inserted_deleted_callback (GSheetModel *model, gint first_column, */ 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); @@ -1389,8 +1141,8 @@ rows_inserted_deleted_callback (GSheetModel *model, gint first_row, */ 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); @@ -1535,10 +1287,9 @@ column_titles_changed (GtkWidget *w, gint first, gint n_columns, gpointer data) 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 ) @@ -1590,7 +1341,6 @@ gtk_sheet_show_grid (GtkSheet *sheet, gboolean show) sheet->show_grid = show; - if (!GTK_SHEET_IS_FROZEN (sheet)) gtk_sheet_range_draw (sheet, NULL); } @@ -1617,7 +1367,6 @@ gtk_sheet_set_background (GtkSheet *sheet, GdkColor *color) else sheet->bg_color = *color; - if (!GTK_SHEET_IS_FROZEN (sheet)) gtk_sheet_range_draw (sheet, NULL); } @@ -1635,7 +1384,6 @@ gtk_sheet_set_grid (GtkSheet *sheet, GdkColor *color) else sheet->grid_color = *color; - if (!GTK_SHEET_IS_FROZEN (sheet)) gtk_sheet_range_draw (sheet, NULL); } @@ -1645,7 +1393,7 @@ gtk_sheet_get_columns_count (GtkSheet *sheet) 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 @@ -1654,16 +1402,7 @@ gtk_sheet_get_rows_count (GtkSheet *sheet) 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 @@ -1710,9 +1449,9 @@ gtk_sheet_autoresize_column (GtkSheet *sheet, gint column) 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) @@ -1725,14 +1464,14 @@ gtk_sheet_autoresize_column (GtkSheet *sheet, gint column) 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); @@ -1778,51 +1517,6 @@ gtk_sheet_justify_entry (GtkSheet *sheet) } - -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) { @@ -1832,7 +1526,6 @@ 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"); @@ -1848,7 +1541,6 @@ gtk_sheet_set_column_titles_height (GtkSheet *sheet, guint height) adjust_scrollbars (sheet); - sheet->old_vadjustment = -1.; if (sheet->vadjustment) g_signal_emit_by_name (sheet->vadjustment, "value_changed"); @@ -1858,15 +1550,13 @@ gtk_sheet_set_column_titles_height (GtkSheet *sheet, guint height) 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, @@ -1874,20 +1564,8 @@ gtk_sheet_show_column_titles (GtkSheet *sheet) 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"); @@ -1898,8 +1576,6 @@ gtk_sheet_show_column_titles (GtkSheet *sheet) void gtk_sheet_show_row_titles (GtkSheet *sheet) { - gint row; - if (sheet->row_titles_visible) return; sheet->row_titles_visible = TRUE; @@ -1914,22 +1590,9 @@ gtk_sheet_show_row_titles (GtkSheet *sheet) 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"); @@ -1939,8 +1602,6 @@ gtk_sheet_show_row_titles (GtkSheet *sheet) void gtk_sheet_hide_column_titles (GtkSheet *sheet) { - gint col; - if (!sheet->column_titles_visible) return; sheet->column_titles_visible = FALSE; @@ -1952,20 +1613,9 @@ gtk_sheet_hide_column_titles (GtkSheet *sheet) 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"); @@ -1974,53 +1624,26 @@ gtk_sheet_hide_column_titles (GtkSheet *sheet) 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, @@ -2039,9 +1662,9 @@ 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; @@ -2050,9 +1673,9 @@ gtk_sheet_moveto (GtkSheet *sheet, /* 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; @@ -2061,8 +1684,8 @@ gtk_sheet_moveto (GtkSheet *sheet, { 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) { @@ -2074,8 +1697,8 @@ gtk_sheet_moveto (GtkSheet *sheet, 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) @@ -2083,7 +1706,6 @@ gtk_sheet_moveto (GtkSheet *sheet, else sheet->vadjustment->value = y; - sheet->old_vadjustment = -1.; g_signal_emit_by_name (sheet->vadjustment, "value_changed"); @@ -2092,9 +1714,9 @@ gtk_sheet_moveto (GtkSheet *sheet, /* 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; @@ -2103,8 +1725,8 @@ gtk_sheet_moveto (GtkSheet *sheet, { 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) { @@ -2113,8 +1735,8 @@ gtk_sheet_moveto (GtkSheet *sheet, 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) @@ -2122,7 +1744,6 @@ gtk_sheet_moveto (GtkSheet *sheet, else sheet->hadjustment->value = x; - sheet->old_vadjustment = -1.; g_signal_emit_by_name (sheet->hadjustment, "value_changed"); } @@ -2168,13 +1789,12 @@ gtk_sheet_rows_resizable (GtkSheet *sheet) 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) @@ -2186,7 +1806,7 @@ gtk_sheet_select_row (GtkSheet * sheet, 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; @@ -2201,7 +1821,7 @@ gtk_sheet_select_column (GtkSheet * sheet, gint column) 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) @@ -2213,7 +1833,7 @@ gtk_sheet_select_column (GtkSheet * sheet, gint column) 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; @@ -2231,16 +1851,16 @@ gtk_sheet_range_isvisible (const GtkSheet * sheet, { 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)) @@ -2285,126 +1905,35 @@ gtk_sheet_get_visible_range (GtkSheet *sheet, GtkSheetRange *range) 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 @@ -2425,7 +1954,6 @@ 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)); @@ -2469,16 +1997,6 @@ gtk_sheet_dispose (GObject *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); } @@ -2512,8 +2030,6 @@ gtk_sheet_realize (GtkWidget * widget) 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)); @@ -2537,6 +2053,8 @@ gtk_sheet_realize (GtkWidget * 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 | @@ -2553,39 +2071,49 @@ gtk_sheet_realize (GtkWidget * widget) 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); @@ -2594,13 +2122,9 @@ gtk_sheet_realize (GtkWidget * widget) 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); @@ -2611,13 +2135,15 @@ gtk_sheet_realize (GtkWidget * widget) 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); @@ -2627,7 +2153,6 @@ gtk_sheet_realize (GtkWidget * widget) 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) @@ -2635,18 +2160,11 @@ gtk_sheet_realize (GtkWidget * widget) 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); } @@ -2703,11 +2221,20 @@ gtk_sheet_unrealize (GtkWidget * widget) 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); @@ -2718,12 +2245,6 @@ gtk_sheet_unrealize (GtkWidget * widget) 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); @@ -2736,8 +2257,6 @@ static void 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)); @@ -2784,38 +2303,17 @@ gtk_sheet_map (GtkWidget * 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); @@ -2830,28 +2328,12 @@ gtk_sheet_unmap (GtkWidget * widget) 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; @@ -2861,12 +2343,10 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col) /* 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); @@ -2877,18 +2357,14 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col) 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); @@ -2904,6 +2380,7 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col) } } + static void gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) { @@ -2935,11 +2412,10 @@ 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); @@ -2952,10 +2428,14 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) 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); @@ -2983,7 +2463,7 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) 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) @@ -2991,7 +2471,7 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) 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) { @@ -3002,16 +2482,16 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) 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: @@ -3023,25 +2503,25 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) { 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: @@ -3051,12 +2531,12 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) 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; @@ -3069,23 +2549,13 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) 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 @@ -3093,7 +2563,6 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) { gint i, j; GtkSheetRange drawing_range; - GdkRectangle area; g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_SHEET (sheet)); @@ -3102,15 +2571,19 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) 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, @@ -3126,61 +2599,6 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) 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++) { @@ -3234,13 +2652,23 @@ gtk_sheet_range_draw_selection (GtkSheet *sheet, GtkSheetRange range) { 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) { @@ -3274,73 +2702,27 @@ gtk_sheet_range_draw_selection (GtkSheet *sheet, GtkSheetRange range) 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) @@ -3351,7 +2733,7 @@ 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) @@ -3366,7 +2748,7 @@ gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col, 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); @@ -3403,15 +2785,14 @@ gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col, 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); } @@ -3428,8 +2809,8 @@ gtk_sheet_cell_clear (GtkSheet *sheet, gint row, gint column) 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; @@ -3440,11 +2821,8 @@ gtk_sheet_cell_clear (GtkSheet *sheet, gint row, gint column) 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) @@ -3479,17 +2857,17 @@ gtk_sheet_real_range_clear (GtkSheet *sheet, const GtkSheetRange *range) 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++) @@ -3521,7 +2899,7 @@ gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col) 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; @@ -3542,7 +2920,7 @@ gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col) 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; @@ -3570,11 +2948,10 @@ gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col) 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, @@ -3596,28 +2973,27 @@ gtk_sheet_get_pixel_info (GtkSheet *sheet, 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; } @@ -3631,22 +3007,17 @@ gtk_sheet_get_cell_area (GtkSheet * sheet, 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; } @@ -3658,7 +3029,7 @@ gtk_sheet_set_active_cell (GtkSheet *sheet, gint row, gint column) 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))) @@ -3718,8 +3089,6 @@ gtk_sheet_entry_changed (GtkWidget *widget, gpointer data) 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); @@ -3727,9 +3096,6 @@ gtk_sheet_entry_changed (GtkWidget *widget, gpointer data) 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; } @@ -3782,9 +3148,6 @@ gtk_sheet_hide_active_cell (GtkSheet *sheet) 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); @@ -3796,21 +3159,9 @@ gtk_sheet_hide_active_cell (GtkSheet *sheet) 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 @@ -3823,7 +3174,7 @@ gtk_sheet_activate_cell (GtkSheet *sheet, gint row, gint col) 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; @@ -3844,6 +3195,8 @@ gtk_sheet_activate_cell (GtkSheet *sheet, gint row, gint col) GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION); + + gtk_sheet_show_active_cell (sheet); g_signal_connect (gtk_sheet_get_entry (sheet), @@ -3941,18 +3294,21 @@ gtk_sheet_draw_active_cell (GtkSheet *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) { @@ -3960,7 +3316,8 @@ gtk_sheet_make_backing_pixmap (GtkSheet *sheet, guint width, guint height) 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 { @@ -3973,7 +3330,7 @@ gtk_sheet_make_backing_pixmap (GtkSheet *sheet, guint width, guint height) 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); } } } @@ -4017,7 +3374,7 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) 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 || @@ -4037,10 +3394,10 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) 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) { @@ -4055,24 +3412,14 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) } 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) { @@ -4108,13 +3455,13 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) 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) { @@ -4129,15 +3476,6 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) } 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); } } } @@ -4152,14 +3490,14 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) 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) { @@ -4190,7 +3528,7 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) 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); @@ -4207,9 +3545,9 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) 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, @@ -4251,177 +3589,69 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) *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; @@ -4454,8 +3684,7 @@ gtk_sheet_real_select_range (GtkSheet * sheet, 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; @@ -4489,7 +3718,6 @@ gtk_sheet_select_range (GtkSheet * sheet, const GtkSheetRange *range) sheet->state = GTK_SHEET_RANGE_SELECTED; gtk_sheet_real_select_range (sheet, NULL); - } void @@ -4529,8 +3757,6 @@ gtk_sheet_real_unselect_range (GtkSheet * sheet, sheet->range.rowi = -1; sheet->range.col0 = -1; sheet->range.coli = -1; - - gtk_sheet_position_children (sheet); } @@ -4545,15 +3771,23 @@ gtk_sheet_expose (GtkWidget * widget, 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 && @@ -4568,7 +3802,9 @@ gtk_sheet_expose (GtkWidget * widget, 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); } @@ -4664,8 +3900,15 @@ gtk_sheet_button_press (GtkWidget * widget, 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) @@ -4794,9 +4037,14 @@ gtk_sheet_button_press (GtkWidget * widget, 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)); @@ -4808,8 +4056,13 @@ gtk_sheet_button_press (GtkWidget * widget, 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)); @@ -4826,18 +4079,21 @@ gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column, gboolean *veto) { *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, @@ -4873,8 +4129,8 @@ gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column, gboolean *veto) { 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); @@ -4919,24 +4175,24 @@ static gint 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; } @@ -4948,8 +4204,8 @@ gtk_sheet_button_release (GtkWidget * widget, 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; } @@ -5028,6 +4284,9 @@ gtk_sheet_button_release (GtkWidget * widget, return TRUE; } + + + /* Shamelessly lifted from gtktooltips */ static gboolean gtk_sheet_subtitle_paint_window (GtkWidget *tip_window) @@ -5043,10 +4302,17 @@ 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); @@ -5095,16 +4361,6 @@ show_subtitle (GtkSheet *sheet, gint row, gint column, const gchar *subtitle) 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); @@ -5150,28 +4406,25 @@ motion_timeout_callback (gpointer data) 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); } @@ -5180,9 +4433,8 @@ motion_timeout_callback (gpointer data) return FALSE; } -static gint -gtk_sheet_motion (GtkWidget * widget, - GdkEventMotion * event) +static gboolean +gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event) { GtkSheet *sheet; GdkModifierType mods; @@ -5200,11 +4452,12 @@ gtk_sheet_motion (GtkWidget * widget, 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 { @@ -5224,9 +4477,8 @@ gtk_sheet_motion (GtkWidget * widget, 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) @@ -5254,7 +4506,6 @@ gtk_sheet_motion (GtkWidget * widget, 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; @@ -5293,8 +4544,10 @@ gtk_sheet_motion (GtkWidget * widget, 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); @@ -5321,18 +4574,17 @@ gtk_sheet_motion (GtkWidget * widget, 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; } @@ -5357,14 +4609,14 @@ gtk_sheet_motion (GtkWidget * widget, { 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; @@ -5386,19 +4638,18 @@ gtk_sheet_motion (GtkWidget * widget, 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) @@ -5409,8 +4660,8 @@ gtk_sheet_motion (GtkWidget * widget, 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) @@ -5433,8 +4684,8 @@ gtk_sheet_motion (GtkWidget * widget, 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; @@ -5467,19 +4718,32 @@ gtk_sheet_motion (GtkWidget * widget, 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; @@ -5487,11 +4751,11 @@ gtk_sheet_move_query (GtkSheet *sheet, gint row, gint column) 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.; @@ -5505,11 +4769,11 @@ gtk_sheet_move_query (GtkSheet *sheet, gint row, gint column) 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.; @@ -5517,7 +4781,7 @@ gtk_sheet_move_query (GtkSheet *sheet, gint row, gint column) } if (column < MIN_VISIBLE_COLUMN (sheet) && sheet->state != GTK_SHEET_ROW_SELECTED) { - col_align = 0.; + col_align = 0.0; column_move = TRUE; } @@ -5551,10 +4815,10 @@ gtk_sheet_extend_selection (GtkSheet *sheet, gint row, gint column) 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; @@ -5564,15 +4828,6 @@ gtk_sheet_extend_selection (GtkSheet *sheet, gint row, gint column) 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; @@ -5640,10 +4895,10 @@ gtk_sheet_key_press (GtkWidget *widget, 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); @@ -5659,7 +4914,7 @@ gtk_sheet_key_press (GtkWidget *widget, 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); @@ -5672,11 +4927,11 @@ gtk_sheet_key_press (GtkWidget *widget, 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); @@ -5697,7 +4952,7 @@ gtk_sheet_key_press (GtkWidget *widget, 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); } @@ -5710,7 +4965,7 @@ gtk_sheet_key_press (GtkWidget *widget, 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; @@ -5727,26 +4982,26 @@ gtk_sheet_key_press (GtkWidget *widget, 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; @@ -5761,10 +5016,10 @@ gtk_sheet_key_press (GtkWidget *widget, 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); } @@ -5772,14 +5027,14 @@ gtk_sheet_key_press (GtkWidget *widget, } 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) { @@ -5803,7 +5058,7 @@ gtk_sheet_key_press (GtkWidget *widget, 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; @@ -5814,7 +5069,7 @@ gtk_sheet_key_press (GtkWidget *widget, 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 @@ -5828,13 +5083,13 @@ gtk_sheet_key_press (GtkWidget *widget, 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; @@ -5864,9 +5119,6 @@ gtk_sheet_size_request (GtkWidget * widget, 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)); @@ -5884,15 +5136,6 @@ gtk_sheet_size_request (GtkWidget * 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); - } } @@ -5945,10 +5188,16 @@ gtk_sheet_size_allocate (GtkWidget * widget, /* 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, @@ -5956,8 +5205,6 @@ gtk_sheet_size_allocate (GtkWidget * widget, 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); @@ -5966,7 +5213,11 @@ gtk_sheet_size_allocate (GtkWidget * widget, 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; @@ -5983,8 +5234,7 @@ gtk_sheet_size_allocate (GtkWidget * widget, 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); @@ -6000,12 +5250,12 @@ size_allocate_column_title_buttons (GtkSheet * 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; } @@ -6020,8 +5270,7 @@ size_allocate_column_title_buttons (GtkSheet * sheet) 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, @@ -6050,7 +5299,6 @@ size_allocate_row_title_buttons (GtkSheet * sheet) if (sheet->column_titles_visible) { - height -= sheet->column_title_area.height; y = sheet->column_title_area.height; } @@ -6064,7 +5312,7 @@ size_allocate_row_title_buttons (GtkSheet * sheet) 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, @@ -6076,7 +5324,7 @@ size_allocate_row_title_buttons (GtkSheet * sheet) 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); } @@ -6151,23 +5399,33 @@ gtk_sheet_size_allocate_entry (GtkSheet *sheet) 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) @@ -6176,11 +5434,11 @@ gtk_sheet_size_allocate_entry (GtkSheet *sheet) 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; } } @@ -6227,7 +5485,7 @@ gtk_sheet_entry_set_max_size (GtkSheet *sheet) 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; @@ -6239,13 +5497,13 @@ gtk_sheet_entry_set_max_size (GtkSheet *sheet) 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--) { @@ -6254,14 +5512,14 @@ gtk_sheet_entry_set_max_size (GtkSheet *sheet) 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; } @@ -6331,9 +5589,6 @@ gtk_sheet_get_entry (GtkSheet *sheet) { 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); @@ -6344,9 +5599,6 @@ gtk_sheet_get_entry (GtkSheet *sheet) 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); @@ -6355,27 +5607,6 @@ gtk_sheet_get_entry (GtkSheet *sheet) 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); @@ -6400,7 +5631,6 @@ gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *window, { GtkShadowType shadow_type; gint text_width = 0, text_height = 0; - GtkSheetChild *child = NULL; PangoAlignment align = PANGO_ALIGN_LEFT; gboolean rtl ; @@ -6412,6 +5642,7 @@ gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *window, 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, @@ -6444,11 +5675,13 @@ gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *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; @@ -6480,11 +5713,11 @@ gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *window, 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: @@ -6522,95 +5755,41 @@ gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *window, } - 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; @@ -6618,23 +5797,23 @@ gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row) 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 @@ -6649,24 +5828,41 @@ adjust_scrollbars (GtkSheet * sheet) { 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"); } } @@ -6674,268 +5870,93 @@ static void 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; @@ -6957,7 +5978,6 @@ draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range) 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, @@ -6968,38 +5988,29 @@ draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range) 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; @@ -7009,30 +6020,28 @@ new_column_width (GtkSheet * sheet, * 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; @@ -7048,15 +6057,15 @@ gtk_sheet_set_column_width (GtkSheet * sheet, 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); @@ -7079,15 +6088,15 @@ gtk_sheet_set_row_height (GtkSheet * 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); @@ -7152,7 +6161,7 @@ init_attributes (const GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) 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; @@ -7164,228 +6173,13 @@ init_attributes (const GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) 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; @@ -7422,8 +6216,8 @@ gtk_sheet_button_size_request (GtkSheet *sheet, 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 { @@ -7431,19 +6225,9 @@ gtk_sheet_button_size_request (GtkSheet *sheet, 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); @@ -7457,30 +6241,13 @@ gtk_sheet_row_size_request (GtkSheet *sheet, 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; } @@ -7490,8 +6257,8 @@ gtk_sheet_column_size_request (GtkSheet *sheet, 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, @@ -7501,157 +6268,9 @@ gtk_sheet_column_size_request (GtkSheet *sheet, *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, @@ -7659,23 +6278,10 @@ 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); @@ -7684,141 +6290,6 @@ gtk_sheet_forall (GtkContainer *container, } -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) { @@ -7836,7 +6307,6 @@ gtk_sheet_button_new (void) button->state = GTK_STATE_NORMAL; button->label = NULL; button->label_visible = TRUE; - button->child = NULL; button->justification = GTK_JUSTIFY_FILL; return button; @@ -7865,6 +6335,7 @@ append_cell_text (GString *string, const GtkSheet *sheet, gint r, gint c) g_free (celltext); } + static GString * range_to_text (const GtkSheet *sheet) { @@ -8002,4 +6473,3 @@ gtk_sheet_update_primary_selection (GtkSheet *sheet) gtk_clipboard_clear (clipboard); } } - diff --git a/lib/gtksheet/gtksheet.h b/lib/gtksheet/gtksheet.h index 4f402252..6aaa49a9 100644 --- a/lib/gtksheet/gtksheet.h +++ b/lib/gtksheet/gtksheet.h @@ -34,9 +34,7 @@ #include "gsheet-row-iface.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +G_BEGIN_DECLS typedef enum @@ -69,13 +67,9 @@ enum #define GTK_SHEET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_sheet_get_type (), GtkSheetClass) #define GTK_IS_SHEET(obj) GTK_CHECK_TYPE (obj, gtk_sheet_get_type ()) -/* Public flags, for compatibility */ -#define GTK_SHEET_ROW_FROZEN(sheet) !gtk_sheet_rows_resizable (sheet) -#define GTK_SHEET_COLUMN_FROZEN(sheet) !gtk_sheet_columns_resizable (sheet) + #define GTK_SHEET_AUTORESIZE(sheet) gtk_sheet_autoresize (sheet) -#define GTK_SHEET_ROW_TITLES_VISIBLE(sheet) gtk_sheet_row_titles_visible (sheet) -#define GTK_SHEET_COL_TITLES_VISIBLE(sheet) gtk_sheet_column_titles_visible (sheet) #define GTK_SHEET_AUTO_SCROLL(sheet) gtk_sheet_autoscroll (sheet) #define GTK_SHEET_JUSTIFY_ENTRY(sheet) gtk_sheet_justify_entry (sheet) @@ -103,6 +97,7 @@ struct _GtkSheetCell gint col; }; + struct _GtkSheetHoverTitle { GtkWidget *window; @@ -112,8 +107,7 @@ struct _GtkSheetHoverTitle struct _GtkSheet { - GtkContainer container; - + GtkBin parent; gboolean dispose_has_run; GSheetColumn *column_geometry; @@ -133,9 +127,6 @@ struct _GtkSheet GdkColor grid_color; gboolean show_grid; - /* sheet children */ - GList *children; - /* allocation rectangle after the container_border_width and the width of the shadow border */ GdkRectangle internal_allocation; @@ -180,12 +171,6 @@ struct _GtkSheet /* sheet backing pixmap */ GdkPixmap *pixmap; - /* offsets for scrolling */ - gint hoffset; - gint voffset; - gfloat old_hadjustment; - gfloat old_vadjustment; - /* border shadow style */ GtkShadowType shadow_type; @@ -193,18 +178,20 @@ struct _GtkSheet GdkRectangle column_title_area; GdkWindow *column_title_window; gboolean column_titles_visible; + /* TRUE if the cursor is over the column title window */ + gboolean column_title_under; /* Row Titles */ GdkRectangle row_title_area; GdkWindow *row_title_window; gboolean row_titles_visible; + /* TRUE if the cursor is over the row title window */ + gboolean row_title_under; /*scrollbars*/ GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; - gint freeze_count; - /* xor GC for the verticle drag line */ GdkGC *xor_gc; @@ -233,7 +220,7 @@ struct _GtkSheet struct _GtkSheetClass { - GtkContainerClass parent_class; + GtkBinClass parent_class; void (*set_scroll_adjustments) (GtkSheet *sheet, GtkAdjustment *hadjustment, @@ -275,17 +262,6 @@ GtkType gtk_sheet_range_get_type (void); GtkWidget * gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo, GSheetModel *model); - - - -/* create a new browser sheet. It cells can not be edited */ -GtkWidget * -gtk_sheet_new_browser (guint rows, guint columns, const gchar *title); - -void -gtk_sheet_construct_browser (GtkSheet *sheet, - guint rows, guint columns, const gchar *title); - /* create a new sheet with custom entry */ GtkWidget * gtk_sheet_new_with_custom_entry (GSheetRow *vgeo, @@ -296,202 +272,125 @@ gtk_sheet_construct_with_custom_entry (GtkSheet *sheet, GSheetRow *vgeo, GSheetColumn *hgeo, GtkType entry_type); -/* change scroll adjustments */ -void -gtk_sheet_set_hadjustment (GtkSheet *sheet, - GtkAdjustment *adjustment); -void -gtk_sheet_set_vadjustment (GtkSheet *sheet, - GtkAdjustment *adjustment); /* Change entry */ -void -gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type); +void gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type); -/* Returns sheet's entry widget */ -GtkWidget * -gtk_sheet_get_entry (GtkSheet *sheet); -GtkWidget * -gtk_sheet_get_entry_widget (GtkSheet *sheet); +GtkWidget *gtk_sheet_get_entry (GtkSheet *sheet); -/* Returns sheet->state - * Added by Steven Rostedt */ -gint -gtk_sheet_get_state (GtkSheet *sheet); -/* Returns sheet's ranges - * Added by Murray Cumming */ -guint -gtk_sheet_get_columns_count (GtkSheet *sheet); +guint gtk_sheet_get_columns_count (GtkSheet *sheet); -guint -gtk_sheet_get_rows_count (GtkSheet *sheet); +guint gtk_sheet_get_rows_count (GtkSheet *sheet); -void -gtk_sheet_get_visible_range (GtkSheet *sheet, +void gtk_sheet_get_selected_range (GtkSheet *sheet, GtkSheetRange *range); -void -gtk_sheet_get_selected_range (GtkSheet *sheet, - GtkSheetRange *range); +void gtk_sheet_set_selection_mode (GtkSheet *sheet, gint mode); -void -gtk_sheet_set_selection_mode (GtkSheet *sheet, gint mode); +void gtk_sheet_set_autoresize (GtkSheet *sheet, gboolean autoresize); -void -gtk_sheet_set_autoresize (GtkSheet *sheet, gboolean autoresize); +gboolean gtk_sheet_autoresize (GtkSheet *sheet); -gboolean -gtk_sheet_autoresize (GtkSheet *sheet); +void gtk_sheet_set_autoscroll (GtkSheet *sheet, gboolean autoscroll); -void -gtk_sheet_set_autoscroll (GtkSheet *sheet, gboolean autoscroll); +gboolean gtk_sheet_autoscroll (GtkSheet *sheet); -gboolean -gtk_sheet_autoscroll (GtkSheet *sheet); +void gtk_sheet_set_justify_entry (GtkSheet *sheet, gboolean justify); -void -gtk_sheet_set_justify_entry (GtkSheet *sheet, gboolean justify); +gboolean gtk_sheet_justify_entry (GtkSheet *sheet); -gboolean -gtk_sheet_justify_entry (GtkSheet *sheet); - -void -gtk_sheet_set_locked (GtkSheet *sheet, gboolean lock); - -gboolean -gtk_sheet_locked (const GtkSheet *sheet); - -/* set sheet title */ -void -gtk_sheet_set_title (GtkSheet *sheet, const gchar *title); - -/* freeze all visual updates of the sheet. - * Then thaw the sheet after you have made a number of changes. - * The updates will occure in a more efficent way than if - * you made them on a unfrozen sheet */ -void -gtk_sheet_freeze (GtkSheet *sheet); -void -gtk_sheet_thaw (GtkSheet *sheet); /* Background colors */ -void -gtk_sheet_set_background (GtkSheet *sheet, +void gtk_sheet_set_background (GtkSheet *sheet, GdkColor *bg_color); -void -gtk_sheet_set_grid (GtkSheet *sheet, + +void gtk_sheet_set_grid (GtkSheet *sheet, GdkColor *grid_color); -void -gtk_sheet_show_grid (GtkSheet *sheet, + +void gtk_sheet_show_grid (GtkSheet *sheet, gboolean show); -gboolean -gtk_sheet_grid_visible (GtkSheet *sheet); + +gboolean gtk_sheet_grid_visible (GtkSheet *sheet); /* set/get column title */ -void -gtk_sheet_set_column_title (GtkSheet * sheet, +void gtk_sheet_set_column_title (GtkSheet * sheet, gint column, const gchar * title); -const gchar * -gtk_sheet_get_column_title (GtkSheet * sheet, +const gchar *gtk_sheet_get_column_title (GtkSheet * sheet, gint column); /* set/get row title */ -void -gtk_sheet_set_row_title (GtkSheet * sheet, +void gtk_sheet_set_row_title (GtkSheet * sheet, gint row, const gchar * title); -const gchar * -gtk_sheet_get_row_title (GtkSheet * sheet, - gint row); +const gchar *gtk_sheet_get_row_title (GtkSheet * sheet, + gint row); /* set/get button label */ -void -gtk_sheet_row_button_add_label (GtkSheet *sheet, +void gtk_sheet_row_button_add_label (GtkSheet *sheet, gint row, const gchar *label); -const gchar * -gtk_sheet_row_button_get_label (GtkSheet *sheet, - gint row); -void -gtk_sheet_row_button_justify (GtkSheet *sheet, - gint row, GtkJustification justification); +const gchar *gtk_sheet_row_button_get_label (GtkSheet *sheet, + gint row); +void gtk_sheet_row_button_justify (GtkSheet *sheet, + gint row, GtkJustification justification); /* scroll the viewing area of the sheet to the given column * and row; row_align and col_align are between 0-1 representing the * location the row should appear on the screen, 0.0 being top or left, * 1.0 being bottom or right; if row or column is negative then there * is no change */ -void -gtk_sheet_moveto (GtkSheet *sheet, +void gtk_sheet_moveto (GtkSheet *sheet, gint row, gint column, gfloat row_align, gfloat col_align); -void -gtk_sheet_show_row_titles (GtkSheet *sheet); -void -gtk_sheet_hide_row_titles (GtkSheet *sheet); -void -gtk_sheet_show_column_titles (GtkSheet *sheet); -void -gtk_sheet_hide_column_titles (GtkSheet *sheet); +void gtk_sheet_show_row_titles (GtkSheet *sheet); +void gtk_sheet_hide_row_titles (GtkSheet *sheet); +void gtk_sheet_show_column_titles (GtkSheet *sheet); +void gtk_sheet_hide_column_titles (GtkSheet *sheet); -gboolean -gtk_sheet_row_titles_visible (GtkSheet *sheet); +gboolean gtk_sheet_row_titles_visible (GtkSheet *sheet); /* set row button sensitivity. If sensitivity is TRUE can be toggled, * otherwise it acts as a title */ -void -gtk_sheet_row_set_sensitivity (GtkSheet *sheet, +void gtk_sheet_row_set_sensitivity (GtkSheet *sheet, gint row, gboolean sensitive); /* set sensitivity for all row buttons */ -void -gtk_sheet_rows_set_sensitivity (GtkSheet *sheet, gboolean sensitive); -void -gtk_sheet_rows_set_resizable (GtkSheet *sheet, gboolean resizable); -gboolean -gtk_sheet_rows_resizable (GtkSheet *sheet); +void gtk_sheet_rows_set_sensitivity (GtkSheet *sheet, gboolean sensitive); +void gtk_sheet_rows_set_resizable (GtkSheet *sheet, gboolean resizable); +gboolean gtk_sheet_rows_resizable (GtkSheet *sheet); /* set row visibility. The default value is TRUE. If FALSE, the * row is hidden */ -void -gtk_sheet_row_set_visibility (GtkSheet *sheet, +void gtk_sheet_row_set_visibility (GtkSheet *sheet, gint row, gboolean visible); -void -gtk_sheet_row_label_set_visibility (GtkSheet *sheet, + +void gtk_sheet_row_label_set_visibility (GtkSheet *sheet, gint row, gboolean visible); -void -gtk_sheet_rows_labels_set_visibility (GtkSheet *sheet, gboolean visible); + +void gtk_sheet_rows_labels_set_visibility (GtkSheet *sheet, gboolean visible); /* select the row. The range is then highlighted, and the bounds are stored * in sheet->range */ -void -gtk_sheet_select_row (GtkSheet * sheet, - gint row); +void gtk_sheet_select_row (GtkSheet * sheet, gint row); /* select the column. The range is then highlighted, and the bounds are stored * in sheet->range */ -void -gtk_sheet_select_column (GtkSheet * sheet, - gint column); - -/* get scrollbars adjustment */ -GtkAdjustment * -gtk_sheet_get_vadjustment (GtkSheet * sheet); -GtkAdjustment * -gtk_sheet_get_hadjustment (GtkSheet * sheet); +void gtk_sheet_select_column (GtkSheet * sheet, gint column); /* highlight the selected range and store bounds in sheet->range */ -void gtk_sheet_select_range (GtkSheet *sheet, - const GtkSheetRange *range); +void gtk_sheet_select_range (GtkSheet *sheet, const GtkSheetRange *range); + +void gtk_sheet_get_visible_range (GtkSheet *sheet, GtkSheetRange *range); + /* obvious */ void gtk_sheet_unselect_range (GtkSheet *sheet); @@ -499,112 +398,79 @@ void gtk_sheet_unselect_range (GtkSheet *sheet); /* set active cell where the entry will be displayed * returns FALSE if current cell can't be deactivated or * requested cell can't be activated */ -gboolean -gtk_sheet_set_active_cell (GtkSheet *sheet, +gboolean gtk_sheet_set_active_cell (GtkSheet *sheet, gint row, gint column); /* Sets *ROW and *COLUMN to be the coordinates of the active cell. ROW and/or COLUMN may be null if the caller is not interested in their values */ -void -gtk_sheet_get_active_cell (GtkSheet *sheet, +void gtk_sheet_get_active_cell (GtkSheet *sheet, gint *row, gint *column); -/* set cell contents and allocate memory if needed */ -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); /* get cell contents */ -gchar * -gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col); +gchar *gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col); /* clear cell contents */ -void -gtk_sheet_cell_clear (GtkSheet *sheet, gint row, gint col); +void gtk_sheet_cell_clear (GtkSheet *sheet, gint row, gint col); /* clear range contents. If range==NULL the whole sheet will be cleared */ -void -gtk_sheet_range_clear (GtkSheet *sheet, +void gtk_sheet_range_clear (GtkSheet *sheet, const GtkSheetRange *range); /* get cell state: GTK_STATE_NORMAL, GTK_STATE_SELECTED */ -GtkStateType -gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col); - -/* get row and column correspondig to the given position in the screen */ -gboolean -gtk_sheet_get_pixel_info (GtkSheet * sheet, - gint x, - gint y, - gint * row, - gint * column); +GtkStateType gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col); /* get area of a given cell */ -gboolean -gtk_sheet_get_cell_area (GtkSheet *sheet, +gboolean gtk_sheet_get_cell_area (GtkSheet *sheet, gint row, gint column, GdkRectangle *area); /* set row height */ -void -gtk_sheet_set_row_height (GtkSheet * sheet, +void gtk_sheet_set_row_height (GtkSheet * sheet, gint row, guint height); /* delete nrows rows starting in row */ -void -gtk_sheet_delete_rows (GtkSheet *sheet, guint row, guint nrows); +void gtk_sheet_delete_rows (GtkSheet *sheet, guint row, guint nrows); /* append nrows row to the end of the sheet */ -void -gtk_sheet_add_row (GtkSheet *sheet, guint nrows); +void gtk_sheet_add_row (GtkSheet *sheet, guint nrows); /* insert nrows rows before the given row and pull right */ -void -gtk_sheet_insert_rows (GtkSheet *sheet, guint row, guint nrows); +void gtk_sheet_insert_rows (GtkSheet *sheet, guint row, guint nrows); /* set abckground color of the given range */ -void -gtk_sheet_range_set_background (GtkSheet *sheet, +void gtk_sheet_range_set_background (GtkSheet *sheet, const GtkSheetRange *range, const GdkColor *color); /* set foreground color (text color) of the given range */ -void -gtk_sheet_range_set_foreground (GtkSheet *sheet, +void gtk_sheet_range_set_foreground (GtkSheet *sheet, const GtkSheetRange *range, const GdkColor *color); /* set text justification (GTK_JUSTIFY_LEFT, RIGHT, CENTER) of the given range. * The default value is GTK_JUSTIFY_LEFT. If autoformat is on, the * default justification for numbers is GTK_JUSTIFY_RIGHT */ -void -gtk_sheet_range_set_justification (GtkSheet *sheet, +void gtk_sheet_range_set_justification (GtkSheet *sheet, const GtkSheetRange *range, GtkJustification justification); -void -gtk_sheet_column_set_justification (GtkSheet *sheet, + +void gtk_sheet_column_set_justification (GtkSheet *sheet, gint column, GtkJustification justification); + /* set if cell contents can be edited or not in the given range: * accepted values are TRUE or FALSE. */ -void -gtk_sheet_range_set_editable (GtkSheet *sheet, +void gtk_sheet_range_set_editable (GtkSheet *sheet, const GtkSheetRange *range, gint editable); /* set if cell contents are visible or not in the given range: * accepted values are TRUE or FALSE.*/ -void -gtk_sheet_range_set_visible (GtkSheet *sheet, +void gtk_sheet_range_set_visible (GtkSheet *sheet, const GtkSheetRange *range, gboolean visible); @@ -613,80 +479,36 @@ gtk_sheet_range_set_visible (GtkSheet *sheet, * CELL_BOTTOM_BORDER * width is the width of the border line in pixels * line_style is the line_style for the border line */ -void -gtk_sheet_range_set_border (GtkSheet *sheet, +void gtk_sheet_range_set_border (GtkSheet *sheet, const GtkSheetRange *range, gint mask, guint width, gint line_style); /* set border color for the given range */ -void -gtk_sheet_range_set_border_color (GtkSheet *sheet, +void gtk_sheet_range_set_border_color (GtkSheet *sheet, const GtkSheetRange *range, const GdkColor *color); /* set font for the given range */ -void -gtk_sheet_range_set_font (GtkSheet *sheet, +void gtk_sheet_range_set_font (GtkSheet *sheet, const GtkSheetRange *range, PangoFontDescription *font); /* get cell attributes of the given cell */ /* TRUE means that the cell is currently allocated */ -gboolean -gtk_sheet_get_attributes (const GtkSheet *sheet, +gboolean gtk_sheet_get_attributes (const GtkSheet *sheet, gint row, gint col, GtkSheetCellAttr *attributes); -GtkSheetChild * -gtk_sheet_put (GtkSheet *sheet, - GtkWidget *widget, - gint x, gint y); -void -gtk_sheet_attach_floating (GtkSheet *sheet, - GtkWidget *widget, - gint row, gint col); -void -gtk_sheet_attach_default (GtkSheet *sheet, - GtkWidget *widget, - gint row, gint col); -void -gtk_sheet_attach (GtkSheet *sheet, - GtkWidget *widget, - gint row, gint col, - gint xoptions, - gint yoptions, - gint xpadding, - gint ypadding); - - -void -gtk_sheet_move_child (GtkSheet *sheet, - GtkWidget *widget, - gint x, gint y); - -GtkSheetChild * -gtk_sheet_get_child_at (GtkSheet *sheet, - gint row, gint col); - -void -gtk_sheet_button_attach (GtkSheet *sheet, - GtkWidget *widget, - gint row, gint col); - - - void gtk_sheet_set_model (GtkSheet *sheet, GSheetModel *model); GSheetModel * gtk_sheet_get_model (const GtkSheet *sheet); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __GTK_SHEET_H__ */ diff --git a/po/en_GB.po b/po/en_GB.po index bf073926..e880e8fd 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.3\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2008-06-07 23:34-0700\n" +"POT-Creation-Date: 2008-07-12 13:32+0800\n" "PO-Revision-Date: 2007-09-15 08:29+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -44,6 +44,12 @@ msgstr "" msgid "Date %04d-%d-%d is before the earliest acceptable date of 1582-10-15." msgstr "" +#: src/data/casereader-filter.c:221 +msgid "" +"At least one case in the data read had a weight value that was user-missing, " +"system-missing, zero, or negative. These case(s) were ignored." +msgstr "" + #: src/data/case-tmpfile.c:57 #, c-format msgid "failed to create temporary file" @@ -69,12 +75,6 @@ msgstr "" msgid "writing to temporary file" msgstr "" -#: src/data/casereader-filter.c:221 -msgid "" -"At least one case in the data read had a weight value that was user-missing, " -"system-missing, zero, or negative. These case(s) were ignored." -msgstr "" - #: src/data/data-in.c:262 src/data/data-in.c:452 msgid "Field contents are not numeric." msgstr "" @@ -320,14 +320,14 @@ msgid "%s variables are not compatible with %s format %s." msgstr "" #: src/data/format.c:327 src/data/sys-file-reader.c:639 -#: src/ui/gui/data-editor.glade:1190 src/ui/gui/psppire-var-store.c:605 -#: src/ui/gui/psppire.glade:2176 +#: src/ui/gui/data-editor.glade:1190 src/ui/gui/psppire.glade:2176 +#: src/ui/gui/psppire-var-store.c:605 msgid "String" msgstr "" #: src/data/format.c:327 src/data/sys-file-reader.c:639 -#: src/ui/gui/data-editor.glade:1079 src/ui/gui/psppire-var-store.c:598 -#: src/ui/gui/psppire.glade:2131 +#: src/ui/gui/data-editor.glade:1079 src/ui/gui/psppire.glade:2131 +#: src/ui/gui/psppire-var-store.c:598 msgid "Numeric" msgstr "" @@ -1423,67 +1423,6 @@ msgstr "" msgid "Handle for %s not allowed here." msgstr "" -#: src/language/data-io/get-data.c:62 -#, c-format -msgid "Unsupported TYPE %s" -msgstr "" - -#: src/language/data-io/get-data.c:258 -#, c-format -msgid "" -"%s is allowed only with %s arrangement, but %s arrangement was stated or " -"implied earlier in this command." -msgstr "" - -#: src/language/data-io/get-data.c:313 -msgid "expecting FIXED or DELIMITED" -msgstr "" - -#: src/language/data-io/get-data.c:326 -msgid "Value of FIRSTCASE must be 1 or greater." -msgstr "" - -#: src/language/data-io/get-data.c:351 -msgid "expecting LINE or VARIABLES" -msgstr "" - -#: src/language/data-io/get-data.c:364 -msgid "Value of FIXCASE must be at least 1." -msgstr "" - -#: src/language/data-io/get-data.c:384 -msgid "Value of FIRST must be at least 1." -msgstr "" - -#: src/language/data-io/get-data.c:396 -msgid "Value of PERCENT must be between 1 and 100." -msgstr "" - -#: src/language/data-io/get-data.c:445 -msgid "" -"In compatible syntax mode, the QUALIFIER string must contain exactly one " -"character." -msgstr "" - -#: src/language/data-io/get-data.c:460 -msgid "expecting VARIABLES" -msgstr "" - -#: src/language/data-io/get-data.c:482 -#: src/language/data-io/placement-parser.c:378 -#, c-format -msgid "" -"The record number specified, %ld, is at or before the previous record, %d. " -"Data fields must be listed in order of increasing record number." -msgstr "" - -#: src/language/data-io/get-data.c:491 -#, c-format -msgid "" -"The record number specified, %ld, exceeds the number of records per case " -"specified on FIXCASE, %d." -msgstr "" - #: src/language/data-io/get.c:99 msgid "expecting COMM or TAPE" msgstr "" @@ -1573,6 +1512,67 @@ msgid "" "variable in earlier file (%s)." msgstr "" +#: src/language/data-io/get-data.c:62 +#, c-format +msgid "Unsupported TYPE %s" +msgstr "" + +#: src/language/data-io/get-data.c:258 +#, c-format +msgid "" +"%s is allowed only with %s arrangement, but %s arrangement was stated or " +"implied earlier in this command." +msgstr "" + +#: src/language/data-io/get-data.c:313 +msgid "expecting FIXED or DELIMITED" +msgstr "" + +#: src/language/data-io/get-data.c:326 +msgid "Value of FIRSTCASE must be 1 or greater." +msgstr "" + +#: src/language/data-io/get-data.c:351 +msgid "expecting LINE or VARIABLES" +msgstr "" + +#: src/language/data-io/get-data.c:364 +msgid "Value of FIXCASE must be at least 1." +msgstr "" + +#: src/language/data-io/get-data.c:384 +msgid "Value of FIRST must be at least 1." +msgstr "" + +#: src/language/data-io/get-data.c:396 +msgid "Value of PERCENT must be between 1 and 100." +msgstr "" + +#: src/language/data-io/get-data.c:445 +msgid "" +"In compatible syntax mode, the QUALIFIER string must contain exactly one " +"character." +msgstr "" + +#: src/language/data-io/get-data.c:460 +msgid "expecting VARIABLES" +msgstr "" + +#: src/language/data-io/get-data.c:482 +#: src/language/data-io/placement-parser.c:378 +#, c-format +msgid "" +"The record number specified, %ld, is at or before the previous record, %d. " +"Data fields must be listed in order of increasing record number." +msgstr "" + +#: src/language/data-io/get-data.c:491 +#, c-format +msgid "" +"The record number specified, %ld, exceeds the number of records per case " +"specified on FIXCASE, %d." +msgstr "" + #: src/language/data-io/inpt-pgm.c:130 msgid "Unexpected end-of-file within INPUT PROGRAM." msgstr "" @@ -1662,20 +1662,6 @@ msgstr "" msgid "The ending column for a field must be greater than the starting column." msgstr "" -#: src/language/data-io/print-space.c:73 src/language/lexer/lexer.c:476 -#: src/language/stats/autorecode.c:154 src/language/xforms/select-if.c:60 -msgid "expecting end of command" -msgstr "" - -#: src/language/data-io/print-space.c:116 -msgid "The expression on PRINT SPACE evaluated to the system-missing value." -msgstr "" - -#: src/language/data-io/print-space.c:119 -#, c-format -msgid "The expression on PRINT SPACE evaluated to %g." -msgstr "" - #: src/language/data-io/print.c:266 #, c-format msgid "Output calls for %d records but %zu specified on RECORDS subcommand." @@ -1695,6 +1681,20 @@ msgid_plural "Writing %d records." msgstr[0] "" msgstr[1] "" +#: src/language/data-io/print-space.c:73 src/language/lexer/lexer.c:476 +#: src/language/stats/autorecode.c:154 src/language/xforms/select-if.c:60 +msgid "expecting end of command" +msgstr "" + +#: src/language/data-io/print-space.c:116 +msgid "The expression on PRINT SPACE evaluated to the system-missing value." +msgstr "" + +#: src/language/data-io/print-space.c:119 +#, c-format +msgid "The expression on PRINT SPACE evaluated to %g." +msgstr "" + #: src/language/dictionary/apply-dictionary.c:75 #, c-format msgid "Variable %s is %s in target file, but %s in source file." @@ -1880,7 +1880,7 @@ msgstr "" #: src/language/dictionary/split-file.c:86 #: src/language/dictionary/sys-file-info.c:397 #: src/language/dictionary/sys-file-info.c:564 src/ui/gui/crosstabs.glade:275 -#: src/ui/gui/psppire-var-sheet.c:104 src/ui/gui/psppire.glade:2099 +#: src/ui/gui/psppire.glade:2099 src/ui/gui/psppire-var-sheet.c:104 msgid "Label" msgstr "" @@ -2637,7 +2637,7 @@ msgstr "" #: src/language/stats/crosstabs.q:1062 src/language/stats/crosstabs.q:1785 #: src/language/stats/examine.q:918 src/language/stats/frequencies.q:1137 #: src/language/stats/oneway.q:306 src/language/stats/oneway.q:476 -#: src/language/stats/regression.q:312 src/ui/gui/crosstabs-dialog.c:59 +#: src/language/stats/regression.q:309 src/ui/gui/crosstabs-dialog.c:59 msgid "Total" msgstr "" @@ -2683,7 +2683,7 @@ msgid "Expected N" msgstr "" #: src/language/stats/chisquare.c:209 src/language/stats/chisquare.c:249 -#: src/language/stats/regression.q:311 src/ui/gui/crosstabs-dialog.c:61 +#: src/language/stats/regression.q:308 src/ui/gui/crosstabs-dialog.c:61 msgid "Residual" msgstr "" @@ -2701,7 +2701,7 @@ msgstr "" #: src/language/stats/chisquare.c:312 src/language/stats/crosstabs.q:1156 #: src/language/stats/oneway.q:279 src/language/stats/oneway.q:694 -#: src/language/stats/regression.q:305 src/language/stats/t-test.q:1001 +#: src/language/stats/regression.q:302 src/language/stats/t-test.q:1001 #: src/language/stats/t-test.q:1193 src/language/stats/t-test.q:1286 msgid "df" msgstr "" @@ -2854,8 +2854,8 @@ msgstr "" msgid "Directional measures." msgstr "" -#: src/language/stats/crosstabs.q:1223 src/ui/gui/psppire-var-sheet.c:101 -#: src/ui/gui/psppire.glade:2223 +#: src/language/stats/crosstabs.q:1223 src/ui/gui/psppire.glade:2223 +#: src/ui/gui/psppire-var-sheet.c:101 msgid "Type" msgstr "" @@ -3133,7 +3133,7 @@ msgid "Lowest" msgstr "" #: src/language/stats/examine.q:1443 src/language/stats/oneway.q:394 -#: src/language/stats/oneway.q:692 src/language/stats/regression.q:204 +#: src/language/stats/oneway.q:692 src/language/stats/regression.q:203 msgid "Std. Error" msgstr "" @@ -3370,11 +3370,11 @@ msgstr "" msgid "Multivariate GLM not yet supported" msgstr "" -#: src/language/stats/glm.q:271 src/language/stats/regression.q:934 +#: src/language/stats/glm.q:271 src/language/stats/regression.q:931 msgid "Dependent variable must be numeric." msgstr "" -#: src/language/stats/glm.q:346 src/language/stats/regression.q:1030 +#: src/language/stats/glm.q:346 src/language/stats/regression.q:1026 msgid "No valid data found. This command was skipped." msgstr "" @@ -3386,22 +3386,6 @@ msgstr "" msgid "TABLES subcommand may not appear more than once." msgstr "" -#: src/language/stats/npar-summary.c:108 -msgid "Descriptive Statistics" -msgstr "" - -#: src/language/stats/npar-summary.c:145 -msgid "25th" -msgstr "" - -#: src/language/stats/npar-summary.c:148 -msgid "50th (Median)" -msgstr "" - -#: src/language/stats/npar-summary.c:151 -msgid "75th" -msgstr "" - #: src/language/stats/npar.q:98 msgid "NPAR subcommand not currently implemented." msgstr "" @@ -3426,6 +3410,22 @@ msgid "" "not match the number following (%zu)." msgstr "" +#: src/language/stats/npar-summary.c:108 +msgid "Descriptive Statistics" +msgstr "" + +#: src/language/stats/npar-summary.c:145 +msgid "25th" +msgstr "" + +#: src/language/stats/npar-summary.c:148 +msgid "50th (Median)" +msgstr "" + +#: src/language/stats/npar-summary.c:151 +msgid "75th" +msgstr "" + #: src/language/stats/oneway.q:169 msgid "Number of contrast coefficients must equal the number of groups" msgstr "" @@ -3440,21 +3440,21 @@ msgstr "" msgid "`%s' is not a variable name" msgstr "" -#: src/language/stats/oneway.q:278 src/language/stats/regression.q:304 +#: src/language/stats/oneway.q:278 src/language/stats/regression.q:301 msgid "Sum of Squares" msgstr "" -#: src/language/stats/oneway.q:280 src/language/stats/regression.q:306 +#: src/language/stats/oneway.q:280 src/language/stats/regression.q:303 msgid "Mean Square" msgstr "" -#: src/language/stats/oneway.q:281 src/language/stats/regression.q:307 +#: src/language/stats/oneway.q:281 src/language/stats/regression.q:304 #: src/language/stats/t-test.q:998 msgid "F" msgstr "" #: src/language/stats/oneway.q:282 src/language/stats/oneway.q:542 -#: src/language/stats/regression.q:207 src/language/stats/regression.q:308 +#: src/language/stats/regression.q:206 src/language/stats/regression.q:305 msgid "Significance" msgstr "" @@ -3466,7 +3466,7 @@ msgstr "" msgid "Within Groups" msgstr "" -#: src/language/stats/oneway.q:352 src/language/stats/regression.q:333 +#: src/language/stats/oneway.q:352 src/language/stats/regression.q:330 msgid "ANOVA" msgstr "" @@ -3502,7 +3502,7 @@ msgstr "" msgid "Value of Contrast" msgstr "" -#: src/language/stats/oneway.q:693 src/language/stats/regression.q:206 +#: src/language/stats/oneway.q:693 src/language/stats/regression.q:205 #: src/language/stats/t-test.q:1000 src/language/stats/t-test.q:1192 #: src/language/stats/t-test.q:1285 msgid "t" @@ -3594,39 +3594,39 @@ msgstr "" msgid "Model Summary" msgstr "" -#: src/language/stats/regression.q:203 +#: src/language/stats/regression.q:202 msgid "B" msgstr "" -#: src/language/stats/regression.q:205 +#: src/language/stats/regression.q:204 msgid "Beta" msgstr "" -#: src/language/stats/regression.q:208 +#: src/language/stats/regression.q:207 msgid "(Constant)" msgstr "" -#: src/language/stats/regression.q:274 +#: src/language/stats/regression.q:271 msgid "Coefficients" msgstr "" -#: src/language/stats/regression.q:310 +#: src/language/stats/regression.q:307 msgid "Regression" msgstr "" -#: src/language/stats/regression.q:392 +#: src/language/stats/regression.q:389 msgid "Model" msgstr "" -#: src/language/stats/regression.q:393 +#: src/language/stats/regression.q:390 msgid "Covariances" msgstr "" -#: src/language/stats/regression.q:408 +#: src/language/stats/regression.q:405 msgid "Coefficient Correlations" msgstr "" -#: src/language/stats/regression.q:810 +#: src/language/stats/regression.q:807 msgid "" "The dependent variable is equal to the independent variable.The least " "squares line is therefore Y=X.Standard errors and related statistics may be " @@ -5578,6 +5578,14 @@ msgstr "" msgid "Paste" msgstr "" +#: src/ui/gui/psppire.c:194 +msgid "_Reset" +msgstr "" + +#: src/ui/gui/psppire.c:195 +msgid "_Select" +msgstr "" + #: src/ui/gui/psppire-data-editor.c:604 msgid "Data View" msgstr "" @@ -5595,52 +5603,6 @@ msgstr "" msgid "%ld" msgstr "" -#: src/ui/gui/psppire-var-sheet.c:100 -msgid "Name" -msgstr "" - -#: src/ui/gui/psppire-var-sheet.c:102 src/ui/gui/psppire.glade:2187 -msgid "Width" -msgstr "" - -#: src/ui/gui/psppire-var-sheet.c:103 -msgid "Decimals" -msgstr "" - -#: src/ui/gui/psppire-var-sheet.c:105 -msgid "Values" -msgstr "" - -#: src/ui/gui/psppire-var-sheet.c:108 -msgid "Align" -msgstr "" - -#: src/ui/gui/psppire-var-sheet.c:109 -msgid "Measure" -msgstr "" - -#: src/ui/gui/psppire-var-store.c:601 -msgid "Scientific" -msgstr "" - -#: src/ui/gui/psppire-var-store.c:604 -msgid "Custom" -msgstr "" - -#: src/ui/gui/psppire-var-store.c:675 src/ui/gui/psppire-var-store.c:685 -#: src/ui/gui/psppire-var-store.c:695 -#, c-format -msgid "%d" -msgstr "" - -#: src/ui/gui/psppire.c:194 -msgid "_Reset" -msgstr "" - -#: src/ui/gui/psppire.c:195 -msgid "_Select" -msgstr "" - #: src/ui/gui/psppire.glade:11 msgid "" "This is beta status software. Please report bugs to bug-gnu-pspp@gnu.org" @@ -5826,6 +5788,10 @@ msgstr "" msgid "Use expression as label" msgstr "" +#: src/ui/gui/psppire.glade:2187 src/ui/gui/psppire-var-sheet.c:102 +msgid "Width" +msgstr "" + #: src/ui/gui/psppire.glade:2274 msgid "Goto Case Number:" msgstr "" @@ -5858,6 +5824,40 @@ msgstr "" msgid "Search backward" msgstr "" +#: src/ui/gui/psppire-var-sheet.c:100 +msgid "Name" +msgstr "" + +#: src/ui/gui/psppire-var-sheet.c:103 +msgid "Decimals" +msgstr "" + +#: src/ui/gui/psppire-var-sheet.c:105 +msgid "Values" +msgstr "" + +#: src/ui/gui/psppire-var-sheet.c:108 +msgid "Align" +msgstr "" + +#: src/ui/gui/psppire-var-sheet.c:109 +msgid "Measure" +msgstr "" + +#: src/ui/gui/psppire-var-store.c:601 +msgid "Scientific" +msgstr "" + +#: src/ui/gui/psppire-var-store.c:604 +msgid "Custom" +msgstr "" + +#: src/ui/gui/psppire-var-store.c:675 src/ui/gui/psppire-var-store.c:685 +#: src/ui/gui/psppire-var-store.c:695 +#, c-format +msgid "%d" +msgstr "" + #: src/ui/gui/rank.glade:111 msgid "By:" msgstr "" @@ -6146,56 +6146,6 @@ msgstr "" msgid "To End" msgstr "" -#: src/ui/gui/t-test-options.c:60 -#, c-format -msgid "Confidence Interval: %2d %%" -msgstr "" - -#: src/ui/gui/t-test-paired-samples.c:228 -msgid "Var 1" -msgstr "" - -#: src/ui/gui/t-test-paired-samples.c:229 -msgid "Var 2" -msgstr "" - -#: src/ui/gui/t-test.glade:56 src/ui/gui/t-test.glade:165 -msgid "Define Groups" -msgstr "" - -#: src/ui/gui/t-test.glade:123 src/ui/gui/t-test.glade:549 -#: src/ui/gui/t-test.glade:761 -msgid "Test Variable(s):" -msgstr "" - -#: src/ui/gui/t-test.glade:258 -msgid "Group_2 value:" -msgstr "" - -#: src/ui/gui/t-test.glade:271 -msgid "Group_1 value:" -msgstr "" - -#: src/ui/gui/t-test.glade:320 -msgid "_Cut point:" -msgstr "" - -#: src/ui/gui/t-test.glade:349 -msgid "_Use specified values:" -msgstr "" - -#: src/ui/gui/t-test.glade:431 -msgid "Exclude cases _analysis by analysis" -msgstr "" - -#: src/ui/gui/t-test.glade:442 -msgid "Exclude cases _listwise" -msgstr "" - -#: src/ui/gui/t-test.glade:594 -msgid "Test Value: " -msgstr "" - #: src/ui/gui/text-data-import-dialog.c:70 msgid "" "The text import assistant has not been compiled into this build of PSPPIRE, " @@ -6415,6 +6365,56 @@ msgstr "" msgid "Data Preview" msgstr "" +#: src/ui/gui/t-test.glade:56 src/ui/gui/t-test.glade:165 +msgid "Define Groups" +msgstr "" + +#: src/ui/gui/t-test.glade:123 src/ui/gui/t-test.glade:549 +#: src/ui/gui/t-test.glade:761 +msgid "Test Variable(s):" +msgstr "" + +#: src/ui/gui/t-test.glade:258 +msgid "Group_2 value:" +msgstr "" + +#: src/ui/gui/t-test.glade:271 +msgid "Group_1 value:" +msgstr "" + +#: src/ui/gui/t-test.glade:320 +msgid "_Cut point:" +msgstr "" + +#: src/ui/gui/t-test.glade:349 +msgid "_Use specified values:" +msgstr "" + +#: src/ui/gui/t-test.glade:431 +msgid "Exclude cases _analysis by analysis" +msgstr "" + +#: src/ui/gui/t-test.glade:442 +msgid "Exclude cases _listwise" +msgstr "" + +#: src/ui/gui/t-test.glade:594 +msgid "Test Value: " +msgstr "" + +#: src/ui/gui/t-test-options.c:60 +#, c-format +msgid "Confidence Interval: %2d %%" +msgstr "" + +#: src/ui/gui/t-test-paired-samples.c:228 +msgid "Var 1" +msgstr "" + +#: src/ui/gui/t-test-paired-samples.c:229 +msgid "Var 2" +msgstr "" + #: src/ui/gui/variable-info-dialog.c:89 #, c-format msgid "Label: %s\n" diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 3a6152a5..1908c0fd 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -563,6 +563,29 @@ on_map (GtkWidget *w) } +static void +xxx (GtkToggleButton *button, gpointer data) +{ + PsppireDataEditor *de = data; + if ( gtk_toggle_button_get_active (button)) + gtk_sheet_show_row_titles (GTK_SHEET (de->data_sheet)); + else + gtk_sheet_hide_row_titles (GTK_SHEET (de->data_sheet)); +} + + +static void +yyy (GtkToggleButton *button, gpointer data) +{ + PsppireDataEditor *de = data; + if ( gtk_toggle_button_get_active (button)) + gtk_sheet_show_column_titles (GTK_SHEET (de->data_sheet)); + else + gtk_sheet_hide_column_titles (GTK_SHEET (de->data_sheet)); +} + + + static void psppire_data_editor_init (PsppireDataEditor *de) { @@ -596,6 +619,26 @@ psppire_data_editor_init (PsppireDataEditor *de) gtk_container_add (GTK_CONTAINER (sw_ds), de->data_sheet); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + + { + GtkWidget *hbox2 = gtk_hbox_new (FALSE, 0); + GtkWidget *button1 = gtk_toggle_button_new_with_label ("vertical"); + GtkWidget *button2 = gtk_toggle_button_new_with_label ("horizontal"); + + gtk_box_pack_start (GTK_BOX (hbox2), button1, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (hbox2), button2, TRUE, TRUE, 0); + gtk_widget_show_all (hbox2); + + gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); + + g_signal_connect (button1, "toggled", G_CALLBACK (xxx), de); + g_signal_connect (button2, "toggled", G_CALLBACK (yyy), de); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button1), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button2), TRUE); + } + gtk_box_pack_start (GTK_BOX (vbox), sw_ds, TRUE, TRUE, 0); gtk_widget_show_all (vbox); @@ -655,6 +698,11 @@ psppire_data_editor_init (PsppireDataEditor *de) g_signal_connect (de, "map", G_CALLBACK (on_map), NULL); + + // gtk_sheet_hide_column_titles (de->var_sheet); + // gtk_sheet_hide_row_titles (de->data_sheet); + + de->dispose_has_run = FALSE; } @@ -670,6 +718,7 @@ psppire_data_editor_new (PsppireVarStore *var_store, "data-store", data_store, NULL); + return widget; } diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index afbe3d2f..18aaaeba 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -56,7 +56,6 @@ static gboolean psppire_data_store_clear_datum (GSheetModel *model, #define MIN_COLUMNS 10 - #define TRAILING_ROWS 10 static GObjectClass *parent_class = NULL; @@ -800,9 +799,11 @@ geometry_set_width (GSheetColumn *geom, glong unit, gint width) { PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom); - struct variable *pv = psppire_dict_get_variable (ds->dict, unit); + struct variable *v = psppire_dict_get_variable (ds->dict, unit); + + g_return_if_fail (v); - var_set_display_width (pv, width / ds->width_of_m ); + var_set_display_width (v, width / ds->width_of_m ); } @@ -934,7 +935,6 @@ geometry_get_row_sensitivity (const GSheetRow *geom, glong unit) return (unit < psppire_case_file_get_case_count (ds->case_file)); } - static gchar * geometry_get_row_button_label (const GSheetRow *geom, glong unit) { -- 2.30.2