Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsPluginInstance Class Reference

#include <plugin.h>

Inheritance diagram for nsPluginInstance:
Inheritance graph
[legend]
Collaboration diagram for nsPluginInstance:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsPluginInstance (NPP aInstance)
 ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError SetWindow (NPWindow *pNPWindow)
uint16 HandleEvent (void *event)
 nsPluginInstance (NPP aInstance)
virtual ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError GetValue (NPPVariable variable, void *value)
NPError SetWindow (NPWindow *aWindow)
const char * getVersion ()
void draw ()
 nsPluginInstance (NPP aInstance)
 ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
const char * getVersion ()
 nsPluginInstance (NPP aInstance)
 ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError SetWindow (NPWindow *pNPWindow)
uint16 HandleEvent (void *event)
NPError GetValue (NPPVariable variable, void *value)
void showVersion ()
void clear ()
nsScriptablePeergetScriptablePeer ()
 nsPluginInstance (NPP aInstance)
virtual ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError GetValue (NPPVariable variable, void *value)
NPError SetWindow (NPWindow *aWindow)
void showVersion ()
void clear ()
void draw ()
nsScriptablePeergetScriptablePeer ()
 nsPluginInstance (NPP aInstance)
 ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError GetValue (NPPVariable variable, void *value)
void showVersion ()
void clear ()
nsScriptablePeergetScriptablePeer ()
 nsPluginInstance (NPP aInstance)
 ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError GetValue (NPPVariable variable, void *value)
void getVersion (char **aVersion)
nsScriptablePeergetScriptablePeer ()
 nsPluginInstance (NPP aInstance)
 ~nsPluginInstance ()
