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


API Reference


Brew Release
Brew MP 1.0.2
See Also
- IDrawDecorator Interface - PFNHANDLER - PFNFREEHANDLER - HandlerDesc - IDrawDecorator_SetDraw() - IDecorator_SetHandler()
This function allows a draw decorator implementation to hook its own event handler into the normal event handling mechanism for decorators. For example, an object that derives from the base IDecorator Interface could insert its own event handler that will be called each time an event is processed.
The event handler is stored in a HandlerDesc data structure as a PFNHANDLER, along with a pointer to a block of memory allocate and owned by the draw decorator implementation. This pointer will be passed into the draw decorator's event handler with each event to be processed. The HandlerDesc data structure also contains a PFNFREEHANDLER that will be called when the draw decorator is released so that the decorator may free the private memory allocated and passed to the event handler.
IDrawDecorator_SetHandler() associates a given HandlerDesc data structure with a particular draw decorator.
IDrawDecorator_SetHandler() inherits wholly from IDecorator_SetHandler().
A pointer to an IDrawDecorator object.
Pointer to the data structure that contains the event handler, private memory pointer, and the callback used to free the private memory.

  •    void IDrawDecorator_SetHandler(IDrawDecorator *p, HandlerDesc *pd);
  • None
Side Effect
  • None
Passing NULL for the HandlerDesc will reset the draw decorator's event handler to use the base widget's default event handler -- without private memory or the need to free privately allocated storage. The handler installed by a draw decorator to process events should itself remember to call HandlerDesc_Call() so that the implementations that themselves derive from this decorator may also to hook into the draw decorator's normal event handling mechanism. An application that hooks into both a draw decorator's event handler and draw handler (by calling IDrawDecorator_SetDraw()), should exercise care in managing the private data released by the PFNFREEHANDLER stored in the HandlerDesc data structure. Event handlers and draw handlers both manage data structures that contain pointers to private storage, as well as a pointer to a function that will be used to release this storage -- which could be different... or could be the same! Each of these PFNFREEHANDLER routines will be called when the draw decorator is released. Therefore, an application that uses the same block of private storage for both its custom event and draw handling procedures should be careful to check the validity of the storage to be freed before actually attempting to release the memory.