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 >
Wrap
Text File
|
1995-05-01
|
8KB
|
161 lines
#ifndef _IBASE_ //Make sure ibase.hpp is included
#include <ibase.hpp> // since that is where IC_<environ>
#endif // is defined.
#include "dmsamp3.hpp"
/*------------------------------------------------------------------------------
| main |
------------------------------------------------------------------------------*/
int main()
{
MySourceWin sourceWin (WND_SOURCE);
MyTargetWin targetWin (WND_TARGET);
IApplication::current().run();
return 0;
}
/*------------------------------------------------------------------------------
| MyWindow::MyWindow |
| |
| Constructor. |
------------------------------------------------------------------------------*/
MyWindow :: MyWindow ( unsigned long windowId ) :
IFrameWindow ( windowId ),
cnrCtl (new ICnrCtl (windowId + 20, this, this, IRectangle())),
car ((Customer *) 0),
space ((Customer *) 0),
bolt ((Customer *) 0),
starfleet ((Customer *) 0),
reslib()
{
/***********************************************************************/
/* Set the frame icon */
/* Set the container as the frame client. */
/***********************************************************************/
setIcon( id() );
setClient(cnrCtl);
/***********************************************************************/
/* Create the container objects ... */
/***********************************************************************/
car = new Customer ("Auto Racer", CAR, "Al Uncer",
"Le Mans, France", "(919) 555-1234", this);
space = new Customer ("Astronaut", SPACE, "E. T.",
"Pirx the Pilot", "(919) 555-4321", this);
bolt = new Customer ("Technician", BOLT, "Joe Blow",
"The Sky", "(919) 555-4321", this);
starfleet = new Customer ("Captain", STARFLEET, "J. L. Picard",
"Starfleet", "(919) 555-1212", this);
/***********************************************************************/
/* and add them to the container. */
/***********************************************************************/
cnrCtl->addObject(car);
cnrCtl->addObject(space);
cnrCtl->addObject(bolt);
cnrCtl->addObject(starfleet, space);
/***********************************************************************/
/* Set the container's attributes. */
/***********************************************************************/
cnrCtl->setDeleteObjectsOnClose();
cnrCtl->showTreeLine();
cnrCtl->showTitle();
cnrCtl->enableDrawItem();
/***********************************************************************/
/* Container view will be tree icon view. */
/***********************************************************************/
cnrCtl->showTreeIconView();
/***********************************************************************/
/* Show it ... */
/***********************************************************************/
show();
cnrCtl->show();
}
/*------------------------------------------------------------------------------
| MySourceWin::MySourceWin |
| |
| Constructor. |
------------------------------------------------------------------------------*/
MySourceWin :: MySourceWin ( unsigned long windowId ) :
MyWindow ( windowId )
{
ITitle title (this, "Direct Manipulation Sample 3 - Source Container" );
/***********************************************************************/
/* Enable the source for dragging from (only). */
/***********************************************************************/
IDMHandler::enableDragFrom( cnrCtl );
};
/*------------------------------------------------------------------------------
| MyTargetWin::MyTargetWin |
| |
| Constructor. |
------------------------------------------------------------------------------*/
MyTargetWin :: MyTargetWin ( unsigned long windowId ) :
MyWindow ( windowId )
{
ITitle title (this, "Direct Manipulation Sample 3 - Target Container" );
/***********************************************************************/
/* Enable the target for dropping on (only). */
/***********************************************************************/
IDMHandler::enableDropOn( cnrCtl );
}
/*------------------------------------------------------------------------------
| Custoner::Customer |
| |
| Copy constructor. |
------------------------------------------------------------------------------*/
Customer :: Customer ( const Customer &cnrobj ) :
IContainerObject ( (const IContainerObject &)cnrobj ),
strName ( cnrobj.name() ),
strAddress ( cnrobj.address() ),
strPhone ( cnrobj.phone() ),
myWin ( cnrobj.myWin )
{
}
/*------------------------------------------------------------------------------
| Custoner::Customer |
| |
| Constructor. |
------------------------------------------------------------------------------*/
Customer :: Customer ( const IString &Text,
unsigned long Icon,
const IString &Name,
const IString &Address,
const IString &Phone,
MyWindow* win ) :
IContainerObject ( Text, Icon ),
strName ( Name ),
strAddress ( Address ),
strPhone ( Phone ),
myWin ( win )
{
}
/*------------------------------------------------------------------------------
| Customer::objectCopy |
| |
| Make a copy of the Customer object. Called by |
| IContainerObject::copyObjectTo(). |
------------------------------------------------------------------------------*/
IContainerObject* Customer :: objectCopy()
{
/***********************************************************************/
/* Use Customer copy constructor to make a copy of the object. */
/***********************************************************************/
Customer *copy = new Customer(*this);
return((IContainerObject *)copy);
}