From d577d991b97ae2b5ee1af23641bcffc3f83af5b2 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 4 Nov 2009 11:56:41 -0800 Subject: Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux. --- cd/test/lua/iuplua_cdlua.wlua | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 cd/test/lua/iuplua_cdlua.wlua (limited to 'cd/test/lua/iuplua_cdlua.wlua') diff --git a/cd/test/lua/iuplua_cdlua.wlua b/cd/test/lua/iuplua_cdlua.wlua new file mode 100755 index 0000000..5528117 --- /dev/null +++ b/cd/test/lua/iuplua_cdlua.wlua @@ -0,0 +1,58 @@ +require"cdlua" +require"iuplua" +require"iupluacd" + +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