Make psppire_sheet_get_attributes a private function
[pspp-builds.git] / lib / gtk-contrib / psppire-sheet.c
index dac561a134b9b2ad99aac73c16699edab2852535..ad1cf78a7fd973d1af993e32696e59813b5f69f3 100644 (file)
@@ -476,6 +476,9 @@ static void psppire_sheet_size_request               (GtkWidget *widget,
 static void psppire_sheet_size_allocate                 (GtkWidget *widget,
                                                  GtkAllocation *allocation);
 
+static gboolean psppire_sheet_focus_in               (GtkWidget     *widget,
+                                                     GdkEventFocus *event);
+
 /* Sheet queries */
 
 static gboolean psppire_sheet_range_isvisible (const PsppireSheet *sheet,
@@ -1010,6 +1013,7 @@ psppire_sheet_class_init (PsppireSheetClass *klass)
   container_class->add = NULL;
   container_class->remove = NULL;
   container_class->forall = psppire_sheet_forall;
+  container_class->set_focus_child = NULL;
 
   object_class->dispose = psppire_sheet_dispose;
   object_class->finalize = psppire_sheet_finalize;
@@ -1064,7 +1068,7 @@ psppire_sheet_class_init (PsppireSheetClass *klass)
   widget_class->expose_event = psppire_sheet_expose;
   widget_class->size_request = psppire_sheet_size_request;
   widget_class->size_allocate = psppire_sheet_size_allocate;
-  widget_class->focus_in_event = NULL;
+  widget_class->focus_in_event = psppire_sheet_focus_in;
   widget_class->focus_out_event = NULL;
 
   klass->set_scroll_adjustments = psppire_sheet_set_scroll_adjustments;
@@ -2094,6 +2098,13 @@ psppire_sheet_unmap (GtkWidget *widget)
     gtk_widget_unmap (sheet->button);
 }
 
+/* get cell attributes of the given cell */
+/* TRUE means that the cell is currently allocated */
+static gboolean psppire_sheet_get_attributes (const PsppireSheet *sheet,
+                                             gint row, gint col,
+                                             PsppireSheetCellAttr *attributes);
+
+
 
 static void
 psppire_sheet_cell_draw (PsppireSheet *sheet, gint row, gint col)
@@ -4052,6 +4063,19 @@ psppire_sheet_crossing_notify (GtkWidget *widget,
   return TRUE;
 }
 
+
+static gboolean
+psppire_sheet_focus_in (GtkWidget     *w,
+                       GdkEventFocus *event)
+{
+  PsppireSheet *sheet = PSPPIRE_SHEET (w);
+
+  gtk_widget_grab_focus (sheet->entry_widget);
+
+  return TRUE;
+}
+
+
 static void
 psppire_sheet_extend_selection (PsppireSheet *sheet, gint row, gint column)
 {
@@ -4185,12 +4209,29 @@ step_sheet (PsppireSheet *sheet, GtkScrollType dir)
     case GTK_SCROLL_STEP_LEFT:
       new_cell.col--;
       break;
+    case GTK_SCROLL_STEP_FORWARD:
+      new_cell.col++;
+      if (new_cell.col >=
+         psppire_sheet_model_get_column_count (sheet->model))
+       {
+         new_cell.col = 0;
+         new_cell.row++;
+       }
+      break;
+    case GTK_SCROLL_STEP_BACKWARD:
+      new_cell.col--;
+      if (new_cell.col < 0)
+       {
+         new_cell.col =
+           psppire_sheet_model_get_column_count (sheet->model) - 1;
+         new_cell.row--;
+       }
+      break;
     default:
       g_assert_not_reached ();
       break;
     }
 
-
   g_signal_emit (sheet, sheet_signals[TRAVERSE], 0,
                 &sheet->active_cell,
                 &new_cell,
@@ -4268,10 +4309,14 @@ psppire_sheet_key_press (GtkWidget *widget,
   switch (key->keyval)
     {
     case GDK_Tab:
+      step_sheet (sheet, GTK_SCROLL_STEP_FORWARD);
+      break;
     case GDK_Right:
       step_sheet (sheet, GTK_SCROLL_STEP_RIGHT);
       break;
     case GDK_ISO_Left_Tab:
+      step_sheet (sheet, GTK_SCROLL_STEP_BACKWARD);
+      break;
     case GDK_Left:
       step_sheet (sheet, GTK_SCROLL_STEP_LEFT);
       break;
@@ -4584,8 +4629,6 @@ set_entry_widget_font (PsppireSheet *sheet)
   gtk_widget_modify_style (sheet->entry_widget, style);
 }
 
-
-
 static void
 create_sheet_entry (PsppireSheet *sheet)
 {
@@ -4711,6 +4754,26 @@ draw_button (PsppireSheet *sheet, GdkWindow *window,
                   allocation.x, allocation.y,
                   allocation.width, allocation.height);
 
+  if ( button->overstruck)
+    {
+      GdkPoint points[2] = {
+       {allocation.x,  allocation.y},
+       {allocation.x + allocation.width,
+        allocation.y + allocation.height}
+      };
+
+      gtk_paint_polygon (sheet->button->style,
+                        window,
+                        button->state,
+                        shadow_type,
+                        NULL,
+                        GTK_WIDGET (sheet),
+                        "button",
+                        points,
+                        2,
+                        TRUE);
+    }
+
   if (button->label_visible)
     {
       text_height = DEFAULT_ROW_HEIGHT -
@@ -5192,7 +5255,7 @@ set_row_height (PsppireSheet *sheet,
     }
 }
 
-gboolean
+static gboolean
 psppire_sheet_get_attributes (const PsppireSheet *sheet, gint row, gint col,
                          PsppireSheetCellAttr *attr)
 {
@@ -5215,8 +5278,6 @@ psppire_sheet_get_attributes (const PsppireSheet *sheet, gint row, gint col,
   attr->border.mask = 0;
   attr->border.color = GTK_WIDGET (sheet)->style->black;
 
-  attr->is_editable = psppire_sheet_model_is_editable (sheet->model, row, col);
-
   colormap = gtk_widget_get_colormap (GTK_WIDGET (sheet));
   fg = psppire_sheet_model_get_foreground (sheet->model, row, col);
   if ( fg )
@@ -5299,6 +5360,7 @@ psppire_sheet_button_new (void)
   button->label = NULL;
   button->label_visible = TRUE;
   button->justification = GTK_JUSTIFY_FILL;
+  button->overstruck = FALSE;
 
   return button;
 }