Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Interface model

The Interface model contains data that can be represented as a pointer to a Brew MP interface that does not natively support an interface query, such as IImage or IBitmap.

IInterfaceModel inherits from the IModel interface and can be used to contain data stored in an interface that lacks a formal query interface, while still ensuring strict data type enforcement on the data stored in the model interface (where the IValueModel interface would not). This is particularly important for standard Brew MP data types; for example, the bitmap and image widgets rely on their native Brew MP interfaces (IBitmap and IImage, respectively) for storing data. However, neither of these interfaces support a query interface. Thus, changes to the data stored in these objects may be funneled through IInterfaceModel.

IInterfaceModel provides functions for:

  • managing reference counting of the interface object
  • registering a listener with a value model
  • manipulating the interface reference information stored in the model

Using interface model

Interface models are used as a wrapper around objects that do not support a query interface. One possible use for this would be to insert a bitmap into an image widget. This example shows the retrieval of a bitmap (pib) that has already been inserted into the widget (piw).

IInterfaceModel *piim = NULL;
// Get the current bitmap from the widget.  It is stored via an interface model.
nErr = IWidget_GetModel(me->piw, AEEIID_IInterfaceModel, (IModel**)&piim);
if (AEE_SUCCESS != nErr) {
   // Perform cleanup
   return;
}
nErr = IInterfaceModel_GetIPtr(piim, AEECLSID_CBitmap, (void**)&pib);
if (AEE_SUCCESS != nErr) {
   // Perform cleanup
   return;
}
// use bitmap obtained from widget through interface model