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>
34 #define TREE_VIEW_DRAG_WIDTH 6
38 GTK_TREE_VIEW_IS_LIST = 1 << 0,
39 GTK_TREE_VIEW_SHOW_EXPANDERS = 1 << 1,
40 GTK_TREE_VIEW_IN_COLUMN_RESIZE = 1 << 2,
41 GTK_TREE_VIEW_ARROW_PRELIT = 1 << 3,
42 GTK_TREE_VIEW_HEADERS_VISIBLE = 1 << 4,
43 GTK_TREE_VIEW_DRAW_KEYFOCUS = 1 << 5,
44 GTK_TREE_VIEW_MODEL_SETUP = 1 << 6,
45 GTK_TREE_VIEW_IN_COLUMN_DRAG = 1 << 7,
50 DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
51 DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
52 DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
53 DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
54 DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4,
57 #define GTK_TREE_VIEW_SET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
58 #define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
59 #define GTK_TREE_VIEW_FLAG_SET(tree_view, flag) ((tree_view->priv->flags&flag)==flag)
60 #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)
61 #define TREE_VIEW_COLUMN_WIDTH(column) (CLAMP (column->width, (column->min_width!=-1)?column->min_width:column->width, (column->max_width!=-1)?column->max_width:column->width))
62 #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))
64 /* This lovely little value is used to determine how far away from the title bar
65 * you can move the mouse and still have a column drag work.
67 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
69 typedef struct _GtkTreeViewColumnReorder GtkTreeViewColumnReorder;
70 struct _GtkTreeViewColumnReorder
74 GtkTreeViewColumn *left_column;
75 GtkTreeViewColumn *right_column;
78 struct _GtkTreeViewPrivate
83 /* tree information */
87 GtkRBNode *button_pressed_node;
88 GtkRBTree *button_pressed_tree;
94 GtkAdjustment *hadjustment;
95 GtkAdjustment *vadjustment;
97 GdkWindow *bin_window;
98 GdkWindow *header_window;
99 GdkWindow *drag_window;
100 GdkWindow *drag_highlight_window;
101 GtkTreeViewColumn *drag_column;
104 gint expander_column;
107 GtkTreeViewColumn *focus_column;
108 GtkTreeViewColumn *scroll_column;
110 /* Selection stuff */
111 GtkTreeRowReference *anchor;
112 GtkTreeRowReference *cursor;
114 /* Column Resizing */
115 GdkCursor *cursor_drag;
120 /* Prelight information */
121 GtkRBNode *prelight_node;
122 GtkRBTree *prelight_tree;
124 /* Selection information */
125 GtkTreeSelection *selection;
127 /* Header information */
132 GtkTreeViewColumnDropFunc column_drop_func;
133 gpointer column_drop_func_data;
134 GtkDestroyNotify column_drop_func_data_destroy;
135 GList *column_drag_info;
136 GtkTreeViewColumnReorder *cur_reorder;
138 /* Scroll timeout (e.g. during dnd) */
139 guint scroll_timeout;
141 /* Row drag-and-drop */
142 GtkTreeRowReference *drag_dest_row;
143 GtkTreeViewDropPosition drag_dest_pos;
144 guint open_dest_timeout;
150 /* Scroll-to functionality when unrealized */
151 GtkTreePath *scroll_to_path;
152 GtkTreeViewColumn *scroll_to_column;
153 gfloat scroll_to_row_align;
154 gfloat scroll_to_col_align;
156 guint reorderable : 1;
157 guint header_has_focus : 1;
158 guint drag_column_window_state : 3;
159 /* hint to display rows in alternating colors */
162 guint in_extended_selection : 1;
163 guint in_free_motion : 1;
168 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
171 g_log (G_LOG_DOMAIN, \
172 G_LOG_LEVEL_CRITICAL, \
173 "file %s: line %d (%s): assertion `%s' failed.\n" \
174 "There is a disparity between the internal view of the GtkTreeView,\n" \
175 "and the GtkTreeModel. This generally means that the model has changed\n"\
176 "without letting the view know. Any display from now on is likely to\n" \
180 __PRETTY_FUNCTION__, \
185 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
188 g_log (G_LOG_DOMAIN, \
189 G_LOG_LEVEL_CRITICAL, \
190 "file %s: line %d (%s): assertion `%s' failed.\n" \
191 "There is a disparity between the internal view of the GtkTreeView,\n" \
192 "and the GtkTreeModel. This generally means that the model has changed\n"\
193 "without letting the view know. Any display from now on is likely to\n" \
197 __PRETTY_FUNCTION__, \
204 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
207 g_log (G_LOG_DOMAIN, \
208 G_LOG_LEVEL_CRITICAL, \
209 "file %s: line %d: assertion `%s' failed.\n" \
210 "There is a disparity between the internal view of the GtkTreeView,\n" \
211 "and the GtkTreeModel. This generally means that the model has changed\n"\
212 "without letting the view know. Any display from now on is likely to\n" \
220 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
223 g_log (G_LOG_DOMAIN, \
224 G_LOG_LEVEL_CRITICAL, \
225 "file %s: line %d: assertion '%s' failed.\n" \
226 "There is a disparity between the internal view of the GtkTreeView,\n" \
227 "and the GtkTreeModel. This generally means that the model has changed\n"\
228 "without letting the view know. Any display from now on is likely to\n" \
238 /* functions that shouldn't be exported */
239 void _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
243 GdkModifierType state);
244 gboolean _gtk_tree_view_find_node (GtkTreeView *tree_view,
248 GtkTreePath *_gtk_tree_view_find_path (GtkTreeView *tree_view,
251 void _gtk_tree_view_update_size (GtkTreeView *tree_view);
254 void _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column);
255 void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
256 void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
257 GtkTreeView *tree_view);
258 void _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column);
259 void _gtk_tree_view_column_set_width (GtkTreeViewColumn *column,
261 void _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
262 GtkTreeViewColumn *column);
264 GtkTreeSelection* _gtk_tree_selection_new (void);
265 GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view);
266 void _gtk_tree_selection_set_tree_view (GtkTreeSelection *selection,
267 GtkTreeView *tree_view);
274 #endif /* __cplusplus */
277 #endif /* __GTK_TREE_PRIVATE_H__ */