Application Framework > The Bitmap Editor Application > Step 3: Modifying and Saving a Bitmap > Adding Notification on the Document Views
 
Adding Notification on the Document Views
The DrawRectangleCommand method used to call the BitmapDocument::refreshViews method to notify a change in the document (as seen earlier in this step). This method will now be implemented:
void
BitmapDocument::refreshViews(const IlvRegion& region)
{
notifyViews(IlvGetSymbol("BitmapHasChanged"), 0, &region);
}
This method broadcasts the BitmapHasChanged message, giving the specified region as argument. To catch the message, the BitmapView declares a method in its interface:
IlvDvBeginInterface(BitmapView)
Method1(BitmapHasChanged, bitmapHasChanged, IlAny, region)
IlvDvEndInterface1(IlvDvFormView)
*The first argument of the Method1 macro is the message name.
*The second argument is the method of BitmapView that will be called when the message BitmapHasChanged is received.
*The third argument is the type of the first argument passed when calling the bitmapHasChanged method.
*The fourth argument is the name of the first argument passed when calling the bitmapHasChanged method.
Note: Only simple types are supported in the interface declaration. Since an IlvRegion is needed to know what the modified region is, an IlAny (that is, a non-typed pointer) is used.
Here is the code of the bitmapHasChanged method:
void
BitmapView::bitmapHasChanged(IlAny region)
{
IlvRegion redrawRegion(*(IlvRegion*)region);
IlvContainer* container = IlvContainer::GetContainer(_icon);
// Deal with the container transformer
if (container->getTransformer())
redrawRegion.apply(container->getTransformer());
// Optimization: Clip using the visible size of the container
IlvRect rect;
container->sizeVisible(rect);
redrawRegion.intersection(rect);
// Then redraw the region
container->bufferedDraw(redrawRegion);
}

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.