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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
definition module ospicture
// Clean Object I/O library, version 1.2
/* Drawing functions and other operations on Pictures.
*/
import osrgn, ostypes
from StdFunc import :: St
from osfont import :: Font
from ostoolbox import :: OSToolbox
import StdPictureDef
:: Picture
:: Origin
:== Point2
/* PA: moved to ostypes
:: OSPictContext
:== HDC
*/
:: Pen
= { penSize :: !Int // The width and height of the pen
, penForeColour :: !Colour // The drawing colour of the pen
, penBackColour :: !Colour // The background colour of the pen
, penPos :: !.Point2 // The pen position in local coordinates
, penFont :: !Font // The font information to draw text and characters
}
/* Conversion operations to and from Picture.
To open/close a picture context:
packPicture creates a Picture, given the proper OS resources. The picture is initialised.
unpackPicture unpacks a Picture, releasing the proper OS resources.
To open/close an existing picture:
peekPicture gives you the components of a Picture
unpeekPicture restores the components to a Picture
To obtain the graphics context of an existing picture:
peekOSPictContext
To obtain a read-only picture:
sharePicture creates a copy of the Picture. This copy does not occupy OS resources.
To obtain temporary access to the screen:
peekScreen creates a window picture, applies the argument function to it, and releases the OS resources.
*/
packPicture :: !Origin !*Pen !Bool !OSPictContext !*OSToolbox -> *Picture
unpeekPicture :: !Origin !*Pen !Bool !OSPictContext !*OSToolbox -> *Picture
unpackPicture :: !*Picture -> (!Origin,!*Pen,!Bool,!OSPictContext,!*OSToolbox)
peekPicture :: !*Picture -> (!Origin,!*Pen,!Bool,!OSPictContext,!*OSToolbox)
peekOSPictContext :: !*Picture -> (!OSPictContext,!*Picture)
sharePicture :: !*Picture -> (!Picture, !*Picture)
peekScreen :: !.(St *Picture .x) !*OSToolbox -> (!.x,!*OSToolbox)
defaultPen :: *Pen // The Pen for customised drawing operations
dialogPen :: *Pen // The Pen for system drawing operations
setPenAttribute :: !PenAttribute !u:Pen -> u:Pen
sharePen :: !*Pen -> (!Pen,!*Pen)
copyPen :: ! Pen -> *Pen
// Picture interface functions.
apppicttoolbox :: !(IdFun *OSToolbox) !*Picture -> *Picture
accpicttoolbox :: !(St *OSToolbox .x) !*Picture -> (!.x,!*Picture)
/* Attribute functions.
*/
// Access to Origin and Pen:
setpictpen :: !Pen !*Picture -> *Picture
getpictpen :: !*Picture -> (!Pen, !*Picture)
setpictorigin :: !Origin !*Picture -> *Picture
getpictorigin :: !*Picture -> (!Origin,!*Picture)
// PenPos attributes:
setpictpenpos :: !Point2 !*Picture -> *Picture
getpictpenpos :: !*Picture -> (!Point2,!*Picture)
movepictpenpos :: !Vector2 !*Picture -> *Picture
// Move the pen position over the given vector
// PenSize attributes:
setpictpensize :: !Int !*Picture -> *Picture
getpictpensize :: !*Picture -> (!Int,!*Picture)
// PenColour attributes:
setpictpencolour :: !Colour !*Picture -> *Picture
setpictbackcolour :: !Colour !*Picture -> *Picture
getpictpencolour :: !*Picture -> (!Colour,!*Picture)
getpictbackcolour :: !*Picture -> (!Colour,!*Picture)
toRGBtriple :: !Colour -> (!Int,!Int,!Int)
// PenFont attributes:
setpictpenfont :: !Font !*Picture -> *Picture
getpictpenfont :: !*Picture -> (!Font,!*Picture)
setpictpendefaultfont :: !*Picture -> *Picture
// setpictpendefaultfont opens and sets the defaultFont (see StdFont).
/* Drawing mode setting functions.
*/
setpictxormode :: !*Picture -> *Picture
setpicthilitemode :: !*Picture -> *Picture
setpictnormalmode :: !*Picture -> *Picture
/* Point2 drawing operations.
pictdrawpoint
only draws a point at that position. The pen position is not changed.
*/
pictdrawpoint :: !Point2 !*Picture -> *Picture
/* Line drawing operations.
pictdrawlineto
draws a line from the current pen position to the given pen position.
The new pen position is the endpoint of the line.
pictdrawline
draws a line from the first point to the second point. The pen position
is not changed.
pictundrawlineto
is the same as pictdrawlineto except that temporarily the background colour is used.
pictundrawline
is the same as pictdrawline except that temporarily the background colour is used.
*/
pictdrawlineto :: !Point2 !*Picture -> *Picture
pictdrawline :: !Point2 !Point2 !*Picture -> *Picture
pictundrawlineto :: !Point2 !*Picture -> *Picture
pictundrawline :: !Point2 !Point2 !*Picture -> *Picture
/* Text drawing operations.
pictdraw(char/string) draws a char/string at the current pen position. The new
pen position is immediately after the drawn char/string.
*/
pictdrawchar :: !Char !*Picture -> *Picture
pictundrawchar :: !Char !*Picture -> *Picture
pictdrawstring :: !String !*Picture -> *Picture
pictundrawstring :: !String !*Picture -> *Picture
/* Oval drawing operations.
pict(draw/fill)oval center oval
draws/fills an oval at center with horizontal and vertical radius. The new
pen position is not changed.
pict(undraw/unfill)oval center oval
draw/fill an oval at center with horizontal and vertical radius using the
background colour of the picture.
*/
pictdrawoval :: !Point2 !Oval !*Picture -> *Picture
pictfilloval :: !Point2 !Oval !*Picture -> *Picture
pictundrawoval :: !Point2 !Oval !*Picture -> *Picture
pictunfilloval :: !Point2 !Oval !*Picture -> *Picture
/* Curve drawing operations.
pict(draw/fill)curve movePen point curve
draws/fills a curve starting at point with a shape defined by curve. If movePen
is True, then the new pen position is at the end of the curve, otherwise it does
not change.
pictun(draw/fill)curve
is equal to pict(draw/fill)curve, using the background colour temporarily.
getcurve_rect_begin_end point curve
returns the enclosing rect of the curve and begin and end point lying on that
curve.
*/
pictdrawcurve :: !Bool !Point2 !Curve !*Picture -> *Picture
pictundrawcurve :: !Bool !Point2 !Curve !*Picture -> *Picture
pictfillcurve :: !Bool !Point2 !Curve !*Picture -> *Picture
pictunfillcurve :: !Bool !Point2 !Curve !*Picture -> *Picture
getcurve_rect_begin_end :: !Point2 !Curve -> (!OSRect,!Point2,!Point2)
/* OSRect drawing operations.
pict(draw/fill)rect rect
draws/fills a rect. The pen position is not changed.
pictun(draw/fill)rect
is equal to pict(draw/fill)rect, using the background colour temporarily.
*/
pictdrawrect :: !OSRect !*Picture -> *Picture
pictundrawrect :: !OSRect !*Picture -> *Picture
pictfillrect :: !OSRect !*Picture -> *Picture
pictunfillrect :: !OSRect !*Picture -> *Picture
/* Scrolling operation (handle with care).
*/
pictscroll :: !OSRect !Vector2 !*Picture -> (!OSRect,!*Picture)
pictscroll2 :: !OSRect !Vector2 !*Picture -> (!OSRect,!*Picture)
/* Polygon drawing operations.
pict(draw/fill)polygon point polygon
draws/fills a polygon starting at point. The pen position is not changed.
pictun(draw/fill)polygon
is equal to pict(draw/fill)polygon, using the background colour temporarily.
*/
pictdrawpolygon :: !Point2 !Polygon !*Picture -> *Picture
pictundrawpolygon :: !Point2 !Polygon !*Picture -> *Picture
pictfillpolygon :: !Point2 !Polygon !*Picture -> *Picture
pictunfillpolygon :: !Point2 !Polygon !*Picture -> *Picture
/* Clipping operations.
pictgetcliprgn gets the current clipping region.
pictsetcliprgn sets the given clipping region.
pictandcliprgn takes the intersection of the current clipping region and the argument region.
*/
pictgetcliprgn :: !*Picture -> (!OSRgnHandle,!*Picture)
pictsetcliprgn :: !OSRgnHandle !*Picture -> *Picture
pictandcliprgn :: !OSRgnHandle !*Picture -> *Picture
/* Resolution access function (added by MW):
*/
getResolutionC :: !OSPictContext !*OSToolbox -> (!(!Int,!Int),!*OSToolbox)
// MW: scaling of screen coordinates to printer coordinates.
getPictureScalingFactors:: !OSPictContext !*OSToolbox -> (!(!Int,!Int),!(!Int,!Int),!OSPictContext,!*OSToolbox)
getpictpenattributes :: !*Picture -> (![PenAttribute],!*Picture)
getPenPenPos :: !*Pen -> (!Point2,!*Pen)
|