2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsChildView_h_
|
|
|
|
#define nsChildView_h_
|
|
|
|
|
|
|
|
// formal protocols
|
|
|
|
#include "mozView.h"
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIAccessible.h"
|
|
|
|
#include "mozAccessibleProtocol.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsBaseWidget.h"
|
|
|
|
#include "nsIPluginWidget.h"
|
|
|
|
#include "nsIScrollableView.h"
|
|
|
|
#include "nsWeakPtr.h"
|
|
|
|
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsIKBStateControl.h"
|
|
|
|
#include "nsIAppShell.h"
|
|
|
|
|
|
|
|
#include "nsIMouseListener.h"
|
|
|
|
#include "nsIEventListener.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIDragService.h"
|
|
|
|
#include "nsIMenuBar.h"
|
|
|
|
|
|
|
|
#include "nsplugindefs.h"
|
|
|
|
|
|
|
|
#undef DARWIN
|
2007-04-05 17:26:53 -07:00
|
|
|
#import <Carbon/Carbon.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2007-04-05 17:26:53 -07:00
|
|
|
class gfxASurface;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsChildView;
|
2007-04-05 17:26:53 -07:00
|
|
|
union nsPluginPort;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
@interface ChildView : NSView<
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
mozAccessible,
|
|
|
|
#endif
|
|
|
|
mozView, NSTextInput>
|
|
|
|
{
|
|
|
|
@private
|
|
|
|
NSWindow* mWindow; // shortcut to the top window, [WEAK]
|
|
|
|
|
|
|
|
// the nsChildView that created the view. It retains this NSView, so
|
|
|
|
// the link back to it must be weak.
|
|
|
|
nsChildView* mGeckoChild;
|
|
|
|
|
|
|
|
// tag for our mouse enter/exit tracking rect
|
|
|
|
NSTrackingRectTag mMouseEnterExitTag;
|
|
|
|
|
|
|
|
// Whether we're a plugin view.
|
|
|
|
BOOL mIsPluginView;
|
|
|
|
|
|
|
|
NSEvent* mCurKeyEvent; // only valid during a keyDown
|
2007-11-26 10:09:38 -08:00
|
|
|
PRBool mKeyDownHandled;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// needed for NSTextInput implementation
|
|
|
|
NSRange mMarkedRange;
|
|
|
|
NSRange mSelectedRange;
|
|
|
|
BOOL mIgnoreDoCommand;
|
|
|
|
|
|
|
|
BOOL mInHandScroll; // true for as long as we are hand scrolling
|
|
|
|
// hand scroll locations
|
|
|
|
NSPoint mHandScrollStartMouseLoc;
|
|
|
|
nscoord mHandScrollStartScrollX, mHandScrollStartScrollY;
|
|
|
|
|
|
|
|
// when menuForEvent: is called, we store its event here (strong)
|
|
|
|
NSEvent* mLastMenuForEventEvent;
|
|
|
|
|
|
|
|
// rects that were invalidated during a draw, so have pending drawing
|
|
|
|
NSMutableArray* mPendingDirtyRects;
|
|
|
|
BOOL mPendingFullDisplay;
|
|
|
|
|
2007-12-19 11:40:18 -08:00
|
|
|
// All views are always opaque (non-transparent). The only exception is when we're
|
|
|
|
// the content view in a transparent XUL window.
|
|
|
|
BOOL mIsTransparent;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Holds our drag service across multiple drag calls. The reference to the
|
|
|
|
// service is obtained when the mouse enters the view and is released when
|
|
|
|
// the mouse exits or there is a drop. This prevents us from having to
|
|
|
|
// re-establish the connection to the service manager many times per second
|
|
|
|
// when handling |draggingUpdated:| messages.
|
|
|
|
nsIDragService* mDragService;
|
|
|
|
|
|
|
|
PRUint32 mLastModifierState;
|
|
|
|
}
|
|
|
|
|
|
|
|
// these are sent to the first responder when the window key status changes
|
|
|
|
- (void)viewsWindowDidBecomeKey;
|
|
|
|
- (void)viewsWindowDidResignKey;
|
2007-05-30 11:25:44 -07:00
|
|
|
|
|
|
|
// Stop NSView hierarchy being changed during [ChildView drawRect:]
|
|
|
|
- (void)delayedTearDown;
|
2008-01-17 08:58:29 -08:00
|
|
|
|
2007-12-19 11:40:18 -08:00
|
|
|
- (void)setTransparent:(BOOL)transparent;
|
2008-01-17 08:58:29 -08:00
|
|
|
|
|
|
|
- (void)sendFocusEvent:(PRUint32)eventType;
|
2007-03-22 10:30:00 -07:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-04-15 06:43:55 -07:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsTSMManager
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsTSMManager {
|
|
|
|
public:
|
|
|
|
static PRBool IsComposing() { return sComposingView ? PR_TRUE : PR_FALSE; }
|
|
|
|
static PRBool IsIMEEnabled() { return sIsIMEEnabled; }
|
2007-08-16 13:30:50 -07:00
|
|
|
static PRBool IgnoreCommit() { return sIgnoreCommit; }
|
2007-04-15 06:43:55 -07:00
|
|
|
|
|
|
|
// Note that we cannot get the actual state in TSM. But we can trust this
|
|
|
|
// value. Because nsIMEStateManager reset this at every focus changing.
|
|
|
|
static PRBool IsRomanKeyboardsOnly() { return sIsRomanKeyboardsOnly; }
|
|
|
|
|
|
|
|
static PRBool GetIMEOpenState();
|
|
|
|
|
|
|
|
static void StartComposing(NSView<mozView>* aComposingView);
|
2007-08-16 13:30:50 -07:00
|
|
|
static void UpdateComposing(NSString* aComposingString);
|
2007-04-15 06:43:55 -07:00
|
|
|
static void EndComposing();
|
|
|
|
static void EnableIME(PRBool aEnable);
|
|
|
|
static void SetIMEOpenState(PRBool aOpen);
|
|
|
|
static void SetRomanKeyboardsOnly(PRBool aRomanOnly);
|
|
|
|
|
|
|
|
static void CommitIME();
|
|
|
|
static void CancelIME();
|
|
|
|
private:
|
|
|
|
static PRBool sIsIMEEnabled;
|
|
|
|
static PRBool sIsRomanKeyboardsOnly;
|
2007-08-16 13:30:50 -07:00
|
|
|
static PRBool sIgnoreCommit;
|
2007-04-15 06:43:55 -07:00
|
|
|
static NSView<mozView>* sComposingView;
|
2007-08-16 13:30:50 -07:00
|
|
|
static TSMDocumentID sDocumentID;
|
|
|
|
static NSString* sComposingString;
|
|
|
|
|
|
|
|
static void KillComposing();
|
2007-04-15 06:43:55 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsChildView
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsChildView : public nsBaseWidget,
|
|
|
|
public nsIPluginWidget,
|
2007-10-09 11:46:30 -07:00
|
|
|
public nsIKBStateControl
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef nsBaseWidget Inherited;
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsChildView();
|
|
|
|
virtual ~nsChildView();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIKBStateControl interface
|
|
|
|
NS_IMETHOD ResetInputState();
|
|
|
|
NS_IMETHOD SetIMEOpenState(PRBool aState);
|
|
|
|
NS_IMETHOD GetIMEOpenState(PRBool* aState);
|
2007-04-15 06:43:55 -07:00
|
|
|
NS_IMETHOD SetIMEEnabled(PRUint32 aState);
|
|
|
|
NS_IMETHOD GetIMEEnabled(PRUint32* aState);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD CancelIMEComposition();
|
2007-06-16 12:19:46 -07:00
|
|
|
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode,
|
|
|
|
PRBool* aLEDState);
|
|
|
|
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
NS_IMETHOD IsVisible(PRBool& outState);
|
|
|
|
|
|
|
|
virtual nsIWidget* GetParent(void);
|
|
|
|
|
|
|
|
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
|
|
|
PRBool *aForWindow);
|
|
|
|
|
|
|
|
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop,
|
|
|
|
PRInt32 *aX, PRInt32 *aY);
|
|
|
|
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint);
|
|
|
|
|
|
|
|
NS_IMETHOD Enable(PRBool aState);
|
|
|
|
NS_IMETHOD IsEnabled(PRBool *aState);
|
|
|
|
NS_IMETHOD SetFocus(PRBool aRaise);
|
|
|
|
NS_IMETHOD SetBounds(const nsRect &aRect);
|
|
|
|
NS_IMETHOD GetBounds(nsRect &aRect);
|
|
|
|
|
|
|
|
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
|
|
|
NS_IMETHOD Invalidate(const nsRect &aRect,PRBool aIsSynchronous);
|
|
|
|
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
|
|
|
|
NS_IMETHOD Validate();
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
static PRBool ConvertStatus(nsEventStatus aStatus)
|
|
|
|
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
|
|
|
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
|
|
|
|
|
|
|
|
NS_IMETHOD Update();
|
|
|
|
|
|
|
|
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
|
|
|
|
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); }
|
|
|
|
|
|
|
|
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
|
|
|
|
NS_IMETHOD ShowMenuBar(PRBool aShow);
|
2008-01-28 22:11:06 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
|
|
|
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
|
|
|
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
|
|
|
|
|
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
|
|
|
|
NS_IMETHOD SetTitle(const nsAString& title);
|
|
|
|
|
|
|
|
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
|
|
|
|
|
|
|
|
// nsIPluginWidget
|
|
|
|
NS_IMETHOD GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible);
|
|
|
|
NS_IMETHOD StartDrawPlugin();
|
|
|
|
NS_IMETHOD EndDrawPlugin();
|
|
|
|
|
2007-12-19 11:40:18 -08:00
|
|
|
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
|
|
|
|
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Mac specific methods
|
|
|
|
virtual PRBool PointInWidget(Point aThePoint);
|
|
|
|
|
|
|
|
virtual PRBool DispatchWindowEvent(nsGUIEvent& event);
|
|
|
|
|
|
|
|
void LiveResizeStarted();
|
|
|
|
void LiveResizeEnded();
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
void GetDocumentAccessible(nsIAccessible** aAccessible);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual gfxASurface* GetThebesSurface();
|
|
|
|
|
2007-09-27 09:01:32 -07:00
|
|
|
NS_IMETHOD BeginSecureKeyboardInput();
|
|
|
|
NS_IMETHOD EndSecureKeyboardInput();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
PRBool ReportDestroyEvent();
|
|
|
|
PRBool ReportMoveEvent();
|
|
|
|
PRBool ReportSizeEvent();
|
|
|
|
|
|
|
|
NS_IMETHOD CalcOffset(PRInt32 &aX,PRInt32 &aY);
|
|
|
|
|
|
|
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
|
|
|
|
|
|
|
// override to create different kinds of child views. Autoreleases, so
|
|
|
|
// caller must retain.
|
|
|
|
virtual NSView* CreateCocoaView(NSRect inFrame);
|
|
|
|
void TearDownView();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
NSView<mozView>* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG]
|
|
|
|
|
|
|
|
NSView<mozView>* mParentView;
|
|
|
|
nsIWidget* mParentWidget;
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// weak ref to this childview's associated mozAccessible for speed reasons
|
|
|
|
// (we get queried for it *a lot* but don't want to own it)
|
|
|
|
nsWeakPtr mAccessible;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> mTempThebesSurface;
|
|
|
|
|
|
|
|
PRPackedBool mVisible;
|
|
|
|
PRPackedBool mDrawing;
|
|
|
|
PRPackedBool mLiveResizeInProgress;
|
2007-03-26 18:07:57 -07:00
|
|
|
PRPackedBool mIsPluginView; // true if this is a plugin view
|
2007-03-22 10:30:00 -07:00
|
|
|
PRPackedBool mPluginDrawing;
|
2007-03-26 18:07:57 -07:00
|
|
|
PRPackedBool mPluginIsCG; // true if this is a CoreGraphics plugin
|
2008-01-15 15:11:55 -08:00
|
|
|
|
2008-01-17 08:58:29 -08:00
|
|
|
PRPackedBool mInSetFocus;
|
|
|
|
|
2007-03-26 18:07:57 -07:00
|
|
|
nsPluginPort mPluginPort;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // nsChildView_h_
|