1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef Window_h__
|
|
|
|
#define Window_h__
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
#include "nsBaseWidget.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsdefs.h"
|
|
|
|
#include "nsSwitchToUIThread.h"
|
|
|
|
#include "nsToolkit.h"
|
|
|
|
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
#include "nsIMenuBar.h"
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIMouseListener.h"
|
|
|
|
#include "nsIEventListener.h"
|
1998-04-17 23:45:07 +00:00
|
|
|
#include "nsStringUtil.h"
|
|
|
|
#include "nsString.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-13 23:01:01 +00:00
|
|
|
#include "nsVoidArray.h"
|
|
|
|
|
1999-04-06 20:23:55 +00:00
|
|
|
class nsNativeDragTarget;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#define NSRGB_2_COLOREF(color) \
|
|
|
|
RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
|
|
|
|
|
1999-03-12 00:21:11 +00:00
|
|
|
|
1998-04-14 23:20:49 +00:00
|
|
|
/**
|
|
|
|
* Native WIN32 window wrapper.
|
|
|
|
*/
|
|
|
|
|
1999-04-19 19:04:12 +00:00
|
|
|
class nsWindow : public nsSwitchToUIThread,
|
1998-09-23 19:19:23 +00:00
|
|
|
public nsBaseWidget
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
1998-09-14 20:40:49 +00:00
|
|
|
nsWindow();
|
|
|
|
virtual ~nsWindow();
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// nsIWidget interface
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
1998-04-13 20:24:54 +00:00
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
1998-07-29 18:51:45 +00:00
|
|
|
nsIAppShell *aAppShell = nsnull,
|
1998-04-24 21:37:30 +00:00
|
|
|
nsIToolkit *aToolkit = nsnull,
|
1998-05-14 21:34:08 +00:00
|
|
|
nsWidgetInitData *aInitData = nsnull);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Create(nsNativeWidget aParent,
|
1998-04-13 20:24:54 +00:00
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
1998-07-29 18:51:45 +00:00
|
|
|
nsIAppShell *aAppShell = nsnull,
|
1998-04-24 21:37:30 +00:00
|
|
|
nsIToolkit *aToolkit = nsnull,
|
1998-05-14 21:34:08 +00:00
|
|
|
nsWidgetInitData *aInitData = nsnull);
|
1998-09-23 19:19:23 +00:00
|
|
|
|
1998-09-29 21:34:58 +00:00
|
|
|
// Utility method for implementing both Create(nsIWidget ...) and
|
|
|
|
// Create(nsNativeWidget...)
|
|
|
|
|
|
|
|
virtual nsresult StandardWindowCreate(nsIWidget *aParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData,
|
|
|
|
nsNativeWidget aNativeParent = nsnull);
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Destroy();
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual nsIWidget* GetParent(void);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Show(PRBool bState);
|
|
|
|
NS_IMETHOD IsVisible(PRBool & aState);
|
1999-05-27 21:09:49 +00:00
|
|
|
HWND mBorderlessParent;
|
|
|
|
|
1999-06-21 20:37:50 +00:00
|
|
|
NS_IMETHOD CaptureMouse(PRBool aCapture);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Move(PRUint32 aX, PRUint32 aY);
|
|
|
|
NS_IMETHOD Resize(PRUint32 aWidth,
|
1998-06-01 20:26:50 +00:00
|
|
|
PRUint32 aHeight,
|
|
|
|
PRBool aRepaint);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Resize(PRUint32 aX,
|
1998-04-13 20:24:54 +00:00
|
|
|
PRUint32 aY,
|
|
|
|
PRUint32 aWidth,
|
1998-06-01 20:26:50 +00:00
|
|
|
PRUint32 aHeight,
|
|
|
|
PRBool aRepaint);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD Enable(PRBool bState);
|
|
|
|
NS_IMETHOD SetFocus(void);
|
|
|
|
NS_IMETHOD GetBounds(nsRect &aRect);
|
1998-11-04 21:43:47 +00:00
|
|
|
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual nsIFontMetrics* GetFont(void);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD SetFont(const nsFont &aFont);
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
1998-10-09 15:18:54 +00:00
|
|
|
NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous);
|
1998-10-27 00:16:59 +00:00
|
|
|
NS_IMETHOD Update();
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void* GetNativeData(PRUint32 aDataType);
|
1999-05-27 23:20:09 +00:00
|
|
|
virtual void FreeNativeData(void * data, PRUint32 aDataType);//~~~
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
|
|
|
|
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
|
|
|
|
NS_IMETHOD SetTitle(const nsString& aTitle);
|
|
|
|
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
|
1999-06-04 04:00:30 +00:00
|
|
|
NS_IMETHOD ShowMenuBar(PRBool aShow);
|
1999-06-09 19:01:55 +00:00
|
|
|
NS_IMETHOD IsMenuBarVisible(PRBool *aVisible);
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
|
|
|
|
NS_IMETHOD RemoveTooltips();
|
|
|
|
NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]);
|
|
|
|
NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect);
|
|
|
|
NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
|
|
|
|
NS_IMETHOD BeginResizingChildren(void);
|
|
|
|
NS_IMETHOD EndResizingChildren(void);
|
|
|
|
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
|
|
|
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
1998-10-07 22:11:37 +00:00
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
1999-03-09 23:48:58 +00:00
|
|
|
NS_IMETHOD EnableFileDrop(PRBool aEnable);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-03 22:28:00 +00:00
|
|
|
virtual void SetUpForPaint(HDC aHDC);
|
1998-09-23 19:19:23 +00:00
|
|
|
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
|
1998-09-16 17:18:56 +00:00
|
|
|
|
1998-08-03 22:28:00 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// nsSwitchToUIThread interface
|
|
|
|
virtual BOOL CallMethod(MethodInfo *info);
|
|
|
|
|
|
|
|
HWND GetWindowHandle() { return mWnd; }
|
|
|
|
WNDPROC GetPrevWindowProc() { return mPrevWndProc; }
|
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
virtual PRBool DispatchMouseEvent(PRUint32 aEventType, nsPoint* aPoint = nsnull);
|
1998-04-28 19:24:52 +00:00
|
|
|
virtual PRBool AutoErase();
|
1998-05-29 22:44:13 +00:00
|
|
|
nsPoint* GetLastPoint() { return &mLastPoint; }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-17 14:30:47 +00:00
|
|
|
PRInt32 GetNewCmdMenuId() { mMenuCmdId++; return mMenuCmdId;}
|
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
void InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint = nsnull);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
|
|
|
|
1999-03-05 15:34:53 +00:00
|
|
|
virtual PRBool ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue);
|
|
|
|
virtual PRBool DispatchWindowEvent(nsGUIEvent* event);
|
|
|
|
nsresult MenuHasBeenSelected(HMENU aNativeMenu, UINT aItemNum, UINT aFlags, UINT aCommand);
|
1999-04-19 08:23:18 +00:00
|
|
|
nsresult DynamicMenuHasBeenSelected(HMENU aNativeMenu, UINT aItemNum, UINT aFlags, UINT aCommand);
|
1999-03-05 15:34:53 +00:00
|
|
|
nsIMenuItem * FindMenuItem(nsIMenu * aMenu, PRUint32 aId);
|
|
|
|
nsIMenu * FindMenu(nsIMenu * aMenu, HMENU aNativeMenu, PRInt32 &aDepth);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-14 21:34:08 +00:00
|
|
|
// Allow Derived classes to modify the height that is passed
|
|
|
|
// when the window is created or resized.
|
|
|
|
virtual PRInt32 GetHeight(PRInt32 aProposedHeight);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual LPCTSTR WindowClass();
|
|
|
|
virtual DWORD WindowStyle();
|
|
|
|
virtual DWORD WindowExStyle();
|
|
|
|
|
1998-08-03 22:28:00 +00:00
|
|
|
virtual void SubclassWindow(BOOL bState);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
virtual void OnDestroy();
|
1998-05-29 22:44:13 +00:00
|
|
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRBool OnPaint();
|
|
|
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
1999-04-23 14:30:51 +00:00
|
|
|
|
1999-06-13 21:13:12 +00:00
|
|
|
#if 1
|
1999-06-11 20:32:09 +00:00
|
|
|
BOOL OnChar(UINT mbcsCharCode, UINT virtualKeyCode, bool isMultibyte);
|
1999-06-04 05:14:01 +00:00
|
|
|
#else
|
|
|
|
BOOL OnChar(UINT aVirtualKeyCode);
|
|
|
|
#endif
|
|
|
|
|
1999-04-23 14:30:51 +00:00
|
|
|
BOOL OnKeyDown( UINT aVirtualKeyCode, UINT aScanCode);
|
|
|
|
BOOL OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode);
|
|
|
|
ULONG IsSpecialChar(UINT aVirtualKeyCode, WORD *aAsciiKey);
|
|
|
|
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
|
|
|
virtual PRBool OnScroll(UINT scrollCode, int cPos);
|
|
|
|
virtual HBRUSH OnControlColor();
|
|
|
|
|
|
|
|
static LRESULT CALLBACK WindowProc(HWND hWnd,
|
|
|
|
UINT msg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
|
|
|
|
static PRBool ConvertStatus(nsEventStatus aStatus);
|
1998-04-17 23:45:07 +00:00
|
|
|
DWORD GetBorderStyle(nsBorderStyle aBorderStyle);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
PRBool DispatchStandardEvent(PRUint32 aMsg);
|
1998-05-18 17:55:34 +00:00
|
|
|
void AddTooltip(HWND hwndOwner, nsRect* aRect, int aId);
|
1998-05-04 19:25:25 +00:00
|
|
|
void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam);
|
1998-04-24 23:09:11 +00:00
|
|
|
|
1998-06-16 17:16:59 +00:00
|
|
|
void GetNonClientBounds(nsRect &aRect);
|
1999-06-29 20:31:22 +00:00
|
|
|
void HandleTextEvent(void);
|
1999-05-03 22:57:48 +00:00
|
|
|
void HandleStartComposition(void);
|
|
|
|
void HandleEndComposition(void);
|
1999-06-29 20:31:22 +00:00
|
|
|
void MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthResult, nsTextRangeArray* textRangeListResult);
|
1998-06-16 17:16:59 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
1998-05-29 22:44:13 +00:00
|
|
|
static nsWindow* gCurrentWindow;
|
|
|
|
nsPoint mLastPoint;
|
1998-04-13 20:24:54 +00:00
|
|
|
HWND mWnd;
|
1998-05-04 19:25:25 +00:00
|
|
|
HWND mTooltip;
|
1998-04-13 20:24:54 +00:00
|
|
|
HPALETTE mPalette;
|
|
|
|
WNDPROC mPrevWndProc;
|
1999-06-08 06:07:51 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
PRBool mHas3DBorder;
|
1998-04-13 20:24:54 +00:00
|
|
|
HBRUSH mBrush;
|
|
|
|
PRBool mIsShiftDown;
|
|
|
|
PRBool mIsControlDown;
|
|
|
|
PRBool mIsAltDown;
|
1998-04-28 18:59:38 +00:00
|
|
|
PRBool mIsDestroying;
|
1998-09-15 03:45:06 +00:00
|
|
|
PRBool mOnDestroyCalled;
|
1998-09-28 22:32:48 +00:00
|
|
|
PRBool mIsVisible;
|
|
|
|
// XXX Temporary, should not be caching the font
|
|
|
|
nsFont * mFont;
|
|
|
|
|
|
|
|
PRInt32 mPreferredWidth;
|
|
|
|
PRInt32 mPreferredHeight;
|
|
|
|
|
1999-03-05 15:34:53 +00:00
|
|
|
nsIMenuBar * mMenuBar;
|
|
|
|
PRInt32 mMenuCmdId;
|
|
|
|
nsIMenu * mHitMenu;
|
|
|
|
nsVoidArray * mHitSubMenus;
|
1999-02-17 14:30:47 +00:00
|
|
|
|
1999-03-19 23:36:20 +00:00
|
|
|
// For Input Method Support
|
|
|
|
DWORD mIMEProperty;
|
|
|
|
PRBool mIMEIsComposing;
|
|
|
|
char* mIMECompositionString;
|
|
|
|
PRUnichar* mIMECompositionUniString;
|
1999-06-29 20:31:22 +00:00
|
|
|
PRInt32 mIMECompositionUniStringSize;
|
1999-03-19 23:36:20 +00:00
|
|
|
PRInt32 mIMECompositionStringLength;
|
|
|
|
PRInt32 mIMECompositionStringSize;
|
1999-06-29 20:31:22 +00:00
|
|
|
char* mIMEAttributeString;
|
|
|
|
PRInt32 mIMEAttributeStringLength;
|
|
|
|
PRInt32 mIMEAttributeStringSize;
|
|
|
|
char* mIMECompClauseString;
|
|
|
|
PRInt32 mIMECompClauseStringLength;
|
|
|
|
PRInt32 mIMECompClauseStringSize;
|
|
|
|
|
1999-06-13 21:13:12 +00:00
|
|
|
#if 1
|
1999-06-04 05:14:01 +00:00
|
|
|
BOOL mHaveDBCSLeadByte;
|
|
|
|
unsigned char mDBCSLeadByte;
|
|
|
|
#endif
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
// Drag & Drop
|
1999-04-06 20:23:55 +00:00
|
|
|
nsNativeDragTarget * mNativeDragTarget;
|
1999-06-17 23:23:11 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Enumeration of the methods which are accessable on the "main GUI thread"
|
|
|
|
// via the CallMethod(...) mechanism...
|
|
|
|
// see nsSwitchToUIThread
|
|
|
|
enum {
|
|
|
|
CREATE = 0x0101,
|
|
|
|
CREATE_NATIVE,
|
|
|
|
DESTROY,
|
|
|
|
SET_FOCUS,
|
|
|
|
SET_CURSOR,
|
|
|
|
CREATE_HACK
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL sIsRegistered;
|
1998-05-13 03:39:08 +00:00
|
|
|
|
|
|
|
HDWP mDeferredPositioner;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// A child window is a window with different style
|
|
|
|
//
|
|
|
|
class ChildWindow : public nsWindow {
|
|
|
|
|
|
|
|
public:
|
1998-09-14 20:40:49 +00:00
|
|
|
ChildWindow(){}
|
1998-07-21 18:04:18 +00:00
|
|
|
PRBool DispatchMouseEvent(PRUint32 aEventType, nsPoint* aPoint = nsnull);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual DWORD WindowStyle();
|
|
|
|
virtual DWORD WindowExStyle() { return 0; }
|
|
|
|
};
|
|
|
|
|
1998-04-17 23:45:07 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif // Window_h__
|