home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / clipbrd / clipbrd.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  5.7 KB  |  139 lines

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