--IupDialog Example in IupLua --Creates a simple dialog. require("cdlua") require("iuplua") require("iupluacd") require("iupluagl") require("iupluaglcontrols") require("iuplua_mglplot") mgp = iup.mglplot{size = "400x100", title="It parse TeX: \\int \\alpha \\cdot \\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx", axs_x="NO", axs_y="NO", cx=50, cy=300} tb = iup.text{size = "400x100", expand="YES", value="I ignore the 'g' key!", border="NO", BGCOLOR = "255 255 255", cx=50,cy=50} cbox = iup.cbox{mgp,tb; size="500x500"} cnvbox = iup.glcanvasbox{ cbox; BGCOLOR="200 200 200", scrollbar="YES" } dlg = iup.dialog{cnvbox; title="Dialog", size="100x100"} dlg:show() canvas = cd.CreateCanvas(cd.IUP, cnvbox) function cnvbox:motion_cb(x, y, r) print(x, y, r) end function cnvbox:keypress_cb(c,press) if c==iup.K_UP and press == 1 then tb.cy = tb.cy-5 print("MOVE UP") iup.Refresh(dlg,1) elseif c==iup.K_DOWN and press == 1 then tb.cy = tb.cy + 5 print("MOVE DOWN") iup.Refresh(dlg,1) elseif c==iup.K_LEFT and press == 1 then tb.cx = tb.cx - 5 print("MOVE LEFT") iup.Refresh(dlg,1) elseif c==iup.K_RIGHT and press == 1 then tb.cx = tb.cx+5 print("MOVE RIGHT") iup.Refresh(dlg,1) elseif c == iup.K_A and press == 1 then print("A pressed") canvas:LineStyle(cd.CONTINUOUS) canvas:LineWidth(3) canvas:Line(5,5,100,5) canvas:Rect(tb.cx,tb.cx+400,tb.cy-10,tb.cy-5) iup.Refresh(dlg,1) print(cbox.size,cnvbox.size,tb.size,mgp.size) elseif c == iup.K_B and press == 1 then elseif c == iup.K_C and press == 1 then end end function tb:motion_cb(x, y, r) print(x, y, r) end function cnvbox:action(posx, posy) canvas:Activate() canvas:SetBackground(cd.CYAN) canvas:Clear() --self:fill(self.bgcolor) end function cnvbox:fill(color) canvas:SetForeground(cd.CYAN) local w,h = canvas:GetSize() canvas:Box(0,w,0,h) end if (iup.MainLoopLevel()==0) then iup.MainLoop() end