summaryrefslogtreecommitdiff
path: root/test/lua/cdtext.wlua
diff options
context:
space:
mode:
authorscuri <scuri>2008-10-17 06:10:33 +0000
committerscuri <scuri>2008-10-17 06:10:33 +0000
commit7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf (patch)
treed0857278bde2eff784227c57dcaf930346ceb7ac /test/lua/cdtext.wlua
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'test/lua/cdtext.wlua')
-rw-r--r--test/lua/cdtext.wlua59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/lua/cdtext.wlua b/test/lua/cdtext.wlua
new file mode 100644
index 0000000..556d02f
--- /dev/null
+++ b/test/lua/cdtext.wlua
@@ -0,0 +1,59 @@
+require("iupcdaux") -- utility module used in some samples
+
+--require"cdluacontextplus"
+--cd.UseContextPlus(1)
+
+dlg = iupcdaux.new_dialog(w, h)
+cnv = dlg[1] -- retrieve the IUP canvas
+
+function DrawTextBox(canvas, x, y, text)
+ canvas:Mark(x, y)
+ canvas:Text(x, y, text)
+ w, h = canvas:GetTextSize(text)
+ xmin = x - w/2
+ ymin = y - h/2
+ xmax = x + w/2
+ ymax = y + h/2
+ canvas:Line(xmin, ymin, xmax, ymin)
+ canvas:Line(xmin, ymin, xmin, ymax)
+ canvas:Line(xmin, ymax, xmax, ymax)
+ canvas:Line(xmax, ymin, xmax, ymax)
+end
+
+-- custom function used in action callback
+-- from the iupcdaux module
+function cnv:Draw(canvas)
+
+ -- Available in ContextPlus drivers or in IMAGERGB driver
+ -- canvas:SetAttribute("ANTIALIAS", "1")
+
+ canvas:TextAlignment(cd.CENTER)
+ canvas:MarkSize(40)
+
+ canvas:Font("Courier", cd.PLAIN, 12)
+ local aa = canvas:GetAttribute("ANTIALIAS")
+ if (aa == "1") then
+ DrawTextBox(canvas, 130, 30, "ANTIALIAS=1")
+ else
+ DrawTextBox(canvas, 130, 30, "ANTIALIAS=0")
+ end
+
+ canvas:Font("Courier", cd.ITALIC, 34)
+ DrawTextBox(canvas, 130, 160, "xxxxxppx")
+
+ canvas:Font("Times", cd.PLAIN, 12)
+ DrawTextBox(canvas, 130, 290, "taaaa")
+
+ canvas:Font("Times", cd.BOLD, 14)
+ DrawTextBox(canvas, 130, 370, "gggggggg")
+end
+
+
+--tmpCanvas = cd.CreateCanvas(cd.PS, "cdtext.ps")
+--tmpCanvas:Clear()
+--cnv:Draw(tmpCanvas)
+--tmpCanvas:Kill()
+
+
+dlg:show()
+iup.MainLoop()