示例#1
0
static gboolean on_auto_scroll(FmDndAutoScroll* as)
{
    int x, y;
    GtkAdjustment* va = as->vadj;
    GtkAdjustment* ha = as->hadj;
    GtkWidget* widget = as->widget;

    gdk_window_get_pointer(widget->window, &x, &y, NULL);

    if(va)
    {
        if(y < SCROLL_EDGE_SIZE) /* scroll up */
        {
            if(va->value > va->lower)
            {
                va->value -= va->step_increment;
                if(va->value < va->lower)
                    va->value = va->lower;
            }
        }
        else if(y > (widget->allocation.height - SCROLL_EDGE_SIZE))
        {
            /* scroll down */
            if(va->value < va->upper - va->page_size)
            {
                va->value += va->step_increment;
                if(va->value > va->upper - va->page_size)
                    va->value = va->upper - va->page_size;
            }
        }
        gtk_adjustment_value_changed(va);
    }

    if(ha)
    {
        if(x < SCROLL_EDGE_SIZE) /* scroll to left */
        {
            if(ha->value > ha->lower)
            {
                ha->value -= ha->step_increment;
                if(ha->value < ha->lower)
                    ha->value = ha->lower;
            }
        }
        else if(x > (widget->allocation.width - SCROLL_EDGE_SIZE))
        {
            /* scroll to right */
            if(ha->value < ha->upper - ha->page_size)
            {
                ha->value += ha->step_increment;
                if(ha->value > ha->upper - ha->page_size)
                    ha->value = ha->upper - ha->page_size;
            }
        }
        gtk_adjustment_value_changed(ha);
    }
    return TRUE;
}
示例#2
0
/*
 * The following is assumed:
 *   (hadj && vadj) || (!hadj && !vadj)
 */
