Good point, let me rephrase my question: how
can I force the button to the exactly same size as the image and no borders
etc? I want to have a pretty image button, not a button that has image in the
middle J
-----Original Message-----
From: Steve Northover
[mailto:Steve_Northover@xxxxxxxxxx]
Sent: Tuesday, September 30, 2003
12:09 PM
To: platform-swt-dev@xxxxxxxxxxx
Cc:
'platform-swt-dev@xxxxxxxxxxx'; platform-swt-dev-admin@xxxxxxxxxxx
Subject: RE: [platform-swt-dev]
Button image missing when Button.setEnable d(false)
What happens when you make the button too small? Anyways
the platform draws the image, not SWT.
|
"GU,JAMES
(HP-Corvallis,ex1)" <james.gu@xxxxxx>
Sent
by: platform-swt-dev-admin@xxxxxxxxxxx
09/30/2003 03:03 PM
Please
respond to platform-swt-dev
|
To: "'platform-swt-dev@xxxxxxxxxxx'"
<platform-swt-dev@xxxxxxxxxxx>
cc: platform-swt-dev-admin@xxxxxxxxxxx
Subject: RE:
[platform-swt-dev] Button image missing when Button.setEnable
d(false)
|
Is there a way to force the image will take all
the space of a button - no border, no excess background space etc?
James
-----Original
Message-----
From: Steve Northover [mailto:Steve_Northover@xxxxxxxxxx]
Sent: Tuesday, September 30, 2003 11:44 AM
To: platform-swt-dev@xxxxxxxxxxx
Cc: platform-swt-dev@xxxxxxxxxxx; platform-swt-dev-admin@xxxxxxxxxxx
Subject: Re: [platform-swt-dev] Button image missing when
Button.setEnabled(false)
Sounds like a feature in Windows. Please enter a problem report with the
code and the image. The algorithm Windows uses to compute a grayed image
sometimes creates a grayed square depending on the image.
|
Randy Hudson
<hudsonr@xxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
09/30/2003 02:34 PM
Please respond to platform-swt-dev
|
To: platform-swt-dev@xxxxxxxxxxx
cc:
Subject: Re:
[platform-swt-dev] Button image missing when Button.setEnabled(false)
|
This could be the bug in SWT where you need to create the Image by first
loading an ImageData, and then create the Image using both the imagedata, and
its transparency mask. The symptoms of this bug are that transparency is
not displayed properly in Buttons, Toolitems, and some other places only on
Win32.
JFace demonstrates the workaround in ImageDescriptor:
ImageData maskData = data.getTransparencyMask();
return new Image(device,
data, maskData);
This type of question should be asked on the newsgroup.
-Randy
|
JR Ruggentaler
<jr@xxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
09/30/2003 09:47 AM
Please respond to platform-swt-dev
|
To: "'platform-swt-dev@xxxxxxxxxxx'"
<platform-swt-dev@xxxxxxxxxxx>
cc:
Subject: [platform-swt-dev]
Button image missing when Button.setEnabled(false)
|
My Button image disappears when I call Button.setEnabled(false). I created
two images one for when my Button is enabled and one for when it's disabled
the enabled image and Button work fine but when the button is disabled all I
see is a dark gray square in the center of the Button. I have tried setting
the disabled image before and after the call to Button.setEnabled(false) but
the behavior is unchanged. I looked to see if there is a bug report but
could not fine one. Does anyone know if this is a SWT Windows only bug or is
it the same on all platforms? I am using swt-win32-2135.dll in Windows 2000.
Below is a code snippet to reproduce this problem. Note you must supply the
two images (images/Open24.gif, images/OpenDisabled24.gif) because I did not
know if attachments are accepted by the mailing list.
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.graphics.*;
import java.io.InputStream;
public class ButtonExample
{
private Button disableButton;
private Button imageButton;
private Display display;
private Shell shell;
private Image enabled;
private Image disabled;
public ButtonExample() {
display = new Display ();
shell = new Shell (display);
imageButton = new Button (shell, SWT.PUSH);
enabled = new Image(display,
getImageResourceAsStream("images/Open24.gif"));
disabled = new Image(display,
getImageResourceAsStream("images/OpenDisabled24.gif"));
imageButton.setImage(enabled);
disableButton = new Button (shell, SWT.PUSH);
disableButton.setText ("Disable");
shell.setDefaultButton (disableButton);
shell.setLayout (new RowLayout ());
disableButton.addSelectionListener(new
org.eclipse.swt.events.SelectionAdapter() {
public void
widgetSelected(org.eclipse.swt.events.SelectionEvent
e) {
if (imageButton.getEnabled()) {
imageButton.setImage(disabled);
imageButton.setEnabled(false);
imageButton.setImage(disabled);
disableButton.setText ("Enable");
}
else {
imageButton.setImage(enabled);
imageButton.setEnabled(true);
disableButton.setText ("Disable");
}
}
});
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
display.dispose ();
}
private InputStream getImageResourceAsStream(String name) {
return getClass().getResourceAsStream("/" +
name);
}
public static void main(String[] args) {
try {
new ButtonExample();
}
catch (Throwable e) {
e.printStackTrace();
}
}
}
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev