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 the MRJ Carbon OJI Plugin.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corp.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Patrick C. Beard <beard@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039        MRJContext.h
00040 
00041        Manages Java content using the MacOS Runtime for Java.
00042        
00043        by Patrick C. Beard.
00044  */
00045 
00046 #pragma once
00047 
00048 #include "jni.h"
00049 #include "nsIPluginTagInfo2.h"
00050 
00051 
00052 //
00053 // Instance state information about the plugin.
00054 //
00055 // *Developers*: Use this struct to hold per-instance
00056 //                           information that you'll need in the
00057 //                           various functions in this file.
00058 //
00059 
00060 class MRJSession;
00061 class MRJPluginInstance;
00062 class nsIPluginInstancePeer;
00063 struct nsPluginWindow;
00064 class MRJFrame;
00065 class MRJPage;
00066 struct MRJPageAttributes;
00067 class MRJSecurityContext;
00068 
00069 struct nsPluginPoint {
00070        PRInt32             x;
00071     PRInt32             y;
00072 };
00073 
00074 class MRJContext {
00075 public:
00076        MRJContext(MRJSession* session, MRJPluginInstance* instance);
00077        ~MRJContext();
00078 
00079        void processAppletTag();
00080        Boolean createContext();
00081 
00082 #if !TARGET_CARBON
00083        JMAWTContextRef getContextRef();
00084     JMAppletViewerRef getViewerRef();
00085 #endif
00086     
00087        Boolean appletLoaded();
00088        Boolean loadApplet();
00089        Boolean isActive();
00090        
00091        void suspendApplet();
00092        void resumeApplet();
00093        jobject getApplet();
00094 
00095        nsIPluginInstance* getInstance();
00096        nsIPluginInstancePeer* getPeer();
00097        
00098        Boolean handleEvent(EventRecord* event);
00099        
00100        void idle(short modifiers);
00101        void drawApplet();
00102        void printApplet(nsPluginWindow* printingWindow);
00103        
00104        void activate(Boolean active);
00105        void resume(Boolean inFront);
00106 
00107        void click(const EventRecord* event, MRJFrame* frame);
00108        void keyPress(long message, short modifiers);
00109        void keyRelease(long message, short modifiers);
00110        
00111     void scrollingBegins();
00112     void scrollingEnds();
00113 
00114        void setWindow(nsPluginWindow* pluginWindow);
00115        Boolean inspectWindow();
00116        
00117        MRJFrame* findFrame(WindowRef window);
00118        GrafPtr getPort();
00119        
00120        void showFrames();
00121        void hideFrames();
00122        void releaseFrames();
00123        
00124        void setDocumentBase(const char* documentBase);
00125        const char* getDocumentBase();
00126        
00127        void setAppletHTML(const char* appletHTML, nsPluginTagType tagType);
00128        const char* getAppletHTML();
00129 
00130     void setSecurityContext(MRJSecurityContext* context);
00131     MRJSecurityContext* getSecurityContext();
00132 
00133        void showURL(const char* url, const char* target);
00134        
00135 private:
00136        void localToFrame(Point* pt);
00137        void ensureValidPort();
00138        void synchronizeClipping();
00139        void synchronizeVisibility();
00140 
00141 #if !TARGET_CARBON
00142     static OSStatus requestFrame(JMAWTContextRef context, JMFrameRef newFrame, JMFrameKind kind,
00143                                                         const Rect *initialBounds, Boolean resizeable, JMFrameCallbacks *callbacks);
00144        static OSStatus releaseFrame(JMAWTContextRef context, JMFrameRef oldFrame);
00145        static SInt16 getUniqueMenuID(JMAWTContextRef context, Boolean isSubmenu);
00146        static void exceptionOccurred(JMAWTContextRef context, JMTextRef exceptionName, JMTextRef exceptionMsg, JMTextRef stackTrace);
00147     
00148        SInt16 allocateMenuID(Boolean isSubmenu);
00149 
00150        OSStatus createFrame(JMFrameRef frameRef, JMFrameKind kind, const Rect* initialBounds, Boolean resizeable);
00151 #endif
00152 
00153        // Finds a suitable MRJPage object for this document URL, or creates one.
00154        MRJPage* findPage(const MRJPageAttributes& attributes);
00155 
00156        static CGrafPtr getEmptyPort();
00157 
00158 #if !TARGET_CARBON
00159        void setProxyInfoForURL(char * url, JMProxyType proxyType);
00160 #endif
00161     
00162        OSStatus installEventHandlers(WindowRef window);
00163        OSStatus removeEventHandlers(WindowRef window);
00164        
00165 private:
00166        MRJPluginInstance*              mPluginInstance;
00167        MRJSession*                            mSession;
00168        nsIPluginInstancePeer*          mPeer;
00169 #if !TARGET_CARBON
00170     JMAppletLocatorRef                 mLocator;
00171        JMAWTContextRef                        mContext;
00172        JMAppletViewerRef               mViewer;
00173        JMFrameRef                             mViewerFrame;
00174 #endif
00175     Boolean                                   mIsActive;
00176        Boolean                     mIsFocused;
00177        Boolean                     mIsVisible;
00178        nsPluginPoint               mCachedOrigin;
00179        nsPluginRect                mCachedClipRect;
00180        RgnHandle                              mPluginClipping;
00181        nsPluginWindow*                        mPluginWindow;
00182        CGrafPtr                               mPluginPort;
00183        char*                                  mDocumentBase;
00184        char*                                  mAppletHTML;
00185        MRJPage*                               mPage;
00186        MRJSecurityContext*         mSecurityContext;
00187 #if TARGET_CARBON
00188     jobject                     mAppletFrame;
00189     jobject                     mAppletObject;
00190     ControlRef                  mAppletControl;
00191     UInt32                      mScrollCounter;
00192 #endif
00193 };