home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / ICNREHDR.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  9KB  |  178 lines

  1. #ifndef _ICNREHDR_
  2.   #define _ICNREHDR_
  3. /*******************************************************************************
  4. * FILE NAME: icnrehdr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     ICnrEditHandler                                                          *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   (C) Copyright IBM Corporation 1992                                         *
  12. *   All Rights Reserved                                                        *
  13. *   Licensed Materials * Property of IBM                                       *
  14. *                                                                              *
  15. * HISTORY:                                                                     *
  16. *******************************************************************************/
  17.  
  18. #ifndef _IHANDLER_
  19.   #include <ihandler.hpp>
  20. #endif
  21.  
  22. #ifndef _ICNREEVT_
  23.   #include <icnreevt.hpp>
  24. #endif
  25.  
  26. /*----------------------------------------------------------------------------*/
  27. /* Align classes on four byte boundary.                                       */
  28. /*----------------------------------------------------------------------------*/
  29. #pragma pack(4)
  30.  
  31. class IHandlerWindow;
  32. class IWindowHandle;
  33. class IMultiLineEdit;
  34.  
  35. class ICnrEditHandler : public IHandler
  36. {
  37. typedef IHandler Inherited;
  38. /*******************************************************************************
  39. * The ICnrEditHandler class supports direct editing of data in the container.  *
  40. *******************************************************************************/
  41. public:
  42.  
  43. /*----------------------- Related Types  ---------------------------------------
  44. | The following ICnrEditHandler types are defined:                             |
  45. |   StringType         - Identifies the real type of user data in the details  |
  46. |                        view of the container:                                |
  47. |      isIString          - The data is an instance of the IString class.      |
  48. |      isCharacterPointer - The data is a pointer to a character (char*).      |
  49. ------------------------------------------------------------------------------*/
  50. enum StringType { isIString, isCharacterPointer };
  51.  
  52.  
  53. /*------------------------ Constructors ----------------------------------------
  54. | The only way to construct an instance of this class is by providing the type |
  55. | of the user data that needs to be edited.  The data can be one of the        |
  56. | following types:
  57. |
  58. |   - isIString, in which the user data is an IString.  This is the
  59. |     recommended form of text.
  60. |   - isCharacterPointer, in which the data is a pointer to a NULL-terminated
  61. |     character array (char*).
  62. |
  63. | The default behavior of this class provides for the reallocation of the
  64. | user data.  The default behavior of this class also manages the allocation
  65. | of other tpes of editable data, such as:
  66. |
  67. |   - Icon text
  68. |   - Container title
  69. |   - Details view column headings
  70. ------------------------------------------------------------------------------*/
  71.   ICnrEditHandler    (StringType   stringType = isIString);
  72.  ~ICnrEditHandler    ( );
  73.  
  74. /*------------------------ Event Processing Functions --------------------------
  75. | These functions must be supplied by a derived class in order to provide      |
  76. | processing for an edit event:                                                |
  77. |  beginEdit        - Called when an edit window has been opened in the        |
  78. |                     container.  The default behavior is to create an         |
  79. |                     instance of an IMultiLineEdit by calling the             |
  80. |                     multiLineEdit function.  If the setMLEHandler function   |
  81. |                     was previously called to store an edit handler, the      |
  82. |                     handler will be added to the multiple-line entry field   |
  83. |                     (MLE) control.                                           |
  84. |                     NOTE: If this function is overridden in a subclass, you  |
  85. |                           must call the library version of this function     |
  86. |                           before adding any behavior.  Other handler         |
  87. |                           functions do not work correctly before this        |
  88. |                           function is called.                                |
  89. |  reallocateString - Called when text has been modified in the container and  |
  90. |                     storage needs to be reallocated.  If the data is an      |
  91. |                     IString, the reallocation is provided by calling the     |
  92. |                     ICnrReallocStringEvent::reallocateString function.  If   |
  93. |                     the type of the data is isCharacterPointer, the          |
  94. |                     reallocation is provided by calling the                  |
  95. |                     ICnrReallocStringEvent::reallocateText function.         |
  96. |  endEdit          - Called when editing has ended.  This is received after   |
  97. |                     the reallocateString function is called.                 |
  98. |                     NOTE: If this function is overridden in a subclass, you  |
  99. |                           must call the library version of this function     |
  100. |                           after adding any behavior.  Some handler           |
  101. |                           functions do not work correctly after this         |
  102. |                           function is called.                                |
  103. |  isDataIString    - Returns true if the user data is type IString.           |
  104. ------------------------------------------------------------------------------*/
  105. virtual Boolean
  106.   beginEdit            ( ICnrBeginEditEvent&     event),
  107.   reallocateString     ( ICnrReallocStringEvent& event),
  108.   endEdit              ( ICnrEndEditEvent&       event);
  109.  
  110. Boolean
  111.   isDataIString        ( );
  112.  
  113. /*---------------------------- Window Attachment -------------------------------
  114. | These functions permit attaching and detaching the handler object to and from|
  115. | a container window:                                                          |
  116. |   handleEventsFor       - Attaches the handler to the container control      |
  117. |                           passed in the argument.                            |
  118. |   stopHandlingEventsFor - Detaches the handler from the container control    |
  119. |                           passed in the argument.                            |
  120. ------------------------------------------------------------------------------*/
  121. virtual ICnrEditHandler
  122.  &handleEventsFor       ( IContainerControl* container ),
  123.  &stopHandlingEventsFor ( IContainerControl* container );
  124.  
  125.  
  126.  
  127. /*---------------------------- Multiple-Line Edit Processing -------------------
  128. | The following functions are used to enable processing of events to the       |
  129. | container's edit field:                                                      |
  130. |  setMLEHandler  - Stores a handler to be added to the multiple-line entry    |
  131. |                   field control when that control is created.                |
  132. |  multiLineEdit  - Called to return an IMultiLineEdit "wrapper."  This        |
  133. |                   function can be overridden to specialize the edit control. |
  134. |  mleHandler     - Called to return the handler for a multiple-line entry     |
  135. |                   field. If a handler has not been provided, 0 is returned.  |
  136. ------------------------------------------------------------------------------*/
  137. void
  138.   setMLEHandler        ( IHandler*  anMLEHandler);
  139.  
  140. virtual IMultiLineEdit
  141.  *multiLineEdit        ( const IWindowHandle& handleMultiLineEdit);
  142.  
  143. IHandler
  144.  *mleHandler           ( ) const;
  145.  
  146. protected:
  147. /*----------------------------- Implementation ---------------------------------
  148. | This function is used to implement the class:                                |
  149. |   dispatchHandlerEvent - Routes the edit events to the appropriate event     |
  150. |                          functions.                                          |
  151. ------------------------------------------------------------------------------*/
  152. virtual Boolean
  153.   dispatchHandlerEvent ( IEvent& event);
  154.  
  155.  
  156. private:
  157. IHandler
  158.  *_phdrMLE;
  159. int _stringType;
  160.  
  161. /* Hidden functions */
  162. virtual IHandler
  163.  &handleEventsFor       ( IWindow* window  ),
  164.  &stopHandlingEventsFor ( IWindow* window  );
  165. };
  166.  
  167. /*----------------------------------------------------------------------------*/
  168. /* Resume compiler default packing.                                           */
  169. /*----------------------------------------------------------------------------*/
  170. #pragma pack()
  171.  
  172. /*--------------------------------- INLINES ----------------------------------*/
  173. #ifndef I_NO_INLINES
  174.   #include <icnrehdr.inl>
  175. #endif
  176.  
  177. #endif
  178.