Community
Participate
Working Groups
DLW (6/20/2001 4:36:38 PM) Native label widgets often show a grayed out appearance when disabled. I think this would be a very useful feature to have in CLabel. NOTES: DLW (6/20/2001 4:37:25 PM) I have added this functionality to CLabel in my workspace. You might want to change it to add an API to set the disabled background and foreground colors, but for now, I just use the native colors. In the method onPaint(), I have made the following change to the section where the text is drawn to the GC: // draw the text if (t != null) { int textHeight = gc.getFontMetrics().getHeight(); Display disp = getDisplay(); if (isEnabled()) { gc.setForeground(getForeground()); } else { // draw the text as "grayed out" gc.setForeground(disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); gc.drawText(t, x + 1, rect.y + 1 + (rect.height-textHeight)/2, true); gc.setForeground(disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } gc.drawText(t, x, rect.y + (rect.height-textHeight)/2, true); } In addition, I added the following method so that the text is repainted when the enablement is changed: /* * Set the label's enablement to <code>enabled</code>. * Redraw the widget so the text gets redrawn to reflect the new value. */ public void setEnabled(boolean enabled) { if (enabled != isEnabled()) { super.setEnabled(enabled); redraw(); } } SN (6/20/01 5:06:12 PM) This "(enabled != isEnabled())" is wrong. It should be "(enabled != getEnabled())" or don't even do the test, just redraw. The "draw disabled" code is also Windows specific ... but given that we don't have any API to support drawing text disabled, there's not much we can do right now (this API exists for Images). DLW (6/21/2001 3:30:50 pm) How is it Windows specific? Those constants not available on other SWT flavors. Or are you saying it b/c other platforms don't "gray out" their labels when disabled? Or that they don't have an "etched" appearance? McQ (26/06/2001 9:13:35 AM) - VI just mentioned that you are using this to do the AWT label. You need to watch out when using the "custom" widgets in the AWT implementation. The Eclipse team gets to decide what the L&F of the custom widgets is. This could cause you grief if they decide to change it radically. DLW (6/27/2001 4:56:16 pm) It would be helpful if the comment for getEnabled() vs. isEnabled() explained the difference between the two, and when you would use one vs. the other. Currently they have an identical comment.
PRODUCT VERSION: Build 112
The comment for isEnable and getEnabled has been fixed. On some platforms, a disabled label draws the text stippled. On others, it changes the text color to gray. Other widgets, like the Windows single line text control, change the background to gray. Assigning to VI. She can decide what to do. My vote, nothing.
Waiting for 22782 to be fixed.
This should be considered a bug, not just an enhansement request. I resorted to using CLabel instead of Label so that I could have Border support, but now setEnabled(false) no longer grays it out! Thus, the behaviour differs from "Label", and, therefore, is not a compatible replacement.
Since drawing disabled is controlled by the theme manager, we shouldn't add a disabled color or change the background. The theme manager decides what to do.
*** Bug 371524 has been marked as a duplicate of this bug. ***
Wow, a more than 10 year old RFE!
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. If the bug is still relevant, please remove the "stalebug" whiteboard tag.