summaryrefslogtreecommitdiff
path: root/test/lua/cdalign.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/cdalign.wlua
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'test/lua/cdalign.wlua')
-rw-r--r--test/lua/cdalign.wlua67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/lua/cdalign.wlua b/test/lua/cdalign.wlua
new file mode 100644
index 0000000..849d258
--- /dev/null
+++ b/test/lua/cdalign.wlua
@@ -0,0 +1,67 @@
+require("iupcdaux") -- utility module used in some samples
+
+dlg = iupcdaux.new_dialog(w, h)
+cnv = dlg[1] -- retrieve the IUP canvas
+
+function DrawText(canvas, x, y, text, align)
+ canvas:TextAlignment(align)
+ canvas:Mark(x, y)
+ canvas:Text(x, y, text)
+ xmin, xmax, ymin, ymax = canvas:GetTextBox(x, y, text)
+ canvas:Rect(xmin, xmax, ymin, ymax)
+end
+
+text_aligment = {
+ cd.NORTH,
+ cd.SOUTH,
+ cd.EAST,
+ cd.WEST,
+ cd.NORTH_EAST,
+ cd.NORTH_WEST,
+ cd.SOUTH_EAST,
+ cd.SOUTH_WEST,
+ cd.CENTER,
+ cd.BASE_LEFT,
+ cd.BASE_CENTER,
+ cd.BASE_RIGHT
+}
+
+text_aligment_str = {
+ "NORTH",
+ "SOUTH",
+ "EAST",
+ "WEST",
+ "NORTH EAST",
+ "NORTH WEST",
+ "SOUTH EAST",
+ "SOUTH WEST",
+ "CENTER",
+ "BASE LEFT",
+ "BASE CENTER",
+ "BASE RIGHT"
+}
+
+
+-- custom function used in action callback
+-- from the iupcdaux module
+function cnv:Draw(canvas)
+ canvas:MarkSize(40)
+ canvas:Font("Courier", cd.PLAIN, 12)
+
+ i = 1
+ while (i <= 12) do
+ DrawText(canvas, 100, 35*i + 30, text_aligment_str[i], text_aligment[i])
+ i = i + 1
+ end
+end
+
+
+--tmpCanvas = cd.CreateCanvas(cd.PS, "cdalign.ps")
+--tmpCanvas:Clear()
+--cnv:Draw(tmpCanvas)
+--tmpCanvas:Kill()
+
+
+dlg:show()
+iup.MainLoop()
+