1 /*
2  * This program is free software; you can redistribute it and/or modify it
3  * under the terms of the GNU Lesser General Public License as published by
4  * the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9  * for more details.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, see <http://www.gnu.org/licenses/>.
13  *
14  *
15  * Authors:
16  *		Chris Lahey <clahey@ximian.com>
17  *		Miguel de Icaza (miguel@gnu.org)
18  *
19  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
20  *
21  */
22 
23 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
24 #error "Only <e-util/e-util.h> should be included directly."
25 #endif
26 
27 #ifndef _E_TABLE_HEADER_ITEM_H_
28 #define _E_TABLE_HEADER_ITEM_H_
29 
30 #include <libxml/tree.h>
31 #include <libgnomecanvas/libgnomecanvas.h>
32 
33 #include <e-util/e-table-header.h>
34 #include <e-util/e-table-sort-info.h>
35 #include <e-util/e-table.h>
36 #include <e-util/e-tree.h>
37 
38 /* Standard GObject macros */
39 #define E_TYPE_TABLE_HEADER_ITEM \
40 	(e_table_header_item_get_type ())
41 #define E_TABLE_HEADER_ITEM(obj) \
42 	(G_TYPE_CHECK_INSTANCE_CAST \
43 	((obj), E_TYPE_TABLE_HEADER_ITEM, ETableHeaderItem))
44 #define E_TABLE_HEADER_ITEM_CLASS(cls) \
45 	(G_TYPE_CHECK_CLASS_CAST \
46 	((cls), E_TYPE_TABLE_HEADER_ITEM, ETableHeaderItemClass))
47 #define E_IS_TABLE_HEADER_ITEM(obj) \
48 	(G_TYPE_CHECK_INSTANCE_TYPE \
49 	((obj), E_TYPE_TABLE_HEADER_ITEM))
50 #define E_IS_TABLE_HEADER_ITEM_CLASS(cls) \
51 	(G_TYPE_CHECK_CLASS_TYPE \
52 	((cls), E_TYPE_TABLE_HEADER_ITEM))
53 #define E_TABLE_HEADER_ITEM_GET_CLASS(obj) \
54 	(G_TYPE_INSTANCE_GET_CLASS \
55 	((obj), E_TYPE_TABLE_HEADER_ITEM, ETableHeaderItemClass))
56 
57 G_BEGIN_DECLS
58 
59 typedef enum {
60 	E_TABLE_HEADER_ITEM_SORT_FLAG_NONE = 0,
61 	E_TABLE_HEADER_ITEM_SORT_FLAG_ADD_AS_FIRST = (1 << 0),
62 	E_TABLE_HEADER_ITEM_SORT_FLAG_ADD_AS_LAST = (1 << 1)
63 } ETableHeaderItemSortFlag;
64 
65 typedef struct _ETableHeaderItem ETableHeaderItem;
66 typedef struct _ETableHeaderItemClass ETableHeaderItemClass;
67 
68 struct _ETableHeaderItem {
69 	GnomeCanvasItem parent;
70 	ETableHeader *eth;
71 
72 	GdkCursor *change_cursor;
73 	GdkCursor *resize_cursor;
74 
75 	gshort height, width;
76 	PangoFontDescription *font_desc;
77 
78 	/*
79 	 * Used during resizing; Could be shorts
80 	 */
81 	gint resize_col;
82 	gint resize_start_pos;
83 	gint resize_min_width;
84 
85 	gpointer resize_guide;
86 
87 	gint group_indent_width;
88 
89 	/*
90 	 * Ids
91 	 */
92 	gint structure_change_id, dimension_change_id;
93 
94 	/*
95 	 * For dragging columns
96 	 */
97 	guint maybe_drag : 1;
98 	guint dnd_ready : 1;
99 	gint click_x, click_y;
100 	gint drag_col, drop_col, drag_mark;
101 	guint drag_motion_id;
102 	guint drag_end_id;
103 	guint drag_leave_id;
104 	guint drag_drop_id;
105 	guint drag_data_received_id;
106 	guint drag_data_get_id;
107 	guint sort_info_changed_id, group_info_changed_id;
108 	GnomeCanvasItem *remove_item;
109 
110 	gchar *dnd_code;
111 
112 	/*
113 	 * For column sorting info
114 	 */
115 	ETableSortInfo *sort_info;
116 
117 	guint scroll_direction : 4;
118 	gint last_drop_x;
119 	gint last_drop_y;
120 	gint last_drop_time;
121 	GdkDragContext *last_drop_context;
122 	gint scroll_idle_id;
123 
124 	/* For adding fields. */
125 	ETableHeader *full_header;
126 	ETable *table;
127 	ETree *tree;
128 	gpointer config;
129 
130 	union {
131 		GtkWidget *widget;
132 		gpointer pointer;
133 	} etfcd;
134 
135 	/* For keyboard navigation*/
136 	gint selected_col;
137 };
138 
139 struct _ETableHeaderItemClass {
140 	GnomeCanvasItemClass parent_class;
141 
142 	/* Signals */
143 	void		(*button_pressed)	(ETableHeaderItem *ethi,
144 						 GdkEvent *button_event);
145 };
146 
147 GType		e_table_header_item_get_type	(void) G_GNUC_CONST;
148 void		ethi_change_sort_state		(ETableHeaderItem *ethi,
149 						 ETableCol *col,
150 						 ETableHeaderItemSortFlag flag);
151 void		e_table_header_item_customize_view
152 						(ETableHeaderItem *ethi);
153 
154 G_END_DECLS
155 
156 #endif /* _E_TABLE_HEADER_ITEM_H_ */
157