home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
keysrt.zip
/
test.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-23
|
21KB
|
548 lines
/*******************************************************************************
* FILE NAME: test.cpp *
* *
* DESCRIPTION: *
* Class implementation of the class: *
* test *
* ---------------------------------------------------------------------------- *
* Warning: This file was generated by the VisualAge C++ Visual Builder. *
* Modifications to this source file will be lost when the part is regenerated. *
*******************************************************************************/
#ifndef _IFRAME_
#include <iframe.hpp>
#endif
#ifndef _ICANVAS_
#include <icanvas.hpp>
#endif
#ifndef _IPUSHBUT_
#include <ipushbut.hpp>
#endif
#ifndef _IRECT_
#include <irect.hpp>
#endif
#ifndef _IPOINT_
#include <ipoint.hpp>
#endif
#ifndef _ICNRCOL_
#include <icnrcol.hpp>
#endif
#ifndef _IMYKYSRT_
#include "imykysrt.h"
#endif
#ifndef _INOTIFEV_
#include <inotifev.hpp>
#endif
#ifndef _IOBSERVR_
#include <iobservr.hpp>
#endif
#ifndef _ISTDNTFY_
#include <istdntfy.hpp>
#endif
#ifndef _TEST_
#include "test.hpp"
#endif
#ifndef _IVBDEFS_
#include <ivbdefs.h>
#endif
#ifndef _ITRACE_
#include <itrace.hpp>
#endif
//*****************************************************************************
// Class definition for testConn13
//*****************************************************************************
class testConn13 : public IObserver {
public:
virtual ~testConn13(){};
//---------------------------------------------------------------------------
// public member functions
//---------------------------------------------------------------------------
void initialize(IMyKeySortedSet< APerson* > * aSource, IVBContainerControl< APerson*, IMyKeySortedSet<APerson*>, testVBContainerControl1CnrObj > * aTarget)
{source = aSource; target = aTarget; aligning = false; };
void setSource()
{ };
void setTarget()
{
if (aligning==false) {
IFUNCTRACE_DEVELOP();
ITRACE_DEVELOP(" firing connection : MyKeySortedSet1(this) to VBContainerControl1(items))");
ITRACE_DEVELOP(" setting target from source ");
aligning = true;
try {target->setItems(source);}
catch (IException& exc) {};
aligning = false;
}
};
protected:
//---------------------------------------------------------------------------
// protected member functions
//---------------------------------------------------------------------------
virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
{
if (anEvent.notificationId() == VBINITIALIZEID) setTarget();
if ((anEvent.notificationId() == IVBContainerControl< APerson*, IMyKeySortedSet<APerson*>, testVBContainerControl1CnrObj >::itemsId) && (target == &anEvent.notifier()))
setSource(); /* set source to target value */
return(*this);
};
private:
//---------------------------------------------------------------------------
// private member data
//---------------------------------------------------------------------------
IMyKeySortedSet< APerson* > * source;
IVBContainerControl< APerson*, IMyKeySortedSet<APerson*>, testVBContainerControl1CnrObj > * target;
Boolean aligning;
}; //testConn13
//*****************************************************************************
// Class definition for testConn14
//*****************************************************************************
class testConn14 : public IObserver, public IStandardNotifier {
public:
virtual ~testConn14(){};
//---------------------------------------------------------------------------
// public member functions
//---------------------------------------------------------------------------
void initialize(IPushButton * aSource, IMyKeySortedSet< APerson* > * aTarget)
{source = aSource; target = aTarget; enableNotification(); };
protected:
//---------------------------------------------------------------------------
// protected member functions
//---------------------------------------------------------------------------
virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
{
if (anEvent.notificationId() == IPushButton::buttonClickId)
{
IFUNCTRACE_DEVELOP();
ITRACE_DEVELOP(" firing connection : PushButton1(buttonClickEvent) to MyKeySortedSet1(customLogic, \"add an item to the collection\"))");
try {codeSnippet(&anEvent);}
catch (IException& exc) {};
}
return(*this);
};
private:
//---------------------------------------------------------------------------
// private member functions
//---------------------------------------------------------------------------
void codeSnippet(const INotificationEvent* event)
{
ITime time;
APerson* p = new APerson (time.asString(),"1222","2222");
target->add(p);
};
//---------------------------------------------------------------------------
// private member data
//---------------------------------------------------------------------------
IPushButton * source;
IMyKeySortedSet< APerson* > * target;
}; //testConn14
//*****************************************************************************
// Class definition for testConn2
//*****************************************************************************
class testConn2 : public IObserver, public IStandardNotifier {
public:
virtual ~testConn2(){};
//---------------------------------------------------------------------------
// public member functions
//---------------------------------------------------------------------------
void initialize(IPushButton * aSource, IMyKeySortedSet< APerson* > * aTarget)
{source = aSource; target = aTarget; enableNotification(); };
protected:
//---------------------------------------------------------------------------
// protected member functions
//---------------------------------------------------------------------------
virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
{
if (anEvent.notificationId() == IPushButton::buttonClickId)
{
IFUNCTRACE_DEVELOP();
ITRACE_DEVELOP(" firing connection : PushButton2(buttonClickEvent) to MyKeySortedSet1(customLogic, \"remove all elements in the collection\"))");
try {codeSnippet(&anEvent);}
catch (IException& exc) {};
}
return(*this);
};
private:
//---------------------------------------------------------------------------
// private member functions
//---------------------------------------------------------------------------
void codeSnippet(const INotificationEvent* event)
{
while(!target->isEmpty()) {
APerson * elem = target->firstElement();
target->removeFirst();
elem->disableNotification();
delete elem;
}
};
//---------------------------------------------------------------------------
// private member data
//---------------------------------------------------------------------------
IPushButton * source;
IMyKeySortedSet< APerson* > * target;
}; //testConn2
//*****************************************************************************
// Class definition for testConn3
//*****************************************************************************
class testConn3 : public IObserver, public IStandardNotifier {
public:
virtual ~testConn3(){};
//---------------------------------------------------------------------------
// public member functions
//---------------------------------------------------------------------------
void initialize(IPushButton * aSource, IFrameWindow * aTarget)
{source = aSource; target = aTarget; enableNotification(); };
protected:
//---------------------------------------------------------------------------
// protected member functions
//---------------------------------------------------------------------------
virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
{
if (anEvent.notificationId() == IPushButton::buttonClickId)
{
IFUNCTRACE_DEVELOP();
ITRACE_DEVELOP(" firing connection : PushButton2(buttonClickEvent) to FrameWindow(close))");
try {target->close();}
catch (IException& exc) {};
}
return(*this);
};
private:
//---------------------------------------------------------------------------
// private member data
//---------------------------------------------------------------------------
IPushButton * source;
IFrameWindow * target;
}; //testConn3
//*****************************************************************************
// Class definition for testConn4
//*****************************************************************************
class testConn4 : public IObserver, public IStandardNotifier {
public:
virtual ~testConn4(){};
//---------------------------------------------------------------------------
// public member functions
//---------------------------------------------------------------------------
void initialize(IPushButton * aSource, IMyKeySortedSet< APerson* > * aTarget)
{source = aSource; target = aTarget; enableNotification(); };
protected:
//---------------------------------------------------------------------------
// protected member functions
//---------------------------------------------------------------------------
virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
{
if (anEvent.notificationId() == IPushButton::buttonClickId)
{
IFUNCTRACE_DEVELOP();
ITRACE_DEVELOP(" firing connection : PushButton3(buttonClickEvent) to MyKeySortedSet1(customLogic, \"clear all items\"))");
try {codeSnippet(&anEvent);}
catch (IException& exc) {};
}
return(*this);
};
private:
//---------------------------------------------------------------------------
// private member functions
//---------------------------------------------------------------------------
void codeSnippet(const INotificationEvent* event)
{
while(!target->isEmpty()) {
APerson * elem = target->firstElement();
target->removeFirst();
elem->disableNotification();
delete elem;
}
};
//---------------------------------------------------------------------------
// private member data
//---------------------------------------------------------------------------
IPushButton * source;
IMyKeySortedSet< APerson* > * target;
}; //testConn4
//------------------------------------------------------------------------------
// testVBContainerControl1CnrObj :: testVBContainerControl1CnrObj
//------------------------------------------------------------------------------
#pragma export (testVBContainerControl1CnrObj::testVBContainerControl1CnrObj(APerson&))
testVBContainerControl1CnrObj::testVBContainerControl1CnrObj(APerson& anObject)
:IVBContainerObject(anObject.asDebugInfo(), ISystemPointerHandle(ISystemPointerHandle::warning)),
Age(anObject.Age()), Name(anObject.Name()), pRealObject(anObject)
{
enableDataUpdate();
handleNotificationsFor(pRealObject);
}
//------------------------------------------------------------------------------
// testVBContainerControl1CnrObj :: testVBContainerControl1CnrObj
//------------------------------------------------------------------------------
#pragma export (testVBContainerControl1CnrObj::testVBContainerControl1CnrObj(testVBContainerControl1CnrObj&))
testVBContainerControl1CnrObj::testVBContainerControl1CnrObj(testVBContainerControl1CnrObj& anObject)
:IVBContainerObject(anObject.iconText(), anObject.icon()),
Age(anObject.Age), Name(anObject.Name), pRealObject(anObject.pRealObject)
{ }
//------------------------------------------------------------------------------
// testVBContainerControl1CnrObj :: ~testVBContainerControl1CnrObj
//------------------------------------------------------------------------------
#pragma export (testVBContainerControl1CnrObj::~testVBContainerControl1CnrObj())
testVBContainerControl1CnrObj::~testVBContainerControl1CnrObj()
{
this->stopHandlingNotificationsFor(pRealObject);
}
//------------------------------------------------------------------------------
// testVBContainerControl1CnrObj :: refreshFromObject
//------------------------------------------------------------------------------
#pragma export (testVBContainerControl1CnrObj::refreshFromObject())
IVBContainerObject & testVBContainerControl1CnrObj::refreshFromObject()
{
setIconText(pRealObject.asDebugInfo());
setIcon(ISystemPointerHandle(ISystemPointerHandle::warning));
Age = pRealObject.Age();
Name = pRealObject.Name();
return *this;
}
//------------------------------------------------------------------------------
// testVBContainerControl1CnrObj :: updateToObject
//------------------------------------------------------------------------------
IVBContainerObject & testVBContainerControl1CnrObj::updateToObject()
{
pRealObject.setAge(Age);
pRealObject.setName(Name);
return *this;
}
//------------------------------------------------------------------------------
// testVBContainerControl1CnrObj :: operator=
//------------------------------------------------------------------------------
testVBContainerControl1CnrObj& testVBContainerControl1CnrObj::operator=(const testVBContainerControl1CnrObj& anObject)
{
if (this == &anObject) {
return *this;
}
IVBContainerObject::operator=(anObject);
Age = anObject.Age;
Name = anObject.Name;
return *this;
}
#pragma export (test::readyId)
const INotificationId test::readyId = "test::readyId";
#pragma export (test::partWindowId)
unsigned long test::partWindowId = 0;
//------------------------------------------------------------------------------
// test :: defaultFramingSpec
//------------------------------------------------------------------------------
#pragma export (test::defaultFramingSpec())
const IRectangle test::defaultFramingSpec()
{
return(IRectangle(IPoint(30, IWindow::desktopWindow()->size().height() - 30 - 423),ISize(555, 423)));
}
//------------------------------------------------------------------------------
// test :: defaultTitle
//------------------------------------------------------------------------------
#pragma export (test::defaultTitle())
IString test::defaultTitle()
{
return("IVKeySortedSet");
}
//------------------------------------------------------------------------------
// test :: test
//------------------------------------------------------------------------------
#pragma export (test::test(unsigned long, IWindow*, IWindow*, const IRectangle&, const IFrameWindow::Style&, const char*))
test::test(
unsigned long id,
IWindow* parent,
IWindow* owner,
const IRectangle& rect,
const IFrameWindow::Style& style,
const char* title)
: IFrameWindow((partWindowId) ? partWindowId : id, parent, owner, rect, style, title)
{
partWindowId = (partWindowId) ? partWindowId : id;
iCanvas = new ICanvas(
IC_FRAME_CLIENT_ID,
this,
this,
IRectangle());
iPushButton1 = new IPushButton(
partWindowId+WNDOFFSET_test_PushButton1,
iCanvas,
iCanvas,
IRectangle(IPoint(383,78),ISize(57, 34)));
iVBContainerControl1 = new IVBContainerControl< APerson*, IMyKeySortedSet<APerson*>, testVBContainerControl1CnrObj >(
partWindowId+WNDOFFSET_test_VBContainerControl1,
iCanvas,
iCanvas,
IRectangle(IPoint(80,165),ISize(380, 209)));
iContainerColumn1 = new IContainerColumn(offsetof(testVBContainerControl1CnrObj, Name), IContainerColumn::defaultHeadingStyle ( ), (IContainerColumn::defaultDataStyle ( )) & ~IContainerColumn::icon | IContainerColumn::string);
iContainerColumn2 = new IContainerColumn(offsetof(testVBContainerControl1CnrObj, Age), IContainerColumn::defaultHeadingStyle ( ), (IContainerColumn::defaultDataStyle ( )) & ~IContainerColumn::icon | IContainerColumn::string);
iPushButton2 = new IPushButton(
partWindowId+WNDOFFSET_test_PushButton2,
iCanvas,
iCanvas,
IRectangle(IPoint(130,81),ISize(67, 34)));
iPushButton3 = new IPushButton(
partWindowId+WNDOFFSET_test_PushButton3,
iCanvas,
iCanvas,
IRectangle(IPoint(260,79),ISize(66, 34)));
iMyKeySortedSet1 = new IMyKeySortedSet< APerson* >();
conn13 = new testConn13();
conn14 = new testConn14();
conn2 = new testConn2();
conn3 = new testConn3();
conn4 = new testConn4();
this->setFocus();
this->setClient(iCanvas);
iPushButton1->setText("add");
iVBContainerControl1->showDetailsView();
iVBContainerControl1->addColumn(iContainerColumn1);
iVBContainerControl1->addColumn(iContainerColumn2);
iContainerColumn1->setHeadingText("name");
iContainerColumn1->setDisplayWidth(125);
iContainerColumn2->setHeadingText("age");
iPushButton2->setText("close");
iPushButton3->setText("clear");
} //end constructor
//------------------------------------------------------------------------------
// test :: ~test
//------------------------------------------------------------------------------
#pragma export (test::~test())
test::~test()
{
conn13->stopHandlingNotificationsFor(*iMyKeySortedSet1);
conn13->stopHandlingNotificationsFor(*iVBContainerControl1);
conn14->stopHandlingNotificationsFor(*iPushButton1);
conn2->stopHandlingNotificationsFor(*iPushButton2);
conn3->stopHandlingNotificationsFor(*iPushButton2);
conn4->stopHandlingNotificationsFor(*iPushButton3);
delete conn13;
delete conn14;
delete conn2;
delete conn3;
delete conn4;
delete iCanvas;
delete iPushButton1;
delete iVBContainerControl1;
delete iContainerColumn1;
delete iContainerColumn2;
delete iPushButton2;
delete iPushButton3;
delete iMyKeySortedSet1;
}
//------------------------------------------------------------------------------
// test :: initializePart
//------------------------------------------------------------------------------
#pragma export (test::initializePart())
test & test::initializePart()
{
makeConnections();
notifyObservers(INotificationEvent(readyId, *this));
return *this;
}
//------------------------------------------------------------------------------
// test :: makeConnections
//------------------------------------------------------------------------------
#pragma export (test::makeConnections())
Boolean test::makeConnections()
{
this->enableNotification();
iCanvas->enableNotification();
iPushButton1->enableNotification();
iVBContainerControl1->enableNotification();
iPushButton2->enableNotification();
iPushButton3->enableNotification();
iMyKeySortedSet1->enableNotification();
conn13->initialize(iMyKeySortedSet1, iVBContainerControl1);
conn13->handleNotificationsFor(*iMyKeySortedSet1);
conn13->handleNotificationsFor(*iVBContainerControl1);
conn14->initialize(iPushButton1, iMyKeySortedSet1);
conn14->handleNotificationsFor(*iPushButton1);
conn2->initialize(iPushButton2, iMyKeySortedSet1);
conn2->handleNotificationsFor(*iPushButton2);
conn3->initialize(iPushButton2, this);
conn3->handleNotificationsFor(*iPushButton2);
conn4->initialize(iPushButton3, iMyKeySortedSet1);
conn4->handleNotificationsFor(*iPushButton3);
conn13->setTarget();
return true;
}