2001-11-06 15:35:24 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 22:01:16 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-11-06 15:35:24 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 22:01:16 +00:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-11-06 15:35:24 +00:00
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 22:01:16 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-11-06 15:35:24 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 22:01:16 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-11-06 15:35:24 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2005-09-30 00:59:29 +00:00
|
|
|
|
|
|
|
#ifndef nsChildView_h__
|
|
|
|
#define nsChildView_h__
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2002-04-04 21:35:20 +00:00
|
|
|
#import "mozView.h"
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsBaseWidget.h"
|
2002-12-13 08:43:18 +00:00
|
|
|
#include "nsIPluginWidget.h"
|
2002-04-23 03:55:19 +00:00
|
|
|
#include "nsIEventSink.h"
|
2003-03-13 20:37:32 +00:00
|
|
|
#include "nsIScrollableView.h"
|
2001-11-06 15:35:24 +00:00
|
|
|
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsIKBStateControl.h"
|
|
|
|
#include "nsIAppShell.h"
|
|
|
|
|
|
|
|
#include "nsIMouseListener.h"
|
|
|
|
#include "nsIEventListener.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
#include "nsIMenuBar.h"
|
|
|
|
|
|
|
|
#include "nsplugindefs.h"
|
2006-05-30 23:26:56 +00:00
|
|
|
#include <Quickdraw.h>
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2006-02-22 01:31:14 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
class gfxASurface;
|
|
|
|
#endif
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
#define NSRGB_2_COLOREF(color) \
|
|
|
|
RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
|
|
|
|
|
|
|
|
struct nsPluginPort;
|
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
#undef DARWIN
|
2001-11-06 15:35:24 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
class nsChildView;
|
|
|
|
|
|
|
|
|
2006-02-22 01:31:14 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
@interface ChildView : NSView<mozView, NSTextInput>
|
|
|
|
#else
|
2002-12-13 08:43:18 +00:00
|
|
|
@interface ChildView : NSQuickDrawView<mozView, NSTextInput>
|
2006-02-22 01:31:14 +00:00
|
|
|
#endif
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
2005-09-30 00:59:29 +00:00
|
|
|
@private
|
2006-03-29 00:49:15 +00:00
|
|
|
NSWindow* mWindow; // shortcut to the top window, [WEAK]
|
2002-02-13 19:57:10 +00:00
|
|
|
|
2006-03-29 00:49:15 +00:00
|
|
|
// the nsChildView that created the view. It retains this NSView, so
|
|
|
|
// the link back to it must be weak.
|
2001-11-06 15:35:24 +00:00
|
|
|
nsChildView* mGeckoChild;
|
2006-03-29 00:49:15 +00:00
|
|
|
|
|
|
|
// tag for our mouse enter/exit tracking rect
|
2001-11-06 15:35:24 +00:00
|
|
|
NSTrackingRectTag mMouseEnterExitTag;
|
2002-04-27 00:19:49 +00:00
|
|
|
|
|
|
|
// Whether we're a plugin view.
|
|
|
|
BOOL mIsPluginView;
|
2001-11-14 22:29:25 +00:00
|
|
|
|
2005-10-13 17:00:18 +00:00
|
|
|
NSEvent* mCurKeyEvent; // only valid during a keyDown
|
2002-12-13 08:43:18 +00:00
|
|
|
|
|
|
|
// needed for NSTextInput implementation
|
|
|
|
NSRange mMarkedRange;
|
|
|
|
NSRange mSelectedRange;
|
|
|
|
BOOL mInComposition;
|
2005-10-13 17:00:18 +00:00
|
|
|
BOOL mIgnoreDoCommand;
|
2003-03-13 20:37:32 +00:00
|
|
|
|
|
|
|
BOOL mInHandScroll; // true for as long as we are hand scrolling
|
|
|
|
// hand scroll locations
|
|
|
|
NSPoint mHandScrollStartMouseLoc;
|
|
|
|
nscoord mHandScrollStartScrollX, mHandScrollStartScrollY;
|
2006-06-12 21:05:36 +00:00
|
|
|
// when menuForEvent: is called, we store its event here (strong)
|
|
|
|
NSEvent* mLastMenuForEventEvent;
|
2002-12-13 08:43:18 +00:00
|
|
|
}
|
2002-04-27 00:19:49 +00:00
|
|
|
|
2005-06-26 03:25:52 +00:00
|
|
|
// these are sent to the first responder when the window key status
|
|
|
|
// changes
|
|
|
|
- (void)viewsWindowDidBecomeKey;
|
|
|
|
- (void)viewsWindowDidResignKey;
|
|
|
|
|
2001-11-06 15:35:24 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsChildView
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
class nsChildView : public nsBaseWidget,
|
|
|
|
public nsIPluginWidget,
|
|
|
|
public nsIKBStateControl,
|
|
|
|
public nsIEventSink
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef nsBaseWidget Inherited;
|
|
|
|
|
|
|
|
public:
|
2001-11-14 22:29:25 +00:00
|
|
|
nsChildView();
|
|
|
|
virtual ~nsChildView();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2002-04-23 03:55:19 +00:00
|
|
|
NS_DECL_NSIEVENTSINK
|
2005-09-30 00:59:29 +00:00
|
|
|
|
|
|
|
// nsIKBStateControl interface
|
|
|
|
NS_IMETHOD ResetInputState();
|
|
|
|
NS_IMETHOD SetIMEOpenState(PRBool aState);
|
|
|
|
NS_IMETHOD GetIMEOpenState(PRBool* aState);
|
|
|
|
NS_IMETHOD SetIMEEnabled(PRBool aState);
|
|
|
|
NS_IMETHOD GetIMEEnabled(PRBool* aState);
|
|
|
|
NS_IMETHOD CancelIMEComposition();
|
2002-04-23 03:55:19 +00:00
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
// nsIWidget interface
|
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell = nsnull,
|
|
|
|
nsIToolkit *aToolkit = nsnull,
|
|
|
|
nsWidgetInitData *aInitData = nsnull);
|
|
|
|
NS_IMETHOD Create(nsNativeWidget aNativeParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell = nsnull,
|
|
|
|
nsIToolkit *aToolkit = nsnull,
|
|
|
|
nsWidgetInitData *aInitData = nsnull);
|
|
|
|
|
|
|
|
// Utility method for implementing both Create(nsIWidget ...) and
|
|
|
|
// Create(nsNativeWidget...)
|
|
|
|
|
|
|
|
virtual nsresult StandardCreate(nsIWidget *aParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData,
|
|
|
|
nsNativeWidget aNativeParent = nsnull);
|
|
|
|
|
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
|
|
|
|
NS_IMETHOD Show(PRBool aState);
|
2006-05-22 18:15:06 +00:00
|
|
|
NS_IMETHOD IsVisible(PRBool& outState);
|
2001-11-14 22:29:25 +00:00
|
|
|
|
2002-02-12 08:30:01 +00:00
|
|
|
virtual nsIWidget* GetParent(void);
|
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
|
|
|
PRBool *aForWindow);
|
|
|
|
|
2002-01-09 01:29:18 +00:00
|
|
|
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop,
|
|
|
|
PRInt32 *aX, PRInt32 *aY);
|
2001-11-14 22:29:25 +00:00
|
|
|
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
2002-04-06 19:50:30 +00:00
|
|
|
NS_IMETHOD MoveWithRepaintOption(PRInt32 aX, PRInt32 aY, PRBool aRepaint);
|
2001-11-14 22:29:25 +00:00
|
|
|
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
|
|
|
|
|
2002-02-28 23:10:04 +00:00
|
|
|
NS_IMETHOD Enable(PRBool aState);
|
|
|
|
NS_IMETHOD IsEnabled(PRBool *aState);
|
2001-11-14 22:29:25 +00:00
|
|
|
NS_IMETHOD SetFocus(PRBool aRaise);
|
|
|
|
NS_IMETHOD SetBounds(const nsRect &aRect);
|
|
|
|
NS_IMETHOD GetBounds(nsRect &aRect);
|
|
|
|
|
|
|
|
virtual nsIFontMetrics* GetFont(void);
|
|
|
|
NS_IMETHOD SetFont(const nsFont &aFont);
|
|
|
|
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
2002-12-13 08:43:18 +00:00
|
|
|
NS_IMETHOD Invalidate(const nsRect &aRect,PRBool aIsSynchronous);
|
|
|
|
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
|
|
|
|
NS_IMETHOD Validate();
|
2001-11-14 22:29:25 +00:00
|
|
|
|
|
|
|
virtual void* GetNativeData(PRUint32 aDataType);
|
|
|
|
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
|
|
|
|
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
|
|
|
|
NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect);
|
|
|
|
NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
|
|
|
|
NS_IMETHOD BeginResizingChildren(void);
|
|
|
|
NS_IMETHOD EndResizingChildren(void);
|
|
|
|
|
2006-03-27 11:32:55 +00:00
|
|
|
static PRBool ConvertStatus(nsEventStatus aStatus)
|
|
|
|
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
2002-12-13 08:43:18 +00:00
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
2001-11-14 22:29:25 +00:00
|
|
|
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
|
|
|
|
|
2006-03-17 23:35:39 +00:00
|
|
|
#ifndef MOZ_CAIRO_GFX
|
2005-09-30 00:59:29 +00:00
|
|
|
virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull);
|
|
|
|
virtual void EndDraw();
|
2006-03-17 23:35:39 +00:00
|
|
|
void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext);
|
|
|
|
#endif
|
2005-09-30 00:59:29 +00:00
|
|
|
NS_IMETHOD Update();
|
2006-03-17 23:35:39 +00:00
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
|
2002-12-13 08:43:18 +00:00
|
|
|
void LocalToWindowCoordinate(nsPoint& aPoint) { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); }
|
|
|
|
void LocalToWindowCoordinate(nscoord& aX, nscoord& aY) { ConvertToDeviceCoordinates(aX, aY); }
|
|
|
|
void LocalToWindowCoordinate(nsRect& aRect) { ConvertToDeviceCoordinates(aRect.x, aRect.y); }
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
|
|
|
|
NS_IMETHOD ShowMenuBar(PRBool aShow);
|
|
|
|
virtual nsIMenuBar* GetMenuBar();
|
|
|
|
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
|
|
|
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
|
|
|
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
2005-09-30 00:59:29 +00:00
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
|
2004-04-18 23:18:23 +00:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& title);
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2004-02-11 03:46:30 +00:00
|
|
|
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
|
2001-11-14 22:29:25 +00:00
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
// nsIPluginWidget
|
2003-02-28 22:59:12 +00:00
|
|
|
NS_IMETHOD GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible);
|
2002-12-13 08:43:18 +00:00
|
|
|
NS_IMETHOD StartDrawPlugin();
|
|
|
|
NS_IMETHOD EndDrawPlugin();
|
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
// Mac specific methods
|
2001-11-06 15:35:24 +00:00
|
|
|
virtual void CalcWindowRegions();
|
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
virtual PRBool PointInWidget(Point aThePoint);
|
2002-03-11 02:39:45 +00:00
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
virtual PRBool DispatchWindowEvent(nsGUIEvent& event);
|
|
|
|
virtual PRBool DispatchWindowEvent(nsGUIEvent &event,nsEventStatus &aStatus);
|
2001-11-14 22:29:25 +00:00
|
|
|
virtual void AcceptFocusOnClick(PRBool aBool) { mAcceptFocusOnClick = aBool;};
|
|
|
|
PRBool AcceptFocusOnClick() { return mAcceptFocusOnClick;};
|
|
|
|
void Flash(nsPaintEvent &aEvent);
|
2002-12-13 08:43:18 +00:00
|
|
|
|
|
|
|
void LiveResizeStarted();
|
|
|
|
void LiveResizeEnded();
|
2006-02-22 01:31:14 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
virtual gfxASurface* GetThebesSurface();
|
|
|
|
#endif
|
2001-11-06 15:35:24 +00:00
|
|
|
protected:
|
|
|
|
|
2005-09-30 00:59:29 +00:00
|
|
|
PRBool ReportDestroyEvent();
|
|
|
|
PRBool ReportMoveEvent();
|
|
|
|
PRBool ReportSizeEvent();
|
2001-11-06 15:35:24 +00:00
|
|
|
|
|
|
|
NS_IMETHOD CalcOffset(PRInt32 &aX,PRInt32 &aY);
|
|
|
|
|
2005-09-30 00:59:29 +00:00
|
|
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2001-11-14 22:29:25 +00:00
|
|
|
// override to create different kinds of child views. Autoreleases, so
|
|
|
|
// caller must retain.
|
2005-09-30 00:59:29 +00:00
|
|
|
virtual NSView* CreateCocoaView(NSRect inFrame);
|
|
|
|
void TearDownView();
|
2001-11-14 22:29:25 +00:00
|
|
|
|
|
|
|
// Find a quickdraw port in which to draw (needed by GFX until it
|
|
|
|
// is converted to Cocoa). This MUST be overridden if CreateCocoaView()
|
|
|
|
// does not create something that inherits from NSQuickDrawView!
|
2005-09-30 00:59:29 +00:00
|
|
|
virtual GrafPtr GetQuickDrawPort(); // gets plugin port or view's port
|
2002-02-22 01:58:21 +00:00
|
|
|
|
2005-09-30 00:59:29 +00:00
|
|
|
// return qdPort for a focussed ChildView, and null otherwise
|
|
|
|
GrafPtr GetChildViewQuickDrawPort();
|
|
|
|
|
|
|
|
protected:
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2005-09-30 00:59:29 +00:00
|
|
|
NSView<mozView>* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG]
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2005-09-30 00:59:29 +00:00
|
|
|
NSView<mozView>* mParentView;
|
2002-12-13 08:43:18 +00:00
|
|
|
nsIWidget* mParentWidget;
|
2002-02-12 08:30:01 +00:00
|
|
|
|
2006-03-17 23:35:39 +00:00
|
|
|
#ifndef MOZ_CAIRO_GFX
|
|
|
|
nsCOMPtr<nsIFontMetrics> mFontMetrics;
|
|
|
|
nsCOMPtr<nsIRenderingContext> mTempRenderingContext;
|
|
|
|
PRPackedBool mTempRenderingContextMadeHere;
|
|
|
|
#endif
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
PRPackedBool mDestructorCalled;
|
|
|
|
PRPackedBool mVisible;
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2002-12-13 08:43:18 +00:00
|
|
|
PRPackedBool mDrawing;
|
|
|
|
|
|
|
|
PRPackedBool mAcceptFocusOnClick;
|
|
|
|
PRPackedBool mLiveResizeInProgress;
|
|
|
|
PRPackedBool mPluginDrawing;
|
|
|
|
|
|
|
|
nsPluginPort* mPluginPort;
|
|
|
|
RgnHandle mVisRgn;
|
2001-11-06 15:35:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-09-30 00:59:29 +00:00
|
|
|
#endif // nsChildView_h__
|