1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2011, 2012 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Library General Public
22 * License as published by the Free Software Foundation; either
23 * version 2 of the License, or (at your option) any later version.
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Library General Public License for more details.
30 * You should have received a copy of the GNU Library General Public
31 * License along with this library; if not, write to the
32 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
33 * Boston, MA 02111-1307, USA.
36 #ifndef __PSPP_SHEET_VIEW_H__
37 #define __PSPP_SHEET_VIEW_H__
40 #include "ui/gui/pspp-sheet-view-column.h"
47 PSPP_SHEET_VIEW_GRID_LINES_NONE,
48 PSPP_SHEET_VIEW_GRID_LINES_HORIZONTAL,
49 PSPP_SHEET_VIEW_GRID_LINES_VERTICAL,
50 PSPP_SHEET_VIEW_GRID_LINES_BOTH
51 } PsppSheetViewGridLines;
53 GType pspp_sheet_view_grid_lines_get_type (void) G_GNUC_CONST;
54 #define PSPP_TYPE_SHEET_VIEW_GRID_LINES (pspp_sheet_view_grid_lines_get_type ())
56 /* A "special cell" is a cell that is editable or activatable. When a row that
57 * contains a special cell is selected, the cursor is drawn around a single
58 * cell; when other rows are selected, the cursor is drawn around the entire
61 * With the default of "detect", whether a given row contains a special cell is
62 * detected automatically. This is the best choice most of the time. For
63 * sheet views that contain more than 100 columns, an explicit "yes" or "no"
64 * improves performance. */
67 PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT,
68 PSPP_SHEET_VIEW_SPECIAL_CELLS_YES,
69 PSPP_SHEET_VIEW_SPECIAL_CELLS_NO,
70 } PsppSheetViewSpecialCells;
72 GType pspp_sheet_view_special_cells_get_type (void) G_GNUC_CONST;
73 #define PSPP_TYPE_SHEET_VIEW_SPECIAL_CELLS (pspp_sheet_view_special_cells_get_type ())
77 /* drop before/after this row */
78 PSPP_SHEET_VIEW_DROP_BEFORE,
79 PSPP_SHEET_VIEW_DROP_AFTER,
80 /* drop as a child of this row (with fallback to before or after
81 * if into is not possible)
83 PSPP_SHEET_VIEW_DROP_INTO_OR_BEFORE,
84 PSPP_SHEET_VIEW_DROP_INTO_OR_AFTER
85 } PsppSheetViewDropPosition;
87 #define PSPP_TYPE_SHEET_VIEW (pspp_sheet_view_get_type ())
88 #define PSPP_SHEET_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPP_TYPE_SHEET_VIEW, PsppSheetView))
89 #define PSPP_SHEET_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PSPP_TYPE_SHEET_VIEW, PsppSheetViewClass))
90 #define PSPP_IS_SHEET_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPP_TYPE_SHEET_VIEW))
91 #define PSPP_IS_SHEET_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPP_TYPE_SHEET_VIEW))
92 #define PSPP_SHEET_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PSPP_TYPE_SHEET_VIEW, PsppSheetViewClass))
94 typedef struct _PsppSheetView PsppSheetView;
95 typedef struct _PsppSheetViewClass PsppSheetViewClass;
96 typedef struct _PsppSheetViewPrivate PsppSheetViewPrivate;
97 typedef struct _PsppSheetSelection PsppSheetSelection;
98 typedef struct _PsppSheetSelectionClass PsppSheetSelectionClass;
100 struct _PsppSheetView
104 PsppSheetViewPrivate *GSEAL (priv);
107 struct _PsppSheetViewClass
109 GtkContainerClass parent_class;
111 void (* set_scroll_adjustments) (PsppSheetView *tree_view,
112 GtkAdjustment *hadjustment,
113 GtkAdjustment *vadjustment);
114 void (* row_activated) (PsppSheetView *tree_view,
116 PsppSheetViewColumn *column);
117 void (* columns_changed) (PsppSheetView *tree_view);
118 void (* cursor_changed) (PsppSheetView *tree_view);
120 /* Key Binding signals */
121 gboolean (* move_cursor) (PsppSheetView *tree_view,
122 GtkMovementStep step,
124 gboolean (* select_all) (PsppSheetView *tree_view);
125 gboolean (* unselect_all) (PsppSheetView *tree_view);
126 gboolean (* select_cursor_row) (PsppSheetView *tree_view,
127 gboolean start_editing);
128 gboolean (* toggle_cursor_row) (PsppSheetView *tree_view);
129 gboolean (* select_cursor_parent) (PsppSheetView *tree_view);
130 gboolean (* start_interactive_search) (PsppSheetView *tree_view);
132 /* Padding for future expansion */
133 void (*_gtk_reserved0) (void);
134 void (*_gtk_reserved1) (void);
135 void (*_gtk_reserved2) (void);
136 void (*_gtk_reserved3) (void);
137 void (*_gtk_reserved4) (void);
141 typedef gboolean (* PsppSheetViewColumnDropFunc) (PsppSheetView *tree_view,
142 PsppSheetViewColumn *column,
143 PsppSheetViewColumn *prev_column,
144 PsppSheetViewColumn *next_column,
146 typedef void (* PsppSheetViewMappingFunc) (PsppSheetView *tree_view,
149 typedef gboolean (*PsppSheetViewSearchEqualFunc) (GtkTreeModel *model,
153 gpointer search_data);
154 typedef void (*PsppSheetViewSearchPositionFunc) (PsppSheetView *tree_view,
155 GtkWidget *search_dialog,
160 GType pspp_sheet_view_get_type (void) G_GNUC_CONST;
161 GtkWidget *pspp_sheet_view_new (void);
162 GtkWidget *pspp_sheet_view_new_with_model (GtkTreeModel *model);
165 GtkTreeModel *pspp_sheet_view_get_model (PsppSheetView *tree_view);
166 void pspp_sheet_view_set_model (PsppSheetView *tree_view,
167 GtkTreeModel *model);
168 PsppSheetSelection *pspp_sheet_view_get_selection (PsppSheetView *tree_view);
169 GtkAdjustment *pspp_sheet_view_get_hadjustment (PsppSheetView *tree_view);
170 void pspp_sheet_view_set_hadjustment (PsppSheetView *tree_view,
171 GtkAdjustment *adjustment);
172 GtkAdjustment *pspp_sheet_view_get_vadjustment (PsppSheetView *tree_view);
173 void pspp_sheet_view_set_vadjustment (PsppSheetView *tree_view,
174 GtkAdjustment *adjustment);
175 gboolean pspp_sheet_view_get_headers_visible (PsppSheetView *tree_view);
176 void pspp_sheet_view_set_headers_visible (PsppSheetView *tree_view,
177 gboolean headers_visible);
178 void pspp_sheet_view_columns_autosize (PsppSheetView *tree_view);
179 gboolean pspp_sheet_view_get_headers_clickable (PsppSheetView *tree_view);
180 void pspp_sheet_view_set_headers_clickable (PsppSheetView *tree_view,
182 void pspp_sheet_view_set_rules_hint (PsppSheetView *tree_view,
184 gboolean pspp_sheet_view_get_rules_hint (PsppSheetView *tree_view);
186 /* Column funtions */
187 gint pspp_sheet_view_append_column (PsppSheetView *tree_view,
188 PsppSheetViewColumn *column);
189 gint pspp_sheet_view_remove_column (PsppSheetView *tree_view,
190 PsppSheetViewColumn *column);
191 gint pspp_sheet_view_insert_column (PsppSheetView *tree_view,
192 PsppSheetViewColumn *column,
194 gint pspp_sheet_view_insert_column_with_attributes (PsppSheetView *tree_view,
197 GtkCellRenderer *cell,
198 ...) G_GNUC_NULL_TERMINATED;
199 gint pspp_sheet_view_insert_column_with_data_func (PsppSheetView *tree_view,
202 GtkCellRenderer *cell,
203 PsppSheetCellDataFunc func,
205 GDestroyNotify dnotify);
206 PsppSheetViewColumn *pspp_sheet_view_get_column (PsppSheetView *tree_view,
208 GList *pspp_sheet_view_get_columns (PsppSheetView *tree_view);
209 void pspp_sheet_view_move_column_after (PsppSheetView *tree_view,
210 PsppSheetViewColumn *column,
211 PsppSheetViewColumn *base_column);
212 void pspp_sheet_view_set_column_drag_function (PsppSheetView *tree_view,
213 PsppSheetViewColumnDropFunc func,
215 GDestroyNotify destroy);
218 void pspp_sheet_view_scroll_to_point (PsppSheetView *tree_view,
221 void pspp_sheet_view_scroll_to_cell (PsppSheetView *tree_view,
223 PsppSheetViewColumn *column,
227 void pspp_sheet_view_row_activated (PsppSheetView *tree_view,
229 PsppSheetViewColumn *column);
230 void pspp_sheet_view_set_reorderable (PsppSheetView *tree_view,
231 gboolean reorderable);
232 gboolean pspp_sheet_view_get_reorderable (PsppSheetView *tree_view);
233 void pspp_sheet_view_set_cursor (PsppSheetView *tree_view,
235 PsppSheetViewColumn *focus_column,
236 gboolean start_editing);
237 void pspp_sheet_view_set_cursor_on_cell (PsppSheetView *tree_view,
239 PsppSheetViewColumn *focus_column,
240 GtkCellRenderer *focus_cell,
241 gboolean start_editing);
242 void pspp_sheet_view_get_cursor (PsppSheetView *tree_view,
244 PsppSheetViewColumn **focus_column);
247 /* Layout information */
248 GdkWindow *pspp_sheet_view_get_bin_window (PsppSheetView *tree_view);
249 gboolean pspp_sheet_view_get_path_at_pos (PsppSheetView *tree_view,
253 PsppSheetViewColumn **column,
256 void pspp_sheet_view_get_cell_area (PsppSheetView *tree_view,
258 PsppSheetViewColumn *column,
260 void pspp_sheet_view_get_background_area (PsppSheetView *tree_view,
262 PsppSheetViewColumn *column,
264 void pspp_sheet_view_get_visible_rect (PsppSheetView *tree_view,
265 GdkRectangle *visible_rect);
267 #ifndef GTK_DISABLE_DEPRECATED
268 void pspp_sheet_view_widget_to_tree_coords (PsppSheetView *tree_view,
273 void pspp_sheet_view_tree_to_widget_coords (PsppSheetView *tree_view,
278 #endif /* !GTK_DISABLE_DEPRECATED */
279 gboolean pspp_sheet_view_get_visible_range (PsppSheetView *tree_view,
280 GtkTreePath **start_path,
281 GtkTreePath **end_path);
283 /* Drag-and-Drop support */
284 void pspp_sheet_view_enable_model_drag_source (PsppSheetView *tree_view,
285 GdkModifierType start_button_mask,
286 const GtkTargetEntry *targets,
288 GdkDragAction actions);
289 void pspp_sheet_view_enable_model_drag_dest (PsppSheetView *tree_view,
290 const GtkTargetEntry *targets,
292 GdkDragAction actions);
293 void pspp_sheet_view_unset_rows_drag_source (PsppSheetView *tree_view);
294 void pspp_sheet_view_unset_rows_drag_dest (PsppSheetView *tree_view);
297 /* These are useful to implement your own custom stuff. */
298 void pspp_sheet_view_set_drag_dest_row (PsppSheetView *tree_view,
300 PsppSheetViewDropPosition pos);
301 void pspp_sheet_view_get_drag_dest_row (PsppSheetView *tree_view,
303 PsppSheetViewDropPosition *pos);
304 gboolean pspp_sheet_view_get_dest_row_at_pos (PsppSheetView *tree_view,
308 PsppSheetViewDropPosition *pos);
309 GdkPixmap *pspp_sheet_view_create_row_drag_icon (PsppSheetView *tree_view,
312 /* Interactive search */
313 void pspp_sheet_view_set_enable_search (PsppSheetView *tree_view,
314 gboolean enable_search);
315 gboolean pspp_sheet_view_get_enable_search (PsppSheetView *tree_view);
316 gint pspp_sheet_view_get_search_column (PsppSheetView *tree_view);
317 void pspp_sheet_view_set_search_column (PsppSheetView *tree_view,
319 PsppSheetViewSearchEqualFunc pspp_sheet_view_get_search_equal_func (PsppSheetView *tree_view);
320 void pspp_sheet_view_set_search_equal_func (PsppSheetView *tree_view,
321 PsppSheetViewSearchEqualFunc search_equal_func,
322 gpointer search_user_data,
323 GDestroyNotify search_destroy);
325 GtkEntry *pspp_sheet_view_get_search_entry (PsppSheetView *tree_view);
326 void pspp_sheet_view_set_search_entry (PsppSheetView *tree_view,
328 PsppSheetViewSearchPositionFunc pspp_sheet_view_get_search_position_func (PsppSheetView *tree_view);
329 void pspp_sheet_view_set_search_position_func (PsppSheetView *tree_view,
330 PsppSheetViewSearchPositionFunc func,
332 GDestroyNotify destroy);
334 /* Convert between the different coordinate systems */
335 void pspp_sheet_view_convert_widget_to_tree_coords (PsppSheetView *tree_view,
340 void pspp_sheet_view_convert_tree_to_widget_coords (PsppSheetView *tree_view,
345 void pspp_sheet_view_convert_widget_to_bin_window_coords (PsppSheetView *tree_view,
350 void pspp_sheet_view_convert_bin_window_to_widget_coords (PsppSheetView *tree_view,
355 void pspp_sheet_view_convert_tree_to_bin_window_coords (PsppSheetView *tree_view,
360 void pspp_sheet_view_convert_bin_window_to_tree_coords (PsppSheetView *tree_view,
366 /* This function should really never be used. It is just for use by ATK.
368 typedef void (* PsppSheetDestroyCountFunc) (PsppSheetView *tree_view,
372 void pspp_sheet_view_set_destroy_count_func (PsppSheetView *tree_view,
373 PsppSheetDestroyCountFunc func,
375 GDestroyNotify destroy);
377 void pspp_sheet_view_set_hover_selection (PsppSheetView *tree_view,
379 gboolean pspp_sheet_view_get_hover_selection (PsppSheetView *tree_view);
380 void pspp_sheet_view_set_rubber_banding (PsppSheetView *tree_view,
382 gboolean pspp_sheet_view_get_rubber_banding (PsppSheetView *tree_view);
384 gboolean pspp_sheet_view_is_rubber_banding_active (PsppSheetView *tree_view);
386 PsppSheetViewGridLines pspp_sheet_view_get_grid_lines (PsppSheetView *tree_view);
387 void pspp_sheet_view_set_grid_lines (PsppSheetView *tree_view,
388 PsppSheetViewGridLines grid_lines);
390 PsppSheetViewSpecialCells pspp_sheet_view_get_special_cells (PsppSheetView *tree_view);
391 void pspp_sheet_view_set_special_cells (PsppSheetView *tree_view,
392 PsppSheetViewSpecialCells);
394 int pspp_sheet_view_get_fixed_height (const PsppSheetView *);
395 void pspp_sheet_view_set_fixed_height (PsppSheetView *,
398 /* Convenience functions for setting tooltips */
399 void pspp_sheet_view_set_tooltip_row (PsppSheetView *tree_view,
402 void pspp_sheet_view_set_tooltip_cell (PsppSheetView *tree_view,
405 PsppSheetViewColumn *column,
406 GtkCellRenderer *cell);
407 gboolean pspp_sheet_view_get_tooltip_context(PsppSheetView *tree_view,
410 gboolean keyboard_tip,
411 GtkTreeModel **model,
414 void pspp_sheet_view_set_tooltip_column (PsppSheetView *tree_view,
416 gint pspp_sheet_view_get_tooltip_column (PsppSheetView *tree_view);
418 void pspp_sheet_view_stop_editing (PsppSheetView *tree_view,
419 gboolean cancel_editing);
424 #endif /* __PSPP_SHEET_VIEW_H__ */