2010-03-04 18:19:41 +00:00
|
|
|
/* vim: set sw=2 sts=2 et cin: */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2000-04-03 23:30:26 +00:00
|
|
|
*
|
2010-03-04 18:19:41 +00:00
|
|
|
* This Original Code has been modified by IBM Corporation.
|
|
|
|
* Modifications made by IBM are
|
|
|
|
* Copyright (c) International Business Machines Corporation, 2000
|
2000-04-03 23:30:26 +00:00
|
|
|
*
|
2010-03-04 18:19:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*
|
2010-03-06 17:52:10 +00:00
|
|
|
* nsWindow derives from nsIWidget via nsBaseWindow. With the aid
|
|
|
|
* of a helper class (os2FrameWindow) and a subclass (nsChildWindow),
|
|
|
|
* it implements the functionality of both toplevel and child widgets.
|
|
|
|
*
|
2010-03-04 18:19:41 +00:00
|
|
|
* Top-level widgets (windows surrounded by a frame with a titlebar, etc.)
|
2010-03-06 17:52:10 +00:00
|
|
|
* are created when NS_WINDOW_CID is used to identify the type of object
|
|
|
|
* needed. Child widgets (windows that either are children of other windows
|
|
|
|
* or are popups such as menus) are created when NS_CHILD_CID is specified.
|
|
|
|
* Since Mozilla expects these to be different classes, NS_CHILD_CID is
|
|
|
|
* mapped to a subclass (nsChildWindow) which acts solely as a wrapper for
|
|
|
|
* nsWindow and adds no functionality.
|
|
|
|
*
|
|
|
|
* While most of the methods inherited from nsIWidget are generic, some
|
|
|
|
* apply only to toplevel widgets (e.g. setting a title or icon). The
|
|
|
|
* nature of toplevel windows on OS/2 with their separate frame & client
|
|
|
|
* windows introduces the need for additional toplevel-specific methods,
|
|
|
|
* as well as for special handling in otherwise generic methods.
|
|
|
|
*
|
|
|
|
* Rather than incorporating these toplevel functions into the body of
|
|
|
|
* the class, nsWindow delegates them to a helper class, os2FrameWindow.
|
|
|
|
* An instance of this class is created when nsWindow is told to create
|
|
|
|
* a toplevel native window and is destroyed in nsWindow's destructor.
|
|
|
|
* The class's methods operate exclusively on the frame window and never
|
|
|
|
* deal with the frame's client other than to create it. Similarly,
|
|
|
|
* nsWindow never operates on frame windows except for a few trivial
|
|
|
|
* methods (e.g. Enable()). Neither class accesses the other's data
|
|
|
|
* though, of necessity, both call the other's methods.
|
1999-06-28 23:39:35 +00:00
|
|
|
*
|
|
|
|
*/
|
2010-03-04 18:19:41 +00:00
|
|
|
//=============================================================================
|
1999-06-28 23:39:35 +00:00
|
|
|
|
|
|
|
#ifndef _nswindow_h
|
|
|
|
#define _nswindow_h
|
|
|
|
|
|
|
|
#include "nsBaseWidget.h"
|
2010-03-04 18:19:41 +00:00
|
|
|
#include "gfxASurface.h"
|
2007-02-08 23:38:51 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
#define INCL_DOS
|
|
|
|
#define INCL_WIN
|
|
|
|
#define INCL_NLS
|
|
|
|
#define INCL_GPI
|
|
|
|
#include <os2.h>
|
2012-06-20 10:09:05 +00:00
|
|
|
#include <os2im.h>
|
2005-04-13 18:40:58 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Items that may not be in the OS/2 Toolkit headers
|
|
|
|
// For WM_MOUSEENTER/LEAVE, mp2 is the other window.
|
|
|
|
#ifndef WM_MOUSEENTER
|
|
|
|
#define WM_MOUSEENTER 0x041E
|
2005-07-08 16:22:27 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
#ifndef WM_MOUSELEAVE
|
|
|
|
#define WM_MOUSELEAVE 0x041F
|
|
|
|
#endif
|
1999-06-28 23:39:35 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
#ifndef WM_FOCUSCHANGED
|
|
|
|
#define WM_FOCUSCHANGED 0x000E
|
|
|
|
#endif
|
1999-06-28 23:39:35 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
extern "C" {
|
|
|
|
PVOID APIENTRY WinQueryProperty(HWND hwnd, PCSZ pszNameOrAtom);
|
|
|
|
PVOID APIENTRY WinRemoveProperty(HWND hwnd, PCSZ pszNameOrAtom);
|
|
|
|
BOOL APIENTRY WinSetProperty(HWND hwnd, PCSZ pszNameOrAtom,
|
|
|
|
PVOID pvData, ULONG ulFlags);
|
|
|
|
APIRET APIENTRY DosQueryModFromEIP(HMODULE* phMod, ULONG* pObjNum,
|
|
|
|
ULONG BuffLen, PCHAR pBuff,
|
|
|
|
ULONG* pOffset, ULONG Address);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Macros
|
|
|
|
|
|
|
|
// nsWindow's PM window class name
|
|
|
|
#define kWindowClassName "MozillaWindowClass"
|
|
|
|
#define QWL_NSWINDOWPTR (QWL_USER+4)
|
|
|
|
|
|
|
|
// Miscellaneous global flags stored in gOS2Flags
|
|
|
|
#define kIsInitialized 0x0001
|
|
|
|
#define kIsDBCS 0x0002
|
|
|
|
#define kIsTrackPoint 0x0004
|
|
|
|
|
|
|
|
// Possible states of the window
|
|
|
|
#define nsWindowState_ePrecreate 0x0001 // Create() not called yet
|
|
|
|
#define nsWindowState_eInCreate 0x0002 // processing Create() method
|
|
|
|
#define nsWindowState_eLive 0x0004 // active, existing window
|
|
|
|
#define nsWindowState_eClosing 0x0008 // processing Close() method
|
|
|
|
#define nsWindowState_eDoingDelete 0x0010 // object destructor running
|
|
|
|
#define nsWindowState_eDead 0x0100 // window destroyed
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Debug
|
1999-06-28 23:39:35 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
//#define DEBUG_FOCUS
|
2000-09-14 22:49:36 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Forward declarations
|
1999-06-28 23:39:35 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
class imgIContainer;
|
|
|
|
class gfxOS2Surface;
|
2010-03-06 17:52:10 +00:00
|
|
|
class os2FrameWindow;
|
2003-03-26 05:23:13 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
MRESULT EXPENTRY fnwpNSWindow(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|
|
|
MRESULT EXPENTRY fnwpFrame(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
1999-06-28 23:39:35 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
//=============================================================================
|
|
|
|
// nsWindow
|
|
|
|
//=============================================================================
|
1999-06-28 23:39:35 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
class nsWindow : public nsBaseWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsWindow();
|
|
|
|
virtual ~nsWindow();
|
|
|
|
|
|
|
|
// from nsIWidget
|
|
|
|
NS_IMETHOD Create(nsIWidget* aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const nsIntRect& aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext* aContext,
|
2012-07-30 14:20:58 +00:00
|
|
|
nsWidgetInitData* aInitData = nullptr);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
virtual nsIWidget* GetParent();
|
2010-08-13 09:58:01 +00:00
|
|
|
virtual float GetDPI();
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD Enable(bool aState);
|
2012-07-23 05:19:08 +00:00
|
|
|
virtual bool IsEnabled() const;
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD Show(bool aState);
|
2012-07-19 08:57:50 +00:00
|
|
|
virtual bool IsVisible() const;
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD SetFocus(bool aRaise);
|
2011-12-24 03:52:21 +00:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect& aRect);
|
2010-03-04 18:19:41 +00:00
|
|
|
gfxASurface* GetThebesSurface();
|
|
|
|
virtual void* GetNativeData(PRUint32 aDataType);
|
|
|
|
virtual void FreeNativeData(void* aDatum, PRUint32 aDataType);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture);
|
|
|
|
virtual bool HasPendingInputEvent();
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD GetBounds(nsIntRect& aRect);
|
|
|
|
NS_IMETHOD GetClientBounds(nsIntRect& aRect);
|
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
|
|
|
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aRepaint);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY,
|
|
|
|
PRInt32 aWidth, PRInt32 aHeight,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aRepaint);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIWidget* aWidget, bool aActivate);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
|
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
|
|
|
|
NS_IMETHOD SetSizeMode(PRInt32 aMode);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
2010-03-04 18:19:41 +00:00
|
|
|
PRInt32* aX, PRInt32* aY);
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
|
|
|
PRUint32 aHotspotX, PRUint32 aHotspotY);
|
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aDoCapture, bool aConsumeRollupEvent);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* aLEDState);
|
2010-03-04 18:19:41 +00:00
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event,
|
|
|
|
nsEventStatus& aStatus);
|
2010-09-18 11:28:50 +00:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
2010-03-04 18:19:41 +00:00
|
|
|
|
2011-11-30 08:59:24 +00:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aInputContext,
|
2011-11-27 11:51:52 +00:00
|
|
|
const InputContextAction& aAction)
|
|
|
|
{
|
|
|
|
mInputContext = aInputContext;
|
|
|
|
}
|
|
|
|
NS_IMETHOD_(InputContext) GetInputContext()
|
|
|
|
{
|
|
|
|
return mInputContext;
|
|
|
|
}
|
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
// nsWindow
|
|
|
|
static void ReleaseGlobals();
|
2000-09-01 01:00:46 +00:00
|
|
|
protected:
|
2010-03-04 18:19:41 +00:00
|
|
|
// from nsBaseWidget
|
|
|
|
virtual void OnDestroy();
|
|
|
|
|
|
|
|
// nsWindow
|
|
|
|
static void InitGlobals();
|
2010-03-06 17:52:10 +00:00
|
|
|
nsresult CreateWindow(nsWindow* aParent,
|
2010-03-04 18:19:41 +00:00
|
|
|
HWND aParentWnd,
|
|
|
|
const nsIntRect& aRect,
|
2010-03-06 17:52:10 +00:00
|
|
|
nsWidgetInitData* aInitData);
|
2010-08-21 19:51:00 +00:00
|
|
|
gfxASurface* ConfirmThebesSurface();
|
2010-03-06 17:52:10 +00:00
|
|
|
HWND GetMainWindow();
|
2010-03-04 18:19:41 +00:00
|
|
|
static nsWindow* GetNSWindowPtr(HWND aWnd);
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool SetNSWindowPtr(HWND aWnd, nsWindow* aPtr);
|
2010-03-04 18:19:41 +00:00
|
|
|
void NS2PM(POINTL& ptl);
|
|
|
|
void NS2PM(RECTL& rcl);
|
|
|
|
void NS2PM_PARENT(POINTL& ptl);
|
|
|
|
void ActivatePlugin(HWND aWnd);
|
|
|
|
void SetPluginClipRegion(const Configuration& aConfiguration);
|
|
|
|
HWND GetPluginClipWindow(HWND aParentWnd);
|
2010-03-06 17:52:10 +00:00
|
|
|
void ActivateTopLevelWidget();
|
2010-03-04 18:19:41 +00:00
|
|
|
HBITMAP DataToBitmap(PRUint8* aImageData, PRUint32 aWidth,
|
|
|
|
PRUint32 aHeight, PRUint32 aDepth);
|
|
|
|
HBITMAP CreateBitmapRGB(PRUint8* aImageData,
|
|
|
|
PRUint32 aWidth, PRUint32 aHeight);
|
|
|
|
HBITMAP CreateTransparencyMask(gfxASurface::gfxImageFormat format,
|
|
|
|
PRUint8* aImageData,
|
|
|
|
PRUint32 aWidth, PRUint32 aHeight);
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool EventIsInsideWindow(nsWindow* aWindow);
|
|
|
|
static bool RollupOnButtonDown(ULONG aMsg);
|
2010-03-04 18:19:41 +00:00
|
|
|
static void RollupOnFocusLost(HWND aFocus);
|
|
|
|
MRESULT ProcessMessage(ULONG msg, MPARAM mp1, MPARAM mp2);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool OnReposition(PSWP pNewSwp);
|
|
|
|
bool OnPaint();
|
|
|
|
bool OnMouseChord(MPARAM mp1, MPARAM mp2);
|
|
|
|
bool OnDragDropMsg(ULONG msg, MPARAM mp1, MPARAM mp2,
|
2010-03-04 18:19:41 +00:00
|
|
|
MRESULT& mr);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool CheckDragStatus(PRUint32 aAction, HPS* aHps);
|
|
|
|
bool ReleaseIfDragHPS(HPS aHps);
|
|
|
|
bool OnTranslateAccelerator(PQMSG pQmsg);
|
2012-06-19 07:33:42 +00:00
|
|
|
bool OnQueryConvertPos(MPARAM mp1, MRESULT& mresult);
|
2012-06-20 10:09:05 +00:00
|
|
|
bool ImeResultString(HIMI himi);
|
|
|
|
bool ImeConversionString(HIMI himi);
|
|
|
|
bool OnImeRequest(MPARAM mp1, MPARAM mp2);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DispatchKeyEvent(MPARAM mp1, MPARAM mp2);
|
2010-03-04 18:19:41 +00:00
|
|
|
void InitEvent(nsGUIEvent& event, nsIntPoint* pt = 0);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DispatchWindowEvent(nsGUIEvent* event);
|
|
|
|
bool DispatchWindowEvent(nsGUIEvent* event,
|
2010-03-04 18:19:41 +00:00
|
|
|
nsEventStatus& aStatus);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DispatchCommandEvent(PRUint32 aEventCommand);
|
|
|
|
bool DispatchDragDropEvent(PRUint32 aMsg);
|
|
|
|
bool DispatchMoveEvent(PRInt32 aX, PRInt32 aY);
|
|
|
|
bool DispatchResizeEvent(PRInt32 aClientX,
|
2010-03-04 18:19:41 +00:00
|
|
|
PRInt32 aClientY);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DispatchMouseEvent(PRUint32 aEventType,
|
2010-03-04 18:19:41 +00:00
|
|
|
MPARAM mp1, MPARAM mp2,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsContextMenuKey = false,
|
2010-03-04 18:19:41 +00:00
|
|
|
PRInt16 aButton = nsMouseEvent::eLeftButton);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DispatchActivationEvent(PRUint32 aEventType);
|
|
|
|
bool DispatchScrollEvent(ULONG msg, MPARAM mp1, MPARAM mp2);
|
2010-03-04 18:19:41 +00:00
|
|
|
|
|
|
|
friend MRESULT EXPENTRY fnwpNSWindow(HWND hwnd, ULONG msg,
|
|
|
|
MPARAM mp1, MPARAM mp2);
|
|
|
|
friend MRESULT EXPENTRY fnwpFrame(HWND hwnd, ULONG msg,
|
|
|
|
MPARAM mp1, MPARAM mp2);
|
2010-03-06 17:52:10 +00:00
|
|
|
friend class os2FrameWindow;
|
2010-03-04 18:19:41 +00:00
|
|
|
|
|
|
|
HWND mWnd; // window handle
|
|
|
|
nsWindow* mParent; // parent widget
|
2010-03-06 17:52:10 +00:00
|
|
|
os2FrameWindow* mFrame; // ptr to os2FrameWindow helper object
|
2010-03-04 18:19:41 +00:00
|
|
|
PRInt32 mWindowState; // current nsWindowState_* value
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsDestroying; // in destructor
|
|
|
|
bool mInSetFocus; // prevent recursive calls
|
|
|
|
bool mNoPaint; // true if window is never visible
|
2010-03-04 18:19:41 +00:00
|
|
|
HPS mDragHps; // retrieved by DrgGetPS() during a drag
|
|
|
|
PRUint32 mDragStatus; // set when object is being dragged over
|
|
|
|
HWND mClipWnd; // used to clip plugin windows
|
|
|
|
HPOINTER mCssCursorHPtr; // created by SetCursor(imgIContainer*)
|
|
|
|
nsCOMPtr<imgIContainer> mCssCursorImg;// saved by SetCursor(imgIContainer*)
|
|
|
|
nsRefPtr<gfxOS2Surface> mThebesSurface;
|
2012-06-20 10:09:05 +00:00
|
|
|
bool mIsComposing;
|
2012-07-15 01:22:54 +00:00
|
|
|
nsString mLastDispatchedCompositionString;
|
2002-05-31 18:48:25 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2010-03-04 18:19:41 +00:00
|
|
|
int mWindowIdentifier; // a serial number for each new window
|
2002-05-31 18:48:25 +00:00
|
|
|
#endif
|
2011-11-27 11:51:52 +00:00
|
|
|
InputContext mInputContext;
|
1999-06-28 23:39:35 +00:00
|
|
|
};
|
|
|
|
|
2010-03-06 17:52:10 +00:00
|
|
|
//=============================================================================
|
|
|
|
// nsChildWindow
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
// This only purpose of this subclass is to map NS_CHILD_CID to
|
|
|
|
// some class other than nsWindow which is mapped to NS_WINDOW_CID.
|
|
|
|
|
|
|
|
class nsChildWindow : public nsWindow {
|
|
|
|
public:
|
|
|
|
nsChildWindow() {}
|
|
|
|
~nsChildWindow() {}
|
|
|
|
};
|
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
#endif // _nswindow_h
|
2000-10-16 22:30:06 +00:00
|
|
|
|
2010-03-04 18:19:41 +00:00
|
|
|
//=============================================================================
|
2000-10-16 22:30:06 +00:00
|
|
|
|