void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj, bool resetValues)
{
    ASSERT(!hadj == !vadj);

    m_horizontalAdjustment = hadj;
    m_verticalAdjustment = vadj;

    // Reset the adjustments to a sane default
    if (m_horizontalAdjustment) {
        ScrollbarGtk* hScrollbar = reinterpret_cast<ScrollbarGtk*>(horizontalScrollbar());
        if (hScrollbar)
            hScrollbar->attachAdjustment(m_horizontalAdjustment);

        ScrollbarGtk* vScrollbar = reinterpret_cast<ScrollbarGtk*>(verticalScrollbar());
        if (vScrollbar)
            vScrollbar->attachAdjustment(m_verticalAdjustment);

        // We used to reset everything to 0 here, but when page cache
        // is enabled we reuse FrameViews that are cached. Since their
        // size is not going to change when being restored, (which is
        // what would cause the upper limit in the adjusments to be
        // set in the normal case), we make sure they are up-to-date
        // here. This is needed for the parent scrolling widget to be
        // able to report correct values.
        m_horizontalAdjustment->lower = 0;
        m_horizontalAdjustment->upper = resetValues ? 0 : frameRect().width();
        m_horizontalAdjustment->value = resetValues ? 0 : scrollOffset().width();
        gtk_adjustment_changed(m_horizontalAdjustment);
        gtk_adjustment_value_changed(m_horizontalAdjustment);

        m_verticalAdjustment->lower = 0;
        m_verticalAdjustment->upper = resetValues ? 0 : frameRect().height();
        m_verticalAdjustment->value = resetValues ? 0 : scrollOffset().height();
        gtk_adjustment_changed(m_verticalAdjustment);
        gtk_adjustment_value_changed(m_verticalAdjustment);
    } else {
        ScrollbarGtk* hScrollbar = reinterpret_cast<ScrollbarGtk*>(horizontalScrollbar());
        if (hScrollbar)
            hScrollbar->detachAdjustment();

        ScrollbarGtk* vScrollbar = reinterpret_cast<ScrollbarGtk*>(verticalScrollbar());
        if (vScrollbar)
            vScrollbar->detachAdjustment();
    }

    /* reconsider having a scrollbar */
    setHasVerticalScrollbar(false);
    setHasHorizontalScrollbar(false);
}
示例#3
0
static gboolean
eog_thumb_nav_scroll_step (gpointer user_data)
{
  EogThumbNav *nav = EOG_THUMB_NAV (user_data);
  gint         delta;
  gdouble      value, upper, page_size;

  if (nav->priv->scroll_pos < 10)
    delta = EOG_THUMB_NAV_SCROLL_INC;
  else if (nav->priv->scroll_pos < 20)
    delta = EOG_THUMB_NAV_SCROLL_INC * 2;
  else if (nav->priv->scroll_pos < 30)
    delta = EOG_THUMB_NAV_SCROLL_INC * 2 + 5;
  else
    delta = EOG_THUMB_NAV_SCROLL_INC * 2 + 12;

  if (!nav->priv->scroll_dir)
    delta *= -1;

  g_object_get (nav->priv->adj,
                "value", &value,
                "upper", &upper,
                "page_size", &page_size,
                NULL);

  if ((gint) (value + (gdouble) delta) >= 0 &&
      (gint) (value + (gdouble) delta) <= upper - page_size)
  {
    gtk_adjustment_set_value (nav->priv->adj, value + (gdouble) delta);
    nav->priv->scroll_pos++;
    gtk_adjustment_value_changed (nav->priv->adj);
  }
  else
  {
    if (delta > 0)
      gtk_adjustment_set_value (nav->priv->adj, upper - page_size);
    else
      gtk_adjustment_set_value (nav->priv->adj, 0);

    nav->priv->scroll_pos = 0;

    gtk_adjustment_value_changed (nav->priv->adj);

    return G_SOURCE_REMOVE;
  }

  return G_SOURCE_CONTINUE;
}
示例#4
0
文件: module.c 项目: chan18/ljedit
static gboolean on_scroll_event(GtkWidget *widget, GdkEventScroll *event, PussVConsole* self) {
	gdouble y_new = self->adjust->value;
	switch( event->direction ) {
	case GDK_SCROLL_UP:
		y_new -= 3;
		if( y_new < self->adjust->lower )
			y_new = self->adjust->lower;
		break;
	case GDK_SCROLL_DOWN:
		y_new += 3;
		if( y_new > self->adjust->upper )
			y_new = self->adjust->upper;
		break;
	case GDK_SCROLL_LEFT:
	case GDK_SCROLL_RIGHT:
		break;
	}

	if( y_new != self->adjust->value ) {
		self->adjust->value = y_new;
		gtk_adjustment_value_changed(self->adjust);
	}

	return TRUE;
}
static void
set_width(GtkWidget *item, gpointer bp)
{
    int widthtype;
    gboolean t;

    ENTER;

    widthtype = gtk_combo_box_get_active(GTK_COMBO_BOX(item)) + 1;
    DBG("widthtype=%d\n", widthtype);
    t = (widthtype != WIDTH_REQUEST);
    gtk_widget_set_sensitive(width_spinb, t);
    if (widthtype == WIDTH_PERCENT) {
        width_adj->upper = 100;
        width_adj->value = width_adj->upper;
    } else if  (widthtype == WIDTH_PIXEL) {
        width_adj->upper = gdk_screen_width();
        width_adj->value = width_adj->upper;
    } else
        RET();

    gtk_adjustment_changed(width_adj);
    gtk_adjustment_value_changed(width_adj);

    RET();
}
示例#6
0
void
patch_edit_update_editors(void)
{
    int i;
    char name[21];

    /* update all the adjustments */
    for (i = 0; i < DX7_VOICE_PARAMETERS - 1 /* omitting name */; i++) {
        GTK_ADJUSTMENT(edit_adj[i])->value = (float)edit_buffer.voice[i];
        /* temporarily block signal to model, then update adjustment */
        g_signal_handlers_block_by_func(G_OBJECT(edit_adj[i]), patch_edit_on_edit_adj_changed,
                                        (gpointer)i);
        gtk_adjustment_value_changed(GTK_ADJUSTMENT(edit_adj[i]));
        g_signal_handlers_unblock_by_func(G_OBJECT(edit_adj[i]), patch_edit_on_edit_adj_changed,
                                          (gpointer)i);
    }
    /* update name entry */
    patch_edit_copy_name_to_utf8(name, edit_buffer.voice, FALSE);
    /* temporarily block signal to model, then update entry text */
    g_signal_handlers_block_by_func(G_OBJECT(editor_name_entry), patch_edit_on_name_entry_changed,
                                    NULL);
    gtk_entry_set_text(GTK_ENTRY(editor_name_entry), name);
    g_signal_handlers_unblock_by_func(G_OBJECT(editor_name_entry), patch_edit_on_name_entry_changed,
                                      NULL);

    patch_edit_update_status();
}
示例#7
0
void
dma_sparse_view_goto (DmaSparseView *view, guint location)
{
	dma_sparse_iter_move_at (&view->priv->start, location);
	gtk_adjustment_set_value (view->priv->vadjustment, (gdouble)location);
	gtk_adjustment_value_changed (view->priv->vadjustment);
}
示例#8
0
文件: pointsel.c 项目: Venkattk/vpp
static void recompute_ps_vscrollbar (void)
{
    GtkAdjustment *adj;
    ulong limit;

    adj = GTK_ADJUSTMENT(s_ps_vsadj);

#ifdef NOTDEF
    /* This seems like the right calculation, but seems not to work */
    if (g_neventdefs > c_maxpointsel)
        limit = g_neventdefs - c_maxpointsel;
    else
        limit = g_neventdefs;
#else
    limit = g_neventdefs-1;
#endif

    adj->lower = (gfloat)0.00;
    adj->upper = (gfloat)limit;
    adj->value = (gfloat)0.00;
    adj->step_increment = (gfloat)1.00;
    adj->page_increment = (gfloat)(c_maxpointsel / 3);
    adj->page_size = (gfloat)c_maxpointsel;
    gtk_adjustment_changed(adj);
    gtk_adjustment_value_changed(adj);
    gtk_widget_show(s_ps_vscroll);
}
示例#9
0
void gui_logfunction(int log_level, const char* str)
{
  GtkTextIter iter;
  GtkAdjustment* adj;
  const char* tag;

  if (!TEXT_BUFFER) 
    return;

  switch (log_level) {
    case LOG_INFO:    tag = "green_text";
		      break;
    case LOG_DEBUG:   tag = "green_text";
		      break;
    case LOG_WARNING: tag = "purple_text";
		      break;
    case LOG_ERROR:   tag = "red_text";
		      break;
  }

  gtk_text_buffer_get_iter_at_offset (TEXT_BUFFER,&iter,-1);
  gtk_text_buffer_insert_with_tags_by_name(TEXT_BUFFER,&iter,str,-1,tag,NULL);
  if (SCROLL_TEXT)
  {
    adj = gtk_scrolled_window_get_vadjustment(SCROLL_TEXT);
    adj -> value = adj -> upper;
    gtk_adjustment_value_changed(adj);
  }
}
示例#10
0
static gboolean
do_adjustment (gpointer user_data)
{
	int row;
	GtkAdjustment *adj ;
	gfloat value, min_value, max_value;
	EReflow *reflow = user_data;

	row = reflow->cursor_row;
	if (row == -1)
		return FALSE;

	adj = gtk_layout_get_hadjustment (GTK_LAYOUT (GNOME_CANVAS_ITEM (reflow)->canvas));
	value = adj->value;

	if ((!reflow->items) || (!reflow->items[row]))
		return TRUE;
	min_value = reflow->items[row]->x2 - adj->page_size;
	max_value = reflow->items[row]->x1;

	if (value < min_value)
		value = min_value;

	if (value > max_value)
		value = max_value;

	if (value != adj->value) {
		adj->value = value;
		gtk_adjustment_value_changed (adj);
	}

	reflow->do_adjustment_idle_id = 0;

	return FALSE;
}
示例#11
0
文件: gtklayout.c 项目: Aridna/gtk2
static void
gtk_layout_set_adjustment_upper (GtkAdjustment *adj,
				 gdouble        upper,
				 gboolean       always_emit_changed)
{
  gboolean changed = FALSE;
  gboolean value_changed = FALSE;
  
  gdouble min = MAX (0., upper - adj->page_size);

  if (upper != adj->upper)
    {
      adj->upper = upper;
      changed = TRUE;
    }
      
  if (adj->value > min)
    {
      adj->value = min;
      value_changed = TRUE;
    }
  
  if (changed || always_emit_changed)
    gtk_adjustment_changed (adj);
  if (value_changed)
    gtk_adjustment_value_changed (adj);
}
示例#12
0
/* center the view to a place */
void center_map(struct mapwin *mw,double longsec, double lattsec)
{

  double x,y;
  geosec2point(&x,&y,(double)longsec,(double)lattsec);
  x=x-mw->page_width/2;
  y=y-mw->page_height/2;
  x=floor(x);
  y=floor(y);
  if ((x != GTK_ADJUSTMENT(mw->hadj)->value) ||
      (y != GTK_ADJUSTMENT(mw->vadj)->value)) {
    GTK_ADJUSTMENT(mw->hadj)->value=x;
    GTK_ADJUSTMENT(mw->vadj)->value=y;
    gtk_adjustment_value_changed(GTK_ADJUSTMENT(mw->hadj));
    gtk_adjustment_value_changed(GTK_ADJUSTMENT(mw->vadj));
  }
}
示例#13
0
void SetScrollPos_(GtkWidget *scr, int pos, int max)
{
  GTK_ADJUSTMENT(GTK_RANGE(scr)->adjustment)->lower = 0;
  GTK_ADJUSTMENT(GTK_RANGE(scr)->adjustment)->upper = max+1;
  GTK_ADJUSTMENT(GTK_RANGE(scr)->adjustment)->value = pos;
  GTK_ADJUSTMENT(GTK_RANGE(scr)->adjustment)->page_size = 1;

  gtk_adjustment_value_changed(GTK_ADJUSTMENT(GTK_RANGE(scr)->adjustment));
}
示例#14
0
int
clip_GTK_ADJUSTMENTVALUECHANGED(ClipMachine * cm)
{
	C_widget *cadj = _fetch_cw_arg(cm);
	CHECKCWID(cadj,GTK_IS_ADJUSTMENT);
	gtk_adjustment_value_changed(GTK_ADJUSTMENT(cadj->widget));
	return 0;
err:
	return 1;
}
示例#15
0
static gboolean
eog_thumb_nav_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
{
  EogThumbNav *nav = EOG_THUMB_NAV (user_data);
  gint         inc = EOG_THUMB_NAV_SCROLL_INC * 3;
  gdouble      value, upper, page_size, delta_x, delta_y;
  gboolean smooth;

  nav->priv->adj = nav->priv->vertical ? nav->priv->vadj : nav->priv->hadj;

  switch (event->direction)
  {
#if GTK_CHECK_VERSION (3, 3, 18)
    /* Handle smooth scroll events from mouse wheels, bug 672311. */
    case GDK_SCROLL_SMOOTH:
      smooth = gdk_event_get_scroll_deltas ((const GdkEvent *) event,
                                            &delta_x, &delta_y);
      /* Pass through non-mouse wheel events. */
      if (G_UNLIKELY (!smooth) || delta_x != 0.0 || fabs (delta_y) != 1.0)
        return FALSE;

      inc *= (gint) delta_y;
      break;
#endif
    case GDK_SCROLL_UP:
    case GDK_SCROLL_LEFT:
      inc *= -1;
      break;

    case GDK_SCROLL_DOWN:
    case GDK_SCROLL_RIGHT:
      break;

    default:
      g_assert_not_reached ();
      return FALSE;
  }

  value = gtk_adjustment_get_value (nav->priv->adj);
  if (inc < 0)
    gtk_adjustment_set_value (nav->priv->adj, MAX (0, value + inc));
  else
  {
    upper     = gtk_adjustment_get_upper (nav->priv->adj);
    page_size = gtk_adjustment_get_page_size (nav->priv->adj);
    gtk_adjustment_set_value (nav->priv->adj, MIN (upper - page_size, value + inc));
  }

  gtk_adjustment_value_changed (nav->priv->adj);

  return TRUE;
}
示例#16
0
文件: tslider.c 项目: DINKIN/nip2
/* from/to/value have changed ... update the widgets.
 */
