You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/03/16 17:36:28 UTC
svn commit: r754936 [30/38] - in /incubator/pivot/tags/v1.0.1: ./
charts-test/ charts-test/src/ charts-test/src/pivot/
charts-test/src/pivot/charts/ charts-test/src/pivot/charts/test/ charts/
charts/lib/ charts/src/ charts/src/pivot/ charts/src/pivot/c...
Added: incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFlowPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFlowPaneSkin.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFlowPaneSkin.java (added)
+++ incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFlowPaneSkin.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin.terra;
+
+import pivot.wtk.Theme;
+import pivot.wtk.skin.FlowPaneSkin;
+
+/**
+ * Terra flow pane skin.
+ *
+ * @author gbrown
+ */
+public class TerraFlowPaneSkin extends FlowPaneSkin {
+ public final void setBackgroundColor(int backgroundColor) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setBackgroundColor(theme.getColor(backgroundColor));
+ }
+}
Added: incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFormSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFormSkin.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFormSkin.java (added)
+++ incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFormSkin.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,561 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin.terra;
+
+import pivot.collections.ArrayList;
+import pivot.collections.Sequence;
+
+import pivot.wtk.Component;
+import pivot.wtk.Dimensions;
+import pivot.wtk.Form;
+import pivot.wtk.FormAttributeListener;
+import pivot.wtk.FormListener;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.ImageView;
+import pivot.wtk.Label;
+import pivot.wtk.MessageType;
+import pivot.wtk.Separator;
+import pivot.wtk.Theme;
+import pivot.wtk.media.Image;
+import pivot.wtk.skin.ContainerSkin;
+
+/**
+ * Form skin.
+ *
+ * @author gbrown
+ */
+public class TerraFormSkin extends ContainerSkin
+ implements FormListener, FormAttributeListener {
+ private ArrayList<Separator> separators = new ArrayList<Separator>();
+ private ArrayList<ArrayList<Label>> labels = new ArrayList<ArrayList<Label>>();
+ private ArrayList<ArrayList<ImageView>> flagImageViews = new ArrayList<ArrayList<ImageView>>();
+
+ private boolean rightAlignLabels = true;
+ private HorizontalAlignment fieldAlignment = HorizontalAlignment.LEFT;
+ private int horizontalSpacing = 6;
+ private int verticalSpacing = 6;
+ private int flagImageOffset = 4;
+ private boolean showFirstSectionHeading = false;
+
+ private static final int FLAG_IMAGE_SIZE = 16;
+
+ @Override
+ public void install(Component component) {
+ super.install(component);
+
+ Form form = (Form)component;
+ form.getFormListeners().add(this);
+ form.getFormAttributeListeners().add(this);
+
+ Form.SectionSequence sections = form.getSections();
+ for (int i = 0, n = sections.getLength(); i < n; i++) {
+ insertSection(sections.get(i), i);
+ }
+ }
+
+ @Override
+ public void uninstall() {
+ Form form = (Form)getComponent();
+ form.getFormListeners().remove(this);
+ form.getFormAttributeListeners().remove(this);
+
+ removeSections(0, form.getSections());
+
+ super.uninstall();
+ }
+
+ public int getPreferredWidth(int height) {
+ int preferredWidth = 0;
+
+ // Preferred width is maximum of either the sum of the maximum label
+ // width, maximum field width, horizontal spacing, flag image offset,
+ // and flag image size values or the maximum separator width
+ int maximumLabelWidth = 0;
+ int maximumFieldWidth = 0;
+ int maximumSeparatorWidth = 0;
+
+ Form form = (Form)getComponent();
+ Form.SectionSequence sections = form.getSections();
+
+ for (int sectionIndex = 0, sectionCount = sections.getLength();
+ sectionIndex < sectionCount; sectionIndex++) {
+ Form.Section section = sections.get(sectionIndex);
+
+ if (showFirstSectionHeading
+ || sectionIndex > 0) {
+ Separator separator = separators.get(sectionIndex);
+ maximumSeparatorWidth = Math.max(maximumSeparatorWidth,
+ separator.getPreferredWidth());
+ }
+
+ for (int fieldIndex = 0, fieldCount = section.getLength();
+ fieldIndex < fieldCount; fieldIndex++) {
+ Component field = section.get(fieldIndex);
+
+ if (field.isDisplayable()) {
+ Label label = labels.get(sectionIndex).get(fieldIndex);
+ maximumLabelWidth = Math.max(maximumLabelWidth,
+ label.getPreferredWidth(-1));
+ maximumFieldWidth = Math.max(maximumFieldWidth,
+ field.getPreferredWidth(-1));
+ }
+ }
+ }
+
+ preferredWidth = Math.max(maximumLabelWidth + horizontalSpacing + maximumFieldWidth
+ + flagImageOffset + FLAG_IMAGE_SIZE, maximumSeparatorWidth);
+
+ return preferredWidth;
+ }
+
+ public int getPreferredHeight(int width) {
+ int preferredHeight = 0;
+
+ Form form = (Form)getComponent();
+ Form.SectionSequence sections = form.getSections();
+
+ // If justified and constrained, determine field width constraint
+ int fieldWidth = -1;
+
+ if (fieldAlignment == HorizontalAlignment.JUSTIFY
+ && width != -1) {
+ int maximumLabelWidth = 0;
+
+ for (int sectionIndex = 0, sectionCount = sections.getLength();
+ sectionIndex < sectionCount; sectionIndex++) {
+ Form.Section section = sections.get(sectionIndex);
+
+ for (int fieldIndex = 0, fieldCount = section.getLength();
+ fieldIndex < fieldCount; fieldIndex++) {
+ Component field = section.get(fieldIndex);
+
+ if (field.isDisplayable()) {
+ Label label = labels.get(sectionIndex).get(fieldIndex);
+ maximumLabelWidth = Math.max(maximumLabelWidth,
+ label.getPreferredWidth(-1));
+ }
+ }
+ }
+
+ fieldWidth = Math.max(0, width - (maximumLabelWidth
+ + horizontalSpacing + flagImageOffset + FLAG_IMAGE_SIZE));
+ }
+
+ // Preferred height is the sum of the maximum value of the label,
+ // field, and flag image for each row, plus vertical spacing and
+ // preferred separator heights
+ for (int sectionIndex = 0, sectionCount = sections.getLength();
+ sectionIndex < sectionCount; sectionIndex++) {
+ Form.Section section = sections.get(sectionIndex);
+
+ if (showFirstSectionHeading
+ || sectionIndex > 0) {
+ Separator separator = separators.get(sectionIndex);
+ preferredHeight += separator.getPreferredHeight(width);
+ preferredHeight += verticalSpacing;
+ }
+
+ for (int fieldIndex = 0, fieldCount = section.getLength();
+ fieldIndex < fieldCount; fieldIndex++) {
+ Component field = section.get(fieldIndex);
+
+ if (field.isDisplayable()) {
+ Label label = labels.get(sectionIndex).get(fieldIndex);
+
+ int preferredRowHeight = Math.max(label.getPreferredHeight(-1),
+ Math.max(field.getPreferredHeight(fieldWidth), FLAG_IMAGE_SIZE));
+ preferredHeight += preferredRowHeight;
+
+ if (fieldIndex > 0) {
+ preferredHeight += verticalSpacing;
+ }
+ }
+ }
+ }
+
+ return preferredHeight;
+ }
+
+ public Dimensions getPreferredSize() {
+ // TODO Optimize
+ return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
+ }
+
+ public void layout() {
+ Form form = (Form)getComponent();
+ Form.SectionSequence sections = form.getSections();
+
+ // Determine the maximum label and field widths
+ int maximumLabelWidth = 0;
+ int maximumFieldWidth = 0;
+
+ for (int sectionIndex = 0, sectionCount = sections.getLength();
+ sectionIndex < sectionCount; sectionIndex++) {
+ Form.Section section = sections.get(sectionIndex);
+
+ for (int fieldIndex = 0, fieldCount = section.getLength();
+ fieldIndex < fieldCount; fieldIndex++) {
+ Component field = section.get(fieldIndex);
+
+ if (field.isDisplayable()) {
+ Label label = labels.get(sectionIndex).get(fieldIndex);
+ maximumLabelWidth = Math.max(maximumLabelWidth,
+ label.getPreferredWidth(-1));
+ maximumFieldWidth = Math.max(maximumFieldWidth,
+ field.getPreferredWidth(-1));
+ }
+ }
+ }
+
+ // Determine the maximum field width
+ int width = getWidth();
+ int availableFieldWidth = Math.max(0, width - (maximumLabelWidth
+ + horizontalSpacing + flagImageOffset + FLAG_IMAGE_SIZE));
+
+ // Lay out the components
+ int rowY = 0;
+
+ for (int sectionIndex = 0, sectionCount = sections.getLength();
+ sectionIndex < sectionCount; sectionIndex++) {
+ Form.Section section = sections.get(sectionIndex);
+
+ Separator separator = separators.get(sectionIndex);
+ if (sectionIndex == 0
+ && !showFirstSectionHeading) {
+ separator.setVisible(false);
+ } else {
+ separator.setVisible(true);
+ separator.setSize(width, separator.getPreferredHeight(width));
+ separator.setLocation(0, rowY);
+ rowY += separator.getHeight();
+ }
+
+ for (int fieldIndex = 0, fieldCount = section.getLength();
+ fieldIndex < fieldCount; fieldIndex++) {
+ Component field = section.get(fieldIndex);
+
+ Label label = labels.get(sectionIndex).get(fieldIndex);
+ ImageView flagImageView = flagImageViews.get(sectionIndex).get(fieldIndex);
+
+ if (field.isDisplayable()) {
+ // Show the row components
+ label.setVisible(true);
+ field.setVisible(true);
+ flagImageView.setVisible(true);
+
+ // Set the row component sizes
+ label.setSize(label.getPreferredSize());
+
+ Dimensions fieldSize = null;
+ if (fieldAlignment == HorizontalAlignment.JUSTIFY) {
+ fieldSize = new Dimensions(availableFieldWidth,
+ field.getPreferredHeight(availableFieldWidth));
+ } else {
+ fieldSize = field.getPreferredSize();
+ }
+
+ field.setSize(fieldSize);
+ flagImageView.setSize(flagImageView.getPreferredSize());
+
+ int rowHeight = Math.max(label.getHeight(),
+ Math.max(field.getHeight(), FLAG_IMAGE_SIZE));
+
+ // Set the row component locations
+ int labelX = rightAlignLabels ? maximumLabelWidth - label.getWidth() : 0;
+ label.setLocation(labelX, rowY);
+
+ int fieldX = 0;
+ switch(fieldAlignment) {
+ case LEFT:
+ case JUSTIFY: {
+ fieldX = maximumLabelWidth + horizontalSpacing;
+ break;
+ }
+
+ case RIGHT: {
+ fieldX = maximumLabelWidth + horizontalSpacing
+ + Math.max(0, Math.max(availableFieldWidth, maximumFieldWidth)
+ - field.getWidth());
+ break;
+ }
+
+ case CENTER: {
+ fieldX = maximumLabelWidth + horizontalSpacing
+ + Math.max(0, (Math.max(availableFieldWidth, maximumFieldWidth)
+ - field.getWidth()) / 2);
+ break;
+ }
+ }
+
+ field.setLocation(fieldX, rowY);
+ flagImageView.setLocation(fieldX + field.getWidth() + flagImageOffset,
+ rowY + (rowHeight - flagImageView.getHeight()) / 2);
+
+ // Update the row y-coordinate
+ rowY += rowHeight + verticalSpacing;
+ } else {
+ // Hide the row components
+ label.setVisible(false);
+ field.setVisible(false);
+ flagImageView.setVisible(false);
+ }
+ }
+ }
+ }
+
+ public boolean getRightAlignLabels() {
+ return rightAlignLabels;
+ }
+
+ public void setRightAlignLabels(boolean rightAlignLabels) {
+ this.rightAlignLabels = rightAlignLabels;
+ }
+
+ public HorizontalAlignment getFieldAlignment() {
+ return fieldAlignment;
+ }
+
+ public void setFieldAlignment(HorizontalAlignment fieldAlignment) {
+ this.fieldAlignment = fieldAlignment;
+ repaintComponent();
+ }
+
+ public final void setFieldAlignment(String fieldAlignment) {
+ if (fieldAlignment == null) {
+ throw new IllegalArgumentException("fieldAlignment is null.");
+ }
+
+ setFieldAlignment(HorizontalAlignment.decode(fieldAlignment));
+ }
+
+ public int getHorizontalSpacing() {
+ return horizontalSpacing;
+ }
+
+ public void setHorizontalSpacing(int horizontalSpacing) {
+ this.horizontalSpacing = horizontalSpacing;
+ invalidateComponent();
+ }
+
+ public final void setHorizontalSpacing(Number horizontalSpacing) {
+ if (horizontalSpacing == null) {
+ throw new IllegalArgumentException("horizontalSpacing is null.");
+ }
+
+ setHorizontalSpacing(horizontalSpacing.intValue());
+ }
+
+ public int getVerticalSpacing() {
+ return verticalSpacing;
+ }
+
+ public void setVerticalSpacing(int verticalSpacing) {
+ this.verticalSpacing = verticalSpacing;
+ invalidateComponent();
+ }
+
+ public final void setVerticalSpacing(Number verticalSpacing) {
+ if (verticalSpacing == null) {
+ throw new IllegalArgumentException("verticalSpacing is null.");
+ }
+
+ setVerticalSpacing(verticalSpacing.intValue());
+ }
+
+ public int getFlagImageOffset() {
+ return flagImageOffset;
+ }
+
+ public void setFlagImageOffset(int flagImageOffset) {
+ this.flagImageOffset = flagImageOffset;
+ invalidateComponent();
+ }
+
+ public final void setFlagImageOffset(Number flagImageOffset) {
+ if (flagImageOffset == null) {
+ throw new IllegalArgumentException("flagImageOffset is null.");
+ }
+
+ setFlagImageOffset(flagImageOffset.intValue());
+ }
+
+ public boolean isShowFirstSectionHeading() {
+ return showFirstSectionHeading;
+ }
+
+ public void setShowFirstSectionHeading(boolean showFirstSectionHeading) {
+ this.showFirstSectionHeading = showFirstSectionHeading;
+ invalidateComponent();
+ }
+
+ // Form events
+ public void sectionInserted(Form form, int index) {
+ insertSection(form.getSections().get(index), index);
+ }
+
+ public void sectionsRemoved(Form form, int index, Sequence<Form.Section> removed) {
+ removeSections(index, removed);
+ }
+
+ public void sectionHeadingChanged(Form.Section section) {
+ updateSectionHeading(section);
+ }
+
+ public void fieldInserted(Form.Section section, int index) {
+ insertField(section, section.get(index), index);
+ }
+
+ public void fieldsRemoved(Form.Section section, int index, Sequence<Component> fields) {
+ removeFields(section, index, fields.getLength());
+ }
+
+ // Form attribute events
+ public void nameChanged(Form form, Component field, String previousName) {
+ Form.Section section = Form.getSection(field);
+ updateFieldName(section, section.indexOf(field));
+ }
+
+ public void flagChanged(Form form, Component field, Form.Flag previousFlag) {
+ Form.Section section = Form.getSection(field);
+ updateFieldFlag(section, section.indexOf(field));
+ }
+
+ // Implementation methods
+ private void insertSection(Form.Section section, int index) {
+ Form form = (Form)getComponent();
+
+ // Insert separator
+ Separator separator = new Separator(section.getHeading());
+ separators.insert(separator, index);
+ form.add(separator);
+
+ // Insert field label and flag image view lists
+ ArrayList<Label> sectionLabels = new ArrayList<Label>();
+ labels.insert(sectionLabels, index);
+
+ ArrayList<ImageView> sectionFlagImageViews = new ArrayList<ImageView>();
+ flagImageViews.insert(sectionFlagImageViews, index);
+
+ // Insert fields
+ for (int i = 0, n = section.getLength(); i < n; i++) {
+ insertField(section, section.get(i), i);
+ }
+
+ invalidateComponent();
+ }
+
+ private void removeSections(int index, Sequence<Form.Section> removed) {
+ Form form = (Form)getComponent();
+
+ for (int i = 0, n = removed.getLength(); i < n; i++) {
+ // Remove fields
+ Form.Section section = removed.get(i);
+ for (int j = 0; j < n; j++) {
+ removeFields(section, 0, section.getLength());
+ }
+
+ // Remove field label and flag image view lists
+ labels.remove(index, n);
+ flagImageViews.remove(index, n);
+
+ // Remove separators
+ Sequence<Separator> removedSeparators = separators.remove(index, n);
+ for (int j = 0; j < n; j++) {
+ form.remove(removedSeparators.get(j));
+ }
+ }
+
+ invalidateComponent();
+ }
+
+ private void insertField(Form.Section section, Component field, int index) {
+ Form form = (Form)getComponent();
+ int sectionIndex = form.getSections().indexOf(section);
+
+ // Create the label
+ Label label = new Label();
+ labels.get(sectionIndex).insert(label, index);
+ form.add(label);
+ updateFieldName(section, index);
+
+ // Create the flag image view
+ ImageView flagImageView = new ImageView();
+ flagImageViews.get(sectionIndex).insert(flagImageView, index);
+ form.add(flagImageView);
+ updateFieldFlag(section, index);
+
+ invalidateComponent();
+ }
+
+ private void removeFields(Form.Section section, int index, int count) {
+ Form form = (Form)getComponent();
+ int sectionIndex = form.getSections().indexOf(section);
+
+ // Remove the labels
+ Sequence<Label> removedLabels = labels.get(sectionIndex).remove(index, count);
+ for (int i = 0; i < count; i++) {
+ form.remove(removedLabels.get(i));
+ }
+
+ // Remove the flag image views
+ Sequence<ImageView> removedFlagImageViews = flagImageViews.get(sectionIndex).remove(index, count);
+ for (int i = 0; i < count; i++) {
+ form.remove(removedFlagImageViews.get(i));
+ }
+
+ invalidateComponent();
+ }
+
+ private void updateSectionHeading(Form.Section section) {
+ Form form = (Form)getComponent();
+ int sectionIndex = form.getSections().indexOf(section);
+
+ Separator separator = separators.get(sectionIndex);
+ separator.setHeading(section.getHeading());
+ }
+
+ private void updateFieldName(Form.Section section, int fieldIndex) {
+ Form form = (Form)getComponent();
+ Component field = section.get(fieldIndex);
+
+ int sectionIndex = form.getSections().indexOf(section);
+ Label label = labels.get(sectionIndex).get(fieldIndex);
+ String name = Form.getName(field);
+ label.setText((name == null) ? "" : name + ":");
+ }
+
+ private void updateFieldFlag(Form.Section section, int fieldIndex) {
+ Form form = (Form)getComponent();
+ Component field = section.get(fieldIndex);
+
+ int sectionIndex = form.getSections().indexOf(section);
+ ImageView flagImageView = flagImageViews.get(sectionIndex).get(fieldIndex);
+ Form.Flag flag = Form.getFlag(field);
+
+ Image flagImage = null;
+ String flagMessage = null;
+
+ if (flag != null) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ MessageType flagMessageType = flag.getMessageType();
+ flagImage = theme.getSmallMessageIcon(flagMessageType);
+ flagMessage = flag.getMessage();
+ }
+
+ flagImageView.setImage(flagImage);
+ flagImageView.setTooltipText(flagMessage);
+ }
+}
Added: incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFrameSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFrameSkin.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFrameSkin.java (added)
+++ incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraFrameSkin.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,805 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin.terra;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Button;
+import pivot.wtk.ButtonPressListener;
+import pivot.wtk.Component;
+import pivot.wtk.ComponentMouseListener;
+import pivot.wtk.ComponentMouseButtonListener;
+import pivot.wtk.Cursor;
+import pivot.wtk.Dimensions;
+import pivot.wtk.Display;
+import pivot.wtk.FlowPane;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.ImageView;
+import pivot.wtk.Insets;
+import pivot.wtk.Label;
+import pivot.wtk.Mouse;
+import pivot.wtk.Point;
+import pivot.wtk.PushButton;
+import pivot.wtk.Bounds;
+import pivot.wtk.Theme;
+import pivot.wtk.VerticalAlignment;
+import pivot.wtk.Window;
+import pivot.wtk.effects.DropShadowDecorator;
+import pivot.wtk.media.Image;
+import pivot.wtk.skin.WindowSkin;
+
+/**
+ * Frame skin.
+ *
+ * @author gbrown
+ * @author tvolkert
+ */
+public class TerraFrameSkin extends WindowSkin {
+ /**
+ * Frame button.
+ *
+ * @author gbrown
+ */
+ public static class FrameButton extends PushButton {
+ public FrameButton(Object buttonData) {
+ super(buttonData);
+
+ installSkin(FrameButton.class);
+ }
+ }
+
+ /**
+ * Frame button skin.
+ *
+ * @author gbrown
+ */
+ public static class FrameButtonSkin extends TerraPushButtonSkin {
+ @Override
+ public boolean isFocusable() {
+ return false;
+ }
+
+ @Override
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ super.mouseDown(component, button, x, y);
+ return true;
+ }
+ }
+
+ /**
+ * Abstract base class for frame button images.
+ *
+ * @author gbrown
+ */
+ protected abstract class ButtonImage extends Image {
+ public int getWidth() {
+ return 8;
+ }
+
+ public int getHeight() {
+ return 8;
+ }
+ }
+
+ /**
+ * Minimize button image.
+ *
+ * @author gbrown
+ */
+ protected class MinimizeImage extends ButtonImage {
+ public void paint(Graphics2D graphics) {
+ Window window = (Window)getComponent();
+ graphics.setPaint(window.isActive() ? titleBarColor : inactiveTitleBarColor);
+ graphics.fill(new Rectangle2D.Double(0, 6, 8, 2));
+ }
+ }
+
+ /**
+ * Maximize button image.
+ *
+ * @author gbrown
+ */
+ protected class MaximizeImage extends ButtonImage {
+ public void paint(Graphics2D graphics) {
+ Window window = (Window)getComponent();
+ graphics.setPaint(window.isActive() ? titleBarColor : inactiveTitleBarColor);
+ graphics.fill(new Rectangle2D.Double(0, 0, 8, 8));
+
+ graphics.setPaint(window.isActive() ? titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
+ graphics.fill(new Rectangle2D.Double(2, 2, 4, 4));
+ }
+ }
+
+ /**
+ * Restore button image.
+ *
+ * @author gbrown
+ */
+ protected class RestoreImage extends ButtonImage {
+ public void paint(Graphics2D graphics) {
+ Window window = (Window)getComponent();
+ graphics.setPaint(window.isActive() ?
+ titleBarColor : inactiveTitleBarColor);
+ graphics.fill(new Rectangle2D.Double(1, 1, 6, 6));
+
+ graphics.setPaint(window.isActive() ?
+ titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
+ graphics.fill(new Rectangle2D.Double(3, 3, 2, 2));
+ }
+ }
+
+ /**
+ * Close button image.
+ *
+ * @author gbrown
+ */
+ protected class CloseImage extends ButtonImage {
+ public void paint(Graphics2D graphics) {
+ Window window = (Window)getComponent();
+ graphics.setPaint(window.isActive() ?
+ titleBarColor : inactiveTitleBarColor);
+ graphics.setStroke(new BasicStroke(2));
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+
+ graphics.draw(new Line2D.Double(0, 0, 7, 7));
+ graphics.draw(new Line2D.Double(0, 7, 7, 0));
+ }
+ }
+
+ /**
+ * Resize button image.
+ *
+ * @author gbrown
+ */
+ protected class ResizeImage extends Image {
+ public static final int ALPHA = 64;
+
+ public int getWidth() {
+ return 5;
+ }
+
+ public int getHeight() {
+ return 5;
+ }
+
+ public void paint(Graphics2D graphics) {
+ graphics.setPaint(new Color(0, 0, 0, ALPHA));
+ graphics.fillRect(3, 0, 2, 1);
+ graphics.fillRect(0, 3, 2, 1);
+ graphics.fillRect(3, 3, 2, 1);
+
+ graphics.setPaint(new Color(contentBorderColor.getRed(),
+ contentBorderColor.getGreen(), contentBorderColor.getBlue(),
+ ALPHA));
+ graphics.fillRect(3, 1, 2, 1);
+ graphics.fillRect(0, 4, 2, 1);
+ graphics.fillRect(3, 4, 2, 1);
+ }
+ }
+
+ private class MoveMouseHandler implements ComponentMouseListener, ComponentMouseButtonListener {
+ public boolean mouseMove(Component component, int x, int y) {
+ Display display = (Display)component;
+
+ // Pretend that the mouse can't move off screen (off the display)
+ x = Math.min(Math.max(x, 0), display.getWidth() - 1);
+ y = Math.min(Math.max(y, 0), display.getHeight() - 1);
+
+ // Calculate the would-be new window location
+ int windowX = x - dragOffset.x;
+ int windowY = y - dragOffset.y;
+
+ Window window = (Window)getComponent();
+ window.setLocation(windowX, windowY);
+
+ return false;
+ }
+
+ public void mouseOver(Component component) {
+ }
+
+ public void mouseOut(Component component) {
+ }
+
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ return false;
+ }
+
+ public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ assert (component instanceof Display);
+ component.getComponentMouseListeners().remove(this);
+ component.getComponentMouseButtonListeners().remove(this);
+
+ return false;
+ }
+
+ public void mouseClick(Component component, Mouse.Button button, int x, int y,
+ int count) {
+ }
+ }
+
+ private class ResizeMouseHandler implements ComponentMouseListener, ComponentMouseButtonListener {
+ public boolean mouseMove(Component component, int x, int y) {
+ Display display = (Display)component;
+
+ // Pretend that the mouse can't move off screen (off the display)
+ x = Math.min(Math.max(x, 0), display.getWidth() - 1);
+ y = Math.min(Math.max(y, 0), display.getHeight() - 1);
+
+ // Calculate the would-be new window size
+ Window window = (Window)getComponent();
+
+ int preferredWidth = -1;
+ int preferredHeight = -1;
+
+ if (window.isPreferredWidthSet()) {
+ preferredWidth = Math.max(x - window.getX() + dragOffset.x,
+ titleBarFlowPane.getPreferredWidth(-1) + 2);
+ }
+
+ if (window.isPreferredHeightSet()) {
+ preferredHeight = Math.max(y - window.getY() + dragOffset.y,
+ titleBarFlowPane.getHeight() + resizeHandle.getHeight() + 7);
+ }
+
+ window.setPreferredSize(preferredWidth, preferredHeight);
+
+ return false;
+ }
+
+ public void mouseOver(Component component) {
+ }
+
+ public void mouseOut(Component component) {
+ }
+
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ return false;
+ }
+
+ public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ assert (component instanceof Display);
+ component.getComponentMouseListeners().remove(this);
+ component.getComponentMouseButtonListeners().remove(this);
+
+ return false;
+ }
+
+ public void mouseClick(Component component, Mouse.Button button, int x, int y,
+ int count) {
+ }
+ }
+
+ private Image minimizeImage = new MinimizeImage();
+ private Image maximizeImage = new MaximizeImage();
+ private Image restoreImage = new RestoreImage();
+ private Image closeImage = new CloseImage();
+ private Image resizeImage = new ResizeImage();
+
+ private FlowPane titleBarFlowPane = new FlowPane();
+ private FlowPane titleFlowPane = new FlowPane();
+ private FlowPane frameButtonFlowPane = new FlowPane();
+
+ private ImageView iconImageView = new ImageView();
+ private Label titleLabel = new Label();
+
+ private FrameButton minimizeButton = null;
+ private FrameButton maximizeButton = null;
+ private FrameButton closeButton = null;
+ private ImageView resizeHandle = new ImageView(resizeImage);
+
+ private DropShadowDecorator dropShadowDecorator = null;
+
+ private Point dragOffset = null;
+ private MoveMouseHandler moveMouseHandler = new MoveMouseHandler();
+ private ResizeMouseHandler resizeMouseHandler = new ResizeMouseHandler();
+
+ private Point restoreLocation = null;
+
+ private Color titleBarColor;
+ private Color titleBarBackgroundColor;
+ private Color titleBarBorderColor;
+ private Color inactiveTitleBarColor;
+ private Color inactiveTitleBarBackgroundColor;
+ private Color inactiveTitleBarBorderColor;
+ private Color contentBorderColor;
+ private Insets padding;
+ private boolean resizable;
+
+ // Derived colors
+ private Color titleBarBevelColor;
+ private Color inactiveTitleBarBevelColor;
+ private Color contentBevelColor;
+
+ private static final float INACTIVE_ICON_OPACITY = 0.5f;
+
+ public TerraFrameSkin() {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setBackgroundColor(theme.getColor(10));
+
+ titleBarColor = theme.getColor(4);
+ titleBarBackgroundColor = theme.getColor(16);
+ titleBarBorderColor = theme.getColor(13);
+ inactiveTitleBarColor = theme.getColor(7);
+ inactiveTitleBarBackgroundColor = theme.getColor(9);
+ inactiveTitleBarBorderColor = theme.getColor(7);
+ contentBorderColor = theme.getColor(7);
+ padding = new Insets(8);
+ resizable = true;
+
+ // Set the derived colors
+ titleBarBevelColor = TerraTheme.brighten(titleBarBackgroundColor);
+ inactiveTitleBarBevelColor = TerraTheme.brighten(inactiveTitleBarBackgroundColor);
+
+ // The title bar flow pane contains two nested flow panes: one for
+ // the title contents and the other for the buttons
+ titleBarFlowPane.add(titleFlowPane);
+ titleBarFlowPane.add(frameButtonFlowPane);
+
+ titleBarFlowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.JUSTIFY);
+ titleBarFlowPane.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
+ titleBarFlowPane.getStyles().put("padding", new Insets(2));
+
+ // Initialize the title flow pane
+ titleFlowPane.add(iconImageView);
+ titleFlowPane.add(titleLabel);
+ titleFlowPane.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
+
+ titleLabel.getStyles().put("fontBold", true);
+ iconImageView.getStyles().put("backgroundColor", null);
+
+ // Initialize the button flow pane
+ frameButtonFlowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);
+ frameButtonFlowPane.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
+ }
+
+ @Override
+ public void install(Component component) {
+ super.install(component);
+
+ Window window = (Window)component;
+
+ // Attach the drop-shadow decorator
+ dropShadowDecorator = new DropShadowDecorator();
+ window.getDecorators().add(dropShadowDecorator);
+
+ window.add(titleBarFlowPane);
+
+ // Create the frame buttons
+ minimizeButton = new FrameButton(minimizeImage);
+ maximizeButton = new FrameButton(maximizeImage);
+ closeButton = new FrameButton(closeImage);
+
+ frameButtonFlowPane.add(minimizeButton);
+ frameButtonFlowPane.add(maximizeButton);
+ frameButtonFlowPane.add(closeButton);
+
+ ButtonPressListener buttonPressListener = new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ Window window = (Window)getComponent();
+
+ if (button == minimizeButton) {
+ window.setDisplayable(false);
+ } else if (button == maximizeButton) {
+ window.setMaximized(!window.isMaximized());
+ } else if (button == closeButton) {
+ window.close();
+ }
+ }
+ };
+
+ minimizeButton.getButtonPressListeners().add(buttonPressListener);
+ maximizeButton.getButtonPressListeners().add(buttonPressListener);
+ closeButton.getButtonPressListeners().add(buttonPressListener);
+
+ window.add(resizeHandle);
+
+ iconChanged(window, null);
+ titleChanged(window, null);
+ activeChanged(window);
+
+ updateMaximizedState();
+ updateResizeHandleCursor();
+ }
+
+ @Override
+ public void uninstall() {
+ Window window = (Window)getComponent();
+
+ // Detach the drop shadow decorator
+ window.getDecorators().remove(dropShadowDecorator);
+ dropShadowDecorator = null;
+
+ window.remove(titleBarFlowPane);
+
+ frameButtonFlowPane.remove(minimizeButton);
+ frameButtonFlowPane.remove(maximizeButton);
+ frameButtonFlowPane.remove(closeButton);
+
+ minimizeButton = null;
+ maximizeButton = null;
+ closeButton = null;
+
+ super.uninstall();
+ }
+
+ public int getPreferredWidth(int height) {
+ int preferredWidth = 0;
+
+ Window window = (Window)getComponent();
+ Component content = window.getContent();
+
+ Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();
+ preferredWidth = preferredTitleBarSize.width;
+
+ if (content != null
+ && content.isDisplayable()) {
+ if (height != -1) {
+ height = Math.max(height - preferredTitleBarSize.height - 4 -
+ padding.top - padding.bottom, 0);
+ }
+
+ preferredWidth = Math.max(preferredWidth,
+ content.getPreferredWidth(height));
+ }
+
+ preferredWidth += (padding.left + padding.right) + 2;
+
+ return preferredWidth;
+ }
+
+ public int getPreferredHeight(int width) {
+ int preferredHeight = 0;
+
+ Window window = (Window)getComponent();
+ Component content = window.getContent();
+
+ if (width != -1) {
+ width = Math.max(width - 2, 0);
+ }
+
+ preferredHeight = titleBarFlowPane.getPreferredHeight(width);
+
+ if (content != null
+ && content.isDisplayable()) {
+ if (width != -1) {
+ width = Math.max(width - padding.left - padding.right, 0);
+ }
+
+ preferredHeight += content.getPreferredHeight(width);
+ }
+
+ preferredHeight += (padding.top + padding.bottom) + 4;
+
+ return preferredHeight;
+ }
+
+ public Dimensions getPreferredSize() {
+ int preferredWidth = 0;
+ int preferredHeight = 0;
+
+ Window window = (Window)getComponent();
+ Component content = window.getContent();
+
+ Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();
+
+ preferredWidth = preferredTitleBarSize.width;
+ preferredHeight = preferredTitleBarSize.height;
+
+ if (content != null
+ && content.isDisplayable()) {
+ Dimensions preferredContentSize = content.getPreferredSize();
+
+ preferredWidth = Math.max(preferredWidth, preferredContentSize.width);
+ preferredHeight += preferredContentSize.height;
+ }
+
+ preferredWidth += (padding.left + padding.right) + 2;
+ preferredHeight += (padding.top + padding.bottom) + 4;
+
+ return new Dimensions(preferredWidth, preferredHeight);
+ }
+
+ public void layout() {
+ Window window = (Window)getComponent();
+
+ int width = getWidth();
+ int height = getHeight();
+
+ // Size/position title bar
+ titleBarFlowPane.setLocation(1, 1);
+ titleBarFlowPane.setSize(Math.max(width - 2, 0),
+ Math.max(titleBarFlowPane.getPreferredHeight(width - 2), 0));
+
+ // Size/position resize handle
+ resizeHandle.setSize(resizeHandle.getPreferredSize());
+ resizeHandle.setLocation(width - resizeHandle.getWidth() - 2,
+ height - resizeHandle.getHeight() - 2);
+
+ boolean maximized = window.isMaximized();
+ resizeHandle.setVisible(resizable
+ && !maximized
+ && (window.isPreferredWidthSet()
+ || window.isPreferredHeightSet()));
+
+ // Size/position content
+ Component content = window.getContent();
+
+ if (content != null) {
+ if (content.isDisplayable()) {
+ content.setVisible(true);
+
+ content.setLocation(padding.left + 1,
+ titleBarFlowPane.getHeight() + padding.top + 3);
+
+ int contentWidth = Math.max(width - (padding.left + padding.right + 2), 0);
+ int contentHeight = Math.max(height - (titleBarFlowPane.getHeight()
+ + padding.top + padding.bottom + 4), 0);
+
+ content.setSize(contentWidth, contentHeight);
+ } else {
+ content.setVisible(false);
+ }
+ }
+ }
+
+ @Override
+ public void paint(Graphics2D graphics) {
+ // Call the base class to paint the background
+ super.paint(graphics);
+
+ Window window = (Window)getComponent();
+
+ int width = getWidth();
+ int height = getHeight();
+ int titleBarHeight = titleBarFlowPane.getHeight();
+
+ graphics.setStroke(new BasicStroke());
+
+ // Draw the title area
+ Color titleBarBackgroundColor = window.isActive() ?
+ this.titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
+ Color titleBarBorderColor = window.isActive() ?
+ this.titleBarBorderColor : inactiveTitleBarBorderColor;
+ Color titleBarBevelColor = window.isActive() ?
+ this.titleBarBevelColor : inactiveTitleBarBevelColor;
+
+ graphics.setPaint(new GradientPaint(width / 2, 0, titleBarBevelColor,
+ width / 2, titleBarHeight + 1, titleBarBackgroundColor));
+ graphics.fillRect(0, 0, width, titleBarHeight + 1);
+
+ // Draw the border
+ graphics.setPaint(titleBarBorderColor);
+ graphics.drawRect(0, 0, width - 1, titleBarHeight + 1);
+
+ // Draw the content area
+ Bounds contentAreaRectangle = new Bounds(0, titleBarHeight + 2,
+ width - 1, height - (titleBarHeight + 3));
+ graphics.setPaint(contentBorderColor);
+ graphics.drawRect(contentAreaRectangle.x, contentAreaRectangle.y,
+ contentAreaRectangle.width, contentAreaRectangle.height);
+
+ Line2D contentAreaBevelLine = new Line2D.Double(contentAreaRectangle.x + 1, contentAreaRectangle.y + 1,
+ contentAreaRectangle.width - 1, contentAreaRectangle.y + 1);
+ graphics.setPaint(contentBevelColor);
+ graphics.draw(contentAreaBevelLine);
+ }
+
+ @Override
+ public void setBackgroundColor(Color backgroundColor) {
+ super.setBackgroundColor(backgroundColor);
+ contentBevelColor = TerraTheme.brighten(backgroundColor);
+ }
+
+ public boolean getShowMinimizeButton() {
+ return minimizeButton.isDisplayable();
+ }
+
+ public void setShowMinimizeButton(boolean showMinimizeButton) {
+ minimizeButton.setDisplayable(showMinimizeButton);
+ }
+
+ public boolean getShowMaximizeButton() {
+ return maximizeButton.isDisplayable();
+ }
+
+ public void setShowMaximizeButton(boolean showMaximizeButton) {
+ maximizeButton.setDisplayable(showMaximizeButton);
+ }
+
+ public boolean getShowCloseButton() {
+ return closeButton.isDisplayable();
+ }
+
+ public void setShowCloseButton(boolean showCloseButton) {
+ closeButton.setDisplayable(showCloseButton);
+ }
+
+ public Insets getPadding() {
+ return padding;
+ }
+
+ public void setPadding(Insets padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ this.padding = padding;
+ invalidateComponent();
+ }
+
+ public final void setPadding(Dictionary<String, ?> padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(new Insets(padding));
+ }
+
+ public final void setPadding(int padding) {
+ setPadding(new Insets(padding));
+ }
+
+ public final void setPadding(Number padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(padding.intValue());
+ }
+
+ public boolean isResizable() {
+ return resizable;
+ }
+
+ public void setResizable(boolean resizable) {
+ this.resizable = resizable;
+ invalidateComponent();
+ }
+
+ private void updateMaximizedState() {
+ Window window = (Window)getComponent();
+ boolean maximized = window.isMaximized();
+
+ if (!maximized) {
+ maximizeButton.setButtonData(maximizeImage);
+
+ if (restoreLocation != null) {
+ window.setLocation(restoreLocation.x, restoreLocation.y);
+ }
+ } else {
+ maximizeButton.setButtonData(restoreImage);
+ restoreLocation = window.getLocation();
+ }
+ }
+
+ @Override
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ boolean consumed = super.mouseDown(component, button, x, y);
+
+ Window window = (Window)getComponent();
+ boolean maximized = window.isMaximized();
+
+ if (button == Mouse.Button.LEFT
+ && !maximized) {
+ Bounds titleBarBounds = titleBarFlowPane.getBounds();
+
+ if (titleBarBounds.contains(x, y)) {
+ dragOffset = new Point(x, y);
+
+ Display display = window.getDisplay();
+ display.getComponentMouseListeners().add(moveMouseHandler);
+ display.getComponentMouseButtonListeners().add(moveMouseHandler);
+ } else {
+ Bounds resizeHandleBounds = resizeHandle.getBounds();
+
+ if (resizeHandleBounds.contains(x, y)) {
+ dragOffset = new Point(getWidth() - x, getHeight() - y);
+
+ Display display = window.getDisplay();
+ display.getComponentMouseListeners().add(resizeMouseHandler);
+ display.getComponentMouseButtonListeners().add(resizeMouseHandler);
+ }
+ }
+ }
+
+ return consumed;
+ }
+
+ @Override
+ public void titleChanged(Window window, String previousTitle) {
+ String title = window.getTitle();
+ titleLabel.setDisplayable(title != null);
+ titleLabel.setText(title);
+ }
+
+ @Override
+ public void iconChanged(Window window, Image previousIcon) {
+ Image icon = window.getIcon();
+ iconImageView.setDisplayable(icon != null);
+ iconImageView.setImage(icon);
+ }
+
+ @Override
+ public void activeChanged(Window window) {
+ boolean active = window.isActive();
+
+ titleLabel.getStyles().put("color", active ?
+ titleBarColor : inactiveTitleBarColor);
+ iconImageView.getStyles().put("opacity", active ?
+ 1.0f : INACTIVE_ICON_OPACITY);
+
+ updateButtonStyles(minimizeButton, active);
+ updateButtonStyles(maximizeButton, active);
+ updateButtonStyles(closeButton, active);
+
+ repaintComponent();
+ }
+
+ private void updateButtonStyles(FrameButton frameButton, boolean active) {
+ frameButton.getStyles().put("color", active ?
+ titleBarColor : inactiveTitleBarColor);
+ frameButton.getStyles().put("backgroundColor", active ?
+ titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
+ frameButton.getStyles().put("borderColor", active ?
+ titleBarBorderColor : inactiveTitleBarBorderColor);
+ }
+
+ private void updateResizeHandleCursor() {
+ Window window = (Window)getComponent();
+
+ Cursor cursor = Cursor.DEFAULT;
+
+ boolean preferredWidthSet = window.isPreferredWidthSet();
+ boolean preferredHeightSet = window.isPreferredHeightSet();
+
+ if (preferredWidthSet
+ && preferredHeightSet) {
+ cursor = Cursor.RESIZE_SOUTH_EAST;
+ } else if (preferredWidthSet) {
+ cursor = Cursor.RESIZE_EAST;
+ } else if (preferredHeightSet) {
+ cursor = Cursor.RESIZE_SOUTH;
+ }
+
+ resizeHandle.setCursor(cursor);
+ }
+
+ @Override
+ public void maximizedChanged(Window window) {
+ updateMaximizedState();
+ }
+
+ @Override
+ public void preferredSizeChanged(Component component,
+ int previousPreferredWidth, int previousPreferredHeight) {
+ updateResizeHandleCursor();
+ }
+
+ @Override
+ public void displayableChanged(Component component) {
+ // No-op
+ }
+}
Added: incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLabelSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLabelSkin.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLabelSkin.java (added)
+++ incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLabelSkin.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin.terra;
+
+import pivot.wtk.Theme;
+import pivot.wtk.skin.LabelSkin;
+
+/**
+ * Terra label skin.
+ *
+ * @author gbrown
+ */
+public class TerraLabelSkin extends LabelSkin {
+ public TerraLabelSkin() {
+ setColor(1);
+ }
+
+ public final void setColor(int color) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setColor(theme.getColor(color));
+ }
+}
Added: incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLinkButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLinkButtonSkin.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLinkButtonSkin.java (added)
+++ incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraLinkButtonSkin.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin.terra;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+
+import pivot.wtk.Button;
+import pivot.wtk.Dimensions;
+import pivot.wtk.LinkButton;
+import pivot.wtk.Theme;
+import pivot.wtk.skin.LinkButtonSkin;
+
+/**
+ * Terra link button skin.
+ *
+ * @author gbrown
+ */
+public class TerraLinkButtonSkin extends LinkButtonSkin {
+ private Font font;
+ private Color color;
+ private Color disabledColor;
+
+ public TerraLinkButtonSkin() {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ font = theme.getFont();
+ color = theme.getColor(13);
+ disabledColor = theme.getColor(7);
+ }
+
+ public int getPreferredWidth(int height) {
+ LinkButton linkButton = (LinkButton)getComponent();
+
+ Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
+ dataRenderer.render(linkButton.getButtonData(), linkButton, false);
+
+ return dataRenderer.getPreferredWidth(height);
+ }
+
+ public int getPreferredHeight(int width) {
+ LinkButton linkButton = (LinkButton)getComponent();
+
+ Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
+ dataRenderer.render(linkButton.getButtonData(), linkButton, false);
+
+ return dataRenderer.getPreferredHeight(width);
+ }
+
+ public Dimensions getPreferredSize() {
+ LinkButton linkButton = (LinkButton)getComponent();
+
+ Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
+ dataRenderer.render(linkButton.getButtonData(), linkButton, false);
+
+ return dataRenderer.getPreferredSize();
+ }
+
+ public void paint(Graphics2D graphics) {
+ LinkButton linkButton = (LinkButton)getComponent();
+ int width = getWidth();
+ int height = getHeight();
+
+ Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
+ dataRenderer.render(linkButton.getButtonData(), linkButton, highlighted);
+ dataRenderer.setSize(width, height);
+
+ dataRenderer.paint(graphics);
+ }
+
+ /**
+ * @return
+ * <tt>false</tt>; link buttons are not focusable.
+ */
+ @Override
+ public boolean isFocusable() {
+ return false;
+ }
+
+ public Font getFont() {
+ return font;
+ }
+
+ public void setFont(Font font) {
+ if (font == null) {
+ throw new IllegalArgumentException("font is null.");
+ }
+
+ this.font = font;
+ invalidateComponent();
+ }
+
+ public final void setFont(String font) {
+ if (font == null) {
+ throw new IllegalArgumentException("font is null.");
+ }
+
+ setFont(Font.decode(font));
+ }
+
+ public Color getColor() {
+ return color;
+ }
+
+ public void setColor(Color color) {
+ if (color == null) {
+ throw new IllegalArgumentException("color is null.");
+ }
+
+ this.color = color;
+ repaintComponent();
+ }
+
+ public final void setColor(String color) {
+ if (color == null) {
+ throw new IllegalArgumentException("color is null.");
+ }
+
+ setColor(decodeColor(color));
+ }
+
+ public Color getDisabledColor() {
+ return disabledColor;
+ }
+
+ public void setDisabledColor(Color disabledColor) {
+ if (disabledColor == null) {
+ throw new IllegalArgumentException("disabledColor is null.");
+ }
+
+ this.disabledColor = disabledColor;
+ repaintComponent();
+ }
+
+ public final void setDisabledColor(String disabledColor) {
+ if (disabledColor == null) {
+ throw new IllegalArgumentException("disabledColor is null.");
+ }
+
+ setDisabledColor(decodeColor(disabledColor));
+ }
+}
Added: incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraListButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraListButtonSkin.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraListButtonSkin.java (added)
+++ incubator/pivot/tags/v1.0.1/wtk/src/pivot/wtk/skin/terra/TerraListButtonSkin.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,560 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.skin.terra;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+
+import pivot.collections.Dictionary;
+import pivot.collections.List;
+import pivot.util.Vote;
+import pivot.wtk.Border;
+import pivot.wtk.Button;
+import pivot.wtk.Dimensions;
+import pivot.wtk.Display;
+import pivot.wtk.Insets;
+import pivot.wtk.ListButton;
+import pivot.wtk.Panorama;
+import pivot.wtk.Bounds;
+import pivot.wtk.Theme;
+import pivot.wtk.Window;
+import pivot.wtk.WindowStateListener;
+import pivot.wtk.effects.Transition;
+import pivot.wtk.effects.TransitionListener;
+import pivot.wtk.skin.ListButtonSkin;
+
+/**
+ * Terra list button skin.
+ *
+ * @author gbrown
+ */
+public class TerraListButtonSkin extends ListButtonSkin {
+ private Panorama listViewPanorama;
+ private Border listViewBorder;
+
+ private WindowStateListener listViewPopupStateListener = new WindowStateListener() {
+ public Vote previewWindowOpen(Window window, Display display) {
+ return Vote.APPROVE;
+ }
+
+ public void windowOpenVetoed(Window window, Vote reason) {
+ // No-op
+ }
+
+ public void windowOpened(Window window) {
+ // No-op
+ }
+
+ public Vote previewWindowClose(final Window window) {
+ Vote vote = Vote.APPROVE;
+
+ if (closeTransition == null) {
+ closeTransition = new FadeTransition(window,
+ CLOSE_TRANSITION_DURATION, CLOSE_TRANSITION_RATE);
+
+ closeTransition.start(new TransitionListener() {
+ public void transitionCompleted(Transition transition) {
+ window.close();
+ }
+ });
+
+ vote = Vote.DEFER;
+ } else {
+ vote = (closeTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
+ }
+
+ return vote;
+ }
+
+ public void windowCloseVetoed(Window window, Vote reason) {
+ if (reason == Vote.DENY
+ && closeTransition != null) {
+ closeTransition.stop();
+ closeTransition = null;
+ }
+ }
+
+ public void windowClosed(Window window, Display display) {
+ closeTransition = null;
+ getComponent().requestFocus();
+ }
+ };
+
+ private Font font;
+ private Color color;
+ private Color disabledColor;
+ private Color backgroundColor;
+ private Color disabledBackgroundColor;
+ private Color borderColor;
+ private Color disabledBorderColor;
+ private Insets padding;
+
+ // Derived colors
+ private Color bevelColor;
+ private Color pressedBevelColor;
+ private Color disabledBevelColor;
+
+ private Transition closeTransition = null;
+
+ private static final int TRIGGER_WIDTH = 14;
+
+ private static final int CLOSE_TRANSITION_DURATION = 150;
+ private static final int CLOSE_TRANSITION_RATE = 30;
+
+ public TerraListButtonSkin() {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+
+ font = theme.getFont();
+ color = theme.getColor(1);
+ disabledColor = theme.getColor(7);
+ backgroundColor = theme.getColor(10);
+ disabledBackgroundColor = theme.getColor(10);
+ borderColor = theme.getColor(7);
+ disabledBorderColor = theme.getColor(7);
+ padding = new Insets(2, 3, 2, 3);
+
+ // Set the derived colors
+ bevelColor = TerraTheme.brighten(backgroundColor);
+ pressedBevelColor = TerraTheme.darken(backgroundColor);
+ disabledBevelColor = disabledBackgroundColor;
+
+ listViewPopup.getWindowStateListeners().add(listViewPopupStateListener);
+
+ // Create the panorama and border
+ listViewPanorama = new Panorama(listView);
+ listViewPanorama.getStyles().put("buttonBackgroundColor",
+ listView.getStyles().get("backgroundColor"));
+
+ listViewBorder = new Border(listViewPanorama);
+ listViewBorder.getStyles().put("padding", 0);
+ listViewBorder.getStyles().put("color", borderColor);
+
+ // Set the popup content
+ listViewPopup.setContent(listViewBorder);
+ }
+
+ @SuppressWarnings("unchecked")
+ public int getPreferredWidth(int height) {
+ ListButton listButton = (ListButton)getComponent();
+ List<Object> listData = (List<Object>)listButton.getListData();
+
+ Button.DataRenderer dataRenderer = listButton.getDataRenderer();
+
+ // Include padding in constraint
+ if (height != -1) {
+ height = Math.max(height - (padding.top + padding.bottom + 2), 0);
+ }
+
+ // Determine the preferred width of the current button data
+ dataRenderer.render(listButton.getButtonData(),
+ listButton, false);
+ int preferredWidth = dataRenderer.getPreferredWidth(-1);
+
+ // The preferred width of the button is the max. width of the rendered
+ // content plus padding and the trigger width
+ for (Object item : listData) {
+ dataRenderer.render(item, listButton, false);
+ preferredWidth = Math.max(preferredWidth, dataRenderer.getPreferredWidth(-1));
+ }
+
+ preferredWidth += TRIGGER_WIDTH + padding.left + padding.right + 2;
+
+ return preferredWidth;
+ }
+
+ public int getPreferredHeight(int width) {
+ ListButton listButton = (ListButton)getComponent();
+ Button.DataRenderer dataRenderer = listButton.getDataRenderer();
+
+ dataRenderer.render(listButton.getButtonData(), listButton, false);
+
+ int preferredHeight = dataRenderer.getPreferredHeight(-1)
+ + padding.top + padding.bottom + 2;
+
+ return preferredHeight;
+ }
+
+ public Dimensions getPreferredSize() {
+ // TODO Optimize by performing calcuations locally
+ return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
+ }
+
+ public void layout() {
+ // No-op
+ }
+
+ public void paint(Graphics2D graphics) {
+ ListButton listButton = (ListButton)getComponent();
+
+ int width = getWidth();
+ int height = getHeight();
+
+ Color backgroundColor = null;
+ Color bevelColor = null;
+ Color borderColor = null;
+
+ if (listButton.isEnabled()) {
+ backgroundColor = this.backgroundColor;
+ bevelColor = (pressed
+ || (listViewPopup.isOpen() && closeTransition == null)) ? pressedBevelColor : this.bevelColor;
+ borderColor = this.borderColor;
+ } else {
+ backgroundColor = disabledBackgroundColor;
+ bevelColor = disabledBevelColor;
+ borderColor = disabledBorderColor;
+ }
+
+ graphics.setStroke(new BasicStroke());
+
+ // Paint the background
+ graphics.setPaint(new GradientPaint(width / 2, 0, bevelColor,
+ width / 2, height / 2, backgroundColor));
+ graphics.fillRect(0, 0, width, height);
+
+ // Paint the border
+ graphics.setPaint(borderColor);
+
+ Bounds contentBounds = new Bounds(0, 0,
+ Math.max(width - TRIGGER_WIDTH - 1, 0), Math.max(height - 1, 0));
+ graphics.drawRect(contentBounds.x, contentBounds.y, contentBounds.width, contentBounds.height);
+
+ Bounds triggerBounds = new Bounds(Math.max(width - TRIGGER_WIDTH - 1, 0), 0,
+ TRIGGER_WIDTH, Math.max(height - 1, 0));
+ graphics.drawRect(triggerBounds.x, triggerBounds.y, triggerBounds.width, triggerBounds.height);
+
+ // Paint the content
+ Button.DataRenderer dataRenderer = listButton.getDataRenderer();
+ dataRenderer.render(listButton.getButtonData(), listButton, false);
+ dataRenderer.setSize(Math.max(contentBounds.width - (padding.left + padding.right + 2) + 1, 0),
+ Math.max(contentBounds.height - (padding.top + padding.bottom + 2) + 1, 0));
+
+ Graphics2D contentGraphics = (Graphics2D)graphics.create();
+ contentGraphics.translate(padding.left + 1, padding.top + 1);
+ contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
+ dataRenderer.paint(contentGraphics);
+ contentGraphics.dispose();
+
+ // Paint the focus state
+ if (listButton.isFocused()) {
+ BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_ROUND, 1.0f, new float[] {0.0f, 2.0f}, 0.0f);
+
+ graphics.setStroke(dashStroke);
+ graphics.setColor(borderColor);
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+
+ graphics.drawRect(2, 2, Math.max(contentBounds.width - 4, 0),
+ Math.max(contentBounds.height - 4, 0));
+
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_OFF);
+ }
+
+ // Paint the trigger
+ GeneralPath triggerIconShape = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
+ triggerIconShape.moveTo(0, 0);
+ triggerIconShape.lineTo(3, 3);
+ triggerIconShape.lineTo(6, 0);
+ triggerIconShape.closePath();
+
+ Graphics2D triggerGraphics = (Graphics2D)graphics.create();
+ triggerGraphics.setStroke(new BasicStroke(0));
+ triggerGraphics.setPaint(color);
+
+ int tx = triggerBounds.x + Math.round((triggerBounds.width
+ - triggerIconShape.getBounds().width) / 2f);
+ int ty = triggerBounds.y + Math.round((triggerBounds.height
+ - triggerIconShape.getBounds().height) / 2f);
+ triggerGraphics.translate(tx, ty);
+
+ triggerGraphics.draw(triggerIconShape);
+ triggerGraphics.fill(triggerIconShape);
+
+ triggerGraphics.dispose();
+ }
+
+ public Font getFont() {
+ return font;
+ }
+
+ public void setFont(Font font) {
+ if (font == null) {
+ throw new IllegalArgumentException("font is null.");
+ }
+
+ this.font = font;
+ invalidateComponent();
+ }
+
+ public final void setFont(String font) {
+ if (font == null) {
+ throw new IllegalArgumentException("font is null.");
+ }
+
+ setFont(Font.decode(font));
+ }
+
+ public Color getColor() {
+ return color;
+ }
+
+ public void setColor(Color color) {
+ if (color == null) {
+ throw new IllegalArgumentException("color is null.");
+ }
+
+ this.color = color;
+ repaintComponent();
+ }
+
+ public final void setColor(String color) {
+ if (color == null) {
+ throw new IllegalArgumentException("color is null.");
+ }
+
+ setColor(decodeColor(color));
+ }
+
+ public Color getDisabledColor() {
+ return disabledColor;
+ }
+
+ public void setDisabledColor(Color disabledColor) {
+ if (disabledColor == null) {
+ throw new IllegalArgumentException("disabledColor is null.");
+ }
+
+ this.disabledColor = disabledColor;
+ repaintComponent();
+ }
+
+ public final void setDisabledColor(String disabledColor) {
+ if (disabledColor == null) {
+ throw new IllegalArgumentException("disabledColor is null.");
+ }
+
+ setDisabledColor(decodeColor(disabledColor));
+ }
+
+ public Color getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ public void setBackgroundColor(Color backgroundColor) {
+ if (backgroundColor == null) {
+ throw new IllegalArgumentException("backgroundColor is null.");
+ }
+
+ this.backgroundColor = backgroundColor;
+ bevelColor = TerraTheme.brighten(backgroundColor);
+ pressedBevelColor = TerraTheme.darken(backgroundColor);
+ repaintComponent();
+ }
+
+ public final void setBackgroundColor(String backgroundColor) {
+ if (backgroundColor == null) {
+ throw new IllegalArgumentException("backgroundColor is null.");
+ }
+
+ setBackgroundColor(decodeColor(backgroundColor));
+ }
+
+ public Color getDisabledBackgroundColor() {
+ return disabledBackgroundColor;
+ }
+
+ public void setDisabledBackgroundColor(Color disabledBackgroundColor) {
+ if (disabledBackgroundColor == null) {
+ throw new IllegalArgumentException("disabledBackgroundColor is null.");
+ }
+
+ this.disabledBackgroundColor = disabledBackgroundColor;
+ disabledBevelColor = disabledBackgroundColor;
+ repaintComponent();
+ }
+
+ public final void setDisabledBackgroundColor(String disabledBackgroundColor) {
+ if (disabledBackgroundColor == null) {
+ throw new IllegalArgumentException("disabledBackgroundColor is null.");
+ }
+
+ setDisabledBackgroundColor(decodeColor(disabledBackgroundColor));
+ }
+
+ public Color getBorderColor() {
+ return borderColor;
+ }
+
+ public void setBorderColor(Color borderColor) {
+ if (borderColor == null) {
+ throw new IllegalArgumentException("borderColor is null.");
+ }
+
+ this.borderColor = borderColor;
+ listViewBorder.getStyles().put("color", borderColor);
+ repaintComponent();
+ }
+
+ public final void setBorderColor(String borderColor) {
+ if (borderColor == null) {
+ throw new IllegalArgumentException("borderColor is null.");
+ }
+
+ setBorderColor(decodeColor(borderColor));
+ }
+
+ public Color getDisabledBorderColor() {
+ return disabledBorderColor;
+ }
+
+ public void setDisabledBorderColor(Color disabledBorderColor) {
+ if (disabledBorderColor == null) {
+ throw new IllegalArgumentException("disabledBorderColor is null.");
+ }
+
+ this.disabledBorderColor = disabledBorderColor;
+ repaintComponent();
+ }
+
+ public final void setDisabledBorderColor(String disabledBorderColor) {
+ if (disabledBorderColor == null) {
+ throw new IllegalArgumentException("disabledBorderColor is null.");
+ }
+
+ setDisabledBorderColor(decodeColor(disabledBorderColor));
+ }
+
+ public Insets getPadding() {
+ return padding;
+ }
+
+ public void setPadding(Insets padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ this.padding = padding;
+ invalidateComponent();
+ }
+
+ public final void setPadding(Dictionary<String, ?> padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(new Insets(padding));
+ }
+
+ public final void setPadding(int padding) {
+ setPadding(new Insets(padding));
+ }
+
+ public final void setPadding(Number padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(padding.intValue());
+ }
+
+ public Object getListFont() {
+ return listView.getStyles().get("font");
+ }
+
+ public void setListFont(Object listFont) {
+ listView.getStyles().put("font", listFont);
+ }
+
+ public Object getListColor() {
+ return listView.getStyles().get("color");
+ }
+
+ public void setListColor(Object listColor) {
+ listView.getStyles().put("color", listColor);
+ }
+
+ public Object getListDisabledColor() {
+ return listView.getStyles().get("disabledColor");
+ }
+
+ public void setListDisabledColor(Object listDisabledColor) {
+ listView.getStyles().put("disabledColor", listDisabledColor);
+ }
+
+ public Object getListBackgroundColor() {
+ return listView.getStyles().get("backgroundColor");
+ }
+
+ public void setListBackgroundColor(Object listBackgroundColor) {
+ listView.getStyles().put("backgroundColor", listBackgroundColor);
+ listViewPanorama.getStyles().put("buttonBackgroundColor", listBackgroundColor);
+ }
+
+ public Object getListSelectionColor() {
+ return listView.getStyles().get("selectionColor");
+ }
+
+ public void setListSelectionColor(Object listSelectionColor) {
+ listView.getStyles().put("selectionColor", listSelectionColor);
+ }
+
+ public Object getListSelectionBackgroundColor() {
+ return listView.getStyles().get("selectionBackgroundColor");
+ }
+
+ public void setListSelectionBackgroundColor(Object listSelectionBackgroundColor) {
+ listView.getStyles().put("selectionBackgroundColor", listSelectionBackgroundColor);
+ }
+
+ public Object getListInactiveSelectionColor() {
+ return listView.getStyles().get("inactiveSelectionColor");
+ }
+
+ public void setListInactiveSelectionColor(Object listInactiveSelectionColor) {
+ listView.getStyles().put("inactiveSelectionColor", listInactiveSelectionColor);
+ }
+
+ public Object getListInactiveSelectionBackgroundColor() {
+ return listView.getStyles().get("inactiveSelectionBackgroundColor");
+ }
+
+ public void setListInactiveSelectionBackgroundColor(Object listInactiveSelectionBackgroundColor) {
+ listView.getStyles().put("inactiveSelectionBackgroundColor", listInactiveSelectionBackgroundColor);
+ }
+
+ public Object getListHighlightColor() {
+ return listView.getStyles().get("highlightColor");
+ }
+
+ public void setListHighlightColor(Object listHighlightColor) {
+ listView.getStyles().put("highlightColor", listHighlightColor);
+ }
+
+ public Object getListHighlightBackgroundColor() {
+ return listView.getStyles().get("highlightBackgroundColor");
+ }
+
+ public void setListHighlightBackgroundColor(Object listHighlightBackgroundColor) {
+ listView.getStyles().put("highlightBackgroundColor", listHighlightBackgroundColor);
+ }
+}