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 / GWindow_test.C < prev    next >
C/C++ Source or Header  |  1994-01-14  |  3KB  |  122 lines

  1. /************************************************
  2.  *
  3.  *    GWindow and SignalResponder test
  4.  *
  5.  *    by Armin Vogt, EMail: armin@uni-paderborn.de
  6.  *
  7.  *    #UPDATE 03-Dec-1993 21:08:59
  8.  *
  9.  ************************************************/
  10.  
  11. #include <APlusPlus/exec/SignalResponder.h>
  12. #include <APlusPlus/intuition/GWindow.h>
  13.  
  14. #include <dos/dos.h>
  15.  
  16.  
  17. BOOL running = TRUE;
  18. BOOL close2 = FALSE;
  19. GWindow *stop_window;
  20.  
  21. class MySRSP : public SignalResponder
  22. {
  23.    public:
  24.       MySRSP(BYTE signal) : SignalResponder(signal,0) {}
  25.  
  26.       // overload the virtual 'signal received' action callback method.
  27.       void actionCallback()
  28.       {
  29.          cout << "**Break\n";
  30.          running = FALSE;
  31.       }
  32. };
  33.  
  34. class MyWindow : public GWindow
  35. {
  36.    private:
  37.       void init();
  38.  
  39.    public:
  40.       MyWindow(OWNER,TAGLIST) : GWindow(owner,taglist) { init(); }
  41.       MyWindow(OWNER,VARTAGS) : GWindow(owner,TAG1ADR) { init(); }
  42.  
  43.       void On_CLOSEWINDOW(const IntuiMessageC *msg)
  44.       {
  45.          cout << "CLOSEWINDOW.\n";
  46.          if (this == stop_window) running = FALSE;
  47.          else close2 = TRUE;
  48.       }
  49.       void On_ACTIVEWINDOW(const IntuiMessageC *msg)
  50.       {
  51.          cout << title() << " is ACTIVE.\n";
  52.       }
  53.       void On_SIZEVERIFY(const IntuiMessageC *msg)
  54.       {
  55.          cout << "SIZEVERIFY. \n";
  56.       }
  57. };
  58.  
  59.  
  60. void MyWindow::init()
  61. {
  62.    _dout("init\n");
  63.    onMessage(CLASS_CLOSEWINDOW,(OnIMessage)&On_CLOSEWINDOW);
  64.    onMessage(CLASS_ACTIVEWINDOW,(OnIMessage)&On_ACTIVEWINDOW);
  65.    _dout("done.\n");
  66. }
  67.  
  68.  
  69. int main(int argc,char *argv[])
  70. {
  71.    IntuiRoot::APPinitialise(argc,argv);
  72.  
  73.    MySRSP sr(SIGBREAKB_CTRL_C);
  74.  
  75.    MyWindow *little = new MyWindow(OWNER_NULL,
  76.       WA_Title,"WindowC - close this to stop.",
  77.       WA_Width,300,
  78.       WA_Height,150,
  79.       WA_MinHeight,20,
  80.       WA_DragBar,TRUE,
  81.       WA_SizeGadget,TRUE,
  82.       WA_DepthGadget,TRUE,
  83.       WA_CloseGadget,TRUE,
  84.       WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_ACTIVEWINDOW,
  85.       TAG_END);
  86.  
  87.    MyWindow *small = new MyWindow(little,
  88.       WCV_SharePortWithWindow,little,
  89.       WA_Title,"WindowC sharing",
  90.       WA_Left,300,
  91.       WA_Width,200,
  92.       WA_Height,150,
  93.       WA_DragBar,TRUE,
  94.       WA_CloseGadget,TRUE,
  95.       //WCV_ShareIDCMPMapper,FALSE,
  96.       TAG_END);
  97.  
  98.    stop_window = little;
  99.  
  100.    cout << little << "\n"<<small<<endl;
  101.    cout << "APPObject status: "<<little->status()
  102.    <<"\t"<<little->GraphicObject::status()<<"\t"<<little->IntuiObject::status()<<endl;
  103.  
  104.    cout <<"sizeof(WindowCV) = "<<sizeof(WindowCV)<<"\n";
  105.    cout <<"sizeof(IntuiObject) = "<<sizeof(IntuiObject)<<"\n";
  106.    cout <<"sizeof(GraphicObject) = "<<sizeof(GraphicObject)<<"\n";
  107.  
  108.    while (running)
  109.    {
  110.       SignalResponder::WaitSignal();
  111.       if (close2 && small->Ok())
  112.       {
  113.          delete small;
  114.          cout << "small destroyed.\n";
  115.       }
  116.    }
  117.  
  118.    cout << "replying not yet replied messages and closing port. goodbye." << endl;
  119.    IntuiRoot::APPexit();   // destroy all IntuiObjects
  120.    return TRUE;
  121. }
  122.