home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * $Source: apphome:APlusPlus/RCS/TESTPRGS/intuition/SimpleWindow_test.cxx,v $
- *
- * Demo for the A++ Library
- * Copyright (C) 1994 by Armin Vogt, EMail: armin@uni-paderborn.de
- *
- * $Revision: 1.5 $
- * $Date: 1994/05/09 21:29:34 $
- * $Author: Armin_Vogt $
- *
- ******************************************************************************/
-
-
- #include <APlusPlus/exec/SignalResponder.h>
- #include <APlusPlus/intuition/GWindow.h>
-
- extern "C" {
- #include <dos/dos.h>
- }
-
-
-
- // a CTRL-C signal responder from the example in the docs
- class MySRSP : public SignalResponder
- {
- private:
- BOOL running; // indicates a received user break to object users
- public:
- MySRSP() : SignalResponder(SIGBREAKB_CTRL_C,0)
- { running = TRUE; }
- ~MySRSP() {}
-
- // overload the virtual 'signal received' action callback method.
- void actionCallback()
- {
- cout << "**Break\n";
- running = FALSE; // end WaitSignal loop
- }
-
- // object users can check with this method if a user break has occurred
- BOOL hasNotOccured() { return running==TRUE; }
- };
-
-
-
- class MyWindow : public GWindow
- {
- public:
- MyWindow(OWNER,AttrList& attrs) : GWindow(owner,attrs)
- {
- modifyIDCMP(CLASS_NEWSIZE|CLASS_CLOSEWINDOW|CLASS_ACTIVEWINDOW|CLASS_SIZEVERIFY);
- }
-
- void On_CLOSEWINDOW(const IntuiMessageC *msg);
- void On_ACTIVEWINDOW(const IntuiMessageC *msg);
- void On_SIZEVERIFY(const IntuiMessageC *msg);
-
- void handleIntuiMsg(const IntuiMessageC* imsg);
- };
-
-
- void MyWindow::On_CLOSEWINDOW(const IntuiMessageC *msg)
- {
- cout << "CLOSEWINDOW.\n";
- delete this; // it is allowed for WindowCV class to destroy itself
- }
- void MyWindow::On_ACTIVEWINDOW(const IntuiMessageC *msg)
- {
- cout << title() << " is ACTIVE.\n";
- }
- void MyWindow::On_SIZEVERIFY(const IntuiMessageC *msg)
- {
- cout << "SIZEVERIFY. \n";
- }
- void MyWindow::handleIntuiMsg(const IntuiMessageC* imsg)
- {
- switch (imsg->getClass())
- {
- case CLASS_CLOSEWINDOW :
- On_CLOSEWINDOW(imsg); break;
- case CLASS_ACTIVEWINDOW :
- On_ACTIVEWINDOW(imsg); break;
- case CLASS_SIZEVERIFY :
- On_SIZEVERIFY(imsg); break;
- }
- GWindow::handleIntuiMsg(imsg);
- }
-
-
-
- void APPmain()
- {
- MySRSP userBreak;
-
- MyWindow *little = new MyWindow(OWNER_NULL,
- AttrList( 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_ACTIVEWINDOW,
- TAG_END) );
-
- cout << little << "\n";
-
- while (userBreak.hasNotOccured() && APPOK(little)) // APPOK(little) expands to (little!=NULL && little->Ok())
- {
- SignalResponder::WaitSignal();
- }
-
- cout << "main() end.\n";
- }
-