Advertisement
draugath

table_viewer_options.lua

May 11th, 2011
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. local tv = test.table_viewer
  2. local ui = tv.ui
  3.  
  4. tv.options = {}
  5. tv.options.ui = {}
  6.  
  7. local opt = tv.options
  8. local optui = opt.ui
  9. local size = tv.history_size
  10.  
  11. function tv.options.build_dialog()
  12.     optui.size = iup.text{value = size, size = 25}
  13.     optui.reset = iup.stationbutton{title = 'Reset History', size = 100, action = function(self)
  14.             for i = 1, size do ui.dropdown[i] = nil end
  15.             tv.history = {}
  16.             gkini.WriteString('DevKit', 'tableviewer.history', spickle(tv.history))
  17.         end}
  18.     optui.save = iup.stationbutton{title = 'Save', size = 75, action = function(self)
  19.             local oldsize = size
  20.             size = tonumber(optui.size.value)
  21.             if size < oldsize then
  22.                 for i = oldsize, size + 1, -1 do
  23.                     ui.dropdown[i] = nil
  24.                     tv.history[i] = nil
  25.                 end
  26.             end
  27.             gkini.WriteInt('DevKit', 'tableviewer.history_size', size)
  28.             tv.history_size = size
  29.             optui.cancel:action()
  30.         end}
  31.  
  32.     optui.cancel = iup.stationbutton{title = 'Cancel', size = 75, action = function(self)
  33.             iup.GetDialog(self):hide()
  34.         end}
  35.  
  36.     optui.main = iup.pdarootframe{
  37.         iup.pdarootframebg{
  38.             iup.vbox{
  39.                 iup.fill{},
  40.                 iup.hbox{
  41.                     iup.fill{},
  42.                     iup.vbox{
  43.                         iup.hbox{iup.label{title = 'History Size: '}, optui.size},
  44.                         iup.hbox{optui.reset},
  45.                         gap = 5,
  46.                     },
  47.                     iup.fill{},
  48.                 },
  49.                 iup.hbox{
  50.                     iup.fill{},
  51.                     optui.save,
  52.                     optui.cancel,
  53.                     iup.fill{},
  54.                     gap = 10,
  55.                 },
  56.                 gap=10,
  57.                 iup.fill{},
  58.             },
  59.         },
  60.         expand="NO",
  61.     }
  62.  
  63.     optui.dialog = iup.dialog{
  64.         iup.vbox{
  65.             iup.fill{},
  66.                 iup.hbox{
  67.                     iup.fill{},
  68.                     optui.main,
  69.                     iup.fill{},
  70.                 },
  71.             iup.fill{},
  72.         },
  73.         defaultesc = optui.cancel,
  74.         --bgcolor = "0 0 0 128 *",
  75.         border = "NO",
  76.         resize = "NO",
  77.         menubox = "NO",
  78.         topmost = "YES",
  79.  
  80.     }
  81.  
  82.     optui.dialog:map()
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement