API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
See Also
- IForm Interface - IPopupMenu Interface
IMenuModel is derived from the IListModel interface and is used to model a collection of objects, each of which is considered to be an item in a menu. Typically, the menu model is used to manage the storage of data for a user interface object that takes the appearance of a menu -- such as a popup menu form. As such, the menu model stores (as one might guess) menu item data from which a menu may be easily built, maintaining that data in the order that it would appear in a menu on the display. Conceptually, the data stored in a menu model would look like this:
         |                          |  Menu model index 0
         |        Menu Item 0       |
         |                          |
         |                          |  Menu model index 1
         |        Menu Item 1       |
         |                          |
         |                          |  Menu model index 2
         |        Menu Item 2       |
         |                          |
         |                          |  Menu model index (n - 1)
         |     Menu Item n - 1      |
         |                          |

In general (though depending on the object that is attached to the menu model), the items in the menu model will be displayed top-to-bottom from items 0 through item (n - 1), with item zero being at the top of the menu and item (n - 1) at the bottom.
The data storage mechanism used by the menu model is (from the standpoint of clients using the menu model) opaque. The data itself could be arbitrarily complex, depending on the capabilities and expectations of the object that has attached to the model. For example, the menu model could store each item as text that an attached user interface object might display to the user as a standard text menu. The data could just as easily be stored as a binary bitmap, which a dutifully equipped user interface object could expose as a menu containing colorful pictures, rather than text. A third example could see each menu item stored as a complex data structure, which an attached object could utilize to display each item however it pleases. For example, a widget could be created that displays menu items as a spinning wheel, rather than as a vertical list. Each item on the wheel could correspond to an item stored in the menu model, perhaps as a structure containing letters, vowels, dollar figures and VALUABLE PRIZES!
      Menu Model.

The menu model interface provides APIs for accessing or modifying the data in a very straightforward manner that satisfies the requirements of BREW's menu capabilities, as well as routines for managing reference counting of the interface object, and functions that allows widgets and UI controls to register for a listener with the menu model.
For Generic Model usage, see the IModel Interface. For Generic ListModel usage, see the IListModel Interface. While this is a fairly simple menu, having only one layer, it is possible using flags such as MMF_SUBMENU to create heirarchical trees of menus.
   int result;
   IMenuModel *piMenuModel = NULL;

   result = ISHELL_CreateInstance(piShell, AEECLSID_MenuModel, (void **)&piMenuModel);

   // Perform actions such as adding listeners

   if (result == AEE_SUCCESS) {
      for(i=0; i