1 /* This version of GtkSheet has been heavily modified, for the specific
2 requirements of PSPPIRE. */
5 /* GtkSheet widget for Gtk+.
6 * Copyright (C) 1999-2001 Adrian E. Feiguin <adrian@ifir.ifir.edu.ar>
8 * Based on GtkClist widget by Jay Painter, but major changes.
9 * Memory allocation routines inspired on SC (Spreadsheet Calculator)
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #ifndef __GTK_SHEET_H__
27 #define __GTK_SHEET_H__
31 #include "gtkextra-sheet.h"
32 #include "gsheetmodel.h"
33 #include "psppire-axis.h"
41 GTK_SHEET_ROW_SELECTED,
42 GTK_SHEET_COLUMN_SELECTED,
43 GTK_SHEET_RANGE_SELECTED
47 #define GTK_TYPE_SHEET_RANGE (gtk_sheet_range_get_type ())
48 #define GTK_TYPE_SHEET_CELL (gtk_sheet_cell_get_type ())
49 #define GTK_TYPE_SHEET (gtk_sheet_get_type ())
51 #define GTK_SHEET(obj) GTK_CHECK_CAST (obj, gtk_sheet_get_type (), GtkSheet)
52 #define GTK_SHEET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_sheet_get_type (), GtkSheetClass)
53 #define GTK_IS_SHEET(obj) GTK_CHECK_TYPE (obj, gtk_sheet_get_type ())
56 typedef struct _GtkSheetClass GtkSheetClass;
57 typedef struct _GtkSheetCellAttr GtkSheetCellAttr;
59 typedef struct _GtkSheetHoverTitle GtkSheetHoverTitle;
62 struct _GtkSheetCellAttr
64 GtkJustification justification;
65 const PangoFontDescription *font_desc;
68 GtkSheetCellBorder border;
73 struct _GtkSheetHoverTitle
91 gboolean dispose_has_run;
99 GtkSelectionMode selection_mode;
101 /* Component colors */
102 GdkColor color[n_COLORS];
105 /* allocation rectangle after the container_border_width
106 and the width of the shadow border */
107 GdkRectangle internal_allocation;
109 gint16 column_requisition;
110 gint16 row_requisition;
112 gboolean rows_resizable;
113 gboolean columns_resizable;
116 GtkSheetCell active_cell;
118 /* The GtkEntry used for editing the cells */
119 GtkWidget *entry_widget;
121 /* The type of entry_widget */
124 /* Handler of the "changed" callback for the entry widget */
125 glong entry_handler_id;
127 /* expanding selection */
128 GtkSheetCell selection_cell;
130 /* global selection button */
139 /* the scrolling window and its height and width to
140 * make things a little speedier */
141 GdkWindow *sheet_window;
143 /* border shadow style */
144 GtkShadowType shadow_type;
147 GdkRectangle column_title_area;
148 GdkWindow *column_title_window;
149 gboolean column_titles_visible;
150 /* TRUE if the cursor is over the column title window */
151 gboolean column_title_under;
154 GdkRectangle row_title_area;
155 GdkWindow *row_title_window;
156 gboolean row_titles_visible;
157 /* TRUE if the cursor is over the row title window */
158 gboolean row_title_under;
161 GtkAdjustment *hadjustment;
162 GtkAdjustment *vadjustment;
164 /* xor GC for the verticle drag line */
167 /* gc for drawing unselected cells */
171 /* cursor used to indicate dragging */
172 GdkCursor *cursor_drag;
174 /* the current x-pixel location of the xor-drag vline */
177 /* the current y-pixel location of the xor-drag hline */
180 /* current cell being dragged */
181 GtkSheetCell drag_cell;
182 /* current range being dragged */
183 GtkSheetRange drag_range;
185 /* Used for the subtitle (popups) */
187 GtkSheetHoverTitle *hover_window;
190 struct _GtkSheetClass
192 GtkBinClass parent_class;
194 void (*set_scroll_adjustments) (GtkSheet *sheet,
195 GtkAdjustment *hadjustment,
196 GtkAdjustment *vadjustment);
198 void (*select_row) (GtkSheet *sheet, gint row);
200 void (*select_column) (GtkSheet *sheet, gint column);
202 void (*select_range) (GtkSheet *sheet, GtkSheetRange *range);
204 void (*resize_range) (GtkSheet *sheet,
205 GtkSheetRange *old_range,
206 GtkSheetRange *new_range);
208 void (*move_range) (GtkSheet *sheet,
209 GtkSheetRange *old_range,
210 GtkSheetRange *new_range);
212 gboolean (*traverse) (GtkSheet *sheet,
213 gint row, gint column,
214 gint *new_row, gint *new_column);
216 gboolean (*activate) (GtkSheet *sheet,
217 gint row, gint column);
219 void (*changed) (GtkSheet *sheet,
220 gint row, gint column);
223 GType gtk_sheet_get_type (void);
224 GtkType gtk_sheet_range_get_type (void);
227 /* create a new sheet */
228 GtkWidget * gtk_sheet_new (GSheetModel *model);
230 /* create a new sheet with custom entry */
232 gtk_sheet_new_with_custom_entry (GtkType entry_type);
235 void gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type);
237 GtkEntry *gtk_sheet_get_entry (GtkSheet *sheet);
240 void gtk_sheet_get_selected_range (GtkSheet *sheet,
241 GtkSheetRange *range);
243 void gtk_sheet_show_grid (GtkSheet *sheet,
246 gboolean gtk_sheet_grid_visible (GtkSheet *sheet);
249 /* scroll the viewing area of the sheet to the given column
250 * and row; row_align and col_align are between 0-1 representing the
251 * location the row should appear on the screen, 0.0 being top or left,
252 * 1.0 being bottom or right; if row or column is negative then there
254 void gtk_sheet_moveto (GtkSheet *sheet,
261 void gtk_sheet_show_row_titles (GtkSheet *sheet);
262 void gtk_sheet_hide_row_titles (GtkSheet *sheet);
263 void gtk_sheet_show_column_titles (GtkSheet *sheet);
264 void gtk_sheet_hide_column_titles (GtkSheet *sheet);
266 /* select the row. The range is then highlighted, and the bounds are stored
268 void gtk_sheet_select_row (GtkSheet * sheet, gint row);
270 /* select the column. The range is then highlighted, and the bounds are stored
272 void gtk_sheet_select_column (GtkSheet * sheet, gint column);
274 /* highlight the selected range and store bounds in sheet->range */
275 void gtk_sheet_select_range (GtkSheet *sheet, const GtkSheetRange *range);
277 void gtk_sheet_get_visible_range (GtkSheet *sheet, GtkSheetRange *range);
281 void gtk_sheet_unselect_range (GtkSheet *sheet);
283 /* set active cell where the entry will be displayed */
284 void gtk_sheet_set_active_cell (GtkSheet *sheet,
285 gint row, gint column);
287 /* Sets *ROW and *COLUMN to be the coordinates of the active cell.
288 ROW and/or COLUMN may be null if the caller is not interested in their
290 void gtk_sheet_get_active_cell (GtkSheet *sheet,
291 gint *row, gint *column);
293 /* get cell contents */
294 gchar *gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col);
297 /* get cell attributes of the given cell */
298 /* TRUE means that the cell is currently allocated */
299 gboolean gtk_sheet_get_attributes (const GtkSheet *sheet,
301 GtkSheetCellAttr *attributes);
303 void gtk_sheet_set_model (GtkSheet *sheet,
306 GSheetModel * gtk_sheet_get_model (const GtkSheet *sheet);
312 #endif /* __GTK_SHEET_H__ */