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 __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 GTK_TREE_SELECT_MODE_TOGGLE = 1 << 0,
59 GTK_TREE_SELECT_MODE_EXTEND = 1 << 1
65 DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
66 DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
67 DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
68 DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
69 DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4
75 RUBBER_BAND_MAYBE_START = 1,
76 RUBBER_BAND_ACTIVE = 2
79 #define PSPP_SHEET_VIEW_SET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
80 #define PSPP_SHEET_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
81 #define PSPP_SHEET_VIEW_FLAG_SET(tree_view, flag) ((tree_view->priv->flags&flag)==flag)
82 #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)
83 #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))
85 /* This lovely little value is used to determine how far away from the title bar
86 * you can move the mouse and still have a column drag work.
88 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
90 typedef struct _PsppSheetViewColumnReorder PsppSheetViewColumnReorder;
91 struct _PsppSheetViewColumnReorder
95 PsppSheetViewColumn *left_column;
96 PsppSheetViewColumn *right_column;
99 struct _PsppSheetViewPrivate
104 /* tree information */
106 struct range_tower *selected;
114 GtkAdjustment *hadjustment;
115 GtkAdjustment *vadjustment;
118 GdkWindow *bin_window;
119 GdkWindow *header_window;
121 /* Scroll position state keeping */
122 GtkTreeRowReference *top_row;
124 /* dy == y pos of top_row + top_row_dy */
125 /* we cache it for simplicity of the code */
128 guint presize_handler_timer;
129 guint validate_rows_timer;
130 guint scroll_sync_timer;
132 /* Indentation and expander layout */
135 /* Key navigation (focus), selection */
138 GtkTreeRowReference *anchor;
139 GtkTreeRowReference *cursor;
141 PsppSheetViewColumn *focus_column;
143 /* Current pressed node, previously pressed, prelight */
147 gint press_start_node;
152 guint last_button_time;
159 PsppSheetViewColumn *edited_column;
161 /* Selection information */
162 PsppSheetSelection *selection;
164 /* Header information */
168 gint n_selected_columns;
170 PsppSheetViewColumnDropFunc column_drop_func;
171 gpointer column_drop_func_data;
172 GDestroyNotify column_drop_func_data_destroy;
173 GList *column_drag_info;
174 PsppSheetViewColumnReorder *cur_reorder;
176 /* Interactive Header reordering */
177 GdkWindow *drag_window;
178 GdkWindow *drag_highlight_window;
179 PsppSheetViewColumn *drag_column;
182 /* Interactive Header Resizing */
186 /* Non-interactive Header Resizing, expand flag support */
189 gint last_extra_space;
190 gint last_extra_space_per_column;
191 gint last_number_of_expand_columns;
194 PsppSheetDestroyCountFunc destroy_count_func;
195 gpointer destroy_count_data;
196 GDestroyNotify destroy_count_destroy;
198 /* Scroll timeout (e.g. during dnd, rubber banding) */
199 guint scroll_timeout;
201 /* Row drag-and-drop */
202 GtkTreeRowReference *drag_dest_row;
203 PsppSheetViewDropPosition drag_dest_pos;
204 guint open_dest_timeout;
207 gint rubber_band_status;
210 gint rubber_band_shift;
211 gint rubber_band_ctrl;
213 int rubber_band_start_node;
215 int rubber_band_end_node;
217 /* Rectangular selection. */
218 PsppSheetViewColumn *anchor_column; /* XXX needs to be a weak pointer? */
223 /* Scroll-to functionality when unrealized */
224 GtkTreeRowReference *scroll_to_path;
225 PsppSheetViewColumn *scroll_to_column;
226 gfloat scroll_to_row_align;
227 gfloat scroll_to_col_align;
229 /* Interactive search */
232 PsppSheetViewSearchPositionFunc search_position_func;
233 PsppSheetViewSearchEqualFunc search_equal_func;
234 gpointer search_user_data;
235 GDestroyNotify search_destroy;
236 gpointer search_position_user_data;
237 GDestroyNotify search_position_destroy;
238 GtkWidget *search_window;
239 GtkWidget *search_entry;
240 guint search_entry_changed_id;
241 guint typeselect_flush_timeout;
243 /* Grid and tree lines */
244 PsppSheetViewGridLines grid_lines;
248 PsppSheetViewSpecialCells special_cells;
250 /* Tooltip support */
253 /* Cached style for button facades in columns. */
254 GtkStyle *button_style;
256 /* Here comes the bitfield */
257 guint scroll_to_use_align : 1;
259 guint reorderable : 1;
260 guint header_has_focus : 1;
261 guint drag_column_window_state : 3;
262 /* hint to display rows in alternating colors */
266 guint empty_view_drop : 1;
268 guint ctrl_pressed : 1;
269 guint shift_pressed : 1;
271 guint init_hadjust_value : 1;
273 guint in_top_row_to_dy : 1;
275 /* interactive search */
276 guint enable_search : 1;
277 guint disable_popdown : 1;
278 guint search_custom_entry_set : 1;
280 guint hover_selection : 1;
281 guint imcontext_changed : 1;
283 guint rubber_banding_enable : 1;
287 guint post_validation_flag : 1;
289 /* Whether our key press handler is to avoid sending an unhandled binding to the search entry */
290 guint search_entry_avoid_unhandled_binding : 1;
295 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
298 g_log (G_LOG_DOMAIN, \
299 G_LOG_LEVEL_CRITICAL, \
300 "%s (%s): assertion `%s' failed.\n" \
301 "There is a disparity between the internal view of the PsppSheetView,\n" \
302 "and the GtkTreeModel. This generally means that the model has changed\n"\
303 "without letting the view know. Any display from now on is likely to\n" \
311 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
314 g_log (G_LOG_DOMAIN, \
315 G_LOG_LEVEL_CRITICAL, \
316 "%s (%s): assertion `%s' failed.\n" \
317 "There is a disparity between the internal view of the PsppSheetView,\n" \
318 "and the GtkTreeModel. This generally means that the model has changed\n"\
319 "without letting the view know. Any display from now on is likely to\n" \
329 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
332 g_log (G_LOG_DOMAIN, \
333 G_LOG_LEVEL_CRITICAL, \
334 "file %s: line %d: assertion `%s' failed.\n" \
335 "There is a disparity between the internal view of the PsppSheetView,\n" \
336 "and the GtkTreeModel. This generally means that the model has changed\n"\
337 "without letting the view know. Any display from now on is likely to\n" \
345 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
348 g_log (G_LOG_DOMAIN, \
349 G_LOG_LEVEL_CRITICAL, \
350 "file %s: line %d: assertion '%s' failed.\n" \
351 "There is a disparity between the internal view of the PsppSheetView,\n" \
352 "and the GtkTreeModel. This generally means that the model has changed\n"\
353 "without letting the view know. Any display from now on is likely to\n" \
363 /* functions that shouldn't be exported */
364 void _pspp_sheet_selection_internal_select_node (PsppSheetSelection *selection,
367 GtkTreeSelectMode mode,
368 gboolean override_browse_mode);
369 void _pspp_sheet_selection_emit_changed (PsppSheetSelection *selection);
370 void _pspp_sheet_view_find_node (PsppSheetView *tree_view,
373 GtkTreePath *_pspp_sheet_view_find_path (PsppSheetView *tree_view,
375 void _pspp_sheet_view_child_move_resize (PsppSheetView *tree_view,
381 void _pspp_sheet_view_queue_draw_node (PsppSheetView *tree_view,
383 const GdkRectangle *clip_rect);
385 void _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column);
386 void _pspp_sheet_view_column_unrealize_button (PsppSheetViewColumn *column);
387 void _pspp_sheet_view_column_set_tree_view (PsppSheetViewColumn *column,
388 PsppSheetView *tree_view);
389 void _pspp_sheet_view_column_unset_model (PsppSheetViewColumn *column,
390 GtkTreeModel *old_model);
391 void _pspp_sheet_view_column_unset_tree_view (PsppSheetViewColumn *column);
392 void _pspp_sheet_view_column_set_width (PsppSheetViewColumn *column,
394 void _pspp_sheet_view_column_start_drag (PsppSheetView *tree_view,
395 PsppSheetViewColumn *column);
396 gboolean _pspp_sheet_view_column_cell_event (PsppSheetViewColumn *tree_column,
397 GtkCellEditable **editable_widget,
400 const GdkRectangle *background_area,
401 const GdkRectangle *cell_area,
403 void _pspp_sheet_view_column_start_editing (PsppSheetViewColumn *tree_column,
404 GtkCellEditable *editable_widget);
405 void _pspp_sheet_view_column_stop_editing (PsppSheetViewColumn *tree_column);
406 void _pspp_sheet_view_install_mark_rows_col_dirty (PsppSheetView *tree_view);
407 void _pspp_sheet_view_column_autosize (PsppSheetView *tree_view,
408 PsppSheetViewColumn *column);
410 gboolean _pspp_sheet_view_column_has_editable_cell (PsppSheetViewColumn *column);
411 GtkCellRenderer *_pspp_sheet_view_column_get_edited_cell (PsppSheetViewColumn *column);
412 gint _pspp_sheet_view_column_count_special_cells (PsppSheetViewColumn *column);
413 GtkCellRenderer *_pspp_sheet_view_column_get_cell_at_pos (PsppSheetViewColumn *column,
416 PsppSheetSelection* _pspp_sheet_selection_new (void);
417 PsppSheetSelection* _pspp_sheet_selection_new_with_tree_view (PsppSheetView *tree_view);
418 void _pspp_sheet_selection_set_tree_view (PsppSheetSelection *selection,
419 PsppSheetView *tree_view);
421 void _pspp_sheet_view_column_cell_render (PsppSheetViewColumn *tree_column,
423 const GdkRectangle *background_area,
424 const GdkRectangle *cell_area,
425 const GdkRectangle *expose_area,
427 void _pspp_sheet_view_column_get_focus_area (PsppSheetViewColumn *tree_column,
428 const GdkRectangle *background_area,
429 const GdkRectangle *cell_area,
430 GdkRectangle *focus_area);
431 gboolean _pspp_sheet_view_column_cell_focus (PsppSheetViewColumn *tree_column,
435 void _pspp_sheet_view_column_cell_draw_focus (PsppSheetViewColumn *tree_column,
437 const GdkRectangle *background_area,
438 const GdkRectangle *cell_area,
439 const GdkRectangle *expose_area,
441 void _pspp_sheet_view_column_cell_set_dirty (PsppSheetViewColumn *tree_column);
442 void _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column,
443 GtkCellRenderer *cell,
447 gboolean pspp_sheet_view_node_is_selected (PsppSheetView *tree_view,
449 void pspp_sheet_view_node_select (PsppSheetView *tree_view,
451 void pspp_sheet_view_node_unselect (PsppSheetView *tree_view,
455 pspp_sheet_view_node_next (PsppSheetView *tree_view,
458 pspp_sheet_view_node_prev (PsppSheetView *tree_view,
461 #endif /* __GTK_TREE_PRIVATE_H__ */