Cane One Use A ListBox As A Custom Component In Another ListBox

Is this possible?
MyListBox: A ‘Normal’ ListBox.
MyListBox::refreshComponentForRow() creates when required a MyCustomListBox.

MyCustomListBox:
Has a header.
Has a couple of rows.
MyCustomListBox header always shows up in
MyListBox.

It seems the height of MyCustomListBox is constrained by what MyListBox thinks the height of an item (row) should be (something like 22px). Am I correct about this? Empirical evidence:

  • When I create a MyCustomListBox() I set the size to (100,400).
  • MyCustomListBox gets a resize() where the bounds are in fact 100,400
  • MyCustomListBox() then immediately gets another resize() where the bounds are (98,22). I Am assuming that this resize() is coming from MyListBox().

So since it is believed that the height of MyCustomListBox is only 22px it is not possible paint the contents of the list box (the rows). I.e. the Models ::paintListBoxItem is never called because no ‘rows’ are visible.

Are my assumptions correct or is it possible to use a ListBox as a CustomComponent within a ListBox? If the latter is true any hints on what I could be missing would be greatly appreciated.

After learning some JUCE lingo and being able to construct the correct search query I see that a ListBox does in fact have a fixed height ListBox item therefore using ListBox as a custom component will not work.

TreeView is is!

The default height of ListBox row is 22 pixels but it’s not fixed, you can change it:

void ListBox::setRowHeight(int newHeight)

I am aware, but it will make all of the rows the same height.
I was under the false impression that a ListBox’s rows could each have their own height.

Have you considered putting your listboxes etc. all into one parent component and then using a viewport for that component?

Yes I have.
But all was trying to do was create an exploding (TreeView like) ListBox.
I understand that it is very possible to roll my own.
So I have moved on to TreeView.

It is implemented (the functionality requirement has been met) but now I am horrified that the scroll bar is hard coded to the left of the TreeViewItems :slight_smile:

I see others here have rolled their own solutions to move the scroll bar to the left within a TreeView. I will do so when I finish my project functionally (make sure it works!).

Thanks to all for the suggestions.