Пример #1
0
void scroll_widget::wheelEvent(QGraphicsSceneWheelEvent *a_event_ptr) {
  if (a_event_ptr->delta() < 0) {
    scroll_by(0, -10);
  } else {
    scroll_by(0, 10);
  }
  a_event_ptr->accept();

  //?
  widget::wheelEvent(a_event_ptr);
}
Пример #2
0
/* Scroll event handler for the image view.  We zoom with an event without
 * modifiers rather than scroll; we use the Shift modifier to scroll.
 * Rationale: images are not primarily vertical, and in EOG you scan scroll by
 * dragging the image with button 1 anyways.
 */
static gboolean
image_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
{
	ImageView *view;
	ImageViewPrivate *priv;
	double zoom_factor;
	int xofs, yofs;

	view = IMAGE_VIEW (widget);
	priv = view->priv;

	/* Compute zoom factor and scrolling offsets; we'll only use either of them */

	xofs = priv->hadj->page_increment / 2; /* same as in gtkscrolledwindow.c */
	yofs = priv->vadj->page_increment / 2;

	switch (event->direction) {
	case GDK_SCROLL_UP:
		zoom_factor = IMAGE_VIEW_ZOOM_MULTIPLIER;
		xofs = 0;
		yofs = -yofs;
		break;

	case GDK_SCROLL_LEFT:
		zoom_factor = 1.0 / IMAGE_VIEW_ZOOM_MULTIPLIER;
		xofs = -xofs;
		yofs = 0;
		break;

	case GDK_SCROLL_DOWN:
		zoom_factor = 1.0 / IMAGE_VIEW_ZOOM_MULTIPLIER;
		xofs = 0;
		yofs = yofs;
		break;

	case GDK_SCROLL_RIGHT:
		zoom_factor = IMAGE_VIEW_ZOOM_MULTIPLIER;
		xofs = xofs;
		yofs = 0;
		break;

	default:
		g_assert_not_reached ();
		return FALSE;
	}

	if ((event->state & GDK_SHIFT_MASK) == 0)
		image_view_set_zoom (view, priv->zoomx * zoom_factor, priv->zoomy * zoom_factor,
				     TRUE, event->x, event->y);
	else
		scroll_by (view, xofs, yofs);

	return TRUE;
}
Пример #3
0
void TBScrollBox::page_backward(DimensionName d) {
    scroll_by(d, long(large_scroll(d)));
}
Пример #4
0
void TBScrollBox::scroll_backward(DimensionName d) {
    scroll_by(d, long(small_scroll(d)));
}
Пример #5
0
/* Key press event handler for the image view */
static gboolean
image_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
{
	ImageView *view;
	ImageViewPrivate *priv;
	gboolean do_zoom;
	double zoomx, zoomy;
	gboolean do_scroll;
	int xofs, yofs;

	view = IMAGE_VIEW (widget);
	priv = view->priv;

	do_zoom = FALSE;
	do_scroll = FALSE;
	xofs = yofs = 0;
	zoomx = zoomy = 1.0;

	if ((event->state & (GDK_MODIFIER_MASK & ~GDK_LOCK_MASK)) != 0)
		return FALSE;

	switch (event->keyval) {
	case GDK_Up:
		do_scroll = TRUE;
		xofs = 0;
		yofs = -SCROLL_STEP_SIZE;
		break;

	case GDK_Down:
		do_scroll = TRUE;
		xofs = 0;
		yofs = SCROLL_STEP_SIZE;
		break;

	case GDK_Left:
		do_scroll = TRUE;
		xofs = -SCROLL_STEP_SIZE;
		yofs = 0;
		break;

	case GDK_Right:
		do_scroll = TRUE;
		xofs = SCROLL_STEP_SIZE;
		yofs = 0;
		break;

	case GDK_plus:
	case GDK_KP_Add:
		do_zoom = TRUE;
		zoomx = priv->zoomx * IMAGE_VIEW_ZOOM_MULTIPLIER;
		zoomy = priv->zoomy * IMAGE_VIEW_ZOOM_MULTIPLIER;
		break;

	case GDK_minus:
	case GDK_KP_Subtract:
		do_zoom = TRUE;
		zoomx = priv->zoomx / IMAGE_VIEW_ZOOM_MULTIPLIER;
		zoomy = priv->zoomy / IMAGE_VIEW_ZOOM_MULTIPLIER;
		break;

	case GDK_1:
		do_zoom = TRUE;
		zoomx = zoomy = 1.0;
		break;

	case GDK_F:
	case GDK_f:
		g_signal_emit (view, image_view_signals [ZOOM_FIT], 0);
		break;

	default:
		return FALSE;
	}

	if (do_zoom) {
		gint x, y;

		gdk_window_get_pointer (widget->window, &x, &y, NULL);
		image_view_set_zoom (view, zoomx, zoomy, TRUE, x, y);
	}

	if (do_scroll)
		scroll_by (view, xofs, yofs);

	return TRUE;
}