home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / CMochaHacks.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  125 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * macmocha.h
  21.  * MacFE mocha hacks
  22.  *
  23.  */
  24.  
  25. #include "structs.h" // mjc
  26. #include "libevent.h"
  27.  
  28. /*
  29.  * static class that encapsulates most of the Macha hacks
  30.  */
  31. class CMochaHacks
  32. {
  33. private:
  34.     static LO_Element*        sMouseOverElement;        // layout element the cursor is over
  35.     static MWContext*        sMouseOverElementContext;    // context associated with sMouseOverElement
  36.     static LO_AnchorData*    sMouseOverMapArea;        // AREA tag the cursor is over
  37.  
  38. public:
  39.     static void ClearSelectionForContext( MWContext* context )
  40.     {
  41.         if (context == sMouseOverElementContext)
  42.         {
  43.             sMouseOverElement = NULL;
  44.             sMouseOverElementContext = NULL;
  45.             sMouseOverMapArea = NULL;
  46.         }
  47.     }
  48.     static void SendOutOfElementEvent(MWContext * winContext, CL_Layer* layer, SPoint32 where); // add layer param 1997-03-02 mjc
  49.     static void SendOutOfMapAreaEvent(MWContext * winContext, CL_Layer* layer, SPoint32 where); // add layer param 1997-03-02 mjc
  50.     static void    ResetMochaMouse();
  51.  
  52.     static Boolean    IsMouseOverElement(LO_Element* inElement)
  53.                     {    return inElement == sMouseOverElement;    }
  54.     static Boolean    IsMouseOverMapArea(LO_AnchorData* inAnchorData)
  55.                     {    return inAnchorData == sMouseOverMapArea;    }
  56.  
  57.     static void    SetMouseOverElement(LO_Element* inElement, MWContext* inElementContext = NULL)
  58.                 {
  59.                     sMouseOverElement = inElement;
  60.                     sMouseOverElementContext = inElementContext;
  61.                 }
  62.     static void RemoveReferenceToMouseOverElementContext(MWContext *context)
  63.     {
  64.         if (sMouseOverElementContext == context)
  65.             sMouseOverElementContext = NULL;
  66.     }
  67.     static void    SetMouseOverMapArea(LO_AnchorData* inAnchorData)
  68.                 {    sMouseOverMapArea = inAnchorData;    }
  69.  
  70.     static LO_Element*    GetMouseOverElement()
  71.                         {    return sMouseOverElement;    }
  72.     static LO_AnchorData*    GetMouseOverMapArea()
  73.                             {    return sMouseOverMapArea;    }
  74.  
  75.     static uint32 MochaModifiers(const UInt16 inModifiers);
  76.     static uint32 MochaModifiersFromKeyboard(void);
  77.                     
  78.     // manage windows declared as dependent in javascript
  79.     static Boolean     IsDependent(MWContext* inContext);
  80.     static void     AddDependent(MWContext* inParent, MWContext* inChild);
  81.     static void     RemoveDependents(MWContext* inContext);
  82.     
  83.     // Whenever a window or frame moves or resizes send an event to javascript
  84.     static void        SendMoveEvent(MWContext* inContext, int32 inX, int32 inY);
  85.     
  86.     static void        SendEvent(MWContext* inContext, int32 inType, LO_Element* inElement = nil);
  87.     
  88.     // Send navigation events - currently not cancellable
  89.     static void        SendBackEvent(MWContext* inContext)
  90.                     { SendEvent(inContext, EVENT_BACK); }
  91.                     
  92.     static void        SendForwardEvent(MWContext* inContext)
  93.                     { SendEvent(inContext, EVENT_FORWARD); }
  94. };
  95.  
  96. /*
  97.  * CMochaEventCallback
  98.  * class that encapsulates sending of mocha events
  99.  * Subclasses should override EventComplete
  100.  */
  101.  
  102. class CMochaEventCallback    {
  103. public:
  104.  
  105. // Constructors
  106.                     CMochaEventCallback();
  107.     virtual         ~CMochaEventCallback();
  108.  
  109. // Mocha interface
  110.     void             SendEvent(MWContext * context, LO_Element * element, int32 type, CL_Layer* layer, SPoint32 where);
  111.     void             SendEvent(MWContext * context, LO_AnchorData * data, int32 type, CL_Layer* layer, SPoint32 where);
  112.  
  113.     // MochaCallback calls EventComplete. You'll be deleted after this call
  114.     virtual void    Complete(MWContext * context, LO_Element * element, 
  115.                  int32 type, ETEventStatus status);
  116.  
  117.     static void MochaCallback(MWContext * context, LO_Element * element, 
  118.                  int32 type, void * inCallback, ETEventStatus status);
  119.  
  120. private:
  121. // Old Mocha calls used to accept either LO_Element, or LO_AnchorData
  122. // New ones only accept LO_Element, so sometimes we need to create/dispose
  123. // dummy layout elements. This is encapsulated in this class
  124.     LO_Element        * fDummyElement;
  125. };