Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Determining if style hint is supported on current platform
Determining if style hint is supported on current platform [message #517389] Sat, 27 February 2010 13:01 Go to next message
Ralf Ebert is currently offline Ralf EbertFriend
Messages: 168
Registered: July 2009
Senior Member
Hi,

I was just wondering, is there an API that answers the question if a given style flag/hint
is supported on the current platform? I want to show an own icon if SWT.ICON_SEARCH for
SWT.Text is not supported. I just wrote a helper method to do this:
http://github.com/ralfebert/rcputils/blob/2.0.2/de.ralfebert .rcputils/src/de/ralfebert/rcputils/porting/CrossPlatformSup port.java

Is there a better way?

Greetings,

Ralf


--
http://www.ralfebert.de/blog/eclipsercp/
Re: Determining if style hint is supported on current platform [message #517649 is a reply to message #517389] Mon, 01 March 2010 15:31 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Ralf,

You can check the Control's style after creation to see if the bit was
retained or not. For example:

public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
int style = SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH;
System.out.println("old: " + style);
Text text = new Text(shell, style);
System.out.println("new: " + (text.getStyle() & style)); // <---
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant


"Ralf Ebert" <info@ralfebert.de> wrote in message
news:hmb53m$3rj$1@build.eclipse.org...
> Hi,
>
> I was just wondering, is there an API that answers the question if a given
style flag/hint
> is supported on the current platform? I want to show an own icon if
SWT.ICON_SEARCH for
> SWT.Text is not supported. I just wrote a helper method to do this:
>
http://github.com/ralfebert/rcputils/blob/2.0.2/de.ralfebert .rcputils/src/de/ralfebert/rcputils/porting/CrossPlatformSup port.java
>
> Is there a better way?
>
> Greetings,
>
> Ralf
>
>
> --
> http://www.ralfebert.de/blog/eclipsercp/
>
Re: Determining if style hint is supported on current platform [message #517743 is a reply to message #517649] Mon, 01 March 2010 17:06 Go to previous message
Ralf Ebert is currently offline Ralf EbertFriend
Messages: 168
Registered: July 2009
Senior Member
Hi Grant,

> System.out.println("new: " + (text.getStyle() & style)); // <---
thanks, that's great, good to know.

Greetings,

Ralf


--
http://www.ralfebert.de/blog/eclipsercp/
Previous Topic:Could my Windows XP environment be causing this?
Next Topic:SWT handle difference between platform
Goto Forum:
  


Current Time: Tue Dec 03 00:36:49 GMT 2024

Powered by FUDForum. Page generated in 0.03563 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top