home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / cnr / acnr.cpp next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  31.1 KB  |  681 lines

  1. /******************************************************************************
  2. * .FILE: acnr.cpp                                                             *
  3. *                                                                             *
  4. * .DESCRIPTION: Container sample application                                  *
  5. *                                                                             *
  6. * .CLASSES:                                                                   *
  7. *   ACnrexWindow                                                              *
  8. *   ACommandHandler                                                           *
  9. *   Department                                                                *
  10. *   ADepartmentView                                                           *
  11. *   ACnrHandler                                                               *
  12. *   ACnrMenuHandler                                                           *
  13. *                                                                             *
  14. * .COPYRIGHT:                                                                 *
  15. *    Licensed Material - Program-Property of IBM                              *
  16. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  17. *                                                                             *
  18. * .DISCLAIMER:                                                                *
  19. *   The following [enclosed] code is sample code created by IBM               *
  20. *   Corporation.  This sample code is not part of any standard IBM product    *
  21. *   and is provided to you solely for the purpose of assisting you in the     *
  22. *   development of your applications.  The code is provided 'AS IS',          *
  23. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  24. *   arising out of your use of the sample code, even if they have been        *
  25. *   advised of the possibility of such damages.                               *
  26. *                                                                             *
  27. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  28. ******************************************************************************/
  29.  
  30. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  31.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  32. #endif                                  //  is defined.
  33. #include <iapp.hpp>
  34. #include <icolor.hpp>
  35. #include <istattxt.hpp>
  36. #include <ipopmenu.hpp>
  37. #include <imenubar.hpp>
  38. #include <imenuhdr.hpp>
  39. #include <icnr.hpp>
  40. #include <ireslib.hpp>
  41. #include <imle.hpp>
  42. #include <istring.hpp>
  43. #include <imsgbox.hpp>
  44. #include <iframe.hpp>
  45. #include <icoordsy.hpp>
  46. #include "acnr.hpp"
  47. #include "acnr.h"
  48.  
  49. int main()
  50. {
  51.   ICoordinateSystem::setApplicationOrientation(
  52.           ICoordinateSystem::originLowerLeft );
  53.  
  54. /*-----------------------------------------------------------------------------
  55. | Create the main frame window that contains the container.                   |
  56.  ----------------------------------------------------------------------------*/
  57.   ACnrexWindow mainWindow (WND_MAIN);
  58.  
  59. /*-----------------------------------------------------------------------------
  60. | If in the Windows environment, also create a main frame window that contains|
  61. |   the PM compatible container.                                              |
  62.  ----------------------------------------------------------------------------*/
  63.   #ifdef IC_WIN
  64.   IContainerControl::setDefaultStyle( IContainerControl::defaultStyle() |
  65.                                       IContainerControl::pmCompatible );
  66.   ACnrexWindow mainWindow2 (WND_MAIN);
  67.   #endif
  68.  
  69. /*-----------------------------------------------------------------------------
  70. | Start the application message loop.                                         |
  71.  ----------------------------------------------------------------------------*/
  72.   IApplication::current().run();
  73.  
  74.   return 0;
  75. } /* end main */
  76.  
  77. /******************************************************************************
  78. * Class ACnrexWindow :: ACnrexWincow - Constructor for the main window        *
  79. *                                                                             *
  80. * Create yourself as an IFrameWindow, title will default to window id resource*
  81. * Create menubar                                                              *
  82. * Create container                                                            *
  83. * Create container columns                                                    *
  84. * Create command handler                                                      *
  85. * Create container handler                                                    *
  86. * Create container menu handler                                               *
  87. * Create container edit handler                                               *
  88. ******************************************************************************/
  89. ACnrexWindow::ACnrexWindow( unsigned long windowId )
  90.   :IFrameWindow( IFrameWindow::defaultStyle()
  91.                 | IFrameWindow::minimizedIcon
  92.                 ,windowId )
  93.   ,menuBar( WND_MAIN, this )
  94.   ,cnr( CNR_RESID, this, this )
  95.   ,colIcon( IContainerColumn::isIcon )
  96.   ,colName( IContainerColumn::isIconViewText )
  97.   ,colCode( offsetof( Department, strCode ))
  98.   ,colAddress( offsetof( Department, strAddress ))
  99.   ,cmdHdr( this, &menuBar, &cnr, &colName, &colCode, &colAddress )
  100.   ,cnrHdr()
  101.   ,cnrMenuHdr( &cnr )
  102.   ,cnrEditHdr()
  103. {
  104.  
  105.  
  106. /*-----------------------------------------------------------------------------
  107. | Attach the command handler to the frame window                              |
  108. | Attach the container handler to the container                               |
  109. | Attach the container edit handler to the container                          |
  110. | Attach the container menu handler to the container                          |
  111.  ----------------------------------------------------------------------------*/
  112.   cmdHdr.handleEventsFor( this );
  113.   cnrHdr.handleEventsFor( &cnr );
  114.   cnrEditHdr.handleEventsFor( &cnr );
  115.   cnrMenuHdr.handleEventsFor( &cnr );
  116.  
  117. /*-----------------------------------------------------------------------------
  118. | Set the container for extended selections                                   |
  119.  ----------------------------------------------------------------------------*/
  120.   cnr.setExtendedSelection();
  121.  
  122. /*-----------------------------------------------------------------------------
  123. | Set the text of the column headings for details view                        |
  124.  ----------------------------------------------------------------------------*/
  125.   colIcon.setHeadingText( STR_ICON );
  126.   colName.setHeadingText( STR_DEPT );
  127.   colCode.setHeadingText( STR_CODE );
  128.   colAddress.setHeadingText( STR_ADDR );
  129.  
  130. /*-----------------------------------------------------------------------------
  131. | Show column separators                                                      |
  132.  ----------------------------------------------------------------------------*/
  133.   colIcon.showSeparators( IContainerColumn::horizontalSeparator );
  134.   colName.showSeparators( IContainerColumn::verticalSeparator );
  135.   colCode.showSeparators();
  136.   colAddress.showSeparators();
  137.  
  138. /*-----------------------------------------------------------------------------
  139. | Add the columns to the container                                            |
  140.  ----------------------------------------------------------------------------*/
  141.   cnr.addColumn( &colIcon );
  142.   cnr.addColumn( &colName );
  143.   cnr.addColumn( &colCode );
  144.   cnr.addColumn( &colAddress );
  145.  
  146. /*-----------------------------------------------------------------------------
  147. | Set the details view split at 350 pixels                                    |
  148. | Automatically delete the container objects when closed                      |
  149.  ----------------------------------------------------------------------------*/
  150.   cnr.setDetailsViewSplit( &colName, 350 );
  151.   cnr.setDeleteObjectsOnClose();
  152.  
  153. /*-----------------------------------------------------------------------------
  154. | Begin using our resource library in order to load strings and icons for     |
  155. |   the container objects.                                                    |
  156. | Create container objects dept1 - dept6                                      |
  157.  ----------------------------------------------------------------------------*/
  158.   IResourceLibrary reslib;
  159.  
  160.   dept1=new Department(reslib.loadString(STR_ITEM_11),
  161.                        reslib.loadIcon(IBMLOGO),
  162.                        reslib.loadString(STR_ITEM_12),
  163.                        reslib.loadString(STR_ITEM_13));
  164.  
  165.   dept2=new Department(reslib.loadString(STR_ITEM_21),
  166.                        reslib.loadIcon(CLOGO),
  167.                        reslib.loadString(STR_ITEM_22),
  168.                        reslib.loadString(STR_ITEM_23));
  169.  
  170.   dept3=new Department(reslib.loadString(STR_ITEM_31),
  171.                        reslib.loadIcon(WLOGO),
  172.                        reslib.loadString(STR_ITEM_32),
  173.                        reslib.loadString(STR_ITEM_33));
  174.  
  175.   dept4=new Department(reslib.loadString(STR_ITEM_41),
  176.                        reslib.loadIcon(OSLOGO),
  177.                        reslib.loadString(STR_ITEM_42),
  178.                        reslib.loadString(STR_ITEM_43));
  179.  
  180.   dept5=new Department(reslib.loadString(STR_ITEM_51),
  181.                        reslib.loadIcon(IBMLOGO),
  182.                        reslib.loadString(STR_ITEM_52),
  183.                        reslib.loadString(STR_ITEM_53));
  184.  
  185.   dept6=new Department(reslib.loadString(STR_ITEM_61),
  186.                        reslib.loadIcon(IBMLOGO),
  187.                        reslib.loadString(STR_ITEM_62),
  188.                        reslib.loadString(STR_ITEM_63));
  189.  
  190. /*-----------------------------------------------------------------------------
  191. | Allow an edit field for the container columns                               |
  192. | Allow the container object data to also be updated directly by the user     |
  193.  ----------------------------------------------------------------------------*/
  194.   colName.enableDataUpdate();
  195.   colCode.enableDataUpdate();
  196.   colAddress.enableDataUpdate();
  197.  
  198.   dept1->enableDataUpdate();
  199.   dept2->enableDataUpdate();
  200.   dept3->enableDataUpdate();
  201.   dept4->enableDataUpdate();
  202.   dept5->enableDataUpdate();
  203.   dept6->enableDataUpdate();
  204.  
  205. /*-----------------------------------------------------------------------------
  206. | Add the objects to the container.  dept2 and dept3 are under dept1.         |
  207.  ----------------------------------------------------------------------------*/
  208.   cnr.addObject( dept1 );
  209.   cnr.addObject( dept2, dept1 );
  210.   cnr.addObject( dept3, dept1 );
  211.   cnr.addObject( dept4, dept1 );
  212.   cnr.addObject( dept5 );
  213.   cnr.addObject( dept6 );
  214.  
  215. /*-----------------------------------------------------------------------------
  216. | Arrange the container objects for icon view                                 |
  217. | Set the container title from the resource library                           |
  218. | Show container title                                                        |
  219. | Show container tree-icon view                                               |
  220.  ----------------------------------------------------------------------------*/
  221.   cnr.arrangeIconView();
  222.   cnr.setTitle( STR_CNRTITLE );
  223.   cnr.showTitle();
  224.   cnr.showTreeIconView();
  225.  
  226. /*-----------------------------------------------------------------------------
  227. | Since we are initially in tree-icon view, disabled the "Mark All" and       |
  228. |   "Unmark All" menu items.  These functions are not supported for this view.|
  229.  ----------------------------------------------------------------------------*/
  230.   menuBar.disableItem( ID_MARKALL );
  231.   menuBar.disableItem( ID_UNMARKALL );
  232.  
  233. /*-----------------------------------------------------------------------------
  234. | Set the frame window's client to the container                              |
  235. | Set the focus to the container instead of the frame window.  This is needed |
  236. |   because containers handle many of the keyboard and mouse events that the  |
  237. |   frame normally handles for controls.  But we want these events to be      |
  238. |   processed by the container first such as <ENTER> and <TAB>.               |
  239. | Show the frame window                                                       |
  240.  ----------------------------------------------------------------------------*/
  241.   setClient( &cnr );
  242.   cnr.setFocus();
  243.   show();
  244.  
  245. } /* end ACnrexWindow :: ACnrexWindow(...) */
  246.  
  247.  
  248. /******************************************************************************
  249. * Class Department :: Department - Constructor for container objects          *
  250. *                                                                             *
  251. * Create yourself as an IContainerObject                                      *
  252. * Store the strings for Code and Address                                      *
  253. ******************************************************************************/
  254. Department::Department( const IString& Name,
  255.                 const IPointerHandle& Icon,
  256.                 const IString& Code,
  257.                 const IString& Address )
  258.   :IContainerObject( Name, Icon )
  259.   ,strCode( Code )
  260.   ,strAddress( Address )
  261. {
  262. }
  263.  
  264.  
  265. /******************************************************************************
  266. * Class Department :: handleOpen - Override container handler function to     *
  267. *   process open requests                                                     *
  268. ******************************************************************************/
  269. void Department::handleOpen (IContainerControl* container)
  270. {
  271. /*-----------------------------------------------------------------------------
  272. | Create a department view window                                             |
  273. | To avoid memory leaks, auto delete the C++ view window when GUI window is   |
  274. |   closed                                                                    |
  275.  ----------------------------------------------------------------------------*/
  276.   ADepartmentView* view = new ADepartmentView( this, container );
  277.   view->setAutoDeleteObject();
  278. }
  279.  
  280.  
  281. /******************************************************************************
  282. * Class ADepartmentView :: ADepartmentView - Constructor for viewing          *
  283. *   department information                                                    *
  284. *                                                                             *
  285. * Create yourself as an IFrameWindow                                          *
  286. * Create a static text                                                        *
  287. ******************************************************************************/
  288. ADepartmentView::ADepartmentView (Department * aDept,
  289.                                   IContainerControl* anOwner)
  290.   :IFrameWindow( WND_DEPT, IWindow::desktopWindow(), anOwner )
  291.   ,stext( WND_CNREX, this, this )
  292. {
  293. /*-----------------------------------------------------------------------------
  294. | Visually indicate the object is open                                        |
  295. | Store the department information.                                           |
  296.  ----------------------------------------------------------------------------*/
  297.   aDept->setOpen();
  298.   saveDept=aDept;
  299.  
  300. /*-----------------------------------------------------------------------------
  301. | Set the static text to the deparment's icon text                            |
  302. | Center the text                                                             |
  303.  ----------------------------------------------------------------------------*/
  304.   stext.setText( aDept->iconText() );
  305.   stext.setAlignment( IStaticText::centerCenter );
  306.  
  307. /*-----------------------------------------------------------------------------
  308. | Set the frame window's client to the static text                            |
  309. | Size the frame window                                                       |
  310. | Set the focus and show the window                                           |
  311.  ----------------------------------------------------------------------------*/
  312.   setClient( &stext );
  313.   sizeTo( ISize( 400, 300 ));
  314.   setFocus().show();
  315. }
  316.  
  317.  
  318. /******************************************************************************
  319. * Class ADepartmentView :: ~ADepartmentView - Destructor                      *
  320. ******************************************************************************/
  321. ADepartmentView :: ~ADepartmentView ()
  322. {
  323. /*-----------------------------------------------------------------------------
  324. | Visually indicate the object is closed                                      |
  325.  ----------------------------------------------------------------------------*/
  326.   saveDept->setClosed();
  327. }
  328.  
  329.  
  330. /******************************************************************************
  331. * Class ACommandHandler :: ACommandHandler - Constructor for a command handler*
  332. *                                                                             *
  333. * Create yourself as an ICommandHandler                                       *
  334. * Store the owner window                                                      *
  335. * Store the owner window menubar                                              *
  336. * Store the owner window container                                            *
  337. * Store the owner window container column for Name                            *
  338. * Store the owner window container column for Code                            *
  339. * Store the owner window container column for Address                         *
  340. ******************************************************************************/
  341. ACommandHandler::ACommandHandler( ACnrexWindow* window,
  342.                     IMenuBar* menuBar,
  343.                     IContainerControl* cnr,
  344.                     IContainerColumn* colName,
  345.                     IContainerColumn* colCode,
  346.                     IContainerColumn* colAddr )
  347.   :ICommandHandler()
  348.   ,pwin( window )
  349.   ,pmenu( menuBar )
  350.   ,pcnr( cnr )
  351.   ,pcolName( colName )
  352.   ,pcolCode( colCode )
  353.   ,pcolAddr( colAddr )
  354. {
  355. }
  356.  
  357.  
  358. /******************************************************************************
  359. * Class ACommandHandler :: command - Override command handler function for    *
  360. *   handling commands                                                         *
  361. ******************************************************************************/
  362. IBase::Boolean ACommandHandler::command( ICommandEvent& event )
  363. {
  364.  
  365.   switch( event.commandId() )
  366.   {
  367.     case ID_VTEXT:
  368.     {
  369. /*-----------------------------------------------------------------------------
  370. | Enable the mark-all and unmark-all menu items for this container view       |
  371. | Show the text-view                                                          |
  372.  ----------------------------------------------------------------------------*/
  373.       pmenu->enableItem( ID_MARKALL );
  374.       pmenu->enableItem( ID_UNMARKALL );
  375.       pcnr->showTextView();
  376.       break;
  377.     }
  378.  
  379.     case ID_VFTEXT:
  380.     {
  381. /*-----------------------------------------------------------------------------
  382. | Enable the mark-all and unmark-all menu items for this container view       |
  383. | Show the flowed-text view                                                   |
  384.  ----------------------------------------------------------------------------*/
  385.       pmenu->enableItem( ID_MARKALL );
  386.       pmenu->enableItem( ID_UNMARKALL );
  387.       pcnr->showFlowedTextView();
  388.       break;
  389.     }
  390.  
  391.     case ID_VNAME:
  392.     {
  393. /*-----------------------------------------------------------------------------
  394. | Enable the mark-all and unmark-all menu items for this container view       |
  395. | Show the name view                                                          |
  396.  ----------------------------------------------------------------------------*/
  397.       pmenu->enableItem( ID_MARKALL );
  398.       pmenu->enableItem( ID_UNMARKALL );
  399.       pcnr->showNameView();
  400.       break;
  401.     }
  402.  
  403.     case ID_VFNAME:
  404.     {
  405. /*-----------------------------------------------------------------------------
  406. | Enable the mark-all and unmark-all menu items for this container view       |
  407. | Show the flowed-name view                                                   |
  408.  ----------------------------------------------------------------------------*/
  409.       pmenu->enableItem( ID_MARKALL );
  410.       pmenu->enableItem( ID_UNMARKALL );
  411.       pcnr->showFlowedNameView();
  412.       break;
  413.     }
  414.  
  415.     case ID_VDETAILS:
  416.     {
  417. /*-----------------------------------------------------------------------------
  418. | Enable the mark-all and unmark-all menu items for this container view       |
  419. | Show the flowed-name view                                                   |
  420.  ----------------------------------------------------------------------------*/
  421.       pmenu->enableItem(ID_MARKALL);  //Enable Mark All Menu Item
  422.       pmenu->enableItem(ID_UNMARKALL);//Enable Mark All Menu Item
  423.       pcnr->showDetailsView();
  424.       break;
  425.     }
  426.  
  427.     case ID_FILTER1:
  428.     {
  429. /*-----------------------------------------------------------------------------
  430. | Get the selected container objects                                          |
  431. | Filter and show these container objects                                     |
  432.  ----------------------------------------------------------------------------*/
  433.       SelectedObjectsFilter selObjects;
  434.       pcnr->filter( selObjects );
  435.       break;
  436.     }
  437.  
  438.     case ID_FILTER2:
  439.     {
  440. /*-----------------------------------------------------------------------------
  441. | Get all the container objects                                               |
  442. | Filter and show these container objects                                     |
  443.  ----------------------------------------------------------------------------*/
  444.       AllObjectsFilter allObjects;
  445.       pcnr->filter( allObjects );
  446.       break;
  447.     }
  448.  
  449.     case ID_SORT1:
  450.     {
  451. /*-----------------------------------------------------------------------------
  452. | Sort the container based on the Icon Text.                                  |
  453. | We call a container function to do this.                                    |
  454.  ----------------------------------------------------------------------------*/
  455.       pcnr->sortByIconText ( true );
  456.       break;
  457.     }
  458.  
  459.     case ID_SORT2:
  460.     {
  461. /*-----------------------------------------------------------------------------
  462. | Sort the container based on the Code Text.                                  |
  463. | We must create an instance of the SortByCode class and pass this in.        |
  464.  ----------------------------------------------------------------------------*/
  465.       SortByCode   sortByCode;
  466.       pcnr->sort( sortByCode );
  467.       break;
  468.     }
  469.  
  470.     case ID_VTICON:
  471.     {
  472. /*-----------------------------------------------------------------------------
  473. | Disable the mark-all and unmark-all menu items for this container view      |
  474. | Show the tree-icon view                                                     |
  475.  ----------------------------------------------------------------------------*/
  476.       pmenu->disableItem( ID_MARKALL );
  477.       pmenu->disableItem( ID_UNMARKALL );
  478.       pcnr->showTreeIconView();
  479.       break;
  480.     }
  481.  
  482.     case ID_VTTEXT:
  483.     {
  484. /*-----------------------------------------------------------------------------
  485. | Disable the mark-all and unmark-all menu items for this container view      |
  486. | Show the tree-text view                                                     |
  487.  ----------------------------------------------------------------------------*/
  488.       pmenu->disableItem( ID_MARKALL );
  489.       pmenu->disableItem( ID_UNMARKALL );
  490.       pcnr->showTreeTextView();
  491.       break;
  492.     }
  493.  
  494.     case ID_VTNAME:
  495. /*-----------------------------------------------------------------------------
  496. | Disable the mark-all and unmark-all menu items for this container view      |
  497. | Show the tree-name view                                                     |
  498.  ----------------------------------------------------------------------------*/
  499.     {
  500.       pmenu->disableItem( ID_MARKALL );
  501.       pmenu->disableItem( ID_UNMARKALL );
  502.       pcnr->showTreeNameView();
  503.       break;
  504.     }
  505.  
  506.     case ID_VICON:
  507.     {
  508. /*-----------------------------------------------------------------------------
  509. | Enable the mark-all and unmark-all menu items for this container view       |
  510. | Show the icon view                                                          |
  511.  ----------------------------------------------------------------------------*/
  512.       pmenu->enableItem( ID_MARKALL );
  513.       pmenu->enableItem( ID_UNMARKALL );
  514.       pcnr->showIconView();
  515.       break;
  516.     }
  517.  
  518.     case ID_VARRANGE:
  519.     {
  520. /*-----------------------------------------------------------------------------
  521. | Enable the mark-all and unmark-all menu items for this container view       |
  522. | Arrange the icons                                                           |
  523.  ----------------------------------------------------------------------------*/
  524.       pmenu->enableItem( ID_MARKALL );
  525.       pmenu->enableItem( ID_UNMARKALL );
  526.       pcnr->arrangeIconView();
  527.       break;
  528.     }
  529.  
  530.     case ID_MARKALL:
  531.     {
  532. /*-----------------------------------------------------------------------------
  533. | Get all the container objects                                               |
  534. | Try to select all the container objects                                     |
  535.  ----------------------------------------------------------------------------*/
  536.       IContainerControl::ObjectCursor CO1 ( *pcnr );
  537.       for ( CO1.setToFirst(); CO1.isValid(); CO1.setToNext() )
  538.       {
  539.         try
  540.         {
  541.           pcnr->setSelected( pcnr->objectAt( CO1 ));
  542.         }
  543.         catch( IException& exc )
  544.         {
  545.         }
  546.       }
  547.       break;
  548.     }
  549.  
  550.     case ID_UNMARKALL:
  551.     {
  552. /*-----------------------------------------------------------------------------
  553. | Get all the container objects                                               |
  554. | Try to deselect all the container objects                                   |
  555.  ----------------------------------------------------------------------------*/
  556.       IContainerControl::ObjectCursor CO2 ( *pcnr );
  557.       for ( CO2.setToFirst(); CO2.isValid(); CO2.setToNext() )
  558.       {
  559.         try
  560.         {
  561.           pcnr->removeSelected( pcnr->objectAt( CO2 ));
  562.         }
  563.         catch( IException& exc )
  564.         {
  565.         }
  566.       }
  567.       break;
  568.     }
  569.  
  570.     case MI_EDRECORD:
  571.     {
  572. /*-----------------------------------------------------------------------------
  573. | Get the cursored container objects                                          |
  574. | Initialize the cursor to the first object                                   |
  575. | Edit the current container object                                           |
  576.  ----------------------------------------------------------------------------*/
  577.       IContainerControl::ObjectCursor CO3 ( *pcnr, IContainerObject::cursored );
  578.       CO3.setToFirst();
  579.       pcnr->editObject( CO3.current() );
  580.       break;
  581.     }
  582.  
  583.     case MI_EDNAME:
  584.     {
  585. /*-----------------------------------------------------------------------------
  586. | Get the cursored container objects                                          |
  587. | Initialize the cursor to the first object                                   |
  588. | Edit the current container object's column                                  |
  589.  ----------------------------------------------------------------------------*/
  590.       IContainerControl::ObjectCursor CO3 ( *pcnr, IContainerObject::cursored );
  591.       CO3.setToFirst();
  592.       pcnr->editObject( CO3.current(), pcolName );
  593.       break;
  594.     }
  595.  
  596.     case MI_EDCODE:
  597.     {
  598. /*-----------------------------------------------------------------------------
  599. | Get the cursored container objects                                          |
  600. | Initialize the cursor to the first object                                   |
  601. | Edit the current container object's column                                  |
  602.  ----------------------------------------------------------------------------*/
  603.       IContainerControl::ObjectCursor CO3 ( *pcnr, IContainerObject::cursored );
  604.       CO3.setToFirst();
  605.       pcnr->editObject( CO3.current(), pcolCode );
  606.       break;
  607.     }
  608.  
  609.     case MI_EDADDRESS:
  610.     {
  611. /*-----------------------------------------------------------------------------
  612. | Get the cursored container objects                                          |
  613. | Initialize the cursor to the first object                                   |
  614. | Edit the current container object's column                                  |
  615.  ----------------------------------------------------------------------------*/
  616.       IContainerControl::ObjectCursor CO3 ( *pcnr, IContainerObject::cursored );
  617.       CO3.setToFirst();
  618.       pcnr->editObject( CO3.current(), pcolAddr );
  619.       break;
  620.     }
  621.   }  /* end switch */
  622.   return(false);
  623. }
  624.  
  625.  
  626. /******************************************************************************
  627. * Class ACnrMenuHandler :: makePopUpMenu - Override container menu handler    *
  628. *   function for creating popup menus                                         *
  629. ******************************************************************************/
  630. IBase::Boolean ACnrMenuHandler::makePopUpMenu( IMenuEvent& event )
  631. {
  632. /*-----------------------------------------------------------------------------
  633. | If a valid container object, continue                                       |
  634.  ----------------------------------------------------------------------------*/
  635.   if ( popupMenuObject() )
  636.   {
  637. /*-----------------------------------------------------------------------------
  638. | Create a popup menu                                                         |
  639. | If not in details view, disable editing of Name, Code, and Address columsn. |
  640.  ----------------------------------------------------------------------------*/
  641.     IPopUpMenu* popUp = new IPopUpMenu( ID_POPMENU,
  642.                 event.window() );
  643.     if ( !pcnr->isDetailsView() )
  644.     {
  645.       popUp->disableItem( MI_EDNAME );
  646.       popUp->disableItem( MI_EDCODE );
  647.       popUp->disableItem( MI_EDADDRESS );
  648.     }
  649.     else
  650.     {
  651. /*-----------------------------------------------------------------------------
  652. | Disable editing of the object                                               |
  653.  ----------------------------------------------------------------------------*/
  654.       popUp->disableItem( MI_EDRECORD );
  655.     }
  656.  
  657. /*-----------------------------------------------------------------------------
  658. | To avoid memory leaks, auto delete the C++ popup menu when the GUI popup    |
  659. |   window closes                                                             |
  660. | Show the popup menu at the current mouse position                           |
  661. | Visually indicate the container object is the source for this action        |
  662. | Visually indicate the container object is the current cursor                |
  663.  ----------------------------------------------------------------------------*/
  664.     popUp->setAutoDeleteObject();
  665.     pcnr->showSourceEmphasis( popupMenuObject() );
  666.     pcnr->setCursor( popupMenuObject() );
  667.     popUp->show( event.mousePosition() );
  668.     return true;
  669.   }
  670.   return false;
  671. };
  672.  
  673.  
  674. int SortByCode::isEqual( IContainerObject*  object1,
  675.                          IContainerObject*  object2,
  676.                          IContainerControl* container ) const
  677. {
  678.   return container->nlsCompare(((Department*)object1)->Code(),
  679.                                ((Department*)object2)->Code());
  680. }
  681.