class Iup::Matrix
Public Class Methods
# 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 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
# File lib/wrapped/matrix.rb, line 59 def bgcolor_cell col, lin, colour IupLib.IupSetAttribute @handle, "BGCOLOR#{lin}:#{col}", colour end
cell attributes (no redraw)
# File lib/wrapped/matrix.rb, line 53 def bgcolor_column col, colour IupLib.IupSetAttribute @handle, "BGCOLOR*:#{col}", colour end
# File lib/wrapped/matrix.rb, line 56 def bgcolor_line lin, colour IupLib.IupSetAttribute @handle, "BGCOLOR#{lin}:*", colour end
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
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
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 value of cell
# File lib/wrapped/matrix.rb, line 15 def get lin, col IupLib.IupGetAttribute(@handle, "#{lin}:#{col}").first end
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
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
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
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
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
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
action attributes
# File lib/wrapped/matrix.rb, line 117 def redraw # TODO - values IupLib.IupSetAttribute @handle, 'redraw', 'all' end
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
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
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 value of cell
# File lib/wrapped/matrix.rb, line 20 def set lin, col, value IupLib.IupSetAttribute @handle, "#{lin}:#{col}", value end
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