Back to index

lightning-sunbird  0.9+nobinonly
nsMacWindow.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * 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 #ifndef MacWindow_h__
00038 #define MacWindow_h__
00039 
00040 #include <memory>    // for auto_ptr
00041 #include <Carbon/Carbon.h>
00042 
00043 using std::auto_ptr;
00044 
00045 #include "nsRegionPool.h"
00046 #include "nsWindow.h"
00047 #include "nsMacEventHandler.h"
00048 #include "nsIEventSink.h"
00049 #include "nsIMacTextInputEventSink.h"
00050 #include "nsPIWidgetMac.h"
00051 #include "nsPIEventSinkStandalone.h"
00052 
00053 class nsMacEventHandler;
00054 
00055 //-------------------------------------------------------------------------
00056 //
00057 // nsMacWindow
00058 //
00059 //-------------------------------------------------------------------------
00060 //     MacOS native window
00061 
00062 class nsMacWindow : public nsChildWindow, public nsIEventSink, public nsPIWidgetMac_MOZILLA_1_8_BRANCH,
00063                     public nsPIEventSinkStandalone, public nsIMacTextInputEventSink
00064 {
00065 private:
00066        typedef nsChildWindow Inherited;
00067 
00068 public:
00069     nsMacWindow();
00070     virtual ~nsMacWindow();
00071 
00072     NS_DECL_ISUPPORTS_INHERITED
00073     NS_DECL_NSIEVENTSINK 
00074     NS_DECL_NSPIWIDGETMAC
00075     NS_DECL_NSPIWIDGETMAC_MOZILLA_1_8_BRANCH
00076     NS_DECL_NSPIEVENTSINKSTANDALONE
00077     NS_DECL_NSIMACTEXTINPUTEVENTSINK
00078     
00079 /*
00080     // nsIWidget interface
00081     NS_IMETHOD            Create(nsIWidget *aParent,
00082                                      const nsRect &aRect,
00083                                      EVENT_CALLBACK aHandleEventFunction,
00084                                      nsIDeviceContext *aContext,
00085                                      nsIAppShell *aAppShell = nsnull,
00086                                      nsIToolkit *aToolkit = nsnull,
00087                                      nsWidgetInitData *aInitData = nsnull);
00088 */
00089     NS_IMETHOD              Create(nsNativeWidget aParent,
00090                                      const nsRect &aRect,
00091                                      EVENT_CALLBACK aHandleEventFunction,
00092                                      nsIDeviceContext *aContext,
00093                                      nsIAppShell *aAppShell = nsnull,
00094                                      nsIToolkit *aToolkit = nsnull,
00095                                      nsWidgetInitData *aInitData = nsnull);
00096 
00097      // Utility method for implementing both Create(nsIWidget ...) and
00098      // Create(nsNativeWidget...)
00099 
00100     virtual nsresult        StandardCreate(nsIWidget *aParent,
00101                                                         const nsRect &aRect,
00102                                                         EVENT_CALLBACK aHandleEventFunction,
00103                                                         nsIDeviceContext *aContext,
00104                                                         nsIAppShell *aAppShell,
00105                                                         nsIToolkit *aToolkit,
00106                                                         nsWidgetInitData *aInitData,
00107                                                         nsNativeWidget aNativeParent = nsnull);
00108 
00109     NS_IMETHOD              Show(PRBool aState);
00110     NS_IMETHOD              ConstrainPosition(PRBool aAllowSlop,
00111                                               PRInt32 *aX, PRInt32 *aY);
00112     NS_IMETHOD              Move(PRInt32 aX, PRInt32 aY);
00113     NS_IMETHOD              PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
00114                                         nsIWidget *aWidget, PRBool aActivate);
00115     NS_IMETHOD              SetSizeMode(PRInt32 aMode);
00116 
00117     NS_IMETHOD              Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
00118     virtual nsresult        Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint, PRBool aFromUI);
00119     NS_IMETHOD              GetScreenBounds(nsRect &aRect);
00120     virtual PRBool          OnPaint(nsPaintEvent &event);
00121 
00122     NS_IMETHOD              SetTitle(const nsAString& aTitle);
00123 
00124     void                    UserStateForResize();
00125 
00126        // nsIKBStateControl interface
00127        NS_IMETHOD ResetInputState();
00128 
00129     void                           MoveToGlobalPoint(PRInt32 aX, PRInt32 aY);
00130 
00131     void IsActive(PRBool* aActive);
00132     void SetIsActive(PRBool aActive);
00133     WindowPtr GetWindowTop(WindowPtr baseWindowRef);
00134     void UpdateWindowMenubar(WindowPtr parentWindow, PRBool enableFlag);
00135 
00136     NS_IMETHOD              Update();
00137 
00138 protected:
00139   
00140        pascal static OSErr DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr theWindow, 
00141                                                                       void *handlerRefCon, DragReference theDrag );
00142        pascal static OSErr DragReceiveHandler (WindowPtr theWindow,
00143                                                                                     void *handlerRefCon, DragReference theDragRef) ;
00144        DragTrackingHandlerUPP mDragTrackingHandlerUPP;
00145        DragReceiveHandlerUPP mDragReceiveHandlerUPP;
00146 
00147 
00148   pascal static OSStatus WindowEventHandler ( EventHandlerCallRef inHandlerChain, 
00149                                                EventRef inEvent, void* userData ) ;
00150   pascal static OSStatus ScrollEventHandler(EventHandlerCallRef aHandlerCallRef,
00151                                             EventRef            aEvent,
00152                                             void*               aUserData);
00153   pascal static OSStatus KeyEventHandler(EventHandlerCallRef aHandlerCallRef,
00154                                          EventRef            aEvent,
00155                                          void*               aUserData);
00156   nsresult GetDesktopRect(Rect* desktopRect);
00157 
00158        PRPackedBool                    mWindowMadeHere; // true if we created the window
00159        PRPackedBool                    mIsSheet;        // true if the window is a sheet (Mac OS X)
00160        PRPackedBool                    mAcceptsActivation;
00161        PRPackedBool                    mIsActive;
00162        PRPackedBool                    mZoomOnShow;
00163        PRPackedBool                    mZooming;
00164        PRPackedBool                    mResizeIsFromUs;    // we originated the resize, prevent infinite recursion
00165        PRPackedBool                    mShown;             // whether the window was actually shown on screen
00166        PRPackedBool                    mSheetNeedsShow;    // a sheet that wants to be displayed but isn't because a sibling sheet is open
00167        PRPackedBool                    mSheetShown;
00168        PRPackedBool                mInPixelMouseScroll;
00169        Point                           mBoundsOffset;      // offset from window structure to content
00170        auto_ptr<nsMacEventHandler>     mMacEventHandler;
00171        nsIWidget                      *mOffsetParent;
00172         nsCOMPtr<nsIWidget>             mDeathGripDuringTransition;
00173        
00174 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
00175        PRPackedBool                    mNeedsResize;
00176        struct {
00177          PRInt32      width;
00178          PRInt32      height;
00179          PRPackedBool repaint;
00180          PRPackedBool fromUI;
00181        }                               mResizeTo;
00182 #endif
00183   EventHandlerRef mScrollEventHandler;
00184   EventHandlerRef mWindowEventHandler;
00185 };
00186 
00187 #endif // MacWindow_h__