Class: Iup::GridBox
- Includes:
- DynamicFillMethods
- Defined in:
- lib/wrapped/gridbox.rb
Overview
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
Also see: HBox, VBox
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#alignmentcol(val = nil, val2 = nil) ⇒ Object
:call-seq: gridbox.alignmentcol() # Reads value of “ALIGNMENTCOL” grid.alignmentcol(val) # Sets “ALIGNMENTCOL” to val grid.alignmentcol(n, val) # Sets alignment of column n to val.
-
#alignmentlin(val = nil, val2 = nil) ⇒ Object
:call-seq: gridbox.alignmentlin() # Reads value of “ALIGNMENTLIN” grid.alignmentlin(val) # Sets “ALIGNMENTLIN” to val grid.alignmentlin(n, val) # Sets alignment of line n to val.
-
#cgapcol ⇒ Object
:attr: cgapcol n, horizontal space in characters between columns.
-
#cgaplin ⇒ Object
:attr: cgaplin n, vertical space in characters between lines.
-
#clientoffset ⇒ Object
:attr_reader: clientoffset returns current offset of box in its client as “widthxheight”.
-
#clientsize ⇒ Object
:attr_reader: clientsize returns current size of box as “widthxheight”.
-
#cmargin ⇒ Object
:attr: cmargin Margin in x and y directions in characters, value as “mxn”.
-
#expand ⇒ Object
:attr: expand Allows container to fill available space in indicated direction.
-
#expandchildren ⇒ Object
:attr: expandchildren Set to allow children to expand fully, values as ‘yes’ / ‘no’ / ‘horizontal’ / ‘vertical’.
-
#fittochildren ⇒ Object
:attr: fittochildren ‘column’ / ‘line’, n -> force column/line n to fit largest element in that column/line.
-
#gapcol ⇒ Object
:attr: gapcol Horizontal space in pixels between columns.
-
#gaplin ⇒ Object
:attr: gaplin Vertical space in pixels between lines.
-
#homogeneouscol ⇒ Object
:attr: homogeneouscol Forces all columns to have same horizontal space.
-
#homogeneouslin ⇒ Object
:attr: homogeneouslin Forces all lines to have same vertical space.
-
#initialize(*widgets) {|_self| ... } ⇒ GridBox
constructor
Creates an instance of the gridbox.
-
#margin ⇒ Object
:attr: margin Margin in x and y directions in pixels, value as “mxn”.
-
#normalizesize ⇒ Object
:attr: normalsize Set to make natural size of children same, values as ‘yes’ / ‘no’ / ‘horizontal’ / ‘vertical’.
-
#numcol ⇒ Object
:attr_reader: numcol returns number of columns.
-
#numdiv ⇒ Object
:attr: numdiv ‘auto’ / n, controls number of divisions in direction as determined by
orientation. -
#numlin ⇒ Object
:attr_reader: numlin returns number of lines.
-
#orientation ⇒ Object
:attr: orientation Controls distribution of children, in lines or columns.
-
#position ⇒ Object
:attr_reader: position returns position in pixels within client window as “x,y”.
-
#rastersize ⇒ Object
:attr: rastersize Size of the container, in pixels, value as “widthxheight”.
-
#sizecol ⇒ Object
:attr: sizecol Index of column to use for calculating height of lines.
-
#sizelin ⇒ Object
:attr: sizelin Index of line to use for calculating width of columns.
Methods included from DynamicFillMethods
Methods inherited from Widget
#active, #assign_handle, #bgcolor, #destroy, #enterwindow_cb=, #fgcolor, #font, #getfocus_cb=, #help_cb=, #k_any=, #killfocus_cb=, #leavewindow_cb=, #map_cb=, #maxsize, #minsize, #open_controls, #size, #unmap_cb=, #visible, #wid, #zorder
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_reader, #define_id_writer, #define_property_attribute, #define_property_reader, #define_property_writer, #define_reader, #define_writer
Methods included from CallbackSetter
Constructor Details
#initialize(*widgets) {|_self| ... } ⇒ GridBox
Creates an instance of the gridbox. If a block is given, the new instance is yielded to it.
-
widgets-one or more child widgets
28 29 30 31 32 33 |
# File 'lib/wrapped/gridbox.rb', line 28 def initialize * @handle = IupLib.IupGridBox(*()) # run any provided block on instance, to set up further attributes yield self if block_given? end |
Instance Method Details
#alignmentcol(val = nil, val2 = nil) ⇒ Object
:call-seq:
gridbox.alignmentcol() # Reads value of "ALIGNMENTCOL"
grid.alignmentcol(val) # Sets "ALIGNMENTCOL" to val
grid.alignmentcol(n, val) # Sets alignment of column n to val
Alignment values are ‘ALEFT’ / ‘ACENTER’ / ‘ARIGHT’.
43 44 45 46 47 48 49 50 51 |
# 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 |
#alignmentlin(val = nil, val2 = nil) ⇒ Object
:call-seq:
gridbox.alignmentlin() # Reads value of "ALIGNMENTLIN"
grid.alignmentlin(val) # Sets "ALIGNMENTLIN" to val
grid.alignmentlin(n, val) # Sets alignment of line n to val
Alignment values are ‘ATOP’ / ‘ACENTER’ / ‘ABOTTOM’.
59 60 61 62 63 64 65 66 67 |
# 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 |
#cgapcol ⇒ Object
:attr: cgapcol n, horizontal space in characters between columns.
72 |
# File 'lib/wrapped/gridbox.rb', line 72 define_attribute :cgapcol |
#cgaplin ⇒ Object
:attr: cgaplin n, vertical space in characters between lines.
77 |
# File 'lib/wrapped/gridbox.rb', line 77 define_attribute :cgaplin |
#clientoffset ⇒ Object
:attr_reader: clientoffset returns current offset of box in its client as “widthxheight”.
82 |
# File 'lib/wrapped/gridbox.rb', line 82 define_reader :clientoffset |
#clientsize ⇒ Object
:attr_reader: clientsize returns current size of box as “widthxheight”.
87 |
# File 'lib/wrapped/gridbox.rb', line 87 define_reader :clientsize |
#cmargin ⇒ Object
:attr: cmargin Margin in x and y directions in characters, value as “mxn”.
92 |
# File 'lib/wrapped/gridbox.rb', line 92 define_attribute :cmargin |
#expand ⇒ Object
:attr: expand Allows container to fill available space in indicated direction. Values ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’.
98 |
# File 'lib/wrapped/gridbox.rb', line 98 define_attribute :expand |
#expandchildren ⇒ Object
:attr: expandchildren Set to allow children to expand fully, values as ‘yes’ / ‘no’ / ‘horizontal’ / ‘vertical’.
104 |
# File 'lib/wrapped/gridbox.rb', line 104 define_attribute :expandchildren |
#fittochildren ⇒ Object
:attr: fittochildren ‘column’ / ‘line’, n -> force column/line n to fit largest element in that column/line.
109 |
# File 'lib/wrapped/gridbox.rb', line 109 define_attribute :fittochildren |
#gapcol ⇒ Object
:attr: gapcol Horizontal space in pixels between columns.
114 |
# File 'lib/wrapped/gridbox.rb', line 114 define_attribute :gapcol |
#gaplin ⇒ Object
:attr: gaplin Vertical space in pixels between lines.
119 |
# File 'lib/wrapped/gridbox.rb', line 119 define_attribute :gaplin |
#homogeneouscol ⇒ Object
:attr: homogeneouscol Forces all columns to have same horizontal space. Values as ‘yes’ / ‘no’.
125 |
# File 'lib/wrapped/gridbox.rb', line 125 define_attribute :homogeneouscol |
#homogeneouslin ⇒ Object
:attr: homogeneouslin Forces all lines to have same vertical space. Values as ‘yes’ / ‘no’.
131 |
# File 'lib/wrapped/gridbox.rb', line 131 define_attribute :homogeneouslin |
#margin ⇒ Object
:attr: margin Margin in x and y directions in pixels, value as “mxn”.
136 |
# File 'lib/wrapped/gridbox.rb', line 136 define_attribute :margin |
#normalizesize ⇒ Object
:attr: normalsize Set to make natural size of children same, values as ‘yes’ / ‘no’ / ‘horizontal’ / ‘vertical’.
142 |
# File 'lib/wrapped/gridbox.rb', line 142 define_attribute :normalizesize |
#numcol ⇒ Object
:attr_reader: numcol returns number of columns.
147 |
# File 'lib/wrapped/gridbox.rb', line 147 define_reader :numcol |
#numdiv ⇒ Object
:attr: numdiv ‘auto’ / n, controls number of divisions in direction as determined by orientation.
153 |
# File 'lib/wrapped/gridbox.rb', line 153 define_attribute :numdiv |
#numlin ⇒ Object
:attr_reader: numlin returns number of lines.
158 |
# File 'lib/wrapped/gridbox.rb', line 158 define_reader :numlin |
#orientation ⇒ Object
:attr: orientation Controls distribution of children, in lines or columns. Value as ‘horizontal’ / ‘vertical’.
164 |
# File 'lib/wrapped/gridbox.rb', line 164 define_attribute :orientation |
#position ⇒ Object
:attr_reader: position returns position in pixels within client window as “x,y”.
169 |
# File 'lib/wrapped/gridbox.rb', line 169 define_reader :position |
#rastersize ⇒ Object
:attr: rastersize Size of the container, in pixels, value as “widthxheight”.
174 |
# File 'lib/wrapped/gridbox.rb', line 174 define_attribute :rastersize |
#sizecol ⇒ Object
:attr: sizecol Index of column to use for calculating height of lines. Note: make sure column is within range, else can crash.
180 |
# File 'lib/wrapped/gridbox.rb', line 180 define_attribute :sizecol |
#sizelin ⇒ Object
:attr: sizelin Index of line to use for calculating width of columns. Note: make sure line is within range, else can crash.
186 |
# File 'lib/wrapped/gridbox.rb', line 186 define_attribute :sizelin |