home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / lancelot / lpagectl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  15.1 KB  |  453 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, 1996                                   *
  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.     : IComboBox( id,  parent, owner,
  221.              IRectangle(),
  222.              (IComboBox::classDefaultStyle &
  223.             ~IComboBox::simpleType     |
  224.              IComboBox::readOnlyDropDownType ) |
  225.              IControl::tabStop)
  226. {
  227.    setLimit( DISPLAY_SMALL_RANGE );
  228.    addAsFirst("=");
  229.    addAsLast(">");
  230.    addAsLast("<");
  231.    addAsLast(">=");
  232.    addAsLast("<=");
  233.    setText("=");
  234. }
  235.  
  236. //*****************************************************************************
  237. // Class QuerryRange :: ~QueryRange()
  238. //*****************************************************************************
  239. QueryRange :: ~QueryRange()
  240. {};
  241.  
  242.  
  243. AGraphicPushButton :: AGraphicPushButton( unsigned long id,
  244.                                              IWindow* parent,
  245.                                              IWindow* owner,
  246.                                              unsigned long iconId) :
  247.    IGraphicPushButton( id, parent, owner, IResourceId(iconId), IRectangle(),
  248.         (IGraphicPushButton::classDefaultStyle |
  249.         IControl::tabStop))
  250. {
  251. }
  252.  
  253. AGraphicPushButton :: ~AGraphicPushButton()
  254. {
  255. }
  256.  
  257.  
  258. #ifdef IC_MOTIF
  259. LPictureVerifyHandler :: LPictureVerifyHandler( IWindow* owner,
  260.                            IString pictureString )
  261.           :IPictureVerifyHandler( pictureString )
  262. {
  263.   pOwner = owner;
  264. }
  265.  
  266.  
  267. IWindow* LPictureVerifyHandler :: owner()
  268. {
  269.   return pOwner;
  270. }
  271.  
  272.  
  273. IBase::Boolean LPictureVerifyHandler :: invalidChange( IEditVerifyEvent& event )
  274. {
  275.   unsigned long resId, msgId;
  276.   switch (event.controlId()) {
  277.  
  278. // GENERAL PAGE
  279.     case  ID_GEN_EMPLOYEE_ID_EF:
  280.      resId = STR_GEN_EMPLOYEE_ID_TEXT;
  281.      msgId = STR_MSG_ALPHA_NUMERIC;
  282.      break;
  283.     case  ID_GEN_LAST_NAME_EF:
  284.      resId = STR_GEN_LAST_NAME_TEXT;
  285.      msgId = STR_MSG_ALPHA;
  286.      break;
  287.     case  ID_GEN_FIRST_NAME_EF:
  288.      resId = STR_GEN_FIRST_NAME_TEXT;
  289.      msgId = STR_MSG_ALPHA;
  290.      break;
  291.     case  ID_GEN_MIDDLE_INITIAL_EF:
  292.      resId = STR_GEN_MIDDLE_NAME_TEXT;
  293.      msgId = STR_MSG_ALPHA;
  294.      break;
  295.     case  ID_GEN_INT_PHONE_EF:
  296.      resId = STR_GEN_INT_PHONE_TEXT;
  297.      msgId = STR_MSG_PHONE;
  298.      break;
  299.     case  ID_GEN_EXT_PHONE_EF:
  300.      resId = STR_GEN_EXT_PHONE_TEXT;
  301.      msgId = STR_MSG_PHONE;
  302.      break;
  303.     case  ID_GEN_MGR_EMP_ID_EF:
  304.      resId = STR_GEN_MGR_EMP_NUM_TEXT;
  305.      msgId = STR_MSG_ALPHA_NUMERIC;
  306.      break;
  307.     case  ID_GEN_MGR_NAME_EF:
  308.      resId = STR_GEN_MGR_EMP_NAME_TEXT;
  309.      msgId = STR_MSG_ALPHA;
  310.      break;
  311.  
  312. // BADGE   PAGE
  313.     case ID_BDG_ISSUE_DATE_EF:
  314.      resId = STR_BDG_ISSUE_DATE ;
  315.      msgId = STR_MSG_DATE;
  316.      break;
  317.     case ID_BDG_EXP_DATE_EF:
  318.      resId = STR_BDG_EXP_DATE;
  319.      msgId = STR_MSG_DATE;
  320.      break;
  321.  
  322. // STATUS  PAGE
  323.     case ID_STA_START_DATE_EF:
  324.      resId = STR_STA_START;
  325.      msgId = STR_MSG_DATE;
  326.      break;
  327.     case ID_STA_END_DATE_EF:
  328.      resId = STR_STA_END;
  329.      msgId = STR_MSG_DATE;
  330.      break;
  331.     case ID_STA_HOURLY_RATE_EF:
  332.      resId = STR_STA_END;
  333.      msgId = STR_MSG_CURRENCY;
  334.      break;
  335.  
  336. // PROJECT PAGE
  337.     case ID_PRJ_PROJ_EF:
  338.      resId = STR_PRJ_PROJ;
  339.      msgId = STR_MSG_ALPHA_NUMERIC;
  340.      break;
  341.  
  342. // TASK PAGE
  343.     case ID_TSK_TASK_EF:
  344.      resId = STR_TSK_TASK;
  345.      msgId = STR_MSG_ALPHA_NUMERIC;
  346.      break;
  347.  
  348. // TIMECARD PAGE
  349.     case ID_TCD_DATE0_EF:
  350.      resId = STR_TCD_DATE;
  351.      msgId = STR_MSG_DATE;
  352.      break;
  353.   }
  354.  
  355.   IMessageBox messageBox( owner() ) ;
  356.   messageBox.setTitle(IResourceId(resId));
  357.   messageBox.show(IResourceId(msgId), IMessageBox::information);
  358.  
  359.   event.allowChange( false );
  360.   return false;
  361. }
  362. #endif
  363.  
  364. /******************************************************************************
  365. * Class PageCnrSelHandler :: PageCnrSelHandler - Constructor for a select     *
  366. *  handler for a notebook page's container.                                   *
  367. *                                                                             *
  368. * Define yourself as a select handler.                                        *
  369. * Set the page pointer in your private data.                                  *
  370. * Set the type of notebook page.                                              *
  371. ******************************************************************************/
  372. PageCnrSelHandler::PageCnrSelHandler( AccountPage* page )
  373.      :ISelectHandler(),
  374.       pPage( page ),
  375.       pageType( accountPage )
  376. {
  377. };
  378.  
  379.  
  380. PageCnrSelHandler::PageCnrSelHandler( SkillPage* page )
  381.      :ISelectHandler(),
  382.       pPage( page ),
  383.       pageType( skillPage )
  384. {
  385. };
  386.  
  387.  
  388. PageCnrSelHandler::PageCnrSelHandler( ProjectPage* page )
  389.      :ISelectHandler(),
  390.       pPage( page ),
  391.       pageType( projectPage )
  392. {
  393. };
  394.  
  395.  
  396. PageCnrSelHandler::PageCnrSelHandler( TasksPage* page )
  397.      :ISelectHandler(),
  398.       pPage( page ),
  399.       pageType( taskPage )
  400. {
  401. };
  402.  
  403.  
  404. /******************************************************************************
  405. * Class PageCnrSelHandler :: ~PageCnrSelHandler - Destructor for the page's   *
  406. *  container select handler.                                                  *
  407. ******************************************************************************/
  408. PageCnrSelHandler::~PageCnrSelHandler()
  409. {
  410. };
  411.  
  412.  
  413. /******************************************************************************
  414. * Class PageCnrSelHandler :: selected - Handle the select events.             *
  415. ******************************************************************************/
  416. IBase::Boolean PageCnrSelHandler::selected( IControlEvent& event )
  417. {
  418.    IContainerControl* pCnr = (IContainerControl*) event.controlWindow();
  419.    IContainerControl::ObjectCursor
  420.       soc( *pCnr,
  421.           IContainerObject::selected );
  422.  
  423.    soc.setToFirst();
  424.    if ( soc.isValid() )
  425.    {
  426.       switch ( pageType )
  427.       {
  428.          case accountPage :
  429.          {
  430.             ((AccountPage*)pPage)->fillEntryfields( (AcctCnrObj *) soc.current() );
  431.             break;
  432.          }
  433.          case skillPage :
  434.          {
  435.             ((SkillPage*)pPage)->fillEntryfields( (SkillCnrObj *) soc.current() );
  436.             break;
  437.          }
  438.          case projectPage :
  439.          {
  440.             ((ProjectPage*)pPage)->fillEntryfields( (ProjCnrObj *) soc.current() );
  441.             break;
  442.          }
  443.          case taskPage :
  444.          {
  445.             ((TasksPage*)pPage)->fillEntryfields( (TaskCnrObj *) soc.current() );
  446.             break;
  447.          }
  448.       }
  449.    }
  450.  
  451.    return false;
  452. }
  453.