import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
-import org.tizen.dynamicanalyzer.widgets.button.splitButton.DACustomSplitButton;
public class DACustomButtonAttribute {
- private static final int MAX_SIZE = 12;
+ public static final int MAX_SIZE = 12;
private String text;
private Image buttonImage = null;
private Font font;
private List<Color> outlineColors = new ArrayList<Color>();
private List<Color> outlineInColors = new ArrayList<Color>();
- // style : draw or position
- private int splitButtonType = DACustomSplitButton.TYPE_POLYGON;
-
- // split line
- private boolean isPolygonSeparator = false;
- private List<Point> polygonSeparatorPoints = new ArrayList<Point>();
- private List<Color> polygonSeparatorColors = new ArrayList<Color>();
-
- // polygon
- private List<Point> polygonPoints = new ArrayList<Point>();
- private List<Color> polygonColors = new ArrayList<Color>();
-
- // split area
- private List<Point> polygonAreaPoints = new ArrayList<Point>();
-
public DACustomButtonAttribute() {
for (int i = 0; i < MAX_SIZE; i++) {
images.add(null);
fontColors.add(null);
outlineColors.add(null);
outlineInColors.add(null);
- polygonSeparatorPoints.add(null);
- polygonSeparatorColors.add(null);
- polygonColors.add(null);
- polygonAreaPoints.add(null);
}
- polygonPoints.clear();
}
public String getText() {
public int getAlign() {
return this.align;
}
-
- public boolean isPolygonSeparator() {
- return isPolygonSeparator;
- }
-
- public void setPolygonSeparator(boolean isPolygonSeparator) {
- this.isPolygonSeparator = isPolygonSeparator;
- }
-
- public Point getPolygonSeparatorPoint(int position) {
- return polygonSeparatorPoints.get(position);
- }
-
- public void setPolygonSeparatorPoint(int position, Point polygonSeparatorPoint) {
- polygonSeparatorPoints.set(position, polygonSeparatorPoint);
- }
-
- public Point getPolygonPoint(int index) {
- return polygonPoints.get(index);
- }
-
- public List<Point> getPolygonPoints() {
- return polygonPoints;
- }
-
- public void setPolygonPoint(Point polygonPoint) {
- polygonPoints.add(polygonPoint);
- }
-
- public Color getPolygonSeparatorColor(int state) {
- return polygonSeparatorColors.get(state);
- }
-
- public void setPolygonSeparatorColor(int state, Color color) {
- polygonSeparatorColors.set(state, color);
- }
-
- public Color getPolygonColor(int state) {
- return polygonColors.get(state);
- }
-
- public void setPolygonColor(int state, Color color) {
- polygonColors.set(state, color);
- }
-
- public Point getPolygonAreaPoint(int position) {
- return polygonAreaPoints.get(position);
- }
-
- public void setPolygonAreaPoint(int position, Point polygonAreaPoint) {
- polygonAreaPoints.set(position, polygonAreaPoint);
- }
-
- public int getSplitButtonType() {
- return splitButtonType;
- }
-
- public void setSplitButtonType(int splitButtonType) {
- this.splitButtonType = splitButtonType;
- }
-
-
+
}
*/
package org.tizen.dynamicanalyzer.widgets.button.splitButton;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
+/**
+ * This class represents the context button.
+ * if you click the arrow of the button, context menu is display.
+ */
public class DACustomSplitButton extends DACustomButton {
// style
public static final int AREA_START = 0;
public static final int AREA_END = 1;
+ // context menu
private DAPopupMenu popupMenu = null;
public DACustomSplitButton(Composite parent, int style) {
}
public DACustomSplitButton(Composite parent, Image normal, Image mouseDown,
- Image hover, Image disable) {
- super(parent, normal, mouseDown, hover, disable);
+ Image hover, Image disable) {
+ super(parent, SWT.TRANSPARENT);
initSplitButton();
+ setImages(normal, mouseDown, hover, disable);
+ attr.setDrawType(TYPE_IMAGE);
}
public DACustomSplitButton(Composite parent, Color normalStart, Color normalEnd,
Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd,
Color disableStart, Color disableEnd) {
- super(parent, normalStart, normalEnd, pushStart, pushEnd,
- hoverStart, hoverEnd, disableStart, disableEnd);
+ super(parent, SWT.NONE);
initSplitButton();
+ attr.setColor(0, normalStart);
+ attr.setColor(1, normalEnd);
+ attr.setColor(2, pushStart);
+ attr.setColor(3, pushEnd);
+ attr.setColor(4, hoverStart);
+ attr.setColor(5, hoverEnd);
+ attr.setColor(6, disableStart);
+ attr.setColor(7, disableEnd);
+ attr.setDrawType(TYPE_GRADATION);
}
public void initSplitButton() {
buttonRenderer = new DACustomSplitButtonRenderer();
+ attr = new DACustomSplitButtonAttribute();
// addListeners();
}
this.popupMenu = popupMenu;
}
- public void setPolygonSeparatorColors(Color normal, Color push, Color hover,
- Color disable) {
- attr.setPolygonSeparatorColor(STATE_NORMAL, normal);
- attr.setPolygonSeparatorColor(STATE_PUSH, push);
- attr.setPolygonSeparatorColor(STATE_HOVER, hover);
- attr.setPolygonSeparatorColor(STATE_DISABLE, disable);
- }
-
- public void setPolygonSeparatorColor(int state, Color color) {
- attr.setPolygonSeparatorColor(state, color);
- }
-
- public void setPolygonColors(Color normal, Color push, Color hover,
- Color disable) {
- attr.setPolygonColor(STATE_NORMAL, normal);
- attr.setPolygonColor(STATE_PUSH, push);
- attr.setPolygonColor(STATE_HOVER, hover);
- attr.setPolygonColor(STATE_DISABLE, disable);
- }
-
- public void setPolygonColor(int state, Color color) {
- attr.setPolygonColor(state, color);
+ public DACustomSplitButtonAttribute getAttr() {
+ return (DACustomSplitButtonAttribute)attr;
}
- public void setPolygonSeparatorPoint(int position, Point point) {
- attr.setPolygonSeparatorPoint(position, point);
- }
-
- public void setPolygonAreaPoint(int position, Point point) {
- attr.setPolygonAreaPoint(position, point);
- }
-
- public Point getPolygonAreaPoint(int position) {
- return attr.getPolygonAreaPoint(position);
- }
-
- public void setPolygonPoint(Point point) {
- attr.setPolygonPoint(point);
- }
-
- public void setPolygonSeparator(boolean isPolygonSeparator) {
- attr.setPolygonSeparator(isPolygonSeparator);
- }
-
- public void setSplitButtonType(int splitButtonType) {
- attr.setSplitButtonType(splitButtonType);
- }
-
-
+// TODO : change depending on the image transfer of the design team.
// protected Listener splitButtonMouseListener = new Listener() {
//
// @Override
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.dynamicanalyzer.widgets.button.splitButton;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonAttribute;
+
+/**
+ * This class represents a property that is used to draw the split button.
+ */
+public class DACustomSplitButtonAttribute extends DACustomButtonAttribute {
+
+ // style : draw or position
+ private int splitButtonType = DACustomSplitButton.TYPE_POLYGON;
+
+ // split line
+ private boolean isPolygonSeparator = false;
+ private List<Point> polygonSeparatorPoints = new ArrayList<Point>();
+ private List<Color> polygonSeparatorColors = new ArrayList<Color>();
+
+ // polygon
+ private List<Point> polygonPoints = new ArrayList<Point>();
+ private List<Color> polygonColors = new ArrayList<Color>();
+
+ // split area
+ private List<Point> polygonAreaPoints = new ArrayList<Point>();
+
+ public DACustomSplitButtonAttribute() {
+ super();
+ for (int i = 0; i < MAX_SIZE; i++) {
+ polygonSeparatorPoints.add(null);
+ polygonSeparatorColors.add(null);
+ polygonColors.add(null);
+ polygonAreaPoints.add(null);
+ }
+ polygonPoints.clear();
+ }
+
+ public boolean isPolygonSeparator() {
+ return isPolygonSeparator;
+ }
+
+ public void setPolygonSeparator(boolean isPolygonSeparator) {
+ this.isPolygonSeparator = isPolygonSeparator;
+ }
+
+ public Point getPolygonSeparatorPoint(int position) {
+ return polygonSeparatorPoints.get(position);
+ }
+
+ public void setPolygonSeparatorPoint(int position, Point polygonSeparatorPoint) {
+ polygonSeparatorPoints.set(position, polygonSeparatorPoint);
+ }
+
+ public Point getPolygonPoint(int index) {
+ return polygonPoints.get(index);
+ }
+
+ public List<Point> getPolygonPoints() {
+ return polygonPoints;
+ }
+
+ public void setPolygonPoint(Point polygonPoint) {
+ polygonPoints.add(polygonPoint);
+ }
+
+ public Color getPolygonSeparatorColor(int state) {
+ return polygonSeparatorColors.get(state);
+ }
+
+ public void setPolygonSeparatorColor(int state, Color color) {
+ polygonSeparatorColors.set(state, color);
+ }
+
+ public Color getPolygonColor(int state) {
+ return polygonColors.get(state);
+ }
+
+ public void setPolygonColor(int state, Color color) {
+ polygonColors.set(state, color);
+ }
+
+ public Point getPolygonAreaPoint(int position) {
+ return polygonAreaPoints.get(position);
+ }
+
+ public void setPolygonAreaPoint(int position, Point polygonAreaPoint) {
+ polygonAreaPoints.set(position, polygonAreaPoint);
+ }
+
+ public int getSplitButtonType() {
+ return splitButtonType;
+ }
+
+ public void setSplitButtonType(int splitButtonType) {
+ this.splitButtonType = splitButtonType;
+ }
+
+ public void setPolygonSeparatorColors(Color normal, Color push, Color hover,
+ Color disable) {
+ polygonSeparatorColors.set(DACustomButton.STATE_NORMAL, normal);
+ polygonSeparatorColors.set(DACustomButton.STATE_PUSH, push);
+ polygonSeparatorColors.set(DACustomButton.STATE_HOVER, hover);
+ polygonSeparatorColors.set(DACustomButton.STATE_DISABLE, disable);
+ }
+
+ public void setPolygonColors(Color normal, Color push, Color hover,
+ Color disable) {
+ polygonColors.set(DACustomButton.STATE_NORMAL, normal);
+ polygonColors.set(DACustomButton.STATE_PUSH, normal);
+ polygonColors.set(DACustomButton.STATE_HOVER, normal);
+ polygonColors.set(DACustomButton.STATE_DISABLE, disable);
+ }
+
+}
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
+/**
+ * This class is responsible for the operation when the user clicks on the split button.
+ */
public abstract class DACustomSplitButtonClickEventListener extends
DACustomButtonClickEventListener {
int y = event.y;
if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {
+ // return if it is not button area
return;
}
} else {
}
if (!button.isDisposed()) {
+ // if the button does not dispose, applied to tooltip
button.setToolTipText(tooltip);
}
}
}
private boolean isShowMenu(DACustomSplitButton button, int x, int y) {
- Point startArea = button.getPolygonAreaPoint(DACustomSplitButton.AREA_START);
- Point endArea = button.getPolygonAreaPoint(DACustomSplitButton.AREA_END);
+ DACustomSplitButtonAttribute attr = button.getAttr();
+ Point startArea = attr.getPolygonAreaPoint(DACustomSplitButton.AREA_START);
+ Point endArea = attr.getPolygonAreaPoint(DACustomSplitButton.AREA_END);
return x>=startArea.x && y>startArea.y && x<=endArea.x && y<=endArea.y;
}
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonAttribute;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
+/**
+ * This class is responsible for drawing the split button.
+ */
public class DACustomSplitButtonRenderer extends DACustomButtonRenderer {
@Override
drawButton(gc, rect, state, attr);
}
- if (attr.getSplitButtonType() == DACustomSplitButton.TYPE_POLYGON) {
- drawButtonPolygon(gc, rect, attr, state);
+ DACustomSplitButtonAttribute splitAttr = (DACustomSplitButtonAttribute)attr;
+ if (splitAttr.getSplitButtonType() == DACustomSplitButton.TYPE_POLYGON) {
+ drawButtonPolygon(gc, rect, splitAttr, state);
}
}
protected void drawButtonPolygon(GC gc, Rectangle rect,
- DACustomButtonAttribute attr, int state) {
+ DACustomSplitButtonAttribute attr, int state) {
Color color = null;
// draw split line