Italics on Solaris [message #730803] |
Thu, 29 September 2011 08:07  |
Guenther Mahr Messages: 25 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   |
Grant Gayed 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01178 seconds