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 / libsource / IntuiMessageC.cxx < prev    next >
C/C++ Source or Header  |  1994-05-05  |  3KB  |  81 lines

  1. /******************************************************************************
  2.  **
  3.  **    C++ Class Library for the Amiga© system software.
  4.  **
  5.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **    All Rights Reserved.
  7.  **
  8.  **    $Source: apphome:APlusPlus/RCS/libsource/IntuiMessageC.cxx,v $
  9.  **    $Revision: 1.4 $
  10.  **    $Date: 1994/05/05 22:07:44 $
  11.  **    $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <APlusPlus/intuition/IntuiMessageC.h>
  17. #include <APlusPlus/intuition/GadgetCV.h>
  18. #include <APlusPlus/intuition/WindowCV.h>
  19. #include <string.h>
  20.  
  21.  
  22. volatile static char rcs_id[] = "$Id: IntuiMessageC.cxx,v 1.4 1994/05/05 22:07:44 Armin_Vogt Exp Armin_Vogt $";
  23.  
  24.  
  25. IntuiMessageC::IntuiMessageC(IDCMPClass mclass)
  26. {
  27.     memset(this,0,sizeof(this));
  28.     Class = mclass;
  29. }
  30.  
  31. WindowCV *IntuiMessageC::decodeWindowCV() const
  32. {
  33.    // test window ptr in WindowCV object against the received message IDCMPWindow
  34.    WindowCV *winC;
  35.    if (IDCMPWindow)
  36.       if (NULL != (winC = (WindowCV*)IDCMPWindow->UserData) )
  37.          if (winC->window() == IDCMPWindow) return winC; 
  38.  
  39.    return NULL;
  40. }
  41.  
  42. GadgetCV *IntuiMessageC::decodeGadgetCV() const
  43.    /* Gets the sending Gadget object from a received message.
  44.       BE AWARE of the fact that, except for GadTools, all gadgets only supply a reference to
  45.       themselves in ONLY the GADGETDOWN/GADGETUP message's IAddress field!
  46.         GadTools gadgets also supply the gadget address for MOUSEMOVE messages.
  47.       Therefore calling decodeGadgetCV() on a different IntuiMessage will return NULL.
  48.       THIS METHOD IS SAFE TO BE CALLED ON EVERY INTUIMESSAGE CLASS.
  49.       Every GadgetCV derived object stores the address of itself into the encapsulated
  50.       Gadget structure. This makes it easy and fast to get the corresponding GadgetCV
  51.       object to an incoming Gadget IntuiMessage.
  52.    */
  53. {
  54.    GadgetCV *gadgetCV;
  55.    if (getClass() & (CLASS_GADGETDOWN|CLASS_GADGETUP|CLASS_MOUSEMOVE)) 
  56.         // IDCMPUPDATE messages hold a taglist in IAddress!!
  57.    {
  58.       struct Gadget *gadget;
  59.       if (NULL != (gadget = (struct Gadget*)getIAddress()) )
  60.  
  61.    /* ENFORCER HITS!! If the presumptive gadget is NO gadget, assuming this unknown address
  62.    ** points to a gadget and further dereferencing UserData to a Gadget object will probably
  63.    ** lead to bus errors!!!
  64.    */
  65.          if (NULL != (gadgetCV = (GadgetCV*)(gadget->UserData)))
  66.             if (gadgetCV->object() == gadget) return gadgetCV;
  67.             else _dout(" IntuiMessageC::decodeGadgetCV(): GadgetCV in IAddress INVALID!\n");
  68.  
  69.       _dout(" IntuiMessageC::decodeGadgetCV(): no GadgetCV in IAddress.\n");
  70.    }
  71.    else _dout(" IntuiMessageC::decodeGadgetCV(): IDCMPUPDATE\n");
  72.    return NULL;
  73. }
  74.  
  75. BOOL IntuiMessageC::isFakeMsg() const
  76. {
  77.     if (*(ULONG*)((IntuiMessage*)this) == 0L) 
  78.         return TRUE; 
  79.     else 
  80.         return FALSE;
  81. }