2 * Jexer - Java Text User Interface
4 * The MIT License (MIT)
6 * Copyright (C) 2017 Kevin Lamonte
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:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
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.
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 package jexer
.backend
;
31 import jexer
.bits
.Cell
;
32 import jexer
.bits
.CellAttributes
;
35 * Drawing operations API.
37 public interface Screen
{
40 * Set drawing offset for x.
42 * @param offsetX new drawing offset
44 public void setOffsetX(final int offsetX
);
47 * Set drawing offset for y.
49 * @param offsetY new drawing offset
51 public void setOffsetY(final int offsetY
);
54 * Get right drawing clipping boundary.
56 * @return drawing boundary
58 public int getClipRight();
61 * Set right drawing clipping boundary.
63 * @param clipRight new boundary
65 public void setClipRight(final int clipRight
);
68 * Get bottom drawing clipping boundary.
70 * @return drawing boundary
72 public int getClipBottom();
75 * Set bottom drawing clipping boundary.
77 * @param clipBottom new boundary
79 public void setClipBottom(final int clipBottom
);
82 * Get left drawing clipping boundary.
84 * @return drawing boundary
86 public int getClipLeft();
89 * Set left drawing clipping boundary.
91 * @param clipLeft new boundary
93 public void setClipLeft(final int clipLeft
);
96 * Get top drawing clipping boundary.
98 * @return drawing boundary
100 public int getClipTop();
103 * Set top drawing clipping boundary.
105 * @param clipTop new boundary
107 public void setClipTop(final int clipTop
);
112 * @return if true, the logical screen is not in sync with the physical
115 public boolean isDirty();
118 * Get the attributes at one location.
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)
124 public CellAttributes
getAttrXY(final int x
, final int y
);
127 * Set the attributes at one location.
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)
133 public void putAttrXY(final int x
, final int y
,
134 final CellAttributes attr
);
137 * Set the attributes at one location.
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
144 public void putAttrXY(final int x
, final int y
,
145 final CellAttributes attr
, final boolean clip
);
148 * Fill the entire screen with one character with attributes.
150 * @param ch character to draw
151 * @param attr attributes to use (bold, foreColor, backColor)
153 public void putAll(final char ch
, final CellAttributes attr
);
156 * Render one character with attributes.
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
162 public void putCharXY(final int x
, final int y
, final Cell ch
);
165 * Render one character with attributes.
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)
172 public void putCharXY(final int x
, final int y
, final char ch
,
173 final CellAttributes attr
);
176 * Render one character without changing the underlying attributes.
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
182 public void putCharXY(final int x
, final int y
, final char ch
);
185 * Render a string. Does not wrap if the string exceeds the line.
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)
192 public void putStringXY(final int x
, final int y
, final String str
,
193 final CellAttributes attr
);
196 * Render a string without changing the underlying attribute. Does not
197 * wrap if the string exceeds the line.
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
203 public void putStringXY(final int x
, final int y
, final String str
);
206 * Draw a vertical line from (x, y) to (x, y + n).
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)
214 public void vLineXY(final int x
, final int y
, final int n
,
215 final char ch
, final CellAttributes attr
);
218 * Draw a horizontal line from (x, y) to (x + n, y).
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)
226 public void hLineXY(final int x
, final int y
, final int n
,
227 final char ch
, final CellAttributes attr
);
230 * Change the width. Everything on-screen will be destroyed and must be
233 * @param width new screen width
235 public void setWidth(final int width
);
238 * Change the height. Everything on-screen will be destroyed and must be
241 * @param height new screen height
243 public void setHeight(final int height
);
246 * Change the width and height. Everything on-screen will be destroyed
247 * and must be redrawn.
249 * @param width new screen width
250 * @param height new screen height
252 public void setDimensions(final int width
, final int height
);
257 * @return current screen height
259 public int getHeight();
264 * @return current screen width
266 public int getWidth();
269 * Reset screen to not-bold, white-on-black. Also flushes the offset and
275 * Flush the offset and clip variables.
277 public void resetClipping();
280 * Clear the logical screen.
285 * Draw a box with a border and empty background.
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
294 public void drawBox(final int left
, final int top
,
295 final int right
, final int bottom
,
296 final CellAttributes border
, final CellAttributes background
);
299 * Draw a box with a border and empty background.
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
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
);
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
325 public void drawBoxShadow(final int left
, final int top
,
326 final int right
, final int bottom
);
329 * Classes must provide an implementation to push the logical screen to
330 * the physical device.
332 public void flushPhysical();
335 * Put the cursor at (x,y).
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
341 public void putCursor(final boolean visible
, final int x
, final int y
);
346 public void hideCursor();
349 * Set the window title.
351 * @param title the new title
353 public void setTitle(final String title
);