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 public void maximize() {
311 restoreWindowWidth
= getWidth();
312 restoreWindowHeight
= getHeight();
313 restoreWindowX
= getX();
314 restoreWindowY
= getY();
315 setWidth(getScreen().getWidth());
316 setHeight(application
.getDesktopBottom() - 1);
323 * Restore (unmaximize) window.
325 public void restore() {
330 setWidth(restoreWindowWidth
);
331 setHeight(restoreWindowHeight
);
332 setX(restoreWindowX
);
333 setY(restoreWindowY
);
337 // ------------------------------------------------------------------------
338 // Window visibility ------------------------------------------------------
339 // ------------------------------------------------------------------------
342 * Hidden flag. A hidden window will still have its onIdle() called, and
343 * will also have onClose() called at application exit. Note package
344 * private access: TApplication will force hidden false if a modal window
347 boolean hidden
= false;
350 * Returns true if this window is hidden.
352 * @return true if this window is hidden, false if the window is shown
354 public final boolean isHidden() {
359 * Returns true if this window is shown.
361 * @return true if this window is shown, false if the window is hidden
363 public final boolean isShown() {
368 * Hide window. A hidden window will still have its onIdle() called, and
369 * will also have onClose() called at application exit. Hidden windows
370 * will not receive any other events.
373 application
.hideWindow(this);
380 application
.showWindow(this);
384 * Activate window (bring to top and receive events).
386 public void activate() {
387 application
.activateWindow(this);
390 // ------------------------------------------------------------------------
391 // Constructors -----------------------------------------------------------
392 // ------------------------------------------------------------------------
395 * Public constructor. Window will be located at (0, 0).
397 * @param application TApplication that manages this window
398 * @param title window title, will be centered along the top border
399 * @param width width of window
400 * @param height height of window
402 public TWindow(final TApplication application
, final String title
,
403 final int width
, final int height
) {
405 this(application
, title
, 0, 0, width
, height
, RESIZABLE
);
409 * Public constructor. Window will be located at (0, 0).
411 * @param application TApplication that manages this window
412 * @param title window title, will be centered along the top border
413 * @param width width of window
414 * @param height height of window
415 * @param flags bitmask of RESIZABLE, CENTERED, or MODAL
417 public TWindow(final TApplication application
, final String title
,
418 final int width
, final int height
, final int flags
) {
420 this(application
, title
, 0, 0, width
, height
, flags
);
424 * Public constructor.
426 * @param application TApplication that manages this window
427 * @param title window title, will be centered along the top border
428 * @param x column relative to parent
429 * @param y row relative to parent
430 * @param width width of window
431 * @param height height of window
433 public TWindow(final TApplication application
, final String title
,
434 final int x
, final int y
, final int width
, final int height
) {
436 this(application
, title
, x
, y
, width
, height
, RESIZABLE
);
440 * Public constructor.
442 * @param application TApplication that manages this window
443 * @param title window title, will be centered along the top border
444 * @param x column relative to parent
445 * @param y row relative to parent
446 * @param width width of window
447 * @param height height of window
448 * @param flags mask of RESIZABLE, CENTERED, or MODAL
450 public TWindow(final TApplication application
, final String title
,
451 final int x
, final int y
, final int width
, final int height
,
456 // I am my own window and parent
457 setupForTWindow(this, x
, y
+ application
.getDesktopTop(),
462 this.application
= application
;
465 // Minimum width/height are 10 and 2
466 assert (width
>= 10);
467 assert (getHeight() >= 2);
469 // MODAL implies CENTERED
471 this.flags
|= CENTERED
;
474 // Center window if specified
477 // Add me to the application
478 application
.addWindow(this);
481 // ------------------------------------------------------------------------
482 // General behavior -------------------------------------------------------
483 // ------------------------------------------------------------------------
486 * Returns true if this window is modal.
488 * @return true if this window is modal
490 public final boolean isModal() {
491 if ((flags
& MODAL
) == 0) {
498 * Retrieve the background color.
500 * @return the background color
502 public final CellAttributes
getBackground() {
504 && (inWindowMove
|| inWindowResize
|| inKeyboardResize
)
507 return getTheme().getColor("twindow.background.windowmove");
508 } else if (isModal() && inWindowMove
) {
510 return getTheme().getColor("twindow.background.modal");
511 } else if (isModal()) {
513 return getTheme().getColor("twindow.background.modal");
515 return getTheme().getColor("twindow.background.modal.inactive");
516 } else if (isActive()) {
518 return getTheme().getColor("twindow.background");
521 return getTheme().getColor("twindow.background.inactive");
526 * Retrieve the border color.
528 * @return the border color
530 public CellAttributes
getBorder() {
532 && (inWindowMove
|| inWindowResize
|| inKeyboardResize
)
535 return getTheme().getColor("twindow.border.windowmove");
536 } else if (isModal() && inWindowMove
) {
538 return getTheme().getColor("twindow.border.modal.windowmove");
539 } else if (isModal()) {
541 return getTheme().getColor("twindow.border.modal");
543 return getTheme().getColor("twindow.border.modal.inactive");
545 } else if (isActive()) {
547 return getTheme().getColor("twindow.border");
550 return getTheme().getColor("twindow.border.inactive");
555 * Retrieve the border line type.
557 * @return the border line type
559 private int getBorderType() {
561 && (inWindowMove
|| inWindowResize
|| inKeyboardResize
)
565 } else if (isModal() && inWindowMove
) {
568 } else if (isModal()) {
574 } else if (isActive()) {
582 * Called by TApplication.drawChildren() to render on screen.
586 // Draw the box and background first.
587 CellAttributes border
= getBorder();
588 CellAttributes background
= getBackground();
589 int borderType
= getBorderType();
591 getScreen().drawBox(0, 0, getWidth(), getHeight(), border
,
592 background
, borderType
, true);
595 int titleLeft
= (getWidth() - title
.length() - 2) / 2;
596 putCharXY(titleLeft
, 0, ' ', border
);
597 putStringXY(titleLeft
+ 1, 0, title
);
598 putCharXY(titleLeft
+ title
.length() + 1, 0, ' ', border
);
602 // Draw the close button
603 putCharXY(2, 0, '[', border
);
604 putCharXY(4, 0, ']', border
);
605 if (mouseOnClose() && mouse
.isMouse1()) {
606 putCharXY(3, 0, GraphicsChars
.CP437
[0x0F],
608 ?
getTheme().getColor("twindow.border.windowmove")
609 : getTheme().getColor("twindow.border.modal.windowmove"));
611 putCharXY(3, 0, GraphicsChars
.CP437
[0xFE],
613 ?
getTheme().getColor("twindow.border.windowmove")
614 : getTheme().getColor("twindow.border.modal.windowmove"));
617 // Draw the maximize button
620 putCharXY(getWidth() - 5, 0, '[', border
);
621 putCharXY(getWidth() - 3, 0, ']', border
);
622 if (mouseOnMaximize() && mouse
.isMouse1()) {
623 putCharXY(getWidth() - 4, 0, GraphicsChars
.CP437
[0x0F],
624 getTheme().getColor("twindow.border.windowmove"));
627 putCharXY(getWidth() - 4, 0, GraphicsChars
.CP437
[0x12],
628 getTheme().getColor("twindow.border.windowmove"));
630 putCharXY(getWidth() - 4, 0, GraphicsChars
.UPARROW
,
631 getTheme().getColor("twindow.border.windowmove"));
635 // Draw the resize corner
636 if ((flags
& RESIZABLE
) != 0) {
637 putCharXY(getWidth() - 2, getHeight() - 1,
638 GraphicsChars
.SINGLE_BAR
,
639 getTheme().getColor("twindow.border.windowmove"));
640 putCharXY(getWidth() - 1, getHeight() - 1,
641 GraphicsChars
.LRCORNER
,
642 getTheme().getColor("twindow.border.windowmove"));
648 // ------------------------------------------------------------------------
649 // Event handlers ---------------------------------------------------------
650 // ------------------------------------------------------------------------
653 * Returns true if the mouse is currently on the close button.
655 * @return true if mouse is currently on the close button
657 protected boolean mouseOnClose() {
659 && (mouse
.getAbsoluteY() == getY())
660 && (mouse
.getAbsoluteX() == getX() + 3)
668 * Returns true if the mouse is currently on the maximize/restore button.
670 * @return true if the mouse is currently on the maximize/restore button
672 protected boolean mouseOnMaximize() {
675 && (mouse
.getAbsoluteY() == getY())
676 && (mouse
.getAbsoluteX() == getX() + getWidth() - 4)
684 * Returns true if the mouse is currently on the resizable lower right
687 * @return true if the mouse is currently on the resizable lower right
690 protected boolean mouseOnResize() {
691 if (((flags
& RESIZABLE
) != 0)
694 && (mouse
.getAbsoluteY() == getY() + getHeight() - 1)
695 && ((mouse
.getAbsoluteX() == getX() + getWidth() - 1)
696 || (mouse
.getAbsoluteX() == getX() + getWidth() - 2))
704 * Subclasses should override this method to cleanup resources. This is
705 * called by application.closeWindow().
707 public void onClose() {
708 // Default: do nothing
712 * Called by application.switchWindow() when this window gets the
713 * focus, and also by application.addWindow().
715 public void onFocus() {
716 // Default: do nothing
720 * Called by application.switchWindow() when another window gets the
723 public void onUnfocus() {
724 // Default: do nothing
728 * Called by application.hideWindow().
730 public void onHide() {
731 // Default: do nothing
735 * Called by application.showWindow().
737 public void onShow() {
738 // Default: do nothing
742 * Handle mouse button presses.
744 * @param mouse mouse button event
747 public void onMouseDown(final TMouseEvent mouse
) {
750 inKeyboardResize
= false;
752 if ((mouse
.getAbsoluteY() == getY())
754 && (getX() <= mouse
.getAbsoluteX())
755 && (mouse
.getAbsoluteX() < getX() + getWidth())
757 && !mouseOnMaximize()
759 // Begin moving window
761 moveWindowMouseX
= mouse
.getAbsoluteX();
762 moveWindowMouseY
= mouse
.getAbsoluteY();
770 if (mouseOnResize()) {
771 // Begin window resize
772 inWindowResize
= true;
773 moveWindowMouseX
= mouse
.getAbsoluteX();
774 moveWindowMouseY
= mouse
.getAbsoluteY();
775 resizeWindowWidth
= getWidth();
776 resizeWindowHeight
= getHeight();
783 // Give the shortcut bar a shot at this.
784 if (statusBar
!= null) {
785 if (statusBar
.statusBarMouseDown(mouse
)) {
790 // I didn't take it, pass it on to my children
791 super.onMouseDown(mouse
);
795 * Handle mouse button releases.
797 * @param mouse mouse button release event
800 public void onMouseUp(final TMouseEvent mouse
) {
803 if ((inWindowMove
) && (mouse
.isMouse1())) {
804 // Stop moving window
805 inWindowMove
= false;
809 if ((inWindowResize
) && (mouse
.isMouse1())) {
810 // Stop resizing window
811 inWindowResize
= false;
815 if (mouse
.isMouse1() && mouseOnClose()) {
817 application
.closeWindow(this);
821 if ((mouse
.getAbsoluteY() == getY())
823 && mouseOnMaximize()) {
831 // Pass a resize event to my children
832 onResize(new TResizeEvent(TResizeEvent
.Type
.WIDGET
,
833 getWidth(), getHeight()));
837 // Give the shortcut bar a shot at this.
838 if (statusBar
!= null) {
839 if (statusBar
.statusBarMouseUp(mouse
)) {
844 // I didn't take it, pass it on to my children
845 super.onMouseUp(mouse
);
849 * Handle mouse movements.
851 * @param mouse mouse motion event
854 public void onMouseMotion(final TMouseEvent mouse
) {
859 setX(oldWindowX
+ (mouse
.getAbsoluteX() - moveWindowMouseX
));
860 setY(oldWindowY
+ (mouse
.getAbsoluteY() - moveWindowMouseY
));
861 // Don't cover up the menu bar
862 if (getY() < application
.getDesktopTop()) {
863 setY(application
.getDesktopTop());
865 // Don't go below the status bar
866 if (getY() >= application
.getDesktopBottom()) {
867 setY(application
.getDesktopBottom() - 1);
872 if (inWindowResize
) {
874 setWidth(resizeWindowWidth
+ (mouse
.getAbsoluteX()
875 - moveWindowMouseX
));
876 setHeight(resizeWindowHeight
+ (mouse
.getAbsoluteY()
877 - moveWindowMouseY
));
878 if (getX() + getWidth() > getScreen().getWidth()) {
879 setWidth(getScreen().getWidth() - getX());
881 if (getY() + getHeight() > application
.getDesktopBottom()) {
882 setY(application
.getDesktopBottom() - getHeight() + 1);
884 // Don't cover up the menu bar
885 if (getY() < application
.getDesktopTop()) {
886 setY(application
.getDesktopTop());
889 // Keep within min/max bounds
890 if (getWidth() < minimumWindowWidth
) {
891 setWidth(minimumWindowWidth
);
892 inWindowResize
= false;
894 if (getHeight() < minimumWindowHeight
) {
895 setHeight(minimumWindowHeight
);
896 inWindowResize
= false;
898 if ((maximumWindowWidth
> 0)
899 && (getWidth() > maximumWindowWidth
)
901 setWidth(maximumWindowWidth
);
902 inWindowResize
= false;
904 if ((maximumWindowHeight
> 0)
905 && (getHeight() > maximumWindowHeight
)
907 setHeight(maximumWindowHeight
);
908 inWindowResize
= false;
911 // Pass a resize event to my children
912 onResize(new TResizeEvent(TResizeEvent
.Type
.WIDGET
,
913 getWidth(), getHeight()));
917 // Give the shortcut bar a shot at this.
918 if (statusBar
!= null) {
919 statusBar
.statusBarMouseMotion(mouse
);
922 // I didn't take it, pass it on to my children
923 super.onMouseMotion(mouse
);
929 * @param keypress keystroke event
932 public void onKeypress(final TKeypressEvent keypress
) {
934 if (inKeyboardResize
) {
936 // ESC or ENTER - Exit size/move
937 if (keypress
.equals(kbEsc
) || keypress
.equals(kbEnter
)) {
938 inKeyboardResize
= false;
941 if (keypress
.equals(kbLeft
)) {
946 if (keypress
.equals(kbRight
)) {
947 if (getX() < getScreen().getWidth() - 1) {
951 if (keypress
.equals(kbDown
)) {
952 if (getY() < application
.getDesktopBottom() - 1) {
956 if (keypress
.equals(kbUp
)) {
961 if (keypress
.equals(kbShiftLeft
)) {
962 if ((getWidth() > minimumWindowWidth
)
963 || (minimumWindowWidth
<= 0)
965 setWidth(getWidth() - 1);
968 if (keypress
.equals(kbShiftRight
)) {
969 if ((getWidth() < maximumWindowWidth
)
970 || (maximumWindowWidth
<= 0)
972 setWidth(getWidth() + 1);
975 if (keypress
.equals(kbShiftUp
)) {
976 if ((getHeight() > minimumWindowHeight
)
977 || (minimumWindowHeight
<= 0)
979 setHeight(getHeight() - 1);
982 if (keypress
.equals(kbShiftDown
)) {
983 if ((getHeight() < maximumWindowHeight
)
984 || (maximumWindowHeight
<= 0)
986 setHeight(getHeight() + 1);
990 // Pass a resize event to my children
991 onResize(new TResizeEvent(TResizeEvent
.Type
.WIDGET
,
992 getWidth(), getHeight()));
997 // Give the shortcut bar a shot at this.
998 if (statusBar
!= null) {
999 if (statusBar
.statusBarKeypress(keypress
)) {
1004 // These keystrokes will typically not be seen unless a subclass
1005 // overrides onMenu() due to how TApplication dispatches
1008 if (!(this instanceof TDesktop
)) {
1010 // Ctrl-W - close window
1011 if (keypress
.equals(kbCtrlW
)) {
1012 application
.closeWindow(this);
1016 // F6 - behave like Alt-TAB
1017 if (keypress
.equals(kbF6
)) {
1018 application
.switchWindow(true);
1022 // Shift-F6 - behave like Shift-Alt-TAB
1023 if (keypress
.equals(kbShiftF6
)) {
1024 application
.switchWindow(false);
1029 if (keypress
.equals(kbF5
)) {
1037 // Ctrl-F5 - size/move
1038 if (keypress
.equals(kbCtrlF5
)) {
1039 inKeyboardResize
= !inKeyboardResize
;
1042 } // if (!(this instanceof TDesktop))
1044 // I didn't take it, pass it on to my children
1045 super.onKeypress(keypress
);
1049 * Handle posted command events.
1051 * @param command command event
1054 public void onCommand(final TCommandEvent command
) {
1056 // These commands will typically not be seen unless a subclass
1057 // overrides onMenu() due to how TApplication dispatches
1060 if (!(this instanceof TDesktop
)) {
1062 if (command
.equals(cmWindowClose
)) {
1063 application
.closeWindow(this);
1067 if (command
.equals(cmWindowNext
)) {
1068 application
.switchWindow(true);
1072 if (command
.equals(cmWindowPrevious
)) {
1073 application
.switchWindow(false);
1077 if (command
.equals(cmWindowMove
)) {
1078 inKeyboardResize
= true;
1082 if (command
.equals(cmWindowZoom
)) {
1090 } // if (!(this instanceof TDesktop))
1092 // I didn't take it, pass it on to my children
1093 super.onCommand(command
);
1097 * Handle posted menu events.
1099 * @param menu menu event
1102 public void onMenu(final TMenuEvent menu
) {
1104 if (!(this instanceof TDesktop
)) {
1106 if (menu
.getId() == TMenu
.MID_WINDOW_CLOSE
) {
1107 application
.closeWindow(this);
1111 if (menu
.getId() == TMenu
.MID_WINDOW_NEXT
) {
1112 application
.switchWindow(true);
1116 if (menu
.getId() == TMenu
.MID_WINDOW_PREVIOUS
) {
1117 application
.switchWindow(false);
1121 if (menu
.getId() == TMenu
.MID_WINDOW_MOVE
) {
1122 inKeyboardResize
= true;
1126 if (menu
.getId() == TMenu
.MID_WINDOW_ZOOM
) {
1135 } // if (!(this instanceof TDesktop))
1137 // I didn't take it, pass it on to my children
1141 // ------------------------------------------------------------------------
1142 // Passthru for Screen functions ------------------------------------------
1143 // ------------------------------------------------------------------------
1146 * Get the attributes at one location.
1148 * @param x column coordinate. 0 is the left-most column.
1149 * @param y row coordinate. 0 is the top-most row.
1150 * @return attributes at (x, y)
1152 public final CellAttributes
getAttrXY(final int x
, final int y
) {
1153 return getScreen().getAttrXY(x
, y
);
1157 * Set the attributes at one location.
1159 * @param x column coordinate. 0 is the left-most column.
1160 * @param y row coordinate. 0 is the top-most row.
1161 * @param attr attributes to use (bold, foreColor, backColor)
1163 public final void putAttrXY(final int x
, final int y
,
1164 final CellAttributes attr
) {
1166 getScreen().putAttrXY(x
, y
, attr
);
1170 * Set the attributes at one location.
1172 * @param x column coordinate. 0 is the left-most column.
1173 * @param y row coordinate. 0 is the top-most row.
1174 * @param attr attributes to use (bold, foreColor, backColor)
1175 * @param clip if true, honor clipping/offset
1177 public final void putAttrXY(final int x
, final int y
,
1178 final CellAttributes attr
, final boolean clip
) {
1180 getScreen().putAttrXY(x
, y
, attr
, clip
);
1184 * Fill the entire screen with one character with attributes.
1186 * @param ch character to draw
1187 * @param attr attributes to use (bold, foreColor, backColor)
1189 public final void putAll(final char ch
, final CellAttributes attr
) {
1190 getScreen().putAll(ch
, attr
);
1194 * Render one character with attributes.
1196 * @param x column coordinate. 0 is the left-most column.
1197 * @param y row coordinate. 0 is the top-most row.
1198 * @param ch character + attributes to draw
1200 public final void putCharXY(final int x
, final int y
, final Cell ch
) {
1201 getScreen().putCharXY(x
, y
, ch
);
1205 * Render one character with attributes.
1207 * @param x column coordinate. 0 is the left-most column.
1208 * @param y row coordinate. 0 is the top-most row.
1209 * @param ch character to draw
1210 * @param attr attributes to use (bold, foreColor, backColor)
1212 public final void putCharXY(final int x
, final int y
, final char ch
,
1213 final CellAttributes attr
) {
1215 getScreen().putCharXY(x
, y
, ch
, attr
);
1219 * Render one character without changing the underlying attributes.
1221 * @param x column coordinate. 0 is the left-most column.
1222 * @param y row coordinate. 0 is the top-most row.
1223 * @param ch character to draw
1225 public final void putCharXY(final int x
, final int y
, final char ch
) {
1226 getScreen().putCharXY(x
, y
, ch
);
1230 * Render a string. Does not wrap if the string exceeds the line.
1232 * @param x column coordinate. 0 is the left-most column.
1233 * @param y row coordinate. 0 is the top-most row.
1234 * @param str string to draw
1235 * @param attr attributes to use (bold, foreColor, backColor)
1237 public final void putStringXY(final int x
, final int y
, final String str
,
1238 final CellAttributes attr
) {
1240 getScreen().putStringXY(x
, y
, str
, attr
);
1244 * Render a string without changing the underlying attribute. Does not
1245 * wrap if the string exceeds the line.
1247 * @param x column coordinate. 0 is the left-most column.
1248 * @param y row coordinate. 0 is the top-most row.
1249 * @param str string to draw
1251 public final void putStringXY(final int x
, final int y
, final String str
) {
1252 getScreen().putStringXY(x
, y
, str
);
1256 * Draw a vertical line from (x, y) to (x, y + n).
1258 * @param x column coordinate. 0 is the left-most column.
1259 * @param y row coordinate. 0 is the top-most row.
1260 * @param n number of characters to draw
1261 * @param ch character to draw
1262 * @param attr attributes to use (bold, foreColor, backColor)
1264 public final void vLineXY(final int x
, final int y
, final int n
,
1265 final char ch
, final CellAttributes attr
) {
1267 getScreen().vLineXY(x
, y
, n
, ch
, attr
);
1271 * Draw a horizontal line from (x, y) to (x + n, y).
1273 * @param x column coordinate. 0 is the left-most column.
1274 * @param y row coordinate. 0 is the top-most row.
1275 * @param n number of characters to draw
1276 * @param ch character to draw
1277 * @param attr attributes to use (bold, foreColor, backColor)
1279 public final void hLineXY(final int x
, final int y
, final int n
,
1280 final char ch
, final CellAttributes attr
) {
1282 getScreen().hLineXY(x
, y
, n
, ch
, attr
);