home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / ifocshdr.hp_ / IFOCSHDR.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  7.7 KB  |  125 lines

  1. #ifndef _IFOCSHDR_
  2.   #define _IFOCSHDR_
  3. /*******************************************************************************
  4. * FILE NAME: ifocshdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IFocusHandler - Process a focus change event for a control.              *
  9. *                                                                              *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   Licensed Materials - Property of IBM                                       *
  13. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  14. *   All Rights Reserved                                                        *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *$Log:   S:/ibmclass/ibaseapp/vcs/ifocshdr.hpv  $                                                                         *
  19. // 
  20. //    Rev 1.25   26 Oct 1992 01:51:54   tsuji
  21. // Edit of comments.
  22. //
  23. //    Rev 1.24   25 Oct 1992 16:57:04   nunn
  24. // changed library name to ICLUI
  25. //
  26. //    Rev 1.23   25 Oct 1992 14:43:24   tsuji
  27. // Update class description.
  28. //
  29. //    Rev 1.22   24 Oct 1992 17:14:10   tsuji
  30. // Format/document in the style of the standard header file.
  31. *******************************************************************************/
  32. #ifndef _IHANDLER_
  33.   #include <ihandler.hpp>
  34. #endif
  35.  
  36. // Forward declarations for other classes:
  37. class IFocusHandler;  /* fch */
  38. class IControlEvent;
  39. class IEvent;
  40.  
  41.  
  42. class IFocusHandler : public IHandler {
  43. /*******************************************************************************
  44. * This class handles processing of focus change events for the following       *
  45. * controls: IContainerControl, IEntryField, IListBox, IMLE,                    *
  46. * IProgressIndicator, ISlider, and ISpinButton.                                *
  47. *                                                                              *
  48. * The IFocusHandler class is designed to handle events resulting from a        *
  49. * control's gaining or losing the input focus (for example, when the user tabs *
  50. * to/from an entry field).  If registered to the appropriate window (by being  *
  51. * passed on the addHandler() function of the control or the owner window of    *
  52. * the control), the IFocusHandler object will be called to process the focus   *
  53. * change event.  It does this by creating an IControlEvent object and routing  *
  54. * it to the appropriate virtual function (these virtual functions allow you to *
  55. * supply your own specialized processing of the event).  The return value from *
  56. * the virtual functions specifies if the IControlEvent should be passed on to  *
  57. * another handler object to be processed, as described below:                  *
  58. *                                                                              *
  59. *   Value  Meaning                                                             *
  60. *   ------ --------                                                            *
  61. *   true   The IControlEvent has been handled and requires no additional       *
  62. *          processing.                                                         *
  63. *   false  The IControlEvent should be passed to the next handler (if this is  *
  64. *          the last handler for the control it should be passed on to the      *
  65. *          first handler of the owner for the control, and if the last handler *
  66. *          for the owner window it should be passed on to the default window   *
  67. *          procedure).                                                         *
  68. *                                                                              *
  69. * EXAMPLE:                                                                     *
  70. *   MyWindow::MyWindow()   // inherits from IFrame, IFocusHandler              *
  71. *     : ...                                                                    *
  72. *   {                                                                          *
  73. *     addHandler((IHandler*)this);                                             *
  74. *     ...                                                                      *
  75. *     IEntryField* ef = new IEntryField(ID_EF, this, this, IRectangle(...));   *
  76. *     IStaticText* stxtHelp = new IStaticText(0, this, this, IRectangle(...)); *
  77. *     ...                                                                      *
  78. *     show();                                                                  *
  79. *   }                                                                          *
  80. *   Boolean  MyWindow::gotFocus(IControlEvent& evt)                            *
  81. *   {                    // provide quick help for current owned control       *
  82. *     if (evt.controlId() == ID_EF)                                            *
  83. *     {                        // entry field gaining focus                    *
  84. *        stxtHelp->setText("Please give your full name.");                     *
  85. *     }                                                                        *
  86. *     ...                                                                      *
  87. *     else                                                                     *
  88. *     {                        // some other control                           *
  89. *        stxtHelp->setText(" ");  // no help for this one                      *
  90. *     }                                                                        *
  91. *     ...                                                                      *
  92. *     return false;            // let another handle event also                *
  93. *   }                                                                          *
  94. *******************************************************************************/
  95. typedef IHandler Inherited;
  96. public:
  97. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  98. | There is 1 way to construct instances of this class:                         |
  99. |   1. default constructor                                                     |
  100. ------------------------------------------------------------------------------*/
  101.   IFocusHandler ( ) {;}
  102.  
  103. /*----------------------- EVENT DISPATCHING INTERFACE --------------------------
  104. | This function evaluates the event to determine if it is one appropriate for  |
  105. | this handler object to process.  If so it calls a virtual function used to   |
  106. | process the event.                                                           |
  107. |   dispatchHandlerEvent - invokes gotFocus or lostFocus as appropriate        |
  108. ------------------------------------------------------------------------------*/
  109. Boolean
  110.   dispatchHandlerEvent ( IEvent& evt );
  111.  
  112. protected:
  113. /*------------------------ EVENT PROCESSING FUNCTIONS --------------------------
  114. | These functions should be supplied by a derived class in order to provide    |
  115. | processing for a selection or enter event.                                   |
  116. |   gotFocus  - function used to process a focus gain event                    |
  117. |   lostFocus - function used to process a focus loss event                    |
  118. ------------------------------------------------------------------------------*/
  119. virtual Boolean
  120.   gotFocus  ( IControlEvent& evt ) { return false; }
  121. virtual Boolean
  122.   lostFocus ( IControlEvent& evt ) { return false; }
  123. };
  124. #endif /* IFOCSHDR */
  125.