Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Strikeout text in Mac OSX
Strikeout text in Mac OSX [message #663465] Tue, 05 April 2011 04:27 Go to next message
Ricky de Klerck is currently offline Ricky de Klerck
Messages: 295
Registered: January 2011
Senior Member
Hi,

We're developing a RCP application but we have some trouble with the differences between Windows and Mac OSX. We want to strikeout text in a Tree, but it doens't work on Mac.

We use this to set the font:

treeItem.setFont(SWTResourceManager.getFont(String name, int size, int style, boolean strikeout, boolean underline))


but we get an error on Mac:

Unable to set underline or strikeout (probably on a non-Windows platform)


Is there another way to create a font with strikeout so it works on both Windows and Mac?


Thanks in advance!
Re: Strikeout text in Mac OSX [message #667341 is a reply to message #663465] Thu, 28 April 2011 04:56 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de Klerck
Messages: 295
Registered: January 2011
Senior Member
I have found a solution myself.

In my treeviewer, I use a labelprovider. It now extends StyledCellLabelProvider where you can apply a style like this:

        private static Styler STRIKETHROUGH = new Styler() {
		@Override
		public void applyStyles(TextStyle textStyle) {
			textStyle.strikeout = true;
		}
	};
	
	private StyledString getStyledString(Object element) {	
		return new StyledString(getText(con),STRIKETHROUGH);
	}
	
	public void update(final ViewerCell cell) {
		Object obj = cell.getElement();
		
		cell.setFont(getFont(obj));

		StyledString styledString = getStyledString(obj);
		cell.setText(styledString.getString());
		   cell.setStyleRanges(styledString.getStyleRanges());		
	}

Re: Strikeout text in Mac OSX [message #761860 is a reply to message #667341] Wed, 07 December 2011 02:43 Go to previous messageGo to next message
Karthikeyan Missing name is currently offline Karthikeyan Missing name
Messages: 47
Registered: July 2011
Member
Hi,

Me too having the same issue. Myself need the label to be underlined or strikethrough (Font not having the same) in both windows and mac os. Kindly help me in the above code, where to use it.

Thanks & Regards,
Karthikeyan.B

[Updated on: Wed, 07 December 2011 04:10]

Report message to a moderator

Re: Strikeout text in Mac OSX [message #763470 is a reply to message #761860] Fri, 09 December 2011 15:39 Go to previous message
Ricky de Klerck is currently offline Ricky de Klerck
Messages: 295
Registered: January 2011
Senior Member
I don't know where to set in a label. In my problem it was a treeviewer which sets it's labels with a labelprovider.
Previous Topic:Removing EObject from EMF Resource with RemoveCommand
Next Topic:Error While Exporting Eclipse Product
Goto Forum:
  


Current Time: Thu Aug 28 05:16:23 EDT 2014

Powered by FUDForum. Page generated in 0.03908 seconds