1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* 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.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-13 20:24:54 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-02-04 00:39:15 +00:00
|
|
|
* Michael Lowe <michael.lowe@bigfoot.com>
|
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
#if defined(DEBUG_ftang)
|
1999-11-15 20:57:41 +00:00
|
|
|
//#define KE_DEBUG
|
1999-12-01 22:10:13 +00:00
|
|
|
//#define DEBUG_IME
|
1999-11-30 22:09:28 +00:00
|
|
|
//#define DEBUG_IME2
|
1999-11-15 20:57:41 +00:00
|
|
|
//#define DEBUG_KBSTATE
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsWindow.h"
|
1998-07-29 18:51:45 +00:00
|
|
|
#include "nsIAppShell.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIFontMetrics.h"
|
1998-09-28 22:32:48 +00:00
|
|
|
#include "nsFont.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsTransform2D.h"
|
1998-04-17 23:45:07 +00:00
|
|
|
#include "nsStringUtil.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include <windows.h>
|
1999-03-05 15:34:53 +00:00
|
|
|
//#include <winuser.h>
|
|
|
|
#include <zmouse.h>
|
|
|
|
//#include "sysmets.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "resource.h"
|
1998-04-17 00:16:11 +00:00
|
|
|
#include <commctrl.h>
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "prtime.h"
|
1998-12-15 05:44:21 +00:00
|
|
|
#include "nsIRenderingContextWin.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-19 23:36:20 +00:00
|
|
|
#include <imm.h>
|
2000-01-07 00:34:34 +00:00
|
|
|
#ifdef MOZ_AIMM
|
|
|
|
#include "aimm.h"
|
|
|
|
#endif // MOZ_AIMM
|
1999-02-17 14:30:47 +00:00
|
|
|
|
1999-04-06 20:23:55 +00:00
|
|
|
#include "nsNativeDragTarget.h"
|
1999-09-21 11:22:21 +00:00
|
|
|
#include "nsIRollupListener.h"
|
1999-11-20 22:33:42 +00:00
|
|
|
#include "nsIRegion.h"
|
1999-09-21 11:22:21 +00:00
|
|
|
|
1999-06-25 21:17:52 +00:00
|
|
|
//~~~ windowless plugin support
|
1999-06-11 22:48:50 +00:00
|
|
|
#include "nsplugindefs.h"
|
|
|
|
|
1999-03-23 21:26:20 +00:00
|
|
|
// For clipboard support
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIClipboard.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
1999-07-09 19:41:46 +00:00
|
|
|
|
2000-01-21 21:56:09 +00:00
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsITimerQueue.h"
|
|
|
|
|
1999-07-09 19:41:46 +00:00
|
|
|
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
|
|
|
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
2000-01-21 21:56:09 +00:00
|
|
|
static NS_DEFINE_CID(kTimerManagerCID, NS_TIMERMANAGER_CID);
|
1999-03-23 21:26:20 +00:00
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
BOOL nsWindow::sIsRegistered = FALSE;
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
1999-09-21 11:22:21 +00:00
|
|
|
////////////////////////////////////////////////////
|
1999-09-30 14:36:17 +00:00
|
|
|
static nsIRollupListener * gRollupListener = nsnull;
|
|
|
|
static nsIWidget * gRollupWidget = nsnull;
|
|
|
|
static PRBool gRollupConsumeRollupEvent = PR_FALSE;
|
1999-09-21 11:22:21 +00:00
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
nsWindow* nsWindow::gCurrentWindow = nsnull;
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#if 0
|
|
|
|
// #ifdef KE_DEBUG
|
|
|
|
static PRBool is_vk_down(int vk)
|
|
|
|
{
|
|
|
|
SHORT st = GetKeyState(vk);
|
|
|
|
printf("is_vk_down vk=%x st=%x\n",vk, st);
|
|
|
|
return (st & 0x80) ? PR_TRUE : PR_FALSE;
|
|
|
|
}
|
|
|
|
#define IS_VK_DOWN is_vk_down
|
|
|
|
#else
|
1998-09-02 21:14:45 +00:00
|
|
|
#define IS_VK_DOWN(a) (PRBool)(((GetKeyState(a) & 0x80)) ? (PR_TRUE) : (PR_FALSE))
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#endif
|
|
|
|
|
1998-09-02 21:14:45 +00:00
|
|
|
|
1998-05-05 23:41:16 +00:00
|
|
|
// Global variable
|
|
|
|
// g_hinst - handle of the application instance
|
|
|
|
extern HINSTANCE g_hinst;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-08-06 07:42:35 +00:00
|
|
|
//
|
|
|
|
// input method offsets
|
|
|
|
//
|
1999-11-11 22:28:52 +00:00
|
|
|
#define IME_X_OFFSET 0
|
|
|
|
#define IME_Y_OFFSET 0
|
1999-08-06 07:42:35 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
|
|
|
|
1999-11-15 20:57:41 +00:00
|
|
|
#define IS_IME_CODEPAGE(cp) ((932==(cp))||(936==(cp))||(949==(cp))||(950==(cp)))
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
//
|
|
|
|
// Macro for Active Input Method Manager (AIMM) support.
|
|
|
|
// Use AIMM method instead of Win32 Imm APIs.
|
|
|
|
//
|
|
|
|
#ifdef MOZ_AIMM
|
|
|
|
|
|
|
|
#define NS_IMM_GETCOMPOSITIONSTRING(hIMC, dwIndex, pBuf, dwBufLen, compStrLen) \
|
|
|
|
{ \
|
|
|
|
compStrLen = 0; \
|
|
|
|
if (nsToolkit::gAIMMApp) \
|
|
|
|
nsToolkit::gAIMMApp->GetCompositionStringA(hIMC, dwIndex, dwBufLen, &(compStrLen), pBuf); \
|
|
|
|
else \
|
|
|
|
compStrLen = ::ImmGetCompositionStringA(hIMC, dwIndex, pBuf, dwBufLen); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMM_GETCONTEXT(hWnd, hIMC) \
|
|
|
|
{ \
|
|
|
|
hIMC = NULL; \
|
|
|
|
if (nsToolkit::gAIMMApp) \
|
|
|
|
nsToolkit::gAIMMApp->GetContext(hWnd, &(hIMC)); \
|
|
|
|
else \
|
|
|
|
hIMC = ::ImmGetContext(hWnd); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMM_GETCONVERSIONSTATUS(hIMC, pfdwConversion, pfdwSentence) \
|
|
|
|
(nsToolkit::gAIMMApp ? \
|
|
|
|
(nsToolkit::gAIMMApp->GetConversionStatus(hIMC, pfdwConversion, pfdwSentence) == S_OK) : \
|
|
|
|
(::ImmGetConversionStatus(hIMC, pfdwConversion, pfdwSentence)))
|
|
|
|
|
|
|
|
#define NS_IMM_RELEASECONTEXT(hWnd, hIMC) \
|
|
|
|
{ \
|
|
|
|
if (nsToolkit::gAIMMApp) \
|
|
|
|
nsToolkit::gAIMMApp->ReleaseContext(hWnd, hIMC); \
|
|
|
|
else \
|
|
|
|
::ImmReleaseContext(hWnd, hIMC); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMM_NOTIFYIME(hIMC, dwAction, dwIndex, dwValue) \
|
|
|
|
(nsToolkit::gAIMMApp ? \
|
|
|
|
(nsToolkit::gAIMMApp->NotifyIME(hIMC, dwAction, dwIndex, dwValue) == S_OK) : \
|
|
|
|
(::ImmNotifyIME(hIMC, dwAction, dwIndex, dwValue)))
|
|
|
|
|
|
|
|
#define NS_IMM_SETCANDIDATEWINDOW(hIMC, candForm) \
|
|
|
|
(nsToolkit::gAIMMApp ? \
|
|
|
|
(nsToolkit::gAIMMApp->SetCandidateWindow(hIMC, candForm) == S_OK) : \
|
|
|
|
(::ImmSetCandidateWindow(hIMC, candForm)))
|
|
|
|
|
|
|
|
#define NS_IMM_SETCONVERSIONSTATUS(hIMC, pfdwConversion, pfdwSentence) \
|
|
|
|
(nsToolkit::gAIMMApp ? \
|
|
|
|
(nsToolkit::gAIMMApp->SetConversionStatus(hIMC, (pfdwConversion), (pfdwSentence)) == S_OK) : \
|
|
|
|
(::ImmSetConversionStatus(hIMC, (pfdwConversion), (pfdwSentence))))
|
|
|
|
|
|
|
|
#else /* !MOZ_AIMM */
|
|
|
|
|
|
|
|
#define NS_IMM_GETCOMPOSITIONSTRING(hIMC, dwIndex, pBuf, dwBufLen, compStrLen) \
|
|
|
|
{ compStrLen = ::ImmGetCompositionString(hIMC, dwIndex, pBuf, dwBufLen); }
|
|
|
|
|
|
|
|
#define NS_IMM_GETCONTEXT(hWnd, hIMC) \
|
|
|
|
{ hIMC = ::ImmGetContext(hWnd); }
|
|
|
|
|
|
|
|
#define NS_IMM_GETCONVERSIONSTATUS(hIMC, lpfdwConversion, lpfdwSentence) \
|
|
|
|
(::ImmGetConversionStatus(hIMC, (lpfdwConversion), (lpfdwSentence)))
|
|
|
|
|
|
|
|
#define NS_IMM_RELEASECONTEXT(hWnd, hIMC) \
|
|
|
|
{ ::ImmReleaseContext(hWnd, hIMC); }
|
|
|
|
|
|
|
|
#define NS_IMM_NOTIFYIME(hIMC, dwAction, dwIndex, dwValue) \
|
|
|
|
(::ImmNotifyIME(hIMC, dwAction, dwIndex, dwValue))
|
|
|
|
|
|
|
|
#define NS_IMM_SETCANDIDATEWINDOW(hIMC, candForm) \
|
|
|
|
(::ImmSetCandidateWindow(hIMC, candForm))
|
|
|
|
|
|
|
|
#define NS_IMM_SETCONVERSIONSTATUS(hIMC, lpfdwConversion, lpfdwSentence) \
|
|
|
|
(::ImmSetConversionStatus(hIMC, (lpfdwConversion), (lpfdwSentence)))
|
|
|
|
|
|
|
|
#endif /* MOZ_AIMM */
|
|
|
|
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
static PRBool LangIDToCP(WORD aLangID, UINT& oCP)
|
|
|
|
{
|
|
|
|
int localeid=MAKELCID(aLangID,SORT_DEFAULT);
|
|
|
|
int numchar=GetLocaleInfo(localeid,LOCALE_IDEFAULTANSICODEPAGE,NULL,0);
|
|
|
|
char cp_on_stack[32];
|
|
|
|
|
|
|
|
char* cp_name;
|
|
|
|
if(numchar > 32)
|
|
|
|
cp_name = new char[numchar];
|
|
|
|
else
|
|
|
|
cp_name = cp_on_stack;
|
|
|
|
if (cp_name) {
|
|
|
|
GetLocaleInfo(localeid,LOCALE_IDEFAULTANSICODEPAGE,cp_name,numchar);
|
|
|
|
oCP = atoi(cp_name);
|
|
|
|
if(cp_name != cp_on_stack)
|
|
|
|
delete [] cp_name;
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
oCP = CP_ACP;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-15 20:57:41 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsISupport stuff
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMPL_ADDREF(nsWindow)
|
|
|
|
NS_IMPL_RELEASE(nsWindow)
|
|
|
|
NS_IMETHODIMP nsWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
2000-02-04 00:39:15 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIKBStateControl))) {
|
1999-11-15 20:57:41 +00:00
|
|
|
*aInstancePtr = (void*) ((nsIKBStateControl*)this);
|
|
|
|
NS_ADDREF((nsBaseWidget*)this);
|
|
|
|
// NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsBaseWidget::QueryInterface(aIID,aInstancePtr);
|
|
|
|
}
|
1998-11-04 21:43:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsWindow constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsWindow::nsWindow() : nsBaseWidget()
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
mWnd = 0;
|
|
|
|
mPrevWndProc = NULL;
|
|
|
|
mBackground = ::GetSysColor(COLOR_BTNFACE);
|
|
|
|
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
|
|
|
mForeground = ::GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
mPalette = NULL;
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
mIsControlDown = PR_FALSE;
|
|
|
|
mIsAltDown = PR_FALSE;
|
|
|
|
mIsDestroying = PR_FALSE;
|
|
|
|
mOnDestroyCalled = PR_FALSE;
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
mLastPoint.x = 0;
|
|
|
|
mLastPoint.y = 0;
|
|
|
|
mPreferredWidth = 0;
|
|
|
|
mPreferredHeight = 0;
|
|
|
|
mFont = nsnull;
|
|
|
|
mIsVisible = PR_FALSE;
|
|
|
|
mHas3DBorder = PR_FALSE;
|
1999-07-27 04:27:17 +00:00
|
|
|
mWindowType = eWindowType_child;
|
|
|
|
mBorderStyle = eBorderStyle_default;
|
1999-05-27 21:09:49 +00:00
|
|
|
mBorderlessParent = 0;
|
1999-03-09 23:48:58 +00:00
|
|
|
|
1999-08-05 14:56:21 +00:00
|
|
|
mIsInMouseCapture = PR_FALSE;
|
1999-03-09 23:48:58 +00:00
|
|
|
|
1999-11-29 21:14:43 +00:00
|
|
|
mIMEProperty = 0;
|
|
|
|
mIMEIsComposing = PR_FALSE;
|
|
|
|
mIMECompString = NULL;
|
|
|
|
mIMECompUnicode = NULL;
|
|
|
|
mIMEAttributeString = NULL;
|
|
|
|
mIMEAttributeStringSize = 0;
|
|
|
|
mIMEAttributeStringLength = 0;
|
|
|
|
mIMECompClauseString = NULL;
|
|
|
|
mIMECompClauseStringSize = 0;
|
|
|
|
mIMECompClauseStringLength = 0;
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
static BOOL gbInitHKL = FALSE;
|
|
|
|
if(! gbInitHKL)
|
|
|
|
{
|
|
|
|
gbInitHKL = TRUE;
|
|
|
|
gKeyboardLayout = GetKeyboardLayout(0);
|
|
|
|
LangIDToCP((WORD)(0x0FFFFL & (DWORD)gKeyboardLayout), gCurrentKeyboardCP);
|
|
|
|
}
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-06-17 23:23:11 +00:00
|
|
|
mNativeDragTarget = nsnull;
|
1999-10-02 00:13:23 +00:00
|
|
|
mIsTopWidgetWindow = PR_FALSE;
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
HKL nsWindow::gKeyboardLayout = 0;
|
|
|
|
UINT nsWindow::gCurrentKeyboardCP = 0;
|
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsWindow destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsWindow::~nsWindow()
|
|
|
|
{
|
|
|
|
mIsDestroying = PR_TRUE;
|
|
|
|
if (gCurrentWindow == this) {
|
|
|
|
gCurrentWindow = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseTrailer * mouseTrailer = MouseTrailer::GetMouseTrailer(0);
|
|
|
|
if (mouseTrailer->GetMouseTrailerWindow() == this) {
|
|
|
|
mouseTrailer->DestroyTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the widget was released without calling Destroy() then the native
|
|
|
|
// window still exists, and we need to destroy it
|
|
|
|
if (NULL != mWnd) {
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
//XXX Temporary: Should not be caching the font
|
|
|
|
delete mFont;
|
1999-06-29 20:31:22 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// delete any of the IME structures that we allocated
|
|
|
|
//
|
1999-11-16 23:45:44 +00:00
|
|
|
if (mIMECompString!=NULL)
|
|
|
|
nsCString::Recycle(mIMECompString);
|
|
|
|
if (mIMECompUnicode!=NULL)
|
|
|
|
nsString::Recycle(mIMECompUnicode);
|
|
|
|
if (mIMEAttributeString!=NULL)
|
|
|
|
delete [] mIMEAttributeString;
|
|
|
|
if (mIMECompClauseString!=NULL)
|
|
|
|
delete [] mIMECompClauseString;
|
1999-11-01 21:53:06 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(mNativeDragTarget);
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-21 20:37:50 +00:00
|
|
|
NS_METHOD nsWindow::CaptureMouse(PRBool aCapture)
|
|
|
|
{
|
|
|
|
if (PR_TRUE == aCapture) {
|
1999-09-09 13:38:30 +00:00
|
|
|
MouseTrailer::SetCaptureWindow(this);
|
|
|
|
::SetCapture(mWnd);
|
1999-06-21 20:37:50 +00:00
|
|
|
} else {
|
1999-09-09 13:38:30 +00:00
|
|
|
MouseTrailer::SetCaptureWindow(NULL);
|
|
|
|
::ReleaseCapture();
|
1999-06-21 20:37:50 +00:00
|
|
|
}
|
1999-08-05 14:56:21 +00:00
|
|
|
mIsInMouseCapture = aCapture;
|
1999-06-21 20:37:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-14 21:34:08 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Default for height modification is to do nothing
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRInt32 nsWindow::GetHeight(PRInt32 aProposedHeight)
|
|
|
|
{
|
|
|
|
return(aProposedHeight);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-13 03:39:08 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deferred Window positioning
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-05-05 23:41:16 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::BeginResizingChildren(void)
|
1998-05-13 03:39:08 +00:00
|
|
|
{
|
|
|
|
if (NULL == mDeferredPositioner)
|
|
|
|
mDeferredPositioner = ::BeginDeferWindowPos(1);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::EndResizingChildren(void)
|
1998-05-13 03:39:08 +00:00
|
|
|
{
|
|
|
|
if (NULL != mDeferredPositioner) {
|
|
|
|
::EndDeferWindowPos(mDeferredPositioner);
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
1998-05-05 23:41:16 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
|
1998-05-05 23:41:16 +00:00
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
point.x = aOldRect.x;
|
|
|
|
point.y = aOldRect.y;
|
|
|
|
::ClientToScreen((HWND)GetNativeData(NS_NATIVE_WINDOW), &point);
|
|
|
|
aNewRect.x = point.x;
|
|
|
|
aNewRect.y = point.y;
|
|
|
|
aNewRect.width = aOldRect.width;
|
|
|
|
aNewRect.height = aOldRect.height;
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-05 23:41:16 +00:00
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
|
1998-05-05 23:41:16 +00:00
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
point.x = aOldRect.x;
|
|
|
|
point.y = aOldRect.y;
|
|
|
|
::ScreenToClient((HWND)GetNativeData(NS_NATIVE_WINDOW), &point);
|
|
|
|
aNewRect.x = point.x;
|
|
|
|
aNewRect.y = point.y;
|
|
|
|
aNewRect.width = aOldRect.width;
|
|
|
|
aNewRect.height = aOldRect.height;
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-04 19:25:25 +00:00
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Convert nsEventStatus value to a windows boolean
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRBool nsWindow::ConvertStatus(nsEventStatus aStatus)
|
|
|
|
{
|
|
|
|
switch(aStatus) {
|
1998-09-15 00:14:11 +00:00
|
|
|
case nsEventStatus_eIgnore:
|
|
|
|
return PR_FALSE;
|
|
|
|
case nsEventStatus_eConsumeNoDefault:
|
|
|
|
return PR_TRUE;
|
|
|
|
case nsEventStatus_eConsumeDoDefault:
|
|
|
|
return PR_FALSE;
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "Illegal nsEventStatus enumeration value");
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-09-15 00:14:11 +00:00
|
|
|
return PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Initialize an event to dispatch
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-05-29 22:44:13 +00:00
|
|
|
void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint)
|
1998-04-24 23:09:11 +00:00
|
|
|
{
|
|
|
|
event.widget = this;
|
1998-10-08 00:04:21 +00:00
|
|
|
NS_ADDREF(event.widget);
|
1998-04-24 23:09:11 +00:00
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
if (nsnull == aPoint) { // use the point from the event
|
|
|
|
// get the message position in client coordinates and in twips
|
|
|
|
DWORD pos = ::GetMessagePos();
|
|
|
|
POINT cpos;
|
1998-04-24 23:09:11 +00:00
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
cpos.x = LOWORD(pos);
|
|
|
|
cpos.y = HIWORD(pos);
|
1998-04-24 23:09:11 +00:00
|
|
|
|
1998-08-04 21:04:02 +00:00
|
|
|
if (mWnd != NULL) {
|
|
|
|
::ScreenToClient(mWnd, &cpos);
|
|
|
|
event.point.x = cpos.x;
|
|
|
|
event.point.y = cpos.y;
|
1998-08-04 21:06:35 +00:00
|
|
|
} else {
|
|
|
|
event.point.x = 0;
|
|
|
|
event.point.y = 0;
|
1998-08-04 21:04:02 +00:00
|
|
|
}
|
1998-05-29 22:44:13 +00:00
|
|
|
}
|
|
|
|
else { // use the point override if provided
|
|
|
|
event.point.x = aPoint->x;
|
|
|
|
event.point.y = aPoint->y;
|
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
|
|
|
|
event.time = ::GetMessageTime();
|
1998-07-23 02:55:33 +00:00
|
|
|
event.message = aEventType;
|
1998-05-29 22:44:13 +00:00
|
|
|
|
|
|
|
mLastPoint.x = event.point.x;
|
|
|
|
mLastPoint.y = event.point.y;
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invokes callback and ProcessEvent method on Event Listener object
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
NS_IMETHODIMP nsWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus)
|
1998-04-24 23:09:11 +00:00
|
|
|
{
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
debug_DumpEvent(stdout,
|
|
|
|
event->widget,
|
|
|
|
event,
|
|
|
|
"something",
|
|
|
|
(PRInt32) mWnd);
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
aStatus = nsEventStatus_eIgnore;
|
1999-07-28 21:38:57 +00:00
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
if (nsnull != mEventCallback) {
|
1998-10-07 22:11:37 +00:00
|
|
|
aStatus = (*mEventCallback)(event);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dispatch to event listener if event was not consumed
|
1998-10-07 22:11:37 +00:00
|
|
|
if ((aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener)) {
|
|
|
|
aStatus = mEventListener->ProcessEvent(*event);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
1999-04-06 00:11:43 +00:00
|
|
|
|
|
|
|
// the window can be destroyed during processing of seemingly innocuous events like, say,
|
|
|
|
// mousedowns due to the magic of scripting. mousedowns will return nsEventStatus_eIgnore,
|
|
|
|
// which causes problems with the deleted window. therefore:
|
|
|
|
if (mOnDestroyCalled)
|
|
|
|
aStatus = nsEventStatus_eConsumeNoDefault;
|
1998-10-07 22:11:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event)
|
|
|
|
{
|
|
|
|
nsEventStatus status;
|
|
|
|
DispatchEvent(event, status);
|
|
|
|
return ConvertStatus(status);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
|
1999-11-12 02:06:52 +00:00
|
|
|
PRBool nsWindow::DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus) {
|
|
|
|
DispatchEvent(event, aStatus);
|
|
|
|
return ConvertStatus(aStatus);
|
|
|
|
}
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Dispatch standard event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg)
|
|
|
|
{
|
|
|
|
nsGUIEvent event;
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_GUI_EVENT;
|
1998-05-04 19:25:25 +00:00
|
|
|
InitEvent(event, aMsg);
|
1998-10-07 22:11:37 +00:00
|
|
|
|
1998-10-08 00:04:21 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
1998-05-04 19:25:25 +00:00
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
|
1999-09-21 11:22:21 +00:00
|
|
|
//-------------------------------------------------------------------------
|
1999-09-30 14:36:17 +00:00
|
|
|
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
|
|
|
|
PRBool aDoCapture,
|
|
|
|
PRBool aConsumeRollupEvent)
|
1999-09-21 11:22:21 +00:00
|
|
|
{
|
|
|
|
if (aDoCapture) {
|
1999-11-12 23:46:11 +00:00
|
|
|
/* we haven't bothered carrying a weak reference to gRollupWidget because
|
|
|
|
we believe lifespan is properly scoped. this next assertion helps
|
|
|
|
assure that remains true. */
|
|
|
|
NS_ASSERTION(!gRollupWidget, "rollup widget reassigned before release");
|
1999-09-30 14:36:17 +00:00
|
|
|
gRollupConsumeRollupEvent = aConsumeRollupEvent;
|
1999-09-21 11:22:21 +00:00
|
|
|
NS_IF_RELEASE(gRollupListener);
|
|
|
|
NS_IF_RELEASE(gRollupWidget);
|
|
|
|
gRollupListener = aListener;
|
|
|
|
NS_ADDREF(aListener);
|
|
|
|
gRollupWidget = this;
|
|
|
|
NS_ADDREF(this);
|
|
|
|
} else {
|
|
|
|
NS_IF_RELEASE(gRollupListener);
|
|
|
|
//gRollupListener = nsnull;
|
|
|
|
NS_IF_RELEASE(gRollupWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-02 00:13:23 +00:00
|
|
|
PRBool
|
|
|
|
nsWindow::EventIsInsideWindow(nsWindow* aWindow)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
::GetWindowRect(aWindow->mWnd, &r);
|
|
|
|
DWORD pos = ::GetMessagePos();
|
|
|
|
POINT mp;
|
|
|
|
mp.x = LOWORD(pos);
|
|
|
|
mp.y = HIWORD(pos);
|
|
|
|
// now make sure that it wasn't one of our children
|
|
|
|
if (mp.x < r.left || mp.x > r.right ||
|
|
|
|
mp.y < r.top || mp.y > r.bottom) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsWindow::IsScrollbar(HWND aWnd) {
|
|
|
|
|
|
|
|
// Make sure this is one of our windows by comparing the window procedures
|
|
|
|
LONG proc = ::GetWindowLong(aWnd, GWL_WNDPROC);
|
|
|
|
if (proc == (LONG)&nsWindow::WindowProc) {
|
|
|
|
// It is a one of our windows.
|
|
|
|
nsWindow *someWindow = (nsWindow*)::GetWindowLong(aWnd, GWL_USERDATA);
|
|
|
|
//This is inefficient, but this method is only called when
|
|
|
|
//a popup window has been displayed, and your clicking within it.
|
|
|
|
//The default window class begins with Netscape so comparing with the initial
|
|
|
|
//S in SCROLLBAR will cause strcmp to immediately return.
|
|
|
|
if (strcmp(someWindow->WindowClass(),"SCROLLBAR") == 0) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// the nsWindow procedure for all nsWindows in this toolkit
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
1999-10-02 00:13:23 +00:00
|
|
|
// check to see if we have a rollup listener registered
|
|
|
|
if (nsnull != gRollupListener && nsnull != gRollupWidget) {
|
|
|
|
|
|
|
|
// All mouse wheel events cause the popup to rollup.
|
|
|
|
// XXX: Need something more reliable then WM_MOUSEWHEEL.
|
|
|
|
// This event is not always generated. The mouse wheel
|
|
|
|
// is plugged into the scrollbar scrolling in odd ways
|
|
|
|
// which make it difficult to find a message which will
|
|
|
|
// reliably be generated when the mouse wheel changes position
|
|
|
|
if (msg == WM_MOUSEWHEEL) {
|
1999-09-21 21:18:46 +00:00
|
|
|
gRollupListener->Rollup();
|
1999-10-02 00:13:23 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg == WM_ACTIVATE || msg == WM_NCLBUTTONDOWN || msg == WM_LBUTTONDOWN ||
|
2000-02-18 09:38:59 +00:00
|
|
|
msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN ||
|
1999-10-02 00:13:23 +00:00
|
|
|
msg == WM_NCMBUTTONDOWN || msg == WM_NCRBUTTONDOWN) {
|
|
|
|
// Rollup if the event is outside the popup
|
|
|
|
if (PR_FALSE == nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget)) {
|
|
|
|
gRollupListener->Rollup();
|
2000-02-18 09:38:59 +00:00
|
|
|
// return TRUE tells Windows that the event is consumed,
|
|
|
|
// false allows the event to be dispatched
|
|
|
|
//
|
|
|
|
// So if we are NOT supposed to be consuming events, let it go through
|
|
|
|
if (gRollupConsumeRollupEvent) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-09-30 14:36:17 +00:00
|
|
|
}
|
1999-10-02 00:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((msg == WM_MOUSEACTIVATE) && (nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget))) {
|
|
|
|
// Prevent the click inside the popup from causing a change in window
|
2000-01-28 23:37:36 +00:00
|
|
|
// activation. Since the popup is shown non-activated, we need to eat
|
1999-10-02 00:13:23 +00:00
|
|
|
// any requests to activate the window while it is displayed. Windows
|
|
|
|
// will automatically activate the popup on the mousedown otherwise.
|
2000-01-28 23:37:36 +00:00
|
|
|
return MA_NOACTIVATE;
|
1999-09-23 12:03:44 +00:00
|
|
|
}
|
1999-09-21 11:22:21 +00:00
|
|
|
}
|
|
|
|
|
1999-02-09 18:20:18 +00:00
|
|
|
// Get the window which caused the event and ask it to process the message
|
|
|
|
nsWindow *someWindow = (nsWindow*)::GetWindowLong(hWnd, GWL_USERDATA);
|
1998-04-17 00:16:11 +00:00
|
|
|
|
1999-07-03 01:17:44 +00:00
|
|
|
// hold on to the window for the life of this method, in case it gets
|
|
|
|
// deleted during processing. yes, it's a double hack, since someWindow
|
|
|
|
// is not really an interface.
|
|
|
|
nsCOMPtr<nsISupports> kungFuDeathGrip;
|
|
|
|
if (!someWindow->mIsDestroying) // not if we're in the destructor!
|
1999-11-15 20:57:41 +00:00
|
|
|
kungFuDeathGrip = do_QueryInterface((nsBaseWidget*)someWindow);
|
1999-07-03 01:17:44 +00:00
|
|
|
|
1999-04-06 00:11:43 +00:00
|
|
|
// Re-direct a tab change message destined for its parent window to the
|
1999-02-09 18:20:18 +00:00
|
|
|
// the actual window which generated the event.
|
1998-04-17 00:16:11 +00:00
|
|
|
if (msg == WM_NOTIFY) {
|
|
|
|
LPNMHDR pnmh = (LPNMHDR) lParam;
|
1999-07-03 01:17:44 +00:00
|
|
|
if (pnmh->code == TCN_SELCHANGE) {
|
|
|
|
someWindow = (nsWindow*)::GetWindowLong(pnmh->hwndFrom, GWL_USERDATA);
|
1998-04-17 00:16:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != someWindow) {
|
|
|
|
LRESULT retValue;
|
|
|
|
if (PR_TRUE == someWindow->ProcessMessage(msg, wParam, lParam, &retValue)) {
|
|
|
|
return retValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-29 06:21:50 +00:00
|
|
|
#if defined(STRICT)
|
|
|
|
return ::CallWindowProc((WNDPROC)someWindow->GetPrevWindowProc(), hWnd,
|
|
|
|
msg, wParam, lParam);
|
|
|
|
#else
|
|
|
|
return ::CallWindowProc((FARPROC)someWindow->GetPrevWindowProc(), hWnd,
|
|
|
|
msg, wParam, lParam);
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
#ifdef MOZ_AIMM
|
|
|
|
//
|
|
|
|
// Default Window proceduer for AIMM support.
|
|
|
|
//
|
|
|
|
LRESULT CALLBACK nsWindow::DefaultWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if(nsToolkit::gAIMMApp)
|
|
|
|
{
|
|
|
|
LRESULT lResult;
|
|
|
|
if (nsToolkit::gAIMMApp->OnDefWindowProc(hWnd, msg, wParam, lParam, &lResult) == S_OK)
|
|
|
|
return lResult;
|
|
|
|
}
|
|
|
|
return ::DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
//WINOLEAPI oleStatus;
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
1998-09-29 21:34:58 +00:00
|
|
|
// Utility method for implementing both Create(nsIWidget ...) and
|
|
|
|
// Create(nsNativeWidget...)
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
1999-03-23 21:26:20 +00:00
|
|
|
// This is needed for drag & drop & Clipboard support
|
1999-03-09 23:48:58 +00:00
|
|
|
BOOL gOLEInited = FALSE;
|
1998-09-29 21:34:58 +00:00
|
|
|
|
|
|
|
nsresult nsWindow::StandardWindowCreate(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,
|
1998-04-24 21:37:30 +00:00
|
|
|
nsIToolkit *aToolkit,
|
1998-09-29 21:34:58 +00:00
|
|
|
nsWidgetInitData *aInitData,
|
|
|
|
nsNativeWidget aNativeParent)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-08-12 22:08:17 +00:00
|
|
|
nsIWidget *baseParent = aInitData &&
|
|
|
|
(aInitData->mWindowType == eWindowType_dialog ||
|
|
|
|
aInitData->mWindowType == eWindowType_toplevel) ?
|
|
|
|
nsnull : aParent;
|
1999-10-02 00:13:23 +00:00
|
|
|
|
|
|
|
mIsTopWidgetWindow = (nsnull == baseParent);
|
|
|
|
|
1999-08-12 22:08:17 +00:00
|
|
|
BaseCreate(baseParent, aRect, aHandleEventFunction, aContext,
|
1998-09-23 19:19:23 +00:00
|
|
|
aAppShell, aToolkit, aInitData);
|
1998-07-29 18:51:45 +00:00
|
|
|
|
1999-01-28 17:06:39 +00:00
|
|
|
// See if the caller wants to explictly set clip children and clip siblings
|
1998-09-29 21:34:58 +00:00
|
|
|
DWORD style = WindowStyle();
|
|
|
|
if (nsnull != aInitData) {
|
|
|
|
if (aInitData->clipChildren) {
|
|
|
|
style |= WS_CLIPCHILDREN;
|
|
|
|
} else {
|
|
|
|
style &= ~WS_CLIPCHILDREN;
|
|
|
|
}
|
1999-01-28 17:06:39 +00:00
|
|
|
if (aInitData->clipSiblings) {
|
|
|
|
style |= WS_CLIPSIBLINGS;
|
|
|
|
}
|
1998-09-29 21:34:58 +00:00
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
|
|
|
//
|
1998-09-29 21:34:58 +00:00
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
1999-03-09 09:44:27 +00:00
|
|
|
if (toolkit) {
|
1999-02-09 18:20:18 +00:00
|
|
|
if (!toolkit->IsGuiThread()) {
|
|
|
|
DWORD args[7];
|
1998-04-13 20:24:54 +00:00
|
|
|
args[0] = (DWORD)aParent;
|
|
|
|
args[1] = (DWORD)&aRect;
|
|
|
|
args[2] = (DWORD)aHandleEventFunction;
|
|
|
|
args[3] = (DWORD)aContext;
|
1999-02-09 18:20:18 +00:00
|
|
|
args[4] = (DWORD)aAppShell;
|
|
|
|
args[5] = (DWORD)aToolkit;
|
|
|
|
args[6] = (DWORD)aInitData;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-09-29 21:34:58 +00:00
|
|
|
if (nsnull != aParent) {
|
|
|
|
// nsIWidget parent dispatch
|
1999-02-09 18:20:18 +00:00
|
|
|
MethodInfo info(this, nsWindow::CREATE, 7, args);
|
1998-09-29 21:34:58 +00:00
|
|
|
toolkit->CallMethod(&info);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Native parent dispatch
|
|
|
|
MethodInfo info(this, nsWindow::CREATE_NATIVE, 5, args);
|
|
|
|
toolkit->CallMethod(&info);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1999-03-09 09:44:27 +00:00
|
|
|
}
|
1998-09-29 21:34:58 +00:00
|
|
|
|
|
|
|
HWND parent;
|
1998-11-02 16:58:55 +00:00
|
|
|
if (nsnull != aParent) { // has a nsIWidget parent
|
1998-09-29 21:34:58 +00:00
|
|
|
parent = ((aParent) ? (HWND)aParent->GetNativeData(NS_NATIVE_WINDOW) : nsnull);
|
1998-11-02 16:58:55 +00:00
|
|
|
} else { // has a nsNative parent
|
1998-09-29 22:22:30 +00:00
|
|
|
parent = (HWND)aNativeParent;
|
1998-08-19 23:11:41 +00:00
|
|
|
}
|
|
|
|
|
1998-11-02 16:58:55 +00:00
|
|
|
DWORD extendedStyle = WindowExStyle();
|
1998-11-02 19:13:05 +00:00
|
|
|
if (nsnull != aInitData) {
|
1999-07-27 04:27:17 +00:00
|
|
|
SetWindowType(aInitData->mWindowType);
|
1999-05-27 21:09:49 +00:00
|
|
|
SetBorderStyle(aInitData->mBorderStyle);
|
|
|
|
|
1999-07-27 04:27:17 +00:00
|
|
|
if (mWindowType == eWindowType_dialog) {
|
1998-11-04 21:43:47 +00:00
|
|
|
extendedStyle &= ~WS_EX_CLIENTEDGE;
|
1999-07-27 06:34:25 +00:00
|
|
|
} else if (mWindowType == eWindowType_popup) {
|
1999-05-27 21:09:49 +00:00
|
|
|
extendedStyle = WS_EX_TOPMOST;
|
|
|
|
style = WS_POPUP;
|
|
|
|
mBorderlessParent = parent;
|
1999-10-02 00:13:23 +00:00
|
|
|
// Don't set the parent of a popup window.
|
|
|
|
parent = NULL;
|
1999-10-06 21:54:49 +00:00
|
|
|
// WS_EX_TOOLWINDOW prevents a button from being placed on
|
|
|
|
// the taskbar for the popup window.
|
|
|
|
extendedStyle |= WS_EX_TOOLWINDOW;
|
1998-11-02 19:13:05 +00:00
|
|
|
}
|
1999-07-27 06:34:25 +00:00
|
|
|
|
1999-08-07 02:51:03 +00:00
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_default) {
|
|
|
|
if (mWindowType == eWindowType_dialog)
|
|
|
|
style &= ~(WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
|
|
|
|
} else if (aInitData->mBorderStyle != eBorderStyle_all) {
|
1999-07-27 22:42:34 +00:00
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_none ||
|
|
|
|
!(aInitData->mBorderStyle & eBorderStyle_border))
|
|
|
|
style &= ~WS_BORDER;
|
|
|
|
|
1999-07-27 06:34:25 +00:00
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_none ||
|
|
|
|
!(aInitData->mBorderStyle & eBorderStyle_title)) {
|
|
|
|
style &= ~WS_DLGFRAME;
|
|
|
|
style |= WS_POPUP;
|
|
|
|
}
|
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_none ||
|
1999-07-27 22:42:34 +00:00
|
|
|
!(aInitData->mBorderStyle & (eBorderStyle_close | eBorderStyle_menu)))
|
1999-07-27 06:34:25 +00:00
|
|
|
style &= ~WS_SYSMENU;
|
1999-07-27 22:42:34 +00:00
|
|
|
|
1999-07-27 06:34:25 +00:00
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_none ||
|
1999-07-27 22:42:34 +00:00
|
|
|
!(aInitData->mBorderStyle & eBorderStyle_resizeh))
|
1999-07-27 06:34:25 +00:00
|
|
|
style &= ~WS_THICKFRAME;
|
1999-07-27 22:42:34 +00:00
|
|
|
|
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_none ||
|
|
|
|
!(aInitData->mBorderStyle & eBorderStyle_minimize))
|
1999-07-27 06:34:25 +00:00
|
|
|
style &= ~WS_MINIMIZEBOX;
|
1999-07-27 22:42:34 +00:00
|
|
|
|
|
|
|
if (aInitData->mBorderStyle == eBorderStyle_none ||
|
|
|
|
!(aInitData->mBorderStyle & eBorderStyle_maximize))
|
1999-07-27 06:34:25 +00:00
|
|
|
style &= ~WS_MAXIMIZEBOX;
|
|
|
|
}
|
1998-11-02 16:58:55 +00:00
|
|
|
}
|
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
mHas3DBorder = (extendedStyle & WS_EX_CLIENTEDGE) > 0;
|
|
|
|
|
1998-11-02 16:58:55 +00:00
|
|
|
mWnd = ::CreateWindowEx(extendedStyle,
|
1998-04-13 20:24:54 +00:00
|
|
|
WindowClass(),
|
|
|
|
"",
|
1998-08-19 23:11:41 +00:00
|
|
|
style,
|
1998-04-13 20:24:54 +00:00
|
|
|
aRect.x,
|
|
|
|
aRect.y,
|
|
|
|
aRect.width,
|
1998-05-14 21:34:08 +00:00
|
|
|
GetHeight(aRect.height),
|
1998-09-29 21:34:58 +00:00
|
|
|
parent,
|
1998-04-13 20:24:54 +00:00
|
|
|
NULL,
|
|
|
|
nsToolkit::mDllInstance,
|
|
|
|
NULL);
|
1998-09-29 21:34:58 +00:00
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
VERIFY(mWnd);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
// Initial Drag & Drop Work
|
|
|
|
if (!gOLEInited) {
|
|
|
|
DWORD dwVer = ::OleBuildVersion();
|
|
|
|
|
|
|
|
if (FAILED(::OleInitialize(NULL))){
|
1999-03-23 21:26:20 +00:00
|
|
|
printf("***** OLE has not been initialized!\n");
|
|
|
|
} else {
|
1999-03-24 18:42:34 +00:00
|
|
|
//if defined(DEBUG) printf("***** OLE has been initialized!\n");
|
1999-03-09 23:48:58 +00:00
|
|
|
}
|
|
|
|
gOLEInited = TRUE;
|
|
|
|
}
|
1999-06-17 23:23:11 +00:00
|
|
|
|
1999-08-26 14:41:17 +00:00
|
|
|
/*mNativeDragTarget = new nsNativeDragTarget(this);
|
1999-04-06 20:23:55 +00:00
|
|
|
if (NULL != mNativeDragTarget) {
|
|
|
|
mNativeDragTarget->AddRef();
|
|
|
|
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
|
|
|
|
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
|
|
|
|
}
|
|
|
|
}
|
1999-08-26 14:41:17 +00:00
|
|
|
}*/
|
1999-06-17 23:23:11 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// call the event callback to notify about creation
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
DispatchStandardEvent(NS_CREATE);
|
1998-04-13 20:24:54 +00:00
|
|
|
SubclassWindow(TRUE);
|
1998-09-29 21:34:58 +00:00
|
|
|
return(NS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Create the proper widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::Create(nsIWidget *aParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData)
|
|
|
|
{
|
|
|
|
return(StandardWindowCreate(aParent, aRect, aHandleEventFunction,
|
|
|
|
aContext, aAppShell, aToolkit, aInitData,
|
|
|
|
nsnull));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// create with a native parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-29 21:34:58 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::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,
|
1998-04-24 21:37:30 +00:00
|
|
|
nsIToolkit *aToolkit,
|
1998-05-14 21:34:08 +00:00
|
|
|
nsWidgetInitData *aInitData)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-09-29 21:34:58 +00:00
|
|
|
return(StandardWindowCreate(nsnull, aRect, aHandleEventFunction,
|
|
|
|
aContext, aAppShell, aToolkit, aInitData,
|
|
|
|
aParent));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-09-29 21:34:58 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Close this nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Destroy()
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-09 01:37:30 +00:00
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
1998-09-23 19:19:23 +00:00
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
|
|
|
if (toolkit != nsnull && !toolkit->IsGuiThread()) {
|
1998-08-09 01:37:30 +00:00
|
|
|
MethodInfo info(this, nsWindow::DESTROY);
|
1998-09-23 19:19:23 +00:00
|
|
|
toolkit->CallMethod(&info);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// disconnect from the parent
|
|
|
|
if (!mIsDestroying) {
|
1998-09-23 19:19:23 +00:00
|
|
|
nsBaseWidget::Destroy();
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1998-05-04 19:25:25 +00:00
|
|
|
|
1999-08-26 14:41:17 +00:00
|
|
|
EnableDragDrop(PR_FALSE);
|
1999-04-06 20:23:55 +00:00
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// destroy the HWND
|
|
|
|
if (mWnd) {
|
|
|
|
// prevent the widget from causing additional events
|
|
|
|
mEventCallback = nsnull;
|
|
|
|
VERIFY(::DestroyWindow(mWnd));
|
1998-09-15 03:45:06 +00:00
|
|
|
mWnd = NULL;
|
|
|
|
//our windows can be subclassed by
|
|
|
|
//others and these namless, faceless others
|
|
|
|
//may not let us know about WM_DESTROY. so,
|
|
|
|
//if OnDestroy() didn't get called, just call
|
|
|
|
//it now. MMP
|
|
|
|
if (PR_FALSE == mOnDestroyCalled)
|
|
|
|
OnDestroy();
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1999-04-06 20:23:55 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsWindow parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsWindow::GetParent(void)
|
|
|
|
{
|
1999-10-02 00:13:23 +00:00
|
|
|
if (mIsTopWidgetWindow) {
|
|
|
|
// Must use a flag instead of mWindowType to tell if the window is the
|
|
|
|
// owned by the topmost widget, because a child window can be embedded inside
|
|
|
|
// a HWND which is not associated with a nsIWidget.
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsWindow* widget = nsnull;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (mWnd) {
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
1998-08-21 21:41:36 +00:00
|
|
|
widget = (nsWindow *)::GetWindowLong(parent, GWL_USERDATA);
|
1998-08-09 01:37:30 +00:00
|
|
|
if (widget) {
|
|
|
|
// If the widget is in the process of being destroyed then
|
|
|
|
// do NOT return it
|
|
|
|
if (widget->mIsDestroying) {
|
1999-10-02 00:13:23 +00:00
|
|
|
widget = nsnull;
|
1998-08-09 01:37:30 +00:00
|
|
|
} else {
|
1998-09-17 20:02:04 +00:00
|
|
|
NS_ADDREF(widget);
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
return (nsIWidget*)widget;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hide or show this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Show(PRBool bState)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
if (bState) {
|
1999-07-28 21:38:57 +00:00
|
|
|
DWORD flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW;
|
1999-09-13 20:33:34 +00:00
|
|
|
if ((mIsVisible) || (mWindowType == eWindowType_popup)) {
|
|
|
|
flags |= SWP_NOZORDER;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:38:57 +00:00
|
|
|
if (mWindowType == eWindowType_popup) {
|
|
|
|
flags |= SWP_NOACTIVATE;
|
1999-09-13 20:33:34 +00:00
|
|
|
::SetWindowPos(mWnd, HWND_TOPMOST, 0, 0, 0, 0, flags);
|
|
|
|
} else {
|
1999-07-28 21:38:57 +00:00
|
|
|
::SetWindowPos(mWnd, HWND_TOP, 0, 0, 0, 0, flags);
|
1999-09-13 20:33:34 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
::ShowWindow(mWnd, SW_HIDE);
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
mIsVisible = bState;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return PR_TRUE if the whether the component is visible, PR_FALSE otherwise
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::IsVisible(PRBool & bState)
|
|
|
|
{
|
|
|
|
bState = mIsVisible;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-11-12 23:46:11 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Return PR_TRUE in aForWindow if the given event should be processed
|
|
|
|
// assuming this is a modal window.
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
|
|
|
PRBool *aForWindow)
|
|
|
|
{
|
|
|
|
if (!aRealEvent) {
|
2000-02-15 05:05:19 +00:00
|
|
|
*aForWindow = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
// this version actually works, but turns out to be unnecessary
|
|
|
|
// if we use the OS properly.
|
|
|
|
MSG *msg = (MSG *) aEvent;
|
1999-11-12 23:46:11 +00:00
|
|
|
|
|
|
|
switch (msg->message) {
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
case WM_MBUTTONDBLCLK:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONUP:
|
2000-02-15 05:05:19 +00:00
|
|
|
case WM_RBUTTONDBLCLK: {
|
|
|
|
HWND msgWindow, ourWindow, rollupWindow;
|
|
|
|
PRBool acceptEvent;
|
|
|
|
|
|
|
|
// is the event within our window?
|
|
|
|
msgWindow = 0;
|
|
|
|
rollupWindow = 0;
|
|
|
|
ourWindow = msg->hwnd;
|
|
|
|
while (ourWindow) {
|
|
|
|
msgWindow = ourWindow;
|
|
|
|
ourWindow = ::GetParent(ourWindow);
|
|
|
|
}
|
|
|
|
ourWindow = (HWND)GetNativeData(NS_NATIVE_WINDOW);
|
|
|
|
if (gRollupWidget)
|
|
|
|
rollupWindow = (HWND)gRollupWidget->GetNativeData(NS_NATIVE_WINDOW);
|
|
|
|
acceptEvent = msgWindow && (msgWindow == ourWindow ||
|
|
|
|
msgWindow == rollupWindow) ?
|
|
|
|
PR_TRUE : PR_FALSE;
|
|
|
|
|
|
|
|
// if not, accept events for any window that hasn't been
|
|
|
|
// disabled.
|
|
|
|
if (!acceptEvent) {
|
|
|
|
LONG proc = ::GetWindowLong(msgWindow, GWL_WNDPROC);
|
|
|
|
if (proc == (LONG)&nsWindow::WindowProc) {
|
|
|
|
nsWindow *msgWin = (nsWindow*) ::GetWindowLong(msgWindow, GWL_USERDATA);
|
|
|
|
msgWin->IsEnabled(&acceptEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*aForWindow = PR_TRUE;
|
1999-11-12 23:46:11 +00:00
|
|
|
}
|
2000-02-15 05:05:19 +00:00
|
|
|
#else
|
|
|
|
*aForWindow = PR_TRUE;
|
|
|
|
#endif
|
1999-11-12 23:46:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Move this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-05-27 21:09:49 +00:00
|
|
|
// When moving a borderless top-level window the window
|
1999-07-03 01:31:18 +00:00
|
|
|
// must be placed relative to its parent. WIN32 wants to
|
1999-05-27 21:09:49 +00:00
|
|
|
// place it relative to the screen, so we used the cached parent
|
|
|
|
// to calculate the parent's location then add the x,y passed to
|
|
|
|
// the move to get the screen coordinate for the borderless top-level
|
|
|
|
// window.
|
1999-07-27 04:27:17 +00:00
|
|
|
if (mWindowType == eWindowType_popup) {
|
1999-05-27 21:09:49 +00:00
|
|
|
HWND parent = mBorderlessParent;
|
|
|
|
if (parent) {
|
|
|
|
RECT pr;
|
|
|
|
VERIFY(::GetWindowRect(parent, &pr));
|
|
|
|
aX += pr.left;
|
|
|
|
aY += pr.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (mWnd) {
|
2000-03-08 04:41:12 +00:00
|
|
|
// Make sure this window is actually on the screen before we move it
|
|
|
|
// XXX: Needs multiple monitor support
|
|
|
|
HDC dc = ::GetDC(mWnd);
|
|
|
|
if(dc) {
|
|
|
|
if (::GetDeviceCaps(dc, TECHNOLOGY) == DT_RASDISPLAY)
|
|
|
|
{
|
|
|
|
RECT workArea;
|
|
|
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
|
|
|
if(mBounds.x >= workArea.right)
|
|
|
|
aX = mBounds.x = workArea.left;
|
|
|
|
|
|
|
|
if(mBounds.y >= workArea.bottom)
|
|
|
|
aY = mBounds.y = workArea.top;
|
|
|
|
}
|
|
|
|
::ReleaseDC(mWnd, dc);
|
|
|
|
}
|
|
|
|
|
1998-05-13 03:39:08 +00:00
|
|
|
nsIWidget *par = GetParent();
|
|
|
|
HDWP deferrer = NULL;
|
|
|
|
|
|
|
|
if (nsnull != par) {
|
|
|
|
deferrer = ((nsWindow *)par)->mDeferredPositioner;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != deferrer) {
|
1998-06-16 17:16:59 +00:00
|
|
|
VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer,
|
|
|
|
mWnd, NULL, aX, aY, 0, 0,
|
1998-05-13 03:39:08 +00:00
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
|
|
|
|
}
|
1998-06-16 17:16:59 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(par);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Resize this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_ASSERTION((aWidth >=0 ) , "Negative width passed to nsWindow::Resize");
|
|
|
|
NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
|
1998-11-24 14:57:09 +00:00
|
|
|
// Set cached value for lightweight and printing
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (mWnd) {
|
1998-05-13 03:39:08 +00:00
|
|
|
nsIWidget *par = GetParent();
|
|
|
|
HDWP deferrer = NULL;
|
|
|
|
|
|
|
|
if (nsnull != par) {
|
|
|
|
deferrer = ((nsWindow *)par)->mDeferredPositioner;
|
|
|
|
}
|
|
|
|
|
1998-06-01 20:26:50 +00:00
|
|
|
UINT flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE;
|
|
|
|
if (!aRepaint) {
|
|
|
|
flags |= SWP_NOREDRAW;
|
|
|
|
}
|
|
|
|
|
1998-05-13 03:39:08 +00:00
|
|
|
if (NULL != deferrer) {
|
1998-06-16 17:16:59 +00:00
|
|
|
VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer,
|
|
|
|
mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), flags));
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-05-14 21:34:08 +00:00
|
|
|
VERIFY(::SetWindowPos(mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight),
|
1998-06-01 20:26:50 +00:00
|
|
|
flags));
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
1998-06-16 17:16:59 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(par);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2000-02-15 21:40:31 +00:00
|
|
|
|
|
|
|
if (aRepaint)
|
|
|
|
Invalidate(PR_FALSE);
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Resize this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_METHOD nsWindow::Resize(PRInt32 aX,
|
|
|
|
PRInt32 aY,
|
|
|
|
PRInt32 aWidth,
|
|
|
|
PRInt32 aHeight,
|
1998-06-01 20:26:50 +00:00
|
|
|
PRBool aRepaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_ASSERTION((aWidth >=0 ), "Negative width passed to nsWindow::Resize");
|
|
|
|
NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
// Set cached value for lightweight and printing
|
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (mWnd) {
|
1998-05-13 03:39:08 +00:00
|
|
|
nsIWidget *par = GetParent();
|
|
|
|
HDWP deferrer = NULL;
|
|
|
|
|
|
|
|
if (nsnull != par) {
|
|
|
|
deferrer = ((nsWindow *)par)->mDeferredPositioner;
|
|
|
|
}
|
|
|
|
|
1998-06-01 20:26:50 +00:00
|
|
|
UINT flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
|
|
|
if (!aRepaint) {
|
|
|
|
flags |= SWP_NOREDRAW;
|
|
|
|
}
|
|
|
|
|
1998-05-13 03:39:08 +00:00
|
|
|
if (NULL != deferrer) {
|
1998-06-16 17:16:59 +00:00
|
|
|
VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer,
|
|
|
|
mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight),
|
1998-06-01 20:26:50 +00:00
|
|
|
flags));
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-05-14 21:34:08 +00:00
|
|
|
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight),
|
1998-06-01 20:26:50 +00:00
|
|
|
flags));
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
1998-06-16 17:16:59 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(par);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2000-02-15 21:40:31 +00:00
|
|
|
|
|
|
|
if (aRepaint)
|
|
|
|
Invalidate(PR_FALSE);
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Enable/disable this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Enable(PRBool bState)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
::EnableWindow(mWnd, bState);
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-15 05:05:19 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Give the focus to this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetFocus(void)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
|
|
|
//
|
1998-09-23 19:19:23 +00:00
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
|
|
|
if (!toolkit->IsGuiThread()) {
|
1998-04-13 20:24:54 +00:00
|
|
|
MethodInfo info(this, nsWindow::SET_FOCUS);
|
1998-09-23 19:19:23 +00:00
|
|
|
toolkit->CallMethod(&info);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mWnd) {
|
|
|
|
::SetFocus(mWnd);
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component dimension
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::GetBounds(nsRect &aRect)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-11-04 21:43:47 +00:00
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetWindowRect(mWnd, &r));
|
|
|
|
|
|
|
|
// assign size
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
|
|
|
|
// convert coordinates if parent exists
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
|
|
|
RECT pr;
|
|
|
|
VERIFY(::GetWindowRect(parent, &pr));
|
|
|
|
r.left -= pr.left;
|
|
|
|
r.top -= pr.top;
|
|
|
|
}
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
|
|
|
} else {
|
1998-11-24 14:57:09 +00:00
|
|
|
aRect = mBounds;
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component dimension
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::GetClientBounds(nsRect &aRect)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetClientRect(mWnd, &r));
|
|
|
|
|
|
|
|
// assign size
|
|
|
|
aRect.x = 0;
|
|
|
|
aRect.y = 0;
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
aRect.SetRect(0,0,0,0);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-06-16 17:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//get the bounds, but don't take into account the client size
|
|
|
|
|
|
|
|
void nsWindow::GetNonClientBounds(nsRect &aRect)
|
|
|
|
{
|
1998-11-04 21:43:47 +00:00
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetWindowRect(mWnd, &r));
|
|
|
|
|
|
|
|
// assign size
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
|
|
|
|
// convert coordinates if parent exists
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
|
|
|
RECT pr;
|
|
|
|
VERIFY(::GetWindowRect(parent, &pr));
|
|
|
|
r.left -= pr.left;
|
|
|
|
r.top -= pr.top;
|
|
|
|
}
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
|
|
|
} else {
|
|
|
|
aRect.SetRect(0,0,0,0);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the background color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetBackgroundColor(const nscolor &aColor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-09-23 19:19:23 +00:00
|
|
|
nsBaseWidget::SetBackgroundColor(aColor);
|
|
|
|
|
1998-07-21 18:04:18 +00:00
|
|
|
if (mBrush)
|
|
|
|
::DeleteObject(mBrush);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
1998-07-21 18:04:18 +00:00
|
|
|
if (mWnd != NULL) {
|
|
|
|
SetClassLong(mWnd, GCL_HBRBACKGROUND, (LONG)mBrush);
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component font
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIFontMetrics* nsWindow::GetFont(void)
|
|
|
|
{
|
|
|
|
NS_NOTYETIMPLEMENTED("GetFont not yet implemented"); // to be implemented
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this component font
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetFont(const nsFont &aFont)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-11-24 14:57:09 +00:00
|
|
|
// Cache Font for owner draw
|
|
|
|
if (mFont == nsnull) {
|
|
|
|
mFont = new nsFont(aFont);
|
|
|
|
} else {
|
|
|
|
*mFont = aFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bail out if there is no context
|
|
|
|
if (nsnull == mContext) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-11-16 22:18:30 +00:00
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
nsIFontMetrics* metrics;
|
|
|
|
mContext->GetMetricsFor(aFont, metrics);
|
|
|
|
nsFontHandle fontHandle;
|
|
|
|
metrics->GetFontHandle(fontHandle);
|
|
|
|
HFONT hfont = (HFONT)fontHandle;
|
|
|
|
|
|
|
|
// Draw in the new font
|
|
|
|
::SendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0);
|
|
|
|
NS_RELEASE(metrics);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this component cursor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetCursor(nsCursor aCursor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-09-23 19:19:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Only change cursor if it's changing
|
1998-11-18 05:25:26 +00:00
|
|
|
|
|
|
|
//XXX mCursor isn't always right. Scrollbars and others change it, too.
|
|
|
|
//XXX If we want this optimization we need a better way to do it.
|
|
|
|
//if (aCursor != mCursor) {
|
1998-04-13 20:24:54 +00:00
|
|
|
HCURSOR newCursor = NULL;
|
|
|
|
|
|
|
|
switch(aCursor) {
|
|
|
|
case eCursor_select:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_IBEAM);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_wait:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_WAIT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_hyperlink: {
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_SELECTANCHOR));
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case eCursor_standard:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_ARROW);
|
|
|
|
break;
|
|
|
|
|
1998-07-30 21:25:35 +00:00
|
|
|
case eCursor_sizeWE:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZEWE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_sizeNS:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENS);
|
|
|
|
break;
|
|
|
|
|
1998-08-07 14:45:46 +00:00
|
|
|
case eCursor_arrow_north:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWNORTH));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_north_plus:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWNORTHPLUS));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_south:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWSOUTH));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_south_plus:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWSOUTHPLUS));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_east:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWEAST));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_east_plus:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWEASTPLUS));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_west:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWWEST));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_west_plus:
|
1998-10-27 18:57:18 +00:00
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ARROWWESTPLUS));
|
1998-08-07 14:45:46 +00:00
|
|
|
break;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "Invalid cursor type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != newCursor) {
|
|
|
|
mCursor = aCursor;
|
|
|
|
HCURSOR oldCursor = ::SetCursor(newCursor);
|
|
|
|
}
|
1998-11-18 05:25:26 +00:00
|
|
|
//}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invalidate this component visible area
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-09-09 03:47:26 +00:00
|
|
|
if (mWnd)
|
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
debug_DumpInvalidate(stdout,
|
|
|
|
this,
|
|
|
|
nsnull,
|
|
|
|
aIsSynchronous,
|
|
|
|
"noname",
|
|
|
|
(PRInt32) mWnd);
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
|
|
|
VERIFY(::InvalidateRect(mWnd, NULL, TRUE));
|
|
|
|
if (aIsSynchronous) {
|
1998-04-13 20:24:54 +00:00
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
1999-09-09 03:47:26 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1999-09-09 03:47:26 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 15:18:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invalidate this component visible area
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
if (mWnd)
|
|
|
|
{
|
1998-10-09 15:18:54 +00:00
|
|
|
rect.left = aRect.x;
|
|
|
|
rect.top = aRect.y;
|
|
|
|
rect.right = aRect.x + aRect.width;
|
|
|
|
rect.bottom = aRect.y + aRect.height;
|
1999-09-09 03:47:26 +00:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
debug_DumpInvalidate(stdout,
|
|
|
|
this,
|
|
|
|
&aRect,
|
|
|
|
aIsSynchronous,
|
|
|
|
"noname",
|
|
|
|
(PRInt32) mWnd);
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
1998-10-09 15:18:54 +00:00
|
|
|
VERIFY(::InvalidateRect(mWnd, &rect, TRUE));
|
|
|
|
if (aIsSynchronous) {
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-20 22:33:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (mWnd) {
|
|
|
|
HRGN nativeRegion;
|
|
|
|
rv = aRegion->GetNativeRegion((void *&)nativeRegion);
|
|
|
|
if (nativeRegion) {
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
VERIFY(::InvalidateRgn(mWnd, nativeRegion, TRUE));
|
|
|
|
|
|
|
|
if (aIsSynchronous) {
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-27 00:16:59 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Force a synchronous repaint of the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsWindow::Update()
|
|
|
|
{
|
1999-04-06 00:11:43 +00:00
|
|
|
// updates can come through for windows no longer holding an mWnd during
|
|
|
|
// deletes triggered by JavaScript in buttons with mouse feedback
|
|
|
|
if (mWnd)
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
1998-10-27 00:16:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return some native data according to aDataType
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void* nsWindow::GetNativeData(PRUint32 aDataType)
|
|
|
|
{
|
|
|
|
switch(aDataType) {
|
1998-06-07 22:30:46 +00:00
|
|
|
case NS_NATIVE_WIDGET:
|
1998-04-13 20:24:54 +00:00
|
|
|
case NS_NATIVE_WINDOW:
|
1999-03-12 22:45:02 +00:00
|
|
|
case NS_NATIVE_PLUGIN_PORT:
|
1998-04-13 20:24:54 +00:00
|
|
|
return (void*)mWnd;
|
|
|
|
case NS_NATIVE_GRAPHIC:
|
1998-07-17 06:27:37 +00:00
|
|
|
// XXX: This is sleezy!! Remember to Release the DC after using it!
|
1998-04-13 20:24:54 +00:00
|
|
|
return (void*)::GetDC(mWnd);
|
|
|
|
case NS_NATIVE_COLORMAP:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-05-27 23:20:09 +00:00
|
|
|
//~~~
|
|
|
|
void nsWindow::FreeNativeData(void * data, PRUint32 aDataType)
|
|
|
|
{
|
|
|
|
switch(aDataType)
|
|
|
|
{
|
|
|
|
case NS_NATIVE_GRAPHIC:
|
|
|
|
::ReleaseDC(mWnd, (HDC)data);
|
|
|
|
case NS_NATIVE_WIDGET:
|
|
|
|
case NS_NATIVE_WINDOW:
|
|
|
|
case NS_NATIVE_PLUGIN_PORT:
|
|
|
|
case NS_NATIVE_COLORMAP:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the colormap of the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
if (mPalette != NULL) {
|
|
|
|
::DeleteObject(mPalette);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint8 *map = aColorMap->Index;
|
|
|
|
LPLOGPALETTE pLogPal = (LPLOGPALETTE) new char[2 * sizeof(WORD) +
|
|
|
|
aColorMap->NumColors * sizeof(PALETTEENTRY)];
|
|
|
|
pLogPal->palVersion = 0x300;
|
|
|
|
pLogPal->palNumEntries = aColorMap->NumColors;
|
|
|
|
for(int i = 0; i < aColorMap->NumColors; i++)
|
|
|
|
{
|
|
|
|
pLogPal->palPalEntry[i].peRed = *map++;
|
|
|
|
pLogPal->palPalEntry[i].peGreen = *map++;
|
|
|
|
pLogPal->palPalEntry[i].peBlue = *map++;
|
|
|
|
pLogPal->palPalEntry[i].peFlags = 0;
|
|
|
|
}
|
|
|
|
mPalette = ::CreatePalette(pLogPal);
|
|
|
|
delete pLogPal;
|
|
|
|
|
|
|
|
NS_ASSERTION(mPalette != NULL, "Null palette");
|
|
|
|
if (mPalette != NULL) {
|
|
|
|
HDC hDC = ::GetDC(mWnd);
|
|
|
|
HPALETTE hOldPalette = ::SelectPalette(hDC, mPalette, TRUE);
|
|
|
|
::RealizePalette(hDC);
|
|
|
|
::SelectPalette(hDC, hOldPalette, TRUE);
|
|
|
|
::ReleaseDC(mWnd, hDC);
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Scroll the bits of a window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2000-01-15 01:38:50 +00:00
|
|
|
//XXX Scroll is obsolete and should go away soon
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
RECT trect;
|
|
|
|
|
|
|
|
if (nsnull != aClipRect)
|
|
|
|
{
|
|
|
|
trect.left = aClipRect->x;
|
|
|
|
trect.top = aClipRect->y;
|
|
|
|
trect.right = aClipRect->XMost();
|
|
|
|
trect.bottom = aClipRect->YMost();
|
|
|
|
}
|
|
|
|
|
|
|
|
::ScrollWindowEx(mWnd, aDx, aDy, (nsnull != aClipRect) ? &trect : NULL, NULL,
|
1998-07-26 04:24:42 +00:00
|
|
|
NULL, NULL, SW_INVALIDATE | SW_SCROLLCHILDREN);
|
1998-04-13 20:24:54 +00:00
|
|
|
::UpdateWindow(mWnd);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-01-15 01:38:50 +00:00
|
|
|
NS_IMETHODIMP nsWindow::ScrollWidgets(PRInt32 aDx, PRInt32 aDy)
|
|
|
|
{
|
|
|
|
// Scroll the entire contents of the window + change the offset of any child windows
|
|
|
|
::ScrollWindowEx(mWnd, aDx, aDy, NULL, NULL, NULL,
|
|
|
|
NULL, SW_INVALIDATE | SW_SCROLLCHILDREN);
|
|
|
|
::UpdateWindow(mWnd); // Force synchronous generation of NS_PAINT
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy)
|
|
|
|
{
|
|
|
|
RECT trect;
|
|
|
|
|
|
|
|
trect.left = aRect.x;
|
|
|
|
trect.top = aRect.y;
|
|
|
|
trect.right = aRect.XMost();
|
|
|
|
trect.bottom = aRect.YMost();
|
|
|
|
|
|
|
|
// Scroll the bits in the window defined by trect.
|
|
|
|
// Child windows are not scrolled.
|
|
|
|
::ScrollWindowEx(mWnd, aDx, aDy, &trect, NULL, NULL,
|
|
|
|
NULL, SW_INVALIDATE);
|
|
|
|
::UpdateWindow(mWnd); // Force synchronous generation of NS_PAINT
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Every function that needs a thread switch goes through this function
|
|
|
|
// by calling SendMessage (..WM_CALLMETHOD..) in nsToolkit::CallMethod.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
BOOL nsWindow::CallMethod(MethodInfo *info)
|
|
|
|
{
|
|
|
|
BOOL bRet = TRUE;
|
|
|
|
|
|
|
|
switch (info->methodId) {
|
|
|
|
case nsWindow::CREATE:
|
1998-07-29 18:51:45 +00:00
|
|
|
NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod");
|
1998-04-13 20:24:54 +00:00
|
|
|
Create((nsIWidget*)(info->args[0]),
|
|
|
|
(nsRect&)*(nsRect*)(info->args[1]),
|
|
|
|
(EVENT_CALLBACK)(info->args[2]),
|
|
|
|
(nsIDeviceContext*)(info->args[3]),
|
1998-07-29 18:51:45 +00:00
|
|
|
(nsIAppShell *)(info->args[4]),
|
|
|
|
(nsIToolkit*)(info->args[5]),
|
|
|
|
(nsWidgetInitData*)(info->args[6]));
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsWindow::CREATE_NATIVE:
|
1998-07-29 18:51:45 +00:00
|
|
|
NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod");
|
1998-06-25 04:24:45 +00:00
|
|
|
Create((nsNativeWidget)(info->args[0]),
|
1998-04-13 20:24:54 +00:00
|
|
|
(nsRect&)*(nsRect*)(info->args[1]),
|
|
|
|
(EVENT_CALLBACK)(info->args[2]),
|
|
|
|
(nsIDeviceContext*)(info->args[3]),
|
1998-07-29 18:51:45 +00:00
|
|
|
(nsIAppShell *)(info->args[4]),
|
|
|
|
(nsIToolkit*)(info->args[5]),
|
|
|
|
(nsWidgetInitData*)(info->args[6]));
|
1998-04-13 20:24:54 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case nsWindow::DESTROY:
|
|
|
|
NS_ASSERTION(info->nArgs == 0, "Wrong number of arguments to CallMethod");
|
|
|
|
Destroy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsWindow::SET_FOCUS:
|
|
|
|
NS_ASSERTION(info->nArgs == 0, "Wrong number of arguments to CallMethod");
|
|
|
|
SetFocus();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bRet = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
1998-08-03 22:28:00 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::SetUpForPaint(HDC aHDC)
|
|
|
|
{
|
|
|
|
::SetBkColor (aHDC, NSRGB_2_COLOREF(mBackground));
|
|
|
|
::SetTextColor(aHDC, NSRGB_2_COLOREF(mForeground));
|
|
|
|
::SetBkMode (aHDC, TRANSPARENT);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
//---------------------------------------------------------
|
1999-08-26 14:41:17 +00:00
|
|
|
NS_METHOD nsWindow::EnableDragDrop(PRBool aEnable)
|
1999-03-09 23:48:58 +00:00
|
|
|
{
|
1999-08-26 14:41:17 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (aEnable) {
|
|
|
|
if (nsnull == mNativeDragTarget) {
|
|
|
|
mNativeDragTarget = new nsNativeDragTarget(this);
|
|
|
|
if (NULL != mNativeDragTarget) {
|
|
|
|
mNativeDragTarget->AddRef();
|
|
|
|
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
|
|
|
|
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1999-04-17 13:45:10 +00:00
|
|
|
}
|
1999-08-26 14:41:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (nsnull != mWnd && NULL != mNativeDragTarget) {
|
|
|
|
::RevokeDragDrop(mWnd);
|
|
|
|
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE)) {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
NS_RELEASE(mNativeDragTarget);
|
|
|
|
}
|
|
|
|
}
|
1999-06-17 23:23:11 +00:00
|
|
|
|
1999-08-26 14:41:17 +00:00
|
|
|
return rv;
|
1999-03-09 23:48:58 +00:00
|
|
|
}
|
1999-03-01 16:22:40 +00:00
|
|
|
|
2000-02-02 15:00:59 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
UINT nsWindow::MapFromNativeToDOM(UINT aNativeKeyCode)
|
|
|
|
{
|
|
|
|
if (aNativeKeyCode == 0xBB) { // equals
|
|
|
|
return 0x3D;
|
|
|
|
} else if (aNativeKeyCode == 0xBA) { // semicolon
|
|
|
|
return 0x3B;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aNativeKeyCode;
|
|
|
|
}
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// OnKey
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode)
|
|
|
|
{
|
|
|
|
nsKeyEvent event;
|
|
|
|
nsPoint point;
|
|
|
|
|
|
|
|
point.x = 0;
|
|
|
|
point.y = 0;
|
|
|
|
|
|
|
|
InitEvent(event, aEventType, &point); // this add ref's event.widget
|
|
|
|
|
|
|
|
event.charCode = aCharCode;
|
2000-02-02 15:00:59 +00:00
|
|
|
event.keyCode = !mIMEIsComposing?MapFromNativeToDOM(aVirtualCharCode):aVirtualCharCode;
|
1999-04-23 14:30:51 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#ifdef KE_DEBUG
|
|
|
|
static cnt=0;
|
|
|
|
printf("%d DispatchKE Type: %s charCode %d keyCode %d ", cnt++,
|
|
|
|
(NS_KEY_PRESS == aEventType)?"PRESS":(aEventType == NS_KEY_UP?"Up":"Down"),
|
|
|
|
event.charCode, event.keyCode);
|
|
|
|
printf("Shift: %s Control %s Alt: %s \n", (mIsShiftDown?"D":"U"), (mIsControlDown?"D":"U"), (mIsAltDown?"D":"U"));
|
|
|
|
printf("[%c][%c][%c] <== [%c][%c][%c][ space bar ][%c][%c][%c]\n",
|
|
|
|
IS_VK_DOWN(NS_VK_SHIFT) ? 'S' : ' ',
|
|
|
|
IS_VK_DOWN(NS_VK_CONTROL) ? 'C' : ' ',
|
|
|
|
IS_VK_DOWN(NS_VK_ALT) ? 'A' : ' ',
|
|
|
|
IS_VK_DOWN(VK_LSHIFT) ? 'S' : ' ',
|
|
|
|
IS_VK_DOWN(VK_LCONTROL) ? 'C' : ' ',
|
|
|
|
IS_VK_DOWN(VK_LMENU) ? 'A' : ' ',
|
|
|
|
IS_VK_DOWN(VK_RMENU) ? 'A' : ' ',
|
|
|
|
IS_VK_DOWN(VK_RCONTROL) ? 'C' : ' ',
|
|
|
|
IS_VK_DOWN(VK_RSHIFT) ? 'S' : ' '
|
|
|
|
|
|
|
|
);
|
|
|
|
#endif
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
event.isShift = mIsShiftDown;
|
|
|
|
event.isControl = mIsControlDown;
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
event.isMeta = PR_FALSE;
|
1999-04-23 14:30:51 +00:00
|
|
|
event.isAlt = mIsAltDown;
|
|
|
|
event.eventStructType = NS_KEY_EVENT;
|
|
|
|
|
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#define WM_CHAR_LATER(vk) ( ((vk)<= VK_SPACE) || \
|
|
|
|
(('0'<=(vk))&&((vk)<='9')) || \
|
1999-10-14 21:49:49 +00:00
|
|
|
(('A'<=(vk))&&((vk)<='Z')) || \
|
|
|
|
((VK_NUMPAD0 <=(vk))&&((vk)<=VK_DIVIDE)) || \
|
|
|
|
((0xBA <=(vk))&&((vk)<=NS_VK_BACK_QUOTE)) || \
|
|
|
|
((NS_VK_OPEN_BRACKET <=(vk))&&((vk)<=NS_VK_QUOTE)) \
|
|
|
|
)
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#define NO_WM_CHAR_LATER(vk) (! WM_CHAR_LATER(vk))
|
|
|
|
|
1999-06-10 21:38:05 +00:00
|
|
|
BOOL nsWindow::OnKeyDown( UINT aVirtualKeyCode, UINT aScanCode)
|
|
|
|
{
|
|
|
|
WORD asciiKey;
|
|
|
|
|
|
|
|
asciiKey = 0;
|
|
|
|
|
1999-09-20 21:07:39 +00:00
|
|
|
//printf("In OnKeyDown ascii %d virt: %d scan: %d\n", asciiKey, aVirtualKeyCode, aScanCode);
|
|
|
|
|
|
|
|
BOOL result = DispatchKeyEvent(NS_KEY_DOWN, asciiKey, aVirtualKeyCode);
|
|
|
|
|
|
|
|
// XXX: this is a special case hack, should probably use IsSpecialChar and
|
|
|
|
// do the right thing for all SPECIAL_KEY codes
|
|
|
|
// "SPECIAL_KEY" keys don't generate a WM_CHAR, so don't generate an NS_KEY_PRESS
|
|
|
|
// this is a special case for the delete key
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
if (aVirtualKeyCode==VK_DELETE)
|
|
|
|
{
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, 0, aVirtualKeyCode);
|
|
|
|
}
|
|
|
|
else if (NO_WM_CHAR_LATER(aVirtualKeyCode))
|
1999-09-20 21:07:39 +00:00
|
|
|
{
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, 0, aVirtualKeyCode);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
}
|
|
|
|
else if (mIsControlDown &&
|
|
|
|
(( NS_VK_0 <= aVirtualKeyCode)&&( aVirtualKeyCode <= NS_VK_9)))
|
|
|
|
{
|
|
|
|
// put the 0 - 9 in charcode instead of keycode.
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, aVirtualKeyCode, 0);
|
1999-09-20 21:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1999-06-10 21:38:05 +00:00
|
|
|
}
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
BOOL nsWindow::OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode)
|
|
|
|
{
|
2000-02-12 00:10:22 +00:00
|
|
|
BOOL result = DispatchKeyEvent(NS_KEY_UP, 0, aVirtualKeyCode);
|
|
|
|
return result;
|
1999-04-23 14:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-06-11 20:32:09 +00:00
|
|
|
BOOL nsWindow::OnChar( UINT mbcsCharCode, UINT virtualKeyCode, bool isMultiByte )
|
1999-06-04 05:14:01 +00:00
|
|
|
{
|
|
|
|
wchar_t uniChar;
|
|
|
|
char charToConvert[2];
|
|
|
|
size_t length;
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
{
|
1999-06-11 20:32:09 +00:00
|
|
|
charToConvert[0] = LOBYTE(mbcsCharCode);
|
1999-06-04 05:14:01 +00:00
|
|
|
length=1;
|
|
|
|
}
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
|
|
|
if(mIsControlDown && (virtualKeyCode <= 0x1A)) // Ctrl+A Ctrl+Z, see Programming Windows 3.1 page 110 for details
|
|
|
|
{
|
1999-10-18 03:39:48 +00:00
|
|
|
// need to account for shift here. bug 16486
|
|
|
|
if ( mIsShiftDown )
|
|
|
|
uniChar = virtualKeyCode - 1 + 'A' ;
|
|
|
|
else
|
|
|
|
uniChar = virtualKeyCode - 1 + 'a' ;
|
|
|
|
virtualKeyCode = 0;
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
}
|
|
|
|
else
|
2000-02-02 15:00:59 +00:00
|
|
|
{ // 0x20 - SPACE, 0x3D - EQUALS
|
2000-02-03 23:58:43 +00:00
|
|
|
if(virtualKeyCode < 0x20 || (virtualKeyCode == 0x3D && mIsControlDown))
|
1999-10-18 03:39:48 +00:00
|
|
|
{
|
|
|
|
uniChar = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-12-01 22:10:13 +00:00
|
|
|
::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,charToConvert,length,
|
1999-10-18 03:39:48 +00:00
|
|
|
&uniChar,sizeof(uniChar));
|
|
|
|
virtualKeyCode = 0;
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
}
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
}
|
1999-07-09 19:41:46 +00:00
|
|
|
return DispatchKeyEvent(NS_KEY_PRESS, uniChar, virtualKeyCode);
|
1999-06-04 05:14:01 +00:00
|
|
|
|
1999-07-09 19:41:46 +00:00
|
|
|
//return FALSE;
|
1999-06-04 05:14:01 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Process all nsWindows messages
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-11-13 05:16:33 +00:00
|
|
|
static PRBool gJustGotDeactivate = PR_FALSE;
|
|
|
|
static PRBool gJustGotActivate = PR_FALSE;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue)
|
|
|
|
{
|
1999-04-06 20:23:55 +00:00
|
|
|
static UINT vkKeyCached = 0; // caches VK code fon WM_KEYDOWN
|
1999-03-05 15:34:53 +00:00
|
|
|
static BOOL firstTime = TRUE; // for mouse wheel logic
|
|
|
|
static int iDeltaPerLine, iAccumDelta ; // for mouse wheel logic
|
|
|
|
ULONG ulScrollLines ; // for mouse wheel logic
|
|
|
|
|
1998-08-19 00:57:02 +00:00
|
|
|
PRBool result = PR_FALSE; // call the default nsWindow proc
|
|
|
|
nsPaletteInfo palInfo;
|
1999-03-01 16:22:40 +00:00
|
|
|
*aRetValue = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-05 15:34:53 +00:00
|
|
|
switch (msg) {
|
1998-06-01 17:04:16 +00:00
|
|
|
case WM_COMMAND: {
|
|
|
|
WORD wNotifyCode = HIWORD(wParam); // notification code
|
1999-05-28 02:11:55 +00:00
|
|
|
if ((CBN_SELENDOK == wNotifyCode) || (CBN_SELENDCANCEL == wNotifyCode)) { // Combo box change
|
|
|
|
nsGUIEvent event;
|
|
|
|
event.eventStructType = NS_GUI_EVENT;
|
|
|
|
nsPoint point(0,0);
|
|
|
|
InitEvent(event, NS_CONTROL_CHANGE, &point); // this add ref's event.widget
|
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
} else if (wNotifyCode == 0) { // Menu selection
|
1998-06-01 17:04:16 +00:00
|
|
|
nsMenuEvent event;
|
1998-10-07 22:11:37 +00:00
|
|
|
event.mCommand = LOWORD(wParam);
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_MENU_EVENT;
|
1998-06-01 17:04:16 +00:00
|
|
|
InitEvent(event, NS_MENU_SELECTED);
|
1998-10-08 00:04:21 +00:00
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
1998-06-01 17:04:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-03-09 01:58:04 +00:00
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
// all we care about right now are the minimize and maximize buttons
|
|
|
|
if (wParam == SC_MINIMIZE || wParam == SC_MAXIMIZE || wParam == SC_RESTORE) {
|
|
|
|
nsSizeModeEvent event;
|
|
|
|
event.eventStructType = NS_SIZEMODE_EVENT;
|
|
|
|
event.mSizeMode = nsSizeMode_Normal;
|
|
|
|
if (wParam == SC_MINIMIZE)
|
|
|
|
event.mSizeMode = nsSizeMode_Minimized;
|
|
|
|
if (wParam == SC_MAXIMIZE)
|
|
|
|
event.mSizeMode = nsSizeMode_Maximized;
|
|
|
|
InitEvent(event, NS_SIZEMODE);
|
|
|
|
|
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-10-06 21:54:49 +00:00
|
|
|
case WM_DISPLAYCHANGE:
|
|
|
|
DispatchStandardEvent(NS_DISPLAYCHANGED);
|
|
|
|
break;
|
|
|
|
|
2000-01-21 21:56:09 +00:00
|
|
|
case WM_ENTERIDLE:
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsITimerQueue, queue, kTimerManagerCID, &rv);
|
|
|
|
if (!NS_FAILED(rv)) {
|
|
|
|
|
|
|
|
if (queue->HasReadyTimers(NS_PRIORITY_LOWEST)) {
|
|
|
|
|
|
|
|
MSG wmsg;
|
|
|
|
do {
|
|
|
|
//printf("fire\n");
|
|
|
|
queue->FireNextReadyTimer(NS_PRIORITY_LOWEST);
|
|
|
|
} while (queue->HasReadyTimers(NS_PRIORITY_LOWEST) &&
|
|
|
|
!::PeekMessage(&wmsg, NULL, 0, 0, PM_NOREMOVE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-04-17 00:16:11 +00:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
// TAB change
|
1998-04-24 23:09:11 +00:00
|
|
|
{
|
|
|
|
LPNMHDR pnmh = (LPNMHDR) lParam;
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
switch (pnmh->code) {
|
|
|
|
case TCN_SELCHANGE: {
|
|
|
|
DispatchStandardEvent(NS_TABCHANGE);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
1998-04-17 00:16:11 +00:00
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOVE: // Window moved
|
|
|
|
{
|
1998-05-29 22:44:13 +00:00
|
|
|
PRInt32 x = (PRInt32)LOWORD(lParam); // horizontal position in screen coordinates
|
|
|
|
PRInt32 y = (PRInt32)HIWORD(lParam); // vertical position in screen coordinates
|
|
|
|
result = OnMove(x, y);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-04-17 00:16:11 +00:00
|
|
|
|
1999-12-01 22:38:06 +00:00
|
|
|
case WM_CLOSE: // close request
|
|
|
|
DispatchStandardEvent(NS_XUL_CLOSE);
|
|
|
|
result = PR_TRUE; // abort window closure
|
|
|
|
break;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
// clean up.
|
|
|
|
OnDestroy();
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
result = OnPaint();
|
|
|
|
break;
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
case WM_SYSCHAR:
|
|
|
|
case WM_CHAR:
|
|
|
|
{
|
|
|
|
#ifdef KE_DEBUG
|
1999-10-14 21:49:49 +00:00
|
|
|
printf("%s\tchar=%c\twp=%4x\tlp=%8x\n", (msg == WM_SYSCHAR) ? "WM_SYSCHAR" : "WM_CHAR" , wParam, wParam, lParam);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#endif
|
1999-11-16 23:45:44 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
if(WM_SYSCHAR==msg)
|
|
|
|
{
|
|
|
|
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
} else { // WM_KEYUP
|
|
|
|
// If the Context Code bit is down and we got a WM_KEY
|
|
|
|
// it is a key press for character, not accelerator
|
|
|
|
// see p246 of Programming Windows 95 [Charles Petzold] for details
|
|
|
|
mIsControlDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
}
|
1999-06-04 05:14:01 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
unsigned char ch = (unsigned char)wParam;
|
|
|
|
UINT char_result;
|
|
|
|
|
|
|
|
//
|
|
|
|
// check first for backspace or return, handle them specially
|
|
|
|
//
|
|
|
|
if (ch==0x0d || ch==0x08) {
|
1999-06-04 05:14:01 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
result = OnChar(ch,ch==0x0d ? VK_RETURN : VK_BACK,true);
|
|
|
|
break;
|
1999-04-23 20:56:32 +00:00
|
|
|
}
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
char_result = ch;
|
|
|
|
result = OnChar(char_result,ch,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
1999-04-23 14:30:51 +00:00
|
|
|
case WM_SYSKEYUP:
|
1999-04-06 20:23:55 +00:00
|
|
|
case WM_KEYUP:
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#ifdef KE_DEBUG
|
|
|
|
printf("%s\t\twp=%x\tlp=%x\n",
|
|
|
|
(WM_KEYUP==msg)?"WM_KEYUP":"WM_SYSKEYUP" , wParam, lParam);
|
|
|
|
#endif
|
1998-09-02 21:14:45 +00:00
|
|
|
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
if(WM_SYSKEYUP==msg)
|
|
|
|
{
|
|
|
|
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
} else { // WM_KEYUP
|
|
|
|
// If the Context Code bit is down and we got a WM_KEY
|
|
|
|
// it is a key press for character, not accelerator
|
|
|
|
// see p246 of Programming Windows 95 [Charles Petzold] for details
|
|
|
|
mIsControlDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
}
|
1999-04-23 14:30:51 +00:00
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
// Note- The origional code pass (HIWORD(lParam)) to OnKeyUp as
|
|
|
|
// scan code. Howerver, this break Alt+Num pad input.
|
|
|
|
// http://msdn.microsoft.com/library/psdk/winui/keybinpt_8qp5.htm
|
|
|
|
// state the following-
|
|
|
|
// Typically, ToAscii performs the translation based on the
|
|
|
|
// virtual-key code. In some cases, however, bit 15 of the
|
|
|
|
// uScanCode parameter may be used to distinguish between a key
|
|
|
|
// press and a key release. The scan code is used for
|
|
|
|
// translating ALT+number key combinations.
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
if (!mIMEIsComposing)
|
1999-12-01 22:10:13 +00:00
|
|
|
result = OnKeyUp(wParam, (HIWORD(lParam) ));
|
1999-04-06 20:23:55 +00:00
|
|
|
else
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
|
1999-07-19 08:08:57 +00:00
|
|
|
// Let ths fall through if it isn't a key pad
|
|
|
|
case WM_SYSKEYDOWN:
|
1999-04-23 14:30:51 +00:00
|
|
|
case WM_KEYDOWN: {
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#ifdef KE_DEBUG
|
|
|
|
printf("%s\t\twp=%4x\tlp=%8x\n",
|
|
|
|
(WM_KEYDOWN==msg)?"WM_KEYDOWN":"WM_SYSKEYDOWN" , wParam, lParam);
|
|
|
|
#endif
|
1999-04-23 14:30:51 +00:00
|
|
|
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
if(WM_SYSKEYDOWN==msg)
|
|
|
|
{
|
|
|
|
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
} else { // WM_KEYUP
|
|
|
|
// If the Context Code bit is down and we got a WM_KEY
|
|
|
|
// If the Context Code bit is down and we got a WM_KEY
|
|
|
|
// it is a key press for character, not accelerator
|
|
|
|
// see p246 of Programming Windows 95 [Charles Petzold] for details
|
|
|
|
mIsControlDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = (0 == (KF_ALTDOWN & HIWORD(lParam)))&& IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
}
|
1999-12-01 22:10:13 +00:00
|
|
|
// Note- The origional code pass (HIWORD(lParam)) to OnKeyDown as
|
|
|
|
// scan code. Howerver, this break Alt+Num pad input.
|
|
|
|
// http://msdn.microsoft.com/library/psdk/winui/keybinpt_8qp5.htm
|
|
|
|
// state the following-
|
|
|
|
// Typically, ToAscii performs the translation based on the
|
|
|
|
// virtual-key code. In some cases, however, bit 15 of the
|
|
|
|
// uScanCode parameter may be used to distinguish between a key
|
|
|
|
// press and a key release. The scan code is used for
|
|
|
|
// translating ALT+number key combinations.
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
if (!mIMEIsComposing)
|
1999-12-01 22:10:13 +00:00
|
|
|
result = OnKeyDown(wParam, (HIWORD(lParam)));
|
2000-01-31 22:53:35 +00:00
|
|
|
else
|
|
|
|
result = PR_FALSE;
|
1999-04-06 20:23:55 +00:00
|
|
|
}
|
2000-02-11 23:35:14 +00:00
|
|
|
|
|
|
|
if (wParam == VK_MENU) {
|
|
|
|
// This is required to make XP menus work.
|
|
|
|
// Do not remove! Talk to me if you have
|
|
|
|
// questions. - hyatt@netscape.com
|
|
|
|
result = PR_TRUE;
|
|
|
|
*aRetValue = 0;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
1998-04-28 19:24:52 +00:00
|
|
|
// say we've dealt with erase background if widget does
|
|
|
|
// not need auto-erasing
|
1998-04-29 19:59:06 +00:00
|
|
|
case WM_ERASEBKGND:
|
1998-05-05 19:58:27 +00:00
|
|
|
if (! AutoErase()) {
|
1998-04-28 19:24:52 +00:00
|
|
|
*aRetValue = 1;
|
|
|
|
result = PR_TRUE;
|
1998-04-29 19:59:06 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
1998-05-04 19:25:25 +00:00
|
|
|
//RelayMouseEvent(msg,wParam, lParam);
|
1998-04-13 20:24:54 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_MOVE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
1999-05-04 22:38:45 +00:00
|
|
|
//SetFocus(); // this is bad
|
1998-05-04 19:25:25 +00:00
|
|
|
//RelayMouseEvent(msg,wParam, lParam);
|
1999-12-01 22:10:13 +00:00
|
|
|
{
|
1998-04-13 20:24:54 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_LEFT_BUTTON_DOWN);
|
1999-12-01 22:10:13 +00:00
|
|
|
} break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
1998-05-04 19:25:25 +00:00
|
|
|
//RelayMouseEvent(msg,wParam, lParam);
|
1998-04-13 20:24:54 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_LEFT_BUTTON_UP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDBLCLK:
|
1999-09-22 02:29:33 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_LEFT_DOUBLECLICK);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDOWN:
|
1999-12-01 22:10:13 +00:00
|
|
|
{
|
1998-04-13 20:24:54 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_MIDDLE_BUTTON_DOWN);
|
1999-12-01 22:10:13 +00:00
|
|
|
} break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_MIDDLE_BUTTON_UP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDBLCLK:
|
1998-04-29 19:59:06 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_MIDDLE_BUTTON_DOWN);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
1999-12-01 22:10:13 +00:00
|
|
|
{
|
1998-04-29 19:59:06 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_DOWN);
|
1999-12-01 22:10:13 +00:00
|
|
|
} break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_UP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDBLCLK:
|
1999-09-22 02:29:33 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_DOUBLECLICK);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_HSCROLL:
|
1999-03-05 15:34:53 +00:00
|
|
|
case WM_VSCROLL:
|
1998-04-13 20:24:54 +00:00
|
|
|
// check for the incoming nsWindow handle to be null in which case
|
|
|
|
// we assume the message is coming from a horizontal scrollbar inside
|
|
|
|
// a listbox and we don't bother processing it (well, we don't have to)
|
|
|
|
if (lParam) {
|
|
|
|
nsWindow* scrollbar = (nsWindow*)::GetWindowLong((HWND)lParam, GWL_USERDATA);
|
|
|
|
|
|
|
|
if (scrollbar) {
|
|
|
|
result = scrollbar->OnScroll(LOWORD(wParam), (short)HIWORD(wParam));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-08-03 22:28:00 +00:00
|
|
|
case WM_CTLCOLORLISTBOX:
|
1998-04-13 20:24:54 +00:00
|
|
|
case WM_CTLCOLOREDIT:
|
1998-07-21 18:04:18 +00:00
|
|
|
case WM_CTLCOLORBTN:
|
1999-01-20 15:42:51 +00:00
|
|
|
//case WM_CTLCOLORSCROLLBAR: //XXX causes a the scrollbar to be drawn incorrectly
|
1998-04-13 20:24:54 +00:00
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
if (lParam) {
|
|
|
|
nsWindow* control = (nsWindow*)::GetWindowLong((HWND)lParam, GWL_USERDATA);
|
|
|
|
if (control) {
|
1998-08-03 22:28:00 +00:00
|
|
|
control->SetUpForPaint((HDC)wParam);
|
1998-04-13 20:24:54 +00:00
|
|
|
*aRetValue = (LPARAM)control->OnControlColor();
|
1998-08-03 22:28:00 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
|
1999-11-13 05:16:33 +00:00
|
|
|
case WM_ACTIVATE:
|
|
|
|
if (mEventCallback) {
|
|
|
|
PRInt32 fActive = LOWORD(wParam);
|
|
|
|
|
|
|
|
if(WA_INACTIVE == fActive) {
|
2000-02-11 23:35:14 +00:00
|
|
|
gJustGotDeactivate = PR_TRUE;
|
1999-11-13 05:16:33 +00:00
|
|
|
} else {
|
2000-02-11 23:35:14 +00:00
|
|
|
gJustGotActivate = PR_TRUE;
|
1999-11-13 05:16:33 +00:00
|
|
|
nsMouseEvent event;
|
|
|
|
event.eventStructType = NS_GUI_EVENT;
|
|
|
|
InitEvent(event, NS_MOUSE_ACTIVATE);
|
|
|
|
|
2000-02-11 23:35:14 +00:00
|
|
|
event.acceptActivation = PR_TRUE;
|
1999-11-13 05:16:33 +00:00
|
|
|
|
2000-02-11 23:35:14 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
|
|
|
if(event.acceptActivation)
|
|
|
|
*aRetValue = MA_ACTIVATE;
|
|
|
|
else
|
|
|
|
*aRetValue = MA_NOACTIVATE;
|
1999-11-13 05:16:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-02-11 23:35:14 +00:00
|
|
|
case WM_SETFOCUS:
|
|
|
|
result = DispatchFocus(NS_GOTFOCUS);
|
|
|
|
if(gJustGotActivate) {
|
|
|
|
gJustGotActivate = PR_FALSE;
|
|
|
|
result = DispatchFocus(NS_ACTIVATE);
|
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-02-11 23:35:14 +00:00
|
|
|
case WM_KILLFOCUS:
|
|
|
|
result = DispatchFocus(NS_LOSTFOCUS);
|
|
|
|
if(gJustGotDeactivate) {
|
|
|
|
gJustGotDeactivate = PR_FALSE;
|
|
|
|
result = DispatchFocus(NS_DEACTIVATE);
|
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-02-11 23:35:14 +00:00
|
|
|
case WM_WINDOWPOSCHANGED:
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
WINDOWPOS *wp = (LPWINDOWPOS)lParam;
|
1998-06-02 02:33:29 +00:00
|
|
|
|
|
|
|
// We only care about a resize, so filter out things like z-order
|
|
|
|
// changes. Note: there's a WM_MOVE handler above which is why we're
|
|
|
|
// not handling them here...
|
|
|
|
if (0 == (wp->flags & SWP_NOSIZE)) {
|
|
|
|
// XXX Why are we using the client size area? If the size notification
|
|
|
|
// is for the client area then the origin should be (0,0) and not
|
|
|
|
// the window origin in screen coordinates...
|
|
|
|
RECT r;
|
1998-11-04 21:43:47 +00:00
|
|
|
::GetWindowRect(mWnd, &r);
|
1998-06-19 02:46:25 +00:00
|
|
|
PRInt32 newWidth, newHeight;
|
|
|
|
newWidth = PRInt32(r.right - r.left);
|
|
|
|
newHeight = PRInt32(r.bottom - r.top);
|
|
|
|
nsRect rect(wp->x, wp->y, newWidth, newHeight);
|
1998-11-24 14:57:09 +00:00
|
|
|
//if (newWidth != mBounds.width)
|
1998-06-19 02:46:25 +00:00
|
|
|
{
|
|
|
|
RECT drect;
|
|
|
|
|
|
|
|
//getting wider
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
drect.left = wp->x + mBounds.width;
|
1998-06-19 02:46:25 +00:00
|
|
|
drect.top = wp->y;
|
1998-11-24 14:57:09 +00:00
|
|
|
drect.right = drect.left + (newWidth - mBounds.width);
|
1998-06-19 02:46:25 +00:00
|
|
|
drect.bottom = drect.top + newHeight;
|
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
// ::InvalidateRect(mWnd, NULL, FALSE);
|
1998-06-19 02:46:25 +00:00
|
|
|
// ::InvalidateRect(mWnd, &drect, FALSE);
|
|
|
|
::RedrawWindow(mWnd, &drect, NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
|
|
|
|
}
|
1998-11-24 14:57:09 +00:00
|
|
|
//if (newHeight != mBounds.height)
|
1998-06-19 02:46:25 +00:00
|
|
|
{
|
|
|
|
RECT drect;
|
|
|
|
|
|
|
|
//getting taller
|
|
|
|
|
|
|
|
drect.left = wp->x;
|
1998-11-24 14:57:09 +00:00
|
|
|
drect.top = wp->y + mBounds.height;
|
1998-06-19 02:46:25 +00:00
|
|
|
drect.right = drect.left + newWidth;
|
1998-11-24 14:57:09 +00:00
|
|
|
drect.bottom = drect.top + (newHeight - mBounds.height);
|
1998-06-19 02:46:25 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
// ::InvalidateRect(mWnd, NULL, FALSE);
|
1998-06-19 02:46:25 +00:00
|
|
|
// ::InvalidateRect(mWnd, &drect, FALSE);
|
|
|
|
::RedrawWindow(mWnd, &drect, NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
|
|
|
|
}
|
1998-11-24 14:57:09 +00:00
|
|
|
mBounds.width = newWidth;
|
|
|
|
mBounds.height = newHeight;
|
1998-06-02 02:33:29 +00:00
|
|
|
///nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
|
1998-11-04 21:43:47 +00:00
|
|
|
|
|
|
|
// recalculate the width and height
|
|
|
|
// this time based on the client area
|
|
|
|
if (::GetClientRect(mWnd, &r)) {
|
|
|
|
rect.width = PRInt32(r.right - r.left);
|
|
|
|
rect.height = PRInt32(r.bottom - r.top);
|
|
|
|
}
|
1998-06-02 02:33:29 +00:00
|
|
|
result = OnResize(rect);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-03-05 15:34:53 +00:00
|
|
|
|
|
|
|
case WM_SETTINGCHANGE:
|
|
|
|
firstTime = TRUE;
|
|
|
|
// Fall through
|
1999-11-29 21:14:43 +00:00
|
|
|
|
1999-09-28 01:31:41 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
{
|
1999-03-05 15:34:53 +00:00
|
|
|
if (firstTime) {
|
|
|
|
firstTime = FALSE;
|
|
|
|
SystemParametersInfo (104, 0, &ulScrollLines, 0) ;
|
|
|
|
|
|
|
|
// ulScrollLines usually equals 3 or 0 (for no scrolling)
|
|
|
|
// WHEEL_DELTA equals 120, so iDeltaPerLine will be 40
|
|
|
|
|
|
|
|
if (ulScrollLines)
|
|
|
|
iDeltaPerLine = WHEEL_DELTA / ulScrollLines ;
|
|
|
|
else
|
|
|
|
iDeltaPerLine = 0 ;
|
|
|
|
|
|
|
|
if (msg == WM_SETTINGCHANGE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
1999-11-29 21:14:43 +00:00
|
|
|
if (iDeltaPerLine == 0)
|
|
|
|
return 0;
|
2000-02-25 01:52:08 +00:00
|
|
|
|
|
|
|
// The mousewheel event will be dispatched to the toplevel
|
|
|
|
// window. We need to give it to the child window
|
|
|
|
|
|
|
|
POINT point;
|
|
|
|
point.x = (short) LOWORD(lParam);
|
|
|
|
point.y = (short) HIWORD(lParam);
|
|
|
|
HWND destWnd = ::WindowFromPoint(point);
|
|
|
|
|
|
|
|
if (destWnd != mWnd) {
|
|
|
|
nsWindow* destWindow = (nsWindow*) ::GetWindowLong(destWnd, GWL_USERDATA);
|
|
|
|
if (destWindow)
|
|
|
|
return destWindow->ProcessMessage(msg, wParam, lParam, aRetValue);
|
|
|
|
#ifdef DEBUG
|
|
|
|
else
|
|
|
|
printf("WARNING: couldn't get child window for MW event\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-11-29 21:14:43 +00:00
|
|
|
nsMouseScrollEvent scrollEvent;
|
|
|
|
scrollEvent.deltaLines = -((short) HIWORD (wParam) / iDeltaPerLine);
|
|
|
|
scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT;
|
|
|
|
scrollEvent.isShift = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
scrollEvent.isControl = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
scrollEvent.isMeta = PR_FALSE;
|
|
|
|
scrollEvent.isAlt = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
InitEvent(scrollEvent, NS_MOUSE_SCROLL);
|
|
|
|
if (nsnull != mEventCallback)
|
|
|
|
result = DispatchWindowEvent(&scrollEvent);
|
1999-12-21 19:32:43 +00:00
|
|
|
NS_RELEASE(scrollEvent.widget);
|
1999-11-29 21:14:43 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-19 00:57:02 +00:00
|
|
|
case WM_PALETTECHANGED:
|
|
|
|
if ((HWND)wParam == mWnd) {
|
|
|
|
// We caused the WM_PALETTECHANGED message so avoid realizing
|
|
|
|
// another foreground palette
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-19 00:57:02 +00:00
|
|
|
// fall thru...
|
|
|
|
|
2000-02-11 14:35:01 +00:00
|
|
|
case WM_QUERYNEWPALETTE: // this window is about to become active
|
1998-08-19 00:57:02 +00:00
|
|
|
mContext->GetPaletteInfo(palInfo);
|
|
|
|
if (palInfo.isPaletteDevice && palInfo.palette) {
|
1998-04-13 20:24:54 +00:00
|
|
|
HDC hDC = ::GetDC(mWnd);
|
1999-09-10 14:24:20 +00:00
|
|
|
HPALETTE hOldPal = ::SelectPalette(hDC, (HPALETTE)palInfo.palette, TRUE);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-19 00:57:02 +00:00
|
|
|
// Realize the drawing palette
|
1998-04-13 20:24:54 +00:00
|
|
|
int i = ::RealizePalette(hDC);
|
|
|
|
|
2000-02-11 14:35:01 +00:00
|
|
|
//printf("number of colors that changed=%d\n",i);
|
|
|
|
|
|
|
|
// we should always invalidate.. because the lookup may have changed
|
|
|
|
::InvalidateRect(mWnd, (LPRECT)NULL, TRUE);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
::ReleaseDC(mWnd, hDC);
|
1998-08-19 02:31:08 +00:00
|
|
|
*aRetValue = TRUE;
|
1998-08-19 00:57:02 +00:00
|
|
|
}
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
1999-03-09 23:48:58 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_INPUTLANGCHANGEREQUEST:
|
|
|
|
*aRetValue = TRUE;
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
1999-08-24 21:46:43 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_INPUTLANGCHANGE:
|
1999-12-01 22:10:13 +00:00
|
|
|
result = OnInputLangChange((HKL)lParam,
|
1999-11-11 22:28:52 +00:00
|
|
|
aRetValue);
|
|
|
|
break;
|
1999-08-24 21:46:43 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_STARTCOMPOSITION:
|
|
|
|
result = OnIMEStartComposition();
|
|
|
|
break;
|
1999-10-27 00:14:46 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_COMPOSITION:
|
|
|
|
result = OnIMEComposition(lParam);
|
|
|
|
break;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_ENDCOMPOSITION:
|
|
|
|
result = OnIMEEndComposition();
|
|
|
|
break;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_CHAR:
|
|
|
|
result = OnIMEChar((BYTE)(wParam>>8),
|
|
|
|
(BYTE) (wParam & 0x00FF),
|
|
|
|
lParam);
|
|
|
|
break;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_NOTIFY:
|
|
|
|
result = OnIMENotify(wParam, lParam, aRetValue);
|
|
|
|
break;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
#if 0
|
|
|
|
// This is a Window 98/2000 only message
|
|
|
|
case WM_IME_REQUEST:
|
|
|
|
result = OnIMERequest(wParam, lParam, aRetValue);
|
|
|
|
break;
|
1999-10-27 00:14:46 +00:00
|
|
|
#endif
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_SELECT:
|
|
|
|
result = OnIMESelect(wParam, (WORD)(lParam & 0x0FFFF));
|
|
|
|
break;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
case WM_IME_SETCONTEXT:
|
|
|
|
result = OnIMESetContext(wParam, lParam);
|
|
|
|
break;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
case WM_DROPFILES: {
|
1999-04-06 20:23:55 +00:00
|
|
|
/*HDROP hDropInfo = (HDROP) wParam;
|
1999-03-09 23:48:58 +00:00
|
|
|
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
|
|
|
|
|
|
|
|
for (UINT iFile = 0; iFile < nFiles; iFile++) {
|
|
|
|
TCHAR szFileName[_MAX_PATH];
|
|
|
|
::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
|
|
|
|
printf("szFileName [%s]\n", szFileName);
|
|
|
|
nsAutoString fileStr(szFileName);
|
|
|
|
nsEventStatus status;
|
|
|
|
nsDragDropEvent event;
|
|
|
|
InitEvent(event, NS_DRAGDROP_EVENT);
|
|
|
|
event.mType = nsDragDropEventStatus_eDrop;
|
|
|
|
event.mIsFileURL = PR_FALSE;
|
|
|
|
event.mURL = (PRUnichar *)fileStr.GetUnicode();
|
|
|
|
DispatchEvent(&event, status);
|
1999-04-06 20:23:55 +00:00
|
|
|
}*/
|
1999-03-09 23:48:58 +00:00
|
|
|
} break;
|
1999-03-23 21:26:20 +00:00
|
|
|
|
|
|
|
case WM_DESTROYCLIPBOARD: {
|
|
|
|
nsIClipboard* clipboard;
|
|
|
|
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
|
2000-02-04 00:39:15 +00:00
|
|
|
NS_GET_IID(nsIClipboard),
|
1999-03-23 21:26:20 +00:00
|
|
|
(nsISupports **)&clipboard);
|
|
|
|
clipboard->EmptyClipboard();
|
1999-04-23 14:30:51 +00:00
|
|
|
nsServiceManager::ReleaseService(kCClipboardCID, clipboard);
|
1999-03-23 21:26:20 +00:00
|
|
|
} break;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-07-09 21:08:09 +00:00
|
|
|
//*aRetValue = result;
|
1999-07-12 22:28:19 +00:00
|
|
|
if (mWnd) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//Events which caused mWnd destruction and aren't consumed
|
|
|
|
//will crash during the Windows default processing.
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return the window class name and initialize the class if needed
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
LPCTSTR nsWindow::WindowClass()
|
|
|
|
{
|
1998-05-05 19:58:27 +00:00
|
|
|
const LPCTSTR className = "NetscapeWindowClass";
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (!nsWindow::sIsRegistered) {
|
|
|
|
WNDCLASS wc;
|
|
|
|
|
1998-06-19 02:46:25 +00:00
|
|
|
// wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
1998-06-02 05:27:08 +00:00
|
|
|
wc.style = CS_DBLCLKS;
|
2000-01-07 00:34:34 +00:00
|
|
|
#ifdef MOZ_AIMM
|
|
|
|
wc.lpfnWndProc = nsWindow::DefaultWindowProc;
|
|
|
|
#else
|
1998-04-13 20:24:54 +00:00
|
|
|
wc.lpfnWndProc = ::DefWindowProc;
|
2000-01-07 00:34:34 +00:00
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = nsToolkit::mDllInstance;
|
2000-02-25 02:25:00 +00:00
|
|
|
wc.hIcon = ::LoadIcon(::GetModuleHandle(NULL), IDI_APPLICATION);
|
1998-04-13 20:24:54 +00:00
|
|
|
wc.hCursor = NULL;
|
1998-07-21 18:04:18 +00:00
|
|
|
wc.hbrBackground = mBrush;
|
1998-04-13 20:24:54 +00:00
|
|
|
wc.lpszMenuName = NULL;
|
1998-05-05 19:58:27 +00:00
|
|
|
wc.lpszClassName = className;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
nsWindow::sIsRegistered = ::RegisterClass(&wc);
|
2000-01-07 00:34:34 +00:00
|
|
|
#ifdef MOZ_AIMM
|
|
|
|
// Call FilterClientWindows method since it enables ActiveIME on CJK Windows
|
|
|
|
if(nsToolkit::gAIMMApp)
|
|
|
|
nsToolkit::gAIMMApp->FilterClientWindows((ATOM*)&nsWindow::sIsRegistered,1);
|
|
|
|
#endif // MOZ_AIMM
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-05-05 19:58:27 +00:00
|
|
|
return className;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return nsWindow styles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD nsWindow::WindowStyle()
|
|
|
|
{
|
1998-04-18 00:27:48 +00:00
|
|
|
return WS_OVERLAPPEDWINDOW;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return nsWindow extended styles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD nsWindow::WindowExStyle()
|
|
|
|
{
|
1999-10-11 23:56:55 +00:00
|
|
|
return WS_EX_WINDOWEDGE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Subclass (or remove the subclass from) this component's nsWindow
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void nsWindow::SubclassWindow(BOOL bState)
|
|
|
|
{
|
1998-09-15 03:45:06 +00:00
|
|
|
if (NULL != mWnd) {
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_PRECONDITION(::IsWindow(mWnd), "Invalid window handle");
|
|
|
|
|
|
|
|
if (bState) {
|
|
|
|
// change the nsWindow proc
|
|
|
|
mPrevWndProc = (WNDPROC)::SetWindowLong(mWnd, GWL_WNDPROC,
|
|
|
|
(LONG)nsWindow::WindowProc);
|
|
|
|
NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
|
|
|
|
// connect the this pointer to the nsWindow handle
|
|
|
|
::SetWindowLong(mWnd, GWL_USERDATA, (LONG)this);
|
|
|
|
}
|
|
|
|
else {
|
1998-08-18 22:03:34 +00:00
|
|
|
::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
|
|
|
|
::SetWindowLong(mWnd, GWL_USERDATA, (LONG)NULL);
|
1998-04-13 20:24:54 +00:00
|
|
|
mPrevWndProc = NULL;
|
|
|
|
}
|
1998-09-15 03:45:06 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// WM_DESTROY has been called
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::OnDestroy()
|
|
|
|
{
|
1998-09-15 03:45:06 +00:00
|
|
|
mOnDestroyCalled = PR_TRUE;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
SubclassWindow(FALSE);
|
1998-08-18 22:03:34 +00:00
|
|
|
mWnd = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-06 05:06:24 +00:00
|
|
|
// free GDI objects
|
|
|
|
if (mBrush) {
|
1998-08-09 01:37:30 +00:00
|
|
|
VERIFY(::DeleteObject(mBrush));
|
|
|
|
mBrush = NULL;
|
|
|
|
}
|
|
|
|
if (mPalette) {
|
|
|
|
VERIFY(::DeleteObject(mPalette));
|
|
|
|
mPalette = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we were in the middle of deferred window positioning then
|
|
|
|
// free the memory for the multiple-window position structure
|
|
|
|
if (mDeferredPositioner) {
|
|
|
|
VERIFY(::EndDeferWindowPos(mDeferredPositioner));
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// release references to children, device context, toolkit, and app shell
|
1998-09-23 19:19:23 +00:00
|
|
|
nsBaseWidget::OnDestroy();
|
|
|
|
|
1998-08-06 05:06:24 +00:00
|
|
|
// dispatch the event
|
1998-08-06 02:11:43 +00:00
|
|
|
if (!mIsDestroying) {
|
1998-08-06 05:06:24 +00:00
|
|
|
// dispatching of the event may cause the reference count to drop to 0
|
1998-08-06 02:11:43 +00:00
|
|
|
// and result in this object being destroyed. To avoid that, add a reference
|
|
|
|
// and then release it after dispatching the event
|
|
|
|
AddRef();
|
|
|
|
DispatchStandardEvent(NS_DESTROY);
|
|
|
|
Release();
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Move
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnMove(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
nsGUIEvent event;
|
|
|
|
InitEvent(event, NS_MOVE);
|
|
|
|
event.point.x = aX;
|
|
|
|
event.point.y = aY;
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_GUI_EVENT;
|
1998-10-08 00:04:21 +00:00
|
|
|
|
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
1998-05-29 22:44:13 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Paint
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnPaint()
|
|
|
|
{
|
|
|
|
nsRect bounds;
|
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
PAINTSTRUCT ps;
|
1999-11-12 02:06:52 +00:00
|
|
|
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
1998-12-15 05:44:21 +00:00
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
HRGN debugPaintFlashRegion = NULL;
|
|
|
|
HDC debugPaintFlashDC = NULL;
|
1998-12-15 05:44:21 +00:00
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
if (debug_WantPaintFlashing())
|
|
|
|
{
|
|
|
|
debugPaintFlashRegion = ::CreateRectRgn(0, 0, 0, 0);
|
|
|
|
::GetUpdateRgn(mWnd, debugPaintFlashRegion, TRUE);
|
|
|
|
debugPaintFlashDC = ::GetDC(mWnd);
|
|
|
|
}
|
|
|
|
#endif // NS_DEBUG
|
1998-12-15 05:44:21 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
HDC hDC = ::BeginPaint(mWnd, &ps);
|
|
|
|
|
1998-08-19 05:06:59 +00:00
|
|
|
// XXX What is this check doing? If it's trying to check for an empty
|
|
|
|
// paint rect then use the IsRectEmpty() function...
|
1998-04-13 20:24:54 +00:00
|
|
|
if (ps.rcPaint.left || ps.rcPaint.right || ps.rcPaint.top || ps.rcPaint.bottom) {
|
|
|
|
// call the event callback
|
1999-09-09 03:47:26 +00:00
|
|
|
if (mEventCallback)
|
|
|
|
{
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
nsPaintEvent event;
|
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
InitEvent(event, NS_PAINT);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
nsRect rect(ps.rcPaint.left,
|
|
|
|
ps.rcPaint.top,
|
|
|
|
ps.rcPaint.right - ps.rcPaint.left,
|
|
|
|
ps.rcPaint.bottom - ps.rcPaint.top);
|
|
|
|
event.rect = ▭
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_PAINT_EVENT;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
debug_DumpPaintEvent(stdout,
|
|
|
|
this,
|
|
|
|
&event,
|
|
|
|
"noname",
|
|
|
|
(PRInt32) mWnd);
|
|
|
|
#endif // NS_DEBUG
|
1998-12-15 05:44:21 +00:00
|
|
|
|
1999-07-09 19:41:46 +00:00
|
|
|
if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID,
|
|
|
|
nsnull,
|
2000-02-04 00:39:15 +00:00
|
|
|
NS_GET_IID(nsIRenderingContext),
|
1999-07-09 19:41:46 +00:00
|
|
|
(void **)&event.renderingContext))
|
1998-12-15 05:44:21 +00:00
|
|
|
{
|
|
|
|
nsIRenderingContextWin *winrc;
|
|
|
|
|
2000-02-04 00:39:15 +00:00
|
|
|
if (NS_OK == event.renderingContext->QueryInterface(NS_GET_IID(nsIRenderingContextWin), (void **)&winrc))
|
1998-12-15 05:44:21 +00:00
|
|
|
{
|
|
|
|
nsDrawingSurface surf;
|
|
|
|
|
|
|
|
//i know all of this seems a little backwards. i'll fix it, i swear. MMP
|
|
|
|
|
|
|
|
if (NS_OK == winrc->CreateDrawingSurface(hDC, surf))
|
|
|
|
{
|
|
|
|
event.renderingContext->Init(mContext, surf);
|
1999-11-12 02:06:52 +00:00
|
|
|
result = DispatchWindowEvent(&event, eventStatus);
|
1998-12-15 05:44:21 +00:00
|
|
|
event.renderingContext->DestroyDrawingSurface(surf);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(winrc);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
NS_RELEASE(event.renderingContext);
|
1998-10-08 00:04:21 +00:00
|
|
|
}
|
1998-12-15 05:44:21 +00:00
|
|
|
else
|
|
|
|
result = PR_FALSE;
|
1998-10-08 00:04:21 +00:00
|
|
|
|
1998-12-15 05:44:21 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-15 05:44:21 +00:00
|
|
|
::EndPaint(mWnd, &ps);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
if (debug_WantPaintFlashing())
|
|
|
|
{
|
1999-11-12 02:06:52 +00:00
|
|
|
// Only flash paint events which have not ignored the paint message.
|
|
|
|
// Those that ignore the paint message aren't painting anything so there
|
|
|
|
// is only the overhead of the dispatching the paint event.
|
|
|
|
if (nsEventStatus_eIgnore != eventStatus) {
|
|
|
|
::InvertRgn(debugPaintFlashDC, debugPaintFlashRegion);
|
|
|
|
int x;
|
|
|
|
for (x = 0; x < 1000000; x++);
|
|
|
|
::InvertRgn(debugPaintFlashDC, debugPaintFlashRegion);
|
|
|
|
for (x = 0; x < 1000000; x++);
|
|
|
|
}
|
1999-09-09 03:47:26 +00:00
|
|
|
::ReleaseDC(mWnd, debugPaintFlashDC);
|
|
|
|
::DeleteObject(debugPaintFlashRegion);
|
|
|
|
}
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Send a resize message to the listener
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
|
|
|
{
|
1998-10-07 22:11:37 +00:00
|
|
|
// call the event callback
|
|
|
|
if (mEventCallback) {
|
|
|
|
nsSizeEvent event;
|
|
|
|
InitEvent(event, NS_SIZE);
|
|
|
|
event.windowSize = &aWindowRect;
|
|
|
|
event.eventStructType = NS_SIZE_EVENT;
|
1998-11-04 21:43:47 +00:00
|
|
|
RECT r;
|
|
|
|
if (::GetWindowRect(mWnd, &r)) {
|
|
|
|
event.mWinWidth = PRInt32(r.right - r.left);
|
|
|
|
event.mWinHeight = PRInt32(r.bottom - r.top);
|
|
|
|
} else {
|
|
|
|
event.mWinWidth = 0;
|
|
|
|
event.mWinHeight = 0;
|
|
|
|
}
|
1998-10-08 00:04:21 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
1998-10-07 22:11:37 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
return PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-17 00:16:11 +00:00
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with all sort of mouse event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-05-29 22:44:13 +00:00
|
|
|
PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, nsPoint* aPoint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull == mEventCallback && nsnull == mMouseListener) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-05-08 14:54:09 +00:00
|
|
|
nsMouseEvent event;
|
1998-05-29 22:44:13 +00:00
|
|
|
InitEvent(event, aEventType, aPoint);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-03 22:36:34 +00:00
|
|
|
event.isShift = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
event.isControl = IS_VK_DOWN(NS_VK_CONTROL);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
event.isMeta = PR_FALSE;
|
1999-02-03 22:36:34 +00:00
|
|
|
event.isAlt = IS_VK_DOWN(NS_VK_ALT);
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_MOUSE_EVENT;
|
1998-05-08 14:54:09 +00:00
|
|
|
|
1999-09-22 02:29:33 +00:00
|
|
|
//Dblclicks are used to set the click count, then changed to mousedowns
|
|
|
|
if (aEventType == NS_MOUSE_LEFT_DOUBLECLICK ||
|
|
|
|
aEventType == NS_MOUSE_RIGHT_DOUBLECLICK) {
|
|
|
|
event.message = (aEventType == NS_MOUSE_LEFT_DOUBLECLICK) ?
|
|
|
|
NS_MOUSE_LEFT_BUTTON_DOWN : NS_MOUSE_RIGHT_BUTTON_DOWN;
|
|
|
|
event.clickCount = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
event.clickCount = 1;
|
|
|
|
}
|
1999-06-25 21:17:52 +00:00
|
|
|
|
|
|
|
nsPluginEvent pluginEvent;
|
|
|
|
|
|
|
|
switch (aEventType)//~~~
|
|
|
|
{
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
|
|
|
pluginEvent.event = WM_LBUTTONDOWN;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
pluginEvent.event = WM_LBUTTONUP;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_LEFT_DOUBLECLICK:
|
|
|
|
pluginEvent.event = WM_LBUTTONDBLCLK;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
|
|
|
pluginEvent.event = WM_RBUTTONDOWN;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_UP:
|
|
|
|
pluginEvent.event = WM_RBUTTONUP;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_RIGHT_DOUBLECLICK:
|
|
|
|
pluginEvent.event = WM_RBUTTONDBLCLK;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
|
|
|
pluginEvent.event = WM_MBUTTONDOWN;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
|
|
|
pluginEvent.event = WM_MBUTTONUP;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_MIDDLE_DOUBLECLICK:
|
|
|
|
pluginEvent.event = WM_MBUTTONDBLCLK;
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
pluginEvent.event = WM_MOUSEMOVE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginEvent.wParam = 0;
|
|
|
|
pluginEvent.wParam |= (event.isShift) ? MK_SHIFT : 0;
|
|
|
|
pluginEvent.wParam |= (event.isControl) ? MK_CONTROL : 0;
|
|
|
|
pluginEvent.lParam = MAKELONG(event.point.x, event.point.y);
|
|
|
|
|
|
|
|
event.nativeMsg = (void *)&pluginEvent;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// call the event callback
|
|
|
|
if (nsnull != mEventCallback) {
|
1998-04-24 23:09:11 +00:00
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
result = DispatchWindowEvent(&event);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
if (aEventType == NS_MOUSE_MOVE) {
|
|
|
|
|
1999-08-05 14:56:21 +00:00
|
|
|
// if we are not in mouse cpature mode (mouse down and hold)
|
|
|
|
// then use "this" window
|
|
|
|
// if we are in mouse capture, then all events are being directed
|
|
|
|
// back to the nsWindow doing the capture. So therefore, the detection
|
|
|
|
// of whether we are in a new nsWindow is wrong. Meaning this MOUSE_MOVE
|
|
|
|
// event hold the captured windows pointer not the one the mouse is over.
|
|
|
|
//
|
|
|
|
// So we use "WindowFromPoint" to find what window we are over and
|
|
|
|
// set that window into the mouse trailer timer.
|
|
|
|
if (!mIsInMouseCapture) {
|
|
|
|
MouseTrailer * mouseTrailer = MouseTrailer::GetMouseTrailer(0);
|
|
|
|
MouseTrailer::SetMouseTrailerWindow(this);
|
|
|
|
mouseTrailer->CreateTimer();
|
|
|
|
} else {
|
|
|
|
POINT mp;
|
|
|
|
DWORD pos = ::GetMessagePos();
|
1999-09-09 13:38:30 +00:00
|
|
|
mp.x = LOWORD(pos);
|
|
|
|
mp.y = HIWORD(pos);
|
|
|
|
|
|
|
|
// OK, now find out if we are still inside
|
|
|
|
// the captured native window
|
|
|
|
POINT cpos;
|
|
|
|
cpos.x = LOWORD(pos);
|
|
|
|
cpos.y = HIWORD(pos);
|
|
|
|
|
|
|
|
nsWindow * someWindow = NULL;
|
|
|
|
HWND hWnd = ::WindowFromPoint(mp);
|
|
|
|
if (hWnd != NULL) {
|
|
|
|
::ScreenToClient(hWnd, &cpos);
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetWindowRect(hWnd, &r));
|
|
|
|
if (cpos.x >= r.left && cpos.x <= r.right &&
|
|
|
|
cpos.y >= r.top && cpos.y <= r.bottom) {
|
|
|
|
// yes we are so we should be able to get a valid window
|
|
|
|
// although, strangley enough when we are on the frame part of the
|
|
|
|
// window we get right here when in capture mode
|
|
|
|
// but this window won't match the capture mode window so
|
|
|
|
// we are ok
|
|
|
|
someWindow = (nsWindow*)::GetWindowLong(hWnd, GWL_USERDATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// only set the window into the mouse trailer if we have a good window
|
1999-08-05 14:56:21 +00:00
|
|
|
if (nsnull != someWindow) {
|
|
|
|
MouseTrailer * mouseTrailer = MouseTrailer::GetMouseTrailer(0);
|
|
|
|
MouseTrailer::SetMouseTrailerWindow(someWindow);
|
|
|
|
mouseTrailer->CreateTimer();
|
|
|
|
}
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
nsRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
|
|
|
|
if (rect.Contains(event.point.x, event.point.y)) {
|
1998-05-29 22:44:13 +00:00
|
|
|
if (gCurrentWindow == NULL || gCurrentWindow != this) {
|
|
|
|
if ((nsnull != gCurrentWindow) && (!gCurrentWindow->mIsDestroying)) {
|
|
|
|
MouseTrailer::IgnoreNextCycle();
|
|
|
|
gCurrentWindow->DispatchMouseEvent(NS_MOUSE_EXIT, gCurrentWindow->GetLastPoint());
|
|
|
|
}
|
|
|
|
gCurrentWindow = this;
|
|
|
|
if (!mIsDestroying) {
|
|
|
|
gCurrentWindow->DispatchMouseEvent(NS_MOUSE_ENTER);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (aEventType == NS_MOUSE_EXIT) {
|
1998-05-29 22:44:13 +00:00
|
|
|
if (gCurrentWindow == this) {
|
|
|
|
gCurrentWindow = nsnull;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
1998-10-08 00:04:21 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1998-04-13 20:24:54 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mMouseListener) {
|
|
|
|
switch (aEventType) {
|
|
|
|
case NS_MOUSE_MOVE: {
|
|
|
|
result = ConvertStatus(mMouseListener->MouseMoved(event));
|
|
|
|
nsRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
if (rect.Contains(event.point.x, event.point.y)) {
|
1998-05-29 22:44:13 +00:00
|
|
|
if (gCurrentWindow == NULL || gCurrentWindow != this) {
|
|
|
|
gCurrentWindow = this;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
} else {
|
1998-07-21 18:04:18 +00:00
|
|
|
//printf("Mouse exit");
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
|
|
|
result = ConvertStatus(mMouseListener->MousePressed(event));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_UP:
|
|
|
|
result = ConvertStatus(mMouseListener->MouseReleased(event));
|
|
|
|
result = ConvertStatus(mMouseListener->MouseClicked(event));
|
|
|
|
break;
|
|
|
|
} // switch
|
|
|
|
}
|
1998-10-08 00:04:21 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1998-04-13 20:24:54 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with focus messages
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::DispatchFocus(PRUint32 aEventType)
|
|
|
|
{
|
1999-07-27 20:50:05 +00:00
|
|
|
// call the event callback
|
|
|
|
if (mEventCallback) {
|
|
|
|
nsGUIEvent event;
|
|
|
|
event.eventStructType = NS_GUI_EVENT;
|
|
|
|
InitEvent(event, aEventType);
|
|
|
|
|
|
|
|
//focus and blur event should go to their base widget loc, not current mouse pos
|
|
|
|
event.point.x = 0;
|
|
|
|
event.point.y = 0;
|
|
|
|
|
|
|
|
nsPluginEvent pluginEvent;
|
|
|
|
|
|
|
|
switch (aEventType)//~~~
|
|
|
|
{
|
|
|
|
case NS_GOTFOCUS:
|
|
|
|
pluginEvent.event = WM_SETFOCUS;
|
|
|
|
break;
|
|
|
|
case NS_LOSTFOCUS:
|
|
|
|
pluginEvent.event = WM_KILLFOCUS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-07-27 20:50:05 +00:00
|
|
|
event.nativeMsg = (void *)&pluginEvent;
|
|
|
|
|
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with scrollbar messages (actually implemented only in nsScrollbar)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnScroll(UINT scrollCode, int cPos)
|
|
|
|
{
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return the brush used to paint the background of this control
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
HBRUSH nsWindow::OnControlColor()
|
|
|
|
{
|
|
|
|
return mBrush;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return the style for a child nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD ChildWindow::WindowStyle()
|
|
|
|
{
|
1999-07-27 04:27:17 +00:00
|
|
|
// return WS_CHILD | WS_CLIPCHILDREN | GetBorderStyle(mBorderStyle);
|
|
|
|
return WS_CHILD | WS_CLIPCHILDREN | GetWindowType(mWindowType);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-07-21 18:04:18 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with all sort of mouse event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool ChildWindow::DispatchMouseEvent(PRUint32 aEventType, nsPoint* aPoint)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull == mEventCallback && nsnull == mMouseListener) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aEventType) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
1999-08-05 14:56:21 +00:00
|
|
|
CaptureMouse(PR_TRUE);
|
1998-07-21 18:04:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_UP:
|
1999-08-05 14:56:21 +00:00
|
|
|
CaptureMouse(PR_FALSE);
|
1998-07-21 18:04:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
} // switch
|
|
|
|
|
|
|
|
return nsWindow::DispatchMouseEvent(aEventType, aPoint);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-27 04:27:17 +00:00
|
|
|
DWORD nsWindow::GetWindowType(nsWindowType aWindowType)
|
|
|
|
{
|
|
|
|
switch(aWindowType)
|
|
|
|
{
|
|
|
|
case eWindowType_child:
|
|
|
|
return(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eWindowType_dialog:
|
|
|
|
return(WS_DLGFRAME | DS_3DLOOK);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eWindowType_popup:
|
|
|
|
return(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eWindowType_toplevel:
|
|
|
|
return(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "unknown border style");
|
|
|
|
return(WS_OVERLAPPEDWINDOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-17 23:45:07 +00:00
|
|
|
DWORD nsWindow::GetBorderStyle(nsBorderStyle aBorderStyle)
|
|
|
|
{
|
1999-07-27 04:56:48 +00:00
|
|
|
return 0;
|
1999-07-27 04:27:17 +00:00
|
|
|
/*
|
1998-04-17 23:45:07 +00:00
|
|
|
switch(aBorderStyle)
|
|
|
|
{
|
1998-04-18 00:27:48 +00:00
|
|
|
case eBorderStyle_none:
|
|
|
|
return(0);
|
1998-04-17 23:45:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eBorderStyle_dialog:
|
1998-04-18 00:27:48 +00:00
|
|
|
return(WS_DLGFRAME | DS_3DLOOK);
|
1998-04-17 23:45:07 +00:00
|
|
|
break;
|
|
|
|
|
1999-05-27 21:09:49 +00:00
|
|
|
case eBorderStyle_BorderlessTopLevel:
|
|
|
|
return(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eBorderStyle_window:
|
|
|
|
return(0);
|
|
|
|
break;
|
|
|
|
|
1998-04-17 23:45:07 +00:00
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "unknown border style");
|
|
|
|
return(WS_OVERLAPPEDWINDOW);
|
|
|
|
}
|
1999-07-27 04:27:17 +00:00
|
|
|
*/
|
1998-04-17 23:45:07 +00:00
|
|
|
}
|
|
|
|
|
2000-01-31 22:53:35 +00:00
|
|
|
static char* GetACPString(const nsString& aStr)
|
|
|
|
{
|
|
|
|
int acplen = aStr.Length() * 2 + 1;
|
|
|
|
char * acp = new char[acplen];
|
|
|
|
if(acp)
|
|
|
|
{
|
|
|
|
int outlen = ::WideCharToMultiByte( CP_ACP, 0,
|
|
|
|
aStr.GetUnicode(), aStr.Length(),
|
|
|
|
acp, acplen, NULL, NULL);
|
|
|
|
if ( outlen > 0)
|
|
|
|
acp[outlen] = '\0'; // null terminate
|
|
|
|
}
|
|
|
|
return acp;
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetTitle(const nsString& aTitle)
|
1998-04-17 23:45:07 +00:00
|
|
|
{
|
1999-10-22 21:45:19 +00:00
|
|
|
char* title = GetACPString(aTitle);
|
|
|
|
if (title) {
|
|
|
|
::SendMessage(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCTSTR)title);
|
|
|
|
delete [] title;
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-17 23:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-28 19:24:52 +00:00
|
|
|
PRBool nsWindow::AutoErase()
|
|
|
|
{
|
|
|
|
return(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
|
|
|
|
{
|
|
|
|
aWidth = mPreferredWidth;
|
|
|
|
aHeight = mPreferredHeight;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsWindow::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
|
|
|
|
{
|
|
|
|
mPreferredWidth = aWidth;
|
|
|
|
mPreferredHeight = aHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:36:20 +00:00
|
|
|
void
|
1999-10-27 23:05:24 +00:00
|
|
|
nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
|
1999-03-19 23:36:20 +00:00
|
|
|
{
|
1999-11-16 23:45:44 +00:00
|
|
|
NS_ASSERTION( mIMECompString, "mIMECompString is null");
|
|
|
|
NS_ASSERTION( mIMECompUnicode, "mIMECompUnicode is null");
|
1999-11-10 23:43:46 +00:00
|
|
|
NS_ASSERTION( mIMEIsComposing, "conflict state");
|
1999-11-16 23:45:44 +00:00
|
|
|
if((nsnull == mIMECompString) || (nsnull == mIMECompUnicode))
|
|
|
|
return;
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
nsTextEvent event;
|
|
|
|
nsPoint point;
|
|
|
|
size_t unicharSize;
|
1999-08-06 07:42:35 +00:00
|
|
|
CANDIDATEFORM candForm;
|
1999-03-19 23:36:20 +00:00
|
|
|
point.x = 0;
|
|
|
|
point.y = 0;
|
1998-04-17 23:45:07 +00:00
|
|
|
|
1999-03-19 23:36:20 +00:00
|
|
|
InitEvent(event, NS_TEXT_EVENT, &point);
|
1999-06-29 20:31:22 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// convert the composition string text into unicode before it is sent to xp-land
|
|
|
|
//
|
1999-12-01 22:10:13 +00:00
|
|
|
unicharSize = ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
1999-11-16 23:45:44 +00:00
|
|
|
mIMECompString->GetBuffer(),
|
|
|
|
mIMECompString->Length(),
|
|
|
|
NULL,0);
|
1999-06-29 20:31:22 +00:00
|
|
|
|
1999-11-16 23:45:44 +00:00
|
|
|
mIMECompUnicode->SetCapacity(unicharSize+1);
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
unicharSize = ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
1999-11-16 23:45:44 +00:00
|
|
|
mIMECompString->GetBuffer(),
|
|
|
|
mIMECompString->Length(),
|
|
|
|
(PRUnichar*)mIMECompUnicode->GetUnicode(),
|
|
|
|
mIMECompUnicode->mCapacity);
|
|
|
|
((PRUnichar*)mIMECompUnicode->GetUnicode())[unicharSize] = (PRUnichar) 0;
|
|
|
|
mIMECompUnicode->mLength = unicharSize;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
//
|
|
|
|
// we need to convert the attribute array, which is alligned with the mutibyte text into an array of offsets
|
|
|
|
// mapped to the unicode text
|
|
|
|
//
|
1999-10-27 00:14:46 +00:00
|
|
|
|
1999-10-27 23:05:24 +00:00
|
|
|
if(aCheckAttr) {
|
1999-10-27 00:14:46 +00:00
|
|
|
MapDBCSAtrributeArrayToUnicodeOffsets(&(event.rangeCount),&(event.rangeArray));
|
|
|
|
} else {
|
|
|
|
event.rangeCount = 0;
|
|
|
|
event.rangeArray = nsnull;
|
|
|
|
}
|
1999-06-29 20:31:22 +00:00
|
|
|
|
1999-11-16 23:45:44 +00:00
|
|
|
event.theText = (PRUnichar*)mIMECompUnicode->GetUnicode();
|
1999-06-29 20:31:22 +00:00
|
|
|
event.isShift = mIsShiftDown;
|
1999-03-19 23:36:20 +00:00
|
|
|
event.isControl = mIsControlDown;
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
event.isMeta = PR_FALSE;
|
1999-06-29 20:31:22 +00:00
|
|
|
event.isAlt = mIsAltDown;
|
1999-03-19 23:36:20 +00:00
|
|
|
event.eventStructType = NS_TEXT_EVENT;
|
|
|
|
|
|
|
|
(void)DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
1998-04-17 23:45:07 +00:00
|
|
|
|
1999-10-25 22:17:09 +00:00
|
|
|
if(event.rangeArray)
|
|
|
|
delete [] event.rangeArray;
|
|
|
|
|
1999-08-06 07:42:35 +00:00
|
|
|
//
|
|
|
|
// Post process event
|
|
|
|
//
|
|
|
|
candForm.dwIndex = 0;
|
|
|
|
candForm.dwStyle = CFS_CANDIDATEPOS;
|
|
|
|
candForm.ptCurrentPos.x = event.theReply.mCursorPosition.x + IME_X_OFFSET;
|
1999-12-22 07:56:40 +00:00
|
|
|
candForm.ptCurrentPos.y = event.theReply.mCursorPosition.y + IME_Y_OFFSET
|
|
|
|
+ event.theReply.mCursorPosition.height ;
|
1999-08-06 07:42:35 +00:00
|
|
|
|
|
|
|
printf("Candidate window position: x=%d, y=%d\n",candForm.ptCurrentPos.x,candForm.ptCurrentPos.y);
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_SETCANDIDATEWINDOW(hIMEContext,&candForm);
|
1999-08-06 07:42:35 +00:00
|
|
|
|
1999-03-19 23:36:20 +00:00
|
|
|
}
|
1999-05-03 22:57:48 +00:00
|
|
|
|
|
|
|
void
|
1999-08-31 01:20:32 +00:00
|
|
|
nsWindow::HandleStartComposition(HIMC hIMEContext)
|
1999-05-03 22:57:48 +00:00
|
|
|
{
|
1999-11-10 23:43:46 +00:00
|
|
|
NS_ASSERTION( !mIMEIsComposing, "conflict state");
|
1999-05-03 22:57:48 +00:00
|
|
|
nsCompositionEvent event;
|
|
|
|
nsPoint point;
|
1999-08-31 01:20:32 +00:00
|
|
|
CANDIDATEFORM candForm;
|
1999-05-03 22:57:48 +00:00
|
|
|
|
|
|
|
point.x = 0;
|
|
|
|
point.y = 0;
|
|
|
|
|
|
|
|
InitEvent(event,NS_COMPOSITION_START,&point);
|
|
|
|
event.eventStructType = NS_COMPOSITION_START;
|
|
|
|
event.compositionMessage = NS_COMPOSITION_START;
|
|
|
|
(void)DispatchWindowEvent(&event);
|
1999-08-31 01:20:32 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Post process event
|
|
|
|
//
|
|
|
|
candForm.dwIndex = 0;
|
|
|
|
candForm.dwStyle = CFS_CANDIDATEPOS;
|
|
|
|
candForm.ptCurrentPos.x = event.theReply.mCursorPosition.x + IME_X_OFFSET;
|
1999-12-22 07:56:40 +00:00
|
|
|
candForm.ptCurrentPos.y = event.theReply.mCursorPosition.y + IME_Y_OFFSET
|
|
|
|
+ event.theReply.mCursorPosition.height;
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
1999-08-31 01:20:32 +00:00
|
|
|
printf("Candidate window position: x=%d, y=%d\n",candForm.ptCurrentPos.x,candForm.ptCurrentPos.y);
|
|
|
|
#endif
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_SETCANDIDATEWINDOW(hIMEContext, &candForm);
|
1999-05-03 22:57:48 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1999-11-16 23:45:44 +00:00
|
|
|
|
|
|
|
if(nsnull == mIMECompString)
|
|
|
|
mIMECompString = new nsCAutoString();
|
|
|
|
if(nsnull == mIMECompUnicode)
|
|
|
|
mIMECompUnicode = new nsAutoString();
|
1999-11-10 23:43:46 +00:00
|
|
|
mIMEIsComposing = PR_TRUE;
|
|
|
|
|
1999-05-03 22:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::HandleEndComposition(void)
|
|
|
|
{
|
1999-11-10 23:43:46 +00:00
|
|
|
NS_ASSERTION(mIMEIsComposing, "conflict state");
|
1999-05-03 22:57:48 +00:00
|
|
|
nsCompositionEvent event;
|
|
|
|
nsPoint point;
|
|
|
|
|
|
|
|
point.x = 0;
|
|
|
|
point.y = 0;
|
|
|
|
|
|
|
|
InitEvent(event,NS_COMPOSITION_END,&point);
|
|
|
|
event.eventStructType = NS_COMPOSITION_END;
|
|
|
|
event.compositionMessage = NS_COMPOSITION_END;
|
|
|
|
(void)DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
1999-11-10 23:43:46 +00:00
|
|
|
mIMEIsComposing = PR_FALSE;
|
1999-05-03 22:57:48 +00:00
|
|
|
}
|
1999-06-29 20:31:22 +00:00
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
static PRUint32 PlatformToNSAttr(PRUint8 aAttr)
|
1999-10-25 22:17:09 +00:00
|
|
|
{
|
|
|
|
switch(aAttr)
|
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
case ATTR_INPUT_ERROR:
|
|
|
|
// case ATTR_FIXEDCONVERTED:
|
1999-10-25 22:17:09 +00:00
|
|
|
case ATTR_INPUT:
|
|
|
|
return NS_TEXTRANGE_RAWINPUT;
|
|
|
|
case ATTR_CONVERTED:
|
|
|
|
return NS_TEXTRANGE_CONVERTEDTEXT;
|
|
|
|
case ATTR_TARGET_NOTCONVERTED:
|
|
|
|
return NS_TEXTRANGE_SELECTEDRAWTEXT;
|
|
|
|
case ATTR_TARGET_CONVERTED:
|
|
|
|
return NS_TEXTRANGE_SELECTEDCONVERTEDTEXT;
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(PR_FALSE, "unknown attribute");
|
|
|
|
return NS_TEXTRANGE_CARETPOSITION;
|
|
|
|
}
|
|
|
|
}
|
1999-06-29 20:31:22 +00:00
|
|
|
//
|
|
|
|
// This function converters the composition string (CGS_COMPSTR) into Unicode while mapping the
|
|
|
|
// attribute (GCS_ATTR) string t
|
|
|
|
void
|
|
|
|
nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthResult,nsTextRangeArray* textRangeListResult)
|
|
|
|
{
|
1999-11-16 23:45:44 +00:00
|
|
|
NS_ASSERTION( mIMECompString, "mIMECompString is null");
|
|
|
|
NS_ASSERTION( mIMECompUnicode, "mIMECompUnicode is null");
|
|
|
|
if((nsnull == mIMECompString) || (nsnull == mIMECompUnicode))
|
|
|
|
return;
|
1999-11-30 22:09:28 +00:00
|
|
|
PRInt32 rangePointer;
|
1999-06-29 20:31:22 +00:00
|
|
|
size_t lastUnicodeOffset, substringLength, lastMBCSOffset;
|
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
long maxlen = mIMECompString->Length();
|
|
|
|
long cursor = mIMECursorPosition;
|
|
|
|
NS_ASSERTION(cursor <= maxlen, "wrong cursor positoin");
|
|
|
|
if(cursor > maxlen)
|
|
|
|
cursor = maxlen;
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
//
|
|
|
|
// figure out the ranges from the compclause string
|
|
|
|
//
|
|
|
|
if (mIMECompClauseStringLength==0) {
|
1999-07-14 20:08:02 +00:00
|
|
|
*textRangeListLengthResult = 2;
|
|
|
|
*textRangeListResult = new nsTextRange[2];
|
1999-06-29 20:31:22 +00:00
|
|
|
(*textRangeListResult)[0].mStartOffset=0;
|
1999-12-01 22:10:13 +00:00
|
|
|
substringLength = ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
1999-11-30 22:09:28 +00:00
|
|
|
mIMECompString->GetBuffer(), maxlen,NULL,0);
|
1999-07-14 20:08:02 +00:00
|
|
|
(*textRangeListResult)[0].mEndOffset = substringLength;
|
1999-07-19 21:17:21 +00:00
|
|
|
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_RAWINPUT;
|
1999-12-01 22:10:13 +00:00
|
|
|
substringLength = ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,mIMECompString->GetBuffer(),
|
1999-11-30 22:09:28 +00:00
|
|
|
cursor,NULL,0);
|
1999-10-25 22:17:09 +00:00
|
|
|
(*textRangeListResult)[1].mStartOffset=substringLength;
|
|
|
|
(*textRangeListResult)[1].mEndOffset = substringLength;
|
|
|
|
(*textRangeListResult)[1].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
1999-07-14 20:08:02 +00:00
|
|
|
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
} else {
|
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
*textRangeListLengthResult = mIMECompClauseStringLength;
|
1999-06-29 20:31:22 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// allocate the offset array
|
|
|
|
//
|
|
|
|
*textRangeListResult = new nsTextRange[*textRangeListLengthResult];
|
|
|
|
|
1999-07-14 20:08:02 +00:00
|
|
|
//
|
|
|
|
// figure out the cursor position
|
|
|
|
//
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
substringLength = ::MultiByteToWideChar(gCurrentKeyboardCP,
|
1999-11-30 22:09:28 +00:00
|
|
|
MB_PRECOMPOSED,mIMECompString->GetBuffer(),cursor,NULL,0);
|
1999-07-14 20:08:02 +00:00
|
|
|
(*textRangeListResult)[0].mStartOffset=substringLength;
|
|
|
|
(*textRangeListResult)[0].mEndOffset = substringLength;
|
|
|
|
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
|
|
|
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
//
|
|
|
|
// iterate over the attributes and convert them into unicode
|
1999-11-30 22:09:28 +00:00
|
|
|
for(rangePointer=1, lastUnicodeOffset= lastMBCSOffset = 0;
|
|
|
|
rangePointer<mIMECompClauseStringLength;
|
|
|
|
rangePointer++)
|
|
|
|
{
|
|
|
|
long current = mIMECompClauseString[rangePointer];
|
|
|
|
NS_ASSERTION(current <= maxlen, "wrong offset");
|
|
|
|
if(current > maxlen)
|
|
|
|
current = maxlen;
|
|
|
|
|
|
|
|
(*textRangeListResult)[rangePointer].mRangeType =
|
|
|
|
PlatformToNSAttr(mIMEAttributeString[lastMBCSOffset]);
|
|
|
|
(*textRangeListResult)[rangePointer].mStartOffset = lastUnicodeOffset;
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
lastUnicodeOffset += ::MultiByteToWideChar(gCurrentKeyboardCP,
|
1999-11-30 22:09:28 +00:00
|
|
|
MB_PRECOMPOSED,mIMECompString->GetBuffer()+lastMBCSOffset,
|
|
|
|
current-lastMBCSOffset,NULL,0);
|
|
|
|
|
|
|
|
(*textRangeListResult)[rangePointer].mEndOffset = lastUnicodeOffset;
|
|
|
|
|
|
|
|
lastMBCSOffset = current;
|
|
|
|
} // for
|
|
|
|
} // if else
|
1999-06-29 20:31:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
1999-11-11 22:28:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
1999-12-01 22:10:13 +00:00
|
|
|
BOOL nsWindow::OnInputLangChange(HKL aHKL, LRESULT *oRetValue)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-12-01 22:10:13 +00:00
|
|
|
#ifdef KE_DEBUG
|
1999-11-11 22:28:52 +00:00
|
|
|
printf("OnInputLanguageChange\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
if(gKeyboardLayout != aHKL)
|
|
|
|
{
|
|
|
|
gKeyboardLayout = aHKL;
|
|
|
|
*oRetValue = LangIDToCP((WORD)((DWORD)gKeyboardLayout & 0x0FFFF),
|
|
|
|
gCurrentKeyboardCP);
|
|
|
|
}
|
|
|
|
ResetInputState();
|
1999-11-11 22:28:52 +00:00
|
|
|
return PR_FALSE; // always pass to child window
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("OnIMEChar\n");
|
|
|
|
#endif
|
1999-11-30 22:09:28 +00:00
|
|
|
NS_ASSERTION(PR_TRUE, "should not got an WM_IME_CHAR");
|
1999-11-11 22:28:52 +00:00
|
|
|
|
|
|
|
// not implement yet
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("OnIMEComposition\n");
|
|
|
|
#endif
|
1999-11-16 23:45:44 +00:00
|
|
|
NS_ASSERTION( mIMECompString, "mIMECompString is null");
|
|
|
|
NS_ASSERTION( mIMECompUnicode, "mIMECompUnicode is null");
|
|
|
|
if((nsnull == mIMECompString) || (nsnull == mIMECompUnicode))
|
|
|
|
return PR_TRUE;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
|
|
|
HIMC hIMEContext;
|
|
|
|
|
|
|
|
BOOL result = PR_FALSE; // will change this if an IME message we handle
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_GETCONTEXT(mWnd, hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
if (hIMEContext==NULL)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This catches a fixed result
|
|
|
|
//
|
|
|
|
if (aGCS & GCS_RESULTSTR) {
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
fprintf(stderr,"Handling GCS_RESULTSTR\n");
|
|
|
|
#endif
|
|
|
|
if(! mIMEIsComposing)
|
|
|
|
HandleStartComposition(hIMEContext);
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
long compStrLen;
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_RESULTSTR, NULL, 0, compStrLen);
|
1999-11-16 23:45:44 +00:00
|
|
|
|
|
|
|
mIMECompString->SetCapacity(compStrLen+1);
|
2000-01-07 00:34:34 +00:00
|
|
|
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_RESULTSTR, (char*)mIMECompString->GetBuffer(), mIMECompString->mCapacity, compStrLen);
|
|
|
|
((char*)mIMECompString->GetBuffer())[compStrLen] = '\0';
|
1999-11-16 23:45:44 +00:00
|
|
|
mIMECompString->mLength = compStrLen;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
fprintf(stderr,"GCS_RESULTSTR compStrLen = %d\n", compStrLen);
|
|
|
|
#endif
|
|
|
|
result = PR_TRUE;
|
|
|
|
HandleTextEvent(hIMEContext, PR_FALSE);
|
|
|
|
HandleEndComposition();
|
|
|
|
}
|
1999-11-30 22:09:28 +00:00
|
|
|
|
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
//
|
|
|
|
// This provides us with a composition string
|
|
|
|
//
|
1999-11-30 22:09:28 +00:00
|
|
|
if (aGCS &
|
|
|
|
(GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE | GCS_CURSORPOS ))
|
|
|
|
{
|
1999-11-11 22:28:52 +00:00
|
|
|
#ifdef DEBUG_IME
|
|
|
|
fprintf(stderr,"Handling GCS_COMPSTR\n");
|
|
|
|
#endif
|
1999-11-30 22:09:28 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
if(! mIMEIsComposing)
|
|
|
|
HandleStartComposition(hIMEContext);
|
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
//--------------------------------------------------------
|
|
|
|
// 1. Get GCS_COMPATTR
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// This provides us with the attribute string necessary
|
|
|
|
// for doing hiliting
|
2000-01-07 00:34:34 +00:00
|
|
|
long attrStrLen;
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPATTR, NULL, 0, attrStrLen);
|
1999-11-30 22:09:28 +00:00
|
|
|
if (attrStrLen>mIMEAttributeStringSize) {
|
|
|
|
if (mIMEAttributeString!=NULL)
|
|
|
|
delete [] mIMEAttributeString;
|
|
|
|
mIMEAttributeString = new PRUint8[attrStrLen+32];
|
|
|
|
mIMEAttributeStringSize = attrStrLen+32;
|
|
|
|
}
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPATTR, mIMEAttributeString, mIMEAttributeStringSize, attrStrLen);
|
1999-11-30 22:09:28 +00:00
|
|
|
mIMEAttributeStringLength = attrStrLen;
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// 2. Get GCS_COMPCLAUSE
|
|
|
|
//--------------------------------------------------------
|
2000-01-07 00:34:34 +00:00
|
|
|
long compClauseLen;
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext,
|
|
|
|
GCS_COMPCLAUSE, NULL, 0, compClauseLen);
|
|
|
|
compClauseLen = compClauseLen / sizeof(PRUint32);
|
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
if (compClauseLen>mIMECompClauseStringSize) {
|
|
|
|
if (mIMECompClauseString!=NULL)
|
|
|
|
delete [] mIMECompClauseString;
|
|
|
|
mIMECompClauseString = new PRUint32 [compClauseLen+32];
|
|
|
|
mIMECompClauseStringSize = compClauseLen+32;
|
|
|
|
}
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
long compClauseLen2;
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext,
|
|
|
|
GCS_COMPCLAUSE,
|
|
|
|
mIMECompClauseString,
|
|
|
|
mIMECompClauseStringSize * sizeof(PRUint32),
|
|
|
|
compClauseLen2);
|
|
|
|
compClauseLen2 = compClauseLen2 / sizeof(PRUint32);
|
1999-12-01 22:10:13 +00:00
|
|
|
NS_ASSERTION(compClauseLen2 == compClauseLen, "strange result");
|
|
|
|
if(compClauseLen > compClauseLen2)
|
|
|
|
compClauseLen = compClauseLen2;
|
1999-11-30 22:09:28 +00:00
|
|
|
mIMECompClauseStringLength = compClauseLen;
|
1999-12-01 22:10:13 +00:00
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// 3. Get GCS_CURSOPOS
|
|
|
|
//--------------------------------------------------------
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_CURSORPOS, NULL, 0, mIMECursorPosition);
|
1999-11-30 22:09:28 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// 4. Get GCS_COMPSTR
|
|
|
|
//--------------------------------------------------------
|
2000-01-07 00:34:34 +00:00
|
|
|
long compStrLen;
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPSTR, NULL, 0, compStrLen);
|
1999-11-16 23:45:44 +00:00
|
|
|
mIMECompString->SetCapacity(compStrLen+1);
|
2000-01-07 00:34:34 +00:00
|
|
|
|
|
|
|
NS_IMM_GETCOMPOSITIONSTRING(hIMEContext,
|
1999-11-11 22:28:52 +00:00
|
|
|
GCS_COMPSTR,
|
1999-11-16 23:45:44 +00:00
|
|
|
(char*)mIMECompString->GetBuffer(),
|
2000-01-07 00:34:34 +00:00
|
|
|
mIMECompString->mCapacity, compStrLen);
|
|
|
|
((char*)mIMECompString->GetBuffer())[compStrLen] = '\0';
|
1999-11-16 23:45:44 +00:00
|
|
|
mIMECompString->mLength = compStrLen;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
fprintf(stderr,"GCS_COMPSTR compStrLen = %d\n", compStrLen);
|
1999-12-01 22:10:13 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
for(int kk=0;kk<mIMECompClauseStringLength;kk++)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mIMECompClauseString[kk] <= mIMECompString->mLength, "illegal pos");
|
|
|
|
}
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
1999-11-30 22:09:28 +00:00
|
|
|
//--------------------------------------------------------
|
|
|
|
// 5. Sent the text event
|
|
|
|
//--------------------------------------------------------
|
1999-11-11 22:28:52 +00:00
|
|
|
HandleTextEvent(hIMEContext);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
if(! result)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
fprintf(stderr,"Haandle 0 length TextEvent. \n");
|
|
|
|
#endif
|
|
|
|
if(! mIMEIsComposing)
|
|
|
|
HandleStartComposition(hIMEContext);
|
|
|
|
|
1999-11-16 23:45:44 +00:00
|
|
|
((char*)mIMECompString->GetBuffer())[0] = '\0';
|
|
|
|
mIMECompString->mLength = 0;
|
1999-11-11 22:28:52 +00:00
|
|
|
HandleTextEvent(hIMEContext,PR_FALSE);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
2000-01-07 00:34:34 +00:00
|
|
|
|
|
|
|
NS_IMM_RELEASECONTEXT(mWnd, hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMECompositionFull()
|
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
1999-11-11 22:28:52 +00:00
|
|
|
printf("OnIMECompositionFull\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// not implement yet
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMEEndComposition()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("OnIMEEndComposition\n");
|
|
|
|
#endif
|
|
|
|
if(mIMEIsComposing)
|
|
|
|
{
|
|
|
|
HIMC hIMEContext;
|
|
|
|
|
|
|
|
if ((mIMEProperty & IME_PROP_SPECIAL_UI) ||
|
|
|
|
(mIMEProperty & IME_PROP_AT_CARET))
|
|
|
|
return PR_FALSE;
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_GETCONTEXT(mWnd, hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
if (hIMEContext==NULL)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
// IME on Korean NT somehow send WM_IME_ENDCOMPOSITION
|
|
|
|
// first when we hit space in composition mode
|
|
|
|
// we need to clear out the current composition string
|
|
|
|
// in that case.
|
1999-11-16 23:45:44 +00:00
|
|
|
((char*)mIMECompString->GetBuffer())[0] = '\0';
|
|
|
|
mIMECompString->mLength = 0;
|
1999-11-11 22:28:52 +00:00
|
|
|
HandleTextEvent(hIMEContext, PR_FALSE);
|
|
|
|
|
|
|
|
HandleEndComposition();
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_RELEASECONTEXT(mWnd, hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMENotify(WPARAM aIMN, LPARAM aData, LRESULT *oResult)
|
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
1999-11-15 20:57:41 +00:00
|
|
|
printf("OnIMENotify ");
|
|
|
|
switch(aIMN) {
|
|
|
|
case IMN_CHANGECANDIDATE:
|
|
|
|
printf("IMN_CHANGECANDIDATE %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_CLOSECANDIDATE:
|
|
|
|
printf("IMN_CLOSECANDIDATE %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_CLOSESTATUSWINDOW:
|
|
|
|
printf("IMN_CLOSESTATUSWINDOW\n");
|
|
|
|
break;
|
|
|
|
case IMN_GUIDELINE:
|
|
|
|
printf("IMN_GUIDELINE\n");
|
|
|
|
break;
|
|
|
|
case IMN_OPENCANDIDATE:
|
|
|
|
printf("IMN_OPENCANDIDATE %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_OPENSTATUSWINDOW:
|
|
|
|
printf("IMN_OPENSTATUSWINDOW\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETCANDIDATEPOS:
|
|
|
|
printf("IMN_SETCANDIDATEPOS %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_SETCOMPOSITIONFONT:
|
|
|
|
printf("IMN_SETCOMPOSITIONFONT\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETCOMPOSITIONWINDOW:
|
|
|
|
printf("IMN_SETCOMPOSITIONWINDOW\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETCONVERSIONMODE:
|
|
|
|
printf("IMN_SETCONVERSIONMODE\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETOPENSTATUS:
|
|
|
|
printf("IMN_SETOPENSTATUS\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETSENTENCEMODE:
|
|
|
|
printf("IMN_SETSENTENCEMODE\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETSTATUSWINDOWPOS:
|
|
|
|
printf("IMN_SETSTATUSWINDOWPOS\n");
|
|
|
|
break;
|
2000-01-07 00:34:34 +00:00
|
|
|
case IMN_PRIVATE:
|
|
|
|
printf("IMN_PRIVATE\n");
|
|
|
|
break;
|
1999-11-15 20:57:41 +00:00
|
|
|
};
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2000-03-04 00:27:16 +00:00
|
|
|
// add hacky code here
|
|
|
|
if(IS_VK_DOWN(NS_VK_ALT)) {
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
mIsControlDown = PR_FALSE;
|
|
|
|
mIsAltDown = PR_TRUE;
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, 0, 192);// XXX hack hack hack
|
|
|
|
}
|
|
|
|
// not implement yet
|
1999-11-11 22:28:52 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMERequest(WPARAM aIMR, LPARAM aData, LRESULT *oResult)
|
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
1999-11-11 22:28:52 +00:00
|
|
|
printf("OnIMERequest\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// not implement yet
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMESelect(BOOL aSelected, WORD aLangID)
|
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
1999-11-11 22:28:52 +00:00
|
|
|
printf("OnIMESelect\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// not implement yet
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
1999-11-15 20:57:41 +00:00
|
|
|
BOOL nsWindow::OnIMESetContext(BOOL aActive, LPARAM& aISC)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
1999-11-15 20:57:41 +00:00
|
|
|
printf("OnIMESetContext %x %s %s %s Candidate[%s%s%s%s]\n", this,
|
|
|
|
(aActive ? "Active" : "Deactiv"),
|
|
|
|
((aISC & ISC_SHOWUICOMPOSITIONWINDOW) ? "[Comp]" : ""),
|
|
|
|
((aISC & ISC_SHOWUIGUIDELINE) ? "[GUID]" : ""),
|
|
|
|
((aISC & ISC_SHOWUICANDIDATEWINDOW) ? "0" : ""),
|
|
|
|
((aISC & (ISC_SHOWUICANDIDATEWINDOW<<1)) ? "1" : ""),
|
|
|
|
((aISC & (ISC_SHOWUICANDIDATEWINDOW<<2)) ? "2" : ""),
|
|
|
|
((aISC & (ISC_SHOWUICANDIDATEWINDOW<<3)) ? "3" : "")
|
|
|
|
);
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
1999-11-15 20:57:41 +00:00
|
|
|
if(! aActive)
|
|
|
|
ResetInputState();
|
1999-11-11 22:28:52 +00:00
|
|
|
|
1999-11-15 20:57:41 +00:00
|
|
|
aISC &= ~ ISC_SHOWUICOMPOSITIONWINDOW;
|
|
|
|
// We still return false here because we need to pass the
|
|
|
|
// aISC w/ ISC_SHOWUICOMPOSITIONWINDOW clear to the default
|
|
|
|
// window proc so it will draw the candidcate window for us...
|
1999-11-11 22:28:52 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMEStartComposition()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("OnIMEStartComposition\n");
|
|
|
|
#endif
|
|
|
|
HIMC hIMEContext;
|
|
|
|
|
|
|
|
if ((mIMEProperty & IME_PROP_SPECIAL_UI) ||
|
|
|
|
(mIMEProperty & IME_PROP_AT_CARET))
|
|
|
|
return PR_FALSE;
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_GETCONTEXT(mWnd, hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
if (hIMEContext==NULL)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
HandleStartComposition(hIMEContext);
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_RELEASECONTEXT(mWnd, hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1999-11-15 20:57:41 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
NS_IMETHODIMP nsWindow::ResetInputState()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
|
|
|
printf("ResetInputState\n");
|
|
|
|
#endif
|
1999-12-08 03:39:53 +00:00
|
|
|
//if(mIMEIsComposing) {
|
2000-01-07 00:34:34 +00:00
|
|
|
HIMC hIMC;
|
|
|
|
NS_IMM_GETCONTEXT(mWnd, hIMC);
|
1999-11-15 20:57:41 +00:00
|
|
|
if(hIMC) {
|
2000-01-07 00:34:34 +00:00
|
|
|
BOOL ret = NS_IMM_NOTIFYIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, NULL);
|
1999-12-08 03:39:53 +00:00
|
|
|
//NS_ASSERTION(ret, "ImmNotify failed");
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_RELEASECONTEXT(mWnd, hIMC);
|
1999-11-15 20:57:41 +00:00
|
|
|
}
|
1999-12-08 03:39:53 +00:00
|
|
|
//}
|
1999-11-15 20:57:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP nsWindow::PasswordFieldInit()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
|
|
|
printf("PasswordFieldInit\n");
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP nsWindow::PasswordFieldEnter(PRUint32& oState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
|
|
|
printf("PasswordFieldEnter\n");
|
|
|
|
#endif
|
1999-12-01 22:10:13 +00:00
|
|
|
if(IS_IME_CODEPAGE(gCurrentKeyboardCP))
|
1999-11-15 20:57:41 +00:00
|
|
|
{
|
2000-01-07 00:34:34 +00:00
|
|
|
HIMC hIMC;
|
|
|
|
NS_IMM_GETCONTEXT(mWnd, hIMC);
|
1999-11-15 20:57:41 +00:00
|
|
|
if(hIMC) {
|
|
|
|
DWORD st1,st2;
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
BOOL ret = NS_IMM_GETCONVERSIONSTATUS(hIMC, &st1, &st2);
|
1999-11-15 20:57:41 +00:00
|
|
|
NS_ASSERTION(ret, "ImmGetConversionStatus failed");
|
|
|
|
if(ret) {
|
|
|
|
oState = st1;
|
2000-01-07 00:34:34 +00:00
|
|
|
ret = NS_IMM_SETCONVERSIONSTATUS(hIMC, IME_CMODE_NOCONVERSION, st2);
|
1999-11-15 20:57:41 +00:00
|
|
|
NS_ASSERTION(ret, "ImmSetConversionStatus failed");
|
|
|
|
}
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_RELEASECONTEXT(mWnd, hIMC);
|
1999-11-15 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::PasswordFieldExit(PRUint32 aState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
|
|
|
printf("PasswordFieldExit\n");
|
|
|
|
#endif
|
1999-12-01 22:10:13 +00:00
|
|
|
if(IS_IME_CODEPAGE(gCurrentKeyboardCP))
|
1999-11-15 20:57:41 +00:00
|
|
|
{
|
2000-01-07 00:34:34 +00:00
|
|
|
HIMC hIMC;
|
|
|
|
NS_IMM_GETCONTEXT(mWnd, hIMC);
|
1999-11-15 20:57:41 +00:00
|
|
|
if(hIMC) {
|
|
|
|
DWORD st1,st2;
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
BOOL ret = NS_IMM_GETCONVERSIONSTATUS(hIMC, &st1, &st2);
|
1999-11-15 20:57:41 +00:00
|
|
|
NS_ASSERTION(ret, "ImmGetConversionStatus failed");
|
|
|
|
if(ret) {
|
2000-01-07 00:34:34 +00:00
|
|
|
ret = NS_IMM_SETCONVERSIONSTATUS(hIMC, (DWORD)aState, st2);
|
1999-11-15 20:57:41 +00:00
|
|
|
NS_ASSERTION(ret, "ImmSetConversionStatus failed");
|
|
|
|
}
|
2000-01-07 00:34:34 +00:00
|
|
|
NS_IMM_RELEASECONTEXT(mWnd, hIMC);
|
1999-11-15 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-10 07:20:51 +00:00
|
|
|
// Pick some random timer ID. Is there a better way?
|
|
|
|
#define NS_FLASH_TIMER_ID 0x011231984
|
|
|
|
|
|
|
|
// This function is called on a timer to do the flashing. It simply toggles the flash
|
|
|
|
// status until the window comes to the foreground.
|
1999-12-17 06:11:45 +00:00
|
|
|
static VOID CALLBACK nsGetAttentionTimerFunc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime ) {
|
1999-12-10 07:20:51 +00:00
|
|
|
// Flash the window until we're in the foreground.
|
|
|
|
if ( GetForegroundWindow() != hwnd ) {
|
|
|
|
// We're not in the foreground yet.
|
|
|
|
FlashWindow( hwnd, TRUE );
|
|
|
|
} else {
|
|
|
|
KillTimer( hwnd, idEvent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw user's attention to this window until it comes to foreground.
|
|
|
|
NS_IMETHODIMP
|
1999-12-17 06:11:45 +00:00
|
|
|
nsWindow::GetAttention() {
|
1999-12-10 07:20:51 +00:00
|
|
|
// Got window?
|
|
|
|
if ( !mWnd ) {
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If window is in foreground, no notification is necessary.
|
|
|
|
if ( GetForegroundWindow() != mWnd ) {
|
|
|
|
// Kick off timer that does single flash till window comes to foreground.
|
1999-12-17 06:11:45 +00:00
|
|
|
SetTimer( mWnd, NS_FLASH_TIMER_ID, GetCaretBlinkTime(), (TIMERPROC)nsGetAttentionTimerFunc );
|
1999-12-10 07:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|