[fxruby-users] two table bugs

Joel VanderWerf vjoel at PATH.Berkeley.EDU
Mon Mar 7 20:57:51 EST 2005


The following two problems occur on Windows and Linux, with ruby-1.8.2 
and FXRuby-1.2.5.

Instead of FXTableItems, (some of) the items of a table are FXHeaderItems.

A memory problem (all I know is GC.disable seems to prevent it).

The code is below.

----
require "fox12"
include Fox

class MyTable < FXTable
   def initialize parent
     super(parent, nil, 0,
       TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y)
     fill
   end

   def fill
     setTableSize(100, 100)

     each_row_header_item do |item|
       item.setJustify FXHeaderItem::CENTER_Y
     end

     each_col_header_item do |item|
       item.setJustify FXHeaderItem::CENTER_X
     end

     each_row_index do |r|
       each_col_index do |c|
         item = table_item(r,c)
         item.setJustify FXTableItem::JUSTIFY_CENTER_X
if item.class != Fox::FXTableItem
p ["fill", r,c,item.class]
end
       end
     end

     setCurrentItem(0,0)

     columnHeader.update
     rowHeader.update
     update
   end

   def each_row_index
     (0...numRows).each do |r|
       yield r
     end
   end

   def each_col_index
     (0...numColumns).each do |c|
       yield c
     end
   end

   def each_row_header_item
     each_row_index do |r|
       yield row_header_item(r)
     end
   end

   def each_col_header_item
     each_col_index do |c|
       yield col_header_item(c)
     end
   end

   def row_header_item(row)
     rowHeader.getItem(row)
   end

   def col_header_item(col)
     columnHeader.getItem(col)
   end

   def table_item(row, col)
#    getItem(row, col) || create_item(row, col)
     if (item = getItem(row, col))
if item.class != Fox::FXTableItem
p ["getItem", row,col,item.class]
end
     else
       item = create_item(row, col)
     end
     item
   end

   def create_item(row, col)
     setItemText(row, col, "")
     item = getItem(row, col)
if item.class != Fox::FXTableItem
p ["create_item", row,col,item.class]
end
     item
   end
end


class TestWindow < FXMainWindow

   def initialize(app)
     super(app, "MyTest", nil, nil, DECOR_ALL, 0, 0, 600, 400, 0, 0)
     mainFrame = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
     bugButton = FXButton.new(mainFrame, "Bug")
     bugButton.connect(SEL_COMMAND) { @table.fill }
     @table = MyTable.new(mainFrame)
   end

   def create
     super
     show(PLACEMENT_SCREEN)
   end

end

def runme
   application = FXApp.new("MyTest", "FoxTest")
   TestWindow.new(application)
   application.create
   application.run
end

runme



More information about the fxruby-users mailing list