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 / SimpleWindow_test.cxx < prev    next >
C/C++ Source or Header  |  1994-05-09  |  3KB  |  117 lines

  1. /******************************************************************************
  2.  *
  3.  *    $Source: apphome:APlusPlus/RCS/TESTPRGS/intuition/SimpleWindow_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:29:34 $
  10.  *       $Author: Armin_Vogt $
  11.  *
  12.  ******************************************************************************/
  13.  
  14.  
  15. #include <APlusPlus/exec/SignalResponder.h>
  16. #include <APlusPlus/intuition/GWindow.h>
  17.  
  18. extern "C" {
  19. #include <dos/dos.h>
  20. }
  21.  
  22.  
  23.  
  24. // a CTRL-C signal responder from the example in the docs
  25. class MySRSP : public SignalResponder
  26. {
  27.     private:
  28.        BOOL running;  // indicates a received user break to object users
  29.    public:
  30.         MySRSP() : SignalResponder(SIGBREAKB_CTRL_C,0)
  31.       { running = TRUE; }
  32.         ~MySRSP() {}
  33.          
  34.       //  overload the virtual 'signal received' action callback method.
  35.       void actionCallback()
  36.       {
  37.          cout << "**Break\n";
  38.          running = FALSE;  // end WaitSignal loop
  39.       }
  40.         
  41.         // object users can check with this method if a user break has occurred
  42.       BOOL hasNotOccured() { return running==TRUE; }
  43. };
  44.  
  45.  
  46.  
  47. class MyWindow : public GWindow
  48. {
  49.    public:
  50.       MyWindow(OWNER,AttrList& attrs) : GWindow(owner,attrs)
  51.       {          
  52.          modifyIDCMP(CLASS_NEWSIZE|CLASS_CLOSEWINDOW|CLASS_ACTIVEWINDOW|CLASS_SIZEVERIFY);       
  53.       }         
  54.          
  55.       void On_CLOSEWINDOW(const IntuiMessageC *msg);
  56.       void On_ACTIVEWINDOW(const IntuiMessageC *msg);
  57.       void On_SIZEVERIFY(const IntuiMessageC *msg);
  58.       
  59.       void handleIntuiMsg(const IntuiMessageC* imsg);
  60. };
  61.  
  62.  
  63. void MyWindow::On_CLOSEWINDOW(const IntuiMessageC *msg)
  64.       {
  65.          cout << "CLOSEWINDOW.\n";   
  66.          delete this;   // it is allowed for WindowCV class to destroy itself
  67.       }
  68. void MyWindow::On_ACTIVEWINDOW(const IntuiMessageC *msg)
  69.       {
  70.          cout << title() << " is ACTIVE.\n";
  71.       }
  72. void MyWindow::On_SIZEVERIFY(const IntuiMessageC *msg)
  73.       {
  74.          cout << "SIZEVERIFY. \n";
  75.       }
  76. void MyWindow::handleIntuiMsg(const IntuiMessageC* imsg)
  77.       {
  78.          switch (imsg->getClass())
  79.          {
  80.             case CLASS_CLOSEWINDOW :
  81.                On_CLOSEWINDOW(imsg); break;
  82.             case CLASS_ACTIVEWINDOW :
  83.                On_ACTIVEWINDOW(imsg); break;
  84.             case CLASS_SIZEVERIFY :
  85.                On_SIZEVERIFY(imsg); break;
  86.          }
  87.          GWindow::handleIntuiMsg(imsg);
  88. }
  89.  
  90.  
  91.  
  92. void APPmain()
  93. {
  94.    MySRSP userBreak;
  95.  
  96.    MyWindow *little = new MyWindow(OWNER_NULL,
  97.    AttrList(    WA_Title,"WindowC - close this to stop.",
  98.       WA_Width,300,
  99.       WA_Height,150,
  100.       WA_MinHeight,20,
  101.       WA_DragBar,TRUE,
  102.       WA_SizeGadget,TRUE,
  103.       WA_DepthGadget,TRUE,
  104.       WA_CloseGadget,TRUE,
  105.       WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_ACTIVEWINDOW,
  106.       TAG_END) );
  107.  
  108.    cout << little << "\n";
  109.  
  110.    while (userBreak.hasNotOccured() && APPOK(little))    // APPOK(little) expands to (little!=NULL && little->Ok())
  111.    {
  112.       SignalResponder::WaitSignal();
  113.    }
  114.  
  115.    cout << "main() end.\n";
  116. }
  117.