NP_Port

This is an archived page. It's not actively maintained.

Summary

Used on Mac OS only

Contains information required by the window field of an NPWindow structure.

Syntax

typedef struct NP_Port
{
    CGrafPtr port;  /* Grafport */
    int32    portx; /* position inside the topmost window */
    int32    porty;
} NP_Port;

Fields

The data structure has the following fields:

port
Standard Mac OS port into which the plug-in should draw.
portx, porty
Top-left corner of the plug-in rectangle in port coordinates (taking the scroll position into account).

Description

On Mac OS, the window field of an NPWindow structure points to an NP_Port object, which is allocated by the browser. The NP_Port is valid for the lifetime of the NPWindow, that is, until NPP_SetWindow is called again with a different value or the instance is destroyed.

Since the port is shared between the plug-in and other plug-ins and the browser, the plug-in should always do the following:

  • Draw only within the area designated by the NPWindow.
  • Save the current port settings before changing the port for drawing.
  • Set the desired port settings before drawing.
  • Restore the previous port settings after drawing.

See Also