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

  1. /*******************************************************************************
  2. * FILE NAME: lpagectl.cpp                                                      *
  3. *                                                                              *
  4. * DESCRIPTION: Page buttons, Container buttons, range combobox.                *
  5. *              These are generic page controls                                 *
  6. *                                                                              *
  7. * Class                                                                        *
  8. *    PageButtons                                                               *
  9. *    PageCnr                                                                   *
  10. *    PageScroll                                                                *
  11. *    PageCnrSelHandler                                                         *
  12. *    QueryRange                                                                *
  13. *                                                                              *
  14. * COPYRIGHT:                                                                   *
  15. *   Licensed Materials - Property of IBM                                       *
  16. *   (C) Copyright IBM Corporation 1992, 1995                                   *
  17. *   All Rights Reserved                                                        *
  18. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  19. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  20. *                                                                              *
  21. *******************************************************************************/
  22.  
  23. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  24.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  25. #endif                                  //  is defined.
  26. #include <ireslib.hpp>
  27. #include "lancelot.h"
  28. #include "lpagectl.hpp"
  29. #include "lacct.hpp"
  30. #include "lskill.hpp"
  31. #include "lproject.hpp"
  32. #include "ltask.hpp"
  33.  
  34. //*****************************************************************************
  35. // Class PageButtons :: PageButtons() contructor
  36. //*****************************************************************************
  37. PageButtons :: PageButtons ( unsigned long windowId,
  38.                              IMultiCellCanvas* parent,
  39.                              IMultiCellCanvas* owner,
  40.                              Boolean aQueryButton )
  41.     : ISetCanvas( windowId, parent, owner )
  42. #ifndef IC_MOTIF
  43.      ,selectHandler( parent )
  44. #endif
  45. {
  46.     if ( aQueryButton )
  47.     {
  48.         queryButton = new AGraphicPushButton( ID_BUTTON_QUERY, this, this,
  49.                                               ID_PAGE_QUERY);
  50.         saveButton = new AGraphicPushButton( ID_BUTTON_SAVE,
  51.                                              this,
  52.                                              this,
  53.                                              ID_PAGE_SAVE);
  54.         undoButton = NULL;
  55.     }
  56.     else
  57.     {
  58.       undoButton = new AGraphicPushButton( ID_BUTTON_UNDO,
  59.                                            this,
  60.                                            this,
  61.                                            ID_PAGE_UNDO);
  62.  
  63.       queryButton = NULL;
  64.       saveButton  = NULL;
  65.     }
  66.  
  67.     helpButton = new AGraphicPushButton( ID_BUTTON_HELP,
  68.                                          this,
  69.                                          this,
  70.                                          ID_PAGE_HELP);
  71. #ifndef IC_MOTIF
  72.     gridCheckBox = new ICheckBox( ID_BUTTON_GRID,
  73.                                   this,
  74.                                   this );
  75.     gridCheckBox->setText( ID_BUTTON_GRID );
  76.     selectHandler.handleEventsFor( gridCheckBox );
  77. #endif
  78.  
  79.     setDeckOrientation( ISetCanvas::horizontal );
  80. }
  81.  
  82. //*****************************************************************************
  83. // Class PageButtons :: ~PageButtons() destructor
  84. //*****************************************************************************
  85. PageButtons :: ~PageButtons()
  86. {
  87.     delete queryButton;
  88.     delete saveButton;
  89.     delete undoButton;
  90.     delete helpButton;
  91. #ifndef IC_MOTIF
  92.     selectHandler.stopHandlingEventsFor( gridCheckBox );
  93.     delete gridCheckBox;
  94. #endif
  95. }
  96.  
  97. #ifndef IC_MOTIF
  98. //*****************************************************************************
  99. // CLASS PageButtonsSelectHandler  - constructor
  100. //*****************************************************************************
  101. PageButtonsSelectHandler::PageButtonsSelectHandler( IMultiCellCanvas* pMulticell )
  102.     : ISelectHandler()
  103.      ,theParentMulticell( pMulticell )
  104. {
  105. }
  106.  
  107. //*****************************************************************************
  108. // CLASS PageButtonsSelectHandler  - destructor
  109. //*****************************************************************************
  110. PageButtonsSelectHandler::~PageButtonsSelectHandler()
  111. {
  112. }
  113.  
  114. //*****************************************************************************
  115. // CLASS GeneralPage :: selected() - select handler
  116. //*****************************************************************************
  117. IBase :: Boolean PageButtonsSelectHandler::selected(IControlEvent& event)
  118. {
  119.   theParentMulticell->enableGridLines( !( theParentMulticell->hasGridLines() ) );
  120.   return(false);
  121. }
  122. #endif
  123.  
  124.  
  125. //*****************************************************************************
  126. // Class PageCnrButtons :: PageCnrButtons() constructor
  127. //*****************************************************************************
  128. PageCnrButtons :: PageCnrButtons( unsigned long windowId,
  129.                                   IWindow* parent,
  130.                                   IWindow* owner,
  131.                                   Boolean noChangeButton )
  132.     : ISetCanvas( windowId, parent, owner )
  133. {
  134.     addButton = new AGraphicPushButton( ID_BUTTON_ADD,
  135.                                         this,
  136.                                         this,
  137.                                         ID_PAGE_ADD);
  138.  
  139.     if ( !noChangeButton )
  140.     {
  141.         changeButton = new AGraphicPushButton( ID_BUTTON_CHANGE,
  142.                                                this,
  143.                                                this,
  144.                                                ID_PAGE_CHANGE);
  145.  
  146.     }
  147.  
  148.    removeButton = new AGraphicPushButton( ID_BUTTON_REMOVE,
  149.                                           this,
  150.                                           this,
  151.                                           ID_PAGE_REMOVE);
  152.  
  153.  
  154.    setDeckOrientation( ISetCanvas::vertical );
  155. }
  156.  
  157. //*****************************************************************************
  158. // Class PageCnrButtons :: ~PageCnrButtons() destructor
  159. //*****************************************************************************
  160. PageCnrButtons :: ~PageCnrButtons()
  161. {
  162.     delete addButton;
  163.     delete changeButton;
  164.     delete removeButton;
  165. }
  166.  
  167.  
  168.  
  169. //*****************************************************************************
  170. // Class PageCnrButtons :: PageScrollButtons()
  171. //*****************************************************************************
  172. PageScrollButtons :: PageScrollButtons( unsigned long windowId,
  173.                                         IWindow* parent,
  174.                                         IWindow* owner )
  175.     : ISetCanvas( windowId, parent, owner )
  176.     , weekEndingText( ID_NO_ITEM, this, this )
  177.     , dateText()
  178.     , prevButton( ID_BUTTON_PREV, this, this,
  179.                   ID_PAGE_PREVIOUS)
  180.     , nextButton( ID_BUTTON_NEXT,  this, this,
  181.                   ID_PAGE_NEXT)
  182.     , displayText()
  183. {
  184.    setPackType(ISetCanvas::even);
  185.    setDeckOrientation( ISetCanvas::horizontal );
  186. }
  187.  
  188.  
  189. //*****************************************************************************
  190. // Class PageScrollButtons :: ~PageScrollButtons()
  191. //*****************************************************************************
  192. PageScrollButtons :: ~PageScrollButtons()
  193. {
  194. };
  195.  
  196.  
  197. //*****************************************************************************
  198. // Class PageScrollButtons :: setDisplayText() - week ending text string
  199. // Used in TimeCard page.
  200. //*****************************************************************************
  201. PageScrollButtons& PageScrollButtons :: setDisplayText( const char* theStr )
  202. {
  203.  
  204.    weekEndingText.setText( STR_TCD_WEEK_ENDING_TEXT );
  205.    displayText = theStr;
  206.    displayText += "      ";
  207.    weekEndingText.setText( weekEndingText.text() + displayText );
  208.  
  209.    return *this;
  210. }
  211.  
  212.  
  213. //*****************************************************************************
  214. // Class QuerryRange :: QueryRange()
  215. //*****************************************************************************
  216. QueryRange :: QueryRange( unsigned long windowId,
  217.                           IWindow* parent,
  218.                           IWindow* owner,
  219.                           unsigned long id)
  220.     : ISetCanvas( windowId, parent, owner )
  221.     , range( id,  this, this,
  222.              IRectangle(),
  223.              (IComboBox::classDefaultStyle &
  224.             ~IComboBox::simpleType     |
  225.              IComboBox::dropDownListType ) |
  226.              IControl::tabStop)
  227. {
  228.    setPackType(ISetCanvas::even);
  229.    setDeckOrientation( ISetCanvas::horizontal );
  230.  
  231.    range.setLimit( DISPLAY_SMALL_RANGE );
  232.    range.addAsFirst("=");
  233.    range.addAsLast(">");
  234.    range.addAsLast("<");
  235.    range.addAsLast(">=");
  236.    range.addAsLast("<=");
  237.    range.setText("=");
  238. }
  239.  
  240. //*****************************************************************************
  241. // Class QuerryRange :: ~QueryRange()
  242. //*****************************************************************************
  243. QueryRange :: ~QueryRange()
  244. {};
  245.  
  246.  
  247. AGraphicPushButton :: AGraphicPushButton( unsigned long id,
  248.                                              IWindow* parent,
  249.                                              IWindow* owner,
  250.                                              unsigned long iconId) :
  251.    IGraphicPushButton( id, parent, owner, IResourceId(iconId), IRectangle(),
  252.         (IGraphicPushButton::classDefaultStyle |
  253.         IControl::tabStop))
  254. {
  255. }
  256.  
  257. AGraphicPushButton :: ~AGraphicPushButton()
  258. {
  259. }
  260.  
  261.  
  262. #ifdef IC_MOTIF
  263. LPictureVerifyHandler :: LPictureVerifyHandler( IWindow* owner,
  264.                            IString pictureString )
  265.           :IPictureVerifyHandler( pictureString )
  266. {
  267.   pOwner = owner;
  268. }
  269.  
  270.  
  271. IWindow* LPictureVerifyHandler :: owner()
  272. {
  273.   return pOwner;
  274. }
  275.  
  276.  
  277. IBase::Boolean LPictureVerifyHandler :: invalidChange( IEditVerifyEvent& event )
  278. {
  279.   unsigned long resId, msgId;
  280.   switch (event.controlId()) {
  281.  
  282. // GENERAL PAGE
  283.     case  ID_GEN_EMPLOYEE_ID_EF:
  284.      resId = STR_GEN_EMPLOYEE_ID_TEXT;
  285.      msgId = STR_MSG_ALPHA_NUMERIC;
  286.      break;
  287.     case  ID_GEN_LAST_NAME_EF:
  288.      resId = STR_GEN_LAST_NAME_TEXT;
  289.      msgId = STR_MSG_ALPHA;
  290.      break;
  291.     case  ID_GEN_FIRST_NAME_EF:
  292.      resId = STR_GEN_FIRST_NAME_TEXT;
  293.      msgId = STR_MSG_ALPHA;
  294.      break;
  295.     case  ID_GEN_MIDDLE_INITIAL_EF:
  296.      resId = STR_GEN_MIDDLE_NAME_TEXT;
  297.      msgId = STR_MSG_ALPHA;
  298.      break;
  299.     case  ID_GEN_INT_PHONE_EF:
  300.      resId = STR_GEN_INT_PHONE_TEXT;
  301.      msgId = STR_MSG_PHONE;
  302.      break;
  303.     case  ID_GEN_EXT_PHONE_EF:
  304.      resId = STR_GEN_EXT_PHONE_TEXT;
  305.      msgId = STR_MSG_PHONE;
  306.      break;
  307.     case  ID_GEN_MGR_EMP_ID_EF:
  308.      resId = STR_GEN_MGR_EMP_NUM_TEXT;
  309.      msgId = STR_MSG_ALPHA_NUMERIC;
  310.      break;
  311.     case  ID_GEN_MGR_NAME_EF:
  312.      resId = STR_GEN_MGR_EMP_NAME_TEXT;
  313.      msgId = STR_MSG_ALPHA;
  314.      break;
  315.  
  316. // BADGE   PAGE
  317.     case ID_BDG_ISSUE_DATE_EF:
  318.      resId = STR_BDG_ISSUE_DATE ;
  319.      msgId = STR_MSG_DATE;
  320.      break;
  321.     case ID_BDG_EXP_DATE_EF:
  322.      resId = STR_BDG_EXP_DATE;
  323.      msgId = STR_MSG_DATE;
  324.      break;
  325.  
  326. // STATUS  PAGE
  327.     case ID_STA_START_DATE_EF:
  328.      resId = STR_STA_START;
  329.      msgId = STR_MSG_DATE;
  330.      break;
  331.     case ID_STA_END_DATE_EF:
  332.      resId = STR_STA_END;
  333.      msgId = STR_MSG_DATE;
  334.      break;
  335.     case ID_STA_HOURLY_RATE_EF:
  336.      resId = STR_STA_END;
  337.      msgId = STR_MSG_CURRENCY;
  338.      break;
  339.  
  340. // PROJECT PAGE
  341.     case ID_PRJ_PROJ_EF:
  342.      resId = STR_PRJ_PROJ;
  343.      msgId = STR_MSG_ALPHA_NUMERIC;
  344.      break;
  345.  
  346. // TASK PAGE
  347.     case ID_TSK_TASK_EF:
  348.      resId = STR_TSK_TASK;
  349.      msgId = STR_MSG_ALPHA_NUMERIC;
  350.      break;
  351.  
  352. // TIMECARD PAGE
  353.     case ID_TCD_DATE0_EF:
  354.      resId = STR_TCD_DATE;
  355.      msgId = STR_MSG_DATE;
  356.      break;
  357.   }
  358.  
  359.   IMessageBox messageBox( owner() ) ;
  360.   messageBox.setTitle(IResourceId(resId));
  361.   messageBox.show(IResourceId(msgId), IMessageBox::information);
  362.  
  363.   event.allowChange( false );
  364.   return false;
  365. }
  366. #endif
  367.  
  368. /******************************************************************************
  369. * Class PageCnrSelHandler :: PageCnrSelHandler - Constructor for a select     *
  370. *  handler for a notebook page's container.                                   *
  371. *                                                                             *
  372. * Define yourself as a select handler.                                        *
  373. * Set the page pointer in your private data.                                  *
  374. * Set the type of notebook page.                                              *
  375. ******************************************************************************/
  376. PageCnrSelHandler::PageCnrSelHandler( AccountPage* page )
  377.      :ISelectHandler(),
  378.       pPage( page ),
  379.       pageType( accountPage )
  380. {
  381. };
  382.  
  383.  
  384. PageCnrSelHandler::PageCnrSelHandler( SkillPage* page )
  385.      :ISelectHandler(),
  386.       pPage( page ),
  387.       pageType( skillPage )
  388. {
  389. };
  390.  
  391.  
  392. PageCnrSelHandler::PageCnrSelHandler( ProjectPage* page )
  393.      :ISelectHandler(),
  394.       pPage( page ),
  395.       pageType( projectPage )
  396. {
  397. };
  398.  
  399.  
  400. PageCnrSelHandler::PageCnrSelHandler( TasksPage* page )
  401.      :ISelectHandler(),
  402.       pPage( page ),
  403.       pageType( taskPage )
  404. {
  405. };
  406.  
  407.  
  408. /******************************************************************************
  409. * Class PageCnrSelHandler :: ~PageCnrSelHandler - Destructor for the page's   *
  410. *  container select handler.                                                  *
  411. ******************************************************************************/
  412. PageCnrSelHandler::~PageCnrSelHandler()
  413. {
  414. };
  415.  
  416.  
  417. /******************************************************************************
  418. * Class PageCnrSelHandler :: selected - Handle the select events.             *
  419. ******************************************************************************/
  420. IBase::Boolean PageCnrSelHandler::selected( IControlEvent& event )
  421. {
  422.    IContainerControl* pCnr = (IContainerControl*) event.controlWindow();
  423.    IContainerControl::ObjectCursor
  424.       soc( *pCnr,
  425.           IContainerObject::selected );
  426.  
  427.    soc.setToFirst();
  428.    if ( soc.isValid() )
  429.    {
  430.       switch ( pageType )
  431.       {
  432.          case accountPage :
  433.          {
  434.             ((AccountPage*)pPage)->fillEntryfields( (AcctCnrObj *) soc.current() );
  435.             break;
  436.          }
  437.          case skillPage :
  438.          {
  439.             ((SkillPage*)pPage)->fillEntryfields( (SkillCnrObj *) soc.current() );
  440.             break;
  441.          }
  442.          case projectPage :
  443.          {
  444.             ((ProjectPage*)pPage)->fillEntryfields( (ProjCnrObj *) soc.current() );
  445.             break;
  446.          }
  447.          case taskPage :
  448.          {
  449.             ((TasksPage*)pPage)->fillEntryfields( (TaskCnrObj *) soc.current() );
  450.             break;
  451.          }
  452.       }
  453.    }
  454.  
  455.    return false;
  456. }
  457.