Back to index

lightning-sunbird  0.9+nobinonly
MRJContext.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1998
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either of the GNU General Public License Version 2 or later (the "GPL"),
00025  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 /*
00038        MRJContext.h
00039 
00040        Manages Java content using the MacOS Runtime for Java.
00041        
00042        by Patrick C. Beard.
00043  */
00044 
00045 #pragma once
00046 
00047 #include "jni.h"
00048 #include "JManager.h"
00049 #include "nsIPluginTagInfo2.h"
00050 
00051 //
00052 // Instance state information about the plugin.
00053 //
00054 // *Developers*: Use this struct to hold per-instance
00055 //                           information that you'll need in the
00056 //                           various functions in this file.
00057 //
00058 
00059 class MRJSession;
00060 class MRJPluginInstance;
00061 class nsIPluginInstancePeer;
00062 struct nsPluginWindow;
00063 class MRJFrame;
00064 class MRJPage;
00065 struct MRJPageAttributes;
00066 class MRJSecurityContext;
00067 
00068 struct nsPluginPoint {
00069        PRInt32             x;
00070     PRInt32             y;
00071 };
00072 
00073 class MRJContext {
00074 public:
00075        MRJContext(MRJSession* session, MRJPluginInstance* instance);
00076        ~MRJContext();
00077 
00078        void processAppletTag();
00079        Boolean createContext();
00080        JMAWTContextRef getContextRef();
00081     JMAppletViewerRef getViewerRef();
00082        
00083        void setProxyInfoForURL(char * url, JMProxyType proxyType);
00084        Boolean appletLoaded();
00085        Boolean loadApplet();
00086        Boolean isActive();
00087        
00088        void suspendApplet();
00089        void resumeApplet();
00090        
00091        jobject getApplet();
00092        
00093        void idle(short modifiers);
00094        void drawApplet();
00095        void printApplet(nsPluginWindow* printingWindow);
00096        
00097        void activate(Boolean active);
00098        void resume(Boolean inFront);
00099 
00100        void click(const EventRecord* event, MRJFrame* frame);
00101        void keyPress(long message, short modifiers);
00102        void keyRelease(long message, short modifiers);
00103        
00104        void setWindow(nsPluginWindow* pluginWindow);
00105        Boolean inspectWindow();
00106        
00107        MRJFrame* findFrame(WindowRef window);
00108        GrafPtr getPort();
00109        
00110        void showFrames();
00111        void hideFrames();
00112        void releaseFrames();
00113        
00114        void setDocumentBase(const char* documentBase);
00115        const char* getDocumentBase();
00116        
00117        void setAppletHTML(const char* appletHTML, nsPluginTagType tagType);
00118        const char* getAppletHTML();
00119 
00120     void setSecurityContext(MRJSecurityContext* context);
00121     MRJSecurityContext* getSecurityContext();
00122 
00123 private:
00124        void localToFrame(Point* pt);
00125        void ensureValidPort();
00126        void synchronizeClipping();
00127        void synchronizeVisibility();
00128 
00129        static OSStatus requestFrame(JMAWTContextRef context, JMFrameRef newFrame, JMFrameKind kind,
00130                                                         const Rect *initialBounds, Boolean resizeable, JMFrameCallbacks *callbacks);
00131        static OSStatus releaseFrame(JMAWTContextRef context, JMFrameRef oldFrame);
00132        static SInt16 getUniqueMenuID(JMAWTContextRef context, Boolean isSubmenu);
00133        static void exceptionOccurred(JMAWTContextRef context, JMTextRef exceptionName, JMTextRef exceptionMsg, JMTextRef stackTrace);
00134 
00135        static void showDocument(JMAppletViewerRef viewer, JMTextRef urlString, JMTextRef windowName);
00136        static void setStatusMessage(JMAppletViewerRef viewer, JMTextRef statusMsg);
00137        
00138        void showURL(const char* url, const char* target);
00139        void showStatus(const char* message);
00140        SInt16 allocateMenuID(Boolean isSubmenu);
00141 
00142        OSStatus createFrame(JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable);
00143 
00144        // Finds a suitable MRJPage object for this document URL, or creates one.
00145        MRJPage* findPage(const MRJPageAttributes& attributes);
00146 
00147        static CGrafPtr getEmptyPort();
00148 
00149 private:
00150        MRJPluginInstance*          mPluginInstance;
00151        MRJSession*                        mSession;
00152        JMSessionRef                mSessionRef;
00153        nsIPluginInstancePeer*      mPeer;
00154        JMAppletLocatorRef          mLocator;
00155        JMAWTContextRef                    mContext;
00156        JMAppletViewerRef           mViewer;
00157        JMFrameRef                         mViewerFrame;
00158        Boolean                                   mIsActive;
00159        nsPluginPoint           mCachedOrigin;
00160        nsPluginRect            mCachedClipRect;
00161        RgnHandle                          mPluginClipping;
00162        nsPluginWindow*                    mPluginWindow;
00163        CGrafPtr                           mPluginPort;
00164        char*                              mDocumentBase;
00165        char*                              mAppletHTML;
00166        MRJPage*                           mPage;
00167        MRJSecurityContext*     mSecurityContext;
00168 };