Class: FX::TableWidget

Inherits:
VerticalFrame show all
Defined in:
lib/libGUIb16.rb,
lib/libGUIb14.rb

Constant Summary collapse

HEADER_COLOR =
Fox::FXRGB(200, 200, 200)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TableWidget

Returns a new instance of TableWidget.



1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
# File 'lib/libGUIb16.rb', line 1407

def initialize(*args)
  super
  @autoresize_titles = true
  Header.new(self) { |w|
    @header = w
    w.headerStyle = HEADER_HORIZONTAL | HEADER_TRACKING
    w.frameStyle = 0
    w.backColor = HEADER_COLOR
    w.connect(SEL_CONFIGURE) {
      set_title_widths
    }
    w.layoutHints = LAYOUT_FILL_X | LAYOUT_FIX_HEIGHT
    w.height = 20
  }
  FXMatrix.new(self, 1) { |w|
    @matrix = w
  }
end

Instance Attribute Details

#autoresize_titlesObject

Returns the value of attribute autoresize_titles.



1425
1426
1427
# File 'lib/libGUIb16.rb', line 1425

def autoresize_titles
  @autoresize_titles
end

Instance Method Details

#createObject



1426
1427
1428
# File 'lib/libGUIb16.rb', line 1426

def create
  super
end

#set_cols(n) ⇒ Object



1463
1464
# File 'lib/libGUIb16.rb', line 1463

def set_cols n
end

#set_rows(n) ⇒ Object



1466
1467
# File 'lib/libGUIb16.rb', line 1466

def set_rows n
end

#set_title_widths(numarray = nil) ⇒ Object



1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
# File 'lib/libGUIb16.rb', line 1438

def set_title_widths numarray = nil
  if numarray
  else # ok, calculate the item widths from their titles
    total = 0
    totalsize = 0
    i = 0
    @header.each { |item|
      total += item.text.size
      totalsize += item.size
      item.data = i
      i += 1
    }
    if @autoresize_titles || (totalsize == 0)
      quant = (@header.width / total.to_f)
      offset = 0
      @header.each { |item|
        i = item.data
        size = (item.text.size * quant).to_i
        @header.setItemSize i, size
        offset += size
      }
    end
  end
end

#set_titles(stringarr) ⇒ Object



1430
1431
1432
1433
1434
1435
1436
# File 'lib/libGUIb16.rb', line 1430

def set_titles stringarr
  stringarr.each { |str|
    @header.appendItem(" " + str)
  }
  set_cols stringarr.size
  set_title_widths
end