TWindow compiles
[fanfix.git] / src / jexer / TWindow.java
CommitLineData
48e27807
KL
1/**
2 * Jexer - Java Text User Interface
3 *
4 * License: LGPLv3 or later
5 *
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
9 *
10 * Copyright (C) 2015 Kevin Lamonte
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * 02110-1301 USA
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
30 */
31package jexer;
32
33import jexer.bits.Cell;
34import jexer.bits.CellAttributes;
35import jexer.bits.GraphicsChars;
36import jexer.event.TCommandEvent;
37import jexer.event.TKeypressEvent;
38import jexer.event.TMenuEvent;
39import jexer.event.TMouseEvent;
40import jexer.event.TResizeEvent;
41import jexer.io.Screen;
42import static jexer.TCommand.*;
43import static jexer.TKeypress.*;
44
45/**
46 * TWindow is the top-level container and drawing surface for other widgets.
47 */
48public class TWindow extends TWidget {
49
50 /**
51 * Window's parent TApplication.
52 */
53 protected TApplication application;
54
55 /**
56 * Get this TWindow's parent TApplication.
57 *
58 * @return this TWindow's parent TApplication
59 */
60 public final TApplication getApplication() {
61 return application;
62 }
63
64 /**
65 * Get the Screen.
66 *
67 * @return the Screen
68 */
69 public final Screen getScreen() {
70 return application.getScreen();
71 }
72
73 /**
74 * Window title.
75 */
76 protected String title = "";
77
78 /**
79 * Window is resizable (default yes).
80 */
81 public static final int RESIZABLE = 0x01;
82
83 /**
84 * Window is modal (default no).
85 */
86 public static final int MODAL = 0x02;
87
88 /**
89 * Window is centered (default no).
90 */
91 public static final int CENTERED = 0x04;
92
93 /**
94 * Window flags.
95 */
96 private int flags = RESIZABLE;
97
98 /**
99 * Z order. Lower number means more in-front.
100 */
101 private int z = 0;
102
103 /**
104 * If true, then the user clicked on the title bar and is moving the
105 * window.
106 */
107 private boolean inWindowMove = false;
108
109 /**
110 * If true, then the user clicked on the bottom right corner and is
111 * resizing the window.
112 */
113 private boolean inWindowResize = false;
114
115 /**
116 * If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is
117 * resizing/moving the window via the keyboard.
118 */
119 private boolean inKeyboardResize = false;
120
121 /**
122 * If true, this window is maximized.
123 */
124 private boolean maximized = false;
125
126 /**
127 * Remember mouse state.
128 */
129 protected TMouseEvent mouse;
130
131 // For moving the window. resizing also uses moveWindowMouseX/Y
132 private int moveWindowMouseX;
133 private int moveWindowMouseY;
134 private int oldWindowX;
135 private int oldWindowY;
136
137 // Resizing
138 private int resizeWindowWidth;
139 private int resizeWindowHeight;
140 private int minimumWindowWidth = 10;
141 private int minimumWindowHeight = 2;
142 private int maximumWindowWidth = -1;
143 private int maximumWindowHeight = -1;
144
145 // For maximize/restore
146 private int restoreWindowWidth;
147 private int restoreWindowHeight;
148 private int restoreWindowX;
149 private int restoreWindowY;
150
151 /**
152 * Public constructor. Window will be located at (0, 0).
153 *
154 * @param application TApplication that manages this window
155 * @param title window title, will be centered along the top border
156 * @param width width of window
157 * @param height height of window
158 */
159 public TWindow(final TApplication application, final String title,
160 final int width, final int height) {
161
162 this(application, title, 0, 0, width, height, RESIZABLE);
163 }
164
165 /**
166 * Public constructor. Window will be located at (0, 0).
167 *
168 * @param application TApplication that manages this window
169 * @param title window title, will be centered along the top border
170 * @param width width of window
171 * @param height height of window
172 * @param flags bitmask of RESIZABLE, CENTERED, or MODAL
173 */
174 public TWindow(final TApplication application, final String title,
175 final int width, final int height, final int flags) {
176
177 this(application, title, 0, 0, width, height, flags);
178 }
179
180 /**
181 * Public constructor.
182 *
183 * @param application TApplication that manages this window
184 * @param title window title, will be centered along the top border
185 * @param x column relative to parent
186 * @param y row relative to parent
187 * @param width width of window
188 * @param height height of window
189 */
190 public TWindow(final TApplication application, final String title,
191 final int x, final int y, final int width, final int height) {
192
193 this(application, title, x, y, width, height, RESIZABLE);
194 }
195
196 /**
197 * Public constructor.
198 *
199 * @param application TApplication that manages this window
200 * @param title window title, will be centered along the top border
201 * @param x column relative to parent
202 * @param y row relative to parent
203 * @param width width of window
204 * @param height height of window
205 * @param flags mask of RESIZABLE, CENTERED, or MODAL
206 */
207 public TWindow(final TApplication application, final String title,
208 final int x, final int y, final int width, final int height,
209 final int flags) {
210
211 // I am my own window and parent
212 this.parent = this;
213 this.window = this;
214
215 // Save fields
216 this.title = title;
217 this.application = application;
218 this.x = x;
219 this.y = y + application.getDesktopTop();
220 this.width = width;
221 this.height = height;
222 this.flags = flags;
223
224 // Minimum width/height are 10 and 2
225 assert (width >= 10);
226 assert (height >= 2);
227
228 // MODAL implies CENTERED
229 if (isModal()) {
230 this.flags |= CENTERED;
231 }
232
233 // Center window if specified
234 center();
235
236 // Add me to the application
237 application.addWindow(this);
238 }
239
240 /**
241 * Recenter the window on-screen.
242 */
243 public final void center() {
244 if ((flags & CENTERED) != 0) {
245 if (width < getScreen().getWidth()) {
246 x = (getScreen().getWidth() - width) / 2;
247 } else {
248 x = 0;
249 }
250 y = (application.getDesktopBottom() - application.getDesktopTop());
251 y -= height;
252 y /= 2;
253 if (y < 0) {
254 y = 0;
255 }
256 y += application.getDesktopTop();
257 }
258 }
259
260 /**
261 * Returns true if this window is modal.
262 *
263 * @return true if this window is modal
264 */
265 public final boolean isModal() {
266 if ((flags & MODAL) == 0) {
267 return false;
268 }
269 return true;
270 }
271
272 /**
273 * Comparison operator sorts on z.
274 *
275 * @param that another TWindow instance
276 * @return difference between this.z and that.z
277 */
278 public final int compare(final TWindow that) {
279 return (z - that.z);
280 }
281
282 /**
283 * Returns true if the mouse is currently on the close button.
284 *
285 * @return true if mouse is currently on the close button
286 */
287 private boolean mouseOnClose() {
288 if ((mouse != null)
289 && (mouse.getAbsoluteY() == y)
290 && (mouse.getAbsoluteX() == x + 3)
291 ) {
292 return true;
293 }
294 return false;
295 }
296
297 /**
298 * Returns true if the mouse is currently on the maximize/restore button.
299 *
300 * @return true if the mouse is currently on the maximize/restore button
301 */
302 private boolean mouseOnMaximize() {
303 if ((mouse != null)
304 && !isModal()
305 && (mouse.getAbsoluteY() == y)
306 && (mouse.getAbsoluteX() == x + width - 4)
307 ) {
308 return true;
309 }
310 return false;
311 }
312
313 /**
314 * Returns true if the mouse is currently on the resizable lower right
315 * corner.
316 *
317 * @return true if the mouse is currently on the resizable lower right
318 * corner
319 */
320 private boolean mouseOnResize() {
321 if (((flags & RESIZABLE) != 0)
322 && !isModal()
323 && (mouse != null)
324 && (mouse.getAbsoluteY() == y + height - 1)
325 && ((mouse.getAbsoluteX() == x + width - 1)
326 || (mouse.getAbsoluteX() == x + width - 2))
327 ) {
328 return true;
329 }
330 return false;
331 }
332
333 /**
334 * Retrieve the background color.
335 *
336 * @return the background color
337 */
338 protected final CellAttributes getBackground() {
339 if (!isModal()
340 && (inWindowMove || inWindowResize || inKeyboardResize)
341 ) {
342 assert (active);
343 return application.getTheme().getColor("twindow.background.windowmove");
344 } else if (isModal() && inWindowMove) {
345 assert (active);
346 return application.getTheme().getColor("twindow.background.modal");
347 } else if (isModal()) {
348 if (active) {
349 return application.getTheme().getColor("twindow.background.modal");
350 }
351 return application.getTheme().getColor("twindow.background.modal.inactive");
352 } else if (active) {
353 assert (!isModal());
354 return application.getTheme().getColor("twindow.background");
355 } else {
356 assert (!isModal());
357 return application.getTheme().getColor("twindow.background.inactive");
358 }
359 }
360
361 /**
362 * Retrieve the border color.
363 *
364 * @return the border color
365 */
366 protected final CellAttributes getBorder() {
367 if (!isModal()
368 && (inWindowMove || inWindowResize || inKeyboardResize)
369 ) {
370 assert (active);
371 return application.getTheme().getColor("twindow.border.windowmove");
372 } else if (isModal() && inWindowMove) {
373 assert (active);
374 return application.getTheme().getColor("twindow.border.modal.windowmove");
375 } else if (isModal()) {
376 if (active) {
377 return application.getTheme().getColor("twindow.border.modal");
378 } else {
379 return application.getTheme().getColor("twindow.border.modal.inactive");
380 }
381 } else if (active) {
382 assert (!isModal());
383 return application.getTheme().getColor("twindow.border");
384 } else {
385 assert (!isModal());
386 return application.getTheme().getColor("twindow.border.inactive");
387 }
388 }
389
390 /**
391 * Retrieve the border line type.
392 *
393 * @return the border line type
394 */
395 protected final int getBorderType() {
396 if (!isModal()
397 && (inWindowMove || inWindowResize || inKeyboardResize)
398 ) {
399 assert (active);
400 return 1;
401 } else if (isModal() && inWindowMove) {
402 assert (active);
403 return 1;
404 } else if (isModal()) {
405 if (active) {
406 return 2;
407 } else {
408 return 1;
409 }
410 } else if (active) {
411 return 2;
412 } else {
413 return 1;
414 }
415 }
416
417 /**
418 * Subclasses should override this method to cleanup resources. This is
419 * called by application.closeWindow().
420 */
421 public void onClose() {
422 // Default: do nothing
423 }
424
425 /**
426 * Called by TApplication.drawChildren() to render on screen.
427 */
428 @Override
429 public void draw() {
430 // Draw the box and background first.
431 CellAttributes border = getBorder();
432 CellAttributes background = getBackground();
433 int borderType = getBorderType();
434
435 getScreen().drawBox(0, 0, width, height, border,
436 background, borderType, true);
437
438 // Draw the title
439 int titleLeft = (width - title.length() - 2) / 2;
440 putCharXY(titleLeft, 0, ' ', border);
441 putStrXY(titleLeft + 1, 0, title);
442 putCharXY(titleLeft + title.length() + 1, 0, ' ', border);
443
444 if (active) {
445
446 // Draw the close button
447 putCharXY(2, 0, '[', border);
448 putCharXY(4, 0, ']', border);
449 if (mouseOnClose() && mouse.getMouse1()) {
450 putCharXY(3, 0, GraphicsChars.CP437[0x0F],
451 !isModal()
452 ? application.getTheme().getColor("twindow.border.windowmove")
453 : application.getTheme().getColor("twindow.border.modal.windowmove"));
454 } else {
455 putCharXY(3, 0, GraphicsChars.CP437[0xFE],
456 !isModal()
457 ? application.getTheme().getColor("twindow.border.windowmove")
458 : application.getTheme().getColor("twindow.border.modal.windowmove"));
459 }
460
461 // Draw the maximize button
462 if (!isModal()) {
463
464 putCharXY(width - 5, 0, '[', border);
465 putCharXY(width - 3, 0, ']', border);
466 if (mouseOnMaximize() && mouse.getMouse1()) {
467 putCharXY(width - 4, 0, GraphicsChars.CP437[0x0F],
468 application.getTheme().getColor("twindow.border.windowmove"));
469 } else {
470 if (maximized) {
471 putCharXY(width - 4, 0, GraphicsChars.CP437[0x12],
472 application.getTheme().getColor("twindow.border.windowmove"));
473 } else {
474 putCharXY(width - 4, 0, GraphicsChars.UPARROW,
475 application.getTheme().getColor("twindow.border.windowmove"));
476 }
477 }
478
479 // Draw the resize corner
480 if ((flags & RESIZABLE) != 0) {
481 putCharXY(width - 2, height - 1, GraphicsChars.SINGLE_BAR,
482 application.getTheme().getColor("twindow.border.windowmove"));
483 putCharXY(width - 1, height - 1, GraphicsChars.LRCORNER,
484 application.getTheme().getColor("twindow.border.windowmove"));
485 }
486 }
487 }
488 }
489
490 /**
491 * Handle mouse button presses.
492 *
493 * @param mouse mouse button event
494 */
495 @Override
496 public void onMouseDown(final TMouseEvent mouse) {
497 this.mouse = mouse;
498 application.setRepaint();
499
500 inKeyboardResize = false;
501
502 if ((mouse.getAbsoluteY() == y)
503 && mouse.getMouse1()
504 && (x <= mouse.getAbsoluteX())
505 && (mouse.getAbsoluteX() < x + width)
506 && !mouseOnClose()
507 && !mouseOnMaximize()
508 ) {
509 // Begin moving window
510 inWindowMove = true;
511 moveWindowMouseX = mouse.getAbsoluteX();
512 moveWindowMouseY = mouse.getAbsoluteY();
513 oldWindowX = x;
514 oldWindowY = y;
515 if (maximized) {
516 maximized = false;
517 }
518 return;
519 }
520 if (mouseOnResize()) {
521 // Begin window resize
522 inWindowResize = true;
523 moveWindowMouseX = mouse.getAbsoluteX();
524 moveWindowMouseY = mouse.getAbsoluteY();
525 resizeWindowWidth = width;
526 resizeWindowHeight = height;
527 if (maximized) {
528 maximized = false;
529 }
530 return;
531 }
532
533 // I didn't take it, pass it on to my children
534 super.onMouseDown(mouse);
535 }
536
537 /**
538 * Maximize window.
539 */
540 private void maximize() {
541 restoreWindowWidth = width;
542 restoreWindowHeight = height;
543 restoreWindowX = x;
544 restoreWindowY = y;
545 width = getScreen().getWidth();
546 height = application.getDesktopBottom() - 1;
547 x = 0;
548 y = 1;
549 maximized = true;
550 }
551
552 /**
553 * Restote (unmaximize) window.
554 */
555 private void restore() {
556 width = restoreWindowWidth;
557 height = restoreWindowHeight;
558 x = restoreWindowX;
559 y = restoreWindowY;
560 maximized = false;
561 }
562
563 /**
564 * Handle mouse button releases.
565 *
566 * @param mouse mouse button release event
567 */
568 @Override
569 public void onMouseUp(final TMouseEvent mouse) {
570 this.mouse = mouse;
571 application.setRepaint();
572
573 if ((inWindowMove) && (mouse.getMouse1())) {
574 // Stop moving window
575 inWindowMove = false;
576 return;
577 }
578
579 if ((inWindowResize) && (mouse.getMouse1())) {
580 // Stop resizing window
581 inWindowResize = false;
582 return;
583 }
584
585 if (mouse.getMouse1() && mouseOnClose()) {
586 // Close window
587 application.closeWindow(this);
588 return;
589 }
590
591 if ((mouse.getAbsoluteY() == y) && mouse.getMouse1()
592 && mouseOnMaximize()) {
593 if (maximized) {
594 // Restore
595 restore();
596 } else {
597 // Maximize
598 maximize();
599 }
600 // Pass a resize event to my children
601 onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, width, height));
602 return;
603 }
604
605 // I didn't take it, pass it on to my children
606 super.onMouseUp(mouse);
607 }
608
609 /**
610 * Handle mouse movements.
611 *
612 * @param mouse mouse motion event
613 */
614 @Override
615 public void onMouseMotion(final TMouseEvent mouse) {
616 this.mouse = mouse;
617 application.setRepaint();
618
619 if (inWindowMove) {
620 // Move window over
621 x = oldWindowX + (mouse.getAbsoluteX() - moveWindowMouseX);
622 y = oldWindowY + (mouse.getAbsoluteY() - moveWindowMouseY);
623 // Don't cover up the menu bar
624 if (y < application.getDesktopTop()) {
625 y = application.getDesktopTop();
626 }
627 return;
628 }
629
630 if (inWindowResize) {
631 // Move window over
632 width = resizeWindowWidth + (mouse.getAbsoluteX() - moveWindowMouseX);
633 height = resizeWindowHeight + (mouse.getAbsoluteY() - moveWindowMouseY);
634 if (x + width > getScreen().getWidth()) {
635 width = getScreen().getWidth() - x;
636 }
637 if (y + height > application.getDesktopBottom()) {
638 y = application.getDesktopBottom() - height + 1;
639 }
640 // Don't cover up the menu bar
641 if (y < application.getDesktopTop()) {
642 y = application.getDesktopTop();
643 }
644
645 // Keep within min/max bounds
646 if (width < minimumWindowWidth) {
647 width = minimumWindowWidth;
648 inWindowResize = false;
649 }
650 if (height < minimumWindowHeight) {
651 height = minimumWindowHeight;
652 inWindowResize = false;
653 }
654 if ((maximumWindowWidth > 0) && (width > maximumWindowWidth)) {
655 width = maximumWindowWidth;
656 inWindowResize = false;
657 }
658 if ((maximumWindowHeight > 0) && (height > maximumWindowHeight)) {
659 height = maximumWindowHeight;
660 inWindowResize = false;
661 }
662
663 // Pass a resize event to my children
664 onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, width, height));
665 return;
666 }
667
668 // I didn't take it, pass it on to my children
669 super.onMouseMotion(mouse);
670 }
671
672 /**
673 * Handle keystrokes.
674 *
675 * @param keypress keystroke event
676 */
677 @Override
678 public void onKeypress(final TKeypressEvent keypress) {
679
680 if (inKeyboardResize) {
681
682 // ESC - Exit size/move
683 if (keypress.equals(kbEsc)) {
684 inKeyboardResize = false;
685 }
686
687 if (keypress.equals(kbLeft)) {
688 if (x > 0) {
689 x--;
690 }
691 }
692 if (keypress.equals(kbRight)) {
693 if (x < getScreen().getWidth() - 1) {
694 x++;
695 }
696 }
697 if (keypress.equals(kbDown)) {
698 if (y < application.getDesktopBottom() - 1) {
699 y++;
700 }
701 }
702 if (keypress.equals(kbUp)) {
703 if (y > 1) {
704 y--;
705 }
706 }
707 if (keypress.equals(kbShiftLeft)) {
708 if (width > minimumWindowWidth) {
709 width--;
710 }
711 }
712 if (keypress.equals(kbShiftRight)) {
713 if (width < maximumWindowWidth) {
714 width++;
715 }
716 }
717 if (keypress.equals(kbShiftUp)) {
718 if (height > minimumWindowHeight) {
719 height--;
720 }
721 }
722 if (keypress.equals(kbShiftDown)) {
723 if (height < maximumWindowHeight) {
724 height++;
725 }
726 }
727
728 return;
729 }
730
731 // These keystrokes will typically not be seen unless a subclass
732 // overrides onMenu() due to how TApplication dispatches
733 // accelerators.
734
735 // Ctrl-W - close window
736 if (keypress.equals(kbCtrlW)) {
737 application.closeWindow(this);
738 return;
739 }
740
741 // F6 - behave like Alt-TAB
742 if (keypress.equals(kbF6)) {
743 application.switchWindow(true);
744 return;
745 }
746
747 // Shift-F6 - behave like Shift-Alt-TAB
748 if (keypress.equals(kbShiftF6)) {
749 application.switchWindow(false);
750 return;
751 }
752
753 // F5 - zoom
754 if (keypress.equals(kbF5)) {
755 if (maximized) {
756 restore();
757 } else {
758 maximize();
759 }
760 }
761
762 // Ctrl-F5 - size/move
763 if (keypress.equals(kbCtrlF5)) {
764 inKeyboardResize = !inKeyboardResize;
765 }
766
767 // I didn't take it, pass it on to my children
768 super.onKeypress(keypress);
769 }
770
771 /**
772 * Handle posted command events.
773 *
774 * @param command command event
775 */
776 @Override
777 public void onCommand(final TCommandEvent command) {
778
779 // These commands will typically not be seen unless a subclass
780 // overrides onMenu() due to how TApplication dispatches
781 // accelerators.
782
783 if (command.equals(cmWindowClose)) {
784 application.closeWindow(this);
785 return;
786 }
787
788 if (command.equals(cmWindowNext)) {
789 application.switchWindow(true);
790 return;
791 }
792
793 if (command.equals(cmWindowPrevious)) {
794 application.switchWindow(false);
795 return;
796 }
797
798 if (command.equals(cmWindowMove)) {
799 inKeyboardResize = true;
800 return;
801 }
802
803 if (command.equals(cmWindowZoom)) {
804 if (maximized) {
805 restore();
806 } else {
807 maximize();
808 }
809 }
810
811 // I didn't take it, pass it on to my children
812 super.onCommand(command);
813 }
814
815 /**
816 * Handle posted menu events.
817 *
818 * @param menu menu event
819 */
820 @Override
821 public void onMenu(final TMenuEvent menu) {
822 if (menu.getId() == TMenu.MID_WINDOW_CLOSE) {
823 application.closeWindow(this);
824 return;
825 }
826
827 if (menu.getId() == TMenu.MID_WINDOW_NEXT) {
828 application.switchWindow(true);
829 return;
830 }
831
832 if (menu.getId() == TMenu.MID_WINDOW_PREVIOUS) {
833 application.switchWindow(false);
834 return;
835 }
836
837 if (menu.getId() == TMenu.MID_WINDOW_MOVE) {
838 inKeyboardResize = true;
839 return;
840 }
841
842 if (menu.getId() == TMenu.MID_WINDOW_ZOOM) {
843 if (maximized) {
844 restore();
845 } else {
846 maximize();
847 }
848 return;
849 }
850
851 // I didn't take it, pass it on to my children
852 super.onMenu(menu);
853 }
854
855 // ------------------------------------------------------------------------
856 // Passthru for Screen functions ------------------------------------------
857 // ------------------------------------------------------------------------
858
859 /**
860 * Get the attributes at one location.
861 *
862 * @param x column coordinate. 0 is the left-most column.
863 * @param y row coordinate. 0 is the top-most row.
864 * @return attributes at (x, y)
865 */
866 public final CellAttributes getAttrXY(final int x, final int y) {
867 return getScreen().getAttrXY(x, y);
868 }
869
870 /**
871 * Set the attributes at one location.
872 *
873 * @param x column coordinate. 0 is the left-most column.
874 * @param y row coordinate. 0 is the top-most row.
875 * @param attr attributes to use (bold, foreColor, backColor)
876 */
877 public final void putAttrXY(final int x, final int y,
878 final CellAttributes attr) {
879
880 getScreen().putAttrXY(x, y, attr);
881 }
882
883 /**
884 * Set the attributes at one location.
885 *
886 * @param x column coordinate. 0 is the left-most column.
887 * @param y row coordinate. 0 is the top-most row.
888 * @param attr attributes to use (bold, foreColor, backColor)
889 * @param clip if true, honor clipping/offset
890 */
891 public final void putAttrXY(final int x, final int y,
892 final CellAttributes attr, final boolean clip) {
893
894 getScreen().putAttrXY(x, y, attr, clip);
895 }
896
897 /**
898 * Fill the entire screen with one character with attributes.
899 *
900 * @param ch character to draw
901 * @param attr attributes to use (bold, foreColor, backColor)
902 */
903 public final void putAll(final char ch, final CellAttributes attr) {
904 getScreen().putAll(ch, attr);
905 }
906
907 /**
908 * Render one character with attributes.
909 *
910 * @param x column coordinate. 0 is the left-most column.
911 * @param y row coordinate. 0 is the top-most row.
912 * @param ch character + attributes to draw
913 */
914 public final void putCharXY(final int x, final int y, final Cell ch) {
915 getScreen().putCharXY(x, y, ch);
916 }
917
918 /**
919 * Render one character with attributes.
920 *
921 * @param x column coordinate. 0 is the left-most column.
922 * @param y row coordinate. 0 is the top-most row.
923 * @param ch character to draw
924 * @param attr attributes to use (bold, foreColor, backColor)
925 */
926 public final void putCharXY(final int x, final int y, final char ch,
927 final CellAttributes attr) {
928
929 getScreen().putCharXY(x, y, ch, attr);
930 }
931
932 /**
933 * Render one character without changing the underlying attributes.
934 *
935 * @param x column coordinate. 0 is the left-most column.
936 * @param y row coordinate. 0 is the top-most row.
937 * @param ch character to draw
938 */
939 public final void putCharXY(final int x, final int y, final char ch) {
940 getScreen().putCharXY(x, y, ch);
941 }
942
943 /**
944 * Render a string. Does not wrap if the string exceeds the line.
945 *
946 * @param x column coordinate. 0 is the left-most column.
947 * @param y row coordinate. 0 is the top-most row.
948 * @param str string to draw
949 * @param attr attributes to use (bold, foreColor, backColor)
950 */
951 public final void putStrXY(final int x, final int y, final String str,
952 final CellAttributes attr) {
953
954 getScreen().putStrXY(x, y, str, attr);
955 }
956
957 /**
958 * Render a string without changing the underlying attribute. Does not
959 * wrap if the string exceeds the line.
960 *
961 * @param x column coordinate. 0 is the left-most column.
962 * @param y row coordinate. 0 is the top-most row.
963 * @param str string to draw
964 */
965 public final void putStrXY(final int x, final int y, final String str) {
966 getScreen().putStrXY(x, y, str);
967 }
968
969 /**
970 * Draw a vertical line from (x, y) to (x, y + n).
971 *
972 * @param x column coordinate. 0 is the left-most column.
973 * @param y row coordinate. 0 is the top-most row.
974 * @param n number of characters to draw
975 * @param ch character to draw
976 * @param attr attributes to use (bold, foreColor, backColor)
977 */
978 public final void vLineXY(final int x, final int y, final int n,
979 final char ch, final CellAttributes attr) {
980
981 getScreen().vLineXY(x, y, n, ch, attr);
982 }
983
984 /**
985 * Draw a horizontal line from (x, y) to (x + n, y).
986 *
987 * @param x column coordinate. 0 is the left-most column.
988 * @param y row coordinate. 0 is the top-most row.
989 * @param n number of characters to draw
990 * @param ch character to draw
991 * @param attr attributes to use (bold, foreColor, backColor)
992 */
993 public final void hLineXY(final int x, final int y, final int n,
994 final char ch, final CellAttributes attr) {
995
996 getScreen().hLineXY(x, y, n, ch, attr);
997 }
998
999
1000}