]> Pileus Git - ~andy/gtk/blob - gtk/gtktreeprivate.h
Remove trailing commas in enum declarations.
[~andy/gtk] / gtk / gtktreeprivate.h
1 /* gtktreeprivate.h
2  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef __GTK_TREE_PRIVATE_H__
21 #define __GTK_TREE_PRIVATE_H__
22
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27
28 #include <gtk/gtktreeview.h>
29 #include <gtk/gtktreeselection.h>
30 #include <gtk/gtkrbtree.h>
31
32
33   
34 #define TREE_VIEW_DRAG_WIDTH 6
35
36 typedef enum
37 {
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
46 } GtkTreeViewFlags;
47
48 enum
49 {
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
55 };
56 #define GTK_TREE_VIEW_SET_FLAG(tree_view, flag)   G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
57 #define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
58 #define GTK_TREE_VIEW_FLAG_SET(tree_view, flag)   ((tree_view->priv->flags&flag)==flag)
59 #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)
60 #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))
61 #define TREE_VIEW_DRAW_EXPANDERS(tree_view)       (!GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_IS_LIST)&&GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
62
63  /* This lovely little value is used to determine how far away from the title bar
64   * you can move the mouse and still have a column drag work.
65   */
66 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
67
68 typedef void (*GtkTreeViewSearchDialogPositionFunc) (GtkTreeView *tree_view,
69                                                      GtkWidget   *search_dialog);
70
71 typedef struct _GtkTreeViewColumnReorder GtkTreeViewColumnReorder;
72 struct _GtkTreeViewColumnReorder
73 {
74   gint left_align;
75   gint right_align;
76   GtkTreeViewColumn *left_column;
77   GtkTreeViewColumn *right_column;
78 };
79
80 struct _GtkTreeViewPrivate
81 {
82   GtkTreeModel *model;
83
84   guint flags;
85   /* tree information */
86   GtkRBTree *tree;
87
88   gint tab_offset;
89   GtkRBNode *button_pressed_node;
90   GtkRBTree *button_pressed_tree;
91
92   GList *children;
93   gint width;
94   gint height;
95
96   GtkAdjustment *hadjustment;
97   GtkAdjustment *vadjustment;
98
99   GdkWindow *bin_window;
100   GdkWindow *header_window;
101   GdkWindow *drag_window;
102   GdkWindow *drag_highlight_window;
103   GtkTreeViewColumn *drag_column;
104
105   /* bin_window offset */
106   gint dy;
107   gint drag_column_x;
108
109   GtkTreeViewColumn *expander_column;
110   GtkTreeViewColumn *edited_column;
111
112   /* Focus code */
113   GtkTreeViewColumn *focus_column;
114
115   /* Selection stuff */
116   GtkTreeRowReference *anchor;
117   GtkTreeRowReference *cursor;
118
119   /* Column Resizing */
120   GdkCursor *cursor_drag;
121   GdkGC *xor_gc;
122   gint drag_pos;
123   gint x_drag;
124
125   /* Prelight information */
126   GtkRBNode *prelight_node;
127   GtkRBTree *prelight_tree;
128
129   /* The node that's currently being collapsed or expanded */
130   GtkRBNode *expanded_collapsed_node;
131   GtkRBTree *expanded_collapsed_tree;
132   guint expand_collapse_timeout;
133
134   /* Selection information */
135   GtkTreeSelection *selection;
136
137   /* Header information */
138   gint n_columns;
139   GList *columns;
140   gint header_height;
141
142   GtkTreeViewColumnDropFunc column_drop_func;
143   gpointer column_drop_func_data;
144   GtkDestroyNotify column_drop_func_data_destroy;
145   GList *column_drag_info;
146   GtkTreeViewColumnReorder *cur_reorder;
147
148   /* ATK Hack */
149   GtkTreeDestroyCountFunc destroy_count_func;
150   gpointer destroy_count_data;
151   GtkDestroyNotify destroy_count_destroy;
152
153   /* Scroll timeout (e.g. during dnd) */
154   guint scroll_timeout;
155
156   /* Row drag-and-drop */
157   GtkTreeRowReference *drag_dest_row;
158   GtkTreeViewDropPosition drag_dest_pos;
159   guint open_dest_timeout;
160
161   gint pressed_button;
162   gint press_start_x;
163   gint press_start_y;
164
165   /* Scroll-to functionality when unrealized */
166   GtkTreePath *scroll_to_path;
167   GtkTreeViewColumn *scroll_to_column;
168   gfloat scroll_to_row_align;
169   gfloat scroll_to_col_align;
170   guint scroll_to_use_align : 1;
171
172   guint reorderable : 1;
173   guint header_has_focus : 1;
174   guint drag_column_window_state : 3;
175   /* hint to display rows in alternating colors */
176   guint has_rules : 1;
177
178   /* interactive search */
179   guint enable_search : 1;
180   gint search_column;
181   GtkTreeViewSearchDialogPositionFunc search_dialog_position_func;
182   GtkTreeViewSearchEqualFunc search_equal_func;
183   gpointer search_user_data;
184   GtkDestroyNotify search_destroy;
185 };
186
187 #ifdef __GNUC__
188
189 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
190      if (!(expr))                                                       \
191        {                                                                \
192          g_log (G_LOG_DOMAIN,                                           \
193                 G_LOG_LEVEL_CRITICAL,                                   \
194                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
195                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
196                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
197                 "without letting the view know.  Any display from now on is likely to\n"  \
198                 "be incorrect.\n",                                                        \
199                 __FILE__,                                               \
200                 __LINE__,                                               \
201                 __PRETTY_FUNCTION__,                                    \
202                 #expr);                                                 \
203          return ret;                                                    \
204        };                               }G_STMT_END
205
206 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{             \
207      if (!(expr))                                                       \
208        {                                                                \
209          g_log (G_LOG_DOMAIN,                                           \
210                 G_LOG_LEVEL_CRITICAL,                                   \
211                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
212                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
213                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
214                 "without letting the view know.  Any display from now on is likely to\n"  \
215                 "be incorrect.\n",                                                        \
216                 __FILE__,                                               \
217                 __LINE__,                                               \
218                 __PRETTY_FUNCTION__,                                    \
219                 #expr);                                                 \
220          return;                                                        \
221        };                               }G_STMT_END
222
223 #else
224
225 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
226      if (!(expr))                                                       \
227        {                                                                \
228          g_log (G_LOG_DOMAIN,                                           \
229                 G_LOG_LEVEL_CRITICAL,                                   \
230                 "file %s: line %d: assertion `%s' failed.\n"       \
231                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
232                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
233                 "without letting the view know.  Any display from now on is likely to\n"  \
234                 "be incorrect.\n",                                                        \
235                 __FILE__,                                               \
236                 __LINE__,                                               \
237                 #expr);                                                 \
238          return ret;                                                    \
239        };                               }G_STMT_END
240
241 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
242      if (!(expr))                                                       \
243        {                                                                \
244          g_log (G_LOG_DOMAIN,                                           \
245                 G_LOG_LEVEL_CRITICAL,                                   \
246                 "file %s: line %d: assertion '%s' failed.\n"            \
247                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
248                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
249                 "without letting the view know.  Any display from now on is likely to\n"  \
250                 "be incorrect.\n",                                                        \
251                 __FILE__,                                               \
252                 __LINE__,                                               \
253                 #expr);                                                 \
254          return;                                                        \
255        };                               }G_STMT_END
256 #endif
257
258
259 /* functions that shouldn't be exported */
260 void         _gtk_tree_selection_internal_select_node (GtkTreeSelection  *selection,
261                                                        GtkRBNode         *node,
262                                                        GtkRBTree         *tree,
263                                                        GtkTreePath       *path,
264                                                        GdkModifierType    state);
265 gboolean     _gtk_tree_view_find_node                 (GtkTreeView       *tree_view,
266                                                        GtkTreePath       *path,
267                                                        GtkRBTree        **tree,
268                                                        GtkRBNode        **node);
269 GtkTreePath *_gtk_tree_view_find_path                 (GtkTreeView       *tree_view,
270                                                        GtkRBTree         *tree,
271                                                        GtkRBNode         *node);
272 void         _gtk_tree_view_update_size               (GtkTreeView       *tree_view);
273 void         _gtk_tree_view_child_move_resize         (GtkTreeView       *tree_view,
274                                                        GtkWidget         *widget,
275                                                        gint               x,
276                                                        gint               y,
277                                                        gint               width,
278                                                        gint               height);
279
280
281 void _gtk_tree_view_column_realize_button   (GtkTreeViewColumn *column);
282 void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
283 void _gtk_tree_view_column_set_tree_view    (GtkTreeViewColumn *column,
284                                              GtkTreeView       *tree_view);
285 void _gtk_tree_view_column_unset_tree_view  (GtkTreeViewColumn *column);
286 void _gtk_tree_view_column_set_width        (GtkTreeViewColumn *column,
287                                              gint               width);
288 void _gtk_tree_view_column_start_drag       (GtkTreeView       *tree_view,
289                                              GtkTreeViewColumn *column);
290 gboolean _gtk_tree_view_column_cell_event   (GtkTreeViewColumn  *tree_column,
291                                              GtkCellEditable   **editable_widget,
292                                              GdkEvent           *event,
293                                              gchar              *path_string,
294                                              GdkRectangle       *background_area,
295                                              GdkRectangle       *cell_area,
296                                              guint               flags);
297 void _gtk_tree_view_column_start_editing (GtkTreeViewColumn *tree_column,
298                                           GtkCellEditable   *editable_widget);
299 void _gtk_tree_view_column_stop_editing  (GtkTreeViewColumn *tree_column);
300                                          
301
302 GtkTreeSelection* _gtk_tree_selection_new                (void);
303 GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView      *tree_view);
304 void              _gtk_tree_selection_set_tree_view      (GtkTreeSelection *selection,
305                                                           GtkTreeView      *tree_view);
306
307
308
309
310 #ifdef __cplusplus
311 }
312 #endif /* __cplusplus */
313
314
315 #endif /* __GTK_TREE_PRIVATE_H__ */
316