2000-10-05 01:04:57 +00:00
|
|
|
/* gtktreeprivate.h
|
|
|
|
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GTK_TREE_PRIVATE_H__
|
|
|
|
#define __GTK_TREE_PRIVATE_H__
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#include <gtk/gtktreeview.h>
|
|
|
|
#include <gtk/gtktreeselection.h>
|
|
|
|
#include <gtk/gtkrbtree.h>
|
|
|
|
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2000-10-05 01:04:57 +00:00
|
|
|
GTK_TREE_VIEW_IS_LIST = 1 << 0,
|
|
|
|
GTK_TREE_VIEW_SHOW_EXPANDERS = 1 << 1,
|
|
|
|
GTK_TREE_VIEW_IN_COLUMN_RESIZE = 1 << 2,
|
|
|
|
GTK_TREE_VIEW_ARROW_PRELIT = 1 << 3,
|
|
|
|
GTK_TREE_VIEW_HEADERS_VISIBLE = 1 << 4,
|
|
|
|
GTK_TREE_VIEW_DRAW_KEYFOCUS = 1 << 5,
|
|
|
|
GTK_TREE_VIEW_MODEL_SETUP = 1 << 6
|
|
|
|
} GtkTreeViewFlags;
|
|
|
|
|
|
|
|
#define GTK_TREE_VIEW_SET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags|=flag); }G_STMT_END
|
|
|
|
#define GTK_TREE_VIEW_UNSET_FLAG(tree_view, flag) G_STMT_START{ (tree_view->priv->flags&=~(flag)); }G_STMT_END
|
|
|
|
#define GTK_TREE_VIEW_FLAG_SET(tree_view, flag) ((tree_view->priv->flags&flag)==flag)
|
|
|
|
#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)
|
|
|
|
#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))
|
|
|
|
#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))
|
|
|
|
|
|
|
|
struct _GtkTreeViewPrivate
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
guint flags;
|
|
|
|
/* tree information */
|
|
|
|
GtkRBTree *tree;
|
|
|
|
|
|
|
|
gint tab_offset;
|
|
|
|
GtkRBNode *button_pressed_node;
|
|
|
|
GtkRBTree *button_pressed_tree;
|
|
|
|
|
|
|
|
GList *children;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
GtkAdjustment *hadjustment;
|
|
|
|
GtkAdjustment *vadjustment;
|
|
|
|
|
|
|
|
GdkWindow *bin_window;
|
|
|
|
GdkWindow *header_window;
|
|
|
|
|
|
|
|
/* Selection stuff */
|
|
|
|
GtkTreePath *anchor;
|
|
|
|
GtkTreePath *cursor;
|
|
|
|
|
|
|
|
/* Column Resizing */
|
|
|
|
GdkCursor *cursor_drag;
|
|
|
|
GdkGC *xor_gc;
|
|
|
|
gint drag_pos;
|
|
|
|
gint x_drag;
|
|
|
|
|
|
|
|
/* Prelight information */
|
|
|
|
GtkRBNode *prelight_node;
|
|
|
|
GtkRBTree *prelight_tree;
|
|
|
|
gint prelight_offset;
|
|
|
|
|
|
|
|
/* Selection information */
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
/* Header information */
|
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
|
|
|
gint n_columns;
|
|
|
|
GList *columns;
|
2000-10-05 01:04:57 +00:00
|
|
|
gint header_height;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
|
|
|
|
#define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
|
|
|
|
if (!(expr)) \
|
|
|
|
{ \
|
|
|
|
g_log (G_LOG_DOMAIN, \
|
|
|
|
G_LOG_LEVEL_CRITICAL, \
|
|
|
|
"file %s: line %d (%s): assertion `%s' failed.\n" \
|
|
|
|
"There is a disparity between the internal view of the GtkTreeView,\n" \
|
|
|
|
"and the GtkTreeModel. This generally means that the model has changed\n"\
|
|
|
|
"without letting the view know. Any display from now on is likely to\n" \
|
|
|
|
"be incorrect.\n", \
|
|
|
|
__FILE__, \
|
|
|
|
__LINE__, \
|
|
|
|
__PRETTY_FUNCTION__, \
|
|
|
|
#expr); \
|
|
|
|
return ret; \
|
|
|
|
}; }G_STMT_END
|
|
|
|
|
|
|
|
#define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
|
|
|
|
if (!(expr)) \
|
|
|
|
{ \
|
|
|
|
g_log (G_LOG_DOMAIN, \
|
|
|
|
G_LOG_LEVEL_CRITICAL, \
|
|
|
|
"file %s: line %d (%s): assertion `%s' failed.\n" \
|
|
|
|
"There is a disparity between the internal view of the GtkTreeView,\n" \
|
|
|
|
"and the GtkTreeModel. This generally means that the model has changed\n"\
|
|
|
|
"without letting the view know. Any display from now on is likely to\n" \
|
|
|
|
"be incorrect.\n", \
|
|
|
|
__FILE__, \
|
|
|
|
__LINE__, \
|
|
|
|
__PRETTY_FUNCTION__, \
|
|
|
|
#expr); \
|
|
|
|
return; \
|
|
|
|
}; }G_STMT_END
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
|
|
|
|
if (!(expr)) \
|
|
|
|
{ \
|
|
|
|
g_log (G_LOG_DOMAIN, \
|
|
|
|
G_LOG_LEVEL_CRITICAL, \
|
|
|
|
"file %s: line %d: assertion `%s' failed.\n" \
|
|
|
|
"There is a disparity between the internal view of the GtkTreeView,\n" \
|
|
|
|
"and the GtkTreeModel. This generally means that the model has changed\n"\
|
|
|
|
"without letting the view know. Any display from now on is likely to\n" \
|
|
|
|
"be incorrect.\n", \
|
|
|
|
__FILE__, \
|
|
|
|
__LINE__, \
|
|
|
|
#expr); \
|
|
|
|
return ret; \
|
|
|
|
}; }G_STMT_END
|
|
|
|
|
|
|
|
#define TREE_VIEW_INTERNAL_ASSERT_VOID(expr) G_STMT_START{ \
|
|
|
|
if (!(expr)) \
|
|
|
|
{ \
|
|
|
|
g_log (G_LOG_DOMAIN, \
|
|
|
|
G_LOG_LEVEL_CRITICAL, \
|
|
|
|
"file %s: line %d: assertion '%s' failed.\n" \
|
|
|
|
"There is a disparity between the internal view of the GtkTreeView,\n" \
|
|
|
|
"and the GtkTreeModel. This generally means that the model has changed\n"\
|
|
|
|
"without letting the view know. Any display from now on is likely to\n" \
|
|
|
|
"be incorrect.\n", \
|
|
|
|
__FILE__, \
|
|
|
|
__LINE__, \
|
|
|
|
#expr); \
|
|
|
|
return; \
|
|
|
|
}; }G_STMT_END
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* functions that shouldn't be exported */
|
|
|
|
void _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
|
|
|
|
GtkRBNode *node,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GdkModifierType state);
|
|
|
|
gboolean _gtk_tree_view_find_node (GtkTreeView *tree_view,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkRBTree **tree,
|
|
|
|
GtkRBNode **node);
|
|
|
|
GtkTreePath *_gtk_tree_view_find_path (GtkTreeView *tree_view,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node);
|
|
|
|
void _gtk_tree_view_set_size (GtkTreeView *tree_view,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __GTK_TREE_PRIVATE_H__ */
|
|
|
|
|