diff options
Diffstat (limited to 'iupe-dbuffer.lua')
-rw-r--r-- | iupe-dbuffer.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/iupe-dbuffer.lua b/iupe-dbuffer.lua new file mode 100644 index 0000000..4321206 --- /dev/null +++ b/iupe-dbuffer.lua @@ -0,0 +1,43 @@ +loadmodule "luaiup" +loadmodule "luahandle" +loadmodule "lualibs" + +if not iupep then iupep = {} end + +iupep.dbuffer = { + map_cb = function (self) + self.cv = cd.CreateCanvas(cd.IUP, self) + if not self.cv then return iup.DEFAULT end + local cvdb = cd.CreateCanvas(cd.DBUFFER, self.cv) + self.cvdb = cvdb + return iup.DEFAULT + end, + + unmap_cb = function(self) + if self.cv then cd.KillCanvas(self.cv) end + if self.cvdb then cd.KillCanvas(self.cvdb) end + end, + + resize_cb = function(self, width, height) + local cv = self.cv + local cvdb = self.cvdb + if not cvdb then + cv:Activate() + self.cvdb = cd.CreateCanvas(cd.DBUFFER, cv) + cvdb = self.cvdb + end + self.width = width + self.height = height + if not cvdb then return iup.DEFAULT end + cvdb:Activate() + return self:draw() + end, + + action = function(self, posx, posy) + local cvdb = self.cvdb + if not cvdb then return end + cvdb:Flush() + + return iup.DEFAULT + end, +} |