-/* This version of GtkSheet has been *heavily* modified, for the specific
- requirements of PSPPIRE. */
+/*
+ * Copyright (C) 2006, 2008 Free Software Foundation
+ *
+ * This version of GtkSheet has been *heavily* modified, for the specific
+ * requirements of PSPPIRE. The changes are copyright by the
+ * Free Software Foundation. The copyright notice for the original work is
+ * below.
+*/
/* GtkSheet widget for Gtk+.
* Copyright (C) 1999-2001 Adrian E. Feiguin <adrian@ifir.ifir.edu.ar>
/* sheet flags */
enum
{
- GTK_SHEET_IS_LOCKED = 1 << 0,
GTK_SHEET_IS_FROZEN = 1 << 1,
GTK_SHEET_IN_XDRAG = 1 << 2,
GTK_SHEET_IN_YDRAG = 1 << 3,
#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_LOCKED(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IS_LOCKED)
-
-
#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)
return sheet->justify_entry;
}
-void
-gtk_sheet_set_locked (GtkSheet *sheet, gboolean locked)
-{
- g_return_if_fail (sheet != NULL);
- g_return_if_fail (GTK_IS_SHEET (sheet));
-
- if ( locked )
- {
- GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IS_LOCKED);
- gtk_widget_hide (sheet->sheet_entry);
- gtk_widget_unmap (sheet->sheet_entry);
- }
- else
- {
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IS_LOCKED);
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (sheet)))
- {
- gtk_widget_show (sheet->sheet_entry);
- gtk_widget_map (sheet->sheet_entry);
- }
- }
-
- gtk_editable_set_editable (GTK_EDITABLE (sheet->sheet_entry), locked);
-
-}
-
-gboolean
-gtk_sheet_locked (const GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
-
- return GTK_SHEET_IS_LOCKED (sheet);
-}
/* This routine has problems with gtk+- 1.2 related with the
label / button drawing - I think it's a bug in gtk+- 1.2 */
width = sheet->sheet_window_width;
/* adjust vertical scrollbar */
- if (row >= 0 && row_align >= 0.)
+ if (row >= 0 && row_align >= 0.0)
{
y = ROW_TOP_YPIXEL (sheet, row) - sheet->voffset
- - (gint) ( row_align*height + (1. - row_align)
+ - (gint) ( row_align * height + (1.0 - row_align)
* yyy_row_height (sheet, row));
/* This forces the sheet to scroll when you don't see the entire cell */
min_row = row;
adjust = 0;
- if (row_align == 1.)
+ if (row_align >= 1.0)
{
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 (adjust >= height)
{
break;
min_row--;
}
min_row = MAX (min_row, 0);
+
+ min_row ++;
+
y = ROW_TOP_YPIXEL (sheet, min_row) - sheet->voffset +
yyy_row_height (sheet, min_row) - 1;
}
}
/* adjust horizontal scrollbar */
- if (column >= 0 && col_align >= 0.)
+ if (column >= 0 && col_align >= 0.0)
{
x = COLUMN_LEFT_XPIXEL (sheet, column) - sheet->hoffset
- - (gint) ( col_align*width + (1.- col_align)*
+ - (gint) ( col_align*width + (1.0 - col_align)*
xxx_column_width (sheet, column));
-
/* This forces the sheet to scroll when you don't see the entire cell */
min_col = column;
adjust = 0;
- if (col_align == 1.)
+ if (col_align == 1.0)
{
while (min_col >= 0 && min_col > MIN_VISIBLE_COLUMN (sheet))
{
sheet->old_vadjustment = -1.;
g_signal_emit_by_name (G_OBJECT (sheet->hadjustment),
"value_changed");
-
}
}
}
if (!GTK_WIDGET_MAPPED (sheet->sheet_entry)
- && ! gtk_sheet_locked (sheet)
&& sheet->active_cell.row >= 0
&& sheet->active_cell.col >= 0 )
{
gtk_sheet_get_attributes (sheet, row, col, &attributes);
justification = attributes.justification;
- if (text && strlen (text) != 0)
- {
- gtk_sheet_set_cell (sheet, row, col, justification, text);
- g_signal_emit (G_OBJECT (sheet), sheet_signals[SET_CELL], 0, row, col);
- }
- else
- {
- gtk_sheet_cell_clear (sheet, row, col);
- }
-
row = sheet->active_cell.row;
col = sheet->active_cell.col;
g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE);
if (row < 0 || col < 0) return FALSE;
- if (row >= yyy_row_count (sheet) || col >= xxx_column_count (sheet))
+
+ if ( row > yyy_row_count (sheet) || col > xxx_column_count (sheet))
return FALSE;
if (!veto) return FALSE;
gtk_sheet_show_active_cell (sheet);
-
g_signal_connect (G_OBJECT (gtk_sheet_get_entry (sheet)),
"changed",
G_CALLBACK (gtk_sheet_entry_changed),
gtk_entry_set_visibility (GTK_ENTRY (sheet_entry), attributes.is_visible);
- if (gtk_sheet_locked (sheet) || !attributes.is_editable)
- gtk_editable_set_editable (GTK_EDITABLE (sheet_entry), FALSE);
- else
- gtk_editable_set_editable (GTK_EDITABLE (sheet_entry), TRUE);
/*** Added by John Gotts. Mar 25, 2005 *********/
old_text = gtk_entry_get_text (GTK_ENTRY (sheet_entry));
if (range->col0 < 0 || range->coli < 0) return;
- if ( gtk_sheet_locked (sheet)) return ;
-
if (sheet->state != GTK_SHEET_NORMAL)
gtk_sheet_real_unselect_range (sheet, NULL);
else
else if (sheet->cursor_drag->type == GDK_TOP_LEFT_ARROW &&
!GTK_SHEET_IN_SELECTION (sheet)
&& ! GTK_SHEET_IN_DRAG (sheet)
- && ! gtk_sheet_locked (sheet)
&& sheet->active_cell.row >= 0
&& sheet->active_cell.col >= 0
)
return TRUE;
}
-#if 0
-static gint
-gtk_sheet_scroll (gpointer data)
-{
- GtkSheet *sheet;
- gint x, y, row, column;
- gint move;
-
- sheet = GTK_SHEET (data);
-
- GDK_THREADS_ENTER ();
-
- gtk_widget_get_pointer (GTK_WIDGET (sheet), &x, &y);
- gtk_sheet_get_pixel_info (sheet, x, y, &row, &column);
-
- move = TRUE;
-
- if (GTK_SHEET_IN_SELECTION (sheet))
- gtk_sheet_extend_selection (sheet, row, column);
-
- if (GTK_SHEET_IN_DRAG (sheet) || GTK_SHEET_IN_RESIZE (sheet))
- {
- move = gtk_sheet_move_query (sheet, row, column);
- if (move) draw_xor_rectangle (sheet, sheet->drag_range);
- }
-
- GDK_THREADS_LEAVE ();
-
- return TRUE;
-}
-#endif
-
static void
gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column, gboolean *veto)
{
if (row >= MAX_VISIBLE_ROW (sheet) && sheet->state != GTK_SHEET_COLUMN_SELECTED)
{
row_align = 1.;
- new_row = MIN (yyy_row_count (sheet), row + 1);
+ new_row = MIN (yyy_row_count (sheet) - 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) +
break;
case GDK_Home:
row = 0;
- while (!yyy_row_is_visible (sheet, row) && row < yyy_row_count (sheet)- 1) row++;
+ while (!yyy_row_is_visible (sheet, row) && row < yyy_row_count (sheet) - 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;
+ row = yyy_row_count (sheet) - 1;
while (!yyy_row_is_visible (sheet, row) && row > 0) row--;
gtk_sheet_click_cell (sheet, row, sheet->active_cell.col, &veto);
extend_selection = FALSE;