Remove unused expose_area parameters from pspp_sheet_view_column functions
[pspp] / src / ui / gui / pspp-sheet-private.h
1  /* PSPPIRE - a graphical user interface for PSPP.
2     Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 /* gtktreeprivate.h
18  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
19  *
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.
24  *
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.
29  *
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.
34  */
35
36 #ifndef __GTK_TREE_PRIVATE_H__
37 #define __GTK_TREE_PRIVATE_H__
38
39
40 #include <gtk/gtk.h>
41 #include "libpspp/range-tower.h"
42 #include "ui/gui/pspp-sheet-view.h"
43 #include "ui/gui/pspp-sheet-view-column.h"
44
45 #define TREE_VIEW_DRAG_WIDTH 6
46
47 typedef enum
48 {
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
54 } PsppSheetViewFlags;
55
56 enum
57 {
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
63 };
64
65 enum
66 {
67   RUBBER_BAND_OFF = 0,
68   RUBBER_BAND_MAYBE_START = 1,
69   RUBBER_BAND_ACTIVE = 2
70 };
71
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))
77
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.
80   */
81 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
82
83 typedef struct _PsppSheetViewColumnReorder PsppSheetViewColumnReorder;
84 struct _PsppSheetViewColumnReorder
85 {
86   gint left_align;
87   gint right_align;
88   PsppSheetViewColumn *left_column;
89   PsppSheetViewColumn *right_column;
90 };
91
92 struct _PsppSheetViewPrivate
93 {
94   GtkTreeModel *model;
95
96   guint flags;
97   /* tree information */
98   gint row_count;
99   struct range_tower *selected;
100
101   /* Container info */
102   GList *children;
103   gint width;
104   gint height;
105
106   /* Adjustments */
107   GtkAdjustment *hadjustment;
108   GtkAdjustment *vadjustment;
109
110   /* Sub windows */
111   GdkWindow *bin_window;
112   GdkWindow *header_window;
113
114   /* Scroll position state keeping */
115   GtkTreeRowReference *top_row;
116   gint top_row_dy;
117   /* dy == y pos of top_row + top_row_dy */
118   /* we cache it for simplicity of the code */
119   gint dy;
120
121   guint presize_handler_timer;
122   guint validate_rows_timer;
123   guint scroll_sync_timer;
124
125   /* Indentation and expander layout */
126   gint expander_size;
127
128   /* Key navigation (focus), selection */
129   gint cursor_offset;
130
131   GtkTreeRowReference *anchor;
132   GtkTreeRowReference *cursor;
133
134   PsppSheetViewColumn *focus_column;
135
136   /* Current pressed node, previously pressed, prelight */
137   gint pressed_button;
138   gint press_start_x;
139   gint press_start_y;
140   gint press_start_node;
141
142   gint event_last_x;
143   gint event_last_y;
144
145   guint last_button_time;
146   gint last_button_x;
147   gint last_button_y;
148
149   int prelight_node;
150
151   /* Cell Editing */
152   PsppSheetViewColumn *edited_column;
153   gint edited_row;
154
155   /* Selection information */
156   PsppSheetSelection *selection;
157
158   /* Header information */
159   gint n_columns;
160   GList *columns;
161   gint header_height;
162   gint n_selected_columns;
163
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;
169
170   /* Interactive Header reordering */
171   GdkWindow *drag_window;
172   GdkWindow *drag_highlight_window;
173   PsppSheetViewColumn *drag_column;
174   gint drag_column_x;
175
176   /* Interactive Header Resizing */
177   gint drag_pos;
178   gint x_drag;
179
180   /* Non-interactive Header Resizing, expand flag support */
181   gint prev_width;
182
183   /* ATK Hack */
184   PsppSheetDestroyCountFunc destroy_count_func;
185   gpointer destroy_count_data;
186   GDestroyNotify destroy_count_destroy;
187
188   /* Scroll timeout (e.g. during dnd, rubber banding) */
189   guint scroll_timeout;
190
191   /* Row drag-and-drop */
192   GtkTreeRowReference *drag_dest_row;
193   PsppSheetViewDropPosition drag_dest_pos;
194   guint open_dest_timeout;
195
196   /* Rubber banding */
197   gint rubber_band_status;
198   gint rubber_band_x;
199   gint rubber_band_y;
200   gint rubber_band_shift;
201   gint rubber_band_ctrl;
202
203   int rubber_band_start_node;
204
205   int rubber_band_end_node;
206
207   /* Rectangular selection. */
208   PsppSheetViewColumn *anchor_column; /* XXX needs to be a weak pointer? */
209
210   /* fixed height */
211   gint fixed_height;
212   gboolean fixed_height_set;
213
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;
219
220   /* Interactive search */
221   gint selected_iter;
222   gint search_column;
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;
233
234   /* Grid and tree lines */
235   PsppSheetViewGridLines grid_lines;
236
237   /* Special cells. */
238   PsppSheetViewSpecialCells special_cells;
239
240   /* Tooltip support */
241   gint tooltip_column;
242
243   /* Cached style for button facades in columns. */
244   GtkStyle *button_style;
245
246   /* Here comes the bitfield */
247   guint scroll_to_use_align : 1;
248
249   guint reorderable : 1;
250   guint header_has_focus : 1;
251   guint drag_column_window_state : 3;
252   /* hint to display rows in alternating colors */
253   guint has_rules : 1;
254
255   /* for DnD */
256   guint empty_view_drop : 1;
257
258   guint init_hadjust_value : 1;
259
260   guint in_top_row_to_dy : 1;
261
262   /* interactive search */
263   guint enable_search : 1;
264   guint disable_popdown : 1;
265   guint search_custom_entry_set : 1;
266   
267   guint hover_selection : 1;
268   guint imcontext_changed : 1;
269
270   guint rubber_banding_enable : 1;
271
272   guint in_grab : 1;
273
274   guint post_validation_flag : 1;
275
276   /* Whether our key press handler is to avoid sending an unhandled binding to the search entry */
277   guint search_entry_avoid_unhandled_binding : 1;
278 };
279
280 #ifdef __GNUC__
281
282 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
283      if (!(expr))                                                       \
284        {                                                                \
285          g_log (G_LOG_DOMAIN,                                           \
286                 G_LOG_LEVEL_CRITICAL,                                   \
287                 "%s (%s): assertion `%s' failed.\n"                     \
288                 "There is a disparity between the internal view of the PsppSheetView,\n"    \
289                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
290                 "without letting the view know.  Any display from now on is likely to\n"  \
291                 "be incorrect.\n",                                                        \
292                 G_STRLOC,                                               \
293                 G_STRFUNC,                                              \
294                 #expr);                                                 \
295          return ret;                                                    \
296        };                               }G_STMT_END
297
298 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
299      if (!(expr))                                                       \
300        {                                                                \
301          g_log (G_LOG_DOMAIN,                                           \
302                 G_LOG_LEVEL_CRITICAL,                                   \
303                 "%s (%s): assertion `%s' failed.\n"                     \
304                 "There is a disparity between the internal view of the PsppSheetView,\n"    \
305                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
306                 "without letting the view know.  Any display from now on is likely to\n"  \
307                 "be incorrect.\n",                                                        \
308                 G_STRLOC,                                               \
309                 G_STRFUNC,                                              \
310                 #expr);                                                 \
311          return;                                                        \
312        };                               }G_STMT_END
313
314 #else
315
316 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
317      if (!(expr))                                                       \
318        {                                                                \
319          g_log (G_LOG_DOMAIN,                                           \
320                 G_LOG_LEVEL_CRITICAL,                                   \
321                 "file %s: line %d: assertion `%s' failed.\n"       \
322                 "There is a disparity between the internal view of the PsppSheetView,\n"    \
323                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
324                 "without letting the view know.  Any display from now on is likely to\n"  \
325                 "be incorrect.\n",                                                        \
326                 __FILE__,                                               \
327                 __LINE__,                                               \
328                 #expr);                                                 \
329          return ret;                                                    \
330        };                               }G_STMT_END
331
332 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
333      if (!(expr))                                                       \
334        {                                                                \
335          g_log (G_LOG_DOMAIN,                                           \
336                 G_LOG_LEVEL_CRITICAL,                                   \
337                 "file %s: line %d: assertion '%s' failed.\n"            \
338                 "There is a disparity between the internal view of the PsppSheetView,\n"    \
339                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
340                 "without letting the view know.  Any display from now on is likely to\n"  \
341                 "be incorrect.\n",                                                        \
342                 __FILE__,                                               \
343                 __LINE__,                                               \
344                 #expr);                                                 \
345          return;                                                        \
346        };                               }G_STMT_END
347 #endif
348
349
350 /* functions that shouldn't be exported */
351 void         _pspp_sheet_selection_internal_select_node (PsppSheetSelection  *selection,
352                                                        int                node,
353                                                        GtkTreePath       *path,
354                                                        PsppSheetSelectMode  mode,
355                                                        gboolean           override_browse_mode);
356 void         _pspp_sheet_selection_emit_changed         (PsppSheetSelection  *selection);
357 void         _pspp_sheet_view_find_node                 (PsppSheetView       *tree_view,
358                                                        GtkTreePath       *path,
359                                                        int              *node);
360 GtkTreePath *_pspp_sheet_view_find_path                 (PsppSheetView       *tree_view,
361                                                        int                    node);
362 void         _pspp_sheet_view_child_move_resize         (PsppSheetView       *tree_view,
363                                                        GtkWidget         *widget,
364                                                        gint               x,
365                                                        gint               y,
366                                                        gint               width,
367                                                        gint               height);
368 void         _pspp_sheet_view_queue_draw_node           (PsppSheetView       *tree_view,
369                                                        int                    node,
370                                                        const GdkRectangle *clip_rect);
371
372 void _pspp_sheet_view_column_realize_button   (PsppSheetViewColumn *column);
373 void _pspp_sheet_view_column_unrealize_button (PsppSheetViewColumn *column);
374 void _pspp_sheet_view_column_set_tree_view    (PsppSheetViewColumn *column,
375                                              PsppSheetView       *tree_view);
376 void _pspp_sheet_view_column_unset_model      (PsppSheetViewColumn *column,
377                                              GtkTreeModel      *old_model);
378 void _pspp_sheet_view_column_unset_tree_view  (PsppSheetViewColumn *column);
379 void _pspp_sheet_view_column_set_width        (PsppSheetViewColumn *column,
380                                              gint               width);
381 void _pspp_sheet_view_column_start_drag       (PsppSheetView       *tree_view,
382                                              PsppSheetViewColumn *column);
383 gboolean _pspp_sheet_view_column_cell_event   (PsppSheetViewColumn  *tree_column,
384                                              GtkCellEditable   **editable_widget,
385                                              GdkEvent           *event,
386                                              gchar              *path_string,
387                                              const GdkRectangle *background_area,
388                                              const GdkRectangle *cell_area,
389                                              guint               flags);
390 void _pspp_sheet_view_column_start_editing (PsppSheetViewColumn *tree_column,
391                                           GtkCellEditable   *editable_widget);
392 void _pspp_sheet_view_column_stop_editing  (PsppSheetViewColumn *tree_column);
393 void _pspp_sheet_view_install_mark_rows_col_dirty (PsppSheetView *tree_view);
394 void             _pspp_sheet_view_column_autosize          (PsppSheetView       *tree_view,
395                                                           PsppSheetViewColumn *column);
396
397 gboolean         _pspp_sheet_view_column_has_editable_cell (PsppSheetViewColumn *column);
398 GtkCellRenderer *_pspp_sheet_view_column_get_edited_cell   (PsppSheetViewColumn *column);
399 gint             _pspp_sheet_view_column_count_special_cells (PsppSheetViewColumn *column);
400 GtkCellRenderer *_pspp_sheet_view_column_get_cell_at_pos   (PsppSheetViewColumn *column,
401                                                           gint               x);
402
403 PsppSheetSelection* _pspp_sheet_selection_new                (void);
404 PsppSheetSelection* _pspp_sheet_selection_new_with_tree_view (PsppSheetView      *tree_view);
405 void              _pspp_sheet_selection_set_tree_view      (PsppSheetSelection *selection,
406                                                           PsppSheetView      *tree_view);
407
408 void              _pspp_sheet_view_column_cell_render      (PsppSheetViewColumn  *tree_column,
409                                                             cairo_t *cr,
410                                                           const GdkRectangle *background_area,
411                                                           const GdkRectangle *cell_area,
412                                                           guint               flags);
413 void              _pspp_sheet_view_column_get_focus_area   (PsppSheetViewColumn  *tree_column,
414                                                           const GdkRectangle *background_area,
415                                                           const GdkRectangle *cell_area,
416                                                           GdkRectangle       *focus_area);
417 gboolean          _pspp_sheet_view_column_cell_focus       (PsppSheetViewColumn  *tree_column,
418                                                           gint                direction,
419                                                           gboolean            left,
420                                                           gboolean            right);
421 void              _pspp_sheet_view_column_cell_draw_focus  (PsppSheetViewColumn  *tree_column,
422                                                             cairo_t *cr,
423                                                           const GdkRectangle *background_area,
424                                                           const GdkRectangle *cell_area,
425                                                           guint               flags);
426 void              _pspp_sheet_view_column_cell_set_dirty         (PsppSheetViewColumn  *tree_column);
427 void              _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column,
428                                                             GtkCellRenderer   *cell,
429                                                             gint              *left,
430                                                             gint              *right);
431
432 gboolean pspp_sheet_view_node_is_selected (PsppSheetView *tree_view,
433                                            int node);
434 void pspp_sheet_view_node_select (PsppSheetView *tree_view,
435                                   int node);
436 void pspp_sheet_view_node_unselect (PsppSheetView *tree_view,
437                                     int node);
438
439 gint
440 pspp_sheet_view_node_next (PsppSheetView *tree_view,
441                            gint node);
442 gint
443 pspp_sheet_view_node_prev (PsppSheetView *tree_view,
444                            gint node);
445
446 #endif /* __GTK_TREE_PRIVATE_H__ */
447