home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / SAMPLES / ICLUI / DRAG4 / DMSAMP4.CPP < prev    next >
Text File  |  1993-10-20  |  8KB  |  167 lines

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