I think this should be possible if you draw the selection yourself in the paintItem method of your TextItem sub-class. In this case you can have the fillAll take the whole size. To avoid the TreeView from drawing the selection before you had a chance to, you need to set the selectedItemBackgroundColourId to a completely transparent colour. This is the default with LookAndFeel version 2, but you can also set this explicetely for your TreeView:
Ahh ok, now I understand the problem :-). It seems like we should maybe have an additional flag similar to
drawsInLeftMargin - maybe drawEntireWidth or drawInRightMargin. I'll ask Jules what he thinks.
Alternatively, would it work for you to have getItemWidth return -1 and then place your TreeView inside JUCE's Viewport? You then only need to resize your TreeView's width to the treeview item which has the maximum width. If this is larger than your Viewport then the viewport should take care of the scroll bars. Is this an option for you?
OK! I've now added setDrawsInRightMargin method to TreeViewItem. This will disable the clipping on the right side when drawing a TreeViewItem. Note, however, that the width parameter sent to your paintItem method will still be called with the actual width of the item (i.e. it will be the width returned by getItemWidth if this is positive). It's only the clipping that will be changed. Does this work for you?