Resources | Resources |




The Brew MP widgets provide basic components representing the fundamental parts of a UI, such as support for radio buttons, softkeys, text entry, and scrollbars.

Widgets and containers can be combined to create a complex view to display to the user.

MVC pattern implementation in widgets

The following figure illustrates how widgets implement a number of interfaces that handle the view, model, and controller functionality of the MVC pattern. For more information these interfaces, see the

When an application receives events, it passes the key and pointer events to the root container, which uses the location information (the x and y values for pointer events) and z-order of the widgets to determine which widget should receive the event. When events are delivered to a widget, the view handles focus events, and sends key events and touch events to its controller and touch controller, respectively.

Widget life cycle

Widgets are dependent on their reference count. A widget's reference count changes at the following times:

  • when the widget is instantiated
  • when the widget is inserted into a container
  • when a pointer to the widget is retrieved via an API call such as QueryInterface()
  • when the reference count is explicitly increased or decreased
  • when the widget is removed from a container

When widget's reference count is zero, all memory and resources used by the widget object are released or freed.


Widgets draw to the display through a cooperative invalidate-draw cycle. When a widget needs to update its view, it invalidates its content by calling IWidget_Invalidate(), which can invalidate part or all of a widget. The invalidation is sent to the widget's parent, which sends it to its parent, and it progresses up to the container tree to the Root Container. The Root Container collates invalidations into a single draw request that is asynchronously served by Brew MP. The draw cycle controls which widgets draw their content, and in what order. It preserves z-ordering of all elements, and only re-draws those widgets that need to be re-drawn.

Since drawing does not immediately occur, calling invalidate multiple times does not cause multiple redraws to occur (unless they occur in different draw cycles).