+ /**
+ * Returns true if this window is modal.
+ *
+ * @return true if this window is modal
+ */
+ public final boolean isModal() {
+ if ((flags & MODAL) == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns true if this window has a close box.
+ *
+ * @return true if this window has a close box
+ */
+ public final boolean hasCloseBox() {
+ if ((flags & NOCLOSEBOX) != 0) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this window has a maximize/zoom box.
+ *
+ * @return true if this window has a maximize/zoom box
+ */
+ public final boolean hasZoomBox() {
+ if ((flags & NOZOOMBOX) != 0) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this window does not want menus to work while it is
+ * visible.
+ *
+ * @return true if this window does not want menus to work while it is
+ * visible
+ */
+ public final boolean hasOverriddenMenu() {
+ if ((flags & OVERRIDEMENU) != 0) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Retrieve the background color.
+ *
+ * @return the background color
+ */
+ public CellAttributes getBackground() {
+ if (!isModal()
+ && (inWindowMove || inWindowResize || inKeyboardResize)
+ ) {
+ assert (isActive());
+ return getTheme().getColor("twindow.background.windowmove");
+ } else if (isModal() && inWindowMove) {
+ assert (isActive());
+ return getTheme().getColor("twindow.background.modal");
+ } else if (isModal()) {
+ if (isActive()) {
+ return getTheme().getColor("twindow.background.modal");
+ }
+ return getTheme().getColor("twindow.background.modal.inactive");
+ } else if (isActive()) {
+ assert (!isModal());
+ return getTheme().getColor("twindow.background");
+ } else {
+ assert (!isModal());
+ return getTheme().getColor("twindow.background.inactive");
+ }
+ }
+
+ /**
+ * Retrieve the border color.
+ *
+ * @return the border color
+ */
+ public CellAttributes getBorder() {
+ if (!isModal()
+ && (inWindowMove || inWindowResize || inKeyboardResize)
+ ) {
+ if (!isActive()) {
+ // The user's terminal never passed a mouse up event, and now
+ // another window is active but we never finished a drag.
+ inWindowMove = false;
+ inWindowResize = false;
+ inKeyboardResize = false;
+ return getTheme().getColor("twindow.border.inactive");
+ }
+
+ return getTheme().getColor("twindow.border.windowmove");
+ } else if (isModal() && inWindowMove) {
+ assert (isActive());
+ return getTheme().getColor("twindow.border.modal.windowmove");
+ } else if (isModal()) {
+ if (isActive()) {
+ return getTheme().getColor("twindow.border.modal");
+ } else {
+ return getTheme().getColor("twindow.border.modal.inactive");
+ }
+ } else if (isActive()) {
+ assert (!isModal());
+ return getTheme().getColor("twindow.border");
+ } else {
+ assert (!isModal());
+ return getTheme().getColor("twindow.border.inactive");
+ }
+ }
+
+ /**
+ * Retrieve the color used by the window movement/sizing controls.
+ *
+ * @return the color used by the zoom box, resize bar, and close box
+ */
+ public CellAttributes getBorderControls() {
+ if (isModal()) {
+ return getTheme().getColor("twindow.border.modal.windowmove");
+ }
+ return getTheme().getColor("twindow.border.windowmove");
+ }
+
+ /**
+ * Retrieve the border line type.
+ *
+ * @return the border line type
+ */
+ private int getBorderType() {
+ if (!isModal()
+ && (inWindowMove || inWindowResize || inKeyboardResize)
+ ) {
+ assert (isActive());
+ return 1;
+ } else if (isModal() && inWindowMove) {
+ assert (isActive());
+ return 1;
+ } else if (isModal()) {
+ if (isActive()) {
+ return 2;
+ } else {
+ return 1;
+ }
+ } else if (isActive()) {
+ return 2;
+ } else {
+ return 1;
+ }
+ }
+
+ /**
+ * Returns true if this window does not want the application-wide mouse
+ * cursor drawn over it.
+ *
+ * @return true if this window does not want the application-wide mouse
+ * cursor drawn over it
+ */
+ public boolean hasHiddenMouse() {
+ return hideMouse;
+ }
+
+ /**
+ * Set request to prevent the application-wide mouse cursor from being
+ * drawn over this window.
+ *
+ * @param hideMouse if true, this window does not want the
+ * application-wide mouse cursor drawn over it
+ */
+ public final void setHiddenMouse(final boolean hideMouse) {
+ this.hideMouse = hideMouse;
+ }
+
+ /**
+ * Generate a human-readable string for this window.
+ *
+ * @return a human-readable string
+ */
+ @Override
+ public String toString() {
+ return String.format("%s(%8x) \'%s\' position (%d, %d) geometry %dx%d" +
+ " hidden %s modal %s", getClass().getName(), hashCode(), title,
+ getX(), getY(), getWidth(), getHeight(), hidden, isModal());
+ }