may be it’s silly question and have easy solution but I am unaware of it. please let me know if any.
I want to put tableList and listbox in same class like following
class abc: public Component, public TableListBoxModel , public ListBoxModel
But both TableListBoxModel , ListBoxModel has virtual method
int getNumRows()
So how this can be done ?
One way is, I can create another component xyz : public ListBoxModel that can go inside component abc : public TableListBoxModel … But I want to know if i use both model in same class ?
Actually i’m working on a customised listbox that is multicolumn and where The final class also has built in models in order to replicate the XOJO way but i realise this breaks the MVC way that juice listboxes operate.
I did it to overcome some limitations in the standard classes - primarily the inability for the listbox class to easily facilitate painting in the area below the last row actually present in the
model.
I’ve found this a lot more painful than just using inheritance, overriding and the like. In the end i’m having to take the route of making customised copies of both ListBox and aTableListBox
.
ListBox has to be modified because of code in Listbox::ListViewport
void updateVisibleArea (const bool makeSureItUpdatesContent)
{
hasUpdated = false;
const int newX = getViewedComponent()->getX();
int newY = getViewedComponent()->getY();
const int newW = jmax (owner.minimumRowWidth, getMaximumVisibleWidth());
// OLD const int newH = owner.totalItems * owner.getRowHeight(); // D STENNING
const int newH = getMaximumVisibleHeight(); // D STENNING
if (newY + newH < getMaximumVisibleHeight() && newH > getMaximumVisibleHeight())
newY = getMaximumVisibleHeight() - newH;
getViewedComponent()->setBounds (newX, newY, newW, newH);
if (makeSureItUpdatesContent && ! hasUpdated)
updateContents();
}
I also had to modify the TableListbox file
It would be much better if the standard classes can just be tweaked a little to handle my needs.
Put simply - the classes need to allow for all the row component instances BEYOND the actual rows in the model to be optionally handled. Whether for a mouse click or for painting the background ( or maybe even foreground )
I will submit my final classes here.
I plan to merge my versions of ListBox and TableListBox into just one class - since its getting far too complicated.
I’m doing all this to replicate the way XOJO ListBoxes work - which are always multi column and allow all the above.