home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / DRAG3 / DMSAMP3.CPP < prev    next >
Text File  |  1995-05-01  |  8KB  |  161 lines

  1. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  2.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  3. #endif                                  //  is defined.
  4. #include "dmsamp3.hpp"
  5.  
  6. /*------------------------------------------------------------------------------
  7. | main                                                                         |
  8. ------------------------------------------------------------------------------*/
  9. int main()
  10. {
  11.    MySourceWin sourceWin (WND_SOURCE);
  12.    MyTargetWin targetWin (WND_TARGET);
  13.    IApplication::current().run();
  14.    return 0;
  15. }
  16.  
  17.  
  18. /*------------------------------------------------------------------------------
  19. | MyWindow::MyWindow                                                           |
  20. |                                                                              |
  21. | Constructor.                                                                 |
  22. ------------------------------------------------------------------------------*/
  23. MyWindow :: MyWindow ( unsigned long windowId ) :
  24.             IFrameWindow ( windowId ),
  25.  
  26.             cnrCtl (new ICnrCtl (windowId + 20, this, this, IRectangle())),
  27.  
  28.             car ((Customer *) 0),
  29.             space ((Customer *) 0),
  30.             bolt ((Customer *) 0),
  31.             starfleet ((Customer *) 0),
  32.  
  33.             reslib()
  34. {
  35.   /***********************************************************************/
  36.   /* Set the frame icon                                                  */
  37.   /* Set the container as the frame client.                              */
  38.   /***********************************************************************/
  39.   setIcon( id() );
  40.   setClient(cnrCtl);
  41.  
  42.   /***********************************************************************/
  43.   /* Create the container objects ...                                    */
  44.   /***********************************************************************/
  45.   car =       new Customer ("Auto Racer", CAR, "Al Uncer",
  46.                             "Le Mans, France", "(919) 555-1234", this);
  47.   space =     new Customer ("Astronaut", SPACE, "E. T.",
  48.                             "Pirx the Pilot", "(919) 555-4321", this);
  49.   bolt =      new Customer ("Technician", BOLT, "Joe Blow",
  50.                             "The Sky", "(919) 555-4321", this);
  51.   starfleet = new Customer ("Captain", STARFLEET, "J. L. Picard",
  52.                             "Starfleet", "(919) 555-1212", this);
  53.  
  54.   /***********************************************************************/
  55.   /* and add them to the container.                                      */
  56.   /***********************************************************************/
  57.   cnrCtl->addObject(car);
  58.   cnrCtl->addObject(space);
  59.   cnrCtl->addObject(bolt);
  60.   cnrCtl->addObject(starfleet, space);
  61.  
  62.   /***********************************************************************/
  63.   /* Set the container's attributes.                                     */
  64.   /***********************************************************************/
  65.   cnrCtl->setDeleteObjectsOnClose();
  66.   cnrCtl->showTreeLine();
  67.   cnrCtl->showTitle();
  68.   cnrCtl->enableDrawItem();
  69.  
  70.   /***********************************************************************/
  71.   /* Container view will be tree icon view.                              */
  72.   /***********************************************************************/
  73.   cnrCtl->showTreeIconView();
  74.  
  75.   /***********************************************************************/
  76.   /* Show it ...                                                         */
  77.   /***********************************************************************/
  78.   show();
  79.   cnrCtl->show();
  80. }
  81.  
  82. /*------------------------------------------------------------------------------
  83. | MySourceWin::MySourceWin                                                     |
  84. |                                                                              |
  85. | Constructor.                                                                 |
  86. ------------------------------------------------------------------------------*/
  87. MySourceWin :: MySourceWin ( unsigned long windowId ) :
  88.                MyWindow ( windowId )
  89. {
  90.   ITitle title (this, "Direct Manipulation Sample 3  - Source Container" );
  91.  
  92.   /***********************************************************************/
  93.   /* Enable the source for dragging from (only).                         */
  94.   /***********************************************************************/
  95.   IDMHandler::enableDragFrom( cnrCtl );
  96. };
  97.  
  98. /*------------------------------------------------------------------------------
  99. | MyTargetWin::MyTargetWin                                                     |
  100. |                                                                              |
  101. | Constructor.                                                                 |
  102. ------------------------------------------------------------------------------*/
  103. MyTargetWin :: MyTargetWin ( unsigned long windowId ) :
  104.                MyWindow ( windowId )
  105. {
  106.   ITitle title (this, "Direct Manipulation Sample 3 - Target Container" );
  107.  
  108.   /***********************************************************************/
  109.   /* Enable the target for dropping on (only).                           */
  110.   /***********************************************************************/
  111.   IDMHandler::enableDropOn( cnrCtl );
  112. }
  113.  
  114. /*------------------------------------------------------------------------------
  115. | Custoner::Customer                                                           |
  116. |                                                                              |
  117. | Copy constructor.                                                            |
  118. ------------------------------------------------------------------------------*/
  119. Customer :: Customer ( const Customer &cnrobj )  :
  120.             IContainerObject ( (const IContainerObject &)cnrobj ),
  121.             strName ( cnrobj.name() ),
  122.             strAddress ( cnrobj.address() ),
  123.             strPhone ( cnrobj.phone() ),
  124.             myWin ( cnrobj.myWin )
  125. {
  126. }
  127.  
  128. /*------------------------------------------------------------------------------
  129. | Custoner::Customer                                                           |
  130. |                                                                              |
  131. | Constructor.                                                                 |
  132. ------------------------------------------------------------------------------*/
  133. Customer :: Customer ( const IString &Text,
  134.                        unsigned long Icon,
  135.                        const IString &Name,
  136.                        const IString &Address,
  137.                        const IString &Phone,
  138.                        MyWindow* win )  :
  139.                        IContainerObject ( Text, Icon ),
  140.                        strName ( Name ),
  141.                        strAddress ( Address ),
  142.                        strPhone ( Phone ),
  143.                        myWin ( win )
  144. {
  145. }
  146.  
  147. /*------------------------------------------------------------------------------
  148. | Customer::objectCopy                                                         |
  149. |                                                                              |
  150. | Make a copy of the Customer object.  Called by                               |
  151. | IContainerObject::copyObjectTo().                                            |
  152. ------------------------------------------------------------------------------*/
  153. IContainerObject* Customer :: objectCopy()
  154. {
  155.   /***********************************************************************/
  156.   /* Use Customer copy constructor to make a copy of the object.         */
  157.   /***********************************************************************/
  158.   Customer *copy = new Customer(*this);
  159.   return((IContainerObject *)copy);
  160. }
  161.