1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2011, 2012, 2013 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 __GTK_TREE_PRIVATE_H__
37 #define __GTK_TREE_PRIVATE_H__
41 #include "libpspp/range-tower.h"
42 #include "ui/gui/pspp-sheet-view.h"
43 #include "ui/gui/pspp-sheet-view-column.h"
45 #define TREE_VIEW_DRAG_WIDTH 6
49 PSPP_SHEET_VIEW_IN_COLUMN_RESIZE = 1 << 2,
50 PSPP_SHEET_VIEW_HEADERS_VISIBLE = 1 << 4,
51 PSPP_SHEET_VIEW_DRAW_KEYFOCUS = 1 << 5,
52 PSPP_SHEET_VIEW_MODEL_SETUP = 1 << 6,
53 PSPP_SHEET_VIEW_IN_COLUMN_DRAG = 1 << 7
58 DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
59 DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
60 DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
61 DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
62 DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4
68 RUBBER_BAND_MAYBE_START = 1,
69 RUBBER_BAND_ACTIVE = 2
72 #define PSPP_SHEET_VIEW_SET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
73 #define PSPP_SHEET_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
74 #define PSPP_SHEET_VIEW_FLAG_SET(tree_view, flag) ((tree_view->priv->flags&flag)==flag)
75 #define TREE_VIEW_HEADER_HEIGHT(tree_view) (PSPP_SHEET_VIEW_FLAG_SET (tree_view, PSPP_SHEET_VIEW_HEADERS_VISIBLE)?tree_view->priv->header_height:0)
76 #define TREE_VIEW_COLUMN_REQUESTED_WIDTH(column) (CLAMP (column->requested_width, (column->min_width!=-1)?column->min_width:column->requested_width, (column->max_width!=-1)?column->max_width:column->requested_width))
78 /* This lovely little value is used to determine how far away from the title bar
79 * you can move the mouse and still have a column drag work.
81 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
83 typedef struct _PsppSheetViewColumnReorder PsppSheetViewColumnReorder;
84 struct _PsppSheetViewColumnReorder
88 PsppSheetViewColumn *left_column;
89 PsppSheetViewColumn *right_column;
92 struct _PsppSheetViewPrivate
97 /* tree information */
99 struct range_tower *selected;
107 GtkAdjustment *hadjustment;
108 GtkAdjustment *vadjustment;
111 GdkWindow *bin_window;
112 GdkWindow *header_window;
114 /* Scroll position state keeping */
115 GtkTreeRowReference *top_row;
117 /* dy == y pos of top_row + top_row_dy */
118 /* we cache it for simplicity of the code */
121 guint presize_handler_timer;
122 guint validate_rows_timer;
123 guint scroll_sync_timer;
125 /* Indentation and expander layout */
128 /* Key navigation (focus), selection */
131 GtkTreeRowReference *anchor;
132 GtkTreeRowReference *cursor;
134 PsppSheetViewColumn *focus_column;
136 /* Current pressed node, previously pressed, prelight */
140 gint press_start_node;
145 guint last_button_time;
152 PsppSheetViewColumn *edited_column;
155 /* Selection information */
156 PsppSheetSelection *selection;
158 /* Header information */
162 gint n_selected_columns;
164 PsppSheetViewColumnDropFunc column_drop_func;
165 gpointer column_drop_func_data;
166 GDestroyNotify column_drop_func_data_destroy;
167 GList *column_drag_info;
168 PsppSheetViewColumnReorder *cur_reorder;
170 /* Interactive Header reordering */
171 GdkWindow *drag_window;
172 GdkWindow *drag_highlight_window;
173 PsppSheetViewColumn *drag_column;
176 /* Interactive Header Resizing */
180 /* Non-interactive Header Resizing, expand flag support */
184 PsppSheetDestroyCountFunc destroy_count_func;
185 gpointer destroy_count_data;
186 GDestroyNotify destroy_count_destroy;
188 /* Scroll timeout (e.g. during dnd, rubber banding) */
189 guint scroll_timeout;
191 /* Row drag-and-drop */
192 GtkTreeRowReference *drag_dest_row;
193 PsppSheetViewDropPosition drag_dest_pos;
194 guint open_dest_timeout;
197 gint rubber_band_status;
200 gint rubber_band_shift;
201 gint rubber_band_ctrl;
203 int rubber_band_start_node;
205 int rubber_band_end_node;
207 /* Rectangular selection. */
208 PsppSheetViewColumn *anchor_column; /* XXX needs to be a weak pointer? */
212 gboolean fixed_height_set;
214 /* Scroll-to functionality when unrealized */
215 GtkTreeRowReference *scroll_to_path;
216 PsppSheetViewColumn *scroll_to_column;
217 gfloat scroll_to_row_align;
218 gfloat scroll_to_col_align;
220 /* Interactive search */
223 PsppSheetViewSearchPositionFunc search_position_func;
224 PsppSheetViewSearchEqualFunc search_equal_func;
225 gpointer search_user_data;
226 GDestroyNotify search_destroy;
227 gpointer search_position_user_data;
228 GDestroyNotify search_position_destroy;
229 GtkWidget *search_window;
230 GtkWidget *search_entry;
231 guint search_entry_changed_id;
232 guint typeselect_flush_timeout;
234 /* Grid and tree lines */
235 PsppSheetViewGridLines grid_lines;
236 GdkGC *grid_line_gc[5];
239 PsppSheetViewSpecialCells special_cells;
241 /* Tooltip support */
244 /* Cached style for button facades in columns. */
245 GtkStyle *button_style;
247 /* Here comes the bitfield */
248 guint scroll_to_use_align : 1;
250 guint reorderable : 1;
251 guint header_has_focus : 1;
252 guint drag_column_window_state : 3;
253 /* hint to display rows in alternating colors */
257 guint empty_view_drop : 1;
259 guint init_hadjust_value : 1;
261 guint in_top_row_to_dy : 1;
263 /* interactive search */
264 guint enable_search : 1;
265 guint disable_popdown : 1;
266 guint search_custom_entry_set : 1;
268 guint hover_selection : 1;
269 guint imcontext_changed : 1;
271 guint rubber_banding_enable : 1;
275 guint post_validation_flag : 1;
277 /* Whether our key press handler is to avoid sending an unhandled binding to the search entry */
278 guint search_entry_avoid_unhandled_binding : 1;
283 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
286 g_log (G_LOG_DOMAIN, \
287 G_LOG_LEVEL_CRITICAL, \
288 "%s (%s): assertion `%s' failed.\n" \
289 "There is a disparity between the internal view of the PsppSheetView,\n" \
290 "and the GtkTreeModel. This generally means that the model has changed\n"\
291 "without letting the view know. Any display from now on is likely to\n" \
299 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
302 g_log (G_LOG_DOMAIN, \
303 G_LOG_LEVEL_CRITICAL, \
304 "%s (%s): assertion `%s' failed.\n" \
305 "There is a disparity between the internal view of the PsppSheetView,\n" \
306 "and the GtkTreeModel. This generally means that the model has changed\n"\
307 "without letting the view know. Any display from now on is likely to\n" \
317 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
320 g_log (G_LOG_DOMAIN, \
321 G_LOG_LEVEL_CRITICAL, \
322 "file %s: line %d: assertion `%s' failed.\n" \
323 "There is a disparity between the internal view of the PsppSheetView,\n" \
324 "and the GtkTreeModel. This generally means that the model has changed\n"\
325 "without letting the view know. Any display from now on is likely to\n" \
333 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
336 g_log (G_LOG_DOMAIN, \
337 G_LOG_LEVEL_CRITICAL, \
338 "file %s: line %d: assertion '%s' failed.\n" \
339 "There is a disparity between the internal view of the PsppSheetView,\n" \
340 "and the GtkTreeModel. This generally means that the model has changed\n"\
341 "without letting the view know. Any display from now on is likely to\n" \
351 /* functions that shouldn't be exported */
352 void _pspp_sheet_selection_internal_select_node (PsppSheetSelection *selection,
355 PsppSheetSelectMode mode,
356 gboolean override_browse_mode);
357 void _pspp_sheet_selection_emit_changed (PsppSheetSelection *selection);
358 void _pspp_sheet_view_find_node (PsppSheetView *tree_view,
361 GtkTreePath *_pspp_sheet_view_find_path (PsppSheetView *tree_view,
363 void _pspp_sheet_view_child_move_resize (PsppSheetView *tree_view,
369 void _pspp_sheet_view_queue_draw_node (PsppSheetView *tree_view,
371 const GdkRectangle *clip_rect);
373 void _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column);
374 void _pspp_sheet_view_column_unrealize_button (PsppSheetViewColumn *column);
375 void _pspp_sheet_view_column_set_tree_view (PsppSheetViewColumn *column,
376 PsppSheetView *tree_view);
377 void _pspp_sheet_view_column_unset_model (PsppSheetViewColumn *column,
378 GtkTreeModel *old_model);
379 void _pspp_sheet_view_column_unset_tree_view (PsppSheetViewColumn *column);
380 void _pspp_sheet_view_column_set_width (PsppSheetViewColumn *column,
382 void _pspp_sheet_view_column_start_drag (PsppSheetView *tree_view,
383 PsppSheetViewColumn *column);
384 gboolean _pspp_sheet_view_column_cell_event (PsppSheetViewColumn *tree_column,
385 GtkCellEditable **editable_widget,
388 const GdkRectangle *background_area,
389 const GdkRectangle *cell_area,
391 void _pspp_sheet_view_column_start_editing (PsppSheetViewColumn *tree_column,
392 GtkCellEditable *editable_widget);
393 void _pspp_sheet_view_column_stop_editing (PsppSheetViewColumn *tree_column);
394 void _pspp_sheet_view_install_mark_rows_col_dirty (PsppSheetView *tree_view);
395 void _pspp_sheet_view_column_autosize (PsppSheetView *tree_view,
396 PsppSheetViewColumn *column);
398 gboolean _pspp_sheet_view_column_has_editable_cell (PsppSheetViewColumn *column);
399 GtkCellRenderer *_pspp_sheet_view_column_get_edited_cell (PsppSheetViewColumn *column);
400 gint _pspp_sheet_view_column_count_special_cells (PsppSheetViewColumn *column);
401 GtkCellRenderer *_pspp_sheet_view_column_get_cell_at_pos (PsppSheetViewColumn *column,
404 PsppSheetSelection* _pspp_sheet_selection_new (void);
405 PsppSheetSelection* _pspp_sheet_selection_new_with_tree_view (PsppSheetView *tree_view);
406 void _pspp_sheet_selection_set_tree_view (PsppSheetSelection *selection,
407 PsppSheetView *tree_view);
409 void _pspp_sheet_view_column_cell_render (PsppSheetViewColumn *tree_column,
411 const GdkRectangle *background_area,
412 const GdkRectangle *cell_area,
413 const GdkRectangle *expose_area,
415 void _pspp_sheet_view_column_get_focus_area (PsppSheetViewColumn *tree_column,
416 const GdkRectangle *background_area,
417 const GdkRectangle *cell_area,
418 GdkRectangle *focus_area);
419 gboolean _pspp_sheet_view_column_cell_focus (PsppSheetViewColumn *tree_column,
423 void _pspp_sheet_view_column_cell_draw_focus (PsppSheetViewColumn *tree_column,
425 const GdkRectangle *background_area,
426 const GdkRectangle *cell_area,
427 const GdkRectangle *expose_area,
429 void _pspp_sheet_view_column_cell_set_dirty (PsppSheetViewColumn *tree_column);
430 void _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column,
431 GtkCellRenderer *cell,
435 gboolean pspp_sheet_view_node_is_selected (PsppSheetView *tree_view,
437 void pspp_sheet_view_node_select (PsppSheetView *tree_view,
439 void pspp_sheet_view_node_unselect (PsppSheetView *tree_view,
443 pspp_sheet_view_node_next (PsppSheetView *tree_view,
446 pspp_sheet_view_node_prev (PsppSheetView *tree_view,
449 #endif /* __GTK_TREE_PRIVATE_H__ */