ICustomButtonDrawHandler

The ICustomButtonDrawHandler class processes ICustomButton drawing events.

When ICustomButtonDrawHandler detects that an ICustomButton needs to be drawn, it calls ICustomButtonDrawHandler::drawButton to do the drawing. ICustomButtonDrawHandler::drawButton calls, in order, ICustomButtonDrawHandler::drawBorder ICustomButtonDrawHandler::drawBackground and ICustomButtonDrawHandler::drawForeground. Then, if a disabled image for the button is needed, it calls ICustomButtonDrawHandler::drawDisabledEmphasis.

In addition to drawing the border, ICustomButtonDrawHandler::drawBorder calls ICustomButtonDrawEvent::setDrawingArea to shrink the drawing area by the size of the border. Because of this change to the drawing area, you do not need to know the size of the border to draw the background and foreground. The area can be retrieved by calling ICustomButtonDrawEvent::drawingArea.

When you are determining the state of the button to draw, use the member functions provided in ICustomButtonDrawEvent. Due to the effects of caching, your handler may be asked to draw an image for a state that does not match the current state of the ICustomButton itself.
Note: Attach objects of this class only to ICustomButton objects. Attaching an ICustomButtonDrawHandler to the owner of an ICustomButton will not work correctly. Also, attach objects of this class to do custom drawing of the button. An attached IPaintHandler will not see all custom button paint events.


ICustomButtonDrawHandler - Member Functions and Data by Group

Constructors & Destructor

You can construct and destruct objects of this class. You can also copy and assign objects of this class. However, if you derive from this class, remember to implement a copy constructor and assignment operator as needed.


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

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
ICustomButtonDrawHandler
public:
ICustomButtonDrawHandler()

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 ICustomButtonDrawHandler object processes only custom button draw events.


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

Calls the appropriate virtual function or functions to process a custom button draw event.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Event Processing

Event-processing members provide information about handling events.


[view class]
drawBackground
protected:
virtual void drawBackground(ICustomButtonDrawEvent& event)

Called to draw the background of the button. You can override this function to change the way the button's background is drawn.

The default behavior is to fill the current drawing area with the background color or latched background color.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
drawBorder
protected:
virtual void drawBorder( ICustomButtonDrawEvent& event, ISize margin = ISize ( ) )

Called to draw the border of the button. The default implementation draws the border and removes the area painted from the button drawing area. Uses the margin option to specify the amount of white space that to be left around the button. You can override this function to change the way the button border is drawn.
Note: If the button's drawing area rectangle is not reduced (by removing the area occupied by the border), then the background and foreground of the button can paint over the border.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
drawButton
protected:
virtual bool drawButton(ICustomButtonDrawEvent& event)

Called when the button needs to be redrawn on the screen. This can occur when the button has just become visible or if the state of the button has changed.

You can override this function to change the way the button is displayed on the screen. The default implementation calls the functions drawBorder, drawBackground, drawForeground, and (if disabled) drawDisabledEmphasis, and then returns true.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes

AIX Considerations

To reduce the number of times the image must be drawn, the ICustomButtonDrawHandler implementation supplied with Open Class Library keeps a copy of the drawn image and supplies this image to the widget as the button label. The drawButton function is only called when the handler determines that the saved image is invalid due to a change to the ICustomButton.


[view class]
drawDisabledEmphasis
protected:
virtual void drawDisabledEmphasis( ICustomButtonDrawEvent& event )

Called to draw disabled emphasis for the button. You can override this function to change the way the button's disabled emphasis is drawn.

The default behavior is to use a halftone in the current drawing area.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
drawForeground
protected:
virtual void drawForeground(ICustomButtonDrawEvent& event)

Called to draw the foreground of the button. You can override this function to change the way the button's foreground is drawn.

The default behavior is to draw the custom button text with the foreground or latched foreground color.

This function examines the text for newline characters and flows the text to multiple lines.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


ICustomButtonDrawHandler - Inherited Member Functions and Data

Inherited Public Functions

IHandler

Inherited Public Data

Inherited Protected Functions

IHandler

Inherited Protected Data