[haiku-appserver] Re: _BMCItem_

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-appserver@xxxxxxxxxxxxx
  • Date: Fri, 17 Feb 2006 10:25:15 +0100

> >The only thing I see is that if R5 had a special >BMenuItem subclass named
> >_BMCItem_, then removing it would break instantiating >BMenuFields that 
> >have
> >been archived under R5. Not that I know where those >would be comming 
> >from...
> >:-)
> 
> See ? There was a reason after all. I don't think we'll find many cases 
> like these, anyway...

Well, in theory, you could add another menu to the menubar, right? If you 
wanted two popup-markers on each menu, then having the item draw it is the 
better idea. The problem with this line of thought is... there is no way 
from the outside to instantiate a _BMCItem_ for the super item of the second 
menu. So that would be useless.

It's another one of those cases where I really hate that fact that there is 
no virtual factory method for instantiating objects. BTextControl is another 
example. I should have a virtual method "BTextView* CreateTextView()" that 
it uses to get an instance of the BTextView. With BMenus it's not that bad, 
because you can do

BMenuItem* item = new MyFancyItem(someSubMenu);
superMenu->AddItem(item);

instead of

superMenu->AddItem(someSubMenu);

so after all, you can control of which class the BMenuItems are an instance 
of. But if there were a virtual BMenuItem* CreateMenuItem() in the BMenu, 
you would have to worry about it less.

Better yet, this mechanism should be delegated to another "instantiator" 
object that you could set on somebody. Like

BMenuItemCreator* creator = new MyFancyItemCreator();
superMenu->SetItemCreator(creator);

This way, you could plug together objects without having to subclass BMenu. 
BMenuField could then provide it's own BMenuItemCreator to *whatever* BMenu 
it is given and have that create _BMCItems_.


[back to topic]

> >Ok, I will just change it and see what happens. I also >see nowhere in the
> >code that fShowPopUpMarker would be configurable.
> 
> It's configurable via BMenuField::ShowPopUpMarker()
> and BMenuField::HidePopUpMarker() which aren't implemented, atm.

Ok, then I will implement those... should be easy.

Best regards,
-Stephan


Other related posts: