Class: Iup::Val

Inherits:
Widget show all
Defined in:
lib/wrapped/val.rb

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

#handle

Instance Method Summary collapse

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

#define_callback

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’

Yields:

  • (_self)

Yield Parameters:

  • _self (Iup::Val)

    the object that the method was called on



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 button_press_cb= 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 button_release_cb= 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

#canfocusObject

:attr: canfocus Enables the control to gain focus. Values ‘yes’ / ‘no’.



36
# File 'lib/wrapped/val.rb', line 36

define_attribute :canfocus

#expandObject

: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

#invertedObject

:attr: inverted If set, places maximum value on opposite side: values ‘yes’ / ‘no’.



47
# File 'lib/wrapped/val.rb', line 47

define_attribute :inverted

#maxObject

:attr: max Maximum value, defaults to 1.



52
# File 'lib/wrapped/val.rb', line 52

define_attribute :max

#minObject

: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

#orientationObject

:attr: orientation Orientation of control: ‘horizontal’ / ‘vertical’



62
# File 'lib/wrapped/val.rb', line 62

define_attribute :orientation

#pagestepObject

: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

#positionObject

:attr_reader: position Returns position in pixels within client window as “x,y”.



73
# File 'lib/wrapped/val.rb', line 73

define_reader :position

#rastersizeObject

:attr: rastersize Size of the control, in pixels, value as “widthxheight”.



78
# File 'lib/wrapped/val.rb', line 78

define_attribute :rastersize

#screenpositionObject

:attr_reader: screenposition Returns position in pixels on screen as “x,y”.



83
# File 'lib/wrapped/val.rb', line 83

define_reader :screenposition

#stepObject

: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

#valueObject

: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