Class: Iup::GridBox

Inherits:
Widget show all
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

#handle

Instance Method Summary collapse

Methods included from DynamicFillMethods

#append, #insert

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

#define_callback

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

Yields:

  • (_self)

Yield Parameters:

  • _self (Iup::GridBox)

    the object that the method was called on



28
29
30
31
32
33
# 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

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

#cgapcolObject

:attr: cgapcol n, horizontal space in characters between columns.



72
# File 'lib/wrapped/gridbox.rb', line 72

define_attribute :cgapcol

#cgaplinObject

:attr: cgaplin n, vertical space in characters between lines.



77
# File 'lib/wrapped/gridbox.rb', line 77

define_attribute :cgaplin

#clientoffsetObject

:attr_reader: clientoffset returns current offset of box in its client as “widthxheight”.



82
# File 'lib/wrapped/gridbox.rb', line 82

define_reader :clientoffset

#clientsizeObject

:attr_reader: clientsize returns current size of box as “widthxheight”.



87
# File 'lib/wrapped/gridbox.rb', line 87

define_reader :clientsize

#cmarginObject

:attr: cmargin Margin in x and y directions in characters, value as “mxn”.



92
# File 'lib/wrapped/gridbox.rb', line 92

define_attribute :cmargin

#expandObject

: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

#expandchildrenObject

: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

#fittochildrenObject

: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

#gapcolObject

:attr: gapcol Horizontal space in pixels between columns.



114
# File 'lib/wrapped/gridbox.rb', line 114

define_attribute :gapcol

#gaplinObject

:attr: gaplin Vertical space in pixels between lines.



119
# File 'lib/wrapped/gridbox.rb', line 119

define_attribute :gaplin

#homogeneouscolObject

: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

#homogeneouslinObject

: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

#marginObject

:attr: margin Margin in x and y directions in pixels, value as “mxn”.



136
# File 'lib/wrapped/gridbox.rb', line 136

define_attribute :margin

#normalizesizeObject

: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

#numcolObject

:attr_reader: numcol returns number of columns.



147
# File 'lib/wrapped/gridbox.rb', line 147

define_reader :numcol

#numdivObject

: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

#numlinObject

:attr_reader: numlin returns number of lines.



158
# File 'lib/wrapped/gridbox.rb', line 158

define_reader :numlin

#orientationObject

: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

#positionObject

:attr_reader: position returns position in pixels within client window as “x,y”.



169
# File 'lib/wrapped/gridbox.rb', line 169

define_reader :position

#rastersizeObject

:attr: rastersize Size of the container, in pixels, value as “widthxheight”.



174
# File 'lib/wrapped/gridbox.rb', line 174

define_attribute :rastersize

#sizecolObject

: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

#sizelinObject

: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