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  *
18  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
19  *
20  */
21 
22 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
23 #error "Only <e-util/e-util.h> should be included directly."
24 #endif
25 
26 #ifndef E_CANVAS_H
27 #define E_CANVAS_H
28 
29 #include <gtk/gtk.h>
30 #include <libgnomecanvas/gnome-canvas.h>
31 
32 /* ECanvas - A class derived from canvas for the purpose of adding
33  * evolution specific canvas hacks. */
34 
35 /* Standard GObject macros */
36 #define E_TYPE_CANVAS \
37 	(e_canvas_get_type ())
38 #define E_CANVAS(obj) \
39 	(G_TYPE_CHECK_INSTANCE_CAST \
40 	((obj), E_TYPE_CANVAS, ECanvas))
41 #define E_CANVAS_CLASS(cls) \
42 	(G_TYPE_CHECK_CLASS_CAST \
43 	((cls), E_TYPE_CANVAS, ECanvasClass))
44 #define E_IS_CANVAS(obj) \
45 	(G_TYPE_CHECK_INSTANCE_TYPE \
46 	((obj), E_TYPE_CANVAS))
47 #define E_IS_CANVAS_CLASS(cls) \
48 	(G_TYPE_CHECK_CLASS_TYPE \
49 	((cls), E_TYPE_CANVAS))
50 #define E_CANVAS_GET_CLASS(obj) \
51 	(G_TYPE_INSTANCE_GET_CLASS \
52 	((obj), E_TYPE_CANVAS, ECanvasClass))
53 
54 G_BEGIN_DECLS
55 
56 typedef void	(*ECanvasItemReflowFunc)	(GnomeCanvasItem *item,
57 						 gint flags);
58 
59 typedef void	(*ECanvasItemSelectionFunc)	(GnomeCanvasItem *item,
60 						 gint flags,
61 						 gpointer user_data);
62 /* Returns the same as strcmp does. */
63 typedef gint	(*ECanvasItemSelectionCompareFunc)
64 						(GnomeCanvasItem *item,
65 						 gpointer data1,
66 						 gpointer data2,
67 						 gint flags);
68 
69 typedef struct _ECanvas ECanvas;
70 typedef struct _ECanvasClass ECanvasClass;
71 
72 /* Object flags for items */
73 enum {
74 	E_CANVAS_ITEM_NEEDS_REFLOW = 1 << 13,
75 	E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW = 1 << 14
76 };
77 
78 typedef struct {
79 	GnomeCanvasItem *item;
80 	gpointer         id;
81 } ECanvasSelectionInfo;
82 
83 typedef void	(*ECanvasItemGrabCancelled)	(ECanvas *canvas,
84 						 GnomeCanvasItem *item,
85 						 gpointer data);
86 
87 struct _ECanvas {
88 	GnomeCanvas parent;
89 
90 	gint idle_id;
91 	GList *selection;
92 	ECanvasSelectionInfo *cursor;
93 
94 	GtkWidget *tooltip_window;
95 	gint visibility_notify_id;
96 	GtkWidget *toplevel;
97 
98 	/* Input context for dead key support */
99 	GtkIMContext *im_context;
100 
101 	ECanvasItemGrabCancelled grab_cancelled_cb;
102 	guint grab_cancelled_check_id;
103 	guint32 grab_cancelled_time;
104 	gpointer grab_cancelled_data;
105 };
106 
107 struct _ECanvasClass {
108 	GnomeCanvasClass parent_class;
109 
110 	void		(*reflow)		(ECanvas *canvas);
111 };
112 
113 GType		e_canvas_get_type		(void) G_GNUC_CONST;
114 GtkWidget *	e_canvas_new			(void);
115 
116 /* Used to send all of the keystroke events to a specific item as well as
117  * GDK_FOCUS_CHANGE events. */
118 void		e_canvas_item_grab_focus	(GnomeCanvasItem *item,
119 						 gboolean widget_too);
120 void		e_canvas_item_request_reflow	(GnomeCanvasItem *item);
121 void		e_canvas_item_request_parent_reflow
122 						(GnomeCanvasItem *item);
123 void		e_canvas_item_set_reflow_callback
124 						(GnomeCanvasItem *item,
125 						 ECanvasItemReflowFunc func);
126 gint		e_canvas_item_grab		(ECanvas *canvas,
127 						 GnomeCanvasItem *item,
128 						 guint event_mask,
129 						 GdkCursor *cursor,
130 						 GdkDevice *device,
131 						 guint32 etime,
132 						 ECanvasItemGrabCancelled cancelled,
133 						 gpointer cancelled_data);
134 void		e_canvas_item_ungrab		(ECanvas *canvas,
135 						 GnomeCanvasItem *item,
136 						 guint32 etime);
137 
138 G_END_DECLS
139 
140 #endif /* E_CANVAS_H */
141