static void
tslider_real_changed( Tslider *tslider )
{
	GtkAdjustment *adj = tslider->adj;
	GtkWidget *entry = tslider->entry;

#ifdef DEBUG
	printf( "tslider_real_changed: %p, val = %g\n", 
		tslider, tslider->value );
#endif /*DEBUG*/

	if( tslider->auto_link ) 
		tslider->svalue = tslider_value_to_slider( tslider, 
			tslider->value );

	gtk_signal_handler_block_by_data( GTK_OBJECT( adj ), tslider );
	gtk_signal_handler_block_by_data( GTK_OBJECT( entry ), tslider );

	/* Some libc's hate out-of-bounds precision, so clip, just in case.
	 */
	set_gentry( tslider->entry, "%.*f", 
		IM_CLIP( 0, tslider->digits, 100 ), tslider->value );
	gtk_scale_set_digits( GTK_SCALE( tslider->slider ), tslider->digits );

	if( !DEQ( tslider->from, tslider->last_from ) || 
		!DEQ( tslider->to, tslider->last_to ) ) {
		double range = tslider->to - tslider->from;

		adj->step_increment = range / 100;
		adj->page_increment = range / 10;
		adj->page_size = range / 10;

		adj->lower = tslider->from;
		adj->upper = tslider->to + adj->page_size;

		tslider->last_to = tslider->to;
		tslider->last_from = tslider->from;

		gtk_adjustment_changed( adj );
	}

	if( !DEQ( tslider->svalue, tslider->last_svalue ) ) {
		adj->value = tslider->svalue;
		tslider->last_svalue = tslider->svalue;

		gtk_adjustment_value_changed( adj );
	}

	gtk_signal_handler_unblock_by_data( GTK_OBJECT( adj ), tslider );
	gtk_signal_handler_unblock_by_data( GTK_OBJECT( entry ), tslider );
}
示例#17
0
GtkWidget *
make_font_selector (void)
{
  GtkWidget *hbox;
  GtkWidget *util_hbox;
  GtkWidget *label;
  GtkWidget *option_menu;
  GtkWidget *spin_button;
  GtkAdjustment *adj;
  
  hbox = gtk_hbox_new (FALSE, 4);
  
  util_hbox = gtk_hbox_new (FALSE, 2);
  label = gtk_label_new ("Family:");
  gtk_box_pack_start (GTK_BOX (util_hbox), label, FALSE, FALSE, 0);
  option_menu = make_families_menu ();
  gtk_box_pack_start (GTK_BOX (util_hbox), option_menu, FALSE, FALSE, 0);
  
  gtk_box_pack_start (GTK_BOX (hbox), util_hbox, FALSE, FALSE, 0);

  util_hbox = gtk_hbox_new (FALSE, 2);
  label = gtk_label_new ("Style:");
  gtk_box_pack_start (GTK_BOX (util_hbox), label, FALSE, FALSE, 0);
  option_menu = make_styles_combo ();
  gtk_box_pack_start (GTK_BOX (util_hbox), option_menu, FALSE, FALSE, 0);
  
  gtk_box_pack_start (GTK_BOX (hbox), util_hbox, FALSE, FALSE, 0);

  util_hbox = gtk_hbox_new (FALSE, 2);
  label = gtk_label_new ("Size:");
  gtk_box_pack_start (GTK_BOX (util_hbox), label, FALSE, FALSE, 0);
  spin_button = gtk_spin_button_new (NULL, 1., 0);
  gtk_box_pack_start (GTK_BOX (util_hbox), spin_button, FALSE, FALSE, 0);

  gtk_box_pack_start (GTK_BOX (hbox), util_hbox, FALSE, FALSE, 0);

  adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin_button));
  adj->value = PANGO_PIXELS (pango_font_description_get_size(font_description));
  adj->lower = 0;
  adj->upper = 1024;
  adj->step_increment = 1;
  adj->page_size = 10;
  gtk_adjustment_changed (adj);
  gtk_adjustment_value_changed (adj);

  gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
		      GTK_SIGNAL_FUNC (font_size_changed), NULL);
  
  return hbox;
}
示例#18
0
文件: utils_gui.c 项目: rosedu/osmo
void
utl_gui_sw_vscrollbar_move_position (GtkWidget *scrolled_window, gint direction) {

GtkAdjustment *adj;

    adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW(scrolled_window));

    if (direction == SW_MOVE_UP) {

        if (adj->value > 0.0) {
            adj->value -= adj->step_increment;
            adj->value = adj->value < 0.0 ? 0.0 : adj->value;
            gtk_adjustment_value_changed (GTK_ADJUSTMENT(adj));
        }

    } else if (direction == SW_MOVE_DOWN) {

        if (adj->value+adj->page_size < adj->upper) {
            adj->value += adj->step_increment;
            gtk_adjustment_value_changed (GTK_ADJUSTMENT(adj));
        }
    }
}
示例#19
0
static int gtkCanvasSetDYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double ymin, ymax, liney;
    float dy;
    int value_changed;
    GtkAdjustment* sb_vert = gtk_scrolled_window_get_vadjustment(gtkCanvasGetScrolledWindow(ih));
    if (!sb_vert) return 1;

    if (!iupStrToFloat(value, &dy))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");

    if (!iupAttribGet(ih,"LINEY"))
    {
      liney = dy/10;
      if (liney==0)
        liney = 1;
    }
    else
      liney = iupAttribGetFloat(ih,"LINEY");

