]> Pileus Git - ~andy/gtk/blob - gtk/gtktreeprivate.h
Adapt to GtkTreeSelection changes
[~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_SIZE(column)             (CLAMP (column->size, (column->min_width!=-1)?column->min_width:column->size, (column->max_width!=-1)?column->max_width:column->size))
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   /* Selection stuff */
73   GtkTreePath *anchor;
74   GtkTreePath *cursor;
75
76   /* Column Resizing */
77   GdkCursor *cursor_drag;
78   GdkGC *xor_gc;
79   gint drag_pos;
80   gint x_drag;
81
82   /* Prelight information */
83   GtkRBNode *prelight_node;
84   GtkRBTree *prelight_tree;
85   gint prelight_offset;
86
87   /* Selection information */
88   GtkTreeSelection *selection;
89
90   /* Header information */
91   gint n_columns;
92   GList *columns;
93   gint header_height;
94 };
95
96 #ifdef __GNUC__
97
98 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
99      if (!(expr))                                                       \
100        {                                                                \
101          g_log (G_LOG_DOMAIN,                                           \
102                 G_LOG_LEVEL_CRITICAL,                                   \
103                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
104                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
105                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
106                 "without letting the view know.  Any display from now on is likely to\n"  \
107                 "be incorrect.\n",                                                        \
108                 __FILE__,                                               \
109                 __LINE__,                                               \
110                 __PRETTY_FUNCTION__,                                    \
111                 #expr);                                                 \
112          return ret;                                                    \
113        };                               }G_STMT_END
114
115 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{             \
116      if (!(expr))                                                       \
117        {                                                                \
118          g_log (G_LOG_DOMAIN,                                           \
119                 G_LOG_LEVEL_CRITICAL,                                   \
120                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
121                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
122                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
123                 "without letting the view know.  Any display from now on is likely to\n"  \
124                 "be incorrect.\n",                                                        \
125                 __FILE__,                                               \
126                 __LINE__,                                               \
127                 __PRETTY_FUNCTION__,                                    \
128                 #expr);                                                 \
129          return;                                                        \
130        };                               }G_STMT_END
131
132 #else
133
134 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
135      if (!(expr))                                                       \
136        {                                                                \
137          g_log (G_LOG_DOMAIN,                                           \
138                 G_LOG_LEVEL_CRITICAL,                                   \
139                 "file %s: line %d: assertion `%s' failed.\n"       \
140                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
141                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
142                 "without letting the view know.  Any display from now on is likely to\n"  \
143                 "be incorrect.\n",                                                        \
144                 __FILE__,                                               \
145                 __LINE__,                                               \
146                 #expr);                                                 \
147          return ret;                                                    \
148        };                               }G_STMT_END
149
150 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
151      if (!(expr))                                                       \
152        {                                                                \
153          g_log (G_LOG_DOMAIN,                                           \
154                 G_LOG_LEVEL_CRITICAL,                                   \
155                 "file %s: line %d: assertion '%s' failed.\n"            \
156                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
157                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
158                 "without letting the view know.  Any display from now on is likely to\n"  \
159                 "be incorrect.\n",                                                        \
160                 __FILE__,                                               \
161                 __LINE__,                                               \
162                 #expr);                                                 \
163          return;                                                        \
164        };                               }G_STMT_END
165 #endif
166
167 /* functions that shouldn't be exported */
168 void         _gtk_tree_selection_internal_select_node (GtkTreeSelection  *selection,
169                                                        GtkRBNode         *node,
170                                                        GtkRBTree         *tree,
171                                                        GtkTreePath       *path,
172                                                        GdkModifierType    state);
173 gboolean     _gtk_tree_view_find_node                 (GtkTreeView       *tree_view,
174                                                        GtkTreePath       *path,
175                                                        GtkRBTree        **tree,
176                                                        GtkRBNode        **node);
177 GtkTreePath *_gtk_tree_view_find_path                 (GtkTreeView       *tree_view,
178                                                        GtkRBTree         *tree,
179                                                        GtkRBNode         *node);
180 void         _gtk_tree_view_set_size                  (GtkTreeView       *tree_view,
181                                                        gint               width,
182                                                        gint               height);
183
184
185 GtkTreeSelection* _gtk_tree_selection_new                (void);
186 GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView      *tree_view);
187 void              _gtk_tree_selection_set_tree_view      (GtkTreeSelection *selection,
188                                                           GtkTreeView      *tree_view);
189
190 #ifdef __cplusplus
191 }
192 #endif /* __cplusplus */
193
194
195 #endif /* __GTK_TREE_PRIVATE_H__ */
196