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

  1. /******************************************************************************
  2. * .FILE:         lperswin.hpp                                                 *
  3. *                                                                             *
  4. * .DESCRIPTION:  Lancelot Sample Program:              Class Definition       *
  5. *                                                                             *
  6. * .CLASSES:      LPersonnelWindow                                             *
  7. *                LPersonnelWindowCommandHandler                               *
  8. *                LPersonnelCnr                                                *
  9. *                LPersonnelCnrObject                                          *
  10. *                LPersonnelWindowHelpHandler                                  *
  11. *                                                                             *
  12. * .COPYRIGHT:                                                                 *
  13. *    Licensed Material - Program-Property of IBM                              *
  14. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  15. *                                                                             *
  16. * .DISCLAIMER:                                                                *
  17. *   The following [enclosed] code is sample code created by IBM               *
  18. *   Corporation.  This sample code is not part of any standard IBM product    *
  19. *   and is provided to you solely for the purpose of assisting you in the     *
  20. *   development of your applications.  The code is provided 'AS IS',          *
  21. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  22. *   arising out of your use of the sample code, even if they have been        *
  23. *   advised of the possibility of such damages.                               *
  24. *                                                                             *
  25. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  26. *                                                                             *
  27. ******************************************************************************/
  28. #ifndef _LPERSWIN_
  29.   #define _LPERSWIN_
  30.  
  31. #include <iapp.hpp>
  32. #include <irect.hpp>
  33. #include <istring.hpp>
  34. #include <iframe.hpp>
  35. #include <ititle.hpp>
  36. #include <iinfoa.hpp>
  37. #include <imenubar.hpp>
  38. #ifndef IC_MOTIF
  39. #include <idmhndlr.hpp>
  40. #include <itbar.hpp>
  41. #include <itbarbut.hpp>
  42. #include <iflytext.hpp>
  43. #include <iflyhhdr.hpp>
  44. #endif
  45. #include <icmdhdr.hpp>
  46. #include <icnrhdr.hpp>
  47. #include <icnrmhdr.hpp>
  48. #include <ievent.hpp>
  49. #include <icnr.hpp>
  50. #include <icnrobj.hpp>
  51. #include <icnrctl.hpp>
  52. #include <icnrcol.hpp>
  53. #include <ipopmenu.hpp>
  54. #include <ifont.hpp>
  55. #include <imsgbox.hpp>
  56. #include <ihelp.hpp>
  57. #include <ihelphdr.hpp>
  58. #include "lcnrobj.hpp"
  59. #include "ldbase.hpp"
  60. #include "ldbqry.hpp"
  61. #include "lancelot.h"
  62. #ifndef IC_MOTIF
  63. #include "lperswdm.hpp"
  64. #endif
  65.  
  66. class LPersonnelWindow;
  67.  
  68. /******************************************************************************
  69. * Class LPersonnelCnrObject - LPersonnelMainWindow's container object         *
  70. ******************************************************************************/
  71. class LPersonnelCnrObject : public LCnrObject
  72. {
  73.    friend class LPersonnelCnr;
  74.  
  75.    public:
  76.  
  77. /*------------------------ Constructors/Destructor ----------------------------
  78. | Construct the object in two of four ways:                                   |
  79. | 1) Existing object                                                          |
  80. | 2) Icon resourceId and EmployeeData object.                                 |
  81. -----------------------------------------------------------------------------*/
  82.       LPersonnelCnrObject( const LPersonnelCnrObject& cnrobj );
  83.  
  84.       LPersonnelCnrObject( unsigned long icon,
  85.             const LEmployeeData& employee );
  86.  
  87.       virtual
  88.         ~LPersonnelCnrObject();
  89.  
  90. /*------------------------------- Accessors -----------------------------------
  91. | These functions provide a means of getting and setting the accessible        |
  92. | attributes of instances of this class:                                       |
  93. |   employeeRecord      - Returns the employee data                            |
  94. -----------------------------------------------------------------------------*/
  95.       inline LEmployeeData
  96.          employeeRecord() const { return theEmployee; };
  97.  
  98.    private:
  99.  
  100.       LEmployeeData
  101.          theEmployee;
  102. };
  103.  
  104.  
  105. /******************************************************************************
  106. * Class LPersonnelCnr - Personnel window's container                          *
  107. ******************************************************************************/
  108. class LPersonnelCnr : public IContainerControl,
  109.                       protected ICnrHandler,
  110.                       protected ICnrMenuHandler
  111.  
  112. {
  113.    public:
  114. /*------------------------ Constructors/Destructor ----------------------------
  115. | Construct the object in only one way:                                       |
  116. | 1) Window id, parent, owner, and location                                   |
  117. -----------------------------------------------------------------------------*/
  118.       LPersonnelCnr( unsigned long id, LPersonnelWindow* parent,
  119.                      LPersonnelWindow* owner, IRectangle location=IRectangle() );
  120.       virtual
  121.         ~LPersonnelCnr();
  122.  
  123. /*------------------------------- Accessors -----------------------------------
  124. | These functions provide a means of getting and setting the accessible        |
  125. | attributes of instances of this class:                                       |
  126. |   lastPopupMenuObject - Returns the last container object that had a         |
  127. |                         popup menu over it.  But not guaranteed that the     |
  128. |                         last action was a popup menu.                        |
  129. |   setLastPopupMenuObject - Sets the last container object that had a popup   |
  130. |                         menu over it.                                        |
  131. -----------------------------------------------------------------------------*/
  132.       LPersonnelCnrObject
  133.         *lastPopupMenuObject() { return ptheLastPopupMenuObject; };
  134.  
  135.       LPersonnelCnr
  136.         &setLastPopupMenuObject( LPersonnelCnrObject* object )
  137.                                { ptheLastPopupMenuObject = object; return *this; };
  138.  
  139.    protected:
  140. /*----------------------------- Event Processing ------------------------------
  141. | Handle and process events:                                                  |
  142. |   makePopupMenu       - Process popup menu events.                          |
  143. |   enter               - Process the enter key for container objects.        |
  144. |   help                - Process the help key for container objects.         |
  145. -----------------------------------------------------------------------------*/
  146.       virtual Boolean
  147.          makePopUpMenu( IMenuEvent& evt ),
  148.          enter( ICnrEnterEvent& evt ),
  149.          help( ICnrHelpEvent& evt );
  150.  
  151.    private:
  152.       LPersonnelCnrObject
  153.         *pCnrObject[ ID_PERSONNEL_MAX_CNROBJECTS ];
  154.  
  155.       IContainerColumn
  156.          colIcon,
  157.          colIconText,
  158.          colLastName,
  159.          colFirstName,
  160.          colMiddleInitial,
  161.          colEmployeeNumber,
  162.          colInternalPhone,
  163.          colExternalPhone,
  164.          colInternalAddress,
  165.          colExternalAddress,
  166.          colRoom,
  167.          colBuilding,
  168.          colDepartment,
  169.          colManagerNumber,
  170.          colManagerName;
  171.  
  172.       LPersonnelCnrObject
  173.         *ptheLastPopupMenuObject;
  174.  
  175.       IHelpWindow
  176.         *helpWin;
  177.  
  178.       IPopUpMenu
  179.         *popm;
  180.  
  181. };
  182.  
  183.  
  184. /******************************************************************************
  185. * Class LPersonnelWindowCommandHandler - Handle command events.               *
  186. ******************************************************************************/
  187. class LPersonnelWindowCommandHandler : public ICommandHandler
  188. {
  189.    public:
  190. /*------------------------ Constructors/Destructor ----------------------------
  191. | Construct the object in only one way:                                       |
  192. | 1) Owner, help window, and container.                                       |
  193. -----------------------------------------------------------------------------*/
  194.       LPersonnelWindowCommandHandler( LPersonnelWindow* owner,
  195.                                       IHelpWindow* helpWin,
  196.                                       LPersonnelCnr* cnrCtl );
  197.       virtual
  198.         ~LPersonnelWindowCommandHandler();
  199.  
  200. /*------------------------- Container Object Actions --------------------------
  201. | These functions provide a means of performing actions on container objects.  |
  202. |   openAction          - Opens/views the container object.                    |
  203. |   createAction        - Creates a new container object.                      |
  204. |   transferAction      - Transfer the container object to another department. |
  205. |   deleteAction        - Deletes the container object.                        |
  206. -----------------------------------------------------------------------------*/
  207.       LPersonnelWindowCommandHandler
  208.         &openAction( LPersonnelCnrObject* cnrObject ),
  209.         &createAction( LPersonnelCnrObject* cnrObject ),
  210.         &transferAction( LPersonnelCnrObject* cnrObject );
  211.       Boolean
  212.         deleteAction( LPersonnelCnrObject* cnrObject );
  213.  
  214.    protected:
  215. /*----------------------------- Event Processing ------------------------------
  216. | Handle and process events:                                                  |
  217. |   command             - Process command events.                             |
  218. -----------------------------------------------------------------------------*/
  219.       virtual Boolean
  220.          command( ICommandEvent& event );
  221.  
  222.    private:
  223.       LPersonnelWindow
  224.         *pOwner;
  225.  
  226.       IHelpWindow
  227.         *pHelp;
  228.  
  229.       LPersonnelCnr
  230.         *pCnr;
  231. };
  232.  
  233.  
  234. /******************************************************************************
  235. * Class LPersonnelWindowHelpHandler - Handle help events.                     *
  236. ******************************************************************************/
  237. class LPersonnelWindowHelpHandler : public IHelpHandler
  238. {
  239.    public:
  240. /*------------------------ Constructors/Destructor ----------------------------
  241. | Construct the object in only one way:                                       |
  242. | 1) No parameters.                                                           |
  243. -----------------------------------------------------------------------------*/
  244.       LPersonnelWindowHelpHandler();
  245.  
  246.       virtual
  247.          ~LPersonnelWindowHelpHandler();
  248.  
  249.    protected:
  250. /*----------------------------- Event Processing ------------------------------
  251. | Handle and process events:                                                  |
  252. |   keysHelpId          - Process help events for the container.              |
  253. -----------------------------------------------------------------------------*/
  254.       virtual Boolean
  255.          keysHelpId( IEvent& event );
  256. };
  257.  
  258.  
  259. #ifndef IC_MOTIF
  260. /******************************************************************************
  261. * Class LPersonnelToolBar - Toolbar class                                     *
  262. ******************************************************************************/
  263. class LPersonnelToolBar : public IToolBar
  264. {
  265.    public:
  266. /*------------------------ Constructors/Destructor ----------------------------
  267. | Construct the object in only one way:                                       |
  268. | 1) Resource id, owner, information area.                                    |
  269. -----------------------------------------------------------------------------*/
  270.       LPersonnelToolBar( unsigned long id, IFrameWindow* owner,
  271.                          ITextControl* infoArea );
  272.  
  273. /*----------------------------- Manipulators ----------------------------------
  274. | These functions provide a means of manipulating the attributes of            |
  275. | instances of this class:                                                     |
  276. |   enableSelects       - Enable or disables the select-all and deselect-all   |
  277. |                         toolbar buttons.                                     |
  278. -----------------------------------------------------------------------------*/
  279.       LPersonnelToolBar
  280.        &enableSelects( Boolean which = true );
  281.  
  282.    private:
  283.       IToolBarButton
  284.          openButton,
  285.          createButton,
  286.          transferButton,
  287.          deleteButton,
  288.          iconButton,
  289.          treeButton,
  290.          detailsButton,
  291.          selectAllButton,
  292.          deselectAllButton,
  293.          sortAscButton,
  294.          sortDescButton,
  295.          arrangeButton,
  296.          helpButton;
  297.  
  298.       IFlyText
  299.          flyText;
  300.  
  301.       IFlyOverHelpHandler
  302.          flyHelpHdr;
  303. };
  304. #endif
  305.  
  306. /******************************************************************************
  307. * Class LPersonnelWindow - Personnel frame window.                            *
  308. ******************************************************************************/
  309. class LPersonnelWindow : public IFrameWindow
  310. {
  311.    public:
  312. /*------------------------ Constructors/Destructor ----------------------------
  313. | Construct the object in only one way:                                       |
  314. | 1) Owner, QueryIntersection object, query string.                           |
  315. -----------------------------------------------------------------------------*/
  316.       LPersonnelWindow( IWindow* owner, QueryIntersection& bagOfIds,
  317.                          const IString deptQuery);
  318.       virtual
  319.        ~LPersonnelWindow();
  320.  
  321. /*------------------------------- Accessors -----------------------------------
  322. | These functions provide a means of getting and setting the accessible       |
  323. | attributes of instances of this class:                                      |
  324. |   helpWindow          - Returns the help window for this frame window.      |
  325. |   deptQuery           - If a fully-qualified department name was specified  |
  326. |                         on the query, return the department name.           |
  327. |   selectsAllowed      - Returns true if select all/deselect all is allowed. |
  328. -----------------------------------------------------------------------------*/
  329.       inline IHelpWindow
  330.        *helpWindow() { return &help; };
  331.  
  332.       inline IString
  333.         deptQuery() { return aDeptQuery; };
  334.  
  335.       inline Boolean
  336.          selectsAllowed() { return aSelects; };
  337.  
  338. /*------------------------------- Manipulation --------------------------------
  339. | These functions provide a means of manipulating the instances of this class:|
  340. |   populate            - Populate the container with employee objects.       |
  341. |   enableSelects       - Enable or disables the select-all and deselect-all   |
  342. |                         toolbar buttons.                                     |
  343. -----------------------------------------------------------------------------*/
  344.       LPersonnelWindow
  345.        &populate( QueryIntersection& bagOfIds );
  346.  
  347.       LPersonnelWindow
  348.        &enableSelects( Boolean which = true );
  349.  
  350. #ifndef IC_MOTIF
  351.       IDMItemProviderFor< EmployeeItem >
  352.          provider;
  353. #endif
  354.  
  355. /*----------------------------- Event Processing ------------------------------
  356. | Handle and process events:                                                  |
  357. |   command             - Process command events.                             |
  358. |   keysHelpId          - Process the help key for container objects.         |
  359. -----------------------------------------------------------------------------*/
  360.    protected:
  361.       Boolean
  362.          command( ICommandEvent& evt ),
  363.          keysHelpId( IEvent& evt );
  364.  
  365.    private:
  366.       ITitle
  367.          title;
  368.  
  369.       IMenuBar
  370.          menubar;
  371.  
  372.       IInfoArea
  373.          infoarea;
  374.  
  375.       LPersonnelCnr
  376.          cnr;
  377.  
  378. #ifndef IC_MOTIF
  379.       LPersonnelToolBar
  380.          toolbar;
  381. #endif
  382.  
  383.       IHelpWindow
  384.          help;
  385.  
  386.       LPersonnelWindowCommandHandler
  387.          cmdHdr;
  388.  
  389.       LPersonnelWindowHelpHandler
  390.          helpHdr;
  391.  
  392.       IString
  393.          aDeptQuery;
  394.  
  395.       Boolean
  396.          aSelects;
  397. };
  398. #endif
  399.