From 686a8c381e4ac6930e1c4afe61e76acf823530d6 Mon Sep 17 00:00:00 2001 From: "hyeran74.kim" Date: Tue, 13 Oct 2015 16:22:18 +0900 Subject: [PATCH] DAText: added some functions about inserting a icon image in text field Change-Id: I00152037489e1925be75aa8f01efd958fb2d59ba Signed-off-by: hyeran74.kim --- .../dynamicanalyzer/widgets/da/base/DAText.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/widgets/da/base/DAText.java b/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/widgets/da/base/DAText.java index dfb639d..fd41a5f 100644 --- a/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/widgets/da/base/DAText.java +++ b/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/widgets/da/base/DAText.java @@ -25,6 +25,7 @@ package org.tizen.dynamicanalyzer.widgets.da.base; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; @@ -32,6 +33,7 @@ import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.widgets.Composite; @@ -51,6 +53,10 @@ public class DAText { public boolean textTooltip = false; public String textTooltipMessage = null; + + private Image iconImage = null; + private int iconImage_x = 0; + private int iconImage_y = 0; public Listener textMouseListener = new Listener() { @Override @@ -79,9 +85,7 @@ public class DAText { public DAText(Composite parent, int style) { text = new Text(parent, style); - currentColor = ColorResources.TEXT_NORMAL_COLOR; - text.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { @@ -90,6 +94,10 @@ public class DAText { Rectangle rect = text.getClientArea(); e.gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1); + if(iconImage != null) { + // draw a image in text box + e.gc.drawImage(iconImage, rect.x+iconImage_x, rect.y+iconImage_y); + } } }); @@ -209,4 +217,19 @@ public class DAText { public void setFont(Font font) { this.text.setFont(font); } + + public void setIconImage(Image image){ + this.iconImage = image; + } + + public void setIconImage(Image image, int x, int y){ + this.iconImage = image; + this.iconImage_x = x; + this.iconImage_y = y; + } + + public void deleteIconImage() { + this.iconImage = null; + } + } -- 2.7.4