0

I have a StyledText in my application with bold or colored words and I want to add an image in front of the text, like in the example above:

like in the example above

But since I am very new in SWT I don't know what to search for. How is this possible? Can anyone give me some code snippet or examples from web? I searched but I could not find anything.

dildik
  • 405
  • 6
  • 16
  • `StyledText` does not support images. Things like Package Explorer are using a JFace `TreeViewer` with a `DecoratingStyledCellLabelProvider` which supports a separate image followed by styled text. – greg-449 Oct 01 '14 at 07:15
  • Ok, is it possible to position an image and a styled text on the right-hand side? What do I have to do for this? – dildik Oct 01 '14 at 09:15
  • Are you asking about just SWT or SWT + JFace or an Eclipse plugin? Because what is available is different in each case. – greg-449 Oct 01 '14 at 09:21
  • I am developing for an Eclipse plugin. It is a ctabitem in a ctabfolder and there I want to post information about different view clicks (for statistic purposes). And it must be a styled text since I want to format the text with bold or colored text. – dildik Oct 01 '14 at 09:29
  • So is a table with the image on the left followed by styled text what you want? – greg-449 Oct 01 '14 at 09:35
  • Its hard to show you since I am not allowed to post my code. I describe it so: I have a ctabfolder with many ctabitems. In one of the ctabitems, I have a ScrolledComposite and in its content composite, I just have a lot of styled texts. Thus, when I catch a new event, I format the styled text and add this to the content composite with a line break (which is also a rounded composite but this is not important for this task/question). I just want to have an image or an icon in front on the styled text. It must not be part of the styled text, just in front of the text. This is also sufficient. – dildik Oct 01 '14 at 09:42

1 Answers1

0

I have found a way to do this: I put the image into the data field of a StyleRange object and repaint everything. Here is a good example from the eclipse community. It worked for me.

dildik
  • 405
  • 6
  • 16