#if GTK_CHECK_VERSION(2, 14, 0)
    {
      double page_size = dy;
      double dvalue = gtk_adjustment_get_value(sb_vert);
      value_changed = gtkCanvasCheckScroll(ymin, ymax, &page_size, &dvalue);
      gtk_adjustment_configure(sb_vert, dvalue, ymin, ymax, liney, page_size, dy);
    }
#else
    sb_vert->lower = ymin;
    sb_vert->upper = ymax;
    sb_vert->step_increment = liney;
    sb_vert->page_size = dy;

    value_changed = gtkCanvasCheckScroll(ymin, ymax, &sb_vert->page_size, &sb_vert->value);
    sb_vert->page_increment = sb_vert->page_size;

    gtk_adjustment_changed(sb_vert);
#endif

    if (value_changed)
      gtk_adjustment_value_changed(sb_vert);
  }
  return 1;
}
示例#20
0
static int gtkCanvasSetDXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double xmin, xmax, linex;
    float dx;
    int value_changed;
    GtkAdjustment* sb_horiz = gtk_scrolled_window_get_hadjustment(gtkCanvasGetScrolledWindow(ih));
    if (!sb_horiz) return 1;

    if (!iupStrToFloat(value, &dx))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");

    if (!iupAttribGet(ih,"LINEX"))
    {
      linex = dx/10;
      if (linex==0)
        linex = 1;
    }
    else
      linex = iupAttribGetFloat(ih,"LINEX");

