mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
215 lines
9.1 KiB
C
215 lines
9.1 KiB
C
|
/* -*- 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 nsBaseWidget_h__
|
||
|
#define nsBaseWidget_h__
|
||
|
|
||
|
#include "nsRect.h"
|
||
|
#include "nsIWidget.h"
|
||
|
#include "nsIMouseListener.h"
|
||
|
#include "nsIEventListener.h"
|
||
|
#include "nsIMenuListener.h"
|
||
|
#include "nsIToolkit.h"
|
||
|
#include "nsIAppShell.h"
|
||
|
#include "nsILocalFile.h"
|
||
|
#include "nsString.h"
|
||
|
#include "nsVoidArray.h"
|
||
|
#include "nsCOMPtr.h"
|
||
|
#include "nsGUIEvent.h"
|
||
|
|
||
|
/**
|
||
|
* Common widget implementation used as base class for native
|
||
|
* or crossplatform implementations of Widgets.
|
||
|
* All cross-platform behavior that all widgets need to implement
|
||
|
* should be placed in this class.
|
||
|
* (Note: widget implementations are not required to use this
|
||
|
* class, but it gives them a head start.)
|
||
|
*/
|
||
|
|
||
|
class nsBaseWidget : public nsIWidget
|
||
|
{
|
||
|
|
||
|
public:
|
||
|
nsBaseWidget();
|
||
|
virtual ~nsBaseWidget();
|
||
|
|
||
|
NS_DECL_ISUPPORTS
|
||
|
|
||
|
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK;}
|
||
|
|
||
|
// nsIWidget interface
|
||
|
NS_IMETHOD CaptureMouse(PRBool aCapture);
|
||
|
NS_IMETHOD Validate();
|
||
|
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
|
||
|
NS_IMETHOD GetClientData(void*& aClientData);
|
||
|
NS_IMETHOD SetClientData(void* aClientData);
|
||
|
NS_IMETHOD Destroy();
|
||
|
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
||
|
virtual nsIWidget* GetParent(void);
|
||
|
virtual void AddChild(nsIWidget* aChild);
|
||
|
virtual void RemoveChild(nsIWidget* aChild);
|
||
|
|
||
|
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
|
||
|
NS_IMETHOD GetZIndex(PRInt32* aZIndex);
|
||
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
||
|
nsIWidget *aWidget, PRBool aActivate);
|
||
|
|
||
|
NS_IMETHOD SetSizeMode(PRInt32 aMode);
|
||
|
NS_IMETHOD GetSizeMode(PRInt32* aMode);
|
||
|
|
||
|
virtual nscolor GetForegroundColor(void);
|
||
|
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
|
||
|
virtual nscolor GetBackgroundColor(void);
|
||
|
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
||
|
virtual nsCursor GetCursor();
|
||
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
||
|
PRUint32 aHotspotX, PRUint32 aHotspotY);
|
||
|
NS_IMETHOD GetWindowType(nsWindowType& aWindowType);
|
||
|
NS_IMETHOD SetWindowType(nsWindowType aWindowType);
|
||
|
NS_IMETHOD SetWindowTranslucency(PRBool aTranslucent);
|
||
|
NS_IMETHOD GetWindowTranslucency(PRBool& aTranslucent);
|
||
|
NS_IMETHOD UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas);
|
||
|
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
|
||
|
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
|
||
|
nsresult MakeFullScreenInternal(PRBool aFullScreen);
|
||
|
virtual nsIRenderingContext* GetRenderingContext();
|
||
|
virtual nsIDeviceContext* GetDeviceContext();
|
||
|
virtual nsIToolkit* GetToolkit();
|
||
|
#ifdef MOZ_CAIRO_GFX
|
||
|
virtual gfxASurface* GetThebesSurface();
|
||
|
#endif
|
||
|
NS_IMETHOD SetModal(PRBool aModal);
|
||
|
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
||
|
PRBool *aForWindow);
|
||
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
|
||
|
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
|
||
|
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener);
|
||
|
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
|
||
|
NS_IMETHOD AddMenuListener(nsIMenuListener * aListener);
|
||
|
NS_IMETHOD SetBounds(const nsRect &aRect);
|
||
|
NS_IMETHOD GetBounds(nsRect &aRect);
|
||
|
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
||
|
NS_IMETHOD GetScreenBounds(nsRect &aRect);
|
||
|
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
|
||
|
NS_IMETHOD ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy);
|
||
|
NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy);
|
||
|
NS_IMETHOD EnableDragDrop(PRBool aEnable);
|
||
|
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
|
||
|
NS_IMETHOD GetLastInputEventTime(PRUint32& aTime);
|
||
|
NS_IMETHOD SetIcon(const nsAString &anIconSpec);
|
||
|
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
|
||
|
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}//~~~
|
||
|
|
||
|
protected:
|
||
|
|
||
|
virtual void ResolveIconName(const nsAString &aIconName,
|
||
|
const nsAString &aIconSuffix,
|
||
|
nsILocalFile **aResult);
|
||
|
virtual void OnDestroy();
|
||
|
virtual void BaseCreate(nsIWidget *aParent,
|
||
|
const nsRect &aRect,
|
||
|
EVENT_CALLBACK aHandleEventFunction,
|
||
|
nsIDeviceContext *aContext,
|
||
|
nsIAppShell *aAppShell,
|
||
|
nsIToolkit *aToolkit,
|
||
|
nsWidgetInitData *aInitData);
|
||
|
|
||
|
protected:
|
||
|
void* mClientData;
|
||
|
EVENT_CALLBACK mEventCallback;
|
||
|
nsIDeviceContext *mContext;
|
||
|
nsIToolkit *mToolkit;
|
||
|
nsIMouseListener *mMouseListener;
|
||
|
nsIEventListener *mEventListener;
|
||
|
nsIMenuListener *mMenuListener;
|
||
|
nscolor mBackground;
|
||
|
nscolor mForeground;
|
||
|
nsCursor mCursor;
|
||
|
nsWindowType mWindowType;
|
||
|
nsBorderStyle mBorderStyle;
|
||
|
PRPackedBool mIsShiftDown;
|
||
|
PRPackedBool mIsControlDown;
|
||
|
PRPackedBool mIsAltDown;
|
||
|
PRPackedBool mIsDestroying;
|
||
|
PRPackedBool mOnDestroyCalled;
|
||
|
nsRect mBounds;
|
||
|
nsRect* mOriginalBounds;
|
||
|
PRInt32 mZIndex;
|
||
|
nsSizeMode mSizeMode;
|
||
|
|
||
|
// Enumeration of the methods which are accessible on the "main GUI thread"
|
||
|
// via the CallMethod(...) mechanism...
|
||
|
// see nsSwitchToUIThread
|
||
|
enum {
|
||
|
CREATE = 0x0101,
|
||
|
CREATE_NATIVE,
|
||
|
DESTROY,
|
||
|
SET_FOCUS,
|
||
|
SET_CURSOR,
|
||
|
CREATE_HACK
|
||
|
};
|
||
|
|
||
|
#ifdef DEBUG
|
||
|
protected:
|
||
|
static nsAutoString debug_GuiEventToString(nsGUIEvent * aGuiEvent);
|
||
|
static PRBool debug_WantPaintFlashing();
|
||
|
|
||
|
static void debug_DumpInvalidate(FILE * aFileOut,
|
||
|
nsIWidget * aWidget,
|
||
|
const nsRect * aRect,
|
||
|
PRBool aIsSynchronous,
|
||
|
const nsCAutoString & aWidgetName,
|
||
|
PRInt32 aWindowID);
|
||
|
|
||
|
static void debug_DumpEvent(FILE * aFileOut,
|
||
|
nsIWidget * aWidget,
|
||
|
nsGUIEvent * aGuiEvent,
|
||
|
const nsCAutoString & aWidgetName,
|
||
|
PRInt32 aWindowID);
|
||
|
|
||
|
static void debug_DumpPaintEvent(FILE * aFileOut,
|
||
|
nsIWidget * aWidget,
|
||
|
nsPaintEvent * aPaintEvent,
|
||
|
const nsCAutoString & aWidgetName,
|
||
|
PRInt32 aWindowID);
|
||
|
|
||
|
static PRBool debug_GetCachedBoolPref(const char* aPrefName);
|
||
|
#endif
|
||
|
};
|
||
|
|
||
|
#endif // nsBaseWidget_h__
|