The IMenuDrawItemHandler class processes menu draw-item events.
Note:
Create a handler derived from IMenuDrawItemHandler and attach it to a menu. Do this by calling IHandler::handleEventsFor to pass the appropriate menu to the menu draw-item handler.
When the menu draw-item handler receives a menu draw-item event, it creates an IMenuDrawItemEvent object and routes that object to the appropriate IMenuDrawItemHandler virtual function. You can override these "Event Processing" virtual functions to supply your own specialized processing of a menu draw-item event.
The return value from the virtual functions specifies whether the menu draw-item event should be passed on for additional processing, as follows:
You can construct and destruct objects of this class.
![]() |
public:
virtual ~IMenuDrawItemHandler()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IMenuDrawItemHandler()
Provides the default constructor.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
An object of the nested class IMenuDrawItemHandler::DrawFlag is passed as the second argument of an overridden version of IMenuDrawItemHandler::draw. The overridden version must set the appropriate drawing flags to indicate whether it handled any of the special drawing needs of the menu item.
![]() |
protected:
static const DrawFlag drewChecked
Indicates that the selected indicator of the menu item has been drawn. If you draw the selected indicator in your override of IMenuDrawItemHander::draw, bitwise OR (|) this value into the second parameter of the function to prevent the default drawing from occurring.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
static const DrawFlag drewDisabled
Indicates that the menu item's disabled state has been drawn. If you draw the disabled emphasis in your override of IMenuDrawItemHander::draw, bitwise OR (|) this value into the second parameter of the function to prevent the default drawing from occurring.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
static const DrawFlag drewSelected
Indicates that the highlighting of the menu item has been drawn. If you draw the selected emphasis highlighting in your override of IMenuDrawItemHander::draw, bitwise OR (|) this value into the second parameter of the function to prevent the default drawing from occurring.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
The Open Class Library dispatches events that have been sent or posted to a window to the handlers attached to that window. It does this by calling the event-dispatching function of the handler objects. An IMenuDrawItemHandler object processes only drawing events for menu items.
![]() |
protected:
virtual bool dispatchHandlerEvent(IEvent& event)
If a menu draw-item event is received, this function calls the appropriate virtual function.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Event-processing functions are called when an event occurs that may need to be processed by this handler.
![]() |
protected:
virtual bool draw( IMenuDrawItemEvent& event, DrawFlag& flag )
By default, the system draws a selected indicator, creates a halftone of the text for a disabled menu item, and inverts the bits to highlight menu item selection. Unless the system default method is unacceptable, you do not have to draw these attributes.
Override this function to draw the menu item. If you draw any of these attributes, set the appropriate IMenuDrawItemHandler::DrawFlag before returning from IMenuDrawItemHandler::draw. This prevents the system from drawing these attributes.
The class IMenuDrawItemEvent provides menu item attribute functions to query whether the menu item is selected, checked, or disabled.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual bool highlight(IMenuDrawItemEvent& event)
Highlights a selected menu item by inverting the bits.
Override this function if you want to draw the highlight
that indicates a menu item has been selected.
Do this only if the default of inverting the bits
for a selected item is unacceptable.
Note:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual bool setSize( IMenuDrawItemEvent& event, ISize& newSize )
Override this function to set the width and height of each draw item menu item. This event is dispatched only once for each menu item, when the menu is initialized. Specify the size in newSize.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual bool unhighlight(IMenuDrawItemEvent& event)
Removes the highlight from a deselected menu item.
Override this function if you want to remove the highlight
that indicates a menu item has been deselected.
Do this only if the default is unacceptable.
Note:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
virtual ~IHandler()
virtual IString asDebugInfo() const
virtual IString asString() const
virtual IHandler& disable()
virtual IHandler& enable(bool enable = true)
virtual IHandler& handleEventsFor(IWindow* window)
IHandler()
bool isEnabled() const
virtual IHandler& stopHandlingEventsFor(IWindow* window)
virtual IEventResult defaultProcedure(IEvent& event)
virtual bool dispatchHandlerEvent(IEvent& event) = 0