2 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GTK_TREE_PRIVATE_H__
21 #define __GTK_TREE_PRIVATE_H__
26 #endif /* __cplusplus */
28 #include <gtk/gtktreeview.h>
29 #include <gtk/gtktreeselection.h>
30 #include <gtk/gtkrbtree.h>
32 #define TREE_VIEW_DRAG_WIDTH 6
36 GTK_TREE_VIEW_IS_LIST = 1 << 0,
37 GTK_TREE_VIEW_SHOW_EXPANDERS = 1 << 1,
38 GTK_TREE_VIEW_IN_COLUMN_RESIZE = 1 << 2,
39 GTK_TREE_VIEW_ARROW_PRELIT = 1 << 3,
40 GTK_TREE_VIEW_HEADERS_VISIBLE = 1 << 4,
41 GTK_TREE_VIEW_DRAW_KEYFOCUS = 1 << 5,
42 GTK_TREE_VIEW_MODEL_SETUP = 1 << 6,
43 GTK_TREE_VIEW_IN_COLUMN_DRAG = 1 << 7
48 GTK_TREE_SELECT_MODE_TOGGLE = 1 << 0,
49 GTK_TREE_SELECT_MODE_EXTEND = 1 << 1
55 DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
56 DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
57 DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
58 DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
59 DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4
62 #define GTK_TREE_VIEW_SET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
63 #define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
64 #define GTK_TREE_VIEW_FLAG_SET(tree_view, flag) ((tree_view->priv->flags&flag)==flag)
65 #define TREE_VIEW_HEADER_HEIGHT(tree_view) (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE)?tree_view->priv->header_height:0)
66 #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))
67 #define TREE_VIEW_DRAW_EXPANDERS(tree_view) (!GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_IS_LIST)&>K_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
69 /* This lovely little value is used to determine how far away from the title bar
70 * you can move the mouse and still have a column drag work.
72 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
74 typedef void (*GtkTreeViewSearchDialogPositionFunc) (GtkTreeView *tree_view,
75 GtkWidget *search_dialog);
77 typedef struct _GtkTreeViewColumnReorder GtkTreeViewColumnReorder;
78 struct _GtkTreeViewColumnReorder
82 GtkTreeViewColumn *left_column;
83 GtkTreeViewColumn *right_column;
86 struct _GtkTreeViewPrivate
91 /* tree information */
94 GtkRBNode *button_pressed_node;
95 GtkRBTree *button_pressed_tree;
102 GtkAdjustment *hadjustment;
103 GtkAdjustment *vadjustment;
105 GdkWindow *bin_window;
106 GdkWindow *header_window;
107 GdkWindow *drag_window;
108 GdkWindow *drag_highlight_window;
109 GtkTreeViewColumn *drag_column;
111 GtkTreeRowReference *last_button_press;
112 GtkTreeRowReference *last_button_press_2;
114 /* bin_window offset */
115 GtkTreeRowReference *top_row;
117 /* dy == y pos of top_row + top_row_dy */
118 /* we cache it for simplicity of the code */
122 GtkTreeViewColumn *expander_column;
123 GtkTreeViewColumn *edited_column;
124 guint presize_handler_timer;
125 guint validate_rows_timer;
126 guint scroll_sync_timer;
129 GtkTreeViewColumn *focus_column;
131 /* Selection stuff */
132 GtkTreeRowReference *anchor;
133 GtkTreeRowReference *cursor;
135 /* Column Resizing */
139 /* Prelight information */
140 GtkRBNode *prelight_node;
141 GtkRBTree *prelight_tree;
143 /* The node that's currently being collapsed or expanded */
144 GtkRBNode *expanded_collapsed_node;
145 GtkRBTree *expanded_collapsed_tree;
146 guint expand_collapse_timeout;
148 /* Selection information */
149 GtkTreeSelection *selection;
151 /* Header information */
156 GtkTreeViewColumnDropFunc column_drop_func;
157 gpointer column_drop_func_data;
158 GtkDestroyNotify column_drop_func_data_destroy;
159 GList *column_drag_info;
160 GtkTreeViewColumnReorder *cur_reorder;
163 GtkTreeDestroyCountFunc destroy_count_func;
164 gpointer destroy_count_data;
165 GtkDestroyNotify destroy_count_destroy;
167 /* Scroll timeout (e.g. during dnd) */
168 guint scroll_timeout;
170 /* Row drag-and-drop */
171 GtkTreeRowReference *drag_dest_row;
172 GtkTreeViewDropPosition drag_dest_pos;
173 guint open_dest_timeout;
182 /* Scroll-to functionality when unrealized */
183 GtkTreeRowReference *scroll_to_path;
184 GtkTreeViewColumn *scroll_to_column;
185 gfloat scroll_to_row_align;
186 gfloat scroll_to_col_align;
187 guint scroll_to_use_align : 1;
189 guint fixed_height_mode : 1;
190 guint fixed_height_check : 1;
192 guint reorderable : 1;
193 guint header_has_focus : 1;
194 guint drag_column_window_state : 3;
195 /* hint to display rows in alternating colors */
197 guint mark_rows_col_dirty : 1;
200 guint empty_view_drop : 1;
202 guint ctrl_pressed : 1;
203 guint shift_pressed : 1;
206 guint init_hadjust_value : 1;
208 /* interactive search */
209 guint enable_search : 1;
210 guint disable_popdown : 1;
214 GtkTreeViewSearchDialogPositionFunc search_dialog_position_func;
215 GtkTreeViewSearchEqualFunc search_equal_func;
216 gpointer search_user_data;
217 GtkDestroyNotify search_destroy;
218 GtkWidget *search_window;
219 GtkWidget *search_entry;
226 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
229 g_log (G_LOG_DOMAIN, \
230 G_LOG_LEVEL_CRITICAL, \
231 "file %s: line %d (%s): assertion `%s' failed.\n" \
232 "There is a disparity between the internal view of the GtkTreeView,\n" \
233 "and the GtkTreeModel. This generally means that the model has changed\n"\
234 "without letting the view know. Any display from now on is likely to\n" \
238 __PRETTY_FUNCTION__, \
243 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
246 g_log (G_LOG_DOMAIN, \
247 G_LOG_LEVEL_CRITICAL, \
248 "file %s: line %d (%s): assertion `%s' failed.\n" \
249 "There is a disparity between the internal view of the GtkTreeView,\n" \
250 "and the GtkTreeModel. This generally means that the model has changed\n"\
251 "without letting the view know. Any display from now on is likely to\n" \
255 __PRETTY_FUNCTION__, \
262 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
265 g_log (G_LOG_DOMAIN, \
266 G_LOG_LEVEL_CRITICAL, \
267 "file %s: line %d: assertion `%s' failed.\n" \
268 "There is a disparity between the internal view of the GtkTreeView,\n" \
269 "and the GtkTreeModel. This generally means that the model has changed\n"\
270 "without letting the view know. Any display from now on is likely to\n" \
278 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
281 g_log (G_LOG_DOMAIN, \
282 G_LOG_LEVEL_CRITICAL, \
283 "file %s: line %d: assertion '%s' failed.\n" \
284 "There is a disparity between the internal view of the GtkTreeView,\n" \
285 "and the GtkTreeModel. This generally means that the model has changed\n"\
286 "without letting the view know. Any display from now on is likely to\n" \
296 /* functions that shouldn't be exported */
297 void _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
301 GtkTreeSelectMode mode,
302 gboolean override_browse_mode);
303 gboolean _gtk_tree_view_find_node (GtkTreeView *tree_view,
307 GtkTreePath *_gtk_tree_view_find_path (GtkTreeView *tree_view,
310 void _gtk_tree_view_child_move_resize (GtkTreeView *tree_view,
316 void _gtk_tree_view_queue_draw_node (GtkTreeView *tree_view,
319 GdkRectangle *clip_rect);
321 void _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column);
322 void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
323 void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
324 GtkTreeView *tree_view);
325 void _gtk_tree_view_column_unset_model (GtkTreeViewColumn *column,
326 GtkTreeModel *old_model);
327 void _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column);
328 void _gtk_tree_view_column_set_width (GtkTreeViewColumn *column,
330 void _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
331 GtkTreeViewColumn *column);
332 gboolean _gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
333 GtkCellEditable **editable_widget,
336 GdkRectangle *background_area,
337 GdkRectangle *cell_area,
339 void _gtk_tree_view_column_start_editing (GtkTreeViewColumn *tree_column,
340 GtkCellEditable *editable_widget);
341 void _gtk_tree_view_column_stop_editing (GtkTreeViewColumn *tree_column);
342 void _gtk_tree_view_install_mark_rows_col_dirty (GtkTreeView *tree_view);
343 void _gtk_tree_view_column_autosize (GtkTreeView *tree_view,
344 GtkTreeViewColumn *column);
346 gboolean _gtk_tree_view_column_has_editable_cell (GtkTreeViewColumn *column);
347 GtkCellRenderer *_gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column);
348 gint _gtk_tree_view_column_count_special_cells (GtkTreeViewColumn *column);
349 GtkCellRenderer *_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
352 GtkTreeSelection* _gtk_tree_selection_new (void);
353 GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view);
354 void _gtk_tree_selection_set_tree_view (GtkTreeSelection *selection,
355 GtkTreeView *tree_view);
357 void _gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
359 GdkRectangle *background_area,
360 GdkRectangle *cell_area,
361 GdkRectangle *expose_area,
363 gboolean _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
367 void _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
369 GdkRectangle *background_area,
370 GdkRectangle *cell_area,
371 GdkRectangle *expose_area,
373 void _gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column,
374 gboolean install_handler);
375 void _gtk_tree_view_column_get_neighbor_sizes (GtkTreeViewColumn *column,
376 GtkCellRenderer *cell,
383 #endif /* __cplusplus */
386 #endif /* __GTK_TREE_PRIVATE_H__ */