Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Italics on Solaris
Italics on Solaris [message #730803] Thu, 29 September 2011 08:07 Go to next message
Guenther Mahr is currently offline Guenther MahrFriend
Messages: 13
Registered: September 2011
Junior Member
Hi,

we develop on Windows for Solaris. Now in order to show one specific row of a table in Italics, I used the following code:

final TextLayout textLayout = new TextLayout(Display.getCurrent());

overviewDialog.getProfilesTable().getTable().addListener(SWT.PaintItem, new Listener() {
public void handleEvent(final Event event) {
textLayout.draw(event.gc, event.x, event.y);
}
});

overviewDialog.getProfilesTable().getTable().addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(final Event e) {
final TableItem item = (TableItem) e.item;
textLayout.setText(item.getText(e.index));
final Profile profile = (Profile) item.getData();
if (profile.getType().equals(PCIConstants.PCI_SYSTEM_TYPE)) {
textLayout.setStyle(styleItalic, 0, item.getText(e.index).length());
} else {
textLayout.setStyle(styleNormal, 0, item.getText(e.index).length());
}
final Rectangle textLayoutBounds = textLayout.getBounds();
e.width = textLayoutBounds.width + 2;
e.height = textLayoutBounds.height + 2;
}

});

overviewDialog.getProfilesTable().getTable().addListener(SWT.EraseItem, new Listener() {
public void handleEvent(final Event e) {
e.detail &= ~SWT.FOREGROUND;
}
});


This code works perfectly on Windows, but on Solaris not only no italic text is shown, but I also get the same text (actually the real text of one of the columns) in all of the table columns, in this case it's the user name: root.

Is there any restriction or special condition for Solaris regarding my code? Or what else could be the reason?

Thanks,
Guenther
Re: Italics on Solaris [message #730902 is a reply to message #730803] Thu, 29 September 2011 13:37 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi Guenther,

The second problem (the same text showing for all columns) is probably a
result of the listeners assuming that for a given Table "cell" that
receiving a MeasureItem event will be followed by a receiving a
PaintItem event for the same cell, but this behaviour is not spec'd.
The PaintItem listener should duplicate the first eight lines from the
MeasureItem listener to ensure that the text for the correct cell is drawn.

Regarding the missing italics, perhaps the font being used on Solaris
just isn't available in an italicized rendering? Does it work to set it
to something different like bold?

Grant


On 9/29/2011 4:07 AM, Guenther Mahr wrote:
> Hi,
> we develop on Windows for Solaris. Now in order to show one specific row
> of a table in Italics, I used the following code:
>
> final TextLayout textLayout = new TextLayout(Display.getCurrent());
>
> overviewDialog.getProfilesTable().getTable().addListener(SWT.PaintItem,
> new Listener() {
> public void handleEvent(final Event event) {
> textLayout.draw(event.gc, event.x, event.y);
> }
> });
>
> overviewDialog.getProfilesTable().getTable().addListener(SWT.MeasureItem, new
> Listener() {
> public void handleEvent(final Event e) {
> final TableItem item = (TableItem) e.item;
> textLayout.setText(item.getText(e.index));
> final Profile profile = (Profile) item.getData();
> if (profile.getType().equals(PCIConstants.PCI_SYSTEM_TYPE)) {
> textLayout.setStyle(styleItalic, 0, item.getText(e.index).length());
> } else {
> textLayout.setStyle(styleNormal, 0, item.getText(e.index).length());
> }
> final Rectangle textLayoutBounds = textLayout.getBounds();
> e.width = textLayoutBounds.width + 2;
> e.height = textLayoutBounds.height + 2;
> }
>
> });
>
> overviewDialog.getProfilesTable().getTable().addListener(SWT.EraseItem,
> new Listener() {
> public void handleEvent(final Event e) {
> e.detail &= ~SWT.FOREGROUND;
> }
> });
>
>
> This code works perfectly on Windows, but on Solaris not only no italic
> text is shown, but I also get the same text (actually the real text of
> one of the columns) in all of the table columns, in this case it's the
> user name: root.
>
> Is there any restriction or special condition for Solaris regarding my
> code? Or what else could be the reason?
>
> Thanks, Guenther
Re: Italics on Solaris [message #731182 is a reply to message #730902] Fri, 30 September 2011 08:07 Go to previous message
Guenther Mahr is currently offline Guenther MahrFriend
Messages: 13
Registered: September 2011
Junior Member
That was really grand help, Grant! I duplicated the code as you recommended and now everything even the italics works perfectly, also on Solaris!

Thanks again!
Guenther

Previous Topic:Eclipse cannot find database and configs
Next Topic:Approach between the two View
Goto Forum:
  


Current Time: Sun Dec 21 00:30:29 GMT 2014

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

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