ICnrDrawHandler

The ICnrDrawHandler class processes draw item and draw background events in the container.

To receive draw item events, you must do either of the following:

Similarly, to receive draw background events, you must do either of the following:

In addition, whenever you draw a container item or background, call IEvent::setResult(true) to prevent the system from drawing the item or background.

Create a handler derived from ICnrDrawHandler and attach it to the container whose foreground or background is to be drawn or to the container's owner window. You can do this by calling ICnrDrawHandler::handleEventsFor to pass the container or owner window to the container draw handler.

ICnrDrawHandler processes the following events in the container:


Note: Attaching ICnrDrawHandler to a container's owner window does not allow you to process ICnrDrawBackgroundEvents. Only ICnrDrawItemEvents are processed if ICnrDrawHandler is attached to an owner window.

When the container draw handler receives one of these container draw events, the handler creates a corresponding event object and routes that object to the appropriate ICnrDrawHandler virtual function. You must override these virtual functions to supply your own specialized processing of a container draw event.

The return value from the virtual functions specifies whether the container draw event should be passed on for additional processing, as follows:

Return Value :ddhd.Meaning
true
The container draw event requires no additional processing. Do not pass it to another handler.
false
Pass the container draw event to the next handler for additional processing, as follows:
  • If there is another handler for the container, pass the container draw event to the next handler.
  • If this is the last handler for the container, call IWindow::defaultProcedure to process ICnrDrawBackgroundEvents and call IWindow::dispatch to dispatch ICnrDrawItemEvents to the container's owner window.
  • If this is the last handler for the container's owner window, call IWindow::defaultProcedure to process the ICnrDrawItemEvents. The handler should not receive any ICnrDrawBackgroundEvents.

AIX Considerations

The Motif container does not support owner drawing. This handler is not called in this case.

Windows Considerations

The native Windows containers (that is, containers constructed without the pmCompatible style) do not support owner drawing. This handler is not called in this case.


ICnrDrawHandler - Member Functions and Data by Group

Constructors & Destructor

You can destroy objects of this class. The only way to construct objects of this class is from a derived class. To enforce this, the only constructor we provide for this class is protected.


[view class]
~ICnrDrawHandler
public:
virtual ~ICnrDrawHandler()

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
ICnrDrawHandler
protected:
ICnrDrawHandler()

Constructs instances of this class by using the default constructor, which does not accept any arguments.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


Event Dispatching

The Open Class Library dispatches events that have been sent or posted to a window to each of the handlers attached to that window. It does this by calling the event-dispatching function of each handler object.


[view class]
handleEventsFor
public:
virtual ICnrDrawHandler& handleEventsFor( IContainerControl* container )

Attaches the handler to the specified container control.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
stopHandlingEventsFor
public:
virtual ICnrDrawHandler& stopHandlingEventsFor( IContainerControl* container )

Detaches the handler from the specified container control.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
dispatchHandlerEvent
protected:
virtual bool dispatchHandlerEvent(IEvent& event)

If a container draw event is found, the appropriate virtual function is called.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


Event Processing

Event-processing members must be supplied by a derived class to provide processing for a draw event.


[view class]
drawBackground
public:
virtual bool drawBackground(ICnrDrawBackgroundEvent& event)

Called when the background of the container needs to be redrawn.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
drawDetailsItem
public:
virtual bool drawDetailsItem(ICnrDrawItemEvent& event)

Called in the details view when the data of an object in a column needs to be redrawn. The emphasis of the data must be drawn during the processing of this event. This is also called when the details view column title needs to be redrawn. In this case, a call to ICnrDrawItemEvent::object() returns 0.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
drawIcon
public:
virtual bool drawIcon(ICnrDrawItemEvent& event)

Called when the icon in the icon or name view needs to be redrawn. The emphasis of the icon must be drawn during the processing of this event.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
drawText
public:
virtual bool drawText(ICnrDrawItemEvent& event)

Called when the text in the icon, name, or text view needs to be redrawn. The emphasis of the text must be drawn during the processing of this event.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
drawTitle
public:
virtual bool drawTitle(ICnrDrawItemEvent& event)

Called when the title of the container needs to be redrawn.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


[view class]
drawTreeIcon
public:
virtual bool drawTreeIcon(ICnrDrawItemEvent& event)

Called in the tree view when the "expand or collapse" icon needs to be redrawn.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored


ICnrDrawHandler - Inherited Member Functions and Data

Inherited Public Functions

IHandler

Inherited Public Data

Inherited Protected Functions

IHandler

Inherited Protected Data