1 /* -*- Mode: C; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */ 2 3 /* 4 * GImageView 5 * Copyright (C) 2001 Takuro Ashie 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: gimv_scrolled.h,v 1.3 2003/07/05 16:41:11 makeinu Exp $ 22 */ 23 24 /* 25 * These codes are mostly taken from Another X image viewer. 26 * 27 * Another X image viewer Author: 28 * David Ramboz <dramboz@users.sourceforge.net> 29 */ 30 31 #ifndef _GIMV_SCROLLED_H_ 32 #define _GIMV_SCROLLED_H_ 33 34 #ifdef HAVE_CONFIG_H 35 #include "config.h" 36 #endif 37 38 #include <gtk/gtk.h> 39 40 41 #define GIMV_TYPE_SCROLLED gimv_scrolled_get_type () 42 #define GIMV_SCROLLED(obj) GTK_CHECK_CAST (obj, GIMV_TYPE_SCROLLED, GimvScrolled) 43 #define GIMV_SCROLLED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMV_TYPE_SCROLLED, GimvScrolledClass)) 44 #define GIMV_IS_SCROLLED(obj) GTK_CHECK_TYPE (obj, GIMV_TYPE_SCROLLED) 45 #define GIMV_SCROLLED_X(scrolled, x) (-GIMV_SCROLLED(scrolled)->x_offset + (x)) 46 #define GIMV_SCROLLED_Y(scrolled, y) (-GIMV_SCROLLED(scrolled)->y_offset + (y)) 47 #define GIMV_SCROLLED_VX(scrolled, x) (GIMV_SCROLLED(scrolled)->x_offset + (x)) 48 #define GIMV_SCROLLED_VY(scrolled, y) (GIMV_SCROLLED(scrolled)->y_offset + (y)) 49 50 51 typedef struct _GimvScrolled GimvScrolled; 52 typedef struct _GimvScrolledClass GimvScrolledClass; 53 54 typedef enum 55 { 56 GIMV_SCROLLED_AUTO_SCROLL_NONE = 0, 57 GIMV_SCROLLED_AUTO_SCROLL_HORIZONTAL = 1 << 0, 58 GIMV_SCROLLED_AUTO_SCROLL_VERTICAL = 1 << 1, 59 GIMV_SCROLLED_AUTO_SCROLL_BOTH = 1 << 2, 60 61 GIMV_SCROLLED_AUTO_SCROLL_DND = 1 << 3, /* for drag motion event */ 62 GIMV_SCROLLED_AUTO_SCROLL_MOTION = 1 << 4, /* for motion notify event */ 63 GIMV_SCROLLED_AUTO_SCROLL_MOTION_ALL = 1 << 5, /* do not check whether button 64 was pressed or not */ 65 } GimvScrolledAutoScrollFlags; 66 67 struct _GimvScrolled { 68 GtkContainer container; 69 70 gint x_offset; 71 gint y_offset; 72 73 GtkAdjustment *h_adjustment; 74 GtkAdjustment *v_adjustment; 75 76 GdkGC *copy_gc; 77 guint freeze_count; 78 79 /* for auto scroll */ 80 gint autoscroll_flags; 81 gint scroll_edge_x, scroll_edge_y; 82 gint x_step, y_step; 83 gint x_interval, y_interval; 84 gboolean pressed; 85 gint drag_start_vx; /* virtual x of drag start point */ 86 gint drag_start_vy; /* virtual y of drag start point */ 87 gint drag_motion_x; /* current real x in the window */ 88 gint drag_motion_y; /* current real y in the window */ 89 gfloat step_scale; 90 gint hscroll_timer_id; 91 gint vscroll_timer_id; 92 }; 93 94 95 struct _GimvScrolledClass { 96 GtkContainerClass parent_class; 97 98 void (*set_scroll_adjustments) (GtkWidget *widget, 99 GtkAdjustment *hadjustment, 100 GtkAdjustment *vadjustment); 101 void (*adjust_adjustments) (GimvScrolled *scrolled); 102 }; 103 104 105 GtkType gimv_scrolled_get_type (void); 106 107 void gimv_scrolled_realize (GimvScrolled *scrolled); 108 void gimv_scrolled_unrealize (GimvScrolled *scrolled); 109 void gimv_scrolled_freeze (GimvScrolled *scrolled); 110 void gimv_scrolled_thawn (GimvScrolled *scrolled); 111 void gimv_scrolled_page_up (GimvScrolled *scrolled); 112 void gimv_scrolled_page_down (GimvScrolled *scrolled); 113 void gimv_scrolled_page_left (GimvScrolled *scrolled); 114 void gimv_scrolled_page_right (GimvScrolled *scrolled); 115 void gimv_scrolled_set_auto_scroll (GimvScrolled *scrolled, 116 GimvScrolledAutoScrollFlags flags); 117 void gimv_scrolled_unset_auto_scroll (GimvScrolled *scrolled); 118 void gimv_scrolled_set_auto_scroll_edge_width (GimvScrolled *scrolled, 119 gint x_edge, 120 gint y_edge); /* -1 to use default value */ 121 void gimv_scrolled_set_h_auto_scroll_resolution (GimvScrolled *scrolled, 122 gint step, 123 gint interval); 124 void gimv_scrolled_set_v_auto_scroll_resolution (GimvScrolled *scrolled, 125 gint step, 126 gint interval); 127 gboolean gimv_scrolled_is_dragging (GimvScrolled *scrolled); 128 void gimv_scrolled_stop_auto_scroll (GimvScrolled *scrolled); 129 130 #endif /* _GIMV_SCROLLED_H_ */ 131