### 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.

~ICustomButtonDrawHandler

      public:
      virtual ~ICustomButtonDrawHandler()

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

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.

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.

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

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

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.

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

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

  -     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)

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  IHandler

  -     virtual IEventResult defaultProcedure(IEvent& event)

  -     virtual bool dispatchHandlerEvent(IEvent& event) = 0

#### Inherited Protected Data

  - None