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

  1. /******************************************************************************
  2. * .FILE: acnr.hpp                                                             *
  3. *                                                                             *
  4. * .DESCRIPTION: Container sample application - Class defintions               *
  5. *                                                                             *
  6. * .CLASSES:                                                                   *
  7. *   ACnrexWindow                                                              *
  8. *   ACommandHandler                                                           *
  9. *   Department                                                                *
  10. *   ADepartmentView                                                           *
  11. *   ACnrHandler                                                               *
  12. *   ACnrMenuHandler                                                           *
  13. *                                                                             *
  14. * .COPYRIGHT:                                                                 *
  15. *    Licensed Material - Program-Property of IBM                              *
  16. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  17. *                                                                             *
  18. * .DISCLAIMER:                                                                *
  19. *   The following [enclosed] code is sample code created by IBM               *
  20. *   Corporation.  This sample code is not part of any standard IBM product    *
  21. *   and is provided to you solely for the purpose of assisting you in the     *
  22. *   development of your applications.  The code is provided 'AS IS',          *
  23. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  24. *   arising out of your use of the sample code, even if they have been        *
  25. *   advised of the possibility of such damages.                               *
  26. *                                                                             *
  27. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  28. ******************************************************************************/
  29. #ifndef ACNR_HPP
  30. #define ACNR_HPP
  31.  
  32. #include <iframe.hpp>
  33. #include <icmdhdr.hpp>
  34. #include <icnrctl.hpp>
  35. #include <icnrhdr.hpp>
  36. #include <icnrehdr.hpp>
  37. #include <icnrmhdr.hpp>
  38. #include <imenuevt.hpp>
  39.  
  40. class ACnrexWindow;
  41.  
  42.  
  43. /******************************************************************************
  44. * Class ACnrMenuHandler - Container menu handler                              *
  45. ******************************************************************************/
  46. class ACnrMenuHandler: public ICnrMenuHandler
  47. {
  48.   public:
  49. /*------------------------ Constructors/Destructor ----------------------------
  50. | Construct the object in only one way:                                       |
  51. | 1) Parameter for IContainerControl                                          |
  52. -----------------------------------------------------------------------------*/
  53.     ACnrMenuHandler( IContainerControl* cnr ) { pcnr = cnr; };
  54.  
  55.   protected:
  56.     virtual Boolean
  57.       makePopUpMenu( IMenuEvent& event );
  58.  
  59.   private:
  60.     IContainerControl
  61.      *pcnr;
  62. };
  63.  
  64.  
  65. /******************************************************************************
  66. * Class ACommandHandler - Command handler                                     *
  67. ******************************************************************************/
  68. class ACommandHandler: public ICommandHandler
  69. {
  70.   public:
  71. /*------------------------ Constructors/Destructor ----------------------------
  72. | Construct the object in only one way:                                       |
  73. | 1) Parameters for ACnrexWindow, IMenuBar, IContainerColumns                 |
  74. -----------------------------------------------------------------------------*/
  75.     ACommandHandler( ACnrexWindow* window,
  76.                      IMenuBar* menubar,
  77.                      IContainerControl* cnr,
  78.                      IContainerColumn* nameColumn,
  79.                      IContainerColumn* codeColumn,
  80.                      IContainerColumn* addrColumn );
  81.  
  82.   protected:
  83.     virtual Boolean
  84.       command( ICommandEvent& event );
  85.  
  86.   private:
  87.     ACnrexWindow
  88.      *pwin;
  89.     IContainerControl
  90.      *pcnr;
  91.     IMenuBar
  92.      *pmenu;
  93.     IContainerColumn
  94.      *pcolName,
  95.      *pcolCode,
  96.      *pcolAddr;
  97. };
  98.  
  99.  
  100. /******************************************************************************
  101. * Class ACnrHandler - Container handler                                       *
  102. ******************************************************************************/
  103. class ACnrHandler: public ICnrHandler
  104. {
  105.   public:
  106. /*------------------------ Constructors/Destructor ----------------------------
  107. | Construct the object in only one way:                                       |
  108. | 1) No parameters                                                            |
  109. -----------------------------------------------------------------------------*/
  110.     ACnrHandler() {};
  111. };
  112.  
  113.  
  114. /******************************************************************************
  115. * Class ACnrEditHandler - Container edit handler                              *
  116. ******************************************************************************/
  117. class ACnrEditHandler: public ICnrEditHandler
  118. {
  119.   public:
  120. /*------------------------ Constructors/Destructor ----------------------------
  121. | Construct the object in only one way:                                       |
  122. | 1) No parameters                                                            |
  123. -----------------------------------------------------------------------------*/
  124.     ACnrEditHandler() {};
  125. };
  126.  
  127.  
  128. /******************************************************************************
  129. * Class Department - Describes a department record                            *
  130. ******************************************************************************/
  131. class Department : public IContainerObject
  132. {
  133.   friend class IContainerColumn;
  134.   friend class ACnrexWindow;
  135.  
  136.   public:
  137.  
  138.     Department( const IString& Name,
  139.                 const IPointerHandle& Icon,
  140.                 const IString& Code,
  141.                 const IString& Address );
  142.  
  143. /*------------------------------- Accessors -----------------------------------
  144. | These functions provide a means of getting and setting the accessible       |
  145. | attributes of instances of this class:                                      |
  146. |   Code                - Returns the Code string                             |
  147. |   Address             - Returns the Address string                          |
  148. |   setCode             - Sets the code to the given address                  |
  149. |   setAddress          - Sets the address to the given address               |
  150. -----------------------------------------------------------------------------*/
  151.     IString
  152.       Code() const {  return strCode; };
  153.     IString
  154.       Address() const {  return strAddress; };
  155.     Department
  156.      &setCode( IString code ) { strCode = code; return *this; };
  157.     Department
  158.      &setAddress( IString address ) { strAddress = address; return *this; };
  159.  
  160.  
  161. /*----------------------------- Handler Callbacks -----------------------------
  162. | These functions provide a means of processing handler callbacks:            |
  163. |   handleOpen          - Handle opening a container object request           |
  164. -----------------------------------------------------------------------------*/
  165.     virtual void
  166.       handleOpen( IContainerControl* container );
  167.  
  168.   private:
  169.     IString       strAddress;
  170.     IString       strCode;
  171. };
  172.  
  173.  
  174. /******************************************************************************
  175. * Class ADepartmentView - Window for displaying department information        *
  176. ******************************************************************************/
  177. class ADepartmentView : public IFrameWindow
  178. {
  179.   public:
  180. /*------------------------ Constructors/Destructor ----------------------------
  181. | Construct the object in only one way:                                       |
  182. | 1) Parameter with a Cepartment and IContainerControl                        |
  183. -----------------------------------------------------------------------------*/
  184.     ADepartmentView( Department* aDept, IContainerControl* anOwner );
  185.     virtual ~ADepartmentView();
  186.  
  187.   private:
  188.     IStaticText
  189.       stext;
  190.     Department
  191.      *saveDept;
  192.  
  193. };
  194.  
  195.  
  196. /******************************************************************************
  197. * Class ACnrexWindow - Main window for application                            *
  198. ******************************************************************************/
  199. class ACnrexWindow : public IFrameWindow
  200. {
  201.   friend class ACnrMenuHandler;
  202.   public:
  203. /*------------------------ Constructors/Destructor ----------------------------
  204. | Construct the object in only one way:                                       |
  205. | 1) No parameters                                                            |
  206. -----------------------------------------------------------------------------*/
  207.     ACnrexWindow( unsigned long windowId );
  208.     virtual ~ACnrexWindow() {};
  209.  
  210.   private:
  211.     IContainerControl
  212.       cnr;
  213.     Department
  214.      *dept1,
  215.      *dept2,
  216.      *dept3,
  217.      *dept4,
  218.      *dept5,
  219.      *dept6;
  220.     IContainerColumn
  221.       colIcon,
  222.       colName,
  223.       colCode,
  224.       colAddress;
  225.     IMenuBar
  226.       menuBar;
  227.     ACommandHandler
  228.       cmdHdr;
  229.     ACnrHandler
  230.       cnrHdr;
  231.     ACnrMenuHandler
  232.       cnrMenuHdr;
  233.     ACnrEditHandler
  234.       cnrEditHdr;
  235. };
  236.  
  237.  
  238. /******************************************************************************
  239. * Class SelectedObjectsFilter - Filter function callback for selected objects *
  240. ******************************************************************************/
  241. class SelectedObjectsFilter : public IContainerControl::FilterFn
  242. {
  243.   virtual Boolean
  244.     isMemberOf( IContainerObject* object,
  245.                 IContainerControl* container ) const
  246.     {
  247.       return container->isSelected( object );
  248.     }
  249. };
  250.  
  251.  
  252. /******************************************************************************
  253. * Class AllObjectsFilter - Filter function callback for all objects           *
  254. ******************************************************************************/
  255. class AllObjectsFilter : public IContainerControl::FilterFn
  256. {
  257.   virtual Boolean
  258.     isMemberOf( IContainerObject* object,
  259.                 IContainerControl* container ) const
  260.     {
  261.       return true;
  262.     }
  263. };
  264.  
  265.  
  266. /******************************************************************************
  267. * Class SortByCode - Sorts objects by string found in Code column.            *
  268. ******************************************************************************/
  269. class SortByCode : public IContainerControl::CompareFn
  270. {
  271.   virtual int
  272.     isEqual( IContainerObject*  object1,
  273.              IContainerObject*  object2,
  274.              IContainerControl* container ) const;
  275. };
  276.  
  277. #endif
  278.