mirror of
https://gitlab.com/AutumnMeowMeow/jexer
synced 2024-09-19 11:50:19 -06:00
Sexy look in demo
This commit is contained in:
parent
533bf0f494
commit
642bdc3c6f
9 changed files with 394 additions and 64 deletions
|
@ -116,41 +116,47 @@ public class TButton extends TWidget {
|
|||
*/
|
||||
private CellAttributes shadowColor;
|
||||
|
||||
/**
|
||||
* The background color used for the button shadow, as set by
|
||||
* setShadowColor().
|
||||
*/
|
||||
private CellAttributes givenShadowColor;
|
||||
|
||||
/**
|
||||
* The style of button to draw.
|
||||
*/
|
||||
private Style style = Style.SQUARE;
|
||||
|
||||
/**
|
||||
* The left edge character, used if the enclosing window has a custom
|
||||
* border.
|
||||
* The left edge character.
|
||||
*/
|
||||
private Cell leftEdgeChar;
|
||||
|
||||
/**
|
||||
* The right edge character, used if the enclosing window has a custom
|
||||
* border.
|
||||
* The right edge character.
|
||||
*/
|
||||
private Cell rightEdgeChar;
|
||||
|
||||
/**
|
||||
* The left edge character, used if the enclosing window has a custom
|
||||
* border.
|
||||
* The left edge character.
|
||||
*/
|
||||
private Cell leftEdgeShadowChar;
|
||||
|
||||
/**
|
||||
* The right edge character, used if the enclosing window has a custom
|
||||
* border.
|
||||
* The right edge character.
|
||||
*/
|
||||
private Cell rightEdgeShadowCharTop;
|
||||
|
||||
/**
|
||||
* The right edge character, used if the enclosing window has a custom
|
||||
* border.
|
||||
* The right edge character.
|
||||
*/
|
||||
private Cell rightEdgeShadowCharBottom;
|
||||
|
||||
/**
|
||||
* The bottom shadow character.
|
||||
*/
|
||||
private Cell shadowCharBottom;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Constructors -----------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -176,10 +182,7 @@ public class TButton extends TWidget {
|
|||
super.setHeight(2);
|
||||
super.setWidth(StringUtils.width(mnemonic.getRawLabel()) + 3);
|
||||
|
||||
shadowColor = new CellAttributes();
|
||||
shadowColor.setTo(getWindow().getBackground());
|
||||
shadowColor.setForeColor(Color.BLACK);
|
||||
shadowColor.setBold(false);
|
||||
setStyle((String) null);
|
||||
|
||||
// Since we set dimensions after TWidget's constructor, we need to
|
||||
// update the layout manager.
|
||||
|
@ -332,6 +335,17 @@ public class TButton extends TWidget {
|
|||
CellAttributes buttonColor;
|
||||
CellAttributes menuMnemonicColor;
|
||||
|
||||
if (shadowColor == null) {
|
||||
shadowColor = new CellAttributes();
|
||||
if (givenShadowColor == null) {
|
||||
shadowColor.setTo(getWindow().getBackground());
|
||||
} else {
|
||||
shadowColor.setTo(givenShadowColor);
|
||||
}
|
||||
shadowColor.setForeColor(Color.BLACK);
|
||||
shadowColor.setBold(false);
|
||||
}
|
||||
|
||||
if (!isEnabled()) {
|
||||
buttonColor = getTheme().getColor("tbutton.disabled");
|
||||
menuMnemonicColor = getTheme().getColor("tbutton.disabled");
|
||||
|
@ -348,6 +362,7 @@ public class TButton extends TWidget {
|
|||
|| (leftEdgeShadowChar == null)
|
||||
|| (rightEdgeShadowCharTop == null)
|
||||
|| (rightEdgeShadowCharBottom == null)
|
||||
|| (shadowCharBottom == null)
|
||||
) {
|
||||
// TODO: If the color theme changes, we need to regenerate these.
|
||||
drawEnds(getWindow().getBackground(), buttonColor);
|
||||
|
@ -364,8 +379,7 @@ public class TButton extends TWidget {
|
|||
|
||||
if (shadowColor != null) {
|
||||
putCharXY(1, 1, leftEdgeShadowChar);
|
||||
hLineXY(2, 1, getWidth() - 3, GraphicsChars.CP437[0xDF],
|
||||
shadowColor);
|
||||
hLineXY(2, 1, getWidth() - 3, shadowCharBottom);
|
||||
putCharXY(getWidth() - 1, 0, rightEdgeShadowCharTop);
|
||||
putCharXY(getWidth() - 1, 1, rightEdgeShadowCharBottom);
|
||||
}
|
||||
|
@ -416,13 +430,15 @@ public class TButton extends TWidget {
|
|||
*/
|
||||
public void setShadowColor(final CellAttributes color) {
|
||||
if (color != null) {
|
||||
shadowColor = new CellAttributes();
|
||||
shadowColor.setTo(color);
|
||||
shadowColor.setForeColor(Color.BLACK);
|
||||
shadowColor.setBold(false);
|
||||
givenShadowColor = new CellAttributes();
|
||||
givenShadowColor.setTo(color);
|
||||
givenShadowColor.setForeColor(Color.BLACK);
|
||||
givenShadowColor.setBold(false);
|
||||
} else {
|
||||
shadowColor = null;
|
||||
givenShadowColor = null;
|
||||
}
|
||||
rightEdgeShadowCharBottom = null;
|
||||
shadowColor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -437,6 +453,7 @@ public class TButton extends TWidget {
|
|||
leftEdgeShadowChar = null;
|
||||
rightEdgeShadowCharTop = null;
|
||||
rightEdgeShadowCharBottom = null;
|
||||
shadowColor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -458,6 +475,8 @@ public class TButton extends TWidget {
|
|||
shadowColor);
|
||||
rightEdgeShadowCharBottom = new Cell(GraphicsChars.CP437[0xDF],
|
||||
shadowColor);
|
||||
shadowCharBottom = new Cell(GraphicsChars.CP437[0xDF],
|
||||
shadowColor);
|
||||
return;
|
||||
}
|
||||
leftEdgeChar = new Cell(buttonColor);
|
||||
|
@ -465,6 +484,7 @@ public class TButton extends TWidget {
|
|||
leftEdgeShadowChar = new Cell(shadowColor);
|
||||
rightEdgeShadowCharTop = new Cell(shadowColor);
|
||||
rightEdgeShadowCharBottom = new Cell(shadowColor);
|
||||
shadowCharBottom = new Cell(shadowColor);
|
||||
|
||||
int cellWidth = getScreen().getTextWidth();
|
||||
int cellHeight = getScreen().getTextHeight();
|
||||
|
@ -474,13 +494,34 @@ public class TButton extends TWidget {
|
|||
BufferedImage shadowImage = new BufferedImage(cellWidth * 2,
|
||||
cellHeight * 2, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
java.awt.Color shadowRgb = null;
|
||||
if (shadowColor.getForeColorRGB() < 0) {
|
||||
shadowRgb = getApplication().getBackend().
|
||||
attrToForegroundColor(shadowColor);
|
||||
} else {
|
||||
shadowRgb = new java.awt.Color(shadowColor.getForeColorRGB());
|
||||
}
|
||||
java.awt.Color rectangleRgb = null;
|
||||
if (rectangleColor.getBackColorRGB() < 0) {
|
||||
rectangleRgb = getApplication().getBackend().
|
||||
attrToBackgroundColor(rectangleColor);
|
||||
} else {
|
||||
rectangleRgb = new java.awt.Color(rectangleColor.getBackColorRGB());
|
||||
}
|
||||
|
||||
java.awt.Color buttonRgb = null;
|
||||
if (buttonColor.getBackColorRGB() < 0) {
|
||||
buttonRgb = getApplication().getBackend().
|
||||
attrToBackgroundColor(buttonColor);
|
||||
} else {
|
||||
buttonRgb = new java.awt.Color(buttonColor.getBackColorRGB());
|
||||
}
|
||||
|
||||
// Draw the shadow first, so that it be underneath the right edge.
|
||||
Graphics2D gr2s = shadowImage.createGraphics();
|
||||
gr2s.setColor(getApplication().getBackend().
|
||||
attrToBackgroundColor(rectangleColor));
|
||||
gr2s.setColor(rectangleRgb);
|
||||
gr2s.fillRect(0, 0, cellWidth * 2, cellHeight * 2);
|
||||
gr2s.setColor(getApplication().getBackend().
|
||||
attrToForegroundColor(shadowColor));
|
||||
gr2s.setColor(shadowRgb);
|
||||
|
||||
int [] xPoints;
|
||||
int [] yPoints;
|
||||
|
@ -543,17 +584,14 @@ public class TButton extends TWidget {
|
|||
// gr2s now has the shadow bits, shifted half a cell down from 0.
|
||||
|
||||
Graphics2D gr2 = image.createGraphics();
|
||||
gr2.setColor(getApplication().getBackend().
|
||||
attrToBackgroundColor(rectangleColor));
|
||||
gr2.setColor(rectangleRgb);
|
||||
gr2.fillRect(0, 0, cellWidth * 2, cellHeight);
|
||||
if (!inButtonPress) {
|
||||
gr2.setColor(getApplication().getBackend().
|
||||
attrToForegroundColor(shadowColor));
|
||||
gr2.setColor(shadowRgb);
|
||||
gr2.fillRect(cellWidth, cellHeight / 2, cellWidth,
|
||||
cellHeight - (cellHeight / 2));
|
||||
}
|
||||
gr2.setColor(getApplication().getBackend().
|
||||
attrToBackgroundColor(buttonColor));
|
||||
gr2.setColor(buttonRgb);
|
||||
switch (style) {
|
||||
case ROUND:
|
||||
gr2.fillOval(0, 0, cellWidth * 2, cellHeight);
|
||||
|
@ -662,6 +700,50 @@ public class TButton extends TWidget {
|
|||
rightEdgeShadowCharBottom.setImage(cellImage);
|
||||
rightEdgeShadowCharBottom.setOpaqueImage();
|
||||
|
||||
cellImage = new BufferedImage(cellWidth, cellHeight,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
gr2s = cellImage.createGraphics();
|
||||
gr2s.setColor(rectangleRgb);
|
||||
gr2s.fillRect(0, 0, cellWidth, cellHeight);
|
||||
gr2s.setColor(shadowRgb);
|
||||
gr2s.fillRect(0, 0, cellWidth, cellHeight / 2);
|
||||
gr2s.dispose();
|
||||
shadowCharBottom.setImage(cellImage);
|
||||
shadowCharBottom.setOpaqueImage();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the button style.
|
||||
*
|
||||
* @param buttonStyle the button style string, one of: "square", "round",
|
||||
* "diamond", "leftArrow", or "rightArrow"; or null to use the value from
|
||||
* jexer.TButton.style.
|
||||
*/
|
||||
public void setStyle(final String buttonStyle) {
|
||||
String styleString = System.getProperty("jexer.TButton.style",
|
||||
"square");
|
||||
if (buttonStyle != null) {
|
||||
styleString = buttonStyle.toLowerCase();
|
||||
}
|
||||
if (styleString.equals("square")) {
|
||||
style = Style.SQUARE;
|
||||
} else if (styleString.equals("round")) {
|
||||
style = Style.ROUND;
|
||||
} else if (styleString.equals("diamond")) {
|
||||
style = Style.DIAMOND;
|
||||
} else if (styleString.equals("arrowleft")
|
||||
|| styleString.equals("leftarrow")
|
||||
) {
|
||||
style = Style.ARROW_LEFT;
|
||||
} else if (styleString.equals("arrowright")
|
||||
|| styleString.equals("rightarrow")
|
||||
) {
|
||||
style = Style.ARROW_RIGHT;
|
||||
} else {
|
||||
style = Style.SQUARE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2103,6 +2103,20 @@ public abstract class TWidget implements Comparable<TWidget> {
|
|||
getScreen().vLineXY(x, y, n, ch, attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a vertical line from (x, y) to (x, y + n).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public final void vLineXY(final int x, final int y, final int n,
|
||||
final Cell ch) {
|
||||
|
||||
getScreen().vLineXY(x, y, n, ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
|
@ -2118,6 +2132,20 @@ public abstract class TWidget implements Comparable<TWidget> {
|
|||
getScreen().hLineXY(x, y, n, ch, attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public final void hLineXY(final int x, final int y, final int n,
|
||||
final Cell ch) {
|
||||
|
||||
getScreen().hLineXY(x, y, n, ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a box with a border and empty background.
|
||||
*
|
||||
|
|
|
@ -273,23 +273,20 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
*/
|
||||
public BufferedImage ditherImage(final BufferedImage image) {
|
||||
|
||||
BufferedImage ditheredImage = new BufferedImage(image.getWidth(),
|
||||
image.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
int [] rgbArray = image.getRGB(0, 0, image.getWidth(),
|
||||
image.getHeight(), null, 0, image.getWidth());
|
||||
ditheredImage.setRGB(0, 0, image.getWidth(), image.getHeight(),
|
||||
rgbArray, 0, image.getWidth());
|
||||
|
||||
for (int imageY = 0; imageY < image.getHeight(); imageY++) {
|
||||
for (int imageX = 0; imageX < image.getWidth(); imageX++) {
|
||||
int oldPixel = ditheredImage.getRGB(imageX,
|
||||
imageY) & 0xFFFFFF;
|
||||
int height = image.getHeight();
|
||||
int width = image.getWidth();
|
||||
for (int imageY = 0; imageY < height; imageY++) {
|
||||
for (int imageX = 0; imageX < width; imageX++) {
|
||||
int oldPixel = rgbArray[imageX + (width * imageY)]
|
||||
& 0xFFFFFF;
|
||||
int colorIdx = matchColor(oldPixel);
|
||||
assert (colorIdx >= 0);
|
||||
assert (colorIdx < paletteSize);
|
||||
int newPixel = rgbColors.get(colorIdx);
|
||||
ditheredImage.setRGB(imageX, imageY, colorIdx);
|
||||
rgbArray[imageX + (width * imageY)] = colorIdx;
|
||||
|
||||
int oldRed = (oldPixel >>> 16) & 0xFF;
|
||||
int oldGreen = (oldPixel >>> 8) & 0xFF;
|
||||
|
@ -305,7 +302,7 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
|
||||
int red, green, blue;
|
||||
if (imageX < image.getWidth() - 1) {
|
||||
int pXpY = ditheredImage.getRGB(imageX + 1, imageY);
|
||||
int pXpY = rgbArray[imageX + 1 + (width * imageY)];
|
||||
red = ((pXpY >>> 16) & 0xFF) + (7 * redError);
|
||||
green = ((pXpY >>> 8) & 0xFF) + (7 * greenError);
|
||||
blue = ( pXpY & 0xFF) + (7 * blueError);
|
||||
|
@ -314,10 +311,9 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
blue = clamp(blue);
|
||||
pXpY = ((red & 0xFF) << 16);
|
||||
pXpY |= ((green & 0xFF) << 8) | (blue & 0xFF);
|
||||
ditheredImage.setRGB(imageX + 1, imageY, pXpY);
|
||||
rgbArray[imageX + 1 + (width * imageY)] = pXpY;
|
||||
if (imageY < image.getHeight() - 1) {
|
||||
int pXpYp = ditheredImage.getRGB(imageX + 1,
|
||||
imageY + 1);
|
||||
int pXpYp = rgbArray[imageX + 1 + (width * (imageY + 1))];
|
||||
red = ((pXpYp >>> 16) & 0xFF) + redError;
|
||||
green = ((pXpYp >>> 8) & 0xFF) + greenError;
|
||||
blue = ( pXpYp & 0xFF) + blueError;
|
||||
|
@ -326,13 +322,11 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
blue = clamp(blue);
|
||||
pXpYp = ((red & 0xFF) << 16);
|
||||
pXpYp |= ((green & 0xFF) << 8) | (blue & 0xFF);
|
||||
ditheredImage.setRGB(imageX + 1, imageY + 1, pXpYp);
|
||||
rgbArray[imageX + 1 + (width * (imageY + 1))] = pXpYp;
|
||||
}
|
||||
} else if (imageY < image.getHeight() - 1) {
|
||||
int pXmYp = ditheredImage.getRGB(imageX - 1,
|
||||
imageY + 1);
|
||||
int pXYp = ditheredImage.getRGB(imageX,
|
||||
imageY + 1);
|
||||
int pXmYp = rgbArray[imageX - 1 + (width * (imageY + 1))];
|
||||
int pXYp = rgbArray[imageX + (width * (imageY + 1))];
|
||||
|
||||
red = ((pXmYp >>> 16) & 0xFF) + (3 * redError);
|
||||
green = ((pXmYp >>> 8) & 0xFF) + (3 * greenError);
|
||||
|
@ -342,7 +336,7 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
blue = clamp(blue);
|
||||
pXmYp = ((red & 0xFF) << 16);
|
||||
pXmYp |= ((green & 0xFF) << 8) | (blue & 0xFF);
|
||||
ditheredImage.setRGB(imageX - 1, imageY + 1, pXmYp);
|
||||
rgbArray[imageX - 1 + (width * (imageY + 1))] = pXmYp;
|
||||
|
||||
red = ((pXYp >>> 16) & 0xFF) + (5 * redError);
|
||||
green = ((pXYp >>> 8) & 0xFF) + (5 * greenError);
|
||||
|
@ -352,10 +346,15 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
blue = clamp(blue);
|
||||
pXYp = ((red & 0xFF) << 16);
|
||||
pXYp |= ((green & 0xFF) << 8) | (blue & 0xFF);
|
||||
ditheredImage.setRGB(imageX, imageY + 1, pXYp);
|
||||
rgbArray[imageX + (width * (imageY + 1))] = pXYp;
|
||||
}
|
||||
} // for (int imageY = 0; imageY < image.getHeight(); imageY++)
|
||||
} // for (int imageX = 0; imageX < image.getWidth(); imageX++)
|
||||
} // for (int imageY = 0; imageY < height; imageY++)
|
||||
} // for (int imageX = 0; imageX < width; imageX++)
|
||||
|
||||
BufferedImage ditheredImage = new BufferedImage(image.getWidth(),
|
||||
image.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
ditheredImage.setRGB(0, 0, image.getWidth(), image.getHeight(),
|
||||
rgbArray, 0, image.getWidth());
|
||||
|
||||
return ditheredImage;
|
||||
}
|
||||
|
@ -786,8 +785,14 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
}
|
||||
|
||||
// Render the entire row of cells.
|
||||
int width = image.getWidth();
|
||||
int [][] sixels = new int[image.getWidth()][6];
|
||||
|
||||
// There is a small performance gain reading the array all at once.
|
||||
int [] rgbArray = image.getRGB(0, 0, width, image.getHeight(),
|
||||
null, 0, width);
|
||||
|
||||
for (int currentRow = 0; currentRow < fullHeight; currentRow += 6) {
|
||||
int [][] sixels = new int[image.getWidth()][6];
|
||||
|
||||
// See which colors are actually used in this band of sixels.
|
||||
for (int imageX = 0; imageX < image.getWidth(); imageX++) {
|
||||
|
@ -795,7 +800,8 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
(imageY < 6) && (imageY + currentRow < fullHeight);
|
||||
imageY++) {
|
||||
|
||||
int colorIdx = image.getRGB(imageX, imageY + currentRow);
|
||||
int colorIdx = rgbArray[imageX +
|
||||
(width * (imageY + currentRow))];
|
||||
if (colorIdx == -1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -821,7 +827,8 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
|
||||
// Set to the beginning of scan line for the next set of
|
||||
// colored pixels, and select the color.
|
||||
sb.append(String.format("$#%d", i));
|
||||
sb.append("$#");
|
||||
sb.append(Integer.toString(i));
|
||||
|
||||
int oldData = -1;
|
||||
int oldDataCount = 0;
|
||||
|
@ -869,7 +876,8 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
if (oldDataCount == 1) {
|
||||
sb.append((char) oldData);
|
||||
} else if (oldDataCount > 1) {
|
||||
sb.append(String.format("!%d", oldDataCount));
|
||||
sb.append("!");
|
||||
sb.append(Integer.toString(oldDataCount));
|
||||
sb.append((char) oldData);
|
||||
}
|
||||
oldDataCount = 1;
|
||||
|
@ -882,7 +890,8 @@ public class LegacySixelEncoder implements SixelEncoder {
|
|||
if (oldDataCount == 1) {
|
||||
sb.append((char) oldData);
|
||||
} else if (oldDataCount > 1) {
|
||||
sb.append(String.format("!%d", oldDataCount));
|
||||
sb.append("!");
|
||||
sb.append(Integer.toString(oldDataCount));
|
||||
sb.append((char) oldData);
|
||||
}
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ public class LogicalScreen implements Screen {
|
|||
public final void putAttrXY(final int x, final int y,
|
||||
final CellAttributes attr) {
|
||||
|
||||
putAttrXY(x, y, attr, true);
|
||||
putAttrXY(x, y, attr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -424,7 +424,7 @@ public class LogicalScreen implements Screen {
|
|||
}
|
||||
|
||||
if ((X >= 0) && (X < width) && (Y >= 0) && (Y < height)) {
|
||||
logical[X][Y].setAttr(attr, true);
|
||||
logical[X][Y].setAttr(attr);
|
||||
|
||||
// If this happens to be the cursor position, make the position
|
||||
// dirty.
|
||||
|
@ -641,6 +641,22 @@ public class LogicalScreen implements Screen {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a vertical line from (x, y) to (x, y + n).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public void vLineXY(final int x, final int y, final int n,
|
||||
final Cell ch) {
|
||||
|
||||
for (int i = y; i < y + n; i++) {
|
||||
putCharXY(x, i, ch);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
|
@ -658,6 +674,22 @@ public class LogicalScreen implements Screen {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public void hLineXY(final int x, final int y, final int n,
|
||||
final Cell ch) {
|
||||
|
||||
for (int i = x; i < x + n; i++) {
|
||||
putCharXY(i, y, ch);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the width. Everything on-screen will be destroyed and must be
|
||||
* redrawn.
|
||||
|
|
|
@ -455,6 +455,24 @@ public class MultiScreen implements Screen {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a vertical line from (x, y) to (x, y + n).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public void vLineXY(final int x, final int y, final int n,
|
||||
final Cell ch) {
|
||||
|
||||
synchronized (screens) {
|
||||
for (Screen screen: screens) {
|
||||
screen.vLineXY(x, y, n, ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
|
@ -474,6 +492,24 @@ public class MultiScreen implements Screen {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public void hLineXY(final int x, final int y, final int n,
|
||||
final Cell ch) {
|
||||
|
||||
synchronized (screens) {
|
||||
for (Screen screen: screens) {
|
||||
screen.hLineXY(x, y, n, ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the width. Everything on-screen will be destroyed and must be
|
||||
* redrawn.
|
||||
|
|
|
@ -252,6 +252,17 @@ public interface Screen {
|
|||
public void vLineXY(final int x, final int y, final int n,
|
||||
final int ch, final CellAttributes attr);
|
||||
|
||||
/**
|
||||
* Draw a vertical line from (x, y) to (x, y + n).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public void vLineXY(final int x, final int y, final int n,
|
||||
final Cell ch);
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
|
@ -264,6 +275,17 @@ public interface Screen {
|
|||
public void hLineXY(final int x, final int y, final int n,
|
||||
final int ch, final CellAttributes attr);
|
||||
|
||||
/**
|
||||
* Draw a horizontal line from (x, y) to (x + n, y).
|
||||
*
|
||||
* @param x column coordinate. 0 is the left-most column.
|
||||
* @param y row coordinate. 0 is the top-most row.
|
||||
* @param n number of characters to draw
|
||||
* @param ch character to draw
|
||||
*/
|
||||
public void hLineXY(final int x, final int y, final int n,
|
||||
final Cell ch);
|
||||
|
||||
/**
|
||||
* Change the width. Everything on-screen will be destroyed and must be
|
||||
* redrawn.
|
||||
|
|
|
@ -745,6 +745,7 @@ public class ColorTheme {
|
|||
setDefaultTheme();
|
||||
final int pink = 0xf7a8b8;
|
||||
final int blue = 0x55cdfc;
|
||||
final int pink2 = 0xd77888;
|
||||
|
||||
for (String key: colors.keySet()) {
|
||||
CellAttributes color = colors.get(key);
|
||||
|
@ -790,14 +791,29 @@ public class ColorTheme {
|
|||
colors.put(key, color);
|
||||
}
|
||||
|
||||
/*
|
||||
CellAttributes color;
|
||||
color = new CellAttributes();
|
||||
color.setForeColor(Color.MAGENTA);
|
||||
color.setBackColorRGB(pink);
|
||||
color.setBackColorRGB(pink2);
|
||||
color.setBold(false);
|
||||
colors.put("twindow.background", color);
|
||||
colors.put("twindow.background.inactive", color);
|
||||
colors.put("twindow.background.modal", color);
|
||||
*/
|
||||
colors.put("twindow.background.modal.inactive", color);
|
||||
colors.put("twindow.background.windowmove", color);
|
||||
|
||||
color = new CellAttributes();
|
||||
color.setForeColor(Color.MAGENTA);
|
||||
color.setBold(true);
|
||||
colors.put("twindow.border", color);
|
||||
colors.put("twindow.border.inactive", color);
|
||||
colors.put("twindow.border.modal", color);
|
||||
colors.put("twindow.border.modal.inactive", color);
|
||||
|
||||
color = new CellAttributes();
|
||||
color.setForeColorRGB(blue);
|
||||
colors.put("twindow.border.windowmove", color);
|
||||
colors.put("twindow.border.modal.windowmove", color);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,8 +38,13 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.util.ResourceBundle;
|
||||
|
||||
import jexer.TApplication;
|
||||
import jexer.TButton;
|
||||
import jexer.TDesktop;
|
||||
import jexer.TEditColorThemeWindow;
|
||||
import jexer.TEditorWindow;
|
||||
import jexer.TWidget;
|
||||
import jexer.TWindow;
|
||||
import jexer.bits.BorderStyle;
|
||||
import jexer.event.TMenuEvent;
|
||||
import jexer.menu.TMenu;
|
||||
import jexer.menu.TMenuItem;
|
||||
|
@ -192,6 +197,98 @@ public class DemoApplication extends TApplication {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (menu.getId() == 10000) {
|
||||
new DemoMainWindow(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (menu.getId() == 10001) {
|
||||
// Look sexy: switch the color theme, window borders, and button
|
||||
// styles.
|
||||
System.setProperty("jexer.TWindow.borderStyleForeground", "round");
|
||||
System.setProperty("jexer.TWindow.borderStyleModal", "round");
|
||||
System.setProperty("jexer.TWindow.borderStyleMoving", "round");
|
||||
System.setProperty("jexer.TWindow.borderStyleInactive", "round");
|
||||
System.setProperty("jexer.TEditColorTheme.borderStyle", "round");
|
||||
System.setProperty("jexer.TEditColorTheme.options.borderStyle", "round");
|
||||
System.setProperty("jexer.TRadioGroup.borderStyle", "round");
|
||||
System.setProperty("jexer.TScreenOptions.borderStyle", "round");
|
||||
System.setProperty("jexer.TScreenOptions.grid.borderStyle", "round");
|
||||
System.setProperty("jexer.TScreenOptions.options.borderStyle", "round");
|
||||
System.setProperty("jexer.TWindow.opacity", "70");
|
||||
System.setProperty("jexer.TImage.opacity", "70");
|
||||
System.setProperty("jexer.TTerminal.opacity", "70");
|
||||
System.setProperty("jexer.TButton.style", "round");
|
||||
|
||||
getTheme().setFemme();
|
||||
for (TWindow window: getAllWindows()) {
|
||||
window.setBorderStyleForeground("round");
|
||||
window.setBorderStyleModal("round");
|
||||
window.setBorderStyleMoving("round");
|
||||
window.setBorderStyleInactive("round");
|
||||
window.setAlpha(70 * 255 / 100);
|
||||
|
||||
for (TWidget widget: window.getChildren()) {
|
||||
if (widget instanceof TButton) {
|
||||
((TButton) widget).setStyle(TButton.Style.ROUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (TMenu m: getAllMenus()) {
|
||||
m.setBorderStyleForeground("round");
|
||||
m.setBorderStyleModal("round");
|
||||
m.setBorderStyleMoving("round");
|
||||
m.setBorderStyleInactive("round");
|
||||
m.setAlpha(70 * 255 / 100);
|
||||
}
|
||||
setDesktop(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (menu.getId() == 10002) {
|
||||
// Look bland: switch the color theme, window borders, and button
|
||||
// styles.
|
||||
System.clearProperty("jexer.TWindow.borderStyleForeground");
|
||||
System.clearProperty("jexer.TWindow.borderStyleModal");
|
||||
System.clearProperty("jexer.TWindow.borderStyleMoving");
|
||||
System.clearProperty("jexer.TWindow.borderStyleInactive");
|
||||
System.clearProperty("jexer.TEditColorTheme.borderStyle");
|
||||
System.clearProperty("jexer.TEditColorTheme.options.borderStyle");
|
||||
System.clearProperty("jexer.TRadioGroup.borderStyle");
|
||||
System.clearProperty("jexer.TScreenOptions.borderStyle");
|
||||
System.clearProperty("jexer.TScreenOptions.grid.borderStyle");
|
||||
System.clearProperty("jexer.TScreenOptions.options.borderStyle");
|
||||
System.clearProperty("jexer.TWindow.opacity");
|
||||
System.clearProperty("jexer.TImage.opacity");
|
||||
System.clearProperty("jexer.TTerminal.opacity");
|
||||
System.clearProperty("jexer.TButton.style");
|
||||
|
||||
getTheme().setDefaultTheme();
|
||||
for (TWindow window: getAllWindows()) {
|
||||
window.setBorderStyleForeground(null);
|
||||
window.setBorderStyleModal(null);
|
||||
window.setBorderStyleMoving(null);
|
||||
window.setBorderStyleInactive(null);
|
||||
window.setAlpha(90 * 255 / 100);
|
||||
|
||||
for (TWidget widget: window.getChildren()) {
|
||||
if (widget instanceof TButton) {
|
||||
((TButton) widget).setStyle(TButton.Style.SQUARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (TMenu m: getAllMenus()) {
|
||||
m.setBorderStyleForeground(null);
|
||||
m.setBorderStyleModal(null);
|
||||
m.setBorderStyleMoving(null);
|
||||
m.setBorderStyleInactive(null);
|
||||
m.setAlpha(90 * 255 / 100);
|
||||
}
|
||||
setDesktop(new TDesktop(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -211,6 +308,11 @@ public class DemoApplication extends TApplication {
|
|||
addEditMenu();
|
||||
|
||||
TMenu demoMenu = addMenu(i18n.getString("demo"));
|
||||
demoMenu.addItem(10000, i18n.getString("mainWindow"));
|
||||
demoMenu.addSeparator();
|
||||
demoMenu.addItem(10001, i18n.getString("lookSexy"));
|
||||
demoMenu.addItem(10002, i18n.getString("lookBland"));
|
||||
demoMenu.addSeparator();
|
||||
TMenuItem item = demoMenu.addItem(2000, i18n.getString("checkable"));
|
||||
item.setCheckable(true);
|
||||
item = demoMenu.addItem(2001, i18n.getString("disabled"));
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
applicationTitle=Demo Application
|
||||
|
||||
demo=&Demo
|
||||
mainWindow=N&ew Main Window...
|
||||
lookSexy=Switch to sexy look
|
||||
lookBland=Switch to bland look
|
||||
checkable=&Checkable
|
||||
disabled=Disabled
|
||||
normal=&Normal
|
||||
|
|
Loading…
Reference in a new issue