PROGRAM(adjustment);
// Used to connect as an example a text widget with a scrollbar.
// Example:
// IMG: lambda() {object a;object h = GTK.Hbox(0,0);h->add(GTK.Text(GTK.Adjustment(),(a=GTK.Adjustment()))->show())->add(GTK.Vscrollbar( a )->show());return h;}()
SIGNAL("changed", "The adjustment changed in some way");
SIGNAL("value_changed", "The value changed.");
INHERIT(data);
FUNCTION(create, "function(void|float,void|float,void|float,void|float,void|float,void|float:void)")
NAME_ARGS(value,lower,upper,step_increment,page_increment,page_size);
// Normal operaion: GTK.Adjustment();
// using no arguments gives defaults of 0.0 1.0 0.0 0.01 0.01 1.0.
// If you want to specify all values, they are:
// value, lower, upper, step_increment, page_increment and page_size
// All are floating point values. For most widgets the unit is pixels.
{
  float l=0.0, u=1.0, v=0.0, si=0.01, pi=0.01, ps=1.0;
  if(args == 6 )
    get_all_args("Adjustment", args,"%f%f%f%f%f%f", &l,&u,&v,&si,&pi,&ps);
  else if(args == 3 )   get_all_args("Adjustment", args,"%f%f%d", &l,&u,&v);
  else if(args == 2 )   get_all_args("Adjustment", args,"%f%f", &l,&u);

  if(THIS->obj) error("GTK.Adjustment->create() can only be called once.\n");
  THIS->obj = GTK_OBJECT( gtk_adjustment_new( l, u, v, si, pi, ps ) );
  if(!THIS->obj) 
    error("Failed to initiate adjustment\n");
  pgtk__init_this_object();
  pop_n_elems(args);
  push_int( 0 );
}
COMPLEX_FUNCTION(set_value, float);
NAME_ARGS(to);
// Set the value component.
FUNCTION(get_value, "function(void:float)")
// Get the value component.
{
  pop_n_elems( args );
  push_float( GTK_ADJUSTMENT( THIS->obj )->value );
}
FUNCTION(get_lower, "function(void:float)")
// Get the lower limit.
{
  pop_n_elems( args );
  push_float( GTK_ADJUSTMENT( THIS->obj )->lower );
}
FUNCTION(get_upper, "function(void:float)")
// Get the upper limit.
{
  pop_n_elems( args );
  push_float( GTK_ADJUSTMENT( THIS->obj )->upper );
}
FUNCTION(get_step_increment, "function(void:float)")
// Get the step increment (arrow click)
{
  pop_n_elems( args );
  push_float( GTK_ADJUSTMENT( THIS->obj )->step_increment );
}
FUNCTION(get_page_increment, "function(void:float)")
// Get the page increment (page down or through click)
{
  pop_n_elems( args );
  push_float( GTK_ADJUSTMENT( THIS->obj )->page_increment );
}
FUNCTION(get_page_size, "function(void:float)")
// Get the page size (the actual size of a page)
{
  pop_n_elems( args );
  push_float( GTK_ADJUSTMENT( THIS->obj )->page_size );
}
COMPLEX_FUNCTION(clamp_page, float, float);
