home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / LANCELOT / LMAINWIN.HPP < prev    next >
C/C++ Source or Header  |  1995-04-07  |  16KB  |  385 lines

  1. /******************************************************************************
  2. * FILE NAME: lmainwin.hpp                                                     *
  3. *                                                                             *
  4. * DESCRIPTION: Frame window for the main application                          *
  5. *                                                                             *
  6. * Classes:                                                                    *
  7. *   LMainWindow                                                               *
  8. *   LMainWindowCommandHandler                                                 *
  9. *   LMainCnr                                                                  *
  10. *   LMainCnrObject                                                            *
  11. *   LMainWindowHelpHandler                                                    *
  12. *                                                                             *
  13. * COPYRIGHT:                                                                  *
  14. *   Licensed Materials - Property of IBM                                      *
  15. *   (C) Copyright IBM Corporation 1992, 1995                                  *
  16. *   All Rights Reserved                                                       *
  17. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  18. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  19. *                                                                             *
  20. ******************************************************************************/
  21. #ifndef _LMAINWIN_
  22.   #define _LMAINWIN_
  23.  
  24. #include <iapp.hpp>
  25. #include <irect.hpp>
  26. #include <istring.hpp>
  27. #include <iframe.hpp>
  28. #include <ititle.hpp>
  29. #include <iinfoa.hpp>
  30. #include <imenubar.hpp>
  31. #ifdef IC_PM
  32. #include <itbar.hpp>
  33. #include <itbarbut.hpp>
  34. #include <iflytext.hpp>
  35. #include <iflyhhdr.hpp>
  36. #endif
  37. #include <icmdhdr.hpp>
  38. #include <icnrhdr.hpp>
  39. #include <icnrmhdr.hpp>
  40. #include <ievent.hpp>
  41. #include <icnr.hpp>
  42. #include <icnrobj.hpp>
  43. #include <icnrctl.hpp>
  44. #include <icnrcol.hpp>
  45. #include <ipopmenu.hpp>
  46. #include <ifont.hpp>
  47. #include <imsgbox.hpp>
  48. #include <ihelp.hpp>
  49. #include <ihelphdr.hpp>
  50. #include "linfowin.hpp"
  51. #include "lcnrobj.hpp"
  52. #include "ldbase.hpp"
  53. #include "lancelot.h"
  54.  
  55. class LMainWindow;
  56.  
  57. /******************************************************************************
  58. * Class LMainCnrObject - LMainWindow's container object                       *
  59. ******************************************************************************/
  60. class LMainCnrObject : public LCnrObject
  61. {
  62.    public:
  63.       enum ObjectType { personnel, project, query };
  64.  
  65. /*------------------------ Constructors/Destructor ----------------------------
  66. | Construct the object in one of four ways:                                   |
  67. | 1) Existing object                                                          |
  68. | 2) Icon resourceId, title, ObjectType, and description.                     |
  69. | 3) Icon resourceId, title resourceId, ObjectType, & description resourceId. |
  70. | 4) Icon resourceId, title, ObjectType, and description resourceId.          |
  71. -----------------------------------------------------------------------------*/
  72.       LMainCnrObject( const LMainCnrObject& cnrobj );
  73.  
  74.       LMainCnrObject( unsigned long icon, IString title,
  75.                       ObjectType type, IString description );
  76.  
  77.       LMainCnrObject( unsigned long icon, IResourceId title,
  78.                       ObjectType type, IResourceId description );
  79.  
  80.       LMainCnrObject( unsigned long icon, IString title,
  81.                       ObjectType type, IResourceId description );
  82.  
  83.       virtual
  84.          ~LMainCnrObject();
  85.  
  86. /*------------------------------- Accessors -----------------------------------
  87. | These functions provide a means of getting and setting the accessible       |
  88. | attributes of instances of this class:                                      |
  89. |   type                - Returns the type of the container object            |
  90. |   description         - Returns the description.                            |
  91. |   setType             - Sets the type.                                      |
  92. |   setDescription      - Sets the description.                               |
  93. |   typeOffset          - Returns the container offset for the type.          |
  94. |   descOffset          - Returns the container offset for the description.   |
  95. -----------------------------------------------------------------------------*/
  96.       inline ObjectType
  97.          type() const { return theType; };
  98.       inline IString
  99.          description() const { return theDesc; };
  100.  
  101.       inline LMainCnrObject
  102.          &setType( ObjectType newType ) { theType=newType; return *this; };
  103.       inline LMainCnrObject
  104.          &setDescription( IString desc ) { theDesc=desc; return *this; };
  105.  
  106.       inline static unsigned long
  107.          typeOffset() { return offsetof( LMainCnrObject, theType ); };
  108.       inline static unsigned long
  109.          descOffset() { return offsetof( LMainCnrObject, theDesc ); };
  110.  
  111.    private:
  112.  
  113.       ObjectType
  114.          theType;
  115.  
  116.       IString
  117.          theDesc;
  118. };
  119.  
  120.  
  121. /******************************************************************************
  122. * Class LMainCnr - Main window's container                                    *
  123. ******************************************************************************/
  124. class LMainCnr : public IContainerControl,
  125.                  protected ICnrHandler,
  126.                  protected ICnrMenuHandler
  127. {
  128.    public:
  129. /*------------------------ Constructors/Destructor ----------------------------
  130. | Construct the object in only one way:                                       |
  131. | 1) Window id, parent, owner, and location                                   |
  132. -----------------------------------------------------------------------------*/
  133.       LMainCnr( unsigned long id, LMainWindow* parent,
  134.                 LMainWindow* owner, IRectangle location=IRectangle() );
  135.       virtual
  136.          ~LMainCnr();
  137.  
  138. /*------------------------------- Accessors -----------------------------------
  139. | These functions provide a means of getting and setting the accessible        |
  140. | attributes of instances of this class:                                       |
  141. |   lastPopupMenuObject - Returns the last container object that had a         |
  142. |                         popup menu over it.  But not guaranteed that the     |
  143. |                         last action was a popup menu.                        |
  144. |   setLastPopupMenuObject - Sets the last container object that had a popup   |
  145. |                         menu over it.                                        |
  146. -----------------------------------------------------------------------------*/
  147.       inline LMainCnrObject
  148.         *lastPopupMenuObject() { return ptheLastPopupMenuObject; };
  149.  
  150.       inline LMainCnr
  151.         &setLastPopupMenuObject( LMainCnrObject* object )
  152.                                { ptheLastPopupMenuObject = object; return *this; };
  153.  
  154. /*------------------------------- Manipulation --------------------------------
  155. | These functions provide a means of manipulating the instances of this class:|
  156. |   populate            - Populate the container with query objects.          |
  157. |   addLastQuery        - Add the new saved query to the container.           |
  158. -----------------------------------------------------------------------------*/
  159.       LMainCnr
  160.         &populate();
  161.  
  162.       LMainCnr
  163.         &addLastQuery( IString queryName );
  164.  
  165.    protected:
  166.  
  167. /*----------------------------- Event Processing ------------------------------
  168. | Handle and process events:                                                  |
  169. |   makePopupMenu       - Process popup menu events.                          |
  170. |   enter               - Process the enter key for container objects.        |
  171. |   help                - Process the help key for container objects.         |
  172. -----------------------------------------------------------------------------*/
  173.       virtual Boolean
  174.          makePopUpMenu( IMenuEvent& evt ),
  175.          enter( ICnrEnterEvent& evt ),
  176.          help( ICnrHelpEvent& evt );
  177.  
  178.    private:
  179.  
  180.       LMainCnrObject
  181.         *pCnrObject[ ID_MAIN_MAX_CNROBJECTS ];
  182.  
  183.       IContainerColumn
  184.          colIcon,
  185.          colIconText,
  186.          colDesc;
  187.  
  188.       LMainCnrObject
  189.         *ptheLastPopupMenuObject;
  190.  
  191.       IHelpWindow
  192.         *helpWin;
  193.  
  194.       IPopUpMenu
  195.         *popm;
  196.  
  197.       unsigned long
  198.          objCount;
  199. };
  200.  
  201.  
  202. /******************************************************************************
  203. * Class LMainWindowCommandHandler - Handle command events.                    *
  204. ******************************************************************************/
  205. class LMainWindowCommandHandler : public ICommandHandler
  206. {
  207.    public:
  208. /*------------------------ Constructors/Destructor ----------------------------
  209. | Construct the object in only one way:                                       |
  210. | 1) Owner, help window, and container.                                       |
  211. -----------------------------------------------------------------------------*/
  212.       LMainWindowCommandHandler( LMainWindow* owner,
  213.                                  IHelpWindow* helpWin,
  214.                                  LMainCnr* cnrCtl );
  215.       virtual
  216.         ~LMainWindowCommandHandler();
  217.  
  218. /*------------------------- Container Object Actions --------------------------
  219. | These functions provide a means of performing actions on container objects.  |
  220. |   openAction          - Opens/views the container object.                    |
  221. |   deleteAction        - Deletes the container object.                        |
  222. -----------------------------------------------------------------------------*/
  223.       LMainWindowCommandHandler
  224.         &openAction( LMainCnrObject* cnrObject );
  225.  
  226.       Boolean
  227.          deleteAction( LMainCnrObject* cnrObject );
  228.  
  229.    protected:
  230. /*----------------------------- Event Processing ------------------------------
  231. | Handle and process events:                                                  |
  232. |   command             - Process command events.                             |
  233. -----------------------------------------------------------------------------*/
  234.       virtual Boolean
  235.          command( ICommandEvent& event );
  236.  
  237.    private:
  238.       LMainWindow
  239.         *pOwner;
  240.  
  241.       IHelpWindow
  242.         *pHelp;
  243.  
  244.       LMainCnr
  245.         *pCnr;
  246. };
  247.  
  248.  
  249. /******************************************************************************
  250. * Class LMainWindowHelpHandler - Handle help events.                          *
  251. ******************************************************************************/
  252. class LMainWindowHelpHandler : public IHelpHandler
  253. {
  254.    public:
  255. /*------------------------ Constructors/Destructor ----------------------------
  256. | Construct the object in only one way:                                       |
  257. | 1) No parameters.                                                           |
  258. -----------------------------------------------------------------------------*/
  259.       LMainWindowHelpHandler();
  260.  
  261.       virtual
  262.         ~LMainWindowHelpHandler();
  263.  
  264.    protected:
  265. /*----------------------------- Event Processing ------------------------------
  266. | Handle and process events:                                                  |
  267. |   keysHelpId          - Process help events for the container.              |
  268. -----------------------------------------------------------------------------*/
  269.       virtual Boolean
  270.          keysHelpId( IEvent& event );
  271. };
  272.  
  273.  
  274. #ifdef IC_PM
  275. /******************************************************************************
  276. * Class LMainToolBar - Toolbar class                                          *
  277. ******************************************************************************/
  278. class LMainToolBar : public IToolBar
  279. {
  280.    public:
  281. /*------------------------ Constructors/Destructor ----------------------------
  282. | Construct the object in only one way:                                       |
  283. | 1) Resource id, owner, information area.                                    |
  284. -----------------------------------------------------------------------------*/
  285.       LMainToolBar( unsigned long id, IFrameWindow* owner,
  286.                     ITextControl* infoArea );
  287.  
  288. /*----------------------------- Manipulators ----------------------------------
  289. | These functions provide a means of manipulating the attributes of            |
  290. | instances of this class:                                                     |
  291. |   enableSelects       - Enable or disables the select-all and deselect-all   |
  292. |                         toolbar buttons.                                     |
  293. -----------------------------------------------------------------------------*/
  294.       LMainToolBar
  295.        &enableSelects( Boolean which = true );
  296.  
  297.    private:
  298.       IToolBarButton
  299.          openButton,
  300.          deleteButton,
  301.          iconButton,
  302.          treeButton,
  303.          detailsButton,
  304.          selectAllButton,
  305.          deselectAllButton,
  306.          sortAscButton,
  307.          sortDescButton,
  308.          arrangeButton,
  309.          helpButton;
  310.  
  311.       IFlyText
  312.          flyText;
  313.  
  314.       IFlyOverHelpHandler
  315.          flyHelpHdr;
  316. };
  317. #endif
  318.  
  319. /******************************************************************************
  320. * Class LMainWindow - Main frame window.                                      *
  321. ******************************************************************************/
  322. class LMainWindow : public IFrameWindow
  323. {
  324.    public:
  325. /*------------------------ Constructors/Destructor ----------------------------
  326. | Construct the object in only one way:                                       |
  327. | 1) No parameters.                                                           |
  328. -----------------------------------------------------------------------------*/
  329.       LMainWindow();
  330.  
  331.       virtual
  332.        ~LMainWindow();
  333.  
  334. /*------------------------------- Accessors -----------------------------------
  335. | These functions provide a means of getting and setting the accessible        |
  336. | attributes of instances of this class:                                       |
  337. |   helpWindow          - Returns the help window for this frame window.       |
  338. |   selectsAllowed      - Returns true if select all/deselect all is allowed. |
  339. -----------------------------------------------------------------------------*/
  340.       inline IHelpWindow
  341.        *helpWindow() { return &help; };
  342.  
  343.       inline Boolean
  344.          selectsAllowed() { return aSelects; };
  345. /*----------------------------- Manipulators ----------------------------------
  346. | These functions provide a means of manipulating the attributes of            |
  347. | instances of this class:                                                     |
  348. |   enableSelects       - Enable or disables the select-all and deselect-all   |
  349. |                         menuitems and toolbar buttons.                       |
  350. -----------------------------------------------------------------------------*/
  351.       LMainWindow
  352.        &enableSelects( Boolean which = true );
  353.  
  354.    private:
  355.       ITitle
  356.          title;
  357.  
  358.       IMenuBar
  359.          menubar;
  360.  
  361.       IInfoArea
  362.          infoarea;
  363.  
  364.       LMainCnr
  365.          cnr;
  366.  
  367. #ifdef IC_PM
  368.       LMainToolBar
  369.          toolbar;
  370. #endif
  371.  
  372.       IHelpWindow
  373.          help;
  374.  
  375.       LMainWindowCommandHandler
  376.          cmdHdr;
  377.  
  378.       LMainWindowHelpHandler
  379.          helpHdr;
  380.  
  381.       Boolean
  382.          aSelects;
  383. };
  384. #endif
  385.