home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / aplusplus-1.01-src.lha / GNU / src / amiga / APlusPlus-1.01 / include / APlusPlus / intuition / WindowCV.h < prev    next >
C/C++ Source or Header  |  1994-05-04  |  5KB  |  132 lines

  1. #ifndef APP_WindowCV_H
  2. #define APP_WindowCV_H
  3. /******************************************************************************
  4.  **
  5.  **    C++ Class Library for the Amiga© system software.
  6.  **
  7.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  8.  **    All Rights Reserved.
  9.  **
  10.  **    $VER: apphome:APlusPlus/intuition/WindowCV.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14.  
  15. extern "C" {
  16. #include <intuition/intuition.h>
  17. }
  18. #include <APlusPlus/exec/SignalResponder.h>
  19. #include <APlusPlus/intuition/IntuiObject.h>
  20. #include <APlusPlus/graphics/GraphicObject.h>
  21. #include <APlusPlus/environment/Dependencies.h>
  22. #include <APlusPlus/intuition/IntuiMessageC.h>
  23. #include <APlusPlus/intuition/ScreenC.h>
  24. #include <APlusPlus/intuition/IntuiRoot.h>
  25.  
  26. /***********************************************************************************************
  27.       » IntuitionResponder class «
  28.       
  29.    The IntuitionResponder class is a specialized SignalResponder that awaits signals on its
  30.    dedicated userport. It receives the incoming IDCMP messages of one userport that may
  31.    be shared between several Intuition® windows and delivers them to their respective WindowCV 
  32.    object. 
  33.    The IntuitionResponder class is a supportive class for the WindowCV class and not designed
  34.    to work with other classes. 
  35.    DO NOT USE THIS CLASS!    
  36.  ***********************************************************************************************/
  37. class WindowCV;
  38. class IntuitionResponder : public Shared, private SignalResponder
  39. {
  40.    friend WindowCV;       // needs access to msgInProcess
  41.    private:
  42.       struct MsgPort *userPort;           // window userport of one or more windows
  43.       struct IntuiMessage *msgInProcess;  // holds the last received yet not replied message
  44.  
  45.       void actionCallback();              // inherited from SignalResponder
  46.                      
  47.          
  48.       IntuitionResponder(struct MsgPort *IPort);
  49.       ~IntuitionResponder();
  50.  
  51.       struct MsgPort *getMsgPort() { return userPort; }
  52.       WORD release(Window *);
  53. };
  54.  
  55.  
  56. /***********************************************************************************************
  57.       » WindowCV class «   virtual base class
  58.       » IntuitionResponder class «
  59.  
  60.    A WindowCV object stands for one single Intuition window and shares its lifetime.
  61.    The WindowCV constructor opens the window (Check with obj.Ok() if the window could successfully
  62.    be opened) and the destructor closes it. The IDCMP message passing is handled by a special
  63.    MsgPort responder, the IntuitionResponder. One IntuitionResponder lives independent of a WindowCV
  64.    object, but each WindowCV object refers to an IntuitionResponder who controls the window's
  65.    user port. It is possible that several WindowCV objects, and thereby several Intuition
  66.    windows, share an IntuitionResponder == UserPort. This can be achieved by using the
  67.    WCV_SharePortWithWindow tag which needs a WindowCV object as parameter.
  68.  
  69.  ***********************************************************************************************/
  70.  
  71. class WindowCV : public GraphicObject
  72. {
  73.    private:
  74.       friend IntuiMessageC;
  75.       friend class IntuitionResponder;
  76.       
  77.       // class member variables
  78.       IntuitionResponder *window_rsp;     // msgport responder for the windows userport
  79.               
  80.       struct Window*& wPtr() { return (struct Window*&)IObject(); }
  81.  
  82.    protected:
  83.       struct Window* window() { return (struct Window*)IObject(); }
  84.       // pointer to the encapsulated Intuition window
  85.  
  86.       // create window
  87.       WindowCV(IntuiObject *owner,AttrList& attrs);
  88.       ~WindowCV();
  89.  
  90.       // message handler: must be filled with functionality by the derived classes
  91.       virtual void handleIntuiMsg(const IntuiMessageC *);
  92.  
  93.       virtual void default_IMsgCallback(const IntuiMessageC *);
  94.  
  95.       void newsize(const IntuiMessageC*);
  96.  
  97.       IntuitionResponder *getIntuiResponder() { return window_rsp; }
  98.       
  99.    public:
  100.       static void WaitSignal() { SignalResponder::WaitSignal(); } // wait for events
  101.  
  102.       // window methods
  103.       ULONG setAttributes(AttrList& attrs);     // inherited from IntuiObject
  104.       ULONG getAttribute(Tag,ULONG& dataStore);
  105.  
  106.       const STRPTR title() { return (const STRPTR)window()->Title; }
  107.  
  108.       const struct Window *windowPtr() { return (const struct Window*)IObject(); }
  109.         operator const struct Window * () { return (const struct Window*)IObject(); }
  110.             
  111.       ScreenC *screenC() { return (ScreenC*)findRootOfKind(IOTYPE_SCREEN); }
  112.       // returns the ScreenC object the window is dedicated to.
  113.  
  114.       void modifyIDCMP(ULONG flags);
  115.       friend ostream& operator << (ostream& OS,WindowCV *win);
  116.  
  117.         // type checking for tag data values (see below)
  118.         static LONG confirm(WindowCV *obj) { return (LONG)obj; }
  119. };
  120.  
  121. #define WCV_Dummy (TAG_USER | IOTYPE_WINDOWCV)
  122.  
  123. #define WCV_SharePortWithWindow  (WCV_Dummy+3)
  124. #define WCV_SharePortWithWindowObj(window) WCV_SharePortWithWindow,WindowCV::confirm(window)
  125.    /* let the window use the same user port as the window given in ti_Data. Prefer using
  126.      *    the WCV_SharePortWithWindowObj(WindowCV* window) macro which assures type checking.
  127.     */
  128.  
  129. #define WINDOWCV_OPENWINDOW_FAILED (IOTYPE_WINDOWCV+1)
  130.  
  131. #endif
  132.