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 / Constraints_test.cxx < prev    next >
C/C++ Source or Header  |  1994-05-09  |  5KB  |  186 lines

  1. /******************************************************************************
  2.  *
  3.  *    $Source: apphome:APlusPlus/RCS/TESTPRGS/intuition/Constraints_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.4 $
  9.  *       $Date: 1994/05/09 21:27:58 $
  10.  *       $Author: Armin_Vogt $
  11.  *
  12.  ******************************************************************************/
  13.  
  14.  
  15. #include <APlusPlus/exec/SignalResponder.h>
  16. #include <APlusPlus/intuition/GWindow.h>
  17. #include <APlusPlus/intuition/BoopsiGadget.h>
  18. #include <APlusPlus/intuition/StdGadget.h>
  19.  
  20. extern "C" {
  21. #include <dos/dos.h>
  22. }
  23.  
  24.  
  25. volatile static char rcs_id[] = "$Id: Constraints_test.cxx,v 1.4 1994/05/09 21:27:58 Armin_Vogt Exp Armin_Vogt $";
  26.  
  27.  
  28. class MyBoopsi : public BoopsiGadget
  29. {
  30.    public:
  31.       MyBoopsi(GOB_OWNER,UBYTE *name,AttrList& attrs)
  32.       : BoopsiGadget(gob_owner,name,attrs) { }
  33.       ~MyBoopsi() {} 
  34.    
  35. };
  36.  
  37.  
  38.  
  39. BOOL running = TRUE;
  40. BOOL close2 = FALSE;
  41. GWindow *stop_window;
  42.  
  43.  
  44. class MySRSP : public SignalResponder
  45. {
  46.    public:
  47.       MySRSP(BYTE signal) : SignalResponder(signal,0) {}
  48.  
  49.       void actionCallback();
  50. };
  51.  
  52. // overload the virtual 'signal received' action callback method.
  53. void MySRSP::actionCallback()
  54. {
  55.    cout << "**Break\n";
  56.    running = FALSE;
  57. }
  58.  
  59. class MyWindow : public GWindow
  60. {
  61.    private:
  62.       void init();
  63.  
  64.    public:
  65.       MyWindow(OWNER,AttrList& attrs) : GWindow(owner,attrs) { init(); }
  66.       void On_CLOSEWINDOW(const IntuiMessageC *msg);
  67.       void On_ACTIVEWINDOW(const IntuiMessageC *msg);
  68.       void On_SIZEVERIFY(const IntuiMessageC *msg);
  69.       void handleIntuiMsg(const IntuiMessageC* imsg);
  70. };
  71.  
  72.  
  73. void MyWindow::init()
  74. {
  75.    modifyIDCMP(CLASS_NEWSIZE|CLASS_CLOSEWINDOW|CLASS_ACTIVEWINDOW|CLASS_SIZEVERIFY);
  76. }
  77.  
  78. void MyWindow::On_CLOSEWINDOW(const IntuiMessageC *msg)
  79.       {
  80.          cout << "CLOSEWINDOW.\n";
  81.          if (this == stop_window) running = FALSE;
  82.          delete this;
  83.       }
  84. void MyWindow::On_ACTIVEWINDOW(const IntuiMessageC *msg)
  85.       {
  86.          cout << title() << " is ACTIVE.\n";
  87.       }
  88. void MyWindow::On_SIZEVERIFY(const IntuiMessageC *msg)
  89.       {
  90.          cout << "SIZEVERIFY. \n";
  91.       }
  92. void MyWindow::handleIntuiMsg(const IntuiMessageC* imsg)
  93.       {
  94.          switch (imsg->getClass())
  95.          {
  96.             case CLASS_CLOSEWINDOW :
  97.                On_CLOSEWINDOW(imsg); break;
  98.             case CLASS_ACTIVEWINDOW :
  99.                On_ACTIVEWINDOW(imsg); break;
  100.             case CLASS_SIZEVERIFY :
  101.                On_SIZEVERIFY(imsg); break;
  102.          }
  103.          GWindow::handleIntuiMsg(imsg);
  104. }
  105.  
  106.  
  107. void APPmain()
  108. {
  109.    MySRSP sr(SIGBREAKB_CTRL_C);
  110.     
  111.     LineBorder LBorder;
  112.     
  113.    MyWindow *little = new MyWindow(OWNER_NULL,
  114.       AttrList( WA_Title,(ULONG)"Window - close this to stop.",
  115.         WA_Left,200,
  116.         WA_Top,200,
  117.       WA_Width,300,
  118.       WA_Height,150,
  119.       WA_MinHeight,40,
  120.       WA_MaxHeight,1600,
  121.       WA_MaxWidth,1600,
  122.       WA_DragBar,TRUE,
  123.       WA_SizeGadget,TRUE,
  124.       WA_DepthGadget,TRUE,
  125.       WA_CloseGadget,TRUE,
  126. //        GOB_BorderObj(&border),
  127.       TAG_END) );
  128.  
  129.    cout<<"TEST: little window created.\n";
  130.  
  131.    MyBoopsi *prop1 = new MyBoopsi(little,
  132.       (UBYTE*)"propgclass",
  133.       AttrList( GOB_LeftFromRightOfParent,-10,
  134.       GOB_TopFromTopOfParent,0,
  135.       GOB_RightFromRightOfParent,-1,
  136.       GOB_BottomFromBottomOfParent,0,
  137.       GA_Immediate,TRUE,
  138.       GA_RelVerify,TRUE,
  139.       PGA_Freedom,FREEVERT,
  140.       PGA_Top,200,
  141.       PGA_Total,2000,
  142.       PGA_Visible,300,
  143.       ICA_TARGET,ICTARGET_IDCMP,
  144.       PGA_NewLook,TRUE,
  145.         GOB_BorderObj(&LBorder),
  146.       TAG_END) );
  147.  
  148.     BevelBox BBorder;
  149.         
  150.    MyBoopsi *prop2 = new MyBoopsi(little,
  151.       (UBYTE*)"propgclass",
  152.         AttrList(
  153.         GOB_LeftFromLeftOfParent,2,
  154.       GOB_TopFromTopOfParent,2,
  155.         GOB_RightFromLeftOfParent,15,
  156.       GOB_BottomFromBottomOfParent,-10,
  157.       GA_Immediate,TRUE,
  158.       GA_RelVerify,TRUE,
  159.       PGA_Freedom,FREEVERT,
  160.       CONSTRAINT( PGA_Top,prop1,PGA_Top ),
  161.       PGA_Total,2000,
  162.       PGA_Visible,1000,
  163.       ICA_TARGET,ICTARGET_IDCMP,
  164.       PGA_NewLook,TRUE,
  165.         GOB_BorderObj(&BBorder),
  166.       TAG_END) );
  167.  
  168.     prop1->setAttributes( AttrList( CONSTRAINT( PGA_Top,prop2,PGA_Top ), TAG_END) );
  169.     
  170.    if (! APPOK(prop2) )
  171.       cerr << " APPOK() on "<<(APTR)prop2<<" failed, status "<<(LONG)prop2->status()<<"\n";
  172.    if (! APPOK(prop1) )
  173.       cerr << "prop1 invalid\n";
  174.     
  175.    stop_window = little;
  176.    cout << little <<endl;
  177.    cout << "sizeof( )"<<"\nBoopsigadget\t"<<sizeof(MyBoopsi)<<endl<<"\nGWindow\t"<<sizeof(GWindow)<<endl;
  178.     little->refreshGList();
  179.  
  180.    while (running)
  181.    {
  182.       SignalResponder::WaitSignal();
  183.    }
  184.  
  185.    cout << "cleaned up. goodbye.\n";
  186. }