home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0400 / CCE_0423.ZIP / CCE_0423.PD / GEM.ZOO / gema.cc < prev    next >
C/C++ Source or Header  |  1992-04-26  |  2KB  |  100 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is Copyright 1992 by Warwick W. Allison,
  4. //  and is freely distributable providing no charge is made.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7.  
  8. #include "aesbind.h"
  9. #include "gema.h"
  10.  
  11.  
  12. GEMactivity::GEMactivity(GEMmenu& m, GEMdesktop& d) :
  13.     Menu(&m), Desk(&d)
  14. {
  15.     AddWindow(*Desk);
  16. }
  17.  
  18. GEMactivity::GEMactivity(GEMmenu& m) :
  19.     Menu(&m), Desk(0)
  20. { }
  21.  
  22. GEMactivity::~GEMactivity()
  23. { }
  24.  
  25. void GEMactivity::AddWindow(GEMwindow& w)
  26. {
  27.     W=new struct WL(&w,W);
  28. }
  29.  
  30. void GEMactivity::Do()
  31. {
  32.     int Pipe[32];
  33.     int mx,my,button,meta,key,count;
  34.     ClickResult r=ContinueInteraction;
  35.  
  36.     int applid=appl_init();
  37.  
  38.     Menu->Show();
  39.  
  40.     graf_mouse(ARROW,0);
  41.  
  42.     while (r==ContinueInteraction) {
  43.         int got=evnt_multi(MU_KEYBD|MU_BUTTON|MU_MESAG,
  44.                 1,1,1,0,0,0,0,0,0,0,0,0,0,
  45.                 Pipe,0,&mx,&my,&button,&meta,&key,&count
  46.             );
  47.  
  48.         if (got&MU_KEYBD) {
  49.             // call key processor
  50.         }
  51.  
  52.         if (got&MU_BUTTON) {
  53.             GEMwindow *win=0;
  54.             for (WL* c=W; c && !win; c=c->Next) {
  55.                 int X,Y,W,H;
  56.                 wind_get(c->Window->handle(),WF_WORKXYWH,&X,&Y,&W,&H);
  57.                 if (mx>=X && mx<X+W && my>=Y && my<Y+H)
  58.                     win=c->Window;
  59.             }
  60.             if (win) win->click(mx,my);
  61.         }
  62.  
  63.         if (got&MU_MESAG) {
  64.             if (Pipe[0]==MN_SELECTED) {
  65.                 r=Menu->Do(Pipe[4]);
  66.                 menu_tnormal(Menu->Obj,Pipe[3],1);
  67.             } else {
  68.                 GEMwindow* To=Window(Pipe[3]);
  69.                 if (To) {
  70.                     switch (Pipe[0]) {
  71.                         case WM_REDRAW:
  72.                             GRECT R;
  73.                             R.g_x=Pipe[4];
  74.                             R.g_y=Pipe[5];
  75.                             R.g_w=Pipe[6];
  76.                             R.g_h=Pipe[7];
  77.                             To->RedrawOverlaps(R);
  78.                     break;    case WM_CLOSED:
  79.                             To->close();
  80.                     break;    case WM_MOVED:
  81.                             To->move(Pipe[4],Pipe[5]);
  82.                     break;    case WM_TOPPED:
  83.                             To->top(mx,my);
  84.                     }
  85.                 }
  86.             }
  87.         }
  88.     }
  89.  
  90.     Menu->Hide();
  91.  
  92.     appl_exit();
  93. }
  94.  
  95. GEMwindow* GEMactivity::Window(int ID)
  96. {
  97.     for (WL* c=W; c && c->Window->handle()!=ID;  c=c->Next);
  98.     return c ? c->Window : 0;
  99. }
  100.