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

  1. #ifndef _IEDITHDR_
  2.   #define _IEDITHDR_
  3. /*******************************************************************************
  4. * FILE NAME: iedithdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IEditHandler - Process an input 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:   R:/IBMCLASS/IBASEAPP/VCS/IEDITHDR.HPV  $                                                                         *
  19. // 
  20. //    Rev 1.24   25 Oct 1992 16:57:00   nunn
  21. // changed library name to ICLUI
  22. // 
  23. //    Rev 1.23   25 Oct 1992 14:43:12   tsuji
  24. // Update class description.
  25. //
  26. //    Rev 1.22   24 Oct 1992 17:12:56   tsuji
  27. // Format/document in style of the standard header file.
  28. *******************************************************************************/
  29. #ifndef _IHANDLER_
  30.   #include <ihandler.hpp>
  31. #endif
  32.  
  33. // Forward declarations for other classes:
  34. class IEditHandler;  /* edh */
  35. class IControlEvent;
  36. class IEvent;
  37.  
  38. class IEditHandler : public IHandler {
  39. /*******************************************************************************
  40. * This class handles processing of input change events for the following       *
  41. * controls: IComboBox, IEntryField, IMLE, IProgressIndicator, ISlider, and     *
  42. * ISpinButton.                                                                 *
  43. *                                                                              *
  44. * The IEditHandler class is designed to handle events resulting from a user    *
  45. * changing a control's input value (for example, changing the value of an      *
  46. * entry field).  If registered to the appropriate window (by being passed on   *
  47. * the addHandler() function of the control or the owner window of the          *
  48. * control), the IEditHandler object will be called to process the input change *
  49. * event.  It does this by creating an IControlEvent object and routing it to   *
  50. * the virtual edit() function (this virtual function allows you to supply your *
  51. * own specialized processing of the event).  The return value from the virtual *
  52. * function specifies if the IControlEvent should be passed on to another       *
  53. * handler object to be processed, as described below:                          *
  54. *                                                                              *
  55. *   Value  Meaning                                                             *
  56. *   ------ --------                                                            *
  57. *   true   The IControlEvent has been handled and requires no additional       *
  58. *          processing.                                                         *
  59. *   false  The IControlEvent should be passed to the next handler (if this is  *
  60. *          the last handler for the control it should be passed on the first   *
  61. *          handler of the owner for the control, and if the last handler for   *
  62. *          the owner window it should be passed on the default window          *
  63. *          procedure).                                                         *
  64. *                                                                              *
  65. * EXAMPLE:                                                                     *
  66. *   MyWindow::MyWindow()                                                       *
  67. *     : ...                                                                    *
  68. *   {                                                                          *
  69. *     MyReqEntryEditHandler* edh = new MyReqEntryEditHandler();                *
  70. *     ...                                                                      *
  71. *     IEntryField* ef = new IEntryField(ID_EF, this, this, IRectangle(...));   *
  72. *     ef->addHandler(edh);                                                     *
  73. *     ...                                                                      *
  74. *     show();                                                                  *
  75. *   }                                                                          *
  76. *   Boolean  MyReqEntryEditHandler::edit(IControlEvent& evt)                   *
  77. *   {                                                                          *
  78. *     Boolean bProcessed = false;                                              *
  79. *     IEntryField* ef = (IEntryField*)ctlevt.controlWindow();                  *
  80. *     IString str = ef->text();                                                *
  81. *     if (str.strip().length() == 0)                                           *
  82. *     {                        // required value missing                       *
  83. *        // disable Enter pushbutton                                           *
  84. *     }                                                                        *
  85. *     else                                                                     *
  86. *     {                        // required value specified                     *
  87. *        // enable Enter pushbutton                                            *
  88. *     }                                                                        *
  89. *     ...                                                                      *
  90. *     return bProcessed;       // let another handle event also                *
  91. *   }                                                                          *
  92. *******************************************************************************/
  93. typedef IHandler Inherited;
  94. public:
  95. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  96. | There is 1 way to construct instances of this class:                         |
  97. |   1. default constructor                                                     |
  98. ------------------------------------------------------------------------------*/
  99.   IEditHandler ( ) {;}
  100.  
  101. /*----------------------- EVENT DISPATCHING INTERFACE --------------------------
  102. | This function evaluates the event to determine if it is one appropriate for  |
  103. | this handler object to process.  If so it calls the virtual function used to |
  104. | process the event.                                                           |
  105. |   dispatchHandlerEvent - invokes the edit function if input change event     |
  106. ------------------------------------------------------------------------------*/
  107. Boolean
  108.   dispatchHandlerEvent ( IEvent& evt );
  109.  
  110. protected:
  111. /*------------------------ EVENT PROCESSING FUNCTIONS --------------------------
  112. | This function must be supplied by a derived class in order to provide        |
  113. | processing for an input change event.                                        |
  114. |   edit    - function used to process the input change event                  |
  115. ------------------------------------------------------------------------------*/
  116. virtual Boolean
  117.   edit     ( IControlEvent& evt ) = 0;
  118. };
  119. #endif /* IEDITHDR */
  120.