git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make Windows look like X11, why does this work
[fanfix.git]
/
src
/
jexer
/
TWindow.java
diff --git
a/src/jexer/TWindow.java
b/src/jexer/TWindow.java
index d57b844d7d4408c4c14c70e4076914782bc90f4a..e047bc80204324f4298e475c9677c5de3c2ea6f7 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;
@@
-475,15
+473,15
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
// Draw the title
int titleLeft = (getWidth() - title.length() - 2) / 2;
putCharXY(titleLeft, 0, ' ', border);
// Draw the title
int titleLeft = (getWidth() - title.length() - 2) / 2;
putCharXY(titleLeft, 0, ' ', border);
- putStrXY(titleLeft + 1, 0, title);
+ putStr
ing
XY(titleLeft + 1, 0, title);
putCharXY(titleLeft + title.length() + 1, 0, ' ', border);
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,26
+748,38
@@
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);
}
}
+ // Pass a resize event to my children
+ onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
+ getWidth(), getHeight()));
+
return;
}
return;
}
@@
-996,10
+1003,10
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
* @param str string to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
* @param str string to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public final void putStrXY(final int x, final int y, final String str,
+ public final void putStr
ing
XY(final int x, final int y, final String str,
final CellAttributes attr) {
final CellAttributes attr) {
- getScreen().putStrXY(x, y, str, attr);
+ getScreen().putStr
ing
XY(x, y, str, attr);
}
/**
}
/**
@@
-1010,8
+1017,8
@@
public class TWindow extends TWidget implements Comparable<TWindow> {
* @param y row coordinate. 0 is the top-most row.
* @param str string to draw
*/
* @param y row coordinate. 0 is the top-most row.
* @param str string to draw
*/
- public final void putStrXY(final int x, final int y, final String str) {
- getScreen().putStrXY(x, y, str);
+ public final void putStr
ing
XY(final int x, final int y, final String str) {
+ getScreen().putStr
ing
XY(x, y, str);
}
/**
}
/**