git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
telnet support 75%
[nikiroo-utils.git]
/
src
/
jexer
/
TWindow.java
diff --git
a/src/jexer/TWindow.java
b/src/jexer/TWindow.java
index d57b844d7d4408c4c14c70e4076914782bc90f4a..82d187c762a4d89743edbc6bdd600c6409b0a810 100644
(file)
--- a/
src/jexer/TWindow.java
+++ b/
src/jexer/TWindow.java
@@
-46,7
+46,7
@@
import static jexer.TKeypress.*;
/**
* TWindow is the top-level container and drawing surface for other widgets.
*/
/**
* TWindow is the top-level container and drawing surface for other widgets.
*/
-public class TWindow extends TWidget
implements Comparable<TWindow>
{
+public class TWindow extends TWidget {
/**
* Window's parent TApplication.
/**
* Window's parent TApplication.
@@
-143,13
+143,13
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
* If true, then the user clicked on the title bar and is moving the
* window.
*/
* If true, then the user clicked on the title bar and is moving the
* window.
*/
- pr
ivate
boolean inWindowMove = false;
+ pr
otected
boolean inWindowMove = false;
/**
* If true, then the user clicked on the bottom right corner and is
* resizing the window.
*/
/**
* If true, then the user clicked on the bottom right corner and is
* resizing the window.
*/
- pr
ivate
boolean inWindowResize = false;
+ pr
otected
boolean inWindowResize = false;
/**
* If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is
/**
* If true, then the user selected "Size/Move" (or hit Ctrl-F5) and is
@@
-187,6
+187,15
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
private int restoreWindowX;
private int restoreWindowY;
private int restoreWindowX;
private int restoreWindowY;
+ /**
+ * Set the maximum width for this window.
+ *
+ * @param maximumWindowWidth new maximum width
+ */
+ public final void setMaximumWindowWidth(final int maximumWindowWidth) {
+ this.maximumWindowWidth = maximumWindowWidth;
+ }
+
/**
* Public constructor. Window will be located at (0, 0).
*
/**
* Public constructor. Window will be located at (0, 0).
*
@@
-305,17
+314,6
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
return true;
}
return true;
}
- /**
- * Comparison operator sorts on z.
- *
- * @param that another TWindow instance
- * @return difference between this.z and that.z
- */
- @Override
- public final int compareTo(final TWindow that) {
- return (this.z - that.z);
- }
-
/**
* Returns true if the mouse is currently on the close button.
*
/**
* Returns true if the mouse is currently on the close button.
*
@@
-376,17
+374,17
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
- assert (
get
Active());
+ assert (
is
Active());
return getTheme().getColor("twindow.background.windowmove");
} else if (isModal() && inWindowMove) {
return getTheme().getColor("twindow.background.windowmove");
} else if (isModal() && inWindowMove) {
- assert (
get
Active());
+ assert (
is
Active());
return getTheme().getColor("twindow.background.modal");
} else if (isModal()) {
return getTheme().getColor("twindow.background.modal");
} else if (isModal()) {
- if (
get
Active()) {
+ if (
is
Active()) {
return getTheme().getColor("twindow.background.modal");
}
return getTheme().getColor("twindow.background.modal.inactive");
return getTheme().getColor("twindow.background.modal");
}
return getTheme().getColor("twindow.background.modal.inactive");
- } else if (
get
Active()) {
+ } else if (
is
Active()) {
assert (!isModal());
return getTheme().getColor("twindow.background");
} else {
assert (!isModal());
return getTheme().getColor("twindow.background");
} else {
@@
-404,18
+402,18
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
- assert (
get
Active());
+ assert (
is
Active());
return getTheme().getColor("twindow.border.windowmove");
} else if (isModal() && inWindowMove) {
return getTheme().getColor("twindow.border.windowmove");
} else if (isModal() && inWindowMove) {
- assert (
get
Active());
+ assert (
is
Active());
return getTheme().getColor("twindow.border.modal.windowmove");
} else if (isModal()) {
return getTheme().getColor("twindow.border.modal.windowmove");
} else if (isModal()) {
- if (
get
Active()) {
+ if (
is
Active()) {
return getTheme().getColor("twindow.border.modal");
} else {
return getTheme().getColor("twindow.border.modal.inactive");
}
return getTheme().getColor("twindow.border.modal");
} else {
return getTheme().getColor("twindow.border.modal.inactive");
}
- } else if (
get
Active()) {
+ } else if (
is
Active()) {
assert (!isModal());
return getTheme().getColor("twindow.border");
} else {
assert (!isModal());
return getTheme().getColor("twindow.border");
} else {
@@
-433,18
+431,18
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
- assert (
get
Active());
+ assert (
is
Active());
return 1;
} else if (isModal() && inWindowMove) {
return 1;
} else if (isModal() && inWindowMove) {
- assert (
get
Active());
+ assert (
is
Active());
return 1;
} else if (isModal()) {
return 1;
} else if (isModal()) {
- if (
get
Active()) {
+ if (
is
Active()) {
return 2;
} else {
return 1;
}
return 2;
} else {
return 1;
}
- } else if (
get
Active()) {
+ } else if (
is
Active()) {
return 2;
} else {
return 1;
return 2;
} else {
return 1;
@@
-478,12
+476,12
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
putStrXY(titleLeft + 1, 0, title);
putCharXY(titleLeft + title.length() + 1, 0, ' ', border);
putStrXY(titleLeft + 1, 0, title);
putCharXY(titleLeft + title.length() + 1, 0, ' ', border);
- if (
get
Active()) {
+ if (
is
Active()) {
// Draw the close button
putCharXY(2, 0, '[', border);
putCharXY(4, 0, ']', border);
// Draw the close button
putCharXY(2, 0, '[', border);
putCharXY(4, 0, ']', border);
- if (mouseOnClose() && mouse.
get
Mouse1()) {
+ if (mouseOnClose() && mouse.
is
Mouse1()) {
putCharXY(3, 0, GraphicsChars.CP437[0x0F],
!isModal()
? getTheme().getColor("twindow.border.windowmove")
putCharXY(3, 0, GraphicsChars.CP437[0x0F],
!isModal()
? getTheme().getColor("twindow.border.windowmove")
@@
-500,7
+498,7
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
putCharXY(getWidth() - 5, 0, '[', border);
putCharXY(getWidth() - 3, 0, ']', border);
putCharXY(getWidth() - 5, 0, '[', border);
putCharXY(getWidth() - 3, 0, ']', border);
- if (mouseOnMaximize() && mouse.
get
Mouse1()) {
+ if (mouseOnMaximize() && mouse.
is
Mouse1()) {
putCharXY(getWidth() - 4, 0, GraphicsChars.CP437[0x0F],
getTheme().getColor("twindow.border.windowmove"));
} else {
putCharXY(getWidth() - 4, 0, GraphicsChars.CP437[0x0F],
getTheme().getColor("twindow.border.windowmove"));
} else {
@@
-534,12
+532,11
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
@Override
public void onMouseDown(final TMouseEvent mouse) {
this.mouse = mouse;
@Override
public void onMouseDown(final TMouseEvent mouse) {
this.mouse = mouse;
- application.setRepaint();
inKeyboardResize = false;
if ((mouse.getAbsoluteY() == getY())
inKeyboardResize = false;
if ((mouse.getAbsoluteY() == getY())
- && mouse.
get
Mouse1()
+ && mouse.
is
Mouse1()
&& (getX() <= mouse.getAbsoluteX())
&& (mouse.getAbsoluteX() < getX() + getWidth())
&& !mouseOnClose()
&& (getX() <= mouse.getAbsoluteX())
&& (mouse.getAbsoluteX() < getX() + getWidth())
&& !mouseOnClose()
@@
-607,28
+604,27
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
@Override
public void onMouseUp(final TMouseEvent mouse) {
this.mouse = mouse;
@Override
public void onMouseUp(final TMouseEvent mouse) {
this.mouse = mouse;
- application.setRepaint();
- if ((inWindowMove) && (mouse.
get
Mouse1())) {
+ if ((inWindowMove) && (mouse.
is
Mouse1())) {
// Stop moving window
inWindowMove = false;
return;
}
// Stop moving window
inWindowMove = false;
return;
}
- if ((inWindowResize) && (mouse.
get
Mouse1())) {
+ if ((inWindowResize) && (mouse.
is
Mouse1())) {
// Stop resizing window
inWindowResize = false;
return;
}
// Stop resizing window
inWindowResize = false;
return;
}
- if (mouse.
get
Mouse1() && mouseOnClose()) {
+ if (mouse.
is
Mouse1() && mouseOnClose()) {
// Close window
application.closeWindow(this);
return;
}
if ((mouse.getAbsoluteY() == getY())
// Close window
application.closeWindow(this);
return;
}
if ((mouse.getAbsoluteY() == getY())
- && mouse.
get
Mouse1()
+ && mouse.
is
Mouse1()
&& mouseOnMaximize()) {
if (maximized) {
// Restore
&& mouseOnMaximize()) {
if (maximized) {
// Restore
@@
-655,7
+651,6
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
@Override
public void onMouseMotion(final TMouseEvent mouse) {
this.mouse = mouse;
@Override
public void onMouseMotion(final TMouseEvent mouse) {
this.mouse = mouse;
- application.setRepaint();
if (inWindowMove) {
// Move window over
if (inWindowMove) {
// Move window over
@@
-753,22
+748,30
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
}
}
if (keypress.equals(kbShiftLeft)) {
}
}
if (keypress.equals(kbShiftLeft)) {
- if (getWidth() > minimumWindowWidth) {
+ if ((getWidth() > minimumWindowWidth)
+ || (minimumWindowWidth <= 0)
+ ) {
setWidth(getWidth() - 1);
}
}
if (keypress.equals(kbShiftRight)) {
setWidth(getWidth() - 1);
}
}
if (keypress.equals(kbShiftRight)) {
- if (getWidth() < maximumWindowWidth) {
+ if ((getWidth() < maximumWindowWidth)
+ || (maximumWindowWidth <= 0)
+ ) {
setWidth(getWidth() + 1);
}
}
if (keypress.equals(kbShiftUp)) {
setWidth(getWidth() + 1);
}
}
if (keypress.equals(kbShiftUp)) {
- if (getHeight() > minimumWindowHeight) {
+ if ((getHeight() > minimumWindowHeight)
+ || (minimumWindowHeight <= 0)
+ ) {
setHeight(getHeight() - 1);
}
}
if (keypress.equals(kbShiftDown)) {
setHeight(getHeight() - 1);
}
}
if (keypress.equals(kbShiftDown)) {
- if (getHeight() < maximumWindowHeight) {
+ if ((getHeight() < maximumWindowHeight)
+ || (maximumWindowHeight <= 0)
+ ) {
setHeight(getHeight() + 1);
}
}
setHeight(getHeight() + 1);
}
}