NPBool init (NPWindow *aWindow)
void shut ()
NPBool isInitialized ()
NPError SetWindow (NPWindow *aWindow)
uint16 HandleEvent (void *aEvent)
virtual NPError NewStream (NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
virtual NPError DestroyStream (NPStream *stream, NPError reason)
virtual void StreamAsFile (NPStream *stream, const char *fname)
virtual int32 WriteReady (NPStream *stream)
virtual int32 Write (NPStream *stream, int32 offset, int32 len, void *buffer)
virtual void Print (NPPrint *printInfo)
virtual void URLNotify (const char *url, NPReason reason, void *notifyData)
virtual NPError SetValue (NPNVariable variable, void *value)

Public Attributes

char mString [128]

Private Member Functions

const char * getVersion ()
void DoDraw ()
NPBool StartDraw (NPWindow *window)
void EndDraw (NPWindow *window)
void DrawString (const unsigned char *text, short width, short height, short centerX, Rect drawRect)
void DoDraw ()
NPBool StartDraw (NPWindow *window)
void EndDraw (NPWindow *window)
void DrawString (const unsigned char *text, short width, short height, short centerX, Rect drawRect)

Private Attributes

NPWindowmWindow
NPP mInstance
NPBool mInitialized
GrafPtr mSavePort
RgnHandle mSaveClip
Rect mRevealedRect
short mSavePortTop
short mSavePortLeft
Window mWindow
DisplaymDisplay
Widget mXtwidget
int mX
int mY
int mWidth
int mHeight
Visual * mVisual
Colormap mColormap
unsigned int mDepth
XFontStruct * mFontInfo
GC mGC
HWND mhWnd
nsScriptablePeermScriptablePeer

Detailed Description

Definition at line 43 of file plugin.h.


Constructor & Destructor Documentation

Definition at line 83 of file plugin.cpp.

Definition at line 90 of file plugin.cpp.

{
}
virtual nsPluginInstance::~nsPluginInstance ( ) [virtual]
virtual nsPluginInstance::~nsPluginInstance ( ) [virtual]

Member Function Documentation

Definition at line 308 of file plugin.cpp.

{
  strcpy(mString, "");

  StartDraw(mWindow);
  DoDraw();
  EndDraw(mWindow);
}

Here is the call graph for this function:

virtual NPError nsPluginInstanceBase::DestroyStream ( NPStream stream,
NPError  reason 
) [inline, virtual, inherited]

Definition at line 68 of file pluginbase.h.

{ return NPERR_NO_ERROR; }

Here is the caller graph for this function:

Definition at line 161 of file plugin.cpp.

{
       Rect drawRect;
  RGBColor    black = { 0x0000, 0x0000, 0x0000 };
  RGBColor    white = { 0xFFFF, 0xFFFF, 0xFFFF };
       SInt32        height = mWindow->height;
       SInt32        width = mWindow->width;
       SInt32        centerX = (width) >> 1;
       SInt32        centerY = (height) >> 1;

       const char * ua = getVersion();
       char* pascalString = (char*) NPN_MemAlloc(strlen(ua) + 1);
       strcpy(pascalString, ua);
       UInt8         *pTheText = (unsigned char*) ua;

       drawRect.top = 0;
       drawRect.left = 0;
       drawRect.bottom = drawRect.top + height;
       drawRect.right = drawRect.left + width;

  PenNormal();
  RGBForeColor(&black);
  RGBBackColor(&white);

#if !TARGET_API_MAC_CARBON
  FillRect(&drawRect, &(gQDPtr->white));
#else
  Pattern qdWhite;
  FillRect(&drawRect, GetQDGlobalsWhite(&qdWhite));
#endif

       FrameRect(&drawRect);
  DrawString(pTheText, width, height, centerX, drawRect);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 132 of file plugin.cpp.

{
  unsigned int h = mHeight/2;
  unsigned int w = 3 * mWidth/4;
  int x = (mWidth - w)/2; // center
  int y = h/2;
  if (x >= 0 && y >= 0) {
    GC gc = XCreateGC(mDisplay, mWindow, 0, NULL);
    if (!gc) 
      return;
    XDrawRectangle(mDisplay, mWindow, gc, x, y, w, h);
  const char *string = getVersion();
  if (string && *string) {
    int l = strlen(string);
    int fmba = mFontInfo->max_bounds.ascent;
    int fmbd = mFontInfo->max_bounds.descent;
    int fh = fmba + fmbd;
    y += fh;
    x += 32;
      XDrawString(mDisplay, mWindow, gc, x, y, string, l); 
    }
    XFreeGC(mDisplay, gc);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsPluginInstance::DrawString ( const unsigned char *  text,
short  width,
short  height,
short  centerX,
Rect  drawRect 
) [private]

Definition at line 126 of file plugin.cpp.

{
       short length, textHeight, textWidth;
 
       if(text == NULL)
              return;
       
       length = strlen((char*)text);
       TextFont(1);
       TextFace(bold);
       TextMode(srcCopy);
       TextSize(12);
       
       FontInfo fontInfo;
       GetFontInfo(&fontInfo);

       textHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
       textWidth = TextWidth(text, 0, length);
              
       if (width > textWidth && height > textHeight)
       {
              MoveTo(centerX - (textWidth >> 1), height >> 1);
              DrawText(text, 0, length);
       }             
}

Here is the caller graph for this function:

void nsPluginInstance::DrawString ( const unsigned char *  text,
short  width,
short  height,
short  centerX,
Rect  drawRect 
) [private]
void nsPluginInstance::EndDraw ( NPWindow window) [private]

Definition at line 288 of file plugin.cpp.

{
       SetOrigin(mSavePortLeft, mSavePortTop);
       SetClip(mSaveClip);
       SetPort(mSavePort);
}

Here is the caller graph for this function:

void nsPluginInstance::EndDraw ( NPWindow window) [private]

Definition at line 364 of file plugin.cpp.

{
  if (!mScriptablePeer) {
    mScriptablePeer = new nsScriptablePeer(this);
    if(!mScriptablePeer)
      return NULL;

    NS_ADDREF(mScriptablePeer);
  }

  // add reference for the caller requesting the object
  NS_ADDREF(mScriptablePeer);
  return mScriptablePeer;
}

Here is the call graph for this function:

NPError nsPluginInstance::GetValue ( NPPVariable  variable,
void value 
) [virtual]

Reimplemented from nsPluginInstanceBase.

NPError nsPluginInstance::GetValue ( NPPVariable  variable,
void value 
) [virtual]

Reimplemented from nsPluginInstanceBase.

NPError nsPluginInstance::GetValue ( NPPVariable  variable,
void value 
) [virtual]

Reimplemented from nsPluginInstanceBase.

Definition at line 178 of file plugin.cpp.

{
  NPError err = NPERR_NO_ERROR;
  switch (aVariable) {
    case NPPVpluginNameString:
    case NPPVpluginDescriptionString:
      return NS_PluginGetValue(aVariable, aValue) ;
      break;
    default:
      err = NPERR_INVALID_PARAM;
      break;
  }
  return err;

}

Here is the call graph for this function:

NPError nsPluginInstance::GetValue ( NPPVariable  variable,
void value 
) [virtual]

Reimplemented from nsPluginInstanceBase.

NPError nsPluginInstance::GetValue ( NPPVariable  variable,
void value 
) [virtual]

Reimplemented from nsPluginInstanceBase.

const char * nsPluginInstance::getVersion ( ) [private]

Definition at line 116 of file plugin.cpp.

{
  return NPN_UserAgent(mInstance);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsPluginInstance::getVersion ( char **  aVersion)

Definition at line 168 of file plugin.cpp.

{
  const char *ua = NPN_UserAgent(mInstance);
  char*& version = *aVersion;

  // although we can use NPAPI NPN_MemAlloc call to allocate memory:
  //    version = (char*)NPN_MemAlloc(strlen(ua) + 1);
  // for illustration purposed we use the service manager to access 
  // the memory service provided by Mozilla
  nsIMemory * nsMemoryService = NULL;
  
  if (gServiceManager) {
    // get service using its contract id and use it to allocate the memory
    gServiceManager->GetServiceByContractID("@mozilla.org/xpcom/memory-service;1", NS_GET_IID(nsIMemory), (void **)&nsMemoryService);
    if(nsMemoryService)
      version = (char *)nsMemoryService->Alloc(strlen(ua) + 1);
  }

  if (version)
    strcpy(version, ua);

  // release service
  NS_IF_RELEASE(nsMemoryService);
}

Here is the call graph for this function:

uint16 nsPluginInstance::HandleEvent ( void event) [virtual]

Reimplemented from nsPluginInstanceBase.

Definition at line 216 of file plugin.cpp.

{
       int16 eventHandled = FALSE;
       
       EventRecord* ev = (EventRecord*) event;
       if (event != NULL)
       {
              switch (ev->what)
              {
                     /*
                      * Draw ourselves on update events
                      */
                     case updateEvt:
                            if( StartDraw(mWindow) ) {
                                   DoDraw();
                                   EndDraw(mWindow);
                            }
                            eventHandled = true;
                            break;

                     default:
                            break;
              }
       }
       return eventHandled;
}

Here is the call graph for this function:

uint16 nsPluginInstance::HandleEvent ( void event) [virtual]

Reimplemented from nsPluginInstanceBase.

uint16 nsPluginInstance::HandleEvent ( void aEvent) [virtual]

Reimplemented from nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

Definition at line 94 of file plugin.cpp.

{
  if(aWindow == NULL)
    return FALSE;
  
  mWindow = aWindow;
  mInitialized = TRUE;
  mSaveClip = NewRgn();
  return TRUE;
}
NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::init ( NPWindow aWindow) [virtual]

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Definition at line 111 of file plugin.cpp.

{
  return mInitialized;
}

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::isInitialized ( ) [inline, virtual]

Implements nsPluginInstanceBase.

Definition at line 56 of file plugin.h.

{return mInitialized;}

Implements nsPluginInstanceBase.

virtual NPError nsPluginInstanceBase::NewStream ( NPMIMEType  type,
NPStream stream,
NPBool  seekable,
uint16 stype 
) [inline, virtual, inherited]

Definition at line 66 of file pluginbase.h.

                                                                    { return NPERR_NO_ERROR; }

Here is the caller graph for this function:

virtual void nsPluginInstanceBase::Print ( NPPrint printInfo) [inline, virtual, inherited]

Definition at line 73 of file pluginbase.h.

{ return; }

Here is the caller graph for this function:

virtual NPError nsPluginInstanceBase::SetValue ( NPNVariable  variable,
void value 
) [inline, virtual, inherited]

Definition at line 78 of file pluginbase.h.

{ return NPERR_NO_ERROR; }

Here is the caller graph for this function:

NPError nsPluginInstance::SetWindow ( NPWindow pNPWindow) [virtual]

Reimplemented from nsPluginInstanceBase.

Definition at line 201 of file plugin.cpp.

{
       mWindow = window;
       if( StartDraw(window) ) {
              DoDraw();
              EndDraw(window);
       }
       return NPERR_NO_ERROR;
}

Here is the call graph for this function:

NPError nsPluginInstance::SetWindow ( NPWindow aWindow) [virtual]

Reimplemented from nsPluginInstanceBase.

NPError nsPluginInstance::SetWindow ( NPWindow pNPWindow) [virtual]

Reimplemented from nsPluginInstanceBase.

NPError nsPluginInstance::SetWindow ( NPWindow aWindow) [virtual]

Reimplemented from nsPluginInstanceBase.

NPError nsPluginInstance::SetWindow ( NPWindow aWindow) [virtual]

Reimplemented from nsPluginInstanceBase.

Definition at line 297 of file plugin.cpp.

{
  const char *ua = NPN_UserAgent(mInstance);
  strcpy(mString, ua);

  StartDraw(mWindow);
  DoDraw();
  EndDraw(mWindow);
}

Here is the call graph for this function:

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Definition at line 105 of file plugin.cpp.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

Implements nsPluginInstanceBase.

NPBool nsPluginInstance::StartDraw ( NPWindow window) [private]

Definition at line 248 of file plugin.cpp.

{
       if (mWindow == NULL)
              return false;
              
       NP_Port* npport = (NP_Port*) mWindow->window;
       CGrafPtr ourPort = npport->port;
       
       if (mWindow->clipRect.left < mWindow->clipRect.right)
       {
              GetPort(&mSavePort);
              SetPort((GrafPtr) ourPort);
    Rect portRect;
#if !TARGET_API_MAC_CARBON
    portRect = ourPort->portRect;
#else
    GetPortBounds(ourPort, &portRect);
#endif
              mSavePortTop = portRect.top;
              mSavePortLeft = portRect.left;
              GetClip(mSaveClip);
              
              mRevealedRect.top = mWindow->clipRect.top + npport->porty;
              mRevealedRect.left = mWindow->clipRect.left + npport->portx;
              mRevealedRect.bottom = mWindow->clipRect.bottom + npport->porty;
              mRevealedRect.right = mWindow->clipRect.right + npport->portx;
              SetOrigin(npport->portx, npport->porty);
              ClipRect(&mRevealedRect);

              return true;
       }
       else
              return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NPBool nsPluginInstance::StartDraw ( NPWindow window) [private]
virtual void nsPluginInstanceBase::StreamAsFile ( NPStream stream,
const char *  fname 
) [inline, virtual, inherited]

Definition at line 69 of file pluginbase.h.

{ return; }

Here is the caller graph for this function:

virtual void nsPluginInstanceBase::URLNotify ( const char *  url,
NPReason  reason,
void notifyData 
) [inline, virtual, inherited]

Definition at line 75 of file pluginbase.h.

                                                                    { return; }

Here is the caller graph for this function:

virtual int32 nsPluginInstanceBase::Write ( NPStream stream,
int32  offset,
int32  len,
void buffer 
) [inline, virtual, inherited]

Definition at line 71 of file pluginbase.h.

                                                                    { return len; }

Here is the caller graph for this function:

virtual int32 nsPluginInstanceBase::WriteReady ( NPStream stream) [inline, virtual, inherited]

Definition at line 70 of file pluginbase.h.

{ return 0x0fffffff; }

Here is the caller graph for this function:


Member Data Documentation

Colormap nsPluginInstance::mColormap [private]

Definition at line 74 of file plugin.h.

unsigned int nsPluginInstance::mDepth [private]

Definition at line 75 of file plugin.h.

Definition at line 69 of file plugin.h.

XFontStruct * nsPluginInstance::mFontInfo [private]

Definition at line 76 of file plugin.h.

Definition at line 77 of file plugin.h.

Definition at line 72 of file plugin.h.

Definition at line 59 of file plugin.h.

Definition at line 65 of file plugin.h.

Definition at line 64 of file plugin.h.

Definition at line 68 of file plugin.h.

Definition at line 67 of file plugin.h.

GrafPtr nsPluginInstance::mSavePort [private]

Definition at line 66 of file plugin.h.

Definition at line 70 of file plugin.h.

Definition at line 69 of file plugin.h.

Definition at line 70 of file plugin.h.

Definition at line 61 of file plugin.h.

Visual * nsPluginInstance::mVisual [private]

Definition at line 73 of file plugin.h.

Definition at line 72 of file plugin.h.

Definition at line 63 of file plugin.h.

Window nsPluginInstance::mWindow [private]

Definition at line 68 of file plugin.h.

Definition at line 71 of file plugin.h.

Widget nsPluginInstance::mXtwidget [private]

Definition at line 70 of file plugin.h.

Definition at line 71 of file plugin.h.


The documentation for this class was generated from the following files: