Remove Indent SWT TreeItem

I am trying to create a SWT tree that has icons at the top level, but not at the next level.

Tree screenshots

Is there a way to avoid the empty space that seems to be left for the image that I am not using? I tried using the following code snippets but didnโ€™t do what I wanted.

SWT.MeasureItem:

tree.addListener(SWT.MeasureItem, new Listener()
{
  @Override
  public void handleEvent(Event event)
  {
    TreeItem item = (TreeItem)event.item;
    Image image = item.getImage();
    if (image == null)
    {
      event.x -= 40;
    }
  }
});

SWT.PaintItem:

tree.addListener(SWT.PaintItem, new Listener()
{
  @Override
  public void handleEvent(Event event) {
    TreeItem item = (TreeItem)event.item;
    Image image = item.getImage();
    if (image == null)
    {
      event.x -= 40;
    }
  }
});

In both cases, I just hoped that the text could be pulled a little to the left.

+5
source share
2 answers

I did some more research. According to Eugene, this is similar to behavioral behavior. There are a few things worth noting.

, . , .

:

  • , .
  • , , , . "" +
  • PaintItem, , , ,

, , , .

+1

(AFAIR, Mac ). , , - ( ).

+2

All Articles