aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvrubezhny2014-01-20 13:22:28 (EST)
committerGerrit Code Review @ Eclipse.org2014-02-12 02:07:05 (EST)
commitb2170202dd439d59048cdf10292188058b2ca5b9 (patch)
tree1756861745b9d4a6bee31ae26cc4172e8aa8ffe2
parenta1109c53561ca0f87bb6fbb474a2c02b0f47af03 (diff)
downloadeclipse.platform.swt-b2170202dd439d59048cdf10292188058b2ca5b9.zip
eclipse.platform.swt-b2170202dd439d59048cdf10292188058b2ca5b9.tar.gz
eclipse.platform.swt-b2170202dd439d59048cdf10292188058b2ca5b9.tar.bz2
Bug 314815 - Checkbox with null text will display a empty rectanglerefs/changes/65/19165/8
SWT/GTK org.eclipse.swt.widgets.Button class is changed to control the visibility of box, label and image widgets due ton hide all the three widgets in case of empty label and image at the same time. Change-Id: I1bf88db2a5a549983bc7eff9fffdbf2b3320eb97 Signed-off-by: vrubezhny <vrubezhny@exadel.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java32
1 files changed, 23 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 45a8c33..ed4dc16 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -900,13 +900,10 @@ public void setImage (Image image) {
int imageIndex = imageList.add (image);
long /*int*/ pixbuf = imageList.getPixbuf (imageIndex);
gtk_image_set_from_pixbuf(imageHandle, pixbuf);
- if (text.length () == 0) OS.gtk_widget_hide (labelHandle);
- OS.gtk_widget_show (imageHandle);
} else {
gtk_image_set_from_pixbuf (imageHandle, 0);
- OS.gtk_widget_show (labelHandle);
- OS.gtk_widget_hide (imageHandle);
}
+ updateWidgetsVisibility();
this.image = image;
_setAlignment (style);
}
@@ -1000,16 +997,33 @@ public void setText (String string) {
char [] chars = fixMnemonic (string);
byte [] buffer = Converter.wcsToMbcs (null, chars, true);
OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
- if (image == null) OS.gtk_widget_hide (imageHandle);
- OS.gtk_widget_show (labelHandle);
+ updateWidgetsVisibility();
_setAlignment (style);
}
+private void updateWidgetsVisibility() {
+ if (text.length() == 0 && image == null) {
+ OS.gtk_widget_hide (boxHandle);
+ OS.gtk_widget_hide (labelHandle);
+ OS.gtk_widget_hide (imageHandle);
+ } else {
+ OS.gtk_widget_show (boxHandle);
+ if (text.length() == 0)
+ OS.gtk_widget_hide (labelHandle);
+ else
+ OS.gtk_widget_show (labelHandle);
+ if (image == null)
+ OS.gtk_widget_hide (imageHandle);
+ else
+ OS.gtk_widget_show (imageHandle);
+ }
+}
+
@Override
void showWidget () {
super.showWidget ();
- if (boxHandle != 0) OS.gtk_widget_show (boxHandle);
- if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
+ if (boxHandle != 0 && ((text != null && text.length() != 0) || image != null)) OS.gtk_widget_show (boxHandle);
+ if (labelHandle != 0 && text != null && text.length() != 0) OS.gtk_widget_show (labelHandle);
if (arrowHandle != 0) OS.gtk_widget_show (arrowHandle);
}