Widget : combo widget refactoring 73/23073/1
authorheeyoung <heeyoung1008.hwang@samsung.com>
Tue, 17 Jun 2014 07:46:17 +0000 (16:46 +0900)
committerheeyoung <heeyoung1008.hwang@samsung.com>
Tue, 17 Jun 2014 07:46:17 +0000 (16:46 +0900)
Clean class inheritance
Remove file
- DACustomComboDefaultRenderer
- TitleComboRenderer
- DACustomComboPopupDefaultRenderer
- TitleComboPopupRenderer

Change-Id: I1c884cc6aef045f4c359f00e70b48ecce5a6cbe6
Signed-off-by: heeyoung <heeyoung1008.hwang@samsung.com>
16 files changed:
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomCombo.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboDefaultRenderer.java [deleted file]
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboPopupDefaultRenderer.java [deleted file]
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboPopupRenderer.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboRenderer.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/IDACustomComboPopupRenderer.java [new file with mode: 0644]
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/helper/ColorResources.java
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/helper/FontResources.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/CallFlowChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/ContextSwitchingChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/chart/GLChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/chart/GLTitleComboRenderer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/ThreadChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/TitleComboPopupRenderer.java [deleted file]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/TitleComboRenderer.java [deleted file]

index 87d0121..cb72899 100644 (file)
@@ -55,6 +55,7 @@ import org.eclipse.swt.widgets.Shell;
 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;
 
@@ -67,58 +68,50 @@ public class DACustomCombo extends Canvas {
        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;
@@ -128,6 +121,8 @@ public class DACustomCombo extends Canvas {
                setForeground(ColorResources.WHITE);
                addListeners();
                initCombo();
+               attr = new DACustomButtonAttribute();
+               attr.setAlign(TEXT_ALIGN_LEFT);
        }
 
        protected void addListeners() {
@@ -139,17 +134,13 @@ public class DACustomCombo extends Canvas {
                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);
@@ -271,14 +262,6 @@ public class DACustomCombo extends Canvas {
                return max;
        }
 
-       public int getArrowButtonHeight() {
-               return arrowButtonHeight;
-       }
-
-       public void setArrowButtonHeight(int arrowButtonHeight) {
-               this.arrowButtonHeight = arrowButtonHeight;
-       }
-
        public int getItemHeight() {
                return itemHeight;
        }
@@ -320,7 +303,7 @@ public class DACustomCombo extends Canvas {
                                }
                        }
                });
-               setSelect(text);
+               setSelect(attr.getText());
 
                tmpSelection = selection;
                tmpItemIndex = itemIndex;
@@ -428,14 +411,18 @@ public class DACustomCombo extends Canvas {
                        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();
                }
@@ -581,33 +568,24 @@ public class DACustomCombo extends Canvas {
        }
 
        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);
                }
        };
 
@@ -630,7 +608,8 @@ public class DACustomCombo extends Canvas {
 
        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();
        }
@@ -642,35 +621,26 @@ public class DACustomCombo extends Canvas {
                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) {
@@ -678,63 +648,33 @@ public class DACustomCombo extends Canvas {
                        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;
@@ -791,7 +731,6 @@ public class DACustomCombo extends Canvas {
        };
 
        private Listener downButtonMouseListener = new Listener() {
-
                @Override
                public void handleEvent(Event event) {
                        DACustomButton upButton = (DACustomButton) event.widget;
@@ -962,10 +901,6 @@ public class DACustomCombo extends Canvas {
                buttonDown = down;
        }
 
-       public int getItemIndex(String text) {
-               return getItems().indexOf(text);
-       }
-
        public boolean isChildShellOpened() {
                if (childShell == null || childShell.isDisposed()) {
                        return false;
@@ -996,10 +931,10 @@ public class DACustomCombo extends Canvas {
        }
 
        public void setTextAlign(int align) {
-               this.titleAlign = align;
+               attr.setAlign(align);
        }
 
        public void setComboFont(Font font) {
-               this.font = font;
+               attr.setFont(font);
        }
 }
diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboDefaultRenderer.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboDefaultRenderer.java
deleted file mode 100644 (file)
index f4845ec..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *  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) {
-
-       }
-
-}
diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboPopupDefaultRenderer.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboPopupDefaultRenderer.java
deleted file mode 100644 (file)
index 9bc8bc8..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  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) {
-
-       }
-
-}
index ab613a2..373bcb4 100644 (file)
@@ -29,18 +29,67 @@ 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.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);
+               }
+       }
 }
index cf7cc23..5393f63 100644 (file)
 
 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);    
+               }
+       }
 }
diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/IDACustomComboPopupRenderer.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/IDACustomComboPopupRenderer.java
new file mode 100644 (file)
index 0000000..c2da49f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  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);
+}
index 20c960d..9905b65 100644 (file)
@@ -176,6 +176,24 @@ public class ColorResources {
        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
index dd19a04..b5f08a1 100644 (file)
@@ -45,10 +45,10 @@ public class FontResources {
                        "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
index 73ef4fc..69ad563 100644 (file)
@@ -44,8 +44,6 @@ 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.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;
@@ -112,8 +110,8 @@ public class CallFlowChartView extends DAViewComposite {
                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();
index 95daa81..3e70b4d 100755 (executable)
@@ -43,8 +43,6 @@ 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.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;
@@ -102,8 +100,8 @@ public class ContextSwitchingChartView extends DAViewComposite {
                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();
index f877f27..442895b 100644 (file)
@@ -46,7 +46,6 @@ import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData;
 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;
@@ -138,7 +137,8 @@ public class GLChartView extends DAViewComposite {
                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() {
@@ -190,7 +190,8 @@ public class GLChartView extends DAViewComposite {
                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() {
index 1d1d629..625049d 100644 (file)
 
 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);
        }
+       
 }
index 2554d6e..05285da 100644 (file)
@@ -43,8 +43,6 @@ 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.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;
@@ -132,8 +130,8 @@ public class ThreadChartView extends DAViewComposite {
                                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() {
 
@@ -174,8 +172,8 @@ public class ThreadChartView extends DAViewComposite {
                                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() {
 
index 52fb3ff..7f41c0b 100755 (executable)
@@ -62,8 +62,6 @@ import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
 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;
@@ -702,8 +700,8 @@ public class ToolbarArea {
                                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);
@@ -727,8 +725,8 @@ public class ToolbarArea {
                                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.
@@ -770,8 +768,8 @@ public class ToolbarArea {
                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();
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/TitleComboPopupRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/TitleComboPopupRenderer.java
deleted file mode 100644 (file)
index 546e3fe..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- *  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
-
-       }
-
-}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/TitleComboRenderer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/TitleComboRenderer.java
deleted file mode 100644 (file)
index 762882d..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- *  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);
-               }
-               
-       }
-
-}