You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/05/11 18:09:50 UTC
svn commit: r1337241 - in /pivot/trunk:
wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraLabelSkin.java
wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java
wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
Author: smartini
Date: Fri May 11 16:09:49 2012
New Revision: 1337241
URL: http://svn.apache.org/viewvc?rev=1337241&view=rev
Log:
add disabledColor style property for Label and Rollup
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraLabelSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraLabelSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraLabelSkin.java?rev=1337241&r1=1337240&r2=1337241&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraLabelSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraLabelSkin.java Fri May 11 16:09:49 2012
@@ -25,6 +25,7 @@ import org.apache.pivot.wtk.skin.LabelSk
public class TerraLabelSkin extends LabelSkin {
public TerraLabelSkin() {
setColor(1);
+ setDisabledColor(7);
}
public final void setColor(int color) {
@@ -32,8 +33,14 @@ public class TerraLabelSkin extends Labe
setColor(theme.getColor(color));
}
+ public final void setDisabledColor(int color) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setDisabledColor(theme.getColor(color));
+ }
+
public final void setBackgroundColor(int backgroundColor) {
TerraTheme theme = (TerraTheme)Theme.getTheme();
setBackgroundColor(theme.getColor(backgroundColor));
}
+
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java?rev=1337241&r1=1337240&r2=1337241&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java Fri May 11 16:09:49 2012
@@ -127,7 +127,11 @@ public class TerraRollupSkin extends Rol
Rollup rollup = (Rollup)TerraRollupSkin.this.getComponent();
graphics.setStroke(new BasicStroke(0));
- graphics.setPaint(buttonColor);
+ if (rollup.isEnabled()) {
+ graphics.setPaint(buttonColor);
+ } else {
+ graphics.setPaint(disabledButtonColor);
+ }
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
@@ -165,6 +169,7 @@ public class TerraRollupSkin extends Rol
// Styles
private Color buttonColor;
+ private Color disabledButtonColor;
private int spacing;
private int buffer;
private boolean fill;
@@ -198,6 +203,7 @@ public class TerraRollupSkin extends Rol
TerraTheme theme = (TerraTheme)Theme.getTheme();
buttonColor = theme.getColor(1);
+ disabledButtonColor = theme.getColor(7);
spacing = 4;
buffer = 4;
fill = false;
@@ -391,6 +397,32 @@ public class TerraRollupSkin extends Rol
setButtonColor(GraphicsUtilities.decodeColor(buttonColor));
}
+ public Color getDisabledButtonColor() {
+ return disabledButtonColor;
+ }
+
+ public final void setDisabledButtonColor(int color) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setDisabledButtonColor(theme.getColor(color));
+ }
+
+ public void setDisabledButtonColor(Color buttonColor) {
+ if (buttonColor == null) {
+ throw new IllegalArgumentException("buttonColor is null.");
+ }
+
+ this.disabledButtonColor = buttonColor;
+ rollupButton.repaint();
+ }
+
+ public final void setDisabledButtonColor(String buttonColor) {
+ if (buttonColor == null) {
+ throw new IllegalArgumentException("buttonColor is null.");
+ }
+
+ setDisabledButtonColor(GraphicsUtilities.decodeColor(buttonColor));
+ }
+
public int getSpacing() {
return spacing;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java?rev=1337241&r1=1337240&r2=1337241&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java Fri May 11 16:09:49 2012
@@ -45,12 +45,11 @@ import org.apache.pivot.wtk.VerticalAlig
/**
* Label skin.
- * <p>
- * TODO Add a showEllipsis style.
*/
public class LabelSkin extends ComponentSkin implements LabelListener {
private Font font;
private Color color;
+ private Color disabledColor;
private Color backgroundColor;
private TextDecoration textDecoration;
private HorizontalAlignment horizontalAlignment;
@@ -65,6 +64,7 @@ public class LabelSkin extends Component
Theme theme = Theme.getTheme();
font = theme.getFont();
color = Color.BLACK;
+ disabledColor = Color.GRAY;
backgroundColor = null;
textDecoration = null;
horizontalAlignment = HorizontalAlignment.LEFT;
@@ -283,6 +283,8 @@ public class LabelSkin extends Component
@Override
public void paint(Graphics2D graphics) {
+ Label label = (Label)this.getComponent();
+
int width = getWidth();
int height = getHeight();
@@ -295,7 +297,12 @@ public class LabelSkin extends Component
// Draw the text
if (glyphVectors != null && glyphVectors.getLength() > 0) {
graphics.setFont(font);
- graphics.setPaint(color);
+
+ if (label.isEnabled()) {
+ graphics.setPaint(color);
+ } else {
+ graphics.setPaint(disabledColor);
+ }
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
LineMetrics lm = font.getLineMetrics("", fontRenderContext);
@@ -345,8 +352,7 @@ public class LabelSkin extends Component
}
if (graphics instanceof PrintGraphics) {
- /* Work-around for printing problem in applets */
- Label label = (Label)getComponent();
+ // Work-around for printing problem in applets
String text = label.getText();
if (text != null && text.length() > 0) {
graphics.drawString(text, x, y + ascent);
@@ -473,6 +479,37 @@ public class LabelSkin extends Component
}
/**
+ * Returns the foreground color of the text of the label when disabled.
+ */
+ public Color getDisabledColor() {
+ return disabledColor;
+ }
+
+ /**
+ * Sets the foreground color of the text of the label when disabled.
+ */
+ public void setDisabledColor(Color color) {
+ if (color == null) {
+ throw new IllegalArgumentException("color is null.");
+ }
+
+ this.disabledColor = color;
+ repaintComponent();
+ }
+
+ /**
+ * Sets the foreground color of the text of the label when disabled.
+ * @param color Any of the {@linkplain GraphicsUtilities#decodeColor color values recognized by Pivot}.
+ */
+ public final void setDisabledColor(String color) {
+ if (color == null) {
+ throw new IllegalArgumentException("color is null.");
+ }
+
+ setDisabledColor(GraphicsUtilities.decodeColor(color));
+ }
+
+ /**
* Returns the background color of the label.
*/
public Color getBackgroundColor() {