home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / LT_IMsg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-16  |  2.3 KB  |  86 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. #define MESSAGE_COOKIE 0x19138AFB
  10.  
  11. struct IntuiMessage * LIBENT
  12. LT_GetIMsg(REG(a0) struct LayoutHandle *Handle)
  13. {
  14.     if(Handle)
  15.     {
  16.         struct IntuiMessage *Msg = GT_GetIMsg(Handle -> Window -> UserPort);
  17.  
  18.         if(Msg)
  19.         {
  20.             struct IntuiMessage *Clone;
  21.  
  22.             if(Msg -> Class == IDCMP_SIZEVERIFY && Handle -> ResizeView)
  23.             {
  24.                     // They're coming to take me away, HAHA!
  25.  
  26.                 Handle -> SizeVerified    = TRUE;
  27.                 Handle -> SizeWidth    = Handle -> Window -> Width;
  28.                 Handle -> SizeHeight    = Handle -> Window -> Height;
  29.  
  30.                 RemoveGList(Handle -> Window,Handle -> List,(UWORD)-1);
  31.  
  32.                     // Fake a null event, otherwise the following
  33.                     // IDCMP_NEWSIZE would probably not get through
  34.  
  35.                 if(Clone = (struct IntuiMessage *)AllocMem(sizeof(struct IntuiMessage),MEMF_ANY))
  36.                 {
  37.                     CopyMem(Msg,Clone,sizeof(struct IntuiMessage));
  38.  
  39.                     Clone -> Class                    = NULL;
  40.                     Clone -> ExecMessage . mn_Node . ln_Name    = (char *)MESSAGE_COOKIE;
  41.                     Clone -> ExecMessage . mn_Node . ln_Pri     = -114;
  42.                     Clone -> ExecMessage . mn_ReplyPort        = (struct MsgPort *)Clone;
  43.                     Clone -> SpecialLink                = (struct IntuiMessage *)Clone;
  44.  
  45.                     GT_ReplyIMsg(Msg);
  46.                 }
  47.             }
  48.             else
  49.             {
  50.                 if(Clone = (struct IntuiMessage *)AllocMem(sizeof(struct IntuiMessage),MEMF_ANY))
  51.                 {
  52.                     CopyMem(Msg,Clone,sizeof(struct IntuiMessage));
  53.  
  54.                     Clone -> ExecMessage . mn_Node . ln_Name    = (char *)MESSAGE_COOKIE;
  55.                     Clone -> ExecMessage . mn_Node . ln_Pri     = -114;
  56.                     Clone -> ExecMessage . mn_ReplyPort        = (struct MsgPort *)Clone;
  57.                     Clone -> SpecialLink                = (struct IntuiMessage *)Clone;
  58.  
  59.                     GT_ReplyIMsg(Msg);
  60.  
  61.                     LT_HandleInput(Handle,Clone -> Qualifier,&Clone -> Class,&Clone -> Code,(struct Gadget **)&Clone -> IAddress);
  62.                 }
  63.             }
  64.  
  65.             if(Clone)
  66.                 return(Clone);
  67.             else
  68.                 GT_ReplyIMsg(Msg);
  69.         }
  70.     }
  71.  
  72.     return(NULL);
  73. }
  74.  
  75. VOID LIBENT
  76. LT_ReplyIMsg(REG(a0) struct IntuiMessage *Msg)
  77. {
  78.     if(Msg)
  79.     {
  80.         if(Msg -> SpecialLink == (struct IntuiMessage *)Msg && Msg -> ExecMessage . mn_Node . ln_Name == (char *)MESSAGE_COOKIE && Msg -> ExecMessage . mn_Node . ln_Pri == -114 && Msg -> ExecMessage . mn_ReplyPort == (struct MsgPort *)Msg)
  81.             FreeMem(Msg,sizeof(struct IntuiMessage));
  82.         else
  83.             GT_ReplyIMsg(Msg);
  84.     }
  85. }
  86.