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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
<head>
<title>window(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>WINDOW(3)</b><td align=right><b>WINDOW(3)</b>
<tr><td width=20><td colspan=2>
<br>
<p><font size=+1><b>NAME </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
Screen, allocscreen, publicscreen, freescreen, allocwindow, bottomwindow,
bottomnwindows, topwindow, topnwindows, originwindow – window management<br>
</table>
<p><font size=+1><b>SYNOPSIS </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>#include <u.h><br>
#include <libc.h><br>
#include <draw.h><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>typedef<br>
struct Screen<br>
{<br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
Display *display; /* display holding data */<br>
int id; /* id of system−held Screen */<br>
Image *image; /* unused; for reference only */<br>
Image *fill; /* color to paint behind windows */<br>
</table>
} Screen;<br>
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
Screen* allocscreen(Image *image, Image *fill, int public)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>Screen* publicscreen(Display *d, int id, ulong chan)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>int freescreen(Screen *s)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>Image* allocwindow(Screen *s, Rectangle r, int ref, int val)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>void bottomwindow(Image *w)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>void bottomnwindows(Image **wp, int nw)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>void topwindow(Image *w)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>void topnwindows(Image **wp, int nw)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>int originwindow(Image *w, Point log, Point scr)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>enum<br>
{<br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
/* refresh methods */<br>
Refbackup= 0,<br>
Refnone= 1,<br>
Refmesg= 2<br>
</table>
</table>
};<br>
</font></tt>
</table>
<p><font size=+1><b>DESCRIPTION </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
Windows are represented as <tt><font size=+1>Images</font></tt> and may be treated as regular
images for all drawing operations. The routines discussed here
permit the creation, deletion, and shuffling of windows, facilities
that do not apply to regular images.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
To create windows, it is first necessary to allocate a <tt><font size=+1>Screen</font></tt>
data structure to gather them together. A <tt><font size=+1>Screen</font></tt> turns an arbitrary
image into something that may have windows upon it. It is created
by <tt><font size=+1>allocscreen</font></tt>, which takes an <i>image</i> upon which to place the windows
(typically <tt><font size=+1>display−>image</font></tt>), a <i>fill</i> image
to paint the background behind all the windows on the image, and
a flag specifying whether the result should be publicly visible.
If it is public, an arbitrary other program connected to the same
display may acquire a pointer to the same screen by calling <tt><font size=+1>publicscreen</font></tt>
with the <tt><font size=+1>Display</font></tt> pointer and the <i>id</i> of the
published <tt><font size=+1>Screen</font></tt>, as well as the expected channel descriptor,
as a safety check. It will usually require some out-of-band coordination
for programs to share a screen profitably. <tt><font size=+1>Freescreen</font></tt> releases
a <tt><font size=+1>Screen</font></tt>, although it may not actually disappear from view until
all the windows upon it have also been
deallocated.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
Unlike <tt><font size=+1>allocwindow</font></tt>, <tt><font size=+1>allocscreen</font></tt> does <i>not</i> initialize the appearance
of the <tt><font size=+1>Screen</font></tt>.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
Windows are created by <tt><font size=+1>allocwindow</font></tt>, which takes a pointer to the
<tt><font size=+1>Screen</font></tt> upon which to create the window, a rectangle <i>r</i> defining
its geometry, an integer pixel value <i>val</i> to color the window initially,
and a refresh method <tt><font size=+1>ref</font></tt>. The refresh methods are <tt><font size=+1>Refbackup</font></tt>, which
provides backing store and is the
method used by <a href="../man1/rio.html"><i>rio</i>(1)</a> for its clients; <tt><font size=+1>Refnone</font></tt>, which provides
no refresh and is designed for temporary uses such as sweeping
a display rectangle, for windows that are completely covered by
other windows, and for windows that are already protected by backing
store; and <tt><font size=+1>Refmesg</font></tt>, which causes messages to be
delivered to the owner of the window when it needs to be repainted.
<tt><font size=+1>Refmesg</font></tt> is not fully implemented.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
The result of <tt><font size=+1>allocwindow</font></tt> is an <tt><font size=+1>Image</font></tt> pointer that may be treated
like any other image. In particular, it is freed by calling <tt><font size=+1>freeimage</font></tt>
(see <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>). The following functions, however, apply only
to windows, not regular images.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
<tt><font size=+1>Bottomwindow</font></tt> pushes window <i>w</i> to the bottom of the stack of windows
on its <tt><font size=+1>Screen</font></tt>, perhaps obscuring it. <tt><font size=+1>Topwindow</font></tt> pulls window <i>w</i>
to the top, making it fully visible on its <tt><font size=+1>Screen</font></tt>. (This <tt><font size=+1>Screen</font></tt>
may itself be within a window that is not fully visible; <tt><font size=+1>topwindow</font></tt>
will not affect the stacking of this parent
window.) <tt><font size=+1>Bottomnwindows</font></tt> and <tt><font size=+1>Topnwindows</font></tt> are analogous, but push
or pull a group of <i>nw</i> windows listed in the array <i>wp</i>. The order
within <i>wp</i> is unaffected.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
Each window is created as an <tt><font size=+1>Image</font></tt> whose <tt><font size=+1>Rectangle r</font></tt> corresponds
to the rectangle given to <tt><font size=+1>allocwindow</font></tt> when it was created. Thus,
a newly created window <i>w</i> resides on its <tt><font size=+1>Screen−>image</font></tt> at <i>w</i><tt><font size=+1>−>r</font></tt> and
has internal coordinates <i>w</i><tt><font size=+1>−>r</font></tt><i>.</i> Both these may be changed by a call
to <tt><font size=+1>originwindow</font></tt>. The two
<tt><font size=+1>Point</font></tt> arguments to <tt><font size=+1>originwindow</font></tt> define the upper left corner of
the logical coordinate system (<i>log</i>) and screen position (<i>scr</i>).
Their usage is shown in the Examples section.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
<a href="../man1/Rio.html"><i>Rio</i>(1)</a> creates its client windows with backing store, <tt><font size=+1>Refbackup</font></tt>.
The graphics initialization routine, <tt><font size=+1>initdraw</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>),
builds a <tt><font size=+1>Screen</font></tt> upon this, and then allocates upon that another
window indented to protect the border. That window is created
<tt><font size=+1>Refnone</font></tt>, since the backing store created by <tt><font size=+1>rio
</font></tt>protects its contents. That window is the one known in the library
by the global name <tt><font size=+1>screen</font></tt> (a historic but confusing choice).<br>
</table>
<p><font size=+1><b>EXAMPLES </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
To move a window to the upper left corner of the display,<br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>originwindow(w, w−>r.min, Pt(0, 0));<br>
</font></tt>
</table>
</table>
To leave a window where it is on the screen but change its internal
coordinate system so (0, 0) is the upper left corner of the window,<br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>originwindow(w, Pt(0, 0), w−>r.min);<br>
</font></tt>
</table>
</table>
After this is done, <tt><font size=+1>w−>r</font></tt> is translated to the origin and there
will be no way to discover the actual screen position of the window
unless it is recorded separately.<br>
</table>
<p><font size=+1><b>SOURCE </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>/usr/local/plan9/src/libdraw<br>
</font></tt>
</table>
<p><font size=+1><b>SEE ALSO </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<a href="../man3/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a><br>
</table>
<p><font size=+1><b>BUGS </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
The refresh method <tt><font size=+1>Refmesg</font></tt> should be finished.<br>
</table>
<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>
|