1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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()
|