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]
31 import java
.util
.HashSet
;
33 import jexer
.bits
.Cell
;
34 import jexer
.bits
.CellAttributes
;
35 import jexer
.bits
.GraphicsChars
;
36 import jexer
.event
.TCommandEvent
;
37 import jexer
.event
.TKeypressEvent
;
38 import jexer
.event
.TMenuEvent
;
39 import jexer
.event
.TMouseEvent
;
40 import jexer
.event
.TResizeEvent
;
41 import jexer
.io
.Screen
;
42 import jexer
.menu
.TMenu
;
43 import static jexer
.TCommand
.*;
44 import static jexer
.TKeypress
.*;
47 * TWindow is the top-level container and drawing surface for other widgets.
49 public class TWindow
extends TWidget
{
51 // ------------------------------------------------------------------------
52 // Public constants -------------------------------------------------------
53 // ------------------------------------------------------------------------
56 * Window is resizable (default yes).
58 public static final int RESIZABLE
= 0x01;
61 * Window is modal (default no).
63 public static final int MODAL
= 0x02;
66 * Window is centered (default no).
68 public static final int CENTERED
= 0x04;
70 // ------------------------------------------------------------------------
71 // Common window attributes -----------------------------------------------
72 // ------------------------------------------------------------------------
75 * Window flags. Note package private access.
77 int flags
= RESIZABLE
;
82 private String title
= "";
87 * @return window title
89 public final String
getTitle() {
96 * @param title new window title
98 public final void setTitle(final String title
) {
102 // ------------------------------------------------------------------------
103 // TApplication integration -----------------------------------------------
104 // ------------------------------------------------------------------------
107 * Window's parent TApplication.
109 private TApplication application
;
112 * Get this TWindow's parent TApplication.
114 * @return this TWindow's parent TApplication
117 public final TApplication
getApplication() {
127 public final Screen
getScreen() {
128 return application
.getScreen();
132 * Z order. Lower number means more in-front.
137 * Get Z order. Lower number means more in-front.
139 * @return Z value. Lower number means more in-front.
141 public final int getZ() {
146 * Set Z order. Lower number means more in-front.
148 * @param z the new Z value. Lower number means more in-front.
150 public final void setZ(final int z
) {
155 * Window's keyboard shortcuts. Any key in this set will be passed to
156 * the window directly rather than processed through the menu
159 private HashSet
<TKeypress
> keyboardShortcuts
= new HashSet
<TKeypress
>();
162 * Add a keypress to be overridden for this window.
164 * @param key the key to start taking control of
166 protected void addShortcutKeypress(final TKeypress key
) {
167 keyboardShortcuts
.add(key
);
171 * Remove a keypress to be overridden for this window.
173 * @param key the key to stop taking control of
175 protected void removeShortcutKeypress(final TKeypress key
) {
176 keyboardShortcuts
.remove(key
);
180 * Remove all keypresses to be overridden for this window.
182 protected void clearShortcutKeypresses() {
183 keyboardShortcuts
.clear();
187 * Determine if a keypress is overridden for this window.
189 * @param key the key to check
190 * @return true if this window wants to process this key on its own
192 public boolean isShortcutKeypress(final TKeypress key
) {
193 return keyboardShortcuts
.contains(key
);
197 * A window may have a status bar associated with it. TApplication will
198 * draw this status bar last, and will also route events to it first
201 protected TStatusBar statusBar
= null;
204 * Get the window's status bar, or null if it does not have one.
206 * @return the status bar, or null
208 public TStatusBar
getStatusBar() {
213 * Set the window's status bar to a new one.
215 * @param text the status bar text
216 * @return the status bar
218 public TStatusBar
newStatusBar(final String text
) {
219 statusBar
= new TStatusBar(this, text
);
223 // ------------------------------------------------------------------------
224 // Window movement/resizing support ---------------------------------------
225 // ------------------------------------------------------------------------
228 * If true, then the user clicked on the title bar and is moving the
231 protected boolean inWindowMove
= false;
234 * If true, then the user clicked on the bottom right corner and is
235 * resizing the window.
237 protected boolean inWindowResize
= false;
240 * If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is
241 * resizing/moving the window via the keyboard.
243 private boolean inKeyboardResize
= false;
246 * If true, this window is maximized.
248 private boolean maximized
= false;
251 * Remember mouse state.
253 protected TMouseEvent mouse
;
255 // For moving the window. resizing also uses moveWindowMouseX/Y
256 private int moveWindowMouseX
;
257 private int moveWindowMouseY
;
258 private int oldWindowX
;
259 private int oldWindowY
;
262 private int resizeWindowWidth
;
263 private int resizeWindowHeight
;
264 private int minimumWindowWidth
= 10;
265 private int minimumWindowHeight
= 2;
266 private int maximumWindowWidth
= -1;
267 private int maximumWindowHeight
= -1;
269 // For maximize/restore
270 private int restoreWindowWidth
;
271 private int restoreWindowHeight
;
272 private int restoreWindowX
;
273 private int restoreWindowY
;
276 * Set the maximum width for this window.
278 * @param maximumWindowWidth new maximum width
280 public final void setMaximumWindowWidth(final int maximumWindowWidth
) {
281 this.maximumWindowWidth
= maximumWindowWidth
;
285 * Recenter the window on-screen.
287 public final void center() {
288 if ((flags
& CENTERED
) != 0) {
289 if (getWidth() < getScreen().getWidth()) {
290 setX((getScreen().getWidth() - getWidth()) / 2);
294 setY(((application
.getDesktopBottom()
295 - application
.getDesktopTop()) - getHeight()) / 2);
299 setY(getY() + application
.getDesktopTop());
306 private void maximize() {
307 restoreWindowWidth
= getWidth();
308 restoreWindowHeight
= getHeight();
309 restoreWindowX
= getX();
310 restoreWindowY
= getY();
311 setWidth(getScreen().getWidth());
312 setHeight(application
.getDesktopBottom() - 1);
319 * Restote (unmaximize) window.
321 private void restore() {
322 setWidth(restoreWindowWidth
);
323 setHeight(restoreWindowHeight
);
324 setX(restoreWindowX
);
325 setY(restoreWindowY
);
329 // ------------------------------------------------------------------------
330 // Constructors -----------------------------------------------------------
331 // ------------------------------------------------------------------------
334 * Public constructor. Window will be located at (0, 0).
336 * @param application TApplication that manages this window
337 * @param title window title, will be centered along the top border
338 * @param width width of window
339 * @param height height of window
341 public TWindow(final TApplication application
, final String title
,
342 final int width
, final int height
) {
344 this(application
, title
, 0, 0, width
, height
, RESIZABLE
);
348 * Public constructor. Window will be located at (0, 0).
350 * @param application TApplication that manages this window
351 * @param title window title, will be centered along the top border
352 * @param width width of window
353 * @param height height of window
354 * @param flags bitmask of RESIZABLE, CENTERED, or MODAL
356 public TWindow(final TApplication application
, final String title
,
357 final int width
, final int height
, final int flags
) {
359 this(application
, title
, 0, 0, width
, height
, flags
);
363 * Public constructor.
365 * @param application TApplication that manages this window
366 * @param title window title, will be centered along the top border
367 * @param x column relative to parent
368 * @param y row relative to parent
369 * @param width width of window
370 * @param height height of window
372 public TWindow(final TApplication application
, final String title
,
373 final int x
, final int y
, final int width
, final int height
) {
375 this(application
, title
, x
, y
, width
, height
, RESIZABLE
);
379 * Public constructor.
381 * @param application TApplication that manages this window
382 * @param title window title, will be centered along the top border
383 * @param x column relative to parent
384 * @param y row relative to parent
385 * @param width width of window
386 * @param height height of window
387 * @param flags mask of RESIZABLE, CENTERED, or MODAL
389 public TWindow(final TApplication application
, final String title
,
390 final int x
, final int y
, final int width
, final int height
,
395 // I am my own window and parent
396 setupForTWindow(this, x
, y
+ application
.getDesktopTop(),
401 this.application
= application
;
404 // Minimum width/height are 10 and 2
405 assert (width
>= 10);
406 assert (getHeight() >= 2);
408 // MODAL implies CENTERED
410 this.flags
|= CENTERED
;
413 // Center window if specified
416 // Add me to the application
417 application
.addWindow(this);
420 // ------------------------------------------------------------------------
421 // General behavior -------------------------------------------------------
422 // ------------------------------------------------------------------------
425 * Returns true if this window is modal.
427 * @return true if this window is modal
429 public final boolean isModal() {
430 if ((flags
& MODAL
) == 0) {
437 * Retrieve the background color.
439 * @return the background color
441 public final CellAttributes
getBackground() {
443 && (inWindowMove
|| inWindowResize
|| inKeyboardResize
)
446 return getTheme().getColor("twindow.background.windowmove");
447 } else if (isModal() && inWindowMove
) {
449 return getTheme().getColor("twindow.background.modal");
450 } else if (isModal()) {
452 return getTheme().getColor("twindow.background.modal");
454 return getTheme().getColor("twindow.background.modal.inactive");
455 } else if (isActive()) {
457 return getTheme().getColor("twindow.background");
460 return getTheme().getColor("twindow.background.inactive");
465 * Retrieve the border color.
467 * @return the border color
469 public CellAttributes
getBorder() {
471 && (inWindowMove
|| inWindowResize
|| inKeyboardResize
)
474 return getTheme().getColor("twindow.border.windowmove");
475 } else if (isModal() && inWindowMove
) {
477 return getTheme().getColor("twindow.border.modal.windowmove");
478 } else if (isModal()) {
480 return getTheme().getColor("twindow.border.modal");
482 return getTheme().getColor("twindow.border.modal.inactive");
484 } else if (isActive()) {
486 return getTheme().getColor("twindow.border");
489 return getTheme().getColor("twindow.border.inactive");
494 * Retrieve the border line type.
496 * @return the border line type
498 private int getBorderType() {
500 && (inWindowMove
|| inWindowResize
|| inKeyboardResize
)
504 } else if (isModal() && inWindowMove
) {
507 } else if (isModal()) {
513 } else if (isActive()) {
521 * Called by TApplication.drawChildren() to render on screen.
525 // Draw the box and background first.
526 CellAttributes border
= getBorder();
527 CellAttributes background
= getBackground();
528 int borderType
= getBorderType();
530 getScreen().drawBox(0, 0, getWidth(), getHeight(), border
,
531 background
, borderType
, true);
534 int titleLeft
= (getWidth() - title
.length() - 2) / 2;
535 putCharXY(titleLeft
, 0, ' ', border
);
536 putStringXY(titleLeft
+ 1, 0, title
);
537 putCharXY(titleLeft
+ title
.length() + 1, 0, ' ', border
);
541 // Draw the close button
542 putCharXY(2, 0, '[', border
);
543 putCharXY(4, 0, ']', border
);
544 if (mouseOnClose() && mouse
.isMouse1()) {
545 putCharXY(3, 0, GraphicsChars
.CP437
[0x0F],
547 ?
getTheme().getColor("twindow.border.windowmove")
548 : getTheme().getColor("twindow.border.modal.windowmove"));
550 putCharXY(3, 0, GraphicsChars
.CP437
[0xFE],
552 ?
getTheme().getColor("twindow.border.windowmove")
553 : getTheme().getColor("twindow.border.modal.windowmove"));
556 // Draw the maximize button
559 putCharXY(getWidth() - 5, 0, '[', border
);
560 putCharXY(getWidth() - 3, 0, ']', border
);
561 if (mouseOnMaximize() && mouse
.isMouse1()) {
562 putCharXY(getWidth() - 4, 0, GraphicsChars
.CP437
[0x0F],
563 getTheme().getColor("twindow.border.windowmove"));
566 putCharXY(getWidth() - 4, 0, GraphicsChars
.CP437
[0x12],
567 getTheme().getColor("twindow.border.windowmove"));
569 putCharXY(getWidth() - 4, 0, GraphicsChars
.UPARROW
,
570 getTheme().getColor("twindow.border.windowmove"));
574 // Draw the resize corner
575 if ((flags
& RESIZABLE
) != 0) {
576 putCharXY(getWidth() - 2, getHeight() - 1,
577 GraphicsChars
.SINGLE_BAR
,
578 getTheme().getColor("twindow.border.windowmove"));
579 putCharXY(getWidth() - 1, getHeight() - 1,
580 GraphicsChars
.LRCORNER
,
581 getTheme().getColor("twindow.border.windowmove"));
587 // ------------------------------------------------------------------------
588 // Event handlers ---------------------------------------------------------
589 // ------------------------------------------------------------------------
592 * Returns true if the mouse is currently on the close button.
594 * @return true if mouse is currently on the close button
596 private boolean mouseOnClose() {
598 && (mouse
.getAbsoluteY() == getY())
599 && (mouse
.getAbsoluteX() == getX() + 3)
607 * Returns true if the mouse is currently on the maximize/restore button.
609 * @return true if the mouse is currently on the maximize/restore button
611 private boolean mouseOnMaximize() {
614 && (mouse
.getAbsoluteY() == getY())
615 && (mouse
.getAbsoluteX() == getX() + getWidth() - 4)
623 * Returns true if the mouse is currently on the resizable lower right
626 * @return true if the mouse is currently on the resizable lower right
629 private boolean mouseOnResize() {
630 if (((flags
& RESIZABLE
) != 0)
633 && (mouse
.getAbsoluteY() == getY() + getHeight() - 1)
634 && ((mouse
.getAbsoluteX() == getX() + getWidth() - 1)
635 || (mouse
.getAbsoluteX() == getX() + getWidth() - 2))
643 * Subclasses should override this method to cleanup resources. This is
644 * called by application.closeWindow().
646 public void onClose() {
647 // Default: do nothing
651 * Called by application.switchWindow() when this window gets the
652 * focus, and also by application.addWindow().
654 public void onFocus() {
655 // Default: do nothing
659 * Called by application.switchWindow() when another window gets the
662 public void onUnfocus() {
663 // Default: do nothing
667 * Handle mouse button presses.
669 * @param mouse mouse button event
672 public void onMouseDown(final TMouseEvent mouse
) {
675 inKeyboardResize
= false;
677 if ((mouse
.getAbsoluteY() == getY())
679 && (getX() <= mouse
.getAbsoluteX())
680 && (mouse
.getAbsoluteX() < getX() + getWidth())
682 && !mouseOnMaximize()
684 // Begin moving window
686 moveWindowMouseX
= mouse
.getAbsoluteX();
687 moveWindowMouseY
= mouse
.getAbsoluteY();
695 if (mouseOnResize()) {
696 // Begin window resize
697 inWindowResize
= true;
698 moveWindowMouseX
= mouse
.getAbsoluteX();
699 moveWindowMouseY
= mouse
.getAbsoluteY();
700 resizeWindowWidth
= getWidth();
701 resizeWindowHeight
= getHeight();
708 // Give the shortcut bar a shot at this.
709 if (statusBar
!= null) {
710 if (statusBar
.statusBarMouseDown(mouse
)) {
715 // I didn't take it, pass it on to my children
716 super.onMouseDown(mouse
);
720 * Handle mouse button releases.
722 * @param mouse mouse button release event
725 public void onMouseUp(final TMouseEvent mouse
) {
728 if ((inWindowMove
) && (mouse
.isMouse1())) {
729 // Stop moving window
730 inWindowMove
= false;
734 if ((inWindowResize
) && (mouse
.isMouse1())) {
735 // Stop resizing window
736 inWindowResize
= false;
740 if (mouse
.isMouse1() && mouseOnClose()) {
742 application
.closeWindow(this);
746 if ((mouse
.getAbsoluteY() == getY())
748 && mouseOnMaximize()) {
756 // Pass a resize event to my children
757 onResize(new TResizeEvent(TResizeEvent
.Type
.WIDGET
,
758 getWidth(), getHeight()));
762 // Give the shortcut bar a shot at this.
763 if (statusBar
!= null) {
764 if (statusBar
.statusBarMouseUp(mouse
)) {
769 // I didn't take it, pass it on to my children
770 super.onMouseUp(mouse
);
774 * Handle mouse movements.
776 * @param mouse mouse motion event
779 public void onMouseMotion(final TMouseEvent mouse
) {
784 setX(oldWindowX
+ (mouse
.getAbsoluteX() - moveWindowMouseX
));
785 setY(oldWindowY
+ (mouse
.getAbsoluteY() - moveWindowMouseY
));
786 // Don't cover up the menu bar
787 if (getY() < application
.getDesktopTop()) {
788 setY(application
.getDesktopTop());
790 // Don't go below the status bar
791 if (getY() >= application
.getDesktopBottom()) {
792 setY(application
.getDesktopBottom() - 1);
797 if (inWindowResize
) {
799 setWidth(resizeWindowWidth
+ (mouse
.getAbsoluteX()
800 - moveWindowMouseX
));
801 setHeight(resizeWindowHeight
+ (mouse
.getAbsoluteY()
802 - moveWindowMouseY
));
803 if (getX() + getWidth() > getScreen().getWidth()) {
804 setWidth(getScreen().getWidth() - getX());
806 if (getY() + getHeight() > application
.getDesktopBottom()) {
807 setY(application
.getDesktopBottom() - getHeight() + 1);
809 // Don't cover up the menu bar
810 if (getY() < application
.getDesktopTop()) {
811 setY(application
.getDesktopTop());
814 // Keep within min/max bounds
815 if (getWidth() < minimumWindowWidth
) {
816 setWidth(minimumWindowWidth
);
817 inWindowResize
= false;
819 if (getHeight() < minimumWindowHeight
) {
820 setHeight(minimumWindowHeight
);
821 inWindowResize
= false;
823 if ((maximumWindowWidth
> 0)
824 && (getWidth() > maximumWindowWidth
)
826 setWidth(maximumWindowWidth
);
827 inWindowResize
= false;
829 if ((maximumWindowHeight
> 0)
830 && (getHeight() > maximumWindowHeight
)
832 setHeight(maximumWindowHeight
);
833 inWindowResize
= false;
836 // Pass a resize event to my children
837 onResize(new TResizeEvent(TResizeEvent
.Type
.WIDGET
,
838 getWidth(), getHeight()));
842 // Give the shortcut bar a shot at this.
843 if (statusBar
!= null) {
844 statusBar
.statusBarMouseMotion(mouse
);
847 // I didn't take it, pass it on to my children
848 super.onMouseMotion(mouse
);
854 * @param keypress keystroke event
857 public void onKeypress(final TKeypressEvent keypress
) {
859 if (inKeyboardResize
) {
861 // ESC or ENTER - Exit size/move
862 if (keypress
.equals(kbEsc
) || keypress
.equals(kbEnter
)) {
863 inKeyboardResize
= false;
866 if (keypress
.equals(kbLeft
)) {
871 if (keypress
.equals(kbRight
)) {
872 if (getX() < getScreen().getWidth() - 1) {
876 if (keypress
.equals(kbDown
)) {
877 if (getY() < application
.getDesktopBottom() - 1) {
881 if (keypress
.equals(kbUp
)) {
886 if (keypress
.equals(kbShiftLeft
)) {
887 if ((getWidth() > minimumWindowWidth
)
888 || (minimumWindowWidth
<= 0)
890 setWidth(getWidth() - 1);
893 if (keypress
.equals(kbShiftRight
)) {
894 if ((getWidth() < maximumWindowWidth
)
895 || (maximumWindowWidth
<= 0)
897 setWidth(getWidth() + 1);
900 if (keypress
.equals(kbShiftUp
)) {
901 if ((getHeight() > minimumWindowHeight
)
902 || (minimumWindowHeight
<= 0)
904 setHeight(getHeight() - 1);
907 if (keypress
.equals(kbShiftDown
)) {
908 if ((getHeight() < maximumWindowHeight
)
909 || (maximumWindowHeight
<= 0)
911 setHeight(getHeight() + 1);
915 // Pass a resize event to my children
916 onResize(new TResizeEvent(TResizeEvent
.Type
.WIDGET
,
917 getWidth(), getHeight()));
922 // Give the shortcut bar a shot at this.
923 if (statusBar
!= null) {
924 if (statusBar
.statusBarKeypress(keypress
)) {
929 // These keystrokes will typically not be seen unless a subclass
930 // overrides onMenu() due to how TApplication dispatches
933 // Ctrl-W - close window
934 if (keypress
.equals(kbCtrlW
)) {
935 application
.closeWindow(this);
939 // F6 - behave like Alt-TAB
940 if (keypress
.equals(kbF6
)) {
941 application
.switchWindow(true);
945 // Shift-F6 - behave like Shift-Alt-TAB
946 if (keypress
.equals(kbShiftF6
)) {
947 application
.switchWindow(false);
952 if (keypress
.equals(kbF5
)) {
960 // Ctrl-F5 - size/move
961 if (keypress
.equals(kbCtrlF5
)) {
962 inKeyboardResize
= !inKeyboardResize
;
965 // I didn't take it, pass it on to my children
966 super.onKeypress(keypress
);
970 * Handle posted command events.
972 * @param command command event
975 public void onCommand(final TCommandEvent command
) {
977 // These commands will typically not be seen unless a subclass
978 // overrides onMenu() due to how TApplication dispatches
981 if (command
.equals(cmWindowClose
)) {
982 application
.closeWindow(this);
986 if (command
.equals(cmWindowNext
)) {
987 application
.switchWindow(true);
991 if (command
.equals(cmWindowPrevious
)) {
992 application
.switchWindow(false);
996 if (command
.equals(cmWindowMove
)) {
997 inKeyboardResize
= true;
1001 if (command
.equals(cmWindowZoom
)) {
1009 // I didn't take it, pass it on to my children
1010 super.onCommand(command
);
1014 * Handle posted menu events.
1016 * @param menu menu event
1019 public void onMenu(final TMenuEvent menu
) {
1020 if (menu
.getId() == TMenu
.MID_WINDOW_CLOSE
) {
1021 application
.closeWindow(this);
1025 if (menu
.getId() == TMenu
.MID_WINDOW_NEXT
) {
1026 application
.switchWindow(true);
1030 if (menu
.getId() == TMenu
.MID_WINDOW_PREVIOUS
) {
1031 application
.switchWindow(false);
1035 if (menu
.getId() == TMenu
.MID_WINDOW_MOVE
) {
1036 inKeyboardResize
= true;
1040 if (menu
.getId() == TMenu
.MID_WINDOW_ZOOM
) {
1049 // I didn't take it, pass it on to my children
1053 // ------------------------------------------------------------------------
1054 // Passthru for Screen functions ------------------------------------------
1055 // ------------------------------------------------------------------------
1058 * Get the attributes at one location.
1060 * @param x column coordinate. 0 is the left-most column.
1061 * @param y row coordinate. 0 is the top-most row.
1062 * @return attributes at (x, y)
1064 public final CellAttributes
getAttrXY(final int x
, final int y
) {
1065 return getScreen().getAttrXY(x
, y
);
1069 * Set the attributes at one location.
1071 * @param x column coordinate. 0 is the left-most column.
1072 * @param y row coordinate. 0 is the top-most row.
1073 * @param attr attributes to use (bold, foreColor, backColor)
1075 public final void putAttrXY(final int x
, final int y
,
1076 final CellAttributes attr
) {
1078 getScreen().putAttrXY(x
, y
, attr
);
1082 * Set the attributes at one location.
1084 * @param x column coordinate. 0 is the left-most column.
1085 * @param y row coordinate. 0 is the top-most row.
1086 * @param attr attributes to use (bold, foreColor, backColor)
1087 * @param clip if true, honor clipping/offset
1089 public final void putAttrXY(final int x
, final int y
,
1090 final CellAttributes attr
, final boolean clip
) {
1092 getScreen().putAttrXY(x
, y
, attr
, clip
);
1096 * Fill the entire screen with one character with attributes.
1098 * @param ch character to draw
1099 * @param attr attributes to use (bold, foreColor, backColor)
1101 public final void putAll(final char ch
, final CellAttributes attr
) {
1102 getScreen().putAll(ch
, attr
);
1106 * Render one character with attributes.
1108 * @param x column coordinate. 0 is the left-most column.
1109 * @param y row coordinate. 0 is the top-most row.
1110 * @param ch character + attributes to draw
1112 public final void putCharXY(final int x
, final int y
, final Cell ch
) {
1113 getScreen().putCharXY(x
, y
, ch
);
1117 * Render one character with attributes.
1119 * @param x column coordinate. 0 is the left-most column.
1120 * @param y row coordinate. 0 is the top-most row.
1121 * @param ch character to draw
1122 * @param attr attributes to use (bold, foreColor, backColor)
1124 public final void putCharXY(final int x
, final int y
, final char ch
,
1125 final CellAttributes attr
) {
1127 getScreen().putCharXY(x
, y
, ch
, attr
);
1131 * Render one character without changing the underlying attributes.
1133 * @param x column coordinate. 0 is the left-most column.
1134 * @param y row coordinate. 0 is the top-most row.
1135 * @param ch character to draw
1137 public final void putCharXY(final int x
, final int y
, final char ch
) {
1138 getScreen().putCharXY(x
, y
, ch
);
1142 * Render a string. Does not wrap if the string exceeds the line.
1144 * @param x column coordinate. 0 is the left-most column.
1145 * @param y row coordinate. 0 is the top-most row.
1146 * @param str string to draw
1147 * @param attr attributes to use (bold, foreColor, backColor)
1149 public final void putStringXY(final int x
, final int y
, final String str
,
1150 final CellAttributes attr
) {
1152 getScreen().putStringXY(x
, y
, str
, attr
);
1156 * Render a string without changing the underlying attribute. Does not
1157 * wrap if the string exceeds the line.
1159 * @param x column coordinate. 0 is the left-most column.
1160 * @param y row coordinate. 0 is the top-most row.
1161 * @param str string to draw
1163 public final void putStringXY(final int x
, final int y
, final String str
) {
1164 getScreen().putStringXY(x
, y
, str
);
1168 * Draw a vertical line from (x, y) to (x, y + n).
1170 * @param x column coordinate. 0 is the left-most column.
1171 * @param y row coordinate. 0 is the top-most row.
1172 * @param n number of characters to draw
1173 * @param ch character to draw
1174 * @param attr attributes to use (bold, foreColor, backColor)
1176 public final void vLineXY(final int x
, final int y
, final int n
,
1177 final char ch
, final CellAttributes attr
) {
1179 getScreen().vLineXY(x
, y
, n
, ch
, attr
);
1183 * Draw a horizontal line from (x, y) to (x + n, y).
1185 * @param x column coordinate. 0 is the left-most column.
1186 * @param y row coordinate. 0 is the top-most row.
1187 * @param n number of characters to draw
1188 * @param ch character to draw
1189 * @param attr attributes to use (bold, foreColor, backColor)
1191 public final void hLineXY(final int x
, final int y
, final int n
,
1192 final char ch
, final CellAttributes attr
) {
1194 getScreen().hLineXY(x
, y
, n
, ch
, attr
);