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

  1. #ifndef _ICNREEVT_
  2.    #define _ICNREEVT_
  3. /*******************************************************************************
  4. * FILE NAME: icnreevt.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     ICnrEditEvent                                                            *
  9. *     ICnrBeginEditEvent                                                       *
  10. *     ICnrEndEditEvent                                                         *
  11. *     ICnrReallocStringEvent                                                   *
  12. *                                                                              *
  13. * COPYRIGHT:                                                                   *
  14. *   (C) Copyright IBM Corporation 1992                                         *
  15. *   All Rights Reserved                                                        *
  16. *   Licensed Materials * Property of IBM                                       *
  17. *                                                                              *
  18. * HISTORY:                                                                     *
  19. *******************************************************************************/
  20.  
  21. #ifndef _ICNREVT_
  22.    #include <icnrevt.hpp>
  23. #endif
  24.  
  25. #ifndef _ISTRING_
  26.    #include <istring.hpp>
  27. #endif
  28.  
  29. /*----------------------------------------------------------------------------*/
  30. /* Align classes on four byte boundary.                                       */
  31. /*----------------------------------------------------------------------------*/
  32. #pragma pack(4)
  33.  
  34. //    Forward Declarations
  35. class IContainerObject;
  36. class IContainerControl;
  37. class IContainerColumn;
  38.  
  39.  
  40. class ICnrEditEvent : public ICnrEvent
  41. {
  42. typedef ICnrEvent Inherited;
  43. /*******************************************************************************
  44. * The ICnrEditEvent class forms the base of the container edit events.  These  *
  45. * events are dispatched during direct editing operations in the container.     *
  46. * An edit operation can be initiated by the user or by program control (see    *
  47. * IContainerControl::editObject, IContainerControl::editColumnTitle, and       *
  48. * IContainerControl::editContainerTitle).  Direct editing of a field in the    *
  49. * container is not allowed unless the field is set to "editable."  Whether     *
  50. * the container is editable is controlled by the following styles:             *
  51. *                                                                              *
  52. *   - IContainerControl::readOnly                                              *
  53. *   - IContainerColumn::readOnly                                               *
  54. *   - IContainerColumn::readOnlyHeading                                        *
  55. *                                                                              *
  56. * and the following functions:                                                 *
  57. *                                                                              *
  58. *   - IContainerObject::enableDataUpdate                                       *
  59. *   - IContainerObject::disableDataUpdate                                      *
  60. *                                                                              *
  61. * The ICnrEditEvent class and its subclasses provide information describing    *
  62. * the location in the container being edited, as well as describing the        *
  63. * contents of the data being edited.                                           *
  64. *******************************************************************************/
  65.  
  66. public:
  67. /*------------------------ Constructors ----------------------------------------
  68. | The only way to construct an instance of this class is from the              |
  69. | IControlEvent class.                                                         |
  70. ------------------------------------------------------------------------------*/
  71.   ICnrEditEvent  ( IControlEvent& event);
  72.  ~ICnrEditEvent  ( );
  73.  
  74. /*-------------------------------- Accessors -----------------------------------
  75. | These functions provide a means of getting and setting the accessible        |
  76. | attributes of instances of this class:                                       |
  77. |    isTitleWindow         - Returns true if the title is being edited.        |
  78. |    isLeftDetailsHeading  - Returns true if the left details heading is       |
  79. |                            being edited.                                     |
  80. |    isRightDetailsHeading - Returns true if the right details heading is      |
  81. |                            being edited.                                     |
  82. |    isDetailsData         - Returns true if data in a column of the details   |
  83. |                            view is being edited.                             |
  84. |    isLeftDetails         - Returns true if data in the left column of the    |
  85. |                            details view is being edited.                     |
  86. |    isRightDetails        - Returns true if data in the right column of the   |
  87. |                            details view is being edited.                     |
  88. |    object                - Returns the object being edited.  If the edit is  |
  89. |                            not object-related (for example, a title edit),   |
  90. |                            0 is returned.                                    |
  91. |    column                - Returns the column being edited.  If the edit is  |
  92. |                            not column-related (for example, a title edit),   |
  93. |                            0 is returned.                                    |
  94. |    container             - Returns the container in which the edit is taking |
  95. |                            place.                                            |
  96. ------------------------------------------------------------------------------*/
  97. Boolean
  98.   isTitleWindow() const,
  99.   isLeftDetailsHeading() const,
  100.   isRightDetailsHeading() const,
  101.   isDetailsData() const,
  102.   isLeftDetails() const,
  103.   isRightDetails() const;
  104.  
  105. IContainerObject
  106.  *object();
  107.  
  108. IContainerColumn
  109.  *column();
  110.  
  111. IContainerControl
  112.  *container();
  113.  
  114. protected:
  115. /*----------------------------- Implementation ---------------------------------
  116. | These functions are used to implement the class:                             |
  117. |    textRef    - Returns a pointer to the current text pointer for the        |
  118. |                 ICnrBeginEditEvent and ICnrReallocStringEvent events.  For   |
  119. |                 ICnrEndEditEvent, a pointer to the new text pointer is       |
  120. |                 returned.                                                    |
  121. |    textSize   - Returns the number of bytes in the text string (not counting |
  122. |                 the null termination) for the ICnrEndEditEvent and           |
  123. |                 ICnrReallocStringEvent events; otherwise, 0 is returned.     |
  124. ------------------------------------------------------------------------------*/
  125. char
  126.  **textRef();
  127.  
  128. unsigned long
  129.  textSize() const;
  130.  
  131. };
  132.  
  133.  
  134. class ICnrReallocStringEvent : public ICnrEditEvent
  135. {
  136. typedef ICnrEditEvent Inherited;
  137. /*******************************************************************************
  138. * The ICnrReallocStringEvent class is dispatched when text is edited in the    *
  139. * container and it is necessary to reallocate the storage for the text.        *
  140. *******************************************************************************/
  141. public:
  142. /*------------------------ Constructors ----------------------------------------
  143. | The only way to construct an instance of this class is from the              |
  144. | IControlEvent class.  ICnrReallocStringEvent is constructed by               |
  145. | ICnrEditHandler::dispatchHandlerEvent from an IControlEvent in response to   |
  146. | a notification from the container that text has changed and storage for the  |
  147. | text may need to be reallocated.                                             |
  148. ------------------------------------------------------------------------------*/
  149.   ICnrReallocStringEvent ( IControlEvent& event);
  150.  ~ICnrReallocStringEvent ( );
  151.  
  152. /*-------------------------------- Accessors -----------------------------------
  153. | These functions provide a means of getting and setting the accessible        |
  154. | attributes of instances of this class:                                       |
  155. |    currentText - Returns the current text stored in the edit field.          |
  156. |    newTextSize - Returns the size (not counting the null termination) of the |
  157. |                  storage that needs to be allocated to store the new text    |
  158. |                  string.                                                     |
  159. |    newText     - Returns the text the user added to the edit control.        |
  160. ------------------------------------------------------------------------------*/
  161. virtual IString
  162.   currentText(),
  163.   newText();
  164.  
  165. long
  166.   newTextSize();
  167.  
  168. /*------------------------------ Text Allocation -------------------------------
  169. | These functions reallocate the storage for the text field either by updating |
  170. | an IString or using operator new() for a char*:                              |
  171. |   reallocateString - Creates and stores an IString of the appropriate size   |
  172. |                      to hold the new data.                                   |
  173. |   reallocateText   - Calls global operator new to acquire storage of the     |
  174. |                      appropriate size to hold the new data.                  |
  175. ------------------------------------------------------------------------------*/
  176. void
  177.   reallocateString();
  178. void
  179.   reallocateText();
  180. };
  181.  
  182.  
  183. class ICnrBeginEditEvent : public ICnrEditEvent
  184. {
  185. typedef ICnrEditEvent Inherited;
  186. /*******************************************************************************
  187. * An ICnrBeginEditEvent event is dispatched to the ICnrEditHandler::beginEdit  *
  188. * function when an edit operation is initiated on one of the editable fields   *
  189. * of a container.  The event provides information about the text being         *
  190. * edited, as well as the type of text (heading, icon, or details view) being   *
  191. * edited.                                                                      *
  192. *******************************************************************************/
  193. public:
  194.  
  195. /*------------------------ Constructors ----------------------------------------
  196. | Instances of this class can only be constructed from an instance of the      |
  197. | IControlEvent class.  This typically occurs in the                           |
  198. | ICnrEditHandler::dispatchHandlerEvent function in response to a request to   |
  199. | begin an edit operation.  Such an occurrence is either as a result of user   |
  200. | action or under program control.                                             |
  201. ------------------------------------------------------------------------------*/
  202.   ICnrBeginEditEvent ( IControlEvent& event);
  203.  ~ICnrBeginEditEvent ( );
  204.  
  205. /*-------------------------------- Accessors -----------------------------------
  206. | This function provides a means of getting and setting the accessible         |
  207. | attributes of instances of this class:                                       |
  208. |    currentText        - Returns the current text stored in the edit field.   |
  209. ------------------------------------------------------------------------------*/
  210. IString
  211.   currentText();
  212.  };
  213.  
  214. class ICnrEndEditEvent : public ICnrEditEvent
  215. {
  216. typedef ICnrEditEvent Inherited;
  217. /*******************************************************************************
  218. * The ICnrEndEditEvent class is dispatched when text editing is complete.      *
  219. *******************************************************************************/
  220. public:
  221.  
  222. /*------------------------ Constructors ----------------------------------------
  223. | ICnrEndEditEvent is constructed by ICnrEditHandler::dispatchHandlerEvent     |
  224. | from an IControlEvent in response to a notification from the container that  |
  225. | direct editing has ended.                                                    |
  226. ------------------------------------------------------------------------------*/
  227.   ICnrEndEditEvent ( IControlEvent& evt);
  228.  ~ICnrEndEditEvent ( );
  229.  
  230. /*-------------------------------- Accessors -----------------------------------
  231. | This function provides a means of getting and setting the accessible         |
  232. | attributes of instances of this class:                                       |
  233. |    newText       - Returns text entered by the user in the edit field.       |
  234. |    currentText   - Returns the current text stored in the container.         |
  235. |                                                                              |
  236. |                    If ICnrReallocStringEvent::reallocateString returns true, |
  237. |                    indicating that the text was reallocated, then the text   |
  238. |                    that is returned will be the text entered by the user in  |
  239. |                    the edit field.                                           |
  240. |                                                                              |
  241. |                    If ICnrReallocStringEvent::reallocateString returns       |
  242. |                    false, indicating that the text was not reallocated, then |
  243. |                    the text that is returned will be the text that was in    |
  244. |                    the edit field before the edit operation began.           |
  245. ------------------------------------------------------------------------------*/
  246. IString
  247.   newText(),
  248.   currentText();
  249.  
  250. private:
  251. friend class ICnrEditHandler;
  252. IString
  253.   strNewText;
  254. };
  255.  
  256. /*----------------------------------------------------------------------------*/
  257. /* Resume compiler default packing.                                           */
  258. /*----------------------------------------------------------------------------*/
  259. #pragma pack()
  260.  
  261. #endif
  262.