]> Pileus Git - ~andy/gtk/blob - gtk/gtktreeprivate.h
remove validation idle
[~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 typedef enum
33 {
34   GTK_TREE_VIEW_IS_LIST = 1 << 0,
35   GTK_TREE_VIEW_SHOW_EXPANDERS = 1 << 1,
36   GTK_TREE_VIEW_IN_COLUMN_RESIZE = 1 << 2,
37   GTK_TREE_VIEW_ARROW_PRELIT = 1 << 3,
38   GTK_TREE_VIEW_HEADERS_VISIBLE = 1 << 4,
39   GTK_TREE_VIEW_DRAW_KEYFOCUS = 1 << 5,
40   GTK_TREE_VIEW_MODEL_SETUP = 1 << 6
41 } GtkTreeViewFlags;
42
43 #define GTK_TREE_VIEW_SET_FLAG(tree_view, flag)   G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
44 #define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
45 #define GTK_TREE_VIEW_FLAG_SET(tree_view, flag)   ((tree_view->priv->flags&flag)==flag)
46 #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)
47 #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))
48 #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))
49
50 struct _GtkTreeViewPrivate
51 {
52   GtkTreeModel *model;
53
54   guint flags;
55   /* tree information */
56   GtkRBTree *tree;
57
58   gint tab_offset;
59   GtkRBNode *button_pressed_node;
60   GtkRBTree *button_pressed_tree;
61
62   GList *children;
63   gint width;
64   gint height;
65
66   GtkAdjustment *hadjustment;
67   GtkAdjustment *vadjustment;
68
69   GdkWindow *bin_window;
70   GdkWindow *header_window;
71
72   gint expander_column;
73   
74   /* Selection stuff */
75   GtkTreeRowReference *anchor;
76   GtkTreeRowReference *cursor;
77
78   /* Column Resizing */
79   GdkCursor *cursor_drag;
80   GdkGC *xor_gc;
81   gint drag_pos;
82   gint x_drag;
83
84   /* Prelight information */
85   GtkRBNode *prelight_node;
86   GtkRBTree *prelight_tree;
87
88   /* Selection information */
89   GtkTreeSelection *selection;
90
91   /* Header information */
92   gint n_columns;
93   GList *columns;
94   gint header_height;
95
96   /* Scroll timeout (e.g. during dnd) */
97   guint scroll_timeout;
98   
99   /* Row drag-and-drop */
100   GtkTreeRowReference *drag_dest_row;
101   GtkTreeViewDropPosition drag_dest_pos;
102   guint open_dest_timeout;
103   
104   gint pressed_button;
105   gint press_start_x;
106   gint press_start_y;
107
108   /* Scroll-to functionality when unrealized */
109   GtkTreePath *scroll_to_path;
110   GtkTreeViewColumn *scroll_to_column;
111   gfloat scroll_to_row_align;
112   gfloat scroll_to_col_align;
113
114   /* hint to display rows in alternating colors */
115   guint has_rules : 1;
116 };
117
118 #ifdef __GNUC__
119
120 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
121      if (!(expr))                                                       \
122        {                                                                \
123          g_log (G_LOG_DOMAIN,                                           \
124                 G_LOG_LEVEL_CRITICAL,                                   \
125                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
126                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
127                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
128                 "without letting the view know.  Any display from now on is likely to\n"  \
129                 "be incorrect.\n",                                                        \
130                 __FILE__,                                               \
131                 __LINE__,                                               \
132                 __PRETTY_FUNCTION__,                                    \
133                 #expr);                                                 \
134          return ret;                                                    \
135        };                               }G_STMT_END
136
137 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{             \
138      if (!(expr))                                                       \
139        {                                                                \
140          g_log (G_LOG_DOMAIN,                                           \
141                 G_LOG_LEVEL_CRITICAL,                                   \
142                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
143                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
144                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
145                 "without letting the view know.  Any display from now on is likely to\n"  \
146                 "be incorrect.\n",                                                        \
147                 __FILE__,                                               \
148                 __LINE__,                                               \
149                 __PRETTY_FUNCTION__,                                    \
150                 #expr);                                                 \
151          return;                                                        \
152        };                               }G_STMT_END
153
154 #else
155
156 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
157      if (!(expr))                                                       \
158        {                                                                \
159          g_log (G_LOG_DOMAIN,                                           \
160                 G_LOG_LEVEL_CRITICAL,                                   \
161                 "file %s: line %d: assertion `%s' failed.\n"       \
162                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
163                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
164                 "without letting the view know.  Any display from now on is likely to\n"  \
165                 "be incorrect.\n",                                                        \
166                 __FILE__,                                               \
167                 __LINE__,                                               \
168                 #expr);                                                 \
169          return ret;                                                    \
170        };                               }G_STMT_END
171
172 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
173      if (!(expr))                                                       \
174        {                                                                \
175          g_log (G_LOG_DOMAIN,                                           \
176                 G_LOG_LEVEL_CRITICAL,                                   \
177                 "file %s: line %d: assertion '%s' failed.\n"            \
178                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
179                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
180                 "without letting the view know.  Any display from now on is likely to\n"  \
181                 "be incorrect.\n",                                                        \
182                 __FILE__,                                               \
183                 __LINE__,                                               \
184                 #expr);                                                 \
185          return;                                                        \
186        };                               }G_STMT_END
187 #endif
188
189 /* functions that shouldn't be exported */
190 void         _gtk_tree_selection_internal_select_node (GtkTreeSelection  *selection,
191                                                        GtkRBNode         *node,
192                                                        GtkRBTree         *tree,
193                                                        GtkTreePath       *path,
194                                                        GdkModifierType    state);
195 gboolean     _gtk_tree_view_find_node                 (GtkTreeView       *tree_view,
196                                                        GtkTreePath       *path,
197                                                        GtkRBTree        **tree,
198                                                        GtkRBNode        **node);
199 GtkTreePath *_gtk_tree_view_find_path                 (GtkTreeView       *tree_view,
200                                                        GtkRBTree         *tree,
201                                                        GtkRBNode         *node);
202 void         _gtk_tree_view_set_size                  (GtkTreeView       *tree_view,
203                                                        gint               width,
204                                                        gint               height);
205
206
207 GtkTreeSelection* _gtk_tree_selection_new                (void);
208 GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView      *tree_view);
209 void              _gtk_tree_selection_set_tree_view      (GtkTreeSelection *selection,
210                                                           GtkTreeView      *tree_view);
211
212 #ifdef __cplusplus
213 }
214 #endif /* __cplusplus */
215
216
217 #endif /* __GTK_TREE_PRIVATE_H__ */
218