Back to index

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

#include <EmbeddedFrame.h>

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

List of all members.

Public Member Functions

 EmbeddedFrame (MRJPluginInstance *pluginInstance, JMFrameRef frameRef, JMFrameKind kind, const Rect *initialBounds, Boolean resizeable)
virtual ~EmbeddedFrame ()
virtual void setSize (const Rect *newSize)
 Methods used to implement the JMFrame callback protocol.
virtual void invalRect (const Rect *invalidRect)
virtual void showHide (Boolean visible)
virtual void setTitle (const StringPtr title)
virtual void checkUpdate ()
virtual void reorder (ReorderRequest request)
virtual void setResizeable (Boolean resizeable)
virtual void activate (Boolean active)
virtual void click (const EventRecord *event)
void setPluginInstance (EmbeddedFramePluginInstance *embeddedInstance)
void setWindow (WindowRef window)
WindowRef getWindow ()
 EmbeddedFrame (MRJPluginInstance *pluginInstance, JMFrameRef frameRef, JMFrameKind kind, const Rect *initialBounds, Boolean resizeable)
virtual ~EmbeddedFrame ()
virtual void setSize (const Rect *newSize)
 Methods used to implement the JMFrame callback protocol.
virtual void invalRect (const Rect *invalidRect)
virtual void showHide (Boolean visible)
virtual void setTitle (const StringPtr title)
virtual void checkUpdate ()
virtual void reorder (ReorderRequest request)
virtual void setResizeable (Boolean resizeable)
virtual void activate (Boolean active)
virtual void click (const EventRecord *event)
void setPluginInstance (EmbeddedFramePluginInstance *embeddedInstance)
void setWindow (WindowRef window)
WindowRef getWindow ()
virtual Boolean handleEvent (const EventRecord *event)
 Methods to handle various events.
virtual Boolean handleEvent (const EventRecord *event)
 Methods to handle various events.
virtual void idle (SInt16 modifiers)
virtual void idle (SInt16 modifiers)
virtual void update ()
virtual void update ()
virtual void resume (Boolean inFront)
virtual void resume (Boolean inFront)
virtual void click (const EventRecord *event, Point localWhere)
virtual void keyPress (UInt32 message, SInt16 modifiers)
virtual void keyPress (UInt32 message, SInt16 modifiers)
virtual void keyRelease (UInt32 message, SInt16 modifiers)
virtual void keyRelease (UInt32 message, SInt16 modifiers)
virtual void focusEvent (Boolean gotFocus)
virtual void focusEvent (Boolean gotFocus)
virtual void menuSelected (UInt32 message, SInt16 modifiers)
virtual void menuSelected (UInt32 message, SInt16 modifiers)
virtual void print (GrafPtr printingPort, Point frameOrigin)
virtual void print (GrafPtr printingPort, Point frameOrigin)

Protected Member Functions

virtual GrafPtr getPort ()
virtual GrafPtr getPort ()

Protected Attributes

JMFrameRef mFrameRef
Boolean mActive
Boolean mFocused

Private Attributes

EmbeddedFramePluginInstancemPluginInstance
JSEvaluatormEvaluator
WindowRef mWindow
Rect mBounds

Detailed Description

Definition at line 58 of file EmbeddedFrame.h.


Constructor & Destructor Documentation

EmbeddedFrame::EmbeddedFrame ( MRJPluginInstance pluginInstance,
JMFrameRef  frameRef,
JMFrameKind  kind,
const Rect *  initialBounds,
Boolean  resizeable 
)

Definition at line 62 of file EmbeddedFrame.cpp.

       :      MRJFrame(frameRef),
              mPluginInstance(NULL), mEvaluator(NULL), mWindow(NULL), mBounds(*initialBounds)
{
       Boolean hasGoAway = true;
       SInt16 windowProc = documentProc;
       SInt16 resizeHeight = resizeable ? 15 : 0;
       
       switch (kind) {
       case eBorderlessModelessWindowFrame:
              hasGoAway = false;
              windowProc = plainDBox;
              // mBounds.bottom += resizeHeight;
              resizeable = false;
              break;
       case eModelessWindowFrame:
       case eModelessDialogFrame:
              hasGoAway = true;
              windowProc = resizeable ? zoomDocProc : documentProc;
              // mBounds.bottom += resizeHeight;
              break;
       case eModalWindowFrame:
              hasGoAway = true;
              // We have to allow resizeable modal windows.
              windowProc = resizeable ? documentProc : movableDBoxProc;
              break;
       }

#if 0
       
       // Note:  opening a new window on a stream using the following code crashes 4.X browsers.
       // The problem is that the window has no URL assigned to it, and so some variables are
       // unitialized and the browser crashes in a call to strlen().

       class NewStreamMessage : public NativeMessage {
              nsIPluginInstancePeer* mPeer;
              const char* mType;
       public:
              NewStreamMessage(nsIPluginInstancePeer* peer, const char* type) : mPeer(peer), mType(type) {}
              
              virtual void execute() {
                     nsIOutputStream* output = NULL;
                     if (mPeer->NewStream(mType, "_new", &output) == NS_OK) {
                            // write some data to the stream.  
                            output->Close();
                            NS_RELEASE(output);
                     }
              }
       };

       // open a stream of type "application/x-java-frame", which should cause a full-screen plugin to get created for a Java frame's
       // behalf. communicate with the other instance via this stream.
       nsIPluginInstancePeer* peer = NULL;
       if (pluginInstance->GetPeer(&peer) == NS_OK) {
              NewStreamMessage msg(peer, "application/x-java-frame");
              pluginInstance->getSession()->sendMessage(&msg);
              NS_RELEASE(peer);
       }

#else
       // var w = window.open('', '_new','resizable=no,status=no,width=200,height=200'); d = w.document; d.open(); d.write('<BODY MARGINHEIGHT=0 MARGINWIDTH=0>Hi</BODY>'); d.close();

       static UInt32 embeddedFrameCounter = 0;

       // Use JavaScript to create a window with an <EMBED TYPE="application/x-java-frame"> tag.
       const char* kEmbeddedFrameScript = "var w = window.open('','__MRJ_JAVA_FRAME_%d__','resizable=no,status=no,width=%d,height=%d,screenX=%d,screenY=%d');"
                                          "var d = w.document; d.open();"
                                          "d.writeln('<BODY BGCOLOR=#FFFFFF MARGINWIDTH=0 MARGINHEIGHT=0>&nbsp;<EMBED TYPE=application/x-java-frame WIDTH=%d HEIGHT=%d JAVAFRAME=%08X>');"
                                          "d.close();";

       int width = mBounds.right - mBounds.left;
       int height = mBounds.bottom - mBounds.top;
       int screenX = mBounds.left;
       int screenY = mBounds.top;

    char* script = new char[::strlen(kEmbeddedFrameScript) + 100];
    if (script)
        ::sprintf(script, kEmbeddedFrameScript, ++embeddedFrameCounter, width, height, screenX, screenY, width, height, this);

        JSEvaluator* evaluator = new JSEvaluator(pluginInstance);
        if (evaluator) {
            NS_ADDREF(evaluator);

            // create the window. It will have been created after returning from eval.
            const char* result = evaluator->eval(script);

            NS_RELEASE(evaluator);
        }
        delete[] script;
    }

Here is the call graph for this function:

Definition at line 161 of file EmbeddedFrame.cpp.

{
       if (mPluginInstance != NULL)
              mPluginInstance->setFrame(NULL);

       // make sure the window is hidden (and unregistered with the browser).
       showHide(false);

       // make sure this port isn't ever current again.
       ::UnsetPort(mWindow);

       // if (mWindow != NULL)
       //     ::DisposeWindow(mWindow);
}

Here is the call graph for this function:

EmbeddedFrame::EmbeddedFrame ( MRJPluginInstance pluginInstance,
JMFrameRef  frameRef,
JMFrameKind  kind,
const Rect *  initialBounds,
Boolean  resizeable 
)
virtual EmbeddedFrame::~EmbeddedFrame ( ) [virtual]

Member Function Documentation

void EmbeddedFrame::activate ( Boolean  active) [virtual]

Reimplemented from MRJFrame.

Definition at line 253 of file EmbeddedFrame.cpp.

{
       focusEvent(active);
       MRJFrame::activate(active);
}

Here is the call graph for this function:

virtual void EmbeddedFrame::activate ( Boolean  active) [virtual]

Reimplemented from MRJFrame.

Reimplemented from MRJFrame.

Definition at line 217 of file EmbeddedFrame.cpp.

{
}
virtual void EmbeddedFrame::checkUpdate ( ) [virtual]

Reimplemented from MRJFrame.

void EmbeddedFrame::click ( const EventRecord *  event) [virtual]

Reimplemented from MRJFrame.

Definition at line 259 of file EmbeddedFrame.cpp.

{
       Point where = event->where;
       SInt16 modifiers = event->modifiers;
       WindowRef hitWindow;
       short partCode = ::FindWindow(where, &hitWindow);
       switch (partCode) {
       case inContent:
              ::SelectWindow(mWindow);
              MRJFrame::click(event);
              break;
       case inDrag:
              Rect bounds = (**GetGrayRgn()).rgnBBox;
              DragWindow(mWindow, where, &bounds);
              computeBounds(mWindow, &mBounds);
              break;
       case inGrow:
              Rect limits = { 30, 30, 5000, 5000 };
              long result = GrowWindow(mWindow, where, &limits);
              if (result != 0) {
                     short width = (result & 0xFFFF);
                     short height = (result >> 16) & 0xFFFF;
                     Rect newBounds;
                     topLeft(newBounds) = topLeft(mBounds);
                     newBounds.right = newBounds.left + width;
                     newBounds.bottom = newBounds.top + height;
                     ::JMSetFrameSize(mFrameRef, &newBounds);
              }
              break;
       case inGoAway:
              if (::TrackGoAway(mWindow, where))
                     ::JMFrameGoAway(mFrameRef);
              break;
       case inZoomIn:
       case inZoomOut:
              if (::TrackBox(mWindow, where, partCode)) {
                     ZoomWindow(mWindow, partCode, true);
                     computeBounds(mWindow, &mBounds);
                     ::JMSetFrameSize(mFrameRef, &mBounds);
              }
              break;
       case inCollapseBox:
              break;
       }
}

Here is the call graph for this function:

virtual void EmbeddedFrame::click ( const EventRecord *  event) [virtual]

Reimplemented from MRJFrame.

void MRJFrame::click ( const EventRecord *  event,
Point  localWhere 
) [virtual, inherited]

Definition at line 181 of file MRJFrame.cpp.

{
       if (&::JMFrameClickWithEventRecord != NULL)
              ::JMFrameClickWithEventRecord(mFrameRef, localWhere, event);
       else
              ::JMFrameClick(mFrameRef, localWhere, event->modifiers);
}
void MRJFrame::focusEvent ( Boolean  gotFocus) [virtual, inherited]

Definition at line 139 of file MRJFrame.cpp.

{
       if (&::JMFrameFocus != NULL) {
              if (gotFocus != mFocused) {
                     if (gotFocus) {
                            // HACK, until focus really works.
                            if (mActive != gotFocus) {
                                   mActive = gotFocus;
                                   ::JMFrameActivate(mFrameRef, gotFocus);
                            }
                     }
                     mFocused = gotFocus;
                     ::JMFrameFocus(mFrameRef, gotFocus);
              }
       } else {
              if (mActive != gotFocus) {
                     mActive = gotFocus;
                     ::JMFrameActivate(mFrameRef, gotFocus);
              }
       }
}

Here is the caller graph for this function:

virtual void MRJFrame::focusEvent ( Boolean  gotFocus) [virtual, inherited]
GrafPtr EmbeddedFrame::getPort ( ) [protected, virtual]

Implements MRJFrame.

Definition at line 320 of file EmbeddedFrame.cpp.

{
       return mWindow;
}
virtual GrafPtr EmbeddedFrame::getPort ( ) [protected, virtual]

Implements MRJFrame.

WindowRef EmbeddedFrame::getWindow ( )

Definition at line 315 of file EmbeddedFrame.cpp.

{
       return mWindow;
}
WindowRef EmbeddedFrame::getWindow ( )
Boolean MRJFrame::handleEvent ( const EventRecord *  event) [virtual, inherited]

Methods to handle various events.

Definition at line 67 of file MRJFrame.cpp.

