import org.tizen.dynamicanalyzer.util.DALogger;
import org.tizen.dynamicanalyzer.widgets.DAWidgetConstants;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonAttribute;
import org.tizen.dynamicanalyzer.widgets.button.IDACustomButtonRenderer;
import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
public static final int STATE_PUSH = 2;
public static final int STATE_DISABLE = 3;
- public static final int TEXT_ALIGN_CENTER = 0;
- public static final int TEXT_ALIGN_LEFT = 1;
- public static final int TEXT_ALIGN_RIGHT = 2;
-
- private static final int pageSize = 5;
+ public static final int TEXT_ALIGN_CENTER = SWT.CENTER;
+ public static final int TEXT_ALIGN_LEFT = SWT.LEFT;
+ public static final int TEXT_ALIGN_RIGHT = SWT.RIGHT;
public static final int TYPE_IMAGE = 0;
public static final int TYPE_COLOR = 1;
public static final int TYPE_GRADATION = 2;
-
+
+ private static final int pageSize = 5;
+
Composite parent;
private Canvas combo = null;
private Canvas popup = null;
private int itemHeight = 0;
- private DACustomButton upArrowButton = null;
- private DACustomButton downArrowButton = null;
private int tmpItemIndex = 0;
private int itemIndex = 0;
private boolean dirty = false;
private Timer closeTimer = null;
private static final int CLOSE_WAITING_TIME = 500;
-
private List<String> items;
private List<Rectangle> rects = null;
-
- private int arrowButtonHeight = 15;
- private Point comboImagePoint;
- private List<Image> comboImages = null;
- private List<Color> colors = null;
- private List<Color> outlineColors = null;
- private int drawType = DACustomCombo.TYPE_COLOR; // color, gradation, image
-
- private List<Image> images = null;
- private Image buttonUp = null;
- private Image buttonDown = null;
private boolean enabled = true;
private Shell childShell = null;
private int selection = 0;
private int tmpSelection = 0;
- private String text = DAWidgetConstants.EMPTY_STRING;
+ private Font itemFont = null;
+ private IDACustomComboPopupRenderer popupRenderer = new DACustomComboPopupRenderer();
+
+ // combo button
private int state = STATE_NORMAL; // 0 normal 1 hover 2 push 3 disable
- private DACustomComboRenderer comboRenderer = new DACustomComboDefaultRenderer();;
- private DACustomComboPopupRenderer popupRenderer = new DACustomComboPopupDefaultRenderer();
- private IDACustomButtonRenderer buttonRenderer = null;
-
+ protected DACustomButtonAttribute attr;
+ private IDACustomButtonRenderer comboRenderer = new DACustomComboRenderer();
+
+ // arrow button
+ private static final int arrowButtonHeight = 15;
+ private DACustomButton upArrowButton = null;
+ private DACustomButton downArrowButton = null;
+ private Image buttonUp = null;
+ private Image buttonDown = null;
private List<Color> arrowColors = null;
private List<Color> arrowOutlineColors = null;
private List<Image> arrowImages = null;
- private int titleAlign = TEXT_ALIGN_LEFT;
- private Font font;
- private Point fontPoint;
-
+ private IDACustomButtonRenderer buttonRenderer = null;
+
public DACustomCombo(Composite parent, int style) {
super(parent, style);
combo = this;
setForeground(ColorResources.WHITE);
addListeners();
initCombo();
+ attr = new DACustomButtonAttribute();
+ attr.setAlign(TEXT_ALIGN_LEFT);
}
protected void addListeners() {
addListener(SWT.MouseUp, comboMouseListener);
}
- public Point getFontPoint() {
- return fontPoint;
- }
-
public void setFontPoint(Point fontPoint) {
- this.fontPoint = fontPoint;
+ attr.setFontPoint(fontPoint);
}
public String getText() {
if (selection < 0) {
- return text;
+ return attr.getText();
}
if (getItems().size() > 0) {
return getItems().get(itemIndex + selection);
return max;
}
- public int getArrowButtonHeight() {
- return arrowButtonHeight;
- }
-
- public void setArrowButtonHeight(int arrowButtonHeight) {
- this.arrowButtonHeight = arrowButtonHeight;
- }
-
public int getItemHeight() {
return itemHeight;
}
}
}
});
- setSelect(text);
+ setSelect(attr.getText());
tmpSelection = selection;
tmpItemIndex = itemIndex;
for (int i = 0; i < size; i++) {
input.add(items.get(tmpItemIndex + i));
}
- popupRenderer.draw(e.gc, popup, state, getRects(), tmpSelection,
- input);
+ popupRenderer.draw(e.gc, popup, getRects(), tmpSelection,
+ input, itemFont);
}
};
+ public void setItemFont(Font itemFont) {
+ this.itemFont = itemFont;
+ }
+
public void setText(String text) {
if (!setSelect(text)) {
- this.text = text;
+ attr.setText(text);
selection = -1;
redraw();
}
}
private void setBackgroundImageAndColor(int state) {
+ int drawType = attr.getDrawType();
if (drawType == TYPE_IMAGE) {
- setBackgroundImage(images.get(state));
+ setBackgroundImage(attr.getImage(state));
} else if (drawType == TYPE_COLOR) {
- setBackground(colors.get(state));
+ setBackground(attr.getColor(state));
} else if (drawType == TYPE_GRADATION) {
int index = state * 2;
- setForeground(colors.get(index));
- setBackground(colors.get(index + 1));
+ setForeground(attr.getColor(index));
+ setBackground(attr.getColor(index + 1));
} else {
DA_LOG.debug("DACustomCombo drawType : " + state);
}
}
private PaintListener comboPaintListener = new PaintListener() {
-
@Override
- public void paintControl(PaintEvent e) {
- if (drawType == TYPE_IMAGE) {
- comboRenderer.drawImage(e.gc, combo, images.get(state), text,
- titleAlign, font, state);
- } else if (drawType == TYPE_COLOR || drawType == TYPE_GRADATION) {
- comboRenderer.draw(e.gc, combo, drawType, colors,
- outlineColors, comboImagePoint, comboImages,
- text, titleAlign, font, fontPoint, state);
- } else {
- DA_LOG.debug("DACustomCombo drawType : " + state);
- }
+ public void paintControl(PaintEvent e) {
+ comboRenderer.draw(e.gc, combo, state, attr);
}
};
public void select(int index) {
selection = index;
- this.text = items.get(itemIndex + selection);
+ String text = items.get(itemIndex + selection);
+ attr.setText(text);
this.setToolTipText(text);
redraw();
}
return DAWidgetConstants.EMPTY_STRING;
}
- private List<Color> getColors() {
- if (null == colors) {
- colors = new ArrayList<Color>();
- }
- return colors;
- }
-
public void setComboColors(Color normal, Color push, Color hover, Color disable) {
- List<Color> comboColors = getColors();
- comboColors.add(normal);
- comboColors.add(hover);
- comboColors.add(push);
- comboColors.add(disable);
- drawType = TYPE_COLOR;
+ attr.setColor(STATE_NORMAL, normal);
+ attr.setColor(STATE_HOVER, hover);
+ attr.setColor(STATE_PUSH, push);
+ attr.setColor(STATE_DISABLE, disable);
+ attr.setDrawType(TYPE_COLOR);
}
public void setComboGradation(Color normalStart, Color normalEnd,
Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd,
Color disableStart, Color disableEnd) {
- List<Color> comboColors = getColors();
- comboColors.add(normalStart);
- comboColors.add(normalEnd);
- comboColors.add(hoverStart);
- comboColors.add(hoverEnd);
- comboColors.add(pushStart);
- comboColors.add(pushEnd);
- comboColors.add(disableStart);
- comboColors.add(disableEnd);
- drawType = TYPE_GRADATION;
+ attr.setColor(0, normalStart);
+ attr.setColor(1, normalEnd);
+ attr.setColor(2, hoverStart);
+ attr.setColor(3, hoverEnd);
+ attr.setColor(4, pushStart);
+ attr.setColor(5, pushEnd);
+ attr.setColor(6, disableStart);
+ attr.setColor(7, disableEnd);
+ attr.setDrawType(TYPE_GRADATION);
}
public void setImages(Image normal, Image hover, Image push, Image disable) {
DA_LOG.debug("DACustomCombo setImages parameter is null");
return;
}
- List<Image> imgs = getImages();
-
- imgs.add(normal);
- imgs.add(hover);
- imgs.add(push);
- imgs.add(disable);
- drawType = TYPE_IMAGE;
- }
-
- private List<Image> getImages() {
- if (null == images) {
- images = new ArrayList<Image>();
- }
- return images;
+ attr.setImage(STATE_NORMAL, normal);
+ attr.setImage(STATE_HOVER, hover);
+ attr.setImage(STATE_PUSH, push);
+ attr.setImage(STATE_DISABLE, disable);
+ attr.setDrawType(TYPE_IMAGE);
}
- private List<Color> getOutlineColors() {
- if (null == outlineColors) {
- outlineColors = new ArrayList<Color>();
- }
- return outlineColors;
- }
-
public void setOutlineColors(Color normal, Color push, Color hover,
- Color disable) {
- List<Color> comboOutlineColors = getOutlineColors();
- comboOutlineColors.add(normal);
- comboOutlineColors.add(hover);
- comboOutlineColors.add(push);
- comboOutlineColors.add(disable);
- }
-
- private List<Image> getComboImages() {
- if (null == comboImages) {
- comboImages = new ArrayList<Image>();
- }
- return comboImages;
+ Color disable) {
+ attr.setOutlineColor(STATE_NORMAL, normal);
+ attr.setOutlineColor(STATE_HOVER, hover);
+ attr.setOutlineColor(STATE_PUSH, push);
+ attr.setOutlineColor(STATE_DISABLE, disable);
}
public void setComboImages(Image normal, Image push, Image hover, Image disable) {
- List<Image> imgs = getComboImages();
- imgs.add(normal);
- imgs.add(hover);
- imgs.add(push);
- imgs.add(disable);
- }
-
- public Point getComboImagePoint() {
- return comboImagePoint;
+ attr.setButtonImage(STATE_NORMAL, normal);
+ attr.setButtonImage(STATE_HOVER, hover);
+ attr.setButtonImage(STATE_PUSH, push);
+ attr.setButtonImage(STATE_DISABLE, disable);
}
public void setComboImagePoint(Point comboImagePoint) {
- this.comboImagePoint = comboImagePoint;
+ attr.setButtonImagePoint(comboImagePoint);
}
private Listener upButtonMouseListener = new Listener() {
-
@Override
public void handleEvent(Event event) {
DACustomButton upButton = (DACustomButton) event.widget;
};
private Listener downButtonMouseListener = new Listener() {
-
@Override
public void handleEvent(Event event) {
DACustomButton upButton = (DACustomButton) event.widget;
buttonDown = down;
}
- public int getItemIndex(String text) {
- return getItems().indexOf(text);
- }
-
public boolean isChildShellOpened() {
if (childShell == null || childShell.isDisposed()) {
return false;
}
public void setTextAlign(int align) {
- this.titleAlign = align;
+ attr.setAlign(align);
}
public void setComboFont(Font font) {
- this.font = font;
+ attr.setFont(font);
}
}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@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.combo;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
-
-public class DACustomComboDefaultRenderer extends DACustomComboRenderer {
-
- @Override
- public void draw(GC gc, Canvas canvas, String text, int textAlign, Font font, int state) {
- Rectangle rect = canvas.getClientArea();
- if (state == DACustomCombo.STATE_NORMAL) {
- gc.setBackground(ColorResources.WINDOW_BG_COLOR);
- } else if (state == DACustomCombo.STATE_HOVER) {
- gc.setBackground(ColorResources.ITEM_BLUE_DARK);
- } else if (state == DACustomCombo.STATE_PUSH) {
- gc.setBackground(ColorResources.BLUE);
- } else if (state == DACustomCombo.STATE_DISABLE) {
- gc.setBackground(ColorResources.BAR_GRAY1);
- }
-
- gc.fillRectangle(rect);
- gc.drawRectangle(rect.x, rect.y, rect.width - 20, rect.height - 1);
-
- if (null == text) {
- text = ""; //$NON-NLS-1$
- }
- Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
- int textX = 0;
- if (textAlign == DACustomCombo.TEXT_ALIGN_LEFT) {
- textX = 5;
- } else if (textAlign == DACustomCombo.TEXT_ALIGN_RIGHT) {
- textX = rect.width - p.x;
- } else {
- textX = (rect.width / 2) - (p.x / 2);
- }
- gc.drawString(text, textX, (rect.height - p.y) / 2, true);
- gc.fillRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
- gc.drawRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
- }
-
- @Override
- public void drawImage(GC gc, Canvas canvas, Image image, String text,
- int textAlign, Font font, int state) {
-
- }
-
- @Override
- public void draw(GC gc, Canvas canvas, int drawType, List<Color> colors,
- List<Color> outlineColors, Point comboImagePoint,
- List<Image> comboImages, String text, int textAlign, Font font,
- Point fontPoint, int state) {
-
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@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.combo;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
-
-
-public class DACustomComboPopupDefaultRenderer extends DACustomComboPopupRenderer {
-
- @Override
- public void draw(GC gc, Canvas canvas, int state, List<Rectangle> rects,
- int selection, List<String> items) {
- int size = rects.size();
- for (int i = 0; i < size; i++) {
- Rectangle r = rects.get(i);
- gc.setBackground(ColorResources.WINDOW_BG_COLOR);
- if (selection == i) {
- gc.setBackground(ColorResources.RED);
- gc.fillRectangle(r);
- gc.setBackground(ColorResources.WINDOW_BG_COLOR);
- }
- gc.setForeground(ColorResources.WHITE);
- gc.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
- Point p = gc.textExtent(items.get(i), SWT.DRAW_MNEMONIC);
- gc.drawString(items.get(i), 5, (r.height - p.y) / 2 + i * r.height,
- true);
- }
- }
-
- @Override
- public void drawPattern(GC gc, Canvas canvas, Image patternImage,
- int state, List<Rectangle> rects, int selection, List<String> items) {
-
- }
-
- @Override
- public void drawImage(GC gc, Canvas canvas, Image image, int state,
- List<Rectangle> rects, int selection, List<String> items) {
-
- }
-
-}
import java.util.List;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
+import org.tizen.dynamicanalyzer.util.DALogger;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
-public abstract class DACustomComboPopupRenderer {
- public abstract void draw(GC gc, Canvas canvas, int state,
- List<Rectangle> rects, int selection, List<String> items);
+public class DACustomComboPopupRenderer implements IDACustomComboPopupRenderer {
+ private static final DALogger DA_LOG = DALogger.getInstance();
- public abstract void drawPattern(GC gc, Canvas canvas, Image patternImage,
- int state, List<Rectangle> rects, int selection, List<String> items);
+ @Override
+ public void draw(GC gc, Canvas canvas, List<Rectangle> rects,
+ int selection, List<String> items, Font font) {
+ int size = rects.size();
+ int itemSize = items.size();
+ if (size != itemSize) {
+ DA_LOG.debug("invalid parameter in popup renderer : Rect size "
+ + size + "item size :" + itemSize);
+ return;
+ } // else normal case
- public abstract void drawImage(GC gc, Canvas canvas, Image image,
- int state, List<Rectangle> rects, int selection, List<String> items);
+ for (int i = 0; i < size; i++) {
+ Rectangle r = rects.get(i);
+ if (selection == i) {
+ gc.setBackground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_INNER);
+ gc.fillRectangle(r);
+
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_TOP);
+ gc.drawLine(r.x, r.y, r.x + r.width, r.y);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_BOTTOM);
+ gc.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y
+ + r.height - 1);
+ } else {
+ gc.setBackground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_INNER);
+ gc.fillRectangle(r);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_TOP);
+ gc.drawLine(r.x, r.y, r.x + r.width, r.y);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM);
+ gc.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y
+ + r.height - 1);
+ }
+
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_DROPDOWN_TEXT);
+
+ // set font style, size
+ if (null == font) {
+ gc.setFont(FontResources.DROPDOWN);
+ } else {
+ gc.setFont(font);
+ }
+ gc.drawString(items.get(i), 5, 6 + i * r.height, true);
+
+
+ Rectangle rect = canvas.getClientArea();
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_POPUP_OUTER_1);
+ gc.drawLine(rect.x, rect.y, rect.x, rect.height);
+ gc.drawLine(rect.width - 1, rect.y, rect.width - 1, rect.height);
+ gc.setForeground(ColorResources.DEVICE_APPLICATION_POPUP_OUTER_2);
+ gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3,
+ rect.height - 2);
+ }
+ }
}
package org.tizen.dynamicanalyzer.widgets.combo;
-import java.util.List;
-
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
+import org.tizen.dynamicanalyzer.widgets.DAWidgetConstants;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonAttribute;
+import org.tizen.dynamicanalyzer.widgets.button.IDACustomButtonRenderer;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
+import org.tizen.dynamicanalyzer.util.DALogger;
-public abstract class DACustomComboRenderer {
- public abstract void draw(GC gc, Canvas canvas, String text, int textAlign,
- Font font, int state);
+public class DACustomComboRenderer implements IDACustomButtonRenderer {
+ private static final DALogger DA_LOG = DALogger.getInstance();
+
+ public void draw(GC gc, Canvas combo, int state,
+ DACustomButtonAttribute attr) {
+
+ Rectangle rect = combo.getClientArea();
+ if (attr.getDrawType() == DACustomCombo.TYPE_IMAGE) {
+ drawImageButton(gc, rect, state, attr);
+ } else if (attr.getDrawType() == DACustomCombo.TYPE_COLOR
+ || attr.getDrawType() == DACustomCombo.TYPE_GRADATION) {
+ drawButton(gc, rect, state, attr);
+ } else {
+ DA_LOG.debug("DACustomCombo drawType : " + state);
+ }
+ }
+
+ protected void drawImageButton(GC gc, Rectangle rect, int state,
+ DACustomButtonAttribute attr) {
+ Image image = attr.getImage(state);
+ if (null == image) {
+ return;
+ }
- public abstract void drawImage(GC gc, Canvas canvas, Image image,
- String text, int textAlign, Font font, int state);
+ // draw image
+ gc.drawImage(image, rect.x, rect.y);
+
+ // draw text
+ drawButtonText(gc, rect, attr, state);
+ Rectangle clipping = new Rectangle(rect.x + rect.width - 17, rect.y, 17,
+ rect.height);
+ gc.setClipping(clipping);
+ gc.drawImage(image, rect.x, rect.y);
+ }
+
+ protected void drawButton(GC gc, Rectangle rect, int state,
+ DACustomButtonAttribute attr) {
+ // draw color
+ if (attr.getDrawType() == DACustomCombo.TYPE_COLOR) {
+ gc.setBackground(attr.getColor(state));
+ gc.fillRectangle(rect);
+ } else if (attr.getDrawType() == DACustomCombo.TYPE_GRADATION) {
+ int index = state * 2;
+ gc.setForeground(attr.getColor(index));
+ gc.setBackground(attr.getColor(index + 1));
+ gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);
+ }
+
+ // draw text
+ drawButtonText(gc, rect, attr, state);
+
+ // stroke
+ Color c = gc.getForeground();
+ Rectangle r = new Rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
+ if (null != attr.getOutlineColor(state)) {
+ gc.setForeground(attr.getOutlineColor(state));
+ } else {
+ gc.setForeground(c);
+ return;
+ }
+ gc.drawRectangle(r);
+ gc.setForeground(c);
+
+ // draw button image
+ drawButtonImage(gc, rect, attr, state);
+ }
+
+ protected void drawButtonImage(GC gc, Rectangle rect,
+ DACustomButtonAttribute attr, int state) {
+
+ Image img = attr.getButtonImage(state);
+ if (attr != null && img != null) {
+ Point p = null;
+ Rectangle imgRect = img.getBounds();
+
+ int x = 0, y = 0;
+ if (null == (p = attr.getButtonImagePoint())) {
+ int width = rect.width - imgRect.width;
+ int height = rect.height - imgRect.height;
+ if (width > 0) {
+ x = width / 2;
+ }
+
+ if (height > 0) {
+ y = height / 2;
+ }
+ } else {
+ x = p.x;
+ y = p.y;
+ }
+
+ gc.drawImage(img, x, y);
+ } // else : attr or imag is null
+ }
+
+ protected void drawButtonText(GC gc, Rectangle rect,
+ DACustomButtonAttribute attr, int state) {
+ Font font = attr.getFont();
+ Point fontPoint = attr.getFontPoint();
+ String text = attr.getText();
+ int align = attr.getAlign();
+
+ // set font style, size
+ if (null == font) {
+ gc.setFont(FontResources.COMBO);
+ } else {
+ gc.setFont(font);
+ }
- public abstract void draw(GC gc, Canvas canvas, int drawType, List<Color> colors,
- List<Color> outlineColors, Point comboImagePoint, List<Image> comboImages,
- String text, int textAlign, Font font, Point fontPoint, int state);
+ // set font color
+ if (state == DACustomButton.STATE_DISABLE) {
+ gc.setForeground(ColorResources.COMBO_DISABLE_FONT);
+ } else {
+ gc.setForeground(ColorResources.COMBO_ENABLE_FONT);
+ }
+
+ if (text == null) {
+ text = DAWidgetConstants.EMPTY_STRING;
+ } // else case text is not null
+
+ // text position
+ if (fontPoint == null) {
+ Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
+ int textX = 0;
+ if (align == DACustomCombo.TEXT_ALIGN_LEFT) {
+ textX = 5;
+ } else if (align == DACustomCombo.TEXT_ALIGN_RIGHT) {
+ textX = rect.width - p.x;
+ } else { // DACustomCombo.TEXT_ALIGN_CENTER
+ textX = (rect.width / 2) - (p.x / 2);
+ }
+ gc.drawString(text, textX, (rect.height - p.y) / 2, true);
+ } else {
+ gc.drawString(text, fontPoint.x, fontPoint.y, true);
+ }
+ }
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2014 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.combo;
+
+import java.util.List;
+
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+public interface IDACustomComboPopupRenderer {
+ public void draw(GC gc, Canvas canvas,
+ List<Rectangle> rects, int selection, List<String> items, Font font);
+}
public static Color CHART_SERIES_CHOCOLATE = getColor(\r
"chart_series_chocolate", new RGB(151, 124, 39)); //$NON-NLS-1$\r
\r
+ /** combo **/\r
+ public static Color COMBO_ENABLE_FONT = getColor("combo_enable_font", new RGB(0, 0, 0)); //$NON-NLS-1$\r
+ public static Color COMBO_DISABLE_FONT = getColor("combo_disable_font", new RGB(119, 223, 238)); //$NON-NLS-1$\r
+\r
+ /** device and application combo specific colors start **/\r
+ public static Color DEVICE_APPLICATION_ENABLE = getColor("device_application_enable_font", new RGB(0, 0, 0)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_DISABLE = getColor("device_application_disable_font", new RGB(119, 223, 238)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_POPUP_OUTER_1 = getColor("device_application_popup_outer_1", new RGB(45, 180, 200)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_POPUP_OUTER_2 = getColor("device_application_popup_outer_2", new RGB(47, 85, 92)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_DROPDOWN_TEXT = getColor("device_application_enable_font", new RGB(0, 0, 0)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_ITEM_NORMAL_TOP = getColor("device_application_item_normal_top", new RGB(255, 255, 255)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_ITEM_NORMAL_INNER = getColor("device_application_item_normal_inner", new RGB(232, 234, 235)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM = getColor("device_application_item_normal_bottom", new RGB(180, 180, 180)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_ITEM_SELECT_TOP = getColor(\r
+ "device_application_item_select_top", new RGB(255, 255, 255)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_ITEM_SELECT_INNER = getColor("device_application_item_select_inner", new RGB(45, 180, 200)); //$NON-NLS-1$\r
+ public static Color DEVICE_APPLICATION_ITEM_SELECT_BOTTOM = getColor("device_application_item_select_bottom", new RGB(180, 180, 180)); //$NON-NLS-1$\r
+ \r
//Button\r
public static Color BUTTON_STATE_DISABLE = getColor(\r
"button_state_disable", new RGB(48, 48, 48)); //$NON-NLS-1$\r
"titlebar", resizeSystemFont(10));//$NON-NLS-1$\r
\r
/** device and application combo specific fonts **/\r
- public static final Font COMBO = getFont("combo", resizeSystemFont(10));//$NON-NLS-1$\r
+ public static final Font COMBO = getFont("combo", resizeSystemFont(9));//$NON-NLS-1$\r
\r
public static final Font DROPDOWN = getFont(\r
- "dropdown", resizeSystemFont(10));//$NON-NLS-1$\r
+ "dropdown", resizeSystemFont(9));//$NON-NLS-1$\r
\r
/** table specific fonts **/\r
public static final Font TABLE_HEADER = getFont(\r
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboPopupRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboRenderer;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
callflowCombo.setTextAlign(DACustomCombo.TEXT_ALIGN_LEFT);
callflowCombo.select(0);
callflowCombo.setEnabled(false);
- callflowCombo.setComboRender(new TitleComboRenderer());
- callflowCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ callflowCombo.setComboFont(FontResources.COMBO);
+ callflowCombo.setItemFont(FontResources.DROPDOWN);
callflowCombo.setButtonRenderer(new DACustomButtonRenderer());
DATimeline timeline = callflowChart.getTimeline();
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboPopupRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboRenderer;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
contextCombo.select(0);
contextCombo.setTextAlign(DACustomCombo.TEXT_ALIGN_LEFT);
contextCombo.setEnabled(false);
- contextCombo.setComboRender(new TitleComboRenderer());
- contextCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ contextCombo.setComboFont(FontResources.COMBO);
+ contextCombo.setItemFont(FontResources.DROPDOWN);
contextCombo.setButtonRenderer(new DACustomButtonRenderer());
DATimeline threadTimeline = contextChart.getTimeline();
import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboPopupRenderer;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
frameTimeCombo.setEnabled(true);
frameTimeCombo.setItemHeight(COMBO_HEIGHT);
frameTimeCombo.setComboRender(new GLTitleComboRenderer());
- frameTimeCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ frameTimeCombo.setComboFont(FontResources.COMBO);
+ frameTimeCombo.setItemFont(FontResources.DROPDOWN);
frameTimeCombo.setButtonRenderer(new DACustomButtonRenderer());
frameTimeCombo
.addSelectionListener(new DACustomComboSelectionListener() {
frameRateCombo.setEnabled(true);
frameRateCombo.setItemHeight(COMBO_HEIGHT);
frameRateCombo.setComboRender(new GLTitleComboRenderer());
- frameRateCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ frameRateCombo.setComboFont(FontResources.COMBO);
+ frameRateCombo.setItemFont(FontResources.DROPDOWN);
frameRateCombo.setButtonRenderer(new DACustomButtonRenderer());
frameRateCombo
.addSelectionListener(new DACustomComboSelectionListener() {
package org.tizen.dynamicanalyzer.ui.opengl.chart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboRenderer;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonAttribute;
+import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboRenderer;
-public class GLTitleComboRenderer extends TitleComboRenderer {
+public class GLTitleComboRenderer extends DACustomComboRenderer {
+
@Override
- public void drawImage(GC gc, Canvas canvas, Image image, String text,
- int textAlign, Font font, int state) {
- Rectangle rect = canvas.getClientArea();
- gc.drawImage(image, rect.x, rect.y);
- if (null == font) {
- gc.setFont(FontResources.COMBO);
- } else {
- gc.setFont(font);
- }
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ENABLE);
- Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
- int textX = 0;
- if (textAlign == DACustomCombo.TEXT_ALIGN_LEFT) {
- textX = 5;
- } else if (textAlign == DACustomCombo.TEXT_ALIGN_RIGHT) {
- textX = rect.width - p.x;
- } else {
- textX = (rect.width / 2) - (p.x / 2);
+ protected void drawImageButton(GC gc, Rectangle rect, int state,
+ DACustomButtonAttribute attr) {
+ Image image = attr.getImage(state);
+ if (null == image) {
+ return;
}
- gc.drawString(text, textX, (rect.height - p.y) / 2, true);
+
+ // draw image
+ gc.drawImage(image, rect.x, rect.y);
+
+ // draw text
+ drawButtonText(gc, rect, attr, state);
Rectangle clipping = new Rectangle(rect.x + rect.width - 17, rect.y, 0,
rect.height);
gc.setClipping(clipping);
gc.drawImage(image, rect.x, rect.y);
}
+
}
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboPopupRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboRenderer;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
ImageResources.COMBO_DROPDOWN_DOWN);
threadCombo.setEnabled(true);
threadCombo.setItemHeight(THREAD_COMBO_ITEM_HEIGHT);
- threadCombo.setComboRender(new TitleComboRenderer());
- threadCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ threadCombo.setComboFont(FontResources.COMBO);
+ threadCombo.setItemFont(FontResources.DROPDOWN);
threadCombo.setButtonRenderer(new DACustomButtonRenderer());
threadCombo.addSelectionListener(new DACustomComboSelectionListener() {
ImageResources.COMBO_DROPDOWN_DOWN);
syncCombo.setEnabled(true);
syncCombo.setItemHeight(THREAD_COMBO_ITEM_HEIGHT);
- syncCombo.setComboRender(new TitleComboRenderer());
- syncCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ syncCombo.setComboFont(FontResources.COMBO);
+ syncCombo.setItemFont(FontResources.DROPDOWN);
syncCombo.setButtonRenderer(new DACustomButtonRenderer());
syncCombo.addSelectionListener(new DACustomComboSelectionListener() {
import org.tizen.dynamicanalyzer.ui.toolbar.configuration.ConfigurationDialog;
import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceDialog;
import org.tizen.dynamicanalyzer.ui.toolbar.replayEditor.ReplayEditDialog;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboPopupRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.TitleComboRenderer;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.util.DALogger;
ImageResources.COMBO_DROPDOWN_DOWN);
deviceCombo.setEnabled(true);
deviceCombo.setItemHeight(DesignConstants.COMBO_DEVICE_HEIGHT);
- deviceCombo.setComboRender(new TitleComboRenderer());
- deviceCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ deviceCombo.setComboFont(FontResources.COMBO);
+ deviceCombo.setItemFont(FontResources.DROPDOWN);
deviceCombo.setButtonRenderer(new DACustomButtonRenderer());
Label bracketLabel = new Label(parent, SWT.CENTER | SWT.TRANSPARENT);
ImageResources.COMBO_DROPDOWN_DOWN);
appCombo.setEnabled(false);
appCombo.setItemHeight(DesignConstants.COMBO_APP_HEIGHT);
- appCombo.setComboRender(new TitleComboRenderer());
- appCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ appCombo.setComboFont(FontResources.COMBO);
+ appCombo.setItemFont(FontResources.DROPDOWN);
appCombo.setButtonRenderer(new DACustomButtonRenderer());
// Sets layout data.
processCombo.setButtonImages(ImageResources.COMBO_DROPDOWN_UP,
ImageResources.COMBO_DROPDOWN_DOWN);
processCombo.setItemHeight(DesignConstants.COMBO_APP_HEIGHT);
- processCombo.setComboRender(new TitleComboRenderer());
- processCombo.setComboPopupRender(new TitleComboPopupRenderer());
+ processCombo.setComboFont(FontResources.COMBO);
+ processCombo.setItemFont(FontResources.DROPDOWN);
processCombo.setButtonRenderer(new DACustomButtonRenderer());
data = new FormData();
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@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.ui.widgets;
-
-import java.util.List;
-
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.util.DALogger;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboPopupRenderer;
-
-public class TitleComboPopupRenderer extends DACustomComboPopupRenderer {
- private static final DALogger DA_LOG = DALogger.getInstance();
-
- @Override
- public void draw(GC gc, Canvas canvas, int state, List<Rectangle> rects,
- int selection, List<String> items) {
- int size = rects.size();
- int itemSize = items.size();
- if (size != itemSize) {
- DA_LOG.debug("invalid parameter in popup renderer : Rect size "
- + size + "item size :" + itemSize);
- return;
- }
-
- for (int i = 0; i < size; i++) {
- Rectangle r = rects.get(i);
- if (selection == i) {
- gc.setBackground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_INNER);
- gc.fillRectangle(r);
-
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_TOP);
- gc.drawLine(r.x, r.y, r.x + r.width, r.y);
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_SELECT_BOTTOM);
- gc.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y
- + r.height - 1);
- } else {
- gc.setBackground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_INNER);
- gc.fillRectangle(r);
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_TOP);
- gc.drawLine(r.x, r.y, r.x + r.width, r.y);
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ITEM_NORMAL_BOTTOM);
- gc.drawLine(r.x, r.y + r.height - 1, r.x + r.width, r.y
- + r.height - 1);
- }
-
- gc.setForeground(ColorResources.DEVICE_APPLICATION_DROPDOWN_TEXT);
- gc.setFont(FontResources.DROPDOWN);
- gc.drawString(items.get(i), 5, 6 + i * r.height, true);
-
-
- Rectangle rect = canvas.getClientArea();
- gc.setForeground(ColorResources.DEVICE_APPLICATION_POPUP_OUTER_1);
- gc.drawLine(rect.x, rect.y, rect.x, rect.height);
- gc.drawLine(rect.width - 1, rect.y, rect.width - 1, rect.height);
- gc.setForeground(ColorResources.DEVICE_APPLICATION_POPUP_OUTER_2);
- gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3,
- rect.height - 2);
- }
- }
-
- @Override
- public void drawPattern(GC gc, Canvas canvas, Image patternImage,
- int state, List<Rectangle> rects, int selection, List<String> items) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void drawImage(GC gc, Canvas canvas, Image image, int state,
- List<Rectangle> rects, int selection, List<String> items) {
- // TODO Auto-generated method stub
-
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@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.ui.widgets;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboRenderer;
-
-public class TitleComboRenderer extends DACustomComboRenderer {
-
- @Override
- public void draw(GC gc, Canvas canvas, String text, int textAlign,
- Font font, int state) {
- Rectangle rect = canvas.getClientArea();
- setColors(state, gc);
- gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);
- gc.setForeground(ColorResources.BLACK);
- gc.drawRectangle(rect.x, rect.y, rect.width - 20, rect.height - 1);
-
- if (null == text) {
- text = CommonConstants.EMPTY;
- }
- if (null == font) {
- gc.setFont(FontResources.COMBO);
- } else {
- gc.setFont(font);
- }
-
- Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ENABLE);
- int textX = 0;
- if (textAlign == DACustomCombo.TEXT_ALIGN_LEFT) {
- textX = 5;
- } else if (textAlign == DACustomCombo.TEXT_ALIGN_RIGHT) {
- textX = rect.width - p.x;
- } else {
- textX = (rect.width / 2) - (p.x / 2);
- }
- gc.drawString(text, textX, (rect.height - p.y) / 2, true);
- setColors(state, gc);
- gc.fillGradientRectangle(rect.x + rect.width - 20, rect.y, 19,
- rect.height - 1, true);
- gc.setForeground(ColorResources.BLACK);
- gc.drawRectangle(rect.x + rect.width - 20, rect.y, 19, rect.height - 1);
- }
-
- @Override
- public void drawImage(GC gc, Canvas canvas, Image image, String text,
- int textAlign, Font font, int state) {
- Rectangle rect = canvas.getClientArea();
- gc.drawImage(image, rect.x, rect.y);
- if (null == font) {
- gc.setFont(FontResources.COMBO);
- } else {
- gc.setFont(font);
- }
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ENABLE);
- Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
- int textX = 0;
- if (textAlign == DACustomCombo.TEXT_ALIGN_LEFT) {
- textX = 5;
- } else if (textAlign == DACustomCombo.TEXT_ALIGN_RIGHT) {
- textX = rect.width - p.x;
- } else {
- textX = (rect.width / 2) - (p.x / 2);
- }
- gc.drawString(text, textX, (rect.height - p.y) / 2, true);
- Rectangle clipping = new Rectangle(rect.x + rect.width - 17, rect.y, 17,
- rect.height);
- gc.setClipping(clipping);
- gc.drawImage(image, rect.x, rect.y);
- }
-
- private void setColors(int state, GC gc) {
- if (state == DACustomCombo.STATE_NORMAL) {
- gc.setForeground(ColorResources.BAR_GRAY2);
- gc.setBackground(ColorResources.WINDOW_BG_COLOR);
- } else if (state == DACustomCombo.STATE_HOVER) {
- gc.setForeground(ColorResources.BAR_GRAY2);
- gc.setBackground(ColorResources.ITEM_BLUE_DARK);
- } else if (state == DACustomCombo.STATE_PUSH) {
- gc.setForeground(ColorResources.BAR_GRAY2);
- gc.setBackground(ColorResources.BLUE);
- } else if (state == DACustomCombo.STATE_DISABLE) {
- gc.setForeground(ColorResources.BAR_GRAY2);
- gc.setBackground(ColorResources.BAR_GRAY1);
- }
- }
-
- @Override
- public void draw(GC gc, Canvas canvas, int drawType, List<Color> colors,
- List<Color> outlineColors, Point comboImagePoint,
- List<Image> comboImages, String text, int textAlign, Font font,
- Point fontPoint, int state) {
- Rectangle rect = canvas.getClientArea();
- if (drawType == DACustomCombo.TYPE_COLOR) {
- gc.setBackground(colors.get(state));
- gc.fillRectangle(rect);
- } else if (drawType == DACustomCombo.TYPE_GRADATION) {
- int index = state * 2;
- gc.setForeground(colors.get(index));
- gc.setBackground(colors.get(index + 1));
- gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);
- }
-
- // text and font(size, style)
- if (null == text) {
- text = CommonConstants.EMPTY;
- }
- if (null == font) {
- gc.setFont(FontResources.COMBO);
- } else {
- gc.setFont(font);
- }
-
- // font color
- if (state == DACustomButton.STATE_DISABLE) {
- gc.setForeground(ColorResources.DEVICE_APPLICATION_DISABLE);
- } else {
- gc.setForeground(ColorResources.DEVICE_APPLICATION_ENABLE);
- }
-
- // text position
- if (fontPoint == null) {
- Point p = gc.textExtent(text, SWT.DRAW_MNEMONIC);
- int textX = 0;
- if (textAlign == DACustomCombo.TEXT_ALIGN_LEFT) {
- textX = 5;
- } else if (textAlign == DACustomCombo.TEXT_ALIGN_RIGHT) {
- textX = rect.width - p.x;
- } else { // DACustomCombo.TEXT_ALIGN_CENTER
- textX = (rect.width / 2) - (p.x / 2);
- }
- gc.drawString(text, textX, (rect.height - p.y) / 2, true);
- } else {
- gc.drawString(text, fontPoint.x, fontPoint.y, true);
- }
-
- // stroke
- Color c = gc.getForeground();
- Rectangle r = new Rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
- if (null != outlineColors.get(state)) {
- gc.setForeground(outlineColors.get(state));
- } else {
- gc.setForeground(c);
- return;
- }
- gc.drawRectangle(r);
- gc.setForeground(c);
-
- // draw button image
- drawComboImage(gc, rect, state, comboImagePoint, comboImages);
-
- }
-
- protected void drawComboImage(GC gc, Rectangle rect,
- int state, Point comboImagePoint, List<Image> comboImages) {
- Image img = comboImages.get(state);
- Rectangle imgRect = null;
-
- if (null != img) {
- imgRect = img.getBounds();
- int x = 0, y = 0;
- if (null == comboImagePoint) {
- int width = rect.width - imgRect.width;
- int height = rect.height - imgRect.height;
- if (width > 0) {
- x = width / 2;
- }
-
- if (height > 0) {
- y = height / 2;
- }
- } else {
- x = comboImagePoint.x;
- y = comboImagePoint.y;
- }
- gc.drawImage(img, x, y);
- }
-
- }
-
-}