home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IEDITHDR.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  9KB  |  139 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. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _IHANDLER_
  19.   #include <ihandler.hpp>
  20. #endif
  21. #ifndef _ICTLEVT_
  22.   #include <ictlevt.hpp>
  23. #endif
  24.  
  25. /*----------------------------------------------------------------------------*/
  26. /* Align classes on four byte boundary.                                       */
  27. /*----------------------------------------------------------------------------*/
  28. #pragma pack(4)
  29.  
  30. // Forward declarations for other classes:
  31. class IEvent;
  32.  
  33.  
  34. class IEditHandler : public IHandler {
  35. typedef IHandler
  36.   Inherited;
  37. /*******************************************************************************
  38. * The IEditHandler class handles the processing of input change events for     *
  39. * the following controls:                                                      *
  40. *   - IComboBox                                                                *
  41. *   - IEntryField                                                              *
  42. *   - IMultiLineEdit                                                           *
  43. *   - IProgressIndicator                                                       *
  44. *   - ISlider                                                                  *
  45. *   - ISpinButton                                                              *
  46. *                                                                              *
  47. * The IEditHandler class is designed to handle events that result from a user  *
  48. * changing a control's input value, such as changing the value of an entry     *
  49. * field or moving the arm of a slider.                                         *
  50. *                                                                              *
  51. * An IEditHandler object should be attached to the control whose input will be *
  52. * changed, or to the owner window of the control.  You can do this by passing  *
  53. * the control window or owner window on the handleEventsFor function of the    *
  54. * IEditHandler object.                                                         *
  55. *                                                                              *
  56. * When it receives an input change event, the IEditHandler object creates an   *
  57. * IControlEvent object and routes it to the appropriate virtual function.  You *
  58. * can override the virtual functions of IEditHandler to supply your own        *
  59. * specialized processing of an event.  The return value from the virtual       *
  60. * functions specifies whether the IControlEvent should be passed on for        *
  61. * additional processing, as follows:                                           *
  62. *                                                                              *
  63. *   Value   Meaning                                                            *
  64. *   ---------------                                                            *
  65. *   true  - The IControlEvent requires no additional processing.               *
  66. *   false - The IControlEvent should be passed to the next handler for         *
  67. *           additional processing, as follows:                                 *
  68. *           -- If there is another handler for the control or window, the      *
  69. *              IControlEvent is passed on to the next handler.                 *
  70. *           -- If this is the last handler for the control, the                *
  71. *              IControlEvent is dispatched to the owner window of the control. *
  72. *              (See IWindow::dispatch.)                                        *
  73. *           -- If this is the last handler for the owner window, the           *
  74. *              IControlEvent is passed on a call to the owner's                *
  75. *              defaultProcedure function.  (See IWindow::defaultProcedure.)    *
  76. *                                                                              *
  77. * Example:                                                                     *
  78. *   MyWindow::MyWindow()                                                       *
  79. *     : ...                                                                    *
  80. *   {                                                                          *
  81. *     MyReqEntryEditHandler* edh = new MyReqEntryEditHandler();                *
  82. *     ...                                                                      *
  83. *     IEntryField* ef = new IEntryField(ID_EF, this, this, IRectangle(...));   *
  84. *     edh->handleEventsFor(ef);                                                *
  85. *     ...                                                                      *
  86. *     show();                                                                  *
  87. *   }                                                                          *
  88. *   Boolean  MyReqEntryEditHandler::edit(IControlEvent& ctlevt)                *
  89. *   {                                                                          *
  90. *     IEntryField* ef = (IEntryField*)ctlevt.controlWindow();                  *
  91. *     IString str = ef->text();                                                *
  92. *     if (str.strip().length() == 0)                                           *
  93. *     {                        // required value missing                       *
  94. *        // disable Enter pushbutton                                           *
  95. *     }                                                                        *
  96. *     else                                                                     *
  97. *     {                        // required value specified                     *
  98. *        // enable Enter pushbutton                                            *
  99. *     }                                                                        *
  100. *     ...                                                                      *
  101. *     return false;            // let another handle event also                *
  102. *   }                                                                          *
  103. *******************************************************************************/
  104. public:
  105. /*-------------------------- Constructor/Destructor ----------------------------
  106. | This class only provides a default constructor, which does not take any      |
  107. | arguments.                                                                   |
  108. ------------------------------------------------------------------------------*/
  109.   IEditHandler         ( );
  110. virtual
  111.  ~IEditHandler         ( );
  112.  
  113. protected:
  114. /*---------------------------- Event Dispatching -------------------------------
  115. | This function evaluates the event to determine if it is appropriate for      |
  116. | this handler object to process.  If it is, this function calls the virtual   |
  117. | function used to process the event.                                          |
  118. |   dispatchHandlerEvent - Calls the edit function if an input change event    |
  119. |                          is found.                                           |
  120. ------------------------------------------------------------------------------*/
  121. virtual Boolean
  122.   dispatchHandlerEvent ( IEvent& event );
  123.  
  124. /*----------------------------- Event Processing -------------------------------
  125. | This function must be supplied by a derived class to process an input change |
  126. | event.                                                                       |
  127. |   edit - Implemented by the derived classes to process input change events.  |
  128. ------------------------------------------------------------------------------*/
  129. virtual Boolean
  130.   edit                 ( IControlEvent& event ) = 0;
  131. }; // IEditHandler
  132.  
  133. /*----------------------------------------------------------------------------*/
  134. /* Resume compiler default packing.                                           */
  135. /*----------------------------------------------------------------------------*/
  136. #pragma pack()
  137.  
  138. #endif /* _IEDITHDR_ */
  139.