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:
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.
![]() |
public:
virtual ~ICustomButtonDrawHandler()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
ICustomButtonDrawHandler()
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 ICustomButtonDrawHandler object processes only custom button draw events.
![]() |
protected:
virtual bool dispatchHandlerEvent(IEvent& event)
Calls the appropriate virtual function or functions to process a custom button draw event.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Event-processing members provide information about handling events.
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
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:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
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.
![]() |
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.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
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.
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