Upon further inspection, the matter seems to be more complex than we've initially thought. The only information a ListboxItem knows about its owner is a const Window* to him. However, the different ListboxItem container classes (Listbox, MultiColumnList, ...) do not share a common ancestor class (something like "ListboxBase" in analogy to "MenuBase" for menu-related stuff). For this reason, in order to call the appropriate handleUpdatedItemData() function from a ListboxItem, one would have to find out the correct type of its owner by brute-force comparison to all "known" Listbox containers via RTTI or something else - which would be incredibly ugly and obviously infeasible.
I assume that this very problem is why it was initially implemented so that MenuItems correctly notify their container (as there is a MenuBase class), but ListboxItems do not (as there is no ListboxBase class). As we've discussed before, this inconsistency between these two very similar structures should be removed - however, this would require some significant (probably even API-breaking) changes. Possibly they could even be unified to a certain extent? I mean both share the functionality of a parent containing multiple Item elements... In that case, I'd imagine a class inheritance structure like this:
Code: Select all
Item
/ \
ListboxItem MenuItem
|
ListboxTextItem
Code: Select all
ItemContainer
/ \
ListboxItemContainer (aka ListboxBase) MenuItemContainer (aka MenuBase)
/ \ / \
Listbox MultiColumnList Menubar PopupMenu
I haven't taken a look at timotei's changes yet. Possibly this issue has already been resolved in the default branch due to his work. If not, it might be a good idea if someone (me?) made the necessary changes.
Looking forward to opinions on this
//EDIT: I just found that there already is an inheritance structure similar to what I've proposed. Apparently ItemEntry / ItemListBase represent Item / ItemContainer of my proposal. Then MenuBase and MenuItem inherit ItemListBase / ItemEntry respectively. However, in the "Listbox" branch of the inheritance diagram, there's only ItemListbox - which I've never used before
It seems to be a generic list box for items other than just text.
At this point, I'm even more confused about why there's a Listbox (for text items only) and an ItemListbox (for any window object), but they are implemented entirely independently from each other, resulting in a lot of duplicate code