Skip to content

Instantly share code, notes, and snippets.

@stuartpb
Created June 9, 2011 03:17
Show Gist options
  • Save stuartpb/1015975 to your computer and use it in GitHub Desktop.
Save stuartpb/1015975 to your computer and use it in GitHub Desktop.
local iup = require "iuplua"
local cairo = require "lcairo"
local drawf, errmsg
local function showerr(hdc, err)
uhoh = cairo.CreateContext(hdc)
cairo.set_source_rgb(uhoh,1,0,0)
cairo.select_font_face (uhoh,"Consolas",
cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
cairo.paint(uhoh)
--cairo.show_text(uhoh, errmsg)
iup.Message("yo","dawg")
end
local can = iup.canvas{}
function can:action()
if drawf then
drawf(self)
elseif errmsg then
showerr(self.HWND, err)
end
end
local edit = iup.text{
multiline="YES",
font = "Consolas, 8",
expand = "YES",
value=[[
local self = ...
local cairo = require "lcairo"
local hdc = self.HWND
]]}
local run = iup.button{
title = "Run",
expand = "HORIZONTAL"
}
function run:action()
drawf, errmsg = loadstring(edit.value)
iup.Update(can)
can:action()
end
local geez = iup.vbox{edit, run}
local dlg = iup.dialog{
title = "Getting to know LuaCairo",
size = "HALFxHALF";
iup.split{
showgrip="NO",
ORIENTATION = "HORIZONTAL",
VALUE = "500";
can, geez
}
}
dlg:show()
iup.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment