From 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:33 +0000 Subject: First commit - moving from LuaForge to SourceForge --- test/lua/iuplua_cdlua.wlua | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/lua/iuplua_cdlua.wlua (limited to 'test/lua/iuplua_cdlua.wlua') diff --git a/test/lua/iuplua_cdlua.wlua b/test/lua/iuplua_cdlua.wlua new file mode 100644 index 0000000..f595987 --- /dev/null +++ b/test/lua/iuplua_cdlua.wlua @@ -0,0 +1,58 @@ +require"iuplua" +require"cdlua" +require"cdluaiup" + +cnv = iup.canvas {size = "200x100"} + +box = iup.vbox{ + iup.button { title="Version" }, + cnv, + iup.button { title="Close" }, + } + +dlg = iup.dialog{box; title="Example IUPLUA/CDLUA"} + +function cnv:map_cb() + canvas = cd.CreateCanvas(cd.IUP, self) + self.canvas = canvas -- store the CD canvas in a IUP attribute +end + +function dlg:close_cb() + cnv = self[1][2] + canvas = cnv.canvas -- retrieve the CD canvas from the IUP attribute + canvas:Kill() + self:destroy() + return iup.IGNORE -- because we destroy the dialog +end + +bt_version = dlg[1][1] +function bt_version:action() + iup.Message("Version", "CD Version: " .. cd.Version() .. "\nIUP Version: " .. iup.Version() .. "\n" .. _VERSION) +end + +bt_close = dlg[1][3] +function bt_close:action() + return iup.CLOSE +end + +function cnv:action() + canvas = self.canvas -- retrieve the CD canvas from the IUP attribute + + canvas:Activate() + canvas:Clear() + canvas:Foreground (cd.RED) + canvas:Box (10, 55, 10, 55) + canvas:Foreground(cd.EncodeColor(255, 32, 140)) + canvas:Line(0, 0, 300, 100) +end + +function cnv:button_cb(b, e, x, y, r) + print ("Button: " .. "Button="..tostring(b).." Pressed="..tostring(e).." X="..tostring(x).." Y="..tostring(y) ) +end + +function cnv:resize_cb(w, h) + print("Resize: Width="..w.." Height="..h) +end + +dlg:show() +iup.MainLoop() -- cgit v1.2.3