i am sorry to steal your time with ask without code! Here's my code - i wanna 
change the content of my sequence data - but it does not show in my table...
    
    
    from uing/rawui import nil
    import uing
    
    var list: seq[string] = @["dummy"]
    
    proc modelNumColumns(mh: ptr TableModelHandler, m: ptr rawui.TableModel): 
cint {.cdecl.} = 0
    proc modelNumRows(mh: ptr TableModelHandler, m: ptr rawui.TableModel): cint 
{.cdecl.} =
      result = cint(list.len())
    
    proc modelColumnType(mh: ptr TableModelHandler, m: ptr rawui.TableModel, 
col: cint): TableValueType {.cdecl.} =
      result = TableValueTypeString
    
    proc modelCellValue(mh: ptr TableModelHandler, m: ptr rawui.TableModel, 
row, col: cint): ptr rawui.TableValue {.cdecl.} =
      result = newTableValue(list[row]).impl
    
    proc modelSetCellValue(mh: ptr TableModelHandler, m: ptr rawui.TableModel, 
row, col: cint, val: ptr rawui.TableValue) {.cdecl.} =
      rawui.tableModelRowChanged(m, row)
    
    proc main() =
      var mainwin: Window
      
      let menu = newMenu("File")
      menu.addQuitItem(
        proc(): bool =
          mainwin.destroy()
          return true
      )
      
      mainwin = newWindow("Table", 640, 480, true)
      mainwin.margined = true
      
      let box = newVerticalBox(true)
      mainwin.child = box
      
      var mh: TableModelHandler
      mh.numColumns = modelNumColumns
      mh.columnType = modelColumnType
      mh.numRows = modelNumRows
      mh.cellValue = modelCellValue
      mh.setCellValue = modelSetCellValue
      
      var p: TableParams
      p.model = newTableModel(addr mh).impl
      p.rowBackgroundColorModelColumn = -1
      
      let table = newTable(addr p)
      table.addTextColumn("My Header", 0, TableModelColumnNeverEditable)
      
      let btn = newButton("click me...", proc(sender: Button)=
        list = @[]
        list.add(@["one", "two", "three", "four"])
        echo list.len()
        # now update the tabel... but how ;(
        mh.numColumns = modelNumColumns
        mh.columnType = modelColumnType
        mh.numRows = modelNumRows
        mh.cellValue = modelCellValue
        mh.setCellValue = modelSetCellValue
      
      )
      box.add btn, false
      box.add table, true
      
      show mainwin
      mainLoop()
    
    init()
    main()
    
    
    Run

Thx

Reply via email to