home *** CD-ROM | disk | FTP | other *** search
- /************************************************
- *
- * WindowCV and SignalResponder test
- *
- * by Armin Vogt, EMail: armin@uni-paderborn.de
- *
- * #UPDATE 25-Sep-1993 17:28:50
- *
- ************************************************/
-
- #include <APlusPlus/exec/SignalResponder.h>
- #include <APlusPlus/intuition/WindowCV.h>
-
- #include <dos/dos.h>
-
-
- BOOL running = TRUE;
- BOOL close2 = FALSE;
- WindowCV *stop_window;
-
- class MyWindow : public WindowCV
- {
- private:
- void init();
- void init2();
-
- public:
- MyWindow(OWNER,TAGLIST) : WindowCV(owner,taglist) { init(); }
- MyWindow(OWNER,VARTAGS) : WindowCV(owner,(struct TagItem*)&tag1Type) { init(); }
- MyWindow(OWNER,WindowCV *share,TAGLIST) : WindowCV(owner,share,taglist) { }
- MyWindow(OWNER,WindowCV *share,VARTAGS) : WindowCV(owner,share,(struct TagItem*)&tag1Type) { init2(); }
-
- void On_CLOSEWINDOW(const IntuiMessageC *msg)
- {
- cout << "CLOSEWINDOW.\n";
- if (this == stop_window) running = FALSE;
- else close2 = TRUE;
- }
- void On_ACTIVEWINDOW(const IntuiMessageC *msg)
- {
- cout << title() << " is ACTIVE.\n";
- }
- void On_SIZEVERIFY(const IntuiMessageC *msg)
- {
- cout << "SIZEVERIFY. \n";
- }
- };
-
- void MyWindow::init()
- {
- _dout("init\n");
- onMessage(CLASS_CLOSEWINDOW,(OnIMessage)&On_CLOSEWINDOW);
- onMessage(CLASS_ACTIVEWINDOW,(OnIMessage)&On_ACTIVEWINDOW);
- _dout("done.\n");
- }
- void MyWindow::init2()
- {
- _dout("init2\n");
- onMessage(CLASS_SIZEVERIFY,(OnIMessage)&On_SIZEVERIFY);
- _dout("done.\n");
- }
- void onBreakGoto(SignalResponder *srp)
- {
- _dout("**Break\n");
- running = FALSE;
- }
-
-
- int main(void)
- {
- SignalResponder sr(SIGBREAKB_CTRL_C,onBreakGoto);
-
-
- MyWindow *little = new MyWindow(OWNER_NULL,
- WA_Title,"WindowC - close this to stop.",
- WA_Width,300,
- WA_Height,150,
- WA_MinHeight,20,
- WA_DragBar,TRUE,
- WA_SizeGadget,TRUE,
- WA_DepthGadget,TRUE,
- WA_CloseGadget,TRUE,
- WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_CHANGEWINDOW,
- TAG_END);
-
- MyWindow *small = new MyWindow(little,little,
- WA_Title,"WindowC sharing",
- WA_Left,301,
- WA_Width,200,
- WA_Height,150,
- WA_DragBar,TRUE,
- WA_CloseGadget,TRUE,
- WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_ACTIVEWINDOW|IDCMP_SIZEVERIFY,
- //WCV_ShareIDCMPMapper,FALSE,
- TAG_END);
-
- stop_window = little;
- cout << "Status: little=" << little->status() << " small=" << small->status() << endl;
-
- while (running)
- {
- SignalResponder::WaitSignal();
- if (close2 && small->Ok())
- {
- delete small;
- cout << "small destroyed.\n";
- }
- }
-
- IntuiObject::base.OwnerList::~OwnerList();
-
- cout << "replying not yet replied messages and closing port. goodbye." << endl;
- return TRUE;
- }
-