#if GTK_CHECK_VERSION(2, 14, 0)
    {
      double page_size = dx;
      double dvalue = gtk_adjustment_get_value(sb_horiz);
      value_changed = gtkCanvasCheckScroll(xmin, xmax, &page_size, &dvalue);
      gtk_adjustment_configure(sb_horiz, dvalue, xmin, xmax, linex, page_size, dx);
    }
#else
    sb_horiz->lower = xmin;
    sb_horiz->upper = xmax;
    sb_horiz->step_increment = linex;
    sb_horiz->page_size = dx;

    value_changed = gtkCanvasCheckScroll(xmin, xmax, &sb_horiz->page_size, &sb_horiz->value);
    sb_horiz->page_increment = sb_horiz->page_size;

    gtk_adjustment_changed(sb_horiz);
#endif

    if (value_changed)
      gtk_adjustment_value_changed(sb_horiz);
  }
  return 1;
}
示例#21
0
static gint
gam_slider_pan_pan_event_cb (GtkWidget *widget, GdkEvent *event, GamSliderPan *gam_slider_pan)
{
    GamSliderPanPrivate *priv;

    priv = GAM_SLIDER_PAN_GET_PRIVATE (gam_slider_pan);

    if (event->type == GDK_2BUTTON_PRESS) {
        gtk_adjustment_set_value (GTK_ADJUSTMENT (priv->pan_adjustment), 0.0);
        gtk_adjustment_value_changed (GTK_ADJUSTMENT (priv->pan_adjustment));

        return TRUE;
    }

    return FALSE;
}
示例#22
0
void channel_changed(void)
{
    scope_vert_t *vert;
    scope_chan_t *chan;
    GtkAdjustment *adj;
    gchar *name;
    gchar buf1[BUFLEN + 1], buf2[BUFLEN + 1];

    vert = &(ctrl_usr->vert);
    if ((vert->selected < 1) || (vert->selected > 16)) {
	gtk_label_set_text_if(vert->scale_label, "----");
	gtk_label_set_text_if(vert->chan_num_label, "--");
	gtk_label_set_text_if(vert->source_name_label, "------");
	request_display_refresh(1);
	return;
    }
    chan = &(ctrl_usr->chan[vert->selected - 1]);
    /* set position slider based on new channel */
    gtk_adjustment_set_value(GTK_ADJUSTMENT(vert->pos_adj),
	chan->position * VERT_POS_RESOLUTION);
    /* set scale slider based on new channel */
    adj = GTK_ADJUSTMENT(vert->scale_adj);
    adj->lower = chan->min_index;
    adj->upper = chan->max_index;
    adj->value = chan->scale_index;
    gtk_adjustment_changed(adj);
    gtk_adjustment_value_changed(adj);
    /* update the channel number and name display */
    snprintf(buf1, BUFLEN, "%2d", vert->selected);
    name = chan->name;
    gtk_label_set_text_if(vert->chan_num_label, buf1);
    gtk_label_set_text_if(vert->source_name_label, name);
    /* update the offset display */
    if (chan->data_type == HAL_BIT) {
	snprintf(buf1, BUFLEN, "----");
    } else {
        if(chan->ac_offset) {
            snprintf(buf1, BUFLEN, "(AC)");
        } else {
            format_signal_value(buf1, BUFLEN, chan->vert_offset);
        }
    }
    snprintf(buf2, BUFLEN, _("Offset\n%s"), buf1);
    gtk_label_set_text_if(vert->offset_label, buf2);
    request_display_refresh(1);
}
示例#23
0
bool ScrollView::platformHandleVerticalAdjustment(const IntSize& scroll)
{
    if (m_verticalAdjustment) {
        m_verticalAdjustment->page_size = visibleHeight();
        m_verticalAdjustment->step_increment = cScrollbarPixelsPerLineStep;
        m_verticalAdjustment->page_increment = visibleHeight() - cAmountToKeepWhenPaging;
        m_verticalAdjustment->lower = 0;
        m_verticalAdjustment->upper = contentsHeight();
        gtk_adjustment_changed(m_verticalAdjustment);

        if (m_verticalAdjustment->value != scroll.height()) {
            m_verticalAdjustment->value = scroll.height();
            gtk_adjustment_value_changed(m_verticalAdjustment);
        }
        return true;
    } 
    return false;
}
示例#24
0
/* The standard gtk_adjustment_set_value ignores page size, which
 * disagrees with the logic used by scroll bars, for example.
 */
