home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / aplusplus-1.01-src.lha / src / amiga / aplusplus-1.01 / testprgs / intuition / GT_test.cxx < prev    next >
C/C++ Source or Header  |  1994-05-09  |  6KB  |  228 lines

  1. /******************************************************************************
  2.  *
  3.  *    $Source: apphome:APlusPlus/RCS/TESTPRGS/intuition/GT_test.cxx,v $
  4.  *
  5.  *    Demo for the A++ Library
  6.  *    Copyright (C) 1994 by Armin Vogt, EMail: armin@uni-paderborn.de
  7.  *
  8.  *       $Revision: 1.6 $
  9.  *       $Date: 1994/05/09 21:28:25 $
  10.  *       $Author: Armin_Vogt $
  11.  *
  12.  ******************************************************************************/
  13.  
  14.  
  15. #include <APlusPlus/exec/SignalResponder.h>
  16. #include <APlusPlus/intuition/GWindow.h>
  17. #include <APlusPlus/intuition/GT_Gadgets/GT_Scroller.h>
  18. #include <APlusPlus/intuition/GT_Gadgets/GT_String.h>
  19. #include <APlusPlus/intuition/BoopsiGadget.h>
  20. #include <APlusPlus/graphics/AutoDrawArea.h>
  21.  
  22. #include <iostream.h>
  23.  
  24. extern "C" {
  25. #include <dos/dos.h>
  26. }
  27.  
  28.  
  29. volatile static char rcs_id[] = "$Id: GT_test.cxx,v 1.6 1994/05/09 21:28:25 Armin_Vogt Exp Armin_Vogt $";
  30.  
  31.  
  32. BOOL running = TRUE;
  33. BOOL close2 = FALSE;
  34. GWindow *stop_window;
  35.  
  36.  
  37. class MySRSP : public SignalResponder
  38. {
  39.    public:
  40.       MySRSP(BYTE signal) : SignalResponder(signal,0) {}
  41.       ~MySRSP() {}
  42.       // overload the virtual 'signal received' action callback method.
  43.       void actionCallback()
  44.       {
  45.          cout << "**Break\n";
  46.          running = FALSE;
  47.       }
  48. };
  49.  
  50.  
  51. class MyWindow : public GWindow
  52. {
  53.    private:
  54.       void init()
  55.       {
  56.          modifyIDCMP(CLASS_NEWSIZE|CLASS_CLOSEWINDOW|CLASS_ACTIVEWINDOW|CLASS_SIZEVERIFY);
  57.       }
  58.  
  59.    public:
  60.       MyWindow(OWNER,AttrList& attrs) : GWindow(owner,attrs) { init(); }
  61.       ~MyWindow() {}
  62.  
  63.       void On_CLOSEWINDOW(const IntuiMessageC *msg)
  64.       {
  65.          cout << "CLOSEWINDOW.\n";
  66.          if (this == stop_window) running = FALSE;
  67.          else close2 = TRUE;
  68.       }
  69.       void On_ACTIVEWINDOW(const IntuiMessageC *msg)
  70.       {
  71.          cout << title() << " is ACTIVE.\n";
  72.       }
  73.       void On_SIZEVERIFY(const IntuiMessageC *msg)
  74.       {
  75.          cout << "SIZEVERIFY. \n";
  76.       }
  77.       void handleIntuiMsg(const IntuiMessageC* imsg)
  78.       {
  79.          switch (imsg->getClass())
  80.          {
  81.             case CLASS_CLOSEWINDOW :
  82.                On_CLOSEWINDOW(imsg); break;
  83.             case CLASS_ACTIVEWINDOW :
  84.                On_ACTIVEWINDOW(imsg); break;
  85.             case CLASS_SIZEVERIFY :
  86.                On_SIZEVERIFY(imsg); break;
  87.          }
  88.          GWindow::handleIntuiMsg(imsg);
  89.       }
  90.  
  91. };
  92.  
  93.  
  94. void APPmain()
  95. {
  96.    MySRSP sr(SIGBREAKB_CTRL_C);
  97.     
  98.     NeXTBorder border;
  99.  
  100.    MyWindow *little = new MyWindow(OWNER_NULL,
  101.     AttrList(  WA_Title,"WindowC - close this to stop.",
  102.       WA_Width,300,
  103.       WA_Height,150,
  104.       WA_MinHeight,50,
  105.       WA_MinWidth,50,
  106.       WA_MaxHeight,1000,
  107.       WA_MaxWidth,1000,
  108.       WA_DragBar,TRUE,
  109.       WA_SizeGadget,TRUE,
  110.       WA_DepthGadget,TRUE,
  111.       WA_CloseGadget,TRUE,
  112.       WA_IDCMP,TRUE,
  113.         GOB_BorderObj(&border),
  114.         GOB_BorderTitle,(UBYTE*)"Boopsi & GadTools",
  115.         GOB_BackgroundColor,5,
  116.       TAG_END) );
  117.  
  118.  
  119.    class Boopsi2GTSC : public ITransponder
  120.    {
  121.       private:
  122.       public:
  123.          virtual void sendNotification(AttrList& attrs)
  124.          {
  125.             attrs.mapAttrs(PGA_Top, GTSC_Top,TAG_END);
  126.  
  127.             cout<<"   notification received: "<<attrs<<"\n";
  128.             if (APPOK(receiver1))
  129.             {
  130.                if(receiver1->setAttributes(attrs)) cout<<"   visual change\n";
  131.             }
  132.             else cerr << " receiver of this("<<(APTR)this<<") is INVALID!\n";
  133.             cout << "   notification forwarded.\n";
  134.          }
  135.    } 
  136.     boopsi2GTSC;
  137.  
  138.    class GTSC2Boopsi : public ITransponder
  139.    {
  140.       private:
  141.       public:
  142.          virtual void sendNotification(AttrList& attrs)
  143.          {
  144.             attrs.mapAttrs( GTSC_Top,PGA_Top,TAG_END);
  145.  
  146.             cout << "   notification received: "<<attrs<<"\n";
  147.             if (APPOK(receiver1))
  148.             {
  149.                if(receiver1->setAttributes(attrs)) cout<<"   visual change\n";
  150.             }
  151.             else cerr << " receiver of this("<<(APTR)this<<") is INVALID!\n";
  152.             cout << "   notification forwarded.\n";
  153.          }
  154.    } GTSC2boopsi;
  155.    
  156.     
  157.    GTSC2boopsi.setReceiver( new BoopsiGadget(little,
  158.       (UBYTE*)"propgclass",
  159.     AttrList( 
  160.         GOB_LeftFromRightOfParent,-20,
  161.       GOB_TopFromTopOfParent,1,
  162.       GOB_RightFromRightOfParent,-1,
  163.       GOB_BottomFromBottomOfParent,-1,        
  164.       GA_Immediate,TRUE,
  165.       GA_RelVerify,TRUE,
  166.       PGA_Freedom,FREEVERT,
  167.       PGA_Top,1,
  168.       PGA_Total,20,
  169.       PGA_Visible,5,
  170.       ICA_TARGET,ICTARGET_IDCMP,
  171.       PGA_NewLook,TRUE,
  172.         ITRANSPONDER(&boopsi2GTSC),
  173.       TAG_END)) );
  174.  
  175.  
  176.    boopsi2GTSC.setReceiver( new GT_Scroller(little, 
  177.     AttrList( 
  178.        GOB_LeftFromLeftOfPred,-20,
  179.       GOB_TopFromTopOfPred,0,
  180.       GOB_RightFromLeftOfPred,-2,
  181.       GOB_BottomFromBottomOfPred,-10,
  182.       GA_Immediate,TRUE,
  183.       GA_RelVerify,TRUE,
  184.       PGA_Freedom,LORIENT_VERT,
  185.       GTSC_Top,1,
  186.       GTSC_Total,20,
  187.       GTSC_Visible,2,
  188.       GTSC_Arrows,8,
  189.       GT_IDCMP,SLIDERIDCMP,
  190.         ITRANSPONDER(>SC2boopsi),
  191.       TAG_END)) );
  192.  
  193.  
  194.    class StringOut : public ITransponder
  195.    {
  196.       protected:
  197.          void sendNotification(AttrList& attrs)
  198.          {
  199.             cout << "GT_String: '" << (char*)attrs.getTagData(GTST_String,NULL) << "'\n";
  200.          }
  201.    } stringOut;
  202.    
  203.    new GT_String(little,
  204.    AttrList(
  205.       GOB_LeftFromLeftOfParent,10,
  206.       GOB_TopFromTopOfParent,10,
  207.       GOB_RightFromLeftOfPred,-10,
  208.       GOB_BottomFromTopOfParent,30,
  209.       GTST_String,(UBYTE*)"Enter here.",
  210.       GA_RelVerify,TRUE,
  211.       ITRANSPONDER(&stringOut),  // call 'stringOut::sendNotification' on attribute change. 
  212.       TAG_END) );
  213.       
  214.         
  215.    stop_window = little;
  216.  
  217.    cout << little << endl<<"Window at "<<(APTR)little<<endl;
  218.    cout << "ITransponder: "<<(APTR)>SC2boopsi<<" and "<<(APTR)&boopsi2GTSC<<endl;
  219.    little->refreshGList();
  220.  
  221.    while (running)
  222.    {
  223.       SignalResponder::WaitSignal();
  224.    }
  225.  
  226.    cout << "cleaned up. goodbye.\n";
  227. }
  228.