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

Developer

resources

Models

The data that drives widget content is stored within a model. Models provide notifications of state changes. For example, a widget's view model provides notifications of changes in the widget's view, such as extent changes.

Models provide APIs that allow applications to manipulate the data and register listeners.  It is possible to register multiple listeners with a model, or to cancel a listener. Model listeners receive all model event notifications, or nothing. It is not possible to register for a subset of model notifications. For more information on model events, see Model Events in the http://developer.brewmp.com/reference/api-all.

The following are some of the models available in Brew MP UI Widgets:

  • IValueModel: A model for data that can be represented in an arbitrarily complex form
  • ITextModel: A model for text strings such as in text entry
  • IListModel: A base class for IArrayModel and IVectorModel
  • IListContainerModel: Provides data that IListContainer can use to create a list
  • IArrayModel: A model for a collection of objects with a constant number or elements
  • IVectorModel: A model for a collection of objects that might be of a variable size
  • IMenuModel: Derived from IListModel
  • IInterfaceModel: A model interface for objects that model their data in an interface that does not have a query interface, for example, bitmap and image widgets
  • IFrameModel: Base class for IMediaFrameModel and ICameraFrameModel
  • IMediaFrameModel: Provides image frames from a video
  • ICameraFrameModel: Provides image frames from a camera
  • IDocModel: Provides input data for a document viewer such as the HTML widget
  • IFontMapModel: Stores a collection of style tag/ IFont object pairs
  • IHTMLViewModel: Provides input data for a document viewer such as the HTML widget
  • IRichTextModel: Used to add, get, and delete tags associated with a text model
  • ITypedListModel: A base class for models that manage data organized in lists or collections
  • ITypedValueModel: A base class for models that manage data

See the http://developer.brewmp.com/reference/api-all for more information on the supported models.

Using models

IModel is the interface for a model in the Model-View-Controller triad. A model consists of data along with a notification mechanism to inform its client of changes to that data.

The IModel interface provides object reference counting mechanisms that allow objects to manage their own memory instances. The interface also provides APIs for registering a listener with a model, and for manipulating the data represented by a model.

The example code below, from OptionViewport_CreateRefreshRateBox() in ViewportTC.c, shows how to get a widget's value model, initialize a model listener, and attach the listener to the value model.

   // Get the value model for the slider
   ERR_TRY( IWidget_GetModel(piwSlider, AEEIID_IValueModel, &pim) );
   // Initialize the listener structure for the textbox update callback
   (void)IWidget_AddRef(piwCounterBox);
   LISTENER_Init(pml, OptionViewport_SliderValueListen, piwCounterBox);
   // attach the listener to the check box's value model
   (void)IModel_AddListener(pim, pml);