class Iup::GridBox
A container which arranges its widgets in a left-to-right, top-to-bottom order to form a grid-like arrangement.
Example
The following example sets up a 2x2 grid of labels, each centered with a small gap between the columns:
box = Iup::GridBox.new(lbl1, lbl2, lbl3, lbl4) do |b| b.sizelin = 1 # the second line is used for calculating spacing b.numdiv = 2 # arranges labels with 2 columns b.alignmentlin = 'acenter' b.gapcol = 5 end
Attributes
n, horizontal space in characters between columns.
n, vertical space in characters between lines.
returns current offset of box in its client as âwidthxheightâ.
returns current size of box as âwidthxheightâ.
Margin in x and y directions in characters, value as âmxnâ.
Allows container to fill available space in indicated direction. Values ânoâ / âhorizontalâ / âverticalâ / âyesâ.
Set to allow children to expand fully, values as âyesâ / ânoâ / âhorizontalâ / âverticalâ.
âcolumnâ / âlineâ, n -> force column/line n to fit largest element in that column/line.
Horizontal space in pixels between columns.
Vertical space in pixels between lines.
Forces all columns to have same horizontal space. Values as âyesâ / ânoâ.
Forces all lines to have same vertical space. Values as âyesâ / ânoâ.
Margin in x and y directions in pixels, value as âmxnâ.
Set to make natural size of children same, values as âyesâ / ânoâ / âhorizontalâ / âverticalâ.
returns number of columns.
âautoâ / n, controls number of divisions in direction as determined by orientation.
returns number of lines.
Controls distribution of children, in lines or columns. Value as âhorizontalâ / âverticalâ.
returns position in pixels within client window as âx,yâ.
Size of the container, in pixels, value as âwidthxheightâ.
Index of column to use for calculating height of lines. Note: make sure column is within range, else can crash.
Index of line to use for calculating width of columns. Note: make sure line is within range, else can crash.
Public Class Methods
Source
# File lib/wrapped/gridbox.rb, line 28 def initialize *widgets @handle = IupLib.IupGridBox(*widget_list(widgets)) # run any provided block on instance, to set up further attributes yield self if block_given? end
Creates an instance of the gridbox. If a block is given, the new instance is yielded to it.
-
widgets-one or more child widgets
Public Instance Methods
Source
# File lib/wrapped/gridbox.rb, line 43 def alignmentcol val=nil, val2=nil if val.nil? IupLib.IupGetAttribute(@handle, 'ALIGNMENTCOL').first elsif val2.nil? IupLib.IupSetAttribute @handle, 'ALIGNMENTCOL', val.to_s else IupLib.IupSetAttribute @handle, "ALIGNMENTCOL#{val}", val2.to_s end end
Alignment values are âALEFTâ / âACENTERâ / âARIGHTâ.
Source
# File lib/wrapped/gridbox.rb, line 59 def alignmentlin val=nil, val2=nil if val.nil? IupLib.IupGetAttribute(@handle, 'ALIGNMENTLIN').first elsif val2.nil? IupLib.IupSetAttribute @handle, 'ALIGNMENTLIN', val.to_s else IupLib.IupSetAttribute @handle, "ALIGNMENTLIN#{val}", val2.to_s end end
Alignment values are âATOPâ / âACENTERâ / âABOTTOMâ.