class Iup::Matrix

Matrix

Public Class Methods

new(&block) click to toggle source
# File lib/wrapped/matrix.rb, line 6
def initialize &block
  open_controls
  @handle = ControlsLib.IupMatrix ""

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

Public Instance Methods

action_cb(callback) click to toggle source

Action generated when a keyboard event occurs returns IUP_DEFAULT to validate the key, IUP_IGNORE to ignore, IUP_CONTINUE forwards the key, or identifier of the key to be treated

# File lib/wrapped/matrix.rb, line 132
def action_cb callback
  unless callback.arity == 5
    raise ArgumentError, 'action_cb callback must take 5 arguments: (key, lin, col, edition, value)'
  end
  cb = Proc.new do |ih, key, lin, col, edition, value|
    callback.call key, lin, col, edition, value
  end
  define_callback cb, 'ACTION_CB', :i_s
end
bgcolor_cell(col, lin, colour) click to toggle source
# File lib/wrapped/matrix.rb, line 59
def bgcolor_cell col, lin, colour
  IupLib.IupSetAttribute @handle, "BGCOLOR#{lin}:#{col}", colour
end
bgcolor_column(col, colour) click to toggle source

cell attributes (no redraw)

# File lib/wrapped/matrix.rb, line 53
def bgcolor_column col, colour
  IupLib.IupSetAttribute @handle, "BGCOLOR*:#{col}", colour
end
bgcolor_line(lin, colour) click to toggle source
# File lib/wrapped/matrix.rb, line 56
def bgcolor_line lin, colour
  IupLib.IupSetAttribute @handle, "BGCOLOR#{lin}:*", colour
end
click_cb(callback) click to toggle source

Action generated when any mouse button is pressed over a cell.

# File lib/wrapped/matrix.rb, line 143
def click_cb callback
  unless callback.arity == 3
    raise ArgumentError, 'click_cb callback must take 3 arguments: (lin, col, status)'
  end
  cb = Proc.new do |ih, lin, col, status|
    callback.call lin, col, status
  end
  define_callback cb, 'CLICK_CB', :i_s
end
colresize_cb(callback) click to toggle source

Action generated when a column is interactively resized.

# File lib/wrapped/matrix.rb, line 154
def colresize_cb callback
  unless callback.arity == 1
    raise ArgumentError, 'colresize_cb callback must take 1 argument: (col)'
  end
  cb = Proc.new do |ih, col|
    callback.call col
  end
  define_callback cb, 'COLRESIZE_CB', :i_s
end
enteritem_cb(callback) click to toggle source

Action generated when matrix cell is selected, matrix gets focus etc.

# File lib/wrapped/matrix.rb, line 199
def enteritem_cb callback
  unless callback.arity == 2
    raise ArgumentError, 'enteritem_cb callback must take 2 arguments: (lin, col)'
  end
  cb = Proc.new do |ih, lin, col|
    callback.call lin, col
  end
  define_callback cb, 'ENTERITEM_CB', :i_s
end
get(lin, col) click to toggle source

get value of cell

# File lib/wrapped/matrix.rb, line 15
def get lin, col
  IupLib.IupGetAttribute(@handle, "#{lin}:#{col}").first
end
height(n, size) click to toggle source

HEIGHTn, defines line height in SIZE units

# File lib/wrapped/matrix.rb, line 91
def height n, size
  IupLib.IupSetAttribute @handle, "HEIGHT#{n}", size.to_s
end
leaveitem_cb(callback) click to toggle source

Action generated when cell is no longer current cell.

# File lib/wrapped/matrix.rb, line 210
def leaveitem_cb callback
  unless callback.arity == 2
    raise ArgumentError, 'leaveitem_cb callback must take 2 arguments: (lin, col)'
  end
  cb = Proc.new do |ih, lin, col|
    callback.call lin, col
  end
  define_callback cb, 'LEAVEITEM_CB', :i_s
end
mincolwidth(n, size) click to toggle source

MINCOLWIDTHn, defines column width in SIZE units

# File lib/wrapped/matrix.rb, line 84
def mincolwidth n, size
  IupLib.IupSetAttribute @handle, "MINCOLWIDTH#{n}", size.to_s
end
mousemove_cb(callback) click to toggle source

Action generated when mouse has moved over the matrix.

# File lib/wrapped/matrix.rb, line 188
def mousemove_cb callback
  unless callback.arity == 2
    raise ArgumentError, 'mousemove_cb callback must take 2 arguments: (lin, col)'
  end
  cb = Proc.new do |ih, lin, col|
    callback.call lin, col
  end
  define_callback cb, 'MOUSEMOVE_CB', :i_s
end
rasterheight(n, num_pixels) click to toggle source

RASTERHEIGHTn, defines line height in pixels

# File lib/wrapped/matrix.rb, line 98
def rasterheight n, num_pixels
  IupLib.IupSetAttribute @handle, "RASTERHEIGHT#{n}", num_pixels.to_s
end
rasterwidth(n, num_pixels) click to toggle source

RASTERWIDTHn, defines column width in pixels

# File lib/wrapped/matrix.rb, line 72
def rasterwidth n, num_pixels
  IupLib.IupSetAttribute @handle, "RASTERWIDTH#{n}", num_pixels.to_s
end
redraw() click to toggle source

action attributes

# File lib/wrapped/matrix.rb, line 117
def redraw # TODO - values
  IupLib.IupSetAttribute @handle, 'redraw', 'all'
end
release_cb(callback) click to toggle source

Action generated when any mouse button is released over a cell.

# File lib/wrapped/matrix.rb, line 165
def release_cb callback
  unless callback.arity == 3
    raise ArgumentError, 'release_cb callback must take 3 arguments: (lin, col, status)'
  end
  cb = Proc.new do |ih, lin, col, status|
    callback.call lin, col, status
  end
  define_callback cb, 'RELEASE_CB', :i_s
end
resizematrix_cb(callback) click to toggle source

Action generated after the element size has been updated, but before the cells are refreshed.

# File lib/wrapped/matrix.rb, line 177
def resizematrix_cb callback
  unless callback.arity == 2
    raise ArgumentError, 'resizematrix_cb callback must take 2 arguments: (width, height)'
  end
  cb = Proc.new do |ih, width, height|
    callback.call width, height
  end
  define_callback cb, 'RESIZEMATRIX_CB', :i_s
end
scrolltop_cb(callback) click to toggle source

Action generated when matrix is scrolled.

# File lib/wrapped/matrix.rb, line 221
def scrolltop_cb callback
  unless callback.arity == 2
    raise ArgumentError, 'scrolltop_cb callback must take 2 arguments: (lin, col)'
  end
  cb = Proc.new do |ih, lin, col|
    callback.call lin, col
  end
  define_callback cb, 'SCROLLTOP_CB', :i_s
end
set(lin, col, value) click to toggle source

set value of cell

# File lib/wrapped/matrix.rb, line 20
def set lin, col, value
  IupLib.IupSetAttribute @handle, "#{lin}:#{col}", value
end
width(n, size) click to toggle source

WIDTHn, defines column width in SIZE units

# File lib/wrapped/matrix.rb, line 77
def width n, size
  IupLib.IupSetAttribute @handle, "WIDTH#{n}", size.to_s
end