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

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