home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / CLIPBRD / CLIPBRD.HPP < prev    next >
Text File  |  1995-05-01  |  5KB  |  129 lines

  1. #ifndef _CLIPBRD_
  2.   #define _CLIPBRD
  3. /******************************************************************************/
  4. /* Clipboard Sample Program:                                                  */
  5. /*                                                                            */
  6. /* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
  7. /*                                                                            */
  8. /* DISCLAIMER OF WARRANTIES:                                                  */
  9. /*   The following [enclosed] code is sample code created by IBM              */
  10. /*   Corporation.  This sample code is not part of any standard IBM product   */
  11. /*   and is provided to you solely for the purpose of assisting you in the    */
  12. /*   development of your applications.  The code is provided "AS IS",         */
  13. /*   without warranty of any kind.  IBM shall not be liable for any damages   */
  14. /*   arising out of your use of the sample code, even if they have been       */
  15. /*   advised of the possibility of such damages.                              */
  16. /******************************************************************************/
  17. #include <icliphdr.hpp>
  18. #include <icmdhdr.hpp>
  19. #include <istring.hpp>
  20. #include <icnr.hpp>
  21.  
  22.  
  23. //**************************************************************************
  24. // Class:   Department                                                     *
  25. //                                                                         *
  26. // Purpose: Defines the data stored in the container for a Department.     *
  27. //                                                                         *
  28. //**************************************************************************
  29. class Department : public IContainerObject {
  30. public:
  31.   Department ( const IString& name=IString(),
  32.                const IString& address=IString()) 
  33.      : IContainerObject (name),
  34.        strAddress(address) {}
  35.  
  36. // Add functions to query and set the data.
  37. virtual IString    
  38.  name       ( ) const,
  39.  address    ( ) const;
  40.  
  41. virtual Department
  42.  &setName    ( const IString& name),
  43.  &setAddress ( const IString& address);
  44.  
  45. // Define the functions to render an object both as a
  46. // private format and as a normal text string, and to 
  47. // re-construct the object from the private format. 
  48. IString
  49.  asString        ( ) const,
  50.  text            ( ) const;
  51. Department
  52.  &initializeFromString  ( const IString& renderedString);
  53.  
  54. // Define the separator character (a tilde) that separates 
  55. // the fields of the object in its string format. 
  56. static const IString
  57.  separator,
  58.  renderedFormat;
  59.  
  60. // Define a function to return the offset of the Address field.
  61. static unsigned long
  62.  offsetOfAddress ( ) { return offsetof(Department, strAddress); }
  63.  
  64.  
  65.  
  66. private:
  67. IString
  68.   strAddress;
  69. };
  70.  
  71. class ICnrObjectSet;
  72.  
  73. //**************************************************************************
  74. // Class:   ContainerCutPasteHandler                                       *
  75. //                                                                         *
  76. // Purpose: Adds Clipboard support to the container for a Department       *
  77. //          object.  This includes:                                        *
  78. //          1) A container menu handler to show a popup menu with          *
  79. //             cut, copy, and paste choices.                               *
  80. //          2) A command handler to process the cut, copy, and paste       *
  81. //             requests.                                                   *
  82. //          3) A clipboard handler to process requests from the clipboard  *
  83. //             to render data not yet on the clipboard.                    *
  84. //**************************************************************************
  85. class ContainerCutPasteHandler : public ICommandHandler,
  86.                                  public ICnrMenuHandler,
  87.                                  public IClipboardHandler {
  88. public:
  89. ContainerCutPasteHandler (IContainerControl& container);
  90.  
  91. IContainerControl
  92.  &container  ( ) { return cnr; }
  93.  
  94. protected:
  95. // Define the command handler callback.
  96. virtual Boolean
  97.   command ( ICommandEvent& event);
  98.  
  99. // Define the popup menu callback.
  100. Boolean 
  101.   makePopUpMenu(IMenuEvent& cnEvt);
  102.  
  103. // Define the callbacks to render data on the
  104. // clipboard.
  105. virtual Boolean
  106.   clipboardEmptied     ( IEvent&        event ),
  107.   renderFormat         ( IEvent&        event, 
  108.                          const IString& format),
  109.   renderAllFormats     ( IEvent&        event);
  110.  
  111. // Define a string object to use as a separator between fields
  112. // for the private format.
  113. static const IString
  114.  separator;
  115.  
  116.  
  117. private:
  118. IContainerControl
  119.  &cnr;
  120. ICnrObjectSet
  121.  *objectList;
  122. /*------------- Hidden Functions ---------------------------*/
  123. ContainerCutPasteHandler (const ContainerCutPasteHandler&);
  124. ContainerCutPasteHandler& operator=(const ContainerCutPasteHandler&);
  125.  
  126. };
  127.  
  128. #endif
  129.