eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
1a05542005-07-28Martin Nilsson class GTK2.SpinButton; inherit GTK2.Entry;
99456a2006-02-02Lance Dillon inherit GTK2.CellEditable; inherit GTK2.Editable;
1a05542005-07-28Martin Nilsson  //! The Spin Button widget is generally used to allow the user to //! select a value from a range of numeric values. It consists of a //! text entry box with up and down arrow buttons attached to the //! side. Selecting one of the buttons causes the value to "spin" up //! and down the range of possible values. The entry box may also be //! edited directly to enter a specific value. //! <p> //! The Spin Button allows the value to have zero or a number of //! decimal places and to be incremented/decremented in configurable //! steps. The action of holding down one of the buttons optionally //! results in an acceleration of change in the value according to how //! long it is depressed. //! </p><p> //! The Spin Button uses an W(Adjustment) object to hold information about //! the range of values that the spin button can take. //! </p><p> //! The attributes of an W(Adjustment) are used by the Spin Button in the //! following way: //! <ul><li>value: initial value for the Spin Button</li> //! <li>lower: lower range value</li> //! <li>upper: upper range value</li> //! <li>step_increment: value to increment/decrement when pressing mouse button 1 on a button</li> //! <li>page_increment: value to increment/decrement when pressing mouse button 2 on a button</li> //! <li>page_size: unused</li> //! </ul> //! </p><p> //! The argument order for the W(Adjustment) constructor is:<br /> //! value, lower, upper, step_increment, page_increment, page_size<br /> //!
27a6df2006-01-05Marcus Comstedt //! IMG: GTK2.SpinButton(GTK2.Adjustment(),0.1, 1 )->set_size_request(60,20)
1a05542005-07-28Martin Nilsson //! </p> //! Properties: //! GTK2.Adjustment adjustment //! float climb-rate //! int digits //! int numeric //! int snap-to-ticks //! int update-policy //! float value //! int wrap //! <p> //! Style properties: //! int shadow-type signal change_value; signal input; signal output; signal value_changed;
3d76632005-11-03Lance Dillon void create(GTK2.Adjustment|float|mapping(string:mixed) range_or_min_or_props,
1a05542005-07-28Martin Nilsson  float climb_rate_or_max, int|float precision_or_step) //! The climb_rate argument take a value between 0.0 and 1.0 and //! indicates the amount of acceleration that the Spin Button has. The //! digits argument specifies the number of decimal places to which //! the value will be displayed. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_not_inited(); pgtk2_verify_setup();
017b572011-10-28Henrik Grubbström (Grubba)  if (TYPEOF(Pike_sp[-args]) == PIKE_T_FLOAT) {
1a05542005-07-28Martin Nilsson  FLOAT_TYPE min,max,step;
3d76632005-11-03Lance Dillon  GtkWidget *gs;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%f%f%f",&min,&max,&step);
3d76632005-11-03Lance Dillon  gs=gtk_spin_button_new_with_range(min,max,step); THIS->obj=G_OBJECT(gs);
017b572011-10-28Henrik Grubbström (Grubba)  } else if (TYPEOF(Pike_sp[-args]) == PIKE_T_OBJECT) {
1a05542005-07-28Martin Nilsson  struct object *o1; FLOAT_TYPE climb; INT_TYPE prec;
3d76632005-11-03Lance Dillon  GtkWidget *gs;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o%f%i",&o1,&climb,&prec);
3d76632005-11-03Lance Dillon  gs=gtk_spin_button_new(GTK_ADJUSTMENT(get_gobject(o1)),climb,prec); THIS->obj=G_OBJECT(gs); } else { INIT_WITH_PROPS(GTK_TYPE_SPIN_BUTTON);
1a05542005-07-28Martin Nilsson  }
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args); pgtk2__init_this_object();
1a05542005-07-28Martin Nilsson } void configure(GTK2.Adjustment range, float climb_rate, int precision); //! Adjustment (with the lower/upper/increse values), climb_rate and digits void set_adjustment(GTK2.Adjustment range); //! Set a new adjustment.
99456a2006-02-02Lance Dillon +GTK2.Adjustment get_adjustment(); //! Get the adjustment associated with this spinbutton.
1a05542005-07-28Martin Nilsson void set_digits(int precision); //! Set the number of digits to show to the user. void set_increments(float step, float page); //! Sets the step and page increments. This affects how quickly the value //! changes when the arrows are activated. void set_range(float min, float max); //! Sets the minimum and maximum allowable values. int get_value_as_int(); //! The current value of a Spin Button can be retrieved as a int. void set_value(float to); //! Set the value. void set_update_policy(int policy); //! The possible values of policy are either GTK2.UpdateAlways or //! GTK2.UpdateIfValid. //! <p> //! These policies affect the behavior of a Spin Button when parsing //! inserted text and syncing its value with the values of the //! Adjustment. //! </p><p> //! In the case of GTK2.UpdateIfValid the Spin Button value only gets //! changed if the text input is a numeric value that is within the //! range specified by the Adjustment. Otherwise the text is reset //! to the current value. //! </p><p> //! In case of GTK2.UpdateAlways errors are ignored while converting text //! into a numeric value.</p> void set_numeric(int numericp); //! If true, it is a numeric value. This prevents a user from typing //! anything other than numeric values into the text box of a Spin //! Button void spin(int direction, float increment); //! If you want to alter the value of a Spin Value relative to its //! current value, then this function can be used. //! <p> //! The direction paramenter is one of CONST(GTK_SPIN) //! </p><p> //! GTK2.SpinStepForward and GTK2.SpinStepBackward change the value //! of the Spin Button by the amount specified by increment, unless //! increment is equal to 0, in which case the value is changed by the //! value of step_increment in theAdjustment. //! </p><p> //! GTK2.SpinPageForward and GTK2.SpinPageBackward simply alter the //! value of the Spin Button by increment. //! </p><p> //! GTK2.SpinHome sets the value of the Spin Button to the bottom of the //! Adjustments range. //! </p><p> //! GTK2.SpinEnd sets the value of the Spin Button to the top of the //! Adjustments range. //! </p><p> //! GTK2.SpinUserDefined simply alters the value of the Spin Button by //! the specified amount.</p> void set_wrap(int wrapp); //! If true, the spin button will wrap from the lowest to the highest //! value, and the highest to the lowest. void set_snap_to_ticks(int snapp); //! Set the Spin Button to round the value to the nearest //! step_increment, which is set within the Adjustment object used with //! the Spin Button void update(); //! Explicitly request that the Spin Button updates itself int get_digits(); //! Fetches the precision. mapping(string:float) get_increments() //! Gets the current step and page increments. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { gdouble step,page; gtk_spin_button_get_increments(GTK_SPIN_BUTTON(THIS->obj),&step,&page);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("step")); push_float(step); ref_push_string(_STR("page")); push_float(page);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(4); } } int get_numeric(); //! Returns whether non-numeric text can be typed in. mapping(string:float) get_range() //! Gets the range allowed. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { gdouble min,max; gtk_spin_button_get_range(GTK_SPIN_BUTTON(THIS->obj),&min,&max);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("min")); push_float(min); ref_push_string(_STR("max")); push_float(max);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(4); } } int get_snap_to_ticks(); //! Returns whether the value are corrected to the nearest step. int get_update_policy(); //! Gets the update behavior. float get_value(); //! Get the value. int get_wrap(); //! Returns whether the value wraps around to the opposite limit when the //! upper or lower limit of the range is exceeded.
3d76632005-11-03Lance Dillon int get_entry() //! Returns W(Entry) of this widget. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args); push_gobjectclass(GTK_ENTRY(THIS->obj),pgtk2_entry_program);
3d76632005-11-03Lance Dillon }