{
       Boolean eventHandled = true;

       switch (event->what) {
       case nsPluginEventType_AdjustCursorEvent:
              idle(event->modifiers);
              break;
       
       case ::mouseDown:
              click(event);
              break;
       
       case keyDown:
       case autoKey:
              keyPress(event->message, event->modifiers);
              break;
       
       case keyUp:
              keyRelease(event->message, event->modifiers);
              break;

       case updateEvt:
              update();
              break;
       
       case activateEvt:
              activate((event->modifiers & activeFlag) != 0);
              break;

#if 0
       case osEvt:
              resume((event->message & resumeFlag) != 0);
              eventHandled = false;
              break;
#endif
       
       default:
              eventHandled = false;
              break;
       }
              
       return eventHandled;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual Boolean MRJFrame::handleEvent ( const EventRecord *  event) [virtual, inherited]

Methods to handle various events.

void MRJFrame::idle ( SInt16  modifiers) [virtual, inherited]

Definition at line 112 of file MRJFrame.cpp.

{
       LocalPort port(getPort());
       port.Enter();
       
       Point pt;
       ::GetMouse(&pt);
       ::JMFrameMouseOver(mFrameRef, pt, modifiers);
       
       port.Exit();
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void MRJFrame::idle ( SInt16  modifiers) [virtual, inherited]
void EmbeddedFrame::invalRect ( const Rect *  invalidRect) [virtual]

Reimplemented from MRJFrame.

Definition at line 188 of file EmbeddedFrame.cpp.

{
       if (mWindow != NULL) {
              ::InvalRect(invalidRect);
       }
}
virtual void EmbeddedFrame::invalRect ( const Rect *  invalidRect) [virtual]

Reimplemented from MRJFrame.

void MRJFrame::keyPress ( UInt32  message,
SInt16  modifiers 
) [virtual, inherited]

Definition at line 189 of file MRJFrame.cpp.

{
       ::JMFrameKey(mFrameRef, message & charCodeMask, (message & keyCodeMask) >> 8, modifiers);
}

Here is the caller graph for this function:

virtual void MRJFrame::keyPress ( UInt32  message,
SInt16  modifiers 
) [virtual, inherited]
void MRJFrame::keyRelease ( UInt32  message,
SInt16  modifiers 
) [virtual, inherited]

Definition at line 194 of file MRJFrame.cpp.

{
       ::JMFrameKeyRelease(mFrameRef, message & charCodeMask, (message & keyCodeMask) >> 8, modifiers);
}

Here is the caller graph for this function:

virtual void MRJFrame::keyRelease ( UInt32  message,
SInt16  modifiers 
) [virtual, inherited]
void MRJFrame::menuSelected ( UInt32  message,
SInt16  modifiers 
) [virtual, inherited]

Definition at line 199 of file MRJFrame.cpp.

{
       MenuHandle menu = ::GetMenuHandle(short(message >> 16));
       if (menu != NULL) {
              short item = short(message);
              if (&::JMMenuSelectedWithModifiers != NULL)
                     ::JMMenuSelectedWithModifiers(::JMGetFrameContext(mFrameRef), menu, item, modifiers);
              else
                     ::JMMenuSelected(::JMGetFrameContext(mFrameRef), menu, item);
       }
}

Here is the caller graph for this function:

virtual void MRJFrame::menuSelected ( UInt32  message,
SInt16  modifiers 
) [virtual, inherited]
void MRJFrame::print ( GrafPtr  printingPort,
Point  frameOrigin 
) [virtual, inherited]

Definition at line 211 of file MRJFrame.cpp.

{
#if 0
       // this doesn't work, as Apple hasn't implemented it yet.
       OSStatus status = JMDrawFrameInPort(mFrameRef, printingPort, frameOrigin, printingPort->clipRgn, false);
       if (status != noErr) {
              ::MoveTo(10, 12);
              ::TextFont(0);
              ::TextSize(12);
              ::DrawString("\pMRJPlugin:  printing failed.");
       }
#endif
}

Here is the call graph for this function:

virtual void MRJFrame::print ( GrafPtr  printingPort,
Point  frameOrigin 
) [virtual, inherited]
void EmbeddedFrame::reorder ( ReorderRequest  request) [virtual]

Reimplemented from MRJFrame.

Definition at line 221 of file EmbeddedFrame.cpp.

{
       switch (request) {
       case eBringToFront:         /* bring the window to front */
              break;
       case eSendToBack:           /* send the window to back */
              break;
       case eSendBehindFront:      /* send the window behind the front window */
              break;
       }
}
virtual void EmbeddedFrame::reorder ( ReorderRequest  request) [virtual]

Reimplemented from MRJFrame.

void MRJFrame::resume ( Boolean  inFront) [virtual, inherited]

Definition at line 161 of file MRJFrame.cpp.

{
       ::JMFrameResume(mFrameRef, inFront);
}

Here is the caller graph for this function:

virtual void MRJFrame::resume ( Boolean  inFront) [virtual, inherited]

Definition at line 305 of file EmbeddedFrame.cpp.

{
       mPluginInstance = embeddedInstance;
}

Here is the caller graph for this function:

void EmbeddedFrame::setResizeable ( Boolean  resizeable) [virtual]

Reimplemented from MRJFrame.

Definition at line 233 of file EmbeddedFrame.cpp.

{
       // this might have to recreate the window, no?
}
virtual void EmbeddedFrame::setResizeable ( Boolean  resizeable) [virtual]

Reimplemented from MRJFrame.

void EmbeddedFrame::setSize ( const Rect *  newSize) [virtual]

Methods used to implement the JMFrame callback protocol.

Reimplemented from MRJFrame.

Definition at line 176 of file EmbeddedFrame.cpp.

{
       mBounds = *newSize;

       if (mWindow != NULL) {
              SInt16 width = newSize->right - newSize->left;
              SInt16 height = newSize->bottom - newSize->top;
              ::SizeWindow(mWindow, width, height, true);
              ::MoveWindow(mWindow, newSize->left, newSize->top, false);
       }
}
virtual void EmbeddedFrame::setSize ( const Rect *  newSize) [virtual]

Methods used to implement the JMFrame callback protocol.

Reimplemented from MRJFrame.

void EmbeddedFrame::setTitle ( const StringPtr  title) [virtual]

Reimplemented from MRJFrame.

Definition at line 210 of file EmbeddedFrame.cpp.

{
       if (mWindow != NULL) {
              ::SetWTitle(mWindow, title);
       }
}
virtual void EmbeddedFrame::setTitle ( const StringPtr  title) [virtual]

Reimplemented from MRJFrame.

void EmbeddedFrame::setWindow ( WindowRef  window)

Definition at line 310 of file EmbeddedFrame.cpp.

{
       mWindow = window;
}

Here is the caller graph for this function:

void EmbeddedFrame::setWindow ( WindowRef  window)
void EmbeddedFrame::showHide ( Boolean  visible) [virtual]

Reimplemented from MRJFrame.

Definition at line 195 of file EmbeddedFrame.cpp.

{
       if (mWindow != NULL && visible != IsWindowVisible(mWindow)) {
              if (visible) {
                     // Have to notify the browser that this window exists, so that it will receive events.
                     ::ShowWindow(mWindow);
                     ::SelectWindow(mWindow);
              } else {
                     ::HideWindow(mWindow);
              }
              
              // ::ShowHide(mWindow, visible);
       }
}

Here is the caller graph for this function:

virtual void EmbeddedFrame::showHide ( Boolean  visible) [virtual]

Reimplemented from MRJFrame.

void MRJFrame::update ( ) [virtual, inherited]

Definition at line 124 of file MRJFrame.cpp.

{
       GrafPtr framePort = getPort();
       if (framePort != NULL)
              ::JMFrameUpdate(mFrameRef, framePort->clipRgn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void MRJFrame::update ( ) [virtual, inherited]

Member Data Documentation

Boolean MRJFrame::mActive [protected, inherited]

Definition at line 93 of file MRJFrame.h.

Rect EmbeddedFrame::mBounds [private]

Definition at line 86 of file EmbeddedFrame.h.

Definition at line 84 of file EmbeddedFrame.h.

Boolean MRJFrame::mFocused [protected, inherited]

Definition at line 94 of file MRJFrame.h.

JMFrameRef MRJFrame::mFrameRef [protected, inherited]

Definition at line 92 of file MRJFrame.h.

Definition at line 83 of file EmbeddedFrame.h.

WindowRef EmbeddedFrame::mWindow [private]

Definition at line 85 of file EmbeddedFrame.h.


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