Italics on Solaris [message #730803] |
Thu, 29 September 2011 04:07  |
Eclipse User |
|
|
|
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 09:37   |
Eclipse User |
|
|
|
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 04:07  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03355 seconds