From 92cdbe1ba01767bc95358696cc7a741a67b2c889 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 26 Dec 2009 01:11:16 +0100 Subject: Adding a little bit more output on the configuration matrix. --- dalos-struct.lua | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 127 insertions(+), 8 deletions(-) (limited to 'dalos-struct.lua') diff --git a/dalos-struct.lua b/dalos-struct.lua index 3451319..350e329 100644 --- a/dalos-struct.lua +++ b/dalos-struct.lua @@ -1,9 +1,31 @@ +local function imLoadImage(fname) + local f = im.FileOpen(fname) + local r = f:LoadImage() + f:Close() + return r +end + dalosp.struct = { images = { - up = iup.LoadImage "12-em-up.tga", - down = iup.LoadImage "12-em-down.tga", - cross = iup.LoadImage "12-em-cross.tga", - plus = iup.LoadImage "12-em-plus.tga", + up = imLoadImage "12-em-up.tga", + down = imLoadImage "12-em-down.tga", + cross = imLoadImage "12-em-cross.tga", + plus = imLoadImage "12-em-plus.tga", + }, + + types = { + "int8", + "uint8", + "int16", + "uint16", + "int32", + "uint32", + "int64", + "uint64", + "float", + "double", + "asciiz", + "nascii", }, get_settings = function (self) @@ -20,6 +42,76 @@ dalosp.struct = { input_change = function (self) end, + cfg_draw_cb = function (self, lin, col, x1, x2, y1, y2, cv) + if col == 1 then + dalosp.struct.images.plus:cdCanvasPutImageRect(cv, x1 + 3, y2 + 5, 12, 12, 0, 12, 0, 12) + return iup.DEFAULT + elseif col == 2 and lin ~= 0 then + dalosp.struct.images.cross:cdCanvasPutImageRect(cv, x1 + 3, y2 + 5, 12, 12, 0, 12, 0, 12) + return iup.DEFAULT + elseif col == 3 and lin ~= 0 then + dalosp.struct.images.up:cdCanvasPutImageRect(cv, x1 + 3, y2 + 5, 12, 12, 0, 12, 0, 12) + return iup.DEFAULT + elseif col == 4 and lin ~= 0 then + dalosp.struct.images.down:cdCanvasPutImageRect(cv, x1 + 3, y2 + 5, 12, 12, 0, 12, 0, 12) + return iup.DEFAULT + end + + return iup.IGNORE + end, + + cfg_click_cb = function (self, lin, col, status) + if col == 1 and lin == 0 then return self.struct:insert_line() end + end, + + cfg_value_cb = function (self, lin, col) + if lin == 0 then + if col == 5 then + return "Name" + elseif col == 6 then + return "Type" + elseif col == 7 then + return "Size" + elseif col == 8 then + return "CumSize" + end + end + + return "" + end, + + cfg_value_edit_cb = function (self, lin, col, newval) + end, + + insert_line = function (self) + local mx = self.cfg_dlg.mx + mx.numlin = mx.numlin + 1 + mx.numlin_visible = mx.numlin_visible + 1 + end, + + cfg_dropcheck_cb = function (self, lin, col) + return col == 6 and iup.DEFAULT or iup.IGNORE + end, + + cfg_edition_cb = function (self, lin, col, mode, update) + if mode == 1 then + return (col >= 5 and col <= 7) and iup.DEFAULT or iup.IGNORE + else + return iup.DEFAULT + end + end, + + cfg_drop_cb = function (self, drop, lin, col) + if col ~= 6 then return iup.IGNORE end + + for i, v in ipairs(dalosp.struct.types) do + drop[i] = v + end + drop.value = self.previousvalue + + return iup.DEFAULT + end, + create = function (d, tab, settings) tab.ninputs = 1 tab.noutputs = 0 @@ -28,6 +120,9 @@ dalosp.struct = { tab.activate = dalosp.struct.activate tab.input_change = dalosp.struct.input_change tab.get_settings = dalosp.struct.get_settings + tab.draw = function (self, cv, x, y, w, h) + dalosp.object.default_draw(self, cv, x, y, w, h) + end tab.default_name = "Struct" tab.ntype = "Struct" @@ -36,8 +131,32 @@ dalosp.struct = { local obj = dalos.object(d, tab, extra) - local cmx = iup.matrix {} - cmx.draw_cb = dalosp.struct.cfg_draw_cb + obj.insert_line = dalosp.struct.insert_line + + local cmx = iup.matrix { + numcol = 8, + numcol_visible = 8, + usetitlesize = "Yes", + rasterwidth1 = 12, + rasterwidth2 = 12, + rasterwidth3 = 12, + rasterwidth4 = 12, + rasterwidth5 = 150, + rasterwidth6 = 80, + rasterwidth7 = 80, + rasterwidth8 = 80, + resizematrix = "Yes", + readonly = "No", + draw_cb = dalosp.struct.cfg_draw_cb, + value_cb = dalosp.struct.cfg_value_cb, + value_edit_cb = dalosp.struct.cfg_value_edit_cb, + dropcheck_cb = dalosp.struct.cfg_dropcheck_cb, + drop_cb = dalosp.struct.cfg_drop_cb, + edition_cb = dalosp.struct.cfg_edition_cb, + click_cb = dalosp.struct.cfg_click_cb, + struct = obj, + } + local amx = iup.matrix {} obj.cfg_dlg = iup.dialog { iup.vbox { @@ -51,12 +170,12 @@ dalosp.struct = { iup.fill {}, }, }, + + size = "350x120", } obj.cfg_dlg.mx = cmx - local amx = iup.matrix {} - obj.actv_dlg = iup.dialog { amx, } -- cgit v1.2.3