IMenuDrawItemHandler

The IMenuDrawItemHandler class processes menu draw-item events.
Note: You must create the menu item with the constructor from IMenuItem that creates a draw item. You can also call IMenuItem::setDrawItem after you have created the menu item.

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:

true
The menu draw-item event requires no additional processing. Do not pass it to another handler.
false
The menu draw-item event may require additional processing. Pass the menu draw-item event to the next handler for additional processing, as follows:
  • If there is another handler for the menu, pass the menu draw-item event to the next handler.
  • If this is the last handler for the menu, call IWindow::dispatch to dispatch the menu draw-item event to the menu's owner window.
  • If this is the last handler for the owner window, call IWindow::defaultProcedure to process the menu draw-item event.


IMenuDrawItemHandler - Member Functions and Data by Group

Constructors & Destructor

You can construct and destruct objects of this class.


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

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IMenuDrawItemHandler
public:
IMenuDrawItemHandler()

Provides the default constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Drawing Flags

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.


[view class]
drewChecked
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.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
drewDisabled
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.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
drewSelected
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.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Event Dispatching

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.


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

If a menu draw-item event is received, this function calls the appropriate virtual function.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Event Processing

Event-processing functions are called when an event occurs that may need to be processed by this handler.


[view class]
draw
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.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
highlight
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: This function is not called if draw returns true.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setSize
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.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
unhighlight
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: This function is not called if draw returns true.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IMenuDrawItemHandler - Inherited Member Functions and Data

Inherited Public Functions

IHandler

Inherited Public Data

Inherited Protected Functions

IHandler

Inherited Protected Data