home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * $Source: apphome:APlusPlus/RCS/TESTPRGS/intuition/GT_test.cxx,v $
- *
- * Demo for the A++ Library
- * Copyright (C) 1994 by Armin Vogt, EMail: armin@uni-paderborn.de
- *
- * $Revision: 1.6 $
- * $Date: 1994/05/09 21:28:25 $
- * $Author: Armin_Vogt $
- *
- ******************************************************************************/
-
-
- #include <APlusPlus/exec/SignalResponder.h>
- #include <APlusPlus/intuition/GWindow.h>
- #include <APlusPlus/intuition/GT_Gadgets/GT_Scroller.h>
- #include <APlusPlus/intuition/GT_Gadgets/GT_String.h>
- #include <APlusPlus/intuition/BoopsiGadget.h>
- #include <APlusPlus/graphics/AutoDrawArea.h>
-
- #include <iostream.h>
-
- extern "C" {
- #include <dos/dos.h>
- }
-
-
- volatile static char rcs_id[] = "$Id: GT_test.cxx,v 1.6 1994/05/09 21:28:25 Armin_Vogt Exp Armin_Vogt $";
-
-
- BOOL running = TRUE;
- BOOL close2 = FALSE;
- GWindow *stop_window;
-
-
- class MySRSP : public SignalResponder
- {
- public:
- MySRSP(BYTE signal) : SignalResponder(signal,0) {}
- ~MySRSP() {}
- // overload the virtual 'signal received' action callback method.
- void actionCallback()
- {
- cout << "**Break\n";
- running = FALSE;
- }
- };
-
-
- class MyWindow : public GWindow
- {
- private:
- void init()
- {
- modifyIDCMP(CLASS_NEWSIZE|CLASS_CLOSEWINDOW|CLASS_ACTIVEWINDOW|CLASS_SIZEVERIFY);
- }
-
- public:
- MyWindow(OWNER,AttrList& attrs) : GWindow(owner,attrs) { init(); }
- ~MyWindow() {}
-
- 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 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 sr(SIGBREAKB_CTRL_C);
-
- NeXTBorder border;
-
- MyWindow *little = new MyWindow(OWNER_NULL,
- AttrList( WA_Title,"WindowC - close this to stop.",
- WA_Width,300,
- WA_Height,150,
- WA_MinHeight,50,
- WA_MinWidth,50,
- WA_MaxHeight,1000,
- WA_MaxWidth,1000,
- WA_DragBar,TRUE,
- WA_SizeGadget,TRUE,
- WA_DepthGadget,TRUE,
- WA_CloseGadget,TRUE,
- WA_IDCMP,TRUE,
- GOB_BorderObj(&border),
- GOB_BorderTitle,(UBYTE*)"Boopsi & GadTools",
- GOB_BackgroundColor,5,
- TAG_END) );
-
-
- class Boopsi2GTSC : public ITransponder
- {
- private:
- public:
- virtual void sendNotification(AttrList& attrs)
- {
- attrs.mapAttrs(PGA_Top, GTSC_Top,TAG_END);
-
- cout<<" notification received: "<<attrs<<"\n";
- if (APPOK(receiver1))
- {
- if(receiver1->setAttributes(attrs)) cout<<" visual change\n";
- }
- else cerr << " receiver of this("<<(APTR)this<<") is INVALID!\n";
- cout << " notification forwarded.\n";
- }
- }
- boopsi2GTSC;
-
- class GTSC2Boopsi : public ITransponder
- {
- private:
- public:
- virtual void sendNotification(AttrList& attrs)
- {
- attrs.mapAttrs( GTSC_Top,PGA_Top,TAG_END);
-
- cout << " notification received: "<<attrs<<"\n";
- if (APPOK(receiver1))
- {
- if(receiver1->setAttributes(attrs)) cout<<" visual change\n";
- }
- else cerr << " receiver of this("<<(APTR)this<<") is INVALID!\n";
- cout << " notification forwarded.\n";
- }
- } GTSC2boopsi;
-
-
- GTSC2boopsi.setReceiver( new BoopsiGadget(little,
- (UBYTE*)"propgclass",
- AttrList(
- GOB_LeftFromRightOfParent,-20,
- GOB_TopFromTopOfParent,1,
- GOB_RightFromRightOfParent,-1,
- GOB_BottomFromBottomOfParent,-1,
- GA_Immediate,TRUE,
- GA_RelVerify,TRUE,
- PGA_Freedom,FREEVERT,
- PGA_Top,1,
- PGA_Total,20,
- PGA_Visible,5,
- ICA_TARGET,ICTARGET_IDCMP,
- PGA_NewLook,TRUE,
- ITRANSPONDER(&boopsi2GTSC),
- TAG_END)) );
-
-
- boopsi2GTSC.setReceiver( new GT_Scroller(little,
- AttrList(
- GOB_LeftFromLeftOfPred,-20,
- GOB_TopFromTopOfPred,0,
- GOB_RightFromLeftOfPred,-2,
- GOB_BottomFromBottomOfPred,-10,
- GA_Immediate,TRUE,
- GA_RelVerify,TRUE,
- PGA_Freedom,LORIENT_VERT,
- GTSC_Top,1,
- GTSC_Total,20,
- GTSC_Visible,2,
- GTSC_Arrows,8,
- GT_IDCMP,SLIDERIDCMP,
- ITRANSPONDER(>SC2boopsi),
- TAG_END)) );
-
-
- class StringOut : public ITransponder
- {
- protected:
- void sendNotification(AttrList& attrs)
- {
- cout << "GT_String: '" << (char*)attrs.getTagData(GTST_String,NULL) << "'\n";
- }
- } stringOut;
-
- new GT_String(little,
- AttrList(
- GOB_LeftFromLeftOfParent,10,
- GOB_TopFromTopOfParent,10,
- GOB_RightFromLeftOfPred,-10,
- GOB_BottomFromTopOfParent,30,
- GTST_String,(UBYTE*)"Enter here.",
- GA_RelVerify,TRUE,
- ITRANSPONDER(&stringOut), // call 'stringOut::sendNotification' on attribute change.
- TAG_END) );
-
-
- stop_window = little;
-
- cout << little << endl<<"Window at "<<(APTR)little<<endl;
- cout << "ITransponder: "<<(APTR)>SC2boopsi<<" and "<<(APTR)&boopsi2GTSC<<endl;
- little->refreshGList();
-
- while (running)
- {
- SignalResponder::WaitSignal();
- }
-
- cout << "cleaned up. goodbye.\n";
- }
-