2010-03-04 21:19:41 +03: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 15:12:37 +04: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-04 03:30:26 +04:00
|
|
|
*
|
2010-03-04 21:19:41 +03:00
|
|
|
* This Original Code has been modified by IBM Corporation.
|
|
|
|
* Modifications made by IBM are
|
|
|
|
* Copyright (c) International Business Machines Corporation, 2000
|
2000-04-04 03:30:26 +04:00
|
|
|
*
|
2010-03-04 21:19:41 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*
|
2010-03-06 20:52:10 +03: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 21:19:41 +03:00
|
|
|
* Top-level widgets (windows surrounded by a frame with a titlebar, etc.)
|
2010-03-06 20:52:10 +03: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-29 03:39:35 +04:00
|
|
|
*
|
|
|
|
*/
|
2010-03-04 21:19:41 +03:00
|
|
|
//=============================================================================
|
1999-06-29 03:39:35 +04:00
|
|
|
|
|
|
|
#ifndef _nswindow_h
|
|
|
|
#define _nswindow_h
|
|
|
|
|
|
|
|
#include "nsBaseWidget.h"
|
2010-03-04 21:19:41 +03:00
|
|
|
#include "gfxASurface.h"
|
2007-02-09 02:38:51 +03:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
#define INCL_DOS
|
|
|
|
#define INCL_WIN
|
|
|
|
#define INCL_NLS
|
|
|
|
#define INCL_GPI
|
|
|
|
#include <os2.h>
|
2012-06-20 14:09:05 +04:00
|
|
|
#include <os2im.h>
|
2005-04-13 22:40:58 +04:00
|
|
|
|
2010-03-04 21:19:41 +03: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 20:22:27 +04:00
|
|
|
#endif
|
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
#ifndef WM_MOUSELEAVE
|
|
|
|
#define WM_MOUSELEAVE 0x041F
|
|
|
|
#endif
|
1999-06-29 03:39:35 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
#ifndef WM_FOCUSCHANGED
|
|
|
|
#define WM_FOCUSCHANGED 0x000E
|
|
|
|
#endif
|
1999-06-29 03:39:35 +04:00
|
|
|
|
2010-03-04 21:19:41 +03: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-29 03:39:35 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
//#define DEBUG_FOCUS
|
2000-09-15 02:49:36 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Forward declarations
|
1999-06-29 03:39:35 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
class imgIContainer;
|
|
|
|
class gfxOS2Surface;
|
2010-03-06 20:52:10 +03:00
|
|
|
class os2FrameWindow;
|
2003-03-26 08:23:13 +03:00
|
|
|
|
2010-03-04 21:19:41 +03: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-29 03:39:35 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
//=============================================================================
|
|
|
|
// nsWindow
|
|
|
|
//=============================================================================
|
1999-06-29 03:39:35 +04:00
|
|
|
|
2010-03-04 21:19:41 +03: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 05:22:44 +04:00
|
|
|
nsDeviceContext* aContext,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsWidgetInitData* aInitData = nullptr);
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
virtual nsIWidget* GetParent();
|
2010-08-13 13:58:01 +04:00
|
|
|
virtual float GetDPI();
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD Enable(bool aState);
|
2012-07-23 09:19:08 +04:00
|
|
|
virtual bool IsEnabled() const;
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD Show(bool aState);
|
2012-07-19 12:57:50 +04:00
|
|
|
virtual bool IsVisible() const;
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD SetFocus(bool aRaise);
|
2011-12-24 07:52:21 +04:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect& aRect);
|
2010-03-04 21:19:41 +03:00
|
|
|
gfxASurface* GetThebesSurface();
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void* GetNativeData(uint32_t aDataType);
|
|
|
|
virtual void FreeNativeData(void* aDatum, uint32_t aDataType);
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture);
|
|
|
|
virtual bool HasPendingInputEvent();
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD GetBounds(nsIntRect& aRect);
|
|
|
|
NS_IMETHOD GetClientBounds(nsIntRect& aRect);
|
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
2012-12-12 13:57:38 +04:00
|
|
|
NS_IMETHOD Move(double aX, double aY);
|
|
|
|
NS_IMETHOD Resize(double aWidth, double aHeight,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aRepaint);
|
2012-12-12 13:57:38 +04:00
|
|
|
NS_IMETHOD Resize(double aX, double aY,
|
|
|
|
double aWidth, double aHeight,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aRepaint);
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIWidget* aWidget, bool aActivate);
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD SetZIndex(int32_t aZIndex);
|
2010-03-04 21:19:41 +03:00
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD SetSizeMode(int32_t aMode);
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide);
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aX, int32_t* aY);
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY);
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDoCapture, bool aConsumeRollupEvent);
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aLEDState);
|
2010-03-04 21:19:41 +03:00
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event,
|
|
|
|
nsEventStatus& aStatus);
|
2010-09-18 15:28:50 +04:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
2010-03-04 21:19:41 +03:00
|
|
|
|
2011-11-30 12:59:24 +04:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aInputContext,
|
2011-11-27 15:51:52 +04:00
|
|
|
const InputContextAction& aAction)
|
|
|
|
{
|
|
|
|
mInputContext = aInputContext;
|
|
|
|
}
|
2012-10-27 03:35:21 +04:00
|
|
|
NS_IMETHOD_(InputContext) GetInputContext();
|
2011-11-27 15:51:52 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
// nsWindow
|
|
|
|
static void ReleaseGlobals();
|
2000-09-01 05:00:46 +04:00
|
|
|
protected:
|
2010-03-04 21:19:41 +03:00
|
|
|
// from nsBaseWidget
|
|
|
|
virtual void OnDestroy();
|
|
|
|
|
|
|
|
// nsWindow
|
|
|
|
static void InitGlobals();
|
2010-03-06 20:52:10 +03:00
|
|
|
nsresult CreateWindow(nsWindow* aParent,
|
2010-03-04 21:19:41 +03:00
|
|
|
HWND aParentWnd,
|
|
|
|
const nsIntRect& aRect,
|
2010-03-06 20:52:10 +03:00
|
|
|
nsWidgetInitData* aInitData);
|
2010-08-21 23:51:00 +04:00
|
|
|
gfxASurface* ConfirmThebesSurface();
|
2010-03-06 20:52:10 +03:00
|
|
|
HWND GetMainWindow();
|
2010-03-04 21:19:41 +03:00
|
|
|
static nsWindow* GetNSWindowPtr(HWND aWnd);
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool SetNSWindowPtr(HWND aWnd, nsWindow* aPtr);
|
2010-03-04 21:19:41 +03: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 20:52:10 +03:00
|
|
|
void ActivateTopLevelWidget();
|
2012-08-22 19:56:38 +04:00
|
|
|
HBITMAP DataToBitmap(uint8_t* aImageData, uint32_t aWidth,
|
|
|
|
uint32_t aHeight, uint32_t aDepth);
|
|
|
|
HBITMAP CreateBitmapRGB(uint8_t* aImageData,
|
|
|
|
uint32_t aWidth, uint32_t aHeight);
|
2010-03-04 21:19:41 +03:00
|
|
|
HBITMAP CreateTransparencyMask(gfxASurface::gfxImageFormat format,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t* aImageData,
|
|
|
|
uint32_t aWidth, uint32_t aHeight);
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool EventIsInsideWindow(nsWindow* aWindow);
|
|
|
|
static bool RollupOnButtonDown(ULONG aMsg);
|
2010-03-04 21:19:41 +03:00
|
|
|
static void RollupOnFocusLost(HWND aFocus);
|
|
|
|
MRESULT ProcessMessage(ULONG msg, MPARAM mp1, MPARAM mp2);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool OnReposition(PSWP pNewSwp);
|
|
|
|
bool OnPaint();
|
|
|
|
bool OnMouseChord(MPARAM mp1, MPARAM mp2);
|
|
|
|
bool OnDragDropMsg(ULONG msg, MPARAM mp1, MPARAM mp2,
|
2010-03-04 21:19:41 +03:00
|
|
|
MRESULT& mr);
|
2012-08-22 19:56:38 +04:00
|
|
|
bool CheckDragStatus(uint32_t aAction, HPS* aHps);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ReleaseIfDragHPS(HPS aHps);
|
|
|
|
bool OnTranslateAccelerator(PQMSG pQmsg);
|
2012-06-19 11:33:42 +04:00
|
|
|
bool OnQueryConvertPos(MPARAM mp1, MRESULT& mresult);
|
2012-06-20 14:09:05 +04:00
|
|
|
bool ImeResultString(HIMI himi);
|
|
|
|
bool ImeConversionString(HIMI himi);
|
|
|
|
bool OnImeRequest(MPARAM mp1, MPARAM mp2);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DispatchKeyEvent(MPARAM mp1, MPARAM mp2);
|
2010-03-04 21:19:41 +03:00
|
|
|
void InitEvent(nsGUIEvent& event, nsIntPoint* pt = 0);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DispatchWindowEvent(nsGUIEvent* event);
|
|
|
|
bool DispatchWindowEvent(nsGUIEvent* event,
|
2010-03-04 21:19:41 +03:00
|
|
|
nsEventStatus& aStatus);
|
2012-08-22 19:56:38 +04:00
|
|
|
bool DispatchCommandEvent(uint32_t aEventCommand);
|
|
|
|
bool DispatchDragDropEvent(uint32_t aMsg);
|
|
|
|
bool DispatchMoveEvent(int32_t aX, int32_t aY);
|
|
|
|
bool DispatchResizeEvent(int32_t aClientX,
|
|
|
|
int32_t aClientY);
|
|
|
|
bool DispatchMouseEvent(uint32_t aEventType,
|
2010-03-04 21:19:41 +03:00
|
|
|
MPARAM mp1, MPARAM mp2,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsContextMenuKey = false,
|
2012-08-22 19:56:38 +04:00
|
|
|
int16_t aButton = nsMouseEvent::eLeftButton);
|
|
|
|
bool DispatchActivationEvent(uint32_t aEventType);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DispatchScrollEvent(ULONG msg, MPARAM mp1, MPARAM mp2);
|
2010-03-04 21:19:41 +03: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 20:52:10 +03:00
|
|
|
friend class os2FrameWindow;
|
2010-03-04 21:19:41 +03:00
|
|
|
|
|
|
|
HWND mWnd; // window handle
|
|
|
|
nsWindow* mParent; // parent widget
|
2010-03-06 20:52:10 +03:00
|
|
|
os2FrameWindow* mFrame; // ptr to os2FrameWindow helper object
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mWindowState; // current nsWindowState_* value
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsDestroying; // in destructor
|
|
|
|
bool mInSetFocus; // prevent recursive calls
|
|
|
|
bool mNoPaint; // true if window is never visible
|
2010-03-04 21:19:41 +03:00
|
|
|
HPS mDragHps; // retrieved by DrgGetPS() during a drag
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mDragStatus; // set when object is being dragged over
|
2010-03-04 21:19:41 +03:00
|
|
|
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 14:09:05 +04:00
|
|
|
bool mIsComposing;
|
2012-07-15 05:22:54 +04:00
|
|
|
nsString mLastDispatchedCompositionString;
|
2002-05-31 22:48:25 +04:00
|
|
|
#ifdef DEBUG_FOCUS
|
2010-03-04 21:19:41 +03:00
|
|
|
int mWindowIdentifier; // a serial number for each new window
|
2002-05-31 22:48:25 +04:00
|
|
|
#endif
|
2011-11-27 15:51:52 +04:00
|
|
|
InputContext mInputContext;
|
1999-06-29 03:39:35 +04:00
|
|
|
};
|
|
|
|
|
2010-03-06 20:52:10 +03: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 21:19:41 +03:00
|
|
|
#endif // _nswindow_h
|
2000-10-17 02:30:06 +04:00
|
|
|
|
2010-03-04 21:19:41 +03:00
|
|
|
//=============================================================================
|
2000-10-17 02:30:06 +04:00
|
|
|
|