Class: WxExtensions::FormGridSizer

Inherits:
Wx::GridBagSizer
  • Object
show all
Defined in:
lib/reactive-wx/wx_ext/form_grid_sizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(rows, cols, hgap, vgap) ⇒ FormGridSizer

Returns a new instance of FormGridSizer.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reactive-wx/wx_ext/form_grid_sizer.rb', line 3

def initialize(rows, cols, hgap, vgap)
  super(hgap, vgap)

  @cols, @rows = cols, rows
  @cols = 1 if @cols.nil? && @rows.nil?
#puts "#{self} arrange: c:#{@cols} r:#{@rows}"
  
  @span = @cols ? Wx::GBSpan.new(1,2) : Wx::GBSpan.new(2,1)
  @defaultspan = Wx::GBSpan.new(1,1)
  
  @row = @col = 0
  
  if @cols
    1.step(@cols*2, 2) {|i| add_growable_col(i, 1); "puts grow: #{i}"}
  else
    add_growable_col(1, 1)
  end
end

Instance Method Details

#add(child, prop = 0, flag = 0, border = 0, userdata = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/reactive-wx/wx_ext/form_grid_sizer.rb', line 22

def add(child, prop = 0, flag = 0, border = 0, userdata = nil)
  span = (flag & 0x10000000 == 0x10000000) || child.is_a?(FormGridSizer)
#puts "#{self} putting at r:#{@row}, c:#{@col} #{child.class} #{flag} #{span}"
  item = super(child, Wx::GBPosition.new(@row, @col), span ? @span : @defaultspan, flag, border, userdata)
  add_growable_row(@row, prop) if span
  move_next
  move_next if span
  item
end