Class: Iup::Matrix
Overview
Matrix
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#action_cb(callback) ⇒ Object
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.
- #bgcolor_cell(col, lin, colour) ⇒ Object
-
#bgcolor_column(col, colour) ⇒ Object
cell attributes (no redraw).
- #bgcolor_line(lin, colour) ⇒ Object
-
#click_cb(callback) ⇒ Object
Action generated when any mouse button is pressed over a cell.
-
#colresize_cb(callback) ⇒ Object
Action generated when a column is interactively resized.
-
#enteritem_cb(callback) ⇒ Object
Action generated when matrix cell is selected, matrix gets focus etc.
-
#get(lin, col) ⇒ Object
get value of cell.
-
#height(n, size) ⇒ Object
HEIGHTn, defines line height in SIZE units.
-
#initialize(&block) ⇒ Matrix
constructor
A new instance of Matrix.
-
#leaveitem_cb(callback) ⇒ Object
Action generated when cell is no longer current cell.
-
#mincolwidth(n, size) ⇒ Object
MINCOLWIDTHn, defines column width in SIZE units.
-
#mousemove_cb(callback) ⇒ Object
Action generated when mouse has moved over the matrix.
-
#rasterheight(n, num_pixels) ⇒ Object
RASTERHEIGHTn, defines line height in pixels.
-
#rasterwidth(n, num_pixels) ⇒ Object
RASTERWIDTHn, defines column width in pixels.
-
#redraw ⇒ Object
action attributes.
-
#release_cb(callback) ⇒ Object
Action generated when any mouse button is released over a cell.
-
#resizematrix_cb(callback) ⇒ Object
Action generated after the element size has been updated, but before the cells are refreshed.
-
#scrolltop_cb(callback) ⇒ Object
Action generated when matrix is scrolled.
-
#set(lin, col, value) ⇒ Object
set value of cell.
-
#width(n, size) ⇒ Object
WIDTHn, defines column width in SIZE units.
Methods inherited from Widget
#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly
Methods included from CallbackSetter
Constructor Details
#initialize(&block) ⇒ Matrix
Returns a new instance of Matrix.
6 7 8 9 10 11 12 |
# 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 |
Instance Method Details
#action_cb(callback) ⇒ Object
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
132 133 134 135 136 137 138 139 140 |
# 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) ⇒ Object
59 60 61 |
# 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) ⇒ Object
cell attributes (no redraw)
53 54 55 |
# File 'lib/wrapped/matrix.rb', line 53 def bgcolor_column col, colour IupLib.IupSetAttribute @handle, "BGCOLOR*:#{col}", colour end |
#bgcolor_line(lin, colour) ⇒ Object
56 57 58 |
# File 'lib/wrapped/matrix.rb', line 56 def bgcolor_line lin, colour IupLib.IupSetAttribute @handle, "BGCOLOR#{lin}:*", colour end |
#click_cb(callback) ⇒ Object
Action generated when any mouse button is pressed over a cell.
143 144 145 146 147 148 149 150 151 |
# 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) ⇒ Object
Action generated when a column is interactively resized.
154 155 156 157 158 159 160 161 162 |
# 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) ⇒ Object
Action generated when matrix cell is selected, matrix gets focus etc.
199 200 201 202 203 204 205 206 207 |
# 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) ⇒ Object
get value of cell
15 16 17 |
# File 'lib/wrapped/matrix.rb', line 15 def get lin, col IupLib.IupGetAttribute(@handle, "#{lin}:#{col}").first end |
#height(n, size) ⇒ Object
HEIGHTn, defines line height in SIZE units
91 92 93 |
# File 'lib/wrapped/matrix.rb', line 91 def height n, size IupLib.IupSetAttribute @handle, "HEIGHT#{n}", size.to_s end |
#leaveitem_cb(callback) ⇒ Object
Action generated when cell is no longer current cell.
210 211 212 213 214 215 216 217 218 |
# 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) ⇒ Object
MINCOLWIDTHn, defines column width in SIZE units
84 85 86 |
# File 'lib/wrapped/matrix.rb', line 84 def mincolwidth n, size IupLib.IupSetAttribute @handle, "MINCOLWIDTH#{n}", size.to_s end |
#mousemove_cb(callback) ⇒ Object
Action generated when mouse has moved over the matrix.
188 189 190 191 192 193 194 195 196 |
# 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) ⇒ Object
RASTERHEIGHTn, defines line height in pixels
98 99 100 |
# 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) ⇒ Object
RASTERWIDTHn, defines column width in pixels
72 73 74 |
# File 'lib/wrapped/matrix.rb', line 72 def rasterwidth n, num_pixels IupLib.IupSetAttribute @handle, "RASTERWIDTH#{n}", num_pixels.to_s end |
#redraw ⇒ Object
action attributes
117 118 119 |
# File 'lib/wrapped/matrix.rb', line 117 def redraw # TODO - values IupLib.IupSetAttribute @handle, 'redraw', 'all' end |
#release_cb(callback) ⇒ Object
Action generated when any mouse button is released over a cell.
165 166 167 168 169 170 171 172 173 |
# 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) ⇒ Object
Action generated after the element size has been updated, but before the cells are refreshed.
177 178 179 180 181 182 183 184 185 |
# 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) ⇒ Object
Action generated when matrix is scrolled.
221 222 223 224 225 226 227 228 229 |
# 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) ⇒ Object
set value of cell
20 21 22 |
# File 'lib/wrapped/matrix.rb', line 20 def set lin, col, value IupLib.IupSetAttribute @handle, "#{lin}:#{col}", value end |
#width(n, size) ⇒ Object
WIDTHn, defines column width in SIZE units
77 78 79 |
# File 'lib/wrapped/matrix.rb', line 77 def width n, size IupLib.IupSetAttribute @handle, "WIDTH#{n}", size.to_s end |