void
eel_gtk_adjustment_set_value (GtkAdjustment *adjustment,
                              float value)
{
    float upper_page_start, clamped_value;

    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

    upper_page_start = MAX (gtk_adjustment_get_upper (adjustment) -
                            gtk_adjustment_get_page_size (adjustment),
                            gtk_adjustment_get_lower (adjustment));
    clamped_value = CLAMP (value, gtk_adjustment_get_lower (adjustment), upper_page_start);
    if (clamped_value != gtk_adjustment_get_value (adjustment))
    {
        gtk_adjustment_set_value (adjustment, clamped_value);
        gtk_adjustment_value_changed (adjustment);
    }
}
示例#25
0
bool ScrollView::platformHandleVerticalAdjustment(const IntSize& scroll)
{
    if (m_verticalAdjustment) {
        m_verticalAdjustment->page_size = visibleHeight();
        m_verticalAdjustment->step_increment = visibleHeight() / 10.0;
        m_verticalAdjustment->page_increment = visibleHeight() * 0.9;
        m_verticalAdjustment->lower = 0;
        m_verticalAdjustment->upper = contentsHeight();
        gtk_adjustment_changed(m_verticalAdjustment);

        if (m_scrollOffset.height() != scroll.height()) {
            m_verticalAdjustment->value = scroll.height();
            gtk_adjustment_value_changed(m_verticalAdjustment);
        }
        return true;
    } 
    return false;
}
示例#26
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkAdjustment_gtk_1adjustment_1value_1changed
(
    JNIEnv* env,
    jclass cls,
    jlong _self
)
{
    GtkAdjustment* self;

    // convert parameter self
    self = (GtkAdjustment*) _self;

    // call function
    gtk_adjustment_value_changed(self);

    // cleanup parameter self
}
示例#27
0
void wxScrollBar::SetThumbPosition( int viewStart )
{
    if (GetThumbPosition() != viewStart)
    {
        GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
        const int i = (GtkRange*)m_widget == m_scrollBar[1];
        const int max = int(adj->upper - adj->page_size);
        if (viewStart > max)
            viewStart = max;
        if (viewStart < 0)
            viewStart = 0;

        m_scrollPos[i] =
        adj->value = viewStart;
        // If a "value_changed" signal emission is not already in progress
        if (!m_blockValueChanged[i])
        {
            gtk_adjustment_value_changed(adj);
        }
    }
}
示例#28
0
static void
gimp_text_style_editor_set_kerning (GimpTextStyleEditor *editor,
                                    GtkTextTag          *kerning_tag)
{
  gint kerning = 0;

  if (kerning_tag)
    kerning = gimp_text_tag_get_kerning (kerning_tag);

  g_signal_handlers_block_by_func (editor->kerning_adjustment,
                                   gimp_text_style_editor_kerning_changed,
                                   editor);

  gtk_adjustment_set_value (editor->kerning_adjustment,
                            (gdouble) kerning / PANGO_SCALE);
  /* make sure the "" really gets replaced */
  gtk_adjustment_value_changed (editor->kerning_adjustment);

  g_signal_handlers_unblock_by_func (editor->kerning_adjustment,
                                     gimp_text_style_editor_kerning_changed,
                                     editor);
}
示例#29
0
static void
gimp_text_style_editor_set_baseline (GimpTextStyleEditor *editor,
                                     GtkTextTag          *baseline_tag)
{
  gint baseline = 0;

  if (baseline_tag)
    baseline = gimp_text_tag_get_baseline (baseline_tag);

  g_signal_handlers_block_by_func (editor->baseline_adjustment,
                                   gimp_text_style_editor_baseline_changed,
                                   editor);

  gtk_adjustment_set_value (editor->baseline_adjustment,
                            (gdouble) baseline / PANGO_SCALE);
  /* make sure the "" really gets replaced */
  gtk_adjustment_value_changed (editor->baseline_adjustment);

  g_signal_handlers_unblock_by_func (editor->baseline_adjustment,
                                     gimp_text_style_editor_baseline_changed,
                                     editor);
}
示例#30
0
文件: scrolbar.cpp 项目: EdgarTx/wx
void wxScrollBar::SetThumbPosition( int viewStart )
{
    if (GetThumbPosition() != viewStart)
    {
        GtkAdjustment* adj = ((GtkRange*)m_widget)->adjustment;
        const int i = (GtkRange*)m_widget == m_scrollBar[1];
        const int max = int(adj->upper - adj->page_size);
        if (viewStart > max)
            viewStart = max;
        if (viewStart < 0)
            viewStart = 0;

        m_scrollPos[i] =
        adj->value = viewStart;
        
        g_signal_handlers_disconnect_by_func( m_widget,
                              (gpointer)gtk_value_changed, this);

        gtk_adjustment_value_changed(adj);
        
        g_signal_connect_after(m_widget, "value_changed",
                     G_CALLBACK(gtk_value_changed), this);
    }
}