Class: Iup::Val
Overview
An interactive control allowing the user to select a value within a limited range.
Example
The following sets up a vertical control with a range from 0 to 10. As the slider is moved, a label’s title is updated to the current value.
Iup::Val.new('vertical') do |v|
t.max = 10
v.valuechanged_cb = ->{
label.title = "VALUE=#{"%0.2f" % v.value}"
Iup::DEFAULT
}
end
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#button_press_cb=(callback) ⇒ Object
–.
-
#button_release_cb=(callback) ⇒ Object
–.
-
#canfocus ⇒ Object
:attr: canfocus Enables the control to gain focus.
-
#expand ⇒ Object
:attr: expand Allows button to fill available space in indicated direction.
-
#initialize(orientation = 'horizontal') {|_self| ... } ⇒ Val
constructor
Creates an instance of the control.
-
#inverted ⇒ Object
:attr: inverted If set, places maximum value on opposite side: values ‘yes’ / ‘no’.
-
#max ⇒ Object
:attr: max Maximum value, defaults to 1.
-
#min ⇒ Object
:attr: min Minimum value, defaults to 0.
-
#mousemove_cb=(callback) ⇒ Object
–.
-
#orientation ⇒ Object
:attr: orientation Orientation of control: ‘horizontal’ / ‘vertical’.
-
#pagestep ⇒ Object
:attr: pagestep Proportion of increment for pageup / pagedown.
-
#position ⇒ Object
:attr_reader: position Returns position in pixels within client window as “x,y”.
-
#rastersize ⇒ Object
:attr: rastersize Size of the control, in pixels, value as “widthxheight”.
-
#screenposition ⇒ Object
:attr_reader: screenposition Returns position in pixels on screen as “x,y”.
-
#step ⇒ Object
:attr: step Proportion of increment for up / down.
-
#value ⇒ Object
:attr: value Returns the current value of the control.
-
#valuechanged_cb=(callback) ⇒ Object
–.
Methods inherited from Widget
#active, #assign_handle, #bgcolor, #destroy, #enterwindow_cb=, #fgcolor, #font, #getfocus_cb=, #help_cb=, #k_any=, #killfocus_cb=, #leavewindow_cb=, #map_cb=, #maxsize, #minsize, #open_controls, #size, #unmap_cb=, #visible, #wid, #zorder
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_reader, #define_id_writer, #define_property_attribute, #define_property_reader, #define_property_writer, #define_reader, #define_writer
Methods included from CallbackSetter
Constructor Details
#initialize(orientation = 'horizontal') {|_self| ... } ⇒ Val
Creates an instance of the control. If a block is given, the new instance is yielded to it.
-
orientation- ‘horizontal’ / ‘vertical’
24 25 26 27 28 29 |
# File 'lib/wrapped/val.rb', line 24 def initialize(orientation='horizontal') @handle = IupLib.IupVal(orientation) # run any provided block on instance, to set up further attributes yield self if block_given? end |
Instance Method Details
#button_press_cb=(callback) ⇒ Object
–
104 105 106 107 108 109 110 111 112 |
# File 'lib/wrapped/val.rb', line 104 def callback unless callback.arity.zero? raise ArgumentError, 'button_press_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'BUTTON_PRESS_CB', :plain end |
#button_release_cb=(callback) ⇒ Object
–
120 121 122 123 124 125 126 127 128 |
# File 'lib/wrapped/val.rb', line 120 def callback unless callback.arity.zero? raise ArgumentError, 'button_release_cb callback must take 0 arguments' end cb = Proc.new do |ih, a| callback.call end define_callback cb, 'BUTTON_RELEASE_CB', :plain end |
#canfocus ⇒ Object
:attr: canfocus Enables the control to gain focus. Values ‘yes’ / ‘no’.
36 |
# File 'lib/wrapped/val.rb', line 36 define_attribute :canfocus |
#expand ⇒ Object
:attr: expand Allows button to fill available space in indicated direction. Values ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’.
42 |
# File 'lib/wrapped/val.rb', line 42 define_attribute :expand |
#inverted ⇒ Object
:attr: inverted If set, places maximum value on opposite side: values ‘yes’ / ‘no’.
47 |
# File 'lib/wrapped/val.rb', line 47 define_attribute :inverted |
#max ⇒ Object
:attr: max Maximum value, defaults to 1.
52 |
# File 'lib/wrapped/val.rb', line 52 define_attribute :max |
#min ⇒ Object
:attr: min Minimum value, defaults to 0.
57 |
# File 'lib/wrapped/val.rb', line 57 define_attribute :min |
#mousemove_cb=(callback) ⇒ Object
–
136 137 138 139 140 141 142 143 144 |
# File 'lib/wrapped/val.rb', line 136 def mousemove_cb= callback unless callback.arity.zero? raise ArgumentError, 'mousemove_cb callback must take 0 arguments' end cb = Proc.new do |ih, a| callback.call end define_callback cb, 'MOUSEMOVE_CB', :plain end |
#orientation ⇒ Object
:attr: orientation Orientation of control: ‘horizontal’ / ‘vertical’
62 |
# File 'lib/wrapped/val.rb', line 62 define_attribute :orientation |
#pagestep ⇒ Object
:attr: pagestep Proportion of increment for pageup / pagedown. Value between 0.0 and 1.0, default is 0.1.
68 |
# File 'lib/wrapped/val.rb', line 68 define_attribute :pagestep |
#position ⇒ Object
:attr_reader: position Returns position in pixels within client window as “x,y”.
73 |
# File 'lib/wrapped/val.rb', line 73 define_reader :position |
#rastersize ⇒ Object
:attr: rastersize Size of the control, in pixels, value as “widthxheight”.
78 |
# File 'lib/wrapped/val.rb', line 78 define_attribute :rastersize |
#screenposition ⇒ Object
:attr_reader: screenposition Returns position in pixels on screen as “x,y”.
83 |
# File 'lib/wrapped/val.rb', line 83 define_reader :screenposition |
#step ⇒ Object
:attr: step Proportion of increment for up / down. Value between 0.0 and 1.0, default is 0.01.
89 |
# File 'lib/wrapped/val.rb', line 89 define_attribute :step |
#value ⇒ Object
:attr: value Returns the current value of the control.
94 |
# File 'lib/wrapped/val.rb', line 94 define_attribute :value |
#valuechanged_cb=(callback) ⇒ Object
–
152 153 154 155 156 157 158 159 160 |
# File 'lib/wrapped/val.rb', line 152 def valuechanged_cb= callback unless callback.arity.zero? raise ArgumentError, 'valuechanged_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'VALUECHANGED_CB', :plain end |