home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / applevnt / mplugin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.3 KB  |  134 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. #pragma once
  20.  
  21. #include "np.h"
  22. #include "npapi.h"
  23.  
  24. #include <Printing.h>
  25. #include <Icons.h>
  26.  
  27. #include <LView.h>
  28. #include <LPeriodical.h>
  29. #include <LCommander.h>
  30. #include <LDragAndDrop.h>
  31.  
  32. class StPluginFocus;
  33.  
  34. //
  35. // Return the "plug-in descriptor" that we pass to XP code
  36. // (this is really just a pointer to a CPluginHandler).
  37. //
  38. class CStr255;
  39. extern void* GetPluginDesc(const CStr255& pluginName);
  40.  
  41.  
  42. /*********************************************************************************
  43.  * CPluginView
  44.  * Embeds the plugin, and passes on the events to it
  45.  *********************************************************************************/
  46.  
  47. class CPluginView : public LView,        // Drawing, etc
  48.                     public LPeriodical,    // Idling
  49.                     public LCommander,    // Key events
  50.                     public LDragAndDrop    // Dragging
  51. {
  52. public:
  53.     friend class StPluginFocus;
  54.     enum { class_ID = 'plug' };
  55.  
  56. // ÑÑ constructors
  57.                             CPluginView(LStream *inStream);
  58.     virtual                    ~CPluginView();
  59.  
  60.             void            EmbedCreate(MWContext* context, LO_EmbedStruct* embed_struct);
  61.             void            EmbedFree(MWContext* context, LO_EmbedStruct* embed_struct);
  62.             void            EmbedSize(LO_EmbedStruct* embed_struct, SDimension16 hyperSize);
  63.             void            EmbedDisplay(LO_EmbedStruct* embed_struct, Boolean isPrinting);
  64.  
  65. // ÑÑ access
  66.             NPWindow*        GetNPWindow()                         { return &fNPWindow; }
  67.             NPEmbeddedApp*    GetNPEmbeddedApp()                    { return fApp; }
  68.  
  69. // ÑÑ event processing
  70.     static    CPluginView*    sPluginTarget;
  71.     static    void            BroadcastPluginEvent(const EventRecord& event);
  72.     static    Boolean            PluginWindowEvent(const EventRecord& event);
  73.     
  74.     virtual void            ClickSelf(const SMouseDownEvent& inMouseDown);
  75.     virtual void            EventMouseUp(const EventRecord &inMacEvent);
  76.     virtual Boolean            HandleKeyPress(const EventRecord& inKeyEvent);
  77.     virtual void            DrawSelf();
  78.     virtual void            SpendTime(const EventRecord& inMacEvent);
  79.     virtual void            ActivateSelf();
  80.     virtual void            DeactivateSelf();
  81.     virtual void            BeTarget();
  82.     virtual void            DontBeTarget();
  83.     virtual void            AdjustCursorSelf(Point inPortPt, const EventRecord& inMacEvent);
  84.             Boolean            PassEvent(EventRecord& inEvent);
  85.     virtual Boolean            HandleEmbedEvent(CL_Event *event);
  86.     
  87. // ÑÑ positioning
  88.     virtual void            AdaptToNewSurroundings();
  89.     virtual void            AdaptToSuperFrameSize(Int32 inSurrWidthDelta, Int32 inSurrHeightDelta, Boolean inRefresh);
  90.     virtual void            MoveBy(Int32 inHorizDelta, Int32 inVertDelta, Boolean inRefresh);
  91.             Boolean            IsPositioned() const { return fPositioned; }
  92. // ÑÑ╩dragging
  93.     virtual Boolean            DragIsAcceptable(DragReference inDragRef);
  94.     virtual void            HiliteDropArea(DragReference inDragRef);
  95.     virtual void            UnhiliteDropArea(DragReference inDragRef);
  96.  
  97. // ÑÑ printing
  98.             Boolean            PrintFullScreen(Boolean printOne, THPrint printRecHandle);
  99.             void            PrintEmbedded();
  100.             
  101. // ÑÑ broken plugin
  102.             void            SetBrokenPlugin();
  103.             void            DrawBroken(Boolean hilite);
  104.  
  105.             void            SetPositioned() { fPositioned = true; }
  106.  
  107. // ÑÑ window control
  108.  
  109.             void             RegisterWindow(void* window);
  110.             void             UnregisterWindow(void* window);
  111.             Boolean            PassWindowEvent(EventRecord& inEvent, WindowPtr window);
  112.             
  113. private:
  114.             void            ResetDrawRect();
  115.     
  116.             NPEmbeddedApp*    fApp;
  117.             NPWindow        fNPWindow;
  118.             NP_Port            fNPPort;
  119.             CPluginView*    fOriginalView;
  120.             CIconHandle        fBrokenIcon;
  121.             short            fHorizontalOffset;
  122.             short            fVerticalOffset;
  123.             Boolean            fBrokenPlugin;
  124.             Boolean            fPositioned;
  125.             Boolean            fHidden;
  126.             Boolean            fWindowed;
  127.             LO_EmbedStruct* fEmbedStruct;
  128.             Boolean            fIsPrinting;
  129.             LArray*            fWindowList;
  130.             
  131.     static    LArray*            sPluginList;
  132. };
  133.  
  134.