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

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