I have experimented with iup.matrix and modified one of the example scripts as shown below.
It adjusts the line and column size according to cell contents.
So if a new cell value is set and the FitToText is applied it adjusts the sizes.
Code: Select all
require( "iuplua" )
require( "iupluacontrols" )
mat = iup.matrix {
numcol=5,
numlin=3,
numcol_visible=5,
numlin_visible=3,
resizematrix = "YES"}
mat:setcell(0,0,"Inflation")
mat:setcell(1,0,"Medicine")
mat:setcell(2,0,"Food")
mat:setcell(3,0,"Energy")
mat:setcell(0,1,"Jan 2000")
mat:setcell(0,2,"Feb 2000")
mat:setcell(0,3,"Mar 2000")
mat:setcell(0,4,"Apr 2000")
mat:setcell(0,5,"May 2000")
mat:setcell(1,1,"5.6")
mat:setcell(2,1,"2.2 \n with long text suffix")
mat:setcell(3,1,"7.2")
mat:setcell(1,2,"4.6\n\nend")
mat:setcell(2,2,"1.3")
mat:setcell(3,2,"1.4")
-- The following 8 lines adjust the size of each line & column to fit the text in cells
mat.FitToText = "L1"
mat.FitToText = "L2"
mat.FitToText = "L3"
mat.FitToText = "C1"
mat.FitToText = "C2"
mat.FitToText = "C3"
mat.FitToText = "C4"
mat.FitToText = "C5"
dlg = iup.dialog{iup.vbox{mat; margin="10x10"}; shrink="yes"}
dlg:showxy(iup.CENTER, iup.CENTER)
function mat:click_cb(lin, col, status) -- Mouse-click on any cell to set its value and adjust its size
mat:setcell(lin,col," new value entered \n on two lines ")
mat.FitToText = "L"..lin
mat.FitToText = "C"..col
return iup.IGNORE
end
if (iup.MainLoopLevel()==0) then
iup.MainLoop()
end