class Iup::Dial

Public Class Methods

new(orientation = 'horizontal', &block) click to toggle source
# File lib/wrapped/dial.rb, line 5
def initialize orientation = 'horizontal', &block
  open_controls
  @handle = ControlsLib.IupDial orientation

  # run any provided block on instance, to set up further attributes
  self.instance_eval &block if block_given?
end

Public Instance Methods

button_press_cb(callback) click to toggle source

Called when the user presses the left mouse button over the dial. The angle here is always zero, except for the circular dial. Callback is a 1-argument function: (angle)

# File lib/wrapped/dial.rb, line 39
def button_press_cb callback
  unless callback.arity == 1
    raise ArgumentError, 'button_press_cb callback must take 1 argument: (angle)'
  end
  cb = Proc.new do |ih, angle|
    callback.call angle 
  end
  define_callback cb, 'BUTTON_PRESS_CB', :d_i
end
button_release_cb(callback) click to toggle source

Called when the user releases the left mouse button after pressing it over the dial. The angle here is always zero, except for the circular dial. Callback is a 1-argument function: (angle)

# File lib/wrapped/dial.rb, line 52
def button_release_cb callback
  unless callback.arity == 1
    raise ArgumentError, 'button_release_cb callback must take 1 argument: (angle)'
  end
  cb = Proc.new do |ih, angle|
    callback.call angle
  end
  define_callback cb, 'BUTTON_RELEASE_CB', :d_i
end
mousemove_cb(callback) click to toggle source

Called each time the user moves the dial with the mouse button pressed. The angle the dial rotated since it was initialized is passed as a parameter. Callback is a 1-argument function: (angle)

# File lib/wrapped/dial.rb, line 65
def mousemove_cb callback
  unless callback.arity == 1
    raise ArgumentError, 'mousemove_cb callback must take 1 argument: (angle)'
  end
  cb = Proc.new do |ih, angle|
    callback.call angle
  end
  define_callback cb, 'MOUSEMOVE_CB', :d_i
end
value(val=nil) click to toggle source
# File lib/wrapped/dial.rb, line 23
def value val=nil
  if val.nil?
    result = IupLib.IupGetAttribute(@handle, 'VALUE').first
    result.to_f
  else
    IupLib.IupSetAttribute @handle, 'VALUE', val.to_s
  end
end
valuechanged_cb(callback) click to toggle source

Called after the value was interactively changed by the user. Called when the selection is changed or when the text is edited.

# File lib/wrapped/dial.rb, line 77
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