]> Pileus Git - ~andy/gtk/blob - gtk/gtktreeprivate.h
Minor fix.
[~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 #define TREE_VIEW_DRAG_WIDTH 6
33
34 typedef enum
35 {
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
44 } GtkTreeViewFlags;
45
46 enum
47 {
48   DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
49   DRAG_COLUMN_WINDOW_STATE_ORIGINAL = 1,
50   DRAG_COLUMN_WINDOW_STATE_ARROW = 2,
51   DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT = 3,
52   DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT = 4
53 };
54   
55 #define GTK_TREE_VIEW_SET_FLAG(tree_view, flag)   G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
56 #define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
57 #define GTK_TREE_VIEW_FLAG_SET(tree_view, flag)   ((tree_view->priv->flags&flag)==flag)
58 #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)
59 #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))
60 #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))
61
62  /* This lovely little value is used to determine how far away from the title bar
63   * you can move the mouse and still have a column drag work.
64   */
65 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
66
67 typedef void (*GtkTreeViewSearchDialogPositionFunc) (GtkTreeView *tree_view,
68                                                      GtkWidget   *search_dialog);
69
70 typedef struct _GtkTreeViewColumnReorder GtkTreeViewColumnReorder;
71 struct _GtkTreeViewColumnReorder
72 {
73   gint left_align;
74   gint right_align;
75   GtkTreeViewColumn *left_column;
76   GtkTreeViewColumn *right_column;
77 };
78
79 struct _GtkTreeViewPrivate
80 {
81   GtkTreeModel *model;
82
83   guint flags;
84   /* tree information */
85   GtkRBTree *tree;
86
87   gint tab_offset;
88   GtkRBNode *button_pressed_node;
89   GtkRBTree *button_pressed_tree;
90
91   GList *children;
92   gint width;
93   gint height;
94
95   GtkAdjustment *hadjustment;
96   GtkAdjustment *vadjustment;
97
98   GdkWindow *bin_window;
99   GdkWindow *header_window;
100   GdkWindow *drag_window;
101   GdkWindow *drag_highlight_window;
102   GtkTreeViewColumn *drag_column;
103
104   /* bin_window offset */
105   gint dy;
106   gint drag_column_x;
107
108   GtkTreeViewColumn *expander_column;
109   GtkTreeViewColumn *edited_column;
110   guint presize_handler_timer;
111   guint validate_rows_timer;
112
113   /* Focus code */
114   GtkTreeViewColumn *focus_column;
115
116   /* Selection stuff */
117   GtkTreeRowReference *anchor;
118   GtkTreeRowReference *cursor;
119
120   /* Column Resizing */
121   gint drag_pos;
122   gint x_drag;
123
124   /* Prelight information */
125   GtkRBNode *prelight_node;
126   GtkRBTree *prelight_tree;
127
128   /* The node that's currently being collapsed or expanded */
129   GtkRBNode *expanded_collapsed_node;
130   GtkRBTree *expanded_collapsed_tree;
131   guint expand_collapse_timeout;
132
133   /* Selection information */
134   GtkTreeSelection *selection;
135
136   /* Header information */
137   gint n_columns;
138   GList *columns;
139   gint header_height;
140
141   GtkTreeViewColumnDropFunc column_drop_func;
142   gpointer column_drop_func_data;
143   GtkDestroyNotify column_drop_func_data_destroy;
144   GList *column_drag_info;
145   GtkTreeViewColumnReorder *cur_reorder;
146
147   /* ATK Hack */
148   GtkTreeDestroyCountFunc destroy_count_func;
149   gpointer destroy_count_data;
150   GtkDestroyNotify destroy_count_destroy;
151
152   /* Scroll timeout (e.g. during dnd) */
153   guint scroll_timeout;
154
155   /* Row drag-and-drop */
156   GtkTreeRowReference *drag_dest_row;
157   GtkTreeViewDropPosition drag_dest_pos;
158   guint open_dest_timeout;
159
160   gint pressed_button;
161   gint press_start_x;
162   gint press_start_y;
163
164   /* Scroll-to functionality when unrealized */
165   GtkTreePath *scroll_to_path;
166   GtkTreeViewColumn *scroll_to_column;
167   gfloat scroll_to_row_align;
168   gfloat scroll_to_col_align;
169   guint scroll_to_use_align : 1;
170
171   guint reorderable : 1;
172   guint header_has_focus : 1;
173   guint drag_column_window_state : 3;
174   /* hint to display rows in alternating colors */
175   guint has_rules : 1;
176   guint mark_rows_col_dirty : 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 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
188      if (!(expr))                                                       \
189        {                                                                \
190          g_log (G_LOG_DOMAIN,                                           \
191                 G_LOG_LEVEL_CRITICAL,                                   \
192                 "file %s: line %d (%s): assertion `%s' failed.\n"       \
193                 "There is a disparity between the internal view of the GtkTreeView,\n"    \
194                 "and the GtkTreeModel.  This generally means that the model has changed\n"\
195                 "without letting the view know.  Any display from now on is likely to\n"  \
196                 "be incorrect.\n",                                                        \
197                 __FILE__,                                               \
198                 __LINE__,                                               \
199                 __PRETTY_FUNCTION__,                                    \
200                 #expr);                                                 \
201          return ret;                                                    \
202        };                               }G_STMT_END
203
204 #define TREE_VIEW_INTERNAL_ASSERT_VOID(expr)     G_STMT_START{          \
205      if (!(expr))                                                       \
206        {                                                                \
207          g_log (G_LOG_DOMAIN,                                           \
208                 G_LOG_LEVEL_CRITICAL,                                   \
209                 "file %s: line %d (%s): 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"  \
213                 "be incorrect.\n",                                                        \
214                 __FILE__,                                               \
215                 __LINE__,                                               \
216                 __PRETTY_FUNCTION__,                                    \
217                 #expr);                                                 \
218          return;                                                        \
219        };                               }G_STMT_END
220
221
222 /* functions that shouldn't be exported */
223 void         _gtk_tree_selection_internal_select_node (GtkTreeSelection  *selection,
224                                                        GtkRBNode         *node,
225                                                        GtkRBTree         *tree,
226                                                        GtkTreePath       *path,
227                                                        GdkModifierType    state);
228 gboolean     _gtk_tree_view_find_node                 (GtkTreeView       *tree_view,
229                                                        GtkTreePath       *path,
230                                                        GtkRBTree        **tree,
231                                                        GtkRBNode        **node);
232 GtkTreePath *_gtk_tree_view_find_path                 (GtkTreeView       *tree_view,
233                                                        GtkRBTree         *tree,
234                                                        GtkRBNode         *node);
235 void         _gtk_tree_view_child_move_resize         (GtkTreeView       *tree_view,
236                                                        GtkWidget         *widget,
237                                                        gint               x,
238                                                        gint               y,
239                                                        gint               width,
240                                                        gint               height);
241
242
243 void _gtk_tree_view_column_realize_button   (GtkTreeViewColumn *column);
244 void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
245 void _gtk_tree_view_column_set_tree_view    (GtkTreeViewColumn *column,
246                                              GtkTreeView       *tree_view);
247 void _gtk_tree_view_column_unset_tree_view  (GtkTreeViewColumn *column);
248 void _gtk_tree_view_column_set_width        (GtkTreeViewColumn *column,
249                                              gint               width);
250 void _gtk_tree_view_column_start_drag       (GtkTreeView       *tree_view,
251                                              GtkTreeViewColumn *column);
252 gboolean _gtk_tree_view_column_cell_event   (GtkTreeViewColumn  *tree_column,
253                                              GtkCellEditable   **editable_widget,
254                                              GdkEvent           *event,
255                                              gchar              *path_string,
256                                              GdkRectangle       *background_area,
257                                              GdkRectangle       *cell_area,
258                                              guint               flags);
259 void _gtk_tree_view_column_start_editing (GtkTreeViewColumn *tree_column,
260                                           GtkCellEditable   *editable_widget);
261 void _gtk_tree_view_column_stop_editing  (GtkTreeViewColumn *tree_column);
262 void _gtk_tree_view_install_mark_rows_col_dirty (GtkTreeView *tree_view);                                        
263
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);
268
269
270
271
272 #ifdef __cplusplus
273 }
274 #endif /* __cplusplus */
275
276
277 #endif /* __GTK_TREE_PRIVATE_H__ */
278