Commit | Line | Data |
---|---|---|
42873e30 KL |
1 | /* |
2 | * Jexer - Java Text User Interface | |
3 | * | |
4 | * The MIT License (MIT) | |
5 | * | |
6 | * Copyright (C) 2017 Kevin Lamonte | |
7 | * | |
8 | * Permission is hereby granted, free of charge, to any person obtaining a | |
9 | * copy of this software and associated documentation files (the "Software"), | |
10 | * to deal in the Software without restriction, including without limitation | |
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
12 | * and/or sell copies of the Software, and to permit persons to whom the | |
13 | * Software is furnished to do so, subject to the following conditions: | |
14 | * | |
15 | * The above copyright notice and this permission notice shall be included in | |
16 | * all copies or substantial portions of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
24 | * DEALINGS IN THE SOFTWARE. | |
25 | * | |
26 | * @author Kevin Lamonte [kevin.lamonte@gmail.com] | |
27 | * @version 1 | |
28 | */ | |
29 | package jexer.backend; | |
30 | ||
31 | import jexer.bits.Cell; | |
32 | import jexer.bits.CellAttributes; | |
33 | ||
34 | /** | |
35 | * Drawing operations API. | |
36 | */ | |
37 | public interface Screen { | |
38 | ||
39 | /** | |
40 | * Set drawing offset for x. | |
41 | * | |
42 | * @param offsetX new drawing offset | |
43 | */ | |
44 | public void setOffsetX(final int offsetX); | |
45 | ||
46 | /** | |
47 | * Set drawing offset for y. | |
48 | * | |
49 | * @param offsetY new drawing offset | |
50 | */ | |
51 | public void setOffsetY(final int offsetY); | |
52 | ||
53 | /** | |
54 | * Get right drawing clipping boundary. | |
55 | * | |
56 | * @return drawing boundary | |
57 | */ | |
58 | public int getClipRight(); | |
59 | ||
60 | /** | |
61 | * Set right drawing clipping boundary. | |
62 | * | |
63 | * @param clipRight new boundary | |
64 | */ | |
65 | public void setClipRight(final int clipRight); | |
66 | ||
67 | /** | |
68 | * Get bottom drawing clipping boundary. | |
69 | * | |
70 | * @return drawing boundary | |
71 | */ | |
72 | public int getClipBottom(); | |
73 | ||
74 | /** | |
75 | * Set bottom drawing clipping boundary. | |
76 | * | |
77 | * @param clipBottom new boundary | |
78 | */ | |
79 | public void setClipBottom(final int clipBottom); | |
80 | ||
81 | /** | |
82 | * Get left drawing clipping boundary. | |
83 | * | |
84 | * @return drawing boundary | |
85 | */ | |
86 | public int getClipLeft(); | |
87 | ||
88 | /** | |
89 | * Set left drawing clipping boundary. | |
90 | * | |
91 | * @param clipLeft new boundary | |
92 | */ | |
93 | public void setClipLeft(final int clipLeft); | |
94 | ||
95 | /** | |
96 | * Get top drawing clipping boundary. | |
97 | * | |
98 | * @return drawing boundary | |
99 | */ | |
100 | public int getClipTop(); | |
101 | ||
102 | /** | |
103 | * Set top drawing clipping boundary. | |
104 | * | |
105 | * @param clipTop new boundary | |
106 | */ | |
107 | public void setClipTop(final int clipTop); | |
108 | ||
109 | /** | |
110 | * Get dirty flag. | |
111 | * | |
112 | * @return if true, the logical screen is not in sync with the physical | |
113 | * screen | |
114 | */ | |
115 | public boolean isDirty(); | |
116 | ||
117 | /** | |
118 | * Get the attributes at one location. | |
119 | * | |
120 | * @param x column coordinate. 0 is the left-most column. | |
121 | * @param y row coordinate. 0 is the top-most row. | |
122 | * @return attributes at (x, y) | |
123 | */ | |
124 | public CellAttributes getAttrXY(final int x, final int y); | |
125 | ||
126 | /** | |
127 | * Set the attributes at one location. | |
128 | * | |
129 | * @param x column coordinate. 0 is the left-most column. | |
130 | * @param y row coordinate. 0 is the top-most row. | |
131 | * @param attr attributes to use (bold, foreColor, backColor) | |
132 | */ | |
133 | public void putAttrXY(final int x, final int y, | |
134 | final CellAttributes attr); | |
135 | ||
136 | /** | |
137 | * Set the attributes at one location. | |
138 | * | |
139 | * @param x column coordinate. 0 is the left-most column. | |
140 | * @param y row coordinate. 0 is the top-most row. | |
141 | * @param attr attributes to use (bold, foreColor, backColor) | |
142 | * @param clip if true, honor clipping/offset | |
143 | */ | |
144 | public void putAttrXY(final int x, final int y, | |
145 | final CellAttributes attr, final boolean clip); | |
146 | ||
147 | /** | |
148 | * Fill the entire screen with one character with attributes. | |
149 | * | |
150 | * @param ch character to draw | |
151 | * @param attr attributes to use (bold, foreColor, backColor) | |
152 | */ | |
153 | public void putAll(final char ch, final CellAttributes attr); | |
154 | ||
155 | /** | |
156 | * Render one character with attributes. | |
157 | * | |
158 | * @param x column coordinate. 0 is the left-most column. | |
159 | * @param y row coordinate. 0 is the top-most row. | |
160 | * @param ch character + attributes to draw | |
161 | */ | |
162 | public void putCharXY(final int x, final int y, final Cell ch); | |
163 | ||
164 | /** | |
165 | * Render one character with attributes. | |
166 | * | |
167 | * @param x column coordinate. 0 is the left-most column. | |
168 | * @param y row coordinate. 0 is the top-most row. | |
169 | * @param ch character to draw | |
170 | * @param attr attributes to use (bold, foreColor, backColor) | |
171 | */ | |
172 | public void putCharXY(final int x, final int y, final char ch, | |
173 | final CellAttributes attr); | |
174 | ||
175 | /** | |
176 | * Render one character without changing the underlying attributes. | |
177 | * | |
178 | * @param x column coordinate. 0 is the left-most column. | |
179 | * @param y row coordinate. 0 is the top-most row. | |
180 | * @param ch character to draw | |
181 | */ | |
182 | public void putCharXY(final int x, final int y, final char ch); | |
183 | ||
184 | /** | |
185 | * Render a string. Does not wrap if the string exceeds the line. | |
186 | * | |
187 | * @param x column coordinate. 0 is the left-most column. | |
188 | * @param y row coordinate. 0 is the top-most row. | |
189 | * @param str string to draw | |
190 | * @param attr attributes to use (bold, foreColor, backColor) | |
191 | */ | |
192 | public void putStringXY(final int x, final int y, final String str, | |
193 | final CellAttributes attr); | |
194 | ||
195 | /** | |
196 | * Render a string without changing the underlying attribute. Does not | |
197 | * wrap if the string exceeds the line. | |
198 | * | |
199 | * @param x column coordinate. 0 is the left-most column. | |
200 | * @param y row coordinate. 0 is the top-most row. | |
201 | * @param str string to draw | |
202 | */ | |
203 | public void putStringXY(final int x, final int y, final String str); | |
204 | ||
205 | /** | |
206 | * Draw a vertical line from (x, y) to (x, y + n). | |
207 | * | |
208 | * @param x column coordinate. 0 is the left-most column. | |
209 | * @param y row coordinate. 0 is the top-most row. | |
210 | * @param n number of characters to draw | |
211 | * @param ch character to draw | |
212 | * @param attr attributes to use (bold, foreColor, backColor) | |
213 | */ | |
214 | public void vLineXY(final int x, final int y, final int n, | |
215 | final char ch, final CellAttributes attr); | |
216 | ||
217 | /** | |
218 | * Draw a horizontal line from (x, y) to (x + n, y). | |
219 | * | |
220 | * @param x column coordinate. 0 is the left-most column. | |
221 | * @param y row coordinate. 0 is the top-most row. | |
222 | * @param n number of characters to draw | |
223 | * @param ch character to draw | |
224 | * @param attr attributes to use (bold, foreColor, backColor) | |
225 | */ | |
226 | public void hLineXY(final int x, final int y, final int n, | |
227 | final char ch, final CellAttributes attr); | |
228 | ||
229 | /** | |
230 | * Change the width. Everything on-screen will be destroyed and must be | |
231 | * redrawn. | |
232 | * | |
233 | * @param width new screen width | |
234 | */ | |
235 | public void setWidth(final int width); | |
236 | ||
237 | /** | |
238 | * Change the height. Everything on-screen will be destroyed and must be | |
239 | * redrawn. | |
240 | * | |
241 | * @param height new screen height | |
242 | */ | |
243 | public void setHeight(final int height); | |
244 | ||
245 | /** | |
246 | * Change the width and height. Everything on-screen will be destroyed | |
247 | * and must be redrawn. | |
248 | * | |
249 | * @param width new screen width | |
250 | * @param height new screen height | |
251 | */ | |
252 | public void setDimensions(final int width, final int height); | |
253 | ||
254 | /** | |
255 | * Get the height. | |
256 | * | |
257 | * @return current screen height | |
258 | */ | |
259 | public int getHeight(); | |
260 | ||
261 | /** | |
262 | * Get the width. | |
263 | * | |
264 | * @return current screen width | |
265 | */ | |
266 | public int getWidth(); | |
267 | ||
268 | /** | |
269 | * Reset screen to not-bold, white-on-black. Also flushes the offset and | |
270 | * clip variables. | |
271 | */ | |
272 | public void reset(); | |
273 | ||
274 | /** | |
275 | * Flush the offset and clip variables. | |
276 | */ | |
277 | public void resetClipping(); | |
278 | ||
279 | /** | |
280 | * Clear the logical screen. | |
281 | */ | |
282 | public void clear(); | |
283 | ||
284 | /** | |
285 | * Draw a box with a border and empty background. | |
286 | * | |
287 | * @param left left column of box. 0 is the left-most row. | |
288 | * @param top top row of the box. 0 is the top-most row. | |
289 | * @param right right column of box | |
290 | * @param bottom bottom row of the box | |
291 | * @param border attributes to use for the border | |
292 | * @param background attributes to use for the background | |
293 | */ | |
294 | public void drawBox(final int left, final int top, | |
295 | final int right, final int bottom, | |
296 | final CellAttributes border, final CellAttributes background); | |
297 | ||
298 | /** | |
299 | * Draw a box with a border and empty background. | |
300 | * | |
301 | * @param left left column of box. 0 is the left-most row. | |
302 | * @param top top row of the box. 0 is the top-most row. | |
303 | * @param right right column of box | |
304 | * @param bottom bottom row of the box | |
305 | * @param border attributes to use for the border | |
306 | * @param background attributes to use for the background | |
307 | * @param borderType if 1, draw a single-line border; if 2, draw a | |
308 | * double-line border; if 3, draw double-line top/bottom edges and | |
309 | * single-line left/right edges (like Qmodem) | |
310 | * @param shadow if true, draw a "shadow" on the box | |
311 | */ | |
312 | public void drawBox(final int left, final int top, | |
313 | final int right, final int bottom, | |
314 | final CellAttributes border, final CellAttributes background, | |
315 | final int borderType, final boolean shadow); | |
316 | ||
317 | /** | |
318 | * Draw a box shadow. | |
319 | * | |
320 | * @param left left column of box. 0 is the left-most row. | |
321 | * @param top top row of the box. 0 is the top-most row. | |
322 | * @param right right column of box | |
323 | * @param bottom bottom row of the box | |
324 | */ | |
325 | public void drawBoxShadow(final int left, final int top, | |
326 | final int right, final int bottom); | |
327 | ||
328 | /** | |
329 | * Classes must provide an implementation to push the logical screen to | |
330 | * the physical device. | |
331 | */ | |
332 | public void flushPhysical(); | |
333 | ||
334 | /** | |
335 | * Put the cursor at (x,y). | |
336 | * | |
337 | * @param visible if true, the cursor should be visible | |
338 | * @param x column coordinate to put the cursor on | |
339 | * @param y row coordinate to put the cursor on | |
340 | */ | |
341 | public void putCursor(final boolean visible, final int x, final int y); | |
342 | ||
343 | /** | |
344 | * Hide the cursor. | |
345 | */ | |
346 | public void hideCursor(); | |
347 | ||
348 | /** | |
349 | * Set the window title. | |
350 | * | |
351 | * @param title the new title | |
352 | */ | |
353 | public void setTitle(final String title); | |
354 | ||
355 | } |