diff options
author | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:56:41 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:59:33 -0800 |
commit | d577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch) | |
tree | 590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /cd/test/lua/cdalign.wlua |
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'cd/test/lua/cdalign.wlua')
-rwxr-xr-x | cd/test/lua/cdalign.wlua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/cd/test/lua/cdalign.wlua b/cd/test/lua/cdalign.wlua new file mode 100755 index 0000000..849d258 --- /dev/null +++ b/cd/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() + |