g_free (text);
}
-static inline
-guint DEFAULT_ROW_HEIGHT (GtkWidget *widget)
+static guint
+default_row_height (const GtkSheet *sheet)
{
- if (!widget->style->font_desc) return 24;
+ GtkWidget *widget = GTK_WIDGET (sheet);
+
+ if (!widget->style->font_desc) return 25;
else
{
PangoContext *context = gtk_widget_get_pango_context (widget);
}
}
-static inline
+static
guint DEFAULT_FONT_ASCENT (GtkWidget *widget)
{
if (!widget->style->font_desc) return 12;
}
}
-static inline
+static
guint STRING_WIDTH (GtkWidget *widget,
const PangoFontDescription *font, const gchar *text)
{
return PANGO_PIXELS (rect.width);
}
-static inline
+static
guint DEFAULT_FONT_DESCENT (GtkWidget *widget)
{
if (!widget->style->font_desc) return 12;
static inline glong
min_visible_row (const GtkSheet *sheet)
{
- return yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value);
+ glong row =
+ yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value);
+
+ return row;
}
static inline glong
max_visible_row (const GtkSheet *sheet)
{
- return yyy_row_ypixel_to_row (sheet,
- sheet->vadjustment->value +
- sheet->vadjustment->page_size);
+ glong row =
+ yyy_row_ypixel_to_row (sheet,
+ sheet->vadjustment->value +
+ sheet->vadjustment->page_size);
+
+ return row;
}
col = column_from_xpixel (sheet, x);
if ( column_from_xpixel (sheet, x - DRAG_WIDTH / 2) < col )
-{
+ {
*column = col - 1;
return TRUE;
-}
+ }
if ( column_from_xpixel (sheet, x + DRAG_WIDTH / 2) > col )
{
GdkEventCrossing *event);
static gint gtk_sheet_entry_key_press (GtkWidget *widget,
GdkEventKey *key);
-static gint gtk_sheet_key_press (GtkWidget *widget,
+static gboolean gtk_sheet_key_press (GtkWidget *widget,
GdkEventKey *key);
static void gtk_sheet_size_request (GtkWidget * widget,
GtkRequisition * requisition);
sheet->column_title_area.x = 0;
sheet->column_title_area.y = 0;
sheet->column_title_area.width = 0;
- sheet->column_title_area.height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+ sheet->column_title_area.height = default_row_height (sheet);
sheet->row_title_window = NULL;
sheet->row_title_area.x = 0;
n_columns = g_sheet_column_get_column_count (sheet->column_geometry) - 1 ;
}
- {
- gint i;
- for ( i = first ; i <= first + n_columns ; ++i )
- {
- gtk_sheet_column_title_button_draw (sheet, i);
- g_signal_emit (sheet, sheet_signals[CHANGED], 0, -1, i);
- }
- }
+ {
+ gint i;
+ for ( i = first ; i <= first + n_columns ; ++i )
+ {
+ gtk_sheet_column_title_button_draw (sheet, i);
+ g_signal_emit (sheet, sheet_signals[CHANGED], 0, -1, i);
+ }
+ }
if ( extremity)
gtk_sheet_column_title_button_draw (sheet, -1);
sheet->show_grid = show;
- gtk_sheet_range_draw (sheet, NULL);
+ gtk_sheet_range_draw (sheet, NULL);
}
gboolean
void
gtk_sheet_set_column_titles_height (GtkSheet *sheet, guint height)
{
- if (height < DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet))) return;
+ if (height < default_row_height (sheet))
+ return;
sheet->column_title_area.height = height;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
return;
- gdk_window_show (sheet->column_title_window);
- gdk_window_move_resize (sheet->column_title_window,
- sheet->column_title_area.x,
- sheet->column_title_area.y,
- sheet->column_title_area.width,
- sheet->column_title_area.height);
+ gdk_window_show (sheet->column_title_window);
+ gdk_window_move_resize (sheet->column_title_window,
+ sheet->column_title_area.x,
+ sheet->column_title_area.y,
+ sheet->column_title_area.width,
+ sheet->column_title_area.height);
- adjust_scrollbars (sheet);
+ adjust_scrollbars (sheet);
if (sheet->vadjustment)
g_signal_emit_by_name (sheet->vadjustment,
GtkAdjustment *vadjustment)
{
if ( sheet->vadjustment != vadjustment )
-{
- if (sheet->vadjustment)
- g_object_unref (sheet->vadjustment);
+ {
+ if (sheet->vadjustment)
+ g_object_unref (sheet->vadjustment);
sheet->vadjustment = vadjustment;
g_object_ref (vadjustment);
}
if ( sheet->hadjustment != hadjustment )
-{
- if (sheet->hadjustment)
- g_object_unref (sheet->hadjustment);
+ {
+ if (sheet->hadjustment)
+ g_object_unref (sheet->hadjustment);
sheet->hadjustment = hadjustment;
g_object_ref (hadjustment);
attributes.x = 0;
attributes.y = 0;
attributes.width = sheet->sheet_window_width;
- attributes.height = sheet->sheet_window_height;
+ attributes.height = sheet->sheet_window_height;
sheet->sheet_window = gdk_window_new (widget->window,
&attributes, attributes_mask);
if (!GTK_WIDGET_MAPPED (widget))
return;
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
- gdk_window_hide (sheet->sheet_window);
- if (sheet->column_titles_visible)
- gdk_window_hide (sheet->column_title_window);
- if (sheet->row_titles_visible)
- gdk_window_hide (sheet->row_title_window);
- gdk_window_hide (widget->window);
+ gdk_window_hide (sheet->sheet_window);
+ if (sheet->column_titles_visible)
+ gdk_window_hide (sheet->column_title_window);
+ if (sheet->row_titles_visible)
+ gdk_window_hide (sheet->row_title_window);
+ gdk_window_hide (widget->window);
- if (GTK_WIDGET_MAPPED (sheet->entry_widget))
- gtk_widget_unmap (sheet->entry_widget);
+ if (GTK_WIDGET_MAPPED (sheet->entry_widget))
+ gtk_widget_unmap (sheet->entry_widget);
- if (GTK_WIDGET_MAPPED (sheet->button))
- gtk_widget_unmap (sheet->button);
+ if (GTK_WIDGET_MAPPED (sheet->button))
+ gtk_widget_unmap (sheet->button);
}
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,
+ MAX (col,
g_sheet_column_get_right_text_column (sheet->column_geometry, i)));
}
area.width = size;
if (sizer >= text_width / 2) break;
sizer += g_sheet_column_get_width (sheet->column_geometry, i);
g_sheet_column_set_left_text_column (sheet->column_geometry, i,
- MIN (
- col,
+ MIN (
+ col,
g_sheet_column_get_left_text_column (sheet->column_geometry, i)));
}
for (i = col - 1; i >= min_visible_column (sheet); i--)
if (sizel >= text_width / 2) break;
sizel += g_sheet_column_get_width (sheet->column_geometry, i);
g_sheet_column_set_right_text_column (sheet->column_geometry, i,
- MAX (col,
+ MAX (col,
g_sheet_column_get_right_text_column (sheet->column_geometry, i)));
}
size = MIN (sizel, sizer);
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,
+ MIN (
+ col,
g_sheet_column_get_left_text_column (sheet->column_geometry, i)));
}
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,
+ GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL],
+ sheet->pixmap,
0, 0, /* src */
sheet->row_titles_visible ? sheet->row_title_area.width : 0,
sheet->column_titles_visible ? sheet->column_title_area.height : 0,
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING);
}
else
- gtk_sheet_range_draw (sheet, &range);
+ gtk_sheet_range_draw (sheet, &range);
}
if ( changed )
gtk_sheet_real_cell_clear (sheet, row, column);
- gtk_sheet_range_draw (sheet, &range);
- }
+ gtk_sheet_range_draw (sheet, &range);
+}
static void
gtk_sheet_real_cell_clear (GtkSheet *sheet, gint row, gint column)
trow = yyy_row_ypixel_to_row (sheet, y);
if (trow > g_sheet_row_get_row_count (sheet->row_geometry))
- return FALSE;
+ return FALSE;
- *row = trow;
+ *row = trow;
if ( sheet->row_titles_visible)
x -= sheet->row_title_area.width;
x += sheet->hadjustment->value;
- tcol = column_from_xpixel (sheet, x);
+ tcol = column_from_xpixel (sheet, x);
if (tcol > g_sheet_column_get_column_count (sheet->column_geometry))
- return FALSE;
+ return FALSE;
- *column = tcol;
+ *column = tcol;
return TRUE;
}
gdk_gc_set_clip_rectangle (sheet->xor_gc, &area);
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
+ gdk_draw_rectangle (sheet->sheet_window,
+ sheet->xor_gc,
FALSE,
x, y,
width - 2,
{
if (! g_sheet_column_get_visibility (sheet->column_geometry, column)
|| !g_sheet_row_get_visibility (sheet->row_geometry, row))
- {
- *veto = FALSE;
- return;
- }
+ {
+ *veto = FALSE;
+ return;
+ }
}
_gtkextra_signal_emit (GTK_OBJECT (sheet), sheet_signals[TRAVERSE],
if (GTK_SHEET_IN_XDRAG (sheet))
{
- x = event->x;
+ x = event->x;
new_column_width (sheet, sheet->drag_cell.col, &x);
#if 0
return focus;
}
-static gint
-gtk_sheet_key_press (GtkWidget *widget,
- GdkEventKey *key)
+
+/* Number of rows in a step-increment */
+#define ROWS_PER_STEP 1
+
+
+static void
+page_vertical (GtkSheet *sheet, GtkScrollType dir)
{
- GtkSheet *sheet;
- gint row, col;
- gint state;
- gboolean extend_selection = FALSE;
- gboolean force_move = FALSE;
- gboolean in_selection = FALSE;
- gboolean veto = TRUE;
- gint scroll = 1;
+ gint old_row = sheet->active_cell.row ;
+ glong vpixel = g_sheet_row_start_pixel (sheet->row_geometry, old_row);
- sheet = GTK_SHEET (widget);
+ gint new_row;
- if (key->state & GDK_CONTROL_MASK || key->keyval == GDK_Control_L ||
- key->keyval == GDK_Control_R) return FALSE;
+ vpixel -= g_sheet_row_start_pixel (sheet->row_geometry,
+ min_visible_row (sheet));
- extend_selection = (key->state & GDK_SHIFT_MASK) || key->keyval == GDK_Shift_L
- || key->keyval == GDK_Shift_R;
+ switch ( dir)
+ {
+ case GTK_SCROLL_PAGE_DOWN:
+ gtk_adjustment_set_value (sheet->vadjustment,
+ sheet->vadjustment->value +
+ sheet->vadjustment->page_increment);
+ break;
+ case GTK_SCROLL_PAGE_UP:
+ gtk_adjustment_set_value (sheet->vadjustment,
+ sheet->vadjustment->value -
+ sheet->vadjustment->page_increment);
+
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+
+ vpixel += g_sheet_row_start_pixel (sheet->row_geometry,
+ min_visible_row (sheet));
+
+ new_row = yyy_row_ypixel_to_row (sheet, vpixel);
+
+ gtk_sheet_activate_cell (sheet, new_row,
+ sheet->active_cell.col);
+}
+
+
+static gboolean
+gtk_sheet_key_press (GtkWidget *widget,
+ GdkEventKey *key)
+{
+ GtkSheet *sheet = GTK_SHEET (widget);
- state = sheet->state;
- in_selection = GTK_SHEET_IN_SELECTION (sheet);
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
+
switch (key->keyval)
{
- case GDK_Return: case GDK_KP_Enter:
- if (sheet->state == GTK_SHEET_NORMAL &&
- !GTK_SHEET_IN_SELECTION (sheet))
- g_signal_stop_emission_by_name (gtk_sheet_get_entry (sheet),
- "key-press-event");
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
- row = min_visible_row (sheet)- 1;
- if (sheet->state == GTK_SHEET_ROW_SELECTED)
- col = min_visible_column (sheet);
- if (row < g_sheet_row_get_row_count (sheet->row_geometry) - 1)
- {
- row = row + scroll;
- 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);
- extend_selection = FALSE;
+ case GDK_Right:
+ /*
+ gtk_adjustment_set_value (sheet->hadjustment,
+ sheet->hadjustment->value +
+ sheet->hadjustment->step_increment);
+ */
+
+ gtk_sheet_activate_cell (sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col + 1);
break;
- case GDK_ISO_Left_Tab:
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- if (sheet->state == GTK_SHEET_ROW_SELECTED)
- col = min_visible_column (sheet)- 1;
- if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
- row = min_visible_row (sheet);
- if (col > 0)
- {
- col = col - scroll;
- 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);
- extend_selection = FALSE;
+ case GDK_Left:
+ gtk_sheet_activate_cell (sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col - 1);
break;
- case GDK_Tab:
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- if (sheet->state == GTK_SHEET_ROW_SELECTED)
- col = min_visible_column (sheet)- 1;
- if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
- row = min_visible_row (sheet);
- if (col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
- {
- col = col + scroll;
- 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);
- extend_selection = FALSE;
+
+ case GDK_Down:
+ gtk_adjustment_set_value (sheet->vadjustment,
+ sheet->vadjustment->value +
+ sheet->vadjustment->step_increment);
+
+ gtk_sheet_activate_cell (sheet,
+ sheet->active_cell.row + ROWS_PER_STEP,
+ sheet->active_cell.col);
+
+
break;
- case GDK_Page_Up:
- scroll = max_visible_row (sheet)- min_visible_row (sheet)+1;
case GDK_Up:
- if (extend_selection)
- {
- if (state == GTK_STATE_NORMAL)
- {
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- gtk_sheet_click_cell (sheet, row, col, &veto);
- if (!veto) break;
- }
- if (sheet->selection_cell.row > 0)
- {
- row = sheet->selection_cell.row - scroll;
- 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);
- }
- return TRUE;
- }
- col = sheet->active_cell.col;
- row = sheet->active_cell.row;
- if (state == GTK_SHEET_COLUMN_SELECTED)
- row = min_visible_row (sheet);
- if (state == GTK_SHEET_ROW_SELECTED)
- col = min_visible_column (sheet);
- row = row - scroll;
- while (!g_sheet_row_get_visibility (sheet->row_geometry, row) && row > 0) row--;
- row = MAX (0, row);
- gtk_sheet_click_cell (sheet, row, col, &veto);
- extend_selection = FALSE;
+ gtk_adjustment_set_value (sheet->vadjustment,
+ sheet->vadjustment->value -
+ sheet->vadjustment->step_increment);
+
+ gtk_sheet_activate_cell (sheet,
+ sheet->active_cell.row - ROWS_PER_STEP,
+ sheet->active_cell.col);
+
break;
+
case GDK_Page_Down:
- scroll = max_visible_row (sheet)- min_visible_row (sheet)+1;
- case GDK_Down:
- if (extend_selection)
- {
- if (state == GTK_STATE_NORMAL)
- {
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- gtk_sheet_click_cell (sheet, row, col, &veto);
- if (!veto) break;
- }
- if (sheet->selection_cell.row < g_sheet_row_get_row_count (sheet->row_geometry) - 1)
- {
- row = sheet->selection_cell.row + scroll;
- 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 < 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 (!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;
+ page_vertical (sheet, GTK_SCROLL_PAGE_DOWN);
break;
- case GDK_Right:
- if (extend_selection)
- {
- if (state == GTK_STATE_NORMAL)
- {
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- gtk_sheet_click_cell (sheet, row, col, &veto);
- if (!veto) break;
- }
- if (sheet->selection_cell.col < g_sheet_column_get_column_count (sheet->column_geometry) - 1)
- {
- col = sheet->selection_cell.col + 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);
- }
- return TRUE;
- }
- col = sheet->active_cell.col;
- row = sheet->active_cell.row;
- 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 (! 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)
- {
- gtk_sheet_click_cell (sheet, row, col, &veto);
- }
- else
- return FALSE;
- }
- extend_selection = FALSE;
- break;
- case GDK_Left:
- if (extend_selection)
- {
- if (state == GTK_STATE_NORMAL)
- {
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
- gtk_sheet_click_cell (sheet, row, col, &veto);
- if (!veto) break;
- }
- if (sheet->selection_cell.col > 0)
- {
- col = sheet->selection_cell.col - 1;
- while (! g_sheet_column_get_visibility (sheet->column_geometry, col) && col > 0) col--;
- gtk_sheet_extend_selection (sheet, sheet->selection_cell.row, col);
- }
- return TRUE;
- }
- col = sheet->active_cell.col - 1;
- row = sheet->active_cell.row;
- if (state == GTK_SHEET_ROW_SELECTED)
- col = min_visible_column (sheet)- 1;
- if (state == GTK_SHEET_COLUMN_SELECTED)
- row = min_visible_row (sheet);
- 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
- || force_move)
- {
- gtk_sheet_click_cell (sheet, row, col, &veto);
- }
- else
- return FALSE;
- extend_selection = FALSE;
- break;
- case GDK_Home:
- row = 0;
- 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 = 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;
+ case GDK_Page_Up:
+ page_vertical (sheet, GTK_SCROLL_PAGE_UP);
break;
- default:
- if (in_selection)
- {
- GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
- if (extend_selection) return TRUE;
- }
- if (state == GTK_SHEET_ROW_SELECTED)
- sheet->active_cell.col = min_visible_column (sheet);
- if (state == GTK_SHEET_COLUMN_SELECTED)
- sheet->active_cell.row = min_visible_row (sheet);
- return FALSE;
- }
- if (extend_selection) return TRUE;
- gtk_sheet_activate_cell (sheet, sheet->active_cell.row,
- sheet->active_cell.col);
+ default:
+ break;
+ }
return TRUE;
}
static void
-gtk_sheet_size_request (GtkWidget * widget,
- GtkRequisition * requisition)
+gtk_sheet_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
{
GtkSheet *sheet;
sheet = GTK_SHEET (widget);
- requisition->width = 3*DEFAULT_COLUMN_WIDTH;
- requisition->height = 3*DEFAULT_ROW_HEIGHT (widget);
+ requisition->width = 3 * DEFAULT_COLUMN_WIDTH;
+ requisition->height = 3 * default_row_height (sheet);
/* compute the size of the column title area */
if (sheet->column_titles_visible)
if (sheet->row_titles_visible)
{
- sheet->column_title_area.x = sheet->row_title_area.width;
+ sheet->column_title_area.x = sheet->row_title_area.width;
sheet->sheet_window_width -= sheet->row_title_area.width;
}
sheet->row_title_area.y = 0;
if (sheet->column_titles_visible)
{
- sheet->row_title_area.y = sheet->column_title_area.height;
+ sheet->row_title_area.y = sheet->column_title_area.height;
sheet->sheet_window_height -= sheet->column_title_area.height;
}
if (button->label_visible)
{
- text_height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet)) -
+ text_height = default_row_height (sheet) -
2 * COLUMN_TITLES_HEIGHT;
gdk_gc_set_clip_rectangle (GTK_WIDGET (sheet)->style->fg_gc[button->state],
button = g_sheet_column_get_button (sheet->column_geometry, column);
allocation.y = 0;
- allocation.x = column_left_xpixel (sheet, column) + CELL_SPACING;
+ allocation.x = column_left_xpixel (sheet, column) + CELL_SPACING;
allocation.x -= sheet->hadjustment->value;
allocation.height = sheet->column_title_area.height;
gtk_sheet_button_draw (sheet, sheet->column_title_window,
button, is_sensitive, allocation);
- }
+}
static void
* hadjustment_value_changed */
static void
-adjust_scrollbars (GtkSheet * sheet)
+adjust_scrollbars (GtkSheet *sheet)
{
if (sheet->vadjustment)
{
+ glong last_row = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+
sheet->vadjustment->step_increment =
- 1 ; // DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+ ROWS_PER_STEP *
+ g_sheet_row_get_height (sheet->row_geometry, last_row);
sheet->vadjustment->page_increment =
- sheet->sheet_window_height - DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+ sheet->sheet_window_height -
+ sheet->column_title_area.height -
+ g_sheet_row_get_height (sheet->row_geometry, last_row);
- sheet->vadjustment->upper = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet))
- * g_sheet_row_get_row_count (sheet->row_geometry);
+ sheet->vadjustment->upper =
+ g_sheet_row_start_pixel (sheet->row_geometry, last_row)
+ +
+ g_sheet_row_get_height (sheet->row_geometry, last_row)
+ ;
+
sheet->vadjustment->lower = 0;
sheet->vadjustment->page_size = sheet->sheet_window_height;
+#if 0
+ {
+ GtkAdjustment *adj = sheet->vadjustment;
+ g_print ("Lower: %g; Upper: %g\n", adj->lower, adj->upper);
+ g_print ("Step: %g; Page %g\n", adj->step_increment,
+ adj->page_increment);
+ g_print ("Current: %g\n", adj->value);
+ }
+#endif
g_signal_emit_by_name (sheet->vadjustment, "changed");
}
gdk_gc_set_clip_rectangle (sheet->xor_gc, &clip_area);
- gdk_draw_rectangle (sheet->sheet_window,
- sheet->xor_gc,
- FALSE,
- area.x + i, area.y + i,
- area.width - 2 * i, area.height - 2 * i);
+ gdk_draw_rectangle (sheet->sheet_window,
+ sheet->xor_gc,
+ FALSE,
+ area.x + i, area.y + i,
+ area.width - 2 * i, area.height - 2 * i);
gdk_gc_set_clip_rectangle (sheet->xor_gc, NULL);
gchar *words;
gchar word[1000];
gint n = 0;
- gint row_height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet)) - 2 * COLUMN_TITLES_HEIGHT + 2;
+ gint row_height = default_row_height (sheet) - 2 * COLUMN_TITLES_HEIGHT + 2;
req->height = 0;
req->width = 0;
}
else
{
- label_requisition.height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
+ label_requisition.height = default_row_height (sheet);
label_requisition.width = COLUMN_MIN_WIDTH;
}
- requisition.height = DEFAULT_ROW_HEIGHT (GTK_WIDGET (sheet));
- requisition.width = COLUMN_MIN_WIDTH;
+ requisition.height = default_row_height (sheet);
+ requisition.width = COLUMN_MIN_WIDTH;
*button_requisition = requisition;