home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gpbhdr.zip / GRBTNHDR.CPP
C/C++ Source or Header  |  1994-09-19  |  3KB  |  62 lines

  1. class AGraphicPushButtonResizeHandler : public IResizeHandler {
  2. typedef IResizeHandler
  3.   Inherited;
  4. /*******************************************************************************
  5. * The AGraphicPushButtonResizeHandler class handles the notification that an   *
  6. * IGraphicPushButton has been resized.                                         *
  7. *                                                                              *
  8. * A resizing event notifies a window or control that it has grown or shrunk    *
  9. * on the screen.  If the AGraphicPushButtonResizeHandler object is attached to *
  10. * an IGraphicPushButton control, it will be called to process the resizing event.*
  11. *                                                                              *
  12. * SGraphicPushButtonResizeHandler processes the resizing event by creating an  *
  13. * IResizeEvent object and routing it to the virtual windowResize function.  This*
  14. * virtual function automatically sizes the drawing window that makes up the    *
  15. * IGraphicPushButton control.
  16. *******************************************************************************/
  17. public:
  18. /*-------------------------- Constructor/Destructor ----------------------------
  19. | The only way to construct instances of this class is by using the default    |
  20. | constructor, which takes no arguments.                                       |
  21. ------------------------------------------------------------------------------*/
  22.   AGraphicPushButtonResizeHandler       ( );
  23. virtual
  24.  ~AGraphicPushButtonResizeHandler       ( );
  25.  
  26. protected:
  27. /*----------------------------- Event Processing -------------------------------
  28. |   windowResize - This handles the resizing event, by sizing the drawing      |
  29. |                  window portion of the IGraphicPushButton.                   |
  30. ------------------------------------------------------------------------------*/
  31. virtual Boolean
  32.   windowResize         ( IResizeEvent& event );
  33. }; // AGraphicPushButtonResizeHandler
  34.  
  35. /*******************************************************************/
  36. AGraphicPushButtonResizeHandler :: AGraphicPushButtonResizeHandler ( )
  37. {}
  38.  
  39. /*******************************************************************/
  40. AGraphicPushButtonResizeHandler :: ~AGraphicPushButtonResizeHandler ( )
  41. {}
  42.  
  43. /*******************************************************************/
  44. Boolean AGraphicPushButtonResizeHandler :: windowResize( IResizeEvent& evt )
  45. {
  46.   IGraphicPushButton* button = (IGraphicPushButton*)evt.window();
  47.   if (evt.oldSize() != evt.newSize() && !(button->isSizeToGraphic()))
  48.   {                               // Size change occurred
  49.      long inith  = 3,      //SPECIFY WHATEVER BORDER
  50.           initw  = 3,      //SIZE YOU WANT HERE!!!!!!!!!!!!
  51.           width  = -initw,
  52.           height = -inith;
  53.      if ((width += evt.newSize().width() ) < 0)
  54.         width = 0;
  55.      if ((height+= evt.newSize().height()) < 0)
  56.         height = 0;
  57.      button->graphicWindow().moveSizeTo(IRectangle(initw,inith,width,height));
  58.   }                               // End size change occurred
  59.   return true;
  60. }
  61.  
  62.