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 "gsheet-column-iface.h"
34 #include "gsheet-row-iface.h"
43 GTK_SHEET_ROW_SELECTED,
44 GTK_SHEET_COLUMN_SELECTED,
45 GTK_SHEET_RANGE_SELECTED
49 #define GTK_TYPE_SHEET_RANGE (gtk_sheet_range_get_type ())
50 #define GTK_TYPE_SHEET (gtk_sheet_get_type ())
52 #define GTK_SHEET(obj) GTK_CHECK_CAST (obj, gtk_sheet_get_type (), GtkSheet)
53 #define GTK_SHEET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_sheet_get_type (), GtkSheetClass)
54 #define GTK_IS_SHEET(obj) GTK_CHECK_TYPE (obj, gtk_sheet_get_type ())
57 typedef struct _GtkSheetClass GtkSheetClass;
58 typedef struct _GtkSheetCellAttr GtkSheetCellAttr;
59 typedef struct _GtkSheetCell GtkSheetCell;
60 typedef struct _GtkSheetHoverTitle GtkSheetHoverTitle;
63 struct _GtkSheetCellAttr
65 GtkJustification justification;
66 const PangoFontDescription *font_desc;
69 GtkSheetCellBorder border;
81 struct _GtkSheetHoverTitle
99 gboolean dispose_has_run;
100 GSheetColumn *column_geometry;
101 GSheetRow *row_geometry;
107 GtkSelectionMode selection_mode;
109 /* Component colors */
110 GdkColor color[n_COLORS];
113 /* allocation rectangle after the container_border_width
114 and the width of the shadow border */
115 GdkRectangle internal_allocation;
117 gint16 column_requisition;
118 gint16 row_requisition;
120 gboolean rows_resizable;
121 gboolean columns_resizable;
124 GtkSheetCell active_cell;
126 /* The GtkEntry used for editing the cells */
127 GtkWidget *entry_widget;
129 /* The widget containing entry_widget, or
130 entry_widget itself if no container */
131 GtkWidget *entry_container;
133 /* The type of entry_widget */
136 /* expanding selection */
137 GtkSheetCell selection_cell;
139 /* global selection button */
148 /* the scrolling window and its height and width to
149 * make things a little speedier */
150 GdkWindow *sheet_window;
152 /* border shadow style */
153 GtkShadowType shadow_type;
156 GdkRectangle column_title_area;
157 GdkWindow *column_title_window;
158 gboolean column_titles_visible;
159 /* TRUE if the cursor is over the column title window */
160 gboolean column_title_under;
163 GdkRectangle row_title_area;
164 GdkWindow *row_title_window;
165 gboolean row_titles_visible;
166 /* TRUE if the cursor is over the row title window */
167 gboolean row_title_under;
170 GtkAdjustment *hadjustment;
171 GtkAdjustment *vadjustment;
173 /* xor GC for the verticle drag line */
176 /* gc for drawing unselected cells */
180 /* cursor used to indicate dragging */
181 GdkCursor *cursor_drag;
183 /* the current x-pixel location of the xor-drag vline */
186 /* the current y-pixel location of the xor-drag hline */
189 /* current cell being dragged */
190 GtkSheetCell drag_cell;
191 /* current range being dragged */
192 GtkSheetRange drag_range;
194 /* Used for the subtitle (popups) */
196 GtkSheetHoverTitle *hover_window;
199 struct _GtkSheetClass
201 GtkBinClass parent_class;
203 void (*set_scroll_adjustments) (GtkSheet *sheet,
204 GtkAdjustment *hadjustment,
205 GtkAdjustment *vadjustment);
207 void (*select_row) (GtkSheet *sheet, gint row);
209 void (*select_column) (GtkSheet *sheet, gint column);
211 void (*select_range) (GtkSheet *sheet, GtkSheetRange *range);
213 void (*resize_range) (GtkSheet *sheet,
214 GtkSheetRange *old_range,
215 GtkSheetRange *new_range);
217 void (*move_range) (GtkSheet *sheet,
218 GtkSheetRange *old_range,
219 GtkSheetRange *new_range);
221 gboolean (*traverse) (GtkSheet *sheet,
222 gint row, gint column,
223 gint *new_row, gint *new_column);
225 gboolean (*deactivate) (GtkSheet *sheet,
226 gint row, gint column);
228 gboolean (*activate) (GtkSheet *sheet,
229 gint row, gint column);
231 void (*changed) (GtkSheet *sheet,
232 gint row, gint column);
235 GType gtk_sheet_get_type (void);
236 GtkType gtk_sheet_range_get_type (void);
239 /* create a new sheet */
240 GtkWidget * gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo,
243 /* create a new sheet with custom entry */
245 gtk_sheet_new_with_custom_entry (GSheetRow *vgeo,
249 gtk_sheet_construct_with_custom_entry (GtkSheet *sheet,
254 void gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type);
256 GtkWidget *gtk_sheet_get_entry (GtkSheet *sheet);
259 void gtk_sheet_get_selected_range (GtkSheet *sheet,
260 GtkSheetRange *range);
262 void gtk_sheet_show_grid (GtkSheet *sheet,
265 gboolean gtk_sheet_grid_visible (GtkSheet *sheet);
268 /* scroll the viewing area of the sheet to the given column
269 * and row; row_align and col_align are between 0-1 representing the
270 * location the row should appear on the screen, 0.0 being top or left,
271 * 1.0 being bottom or right; if row or column is negative then there
273 void gtk_sheet_moveto (GtkSheet *sheet,
280 void gtk_sheet_show_row_titles (GtkSheet *sheet);
281 void gtk_sheet_hide_row_titles (GtkSheet *sheet);
282 void gtk_sheet_show_column_titles (GtkSheet *sheet);
283 void gtk_sheet_hide_column_titles (GtkSheet *sheet);
285 /* select the row. The range is then highlighted, and the bounds are stored
287 void gtk_sheet_select_row (GtkSheet * sheet, gint row);
289 /* select the column. The range is then highlighted, and the bounds are stored
291 void gtk_sheet_select_column (GtkSheet * sheet, gint column);
293 /* highlight the selected range and store bounds in sheet->range */
294 void gtk_sheet_select_range (GtkSheet *sheet, const GtkSheetRange *range);
296 void gtk_sheet_get_visible_range (GtkSheet *sheet, GtkSheetRange *range);
300 void gtk_sheet_unselect_range (GtkSheet *sheet);
302 /* set active cell where the entry will be displayed */
303 void gtk_sheet_set_active_cell (GtkSheet *sheet,
304 gint row, gint column);
306 /* Sets *ROW and *COLUMN to be the coordinates of the active cell.
307 ROW and/or COLUMN may be null if the caller is not interested in their
309 void gtk_sheet_get_active_cell (GtkSheet *sheet,
310 gint *row, gint *column);
312 /* get cell contents */
313 gchar *gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col);
316 /* get cell attributes of the given cell */
317 /* TRUE means that the cell is currently allocated */
318 gboolean gtk_sheet_get_attributes (const GtkSheet *sheet,
320 GtkSheetCellAttr *attributes);
322 void gtk_sheet_set_model (GtkSheet *sheet,
325 GSheetModel * gtk_sheet_get_model (const GtkSheet *sheet);
331 #endif /* __GTK_SHEET_H__ */