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 / graphics / AutoDrawArea_test.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-10  |  4.1 KB  |  166 lines

  1. /******************************************************************************
  2.  *
  3.  *    $Source: apphome:APlusPlus/RCS/TESTPRGS/graphics/AutoDrawArea_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.5 $
  9.  *       $Date: 1994/05/09 21:26:30 $
  10.  *       $Author: Armin_Vogt $
  11.  *
  12.  ******************************************************************************/
  13.  
  14.  
  15. extern "C" {
  16. #include <dos/dos.h>
  17. }
  18. #include <APlusPlus/exec/SignalResponder.h>
  19. #include <APlusPlus/intuition/GWindow.h>
  20. #include <APlusPlus/graphics/AutoDrawArea.h>
  21.  
  22.  
  23. volatile static char rcs_id[] = "$Id: AutoDrawArea_test.cxx,v 1.5 1994/05/09 21:26:30 Armin_Vogt Exp Armin_Vogt $";
  24.  
  25.  
  26. BOOL running = TRUE;
  27. BOOL close2 = FALSE;
  28.  
  29. class MySRSP : public SignalResponder
  30. {
  31.    public:
  32.       MySRSP(BYTE signal) : SignalResponder(signal,0) {}
  33.       ~MySRSP() {}
  34.       // overload the virtual 'signal received' action callback method.
  35.       void actionCallback()
  36.       {
  37.          cout << "**Break\n";
  38.          running = FALSE;
  39.       }
  40. };
  41. class MyAutoDrawArea : public AutoDrawArea
  42. {
  43.    public:
  44.       MyAutoDrawArea(GraphicObject *owner,AttrList& attrs) : AutoDrawArea(owner,attrs) { }
  45.       ~MyAutoDrawArea() {}
  46.         
  47.       void drawSelf()
  48.       {
  49.             setDrMd(JAM2);
  50.             setDrPt(~0);
  51.          setAPen(2);
  52.          setOPen(3);
  53.          rectFill(0,0,iWidth()-1,iHeight()-1);
  54.          setAPen(3);
  55.          drawEllipse(iWidth()/2,iHeight()/2,iWidth()/2,iHeight()/2);
  56.             setAPen(1);
  57.             WORD polyTable[] = {10,10,40,10,40,40,10,40,10,10};
  58.             polyDraw(5,polyTable);
  59.       }
  60. };
  61.  
  62. class MyWindow : public GWindow
  63. {
  64.    private:
  65.       void init();
  66.  
  67.    public:
  68.       MyWindow(OWNER,AttrList& attrs) : GWindow(owner,attrs) { init(); }
  69.     
  70.  
  71.       void On_CLOSEWINDOW(const IntuiMessageC *msg)
  72.       {
  73.          cout << "CLOSEWINDOW.\n";
  74.          delete this;
  75.          running = FALSE;
  76.       }
  77.       void On_ACTIVEWINDOW(const IntuiMessageC *msg)
  78.       {
  79.          cout << title() << " is ACTIVE.\n";
  80.       }
  81.       void On_SIZEVERIFY(const IntuiMessageC *msg)
  82.       {
  83.          cout << "SIZEVERIFY. \n";
  84.       }
  85.       virtual void handleIntuiMsg(const IntuiMessageC* imsg)
  86.       {
  87.          switch (imsg->getClass())
  88.          {
  89.             case CLASS_CLOSEWINDOW :
  90.                On_CLOSEWINDOW(imsg); break;
  91.             case CLASS_ACTIVEWINDOW :
  92.                On_ACTIVEWINDOW(imsg); break;
  93.             case CLASS_SIZEVERIFY :
  94.                On_SIZEVERIFY(imsg); break;
  95.          }
  96.          GWindow::handleIntuiMsg(imsg);
  97.       }
  98. };
  99.  
  100. void MyWindow::init()
  101. {
  102.    modifyIDCMP(CLASS_NEWSIZE|CLASS_CLOSEWINDOW|CLASS_ACTIVEWINDOW|CLASS_SIZEVERIFY);
  103. }
  104.  
  105.  
  106. void APPmain()
  107. {
  108.    MySRSP sr(SIGBREAKB_CTRL_C);
  109.  
  110.     
  111.     NeXTBorder lineBorder;
  112.  
  113.  
  114.    MyWindow *little = new MyWindow(OWNER_NULL,
  115.    AttrList( WA_Title,"WindowC - close this to stop.",
  116.         WA_Left,300,
  117.         WA_Top,200,
  118.       WA_Width,300,
  119.       WA_Height,150,
  120.       WA_MinHeight,100,
  121.         WA_MinWidth,200,
  122.       WA_MaxHeight,1600,
  123.       WA_MaxWidth,1600,
  124.       WA_DragBar,TRUE,
  125.       WA_SizeGadget,TRUE,
  126.       WA_DepthGadget,TRUE,
  127.       WA_CloseGadget,TRUE,
  128.       WA_IDCMP,IDCMP_CLOSEWINDOW,
  129.         GOB_BorderObj(&lineBorder),
  130.         GOB_BorderTitle, (UBYTE*)" AutoDrawArea ",
  131.         GOB_BackgroundColor, 4,
  132.       TAG_END) );
  133.  
  134.    new MyAutoDrawArea(little,
  135.    AttrList( GOB_LeftFromLeftOfParent,0,
  136.              GOB_TopFromTopOfParent,0,
  137.              GOB_RightFromRightOfParent,0,
  138.              GOB_BottomFromBottomOfParent,0,
  139.              TAG_END) );
  140.       
  141.    new MyAutoDrawArea(little,
  142.    AttrList( GOB_LeftFromRightOfParent,-50,
  143.              GOB_TopFromTopOfParent,10,
  144.              GOB_RightFromRightOfParent,-10,
  145.              GOB_BottomFromBottomOfParent,-1,
  146.              GOB_BorderObj(&lineBorder),
  147.              TAG_END) );
  148.     
  149.     new MyAutoDrawArea(little,
  150.    AttrList( GOB_LeftFromLeftOfPred,-50,
  151.              GOB_TopFromTopOfParent,10,
  152.              GOB_RightFromLeftOfPred,-1,
  153.              GOB_BottomFromBottomOfParent,-2,
  154.              GOB_BorderObj(&lineBorder),
  155.              TAG_END) );
  156.  
  157.     little->refreshGList();        // display objects
  158.        
  159.    while (running)
  160.    {
  161.       SignalResponder::WaitSignal();
  162.    }
  163.  
  164.    cout << "cleaned up. goodbye.\n";
  165. }
  166.