1 /* Copyright 2006, 2007, 2008, Soren Sandmann <sandmann@daimi.au.dk> 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Lesser General Public 5 * License as published by the Free Software Foundation; either 6 * version 2 of the License, or (at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public 14 * License along with this library; if not, write to the 15 * Free Software Foundation, Inc., 51 Franklin Street - Suite 500, 16 * Boston, MA 02110-1335, USA. 17 */ 18 #include <cairo.h> 19 #include <gtk/gtk.h> 20 21 #define FOO_TYPE_SCROLL_AREA (foo_scroll_area_get_type ()) 22 #define FOO_SCROLL_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOO_TYPE_SCROLL_AREA, FooScrollArea)) 23 #define FOO_SCROLL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOO_TYPE_SCROLL_AREA, FooScrollAreaClass)) 24 #define FOO_IS_SCROLL_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOO_TYPE_SCROLL_AREA)) 25 #define FOO_IS_SCROLL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOO_TYPE_SCROLL_AREA)) 26 #define FOO_SCROLL_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOO_TYPE_SCROLL_AREA, FooScrollAreaClass)) 27 28 typedef struct FooScrollArea FooScrollArea; 29 typedef struct FooScrollAreaClass FooScrollAreaClass; 30 typedef struct FooScrollAreaPrivate FooScrollAreaPrivate; 31 typedef struct FooScrollAreaEvent FooScrollAreaEvent; 32 33 typedef enum 34 { 35 FOO_BUTTON_PRESS, 36 FOO_BUTTON_RELEASE, 37 FOO_DRAG_HOVER, 38 FOO_DROP, 39 FOO_MOTION 40 } FooScrollAreaEventType; 41 42 struct FooScrollAreaEvent 43 { 44 FooScrollAreaEventType type; 45 int x; 46 int y; 47 }; 48 49 typedef void (* FooScrollAreaEventFunc) (FooScrollArea *area, 50 FooScrollAreaEvent *event, 51 gpointer data); 52 53 struct FooScrollArea 54 { 55 GtkContainer parent_instance; 56 57 FooScrollAreaPrivate *priv; 58 }; 59 60 struct FooScrollAreaClass 61 { 62 GtkContainerClass parent_class; 63 64 void (*set_scroll_adjustments) (FooScrollArea *scroll_area, 65 GtkAdjustment *hadjustment, 66 GtkAdjustment *vadjustment); 67 68 void (*viewport_changed) (FooScrollArea *scroll_area, 69 GdkRectangle *old_viewport, 70 GdkRectangle *new_viewport); 71 72 void (*paint) (FooScrollArea *scroll_area, 73 cairo_t *cr, 74 GdkRectangle *extents, 75 cairo_region_t *region); 76 }; 77 78 GType foo_scroll_area_get_type (void); 79 80 FooScrollArea *foo_scroll_area_new (void); 81 82 /* Set the requisition for the widget. */ 83 void foo_scroll_area_set_min_size (FooScrollArea *scroll_area, 84 int min_width, 85 int min_height); 86 87 /* Set how much of the canvas can be scrolled into view */ 88 void foo_scroll_area_set_size (FooScrollArea *scroll_area, 89 int width, 90 int height); 91 void foo_scroll_area_set_size_fixed_y (FooScrollArea *scroll_area, 92 int width, 93 int height, 94 int old_y, 95 int new_y); 96 void foo_scroll_area_set_viewport_pos (FooScrollArea *scroll_area, 97 int x, 98 int y); 99 void foo_scroll_area_get_viewport (FooScrollArea *scroll_area, 100 GdkRectangle *viewport); 101 void foo_scroll_area_add_input_from_stroke (FooScrollArea *scroll_area, 102 cairo_t *cr, 103 FooScrollAreaEventFunc func, 104 gpointer data); 105 void foo_scroll_area_add_input_from_fill (FooScrollArea *scroll_area, 106 cairo_t *cr, 107 FooScrollAreaEventFunc func, 108 gpointer data); 109 void foo_scroll_area_invalidate_region (FooScrollArea *area, 110 cairo_region_t *region); 111 void foo_scroll_area_invalidate (FooScrollArea *scroll_area); 112 void foo_scroll_area_invalidate_rect (FooScrollArea *scroll_area, 113 int x, 114 int y, 115 int width, 116 int height); 117 void foo_scroll_area_begin_grab (FooScrollArea *scroll_area, 118 FooScrollAreaEventFunc func, 119 gpointer input_data); 120 void foo_scroll_area_end_grab (FooScrollArea *scroll_area, 121 FooScrollAreaEvent *event); 122 gboolean foo_scroll_area_is_grabbed (FooScrollArea *scroll_area); 123 124 void foo_scroll_area_begin_auto_scroll (FooScrollArea *scroll_area); 125 void foo_scroll_area_auto_scroll (FooScrollArea *scroll_area, 126 FooScrollAreaEvent *event); 127 void foo_scroll_area_end_auto_scroll (FooScrollArea *scroll_area); 128