1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#include "nsIFontCache.h"
|
|
|
|
#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>
|
|
|
|
#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"
|
|
|
|
|
|
|
|
BOOL nsWindow::sIsRegistered = FALSE;
|
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
nsWindow* nsWindow::gCurrentWindow = nsnull;
|
|
|
|
|
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
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
|
|
|
|
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-05-13 03:39:08 +00:00
|
|
|
void nsWindow::BeginResizingChildren(void)
|
|
|
|
{
|
|
|
|
if (NULL == mDeferredPositioner)
|
|
|
|
mDeferredPositioner = ::BeginDeferWindowPos(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::EndResizingChildren(void)
|
|
|
|
{
|
|
|
|
if (NULL != mDeferredPositioner) {
|
|
|
|
::EndDeferWindowPos(mDeferredPositioner);
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
}
|
|
|
|
}
|
1998-05-05 23:41:16 +00:00
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
// DoCreateTooltip - creates a tooltip control and adds some tools
|
|
|
|
// to it.
|
|
|
|
// Returns the handle of the tooltip control if successful or NULL
|
|
|
|
// otherwise.
|
|
|
|
// hwndOwner - handle of the owner window
|
|
|
|
//
|
|
|
|
|
1998-05-18 17:55:34 +00:00
|
|
|
void nsWindow::AddTooltip(HWND hwndOwner,nsRect* aRect, int aId)
|
1998-05-04 19:25:25 +00:00
|
|
|
{
|
1998-05-18 17:55:34 +00:00
|
|
|
TOOLINFO ti; // tool information
|
|
|
|
memset(&ti, 0, sizeof(TOOLINFO));
|
1998-05-04 19:25:25 +00:00
|
|
|
|
|
|
|
// Make sure the common control DLL is loaded
|
|
|
|
InitCommonControls();
|
|
|
|
|
|
|
|
// Create a tooltip control for the window if needed
|
|
|
|
if (mTooltip == (HWND) NULL) {
|
|
|
|
mTooltip = CreateWindow(TOOLTIPS_CLASS, (LPSTR) NULL, TTS_ALWAYSTIP,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
NULL, (HMENU) NULL,
|
|
|
|
nsToolkit::mDllInstance,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTooltip == (HWND) NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ti.cbSize = sizeof(TOOLINFO);
|
|
|
|
ti.uFlags = TTF_SUBCLASS;
|
|
|
|
ti.hwnd = hwndOwner;
|
|
|
|
ti.hinst = nsToolkit::mDllInstance;
|
1998-05-18 17:55:34 +00:00
|
|
|
ti.uId = aId;
|
1998-05-04 19:25:25 +00:00
|
|
|
ti.lpszText = (LPSTR)" "; // must set text to
|
|
|
|
// something for tooltip to give events;
|
1998-05-18 17:55:34 +00:00
|
|
|
ti.rect.left = aRect->x;
|
|
|
|
ti.rect.top = aRect->y;
|
|
|
|
ti.rect.right = aRect->x + aRect->width;
|
|
|
|
ti.rect.bottom = aRect->y + aRect->height;
|
1998-05-04 19:25:25 +00:00
|
|
|
|
|
|
|
if (!SendMessage(mTooltip, TTM_ADDTOOL, 0,
|
|
|
|
(LPARAM) (LPTOOLINFO) &ti))
|
|
|
|
return;
|
1998-05-05 23:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
|
|
|
|
{
|
|
|
|
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-05-04 19:25:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Setup initial tooltip rectangles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-05-18 17:55:34 +00:00
|
|
|
void nsWindow::SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[])
|
1998-05-04 19:25:25 +00:00
|
|
|
{
|
|
|
|
RemoveTooltips();
|
|
|
|
for (int i = 0; i < (int)aNumberOfTips; i++) {
|
1998-05-18 17:55:34 +00:00
|
|
|
AddTooltip(mWnd, aTooltipAreas[i], i);
|
1998-05-04 19:25:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Update all tooltip rectangles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-05-18 17:55:34 +00:00
|
|
|
void nsWindow::UpdateTooltips(nsRect* aNewTips[])
|
1998-05-04 19:25:25 +00:00
|
|
|
{
|
|
|
|
TOOLINFO ti;
|
1998-05-18 17:55:34 +00:00
|
|
|
memset(&ti, 0, sizeof(TOOLINFO));
|
|
|
|
ti.cbSize = sizeof(TOOLINFO);
|
|
|
|
ti.hwnd = mWnd;
|
1998-05-04 19:25:25 +00:00
|
|
|
// Get the number of tooltips
|
|
|
|
UINT count = ::SendMessage(mTooltip, TTM_GETTOOLCOUNT, 0, 0);
|
|
|
|
NS_ASSERTION(count > 0, "Called UpdateTooltips before calling SetTooltips");
|
|
|
|
|
|
|
|
for (UINT i = 0; i < count; i++) {
|
1998-05-18 17:55:34 +00:00
|
|
|
ti.uId = i;
|
|
|
|
int result =::SendMessage(mTooltip, TTM_ENUMTOOLS, i, (LPARAM) (LPTOOLINFO)&ti);
|
|
|
|
|
|
|
|
nsRect* newTip = aNewTips[i];
|
|
|
|
ti.rect.left = newTip->x;
|
|
|
|
ti.rect.top = newTip->y;
|
|
|
|
ti.rect.right = newTip->x + newTip->width;
|
|
|
|
ti.rect.bottom = newTip->y + newTip->height;
|
1998-05-04 19:25:25 +00:00
|
|
|
::SendMessage(mTooltip, TTM_NEWTOOLRECT, 0, (LPARAM) (LPTOOLINFO)&ti);
|
1998-05-18 17:55:34 +00:00
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
}
|
1998-05-18 17:55:34 +00:00
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Remove all tooltip rectangles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void nsWindow::RemoveTooltips()
|
|
|
|
{
|
|
|
|
TOOLINFO ti;
|
1998-05-18 17:55:34 +00:00
|
|
|
memset(&ti, 0, sizeof(TOOLINFO));
|
|
|
|
ti.cbSize = sizeof(TOOLINFO);
|
1998-05-04 19:25:25 +00:00
|
|
|
long val;
|
1998-05-18 17:55:34 +00:00
|
|
|
|
|
|
|
if (mTooltip == NULL)
|
|
|
|
return;
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
// Get the number of tooltips
|
|
|
|
UINT count = ::SendMessage(mTooltip, TTM_GETTOOLCOUNT, 0, (LPARAM)&val);
|
|
|
|
for (UINT i = 0; i < count; i++) {
|
1998-05-18 17:55:34 +00:00
|
|
|
ti.uId = i;
|
|
|
|
ti.hwnd = mWnd;
|
1998-05-04 19:25:25 +00:00
|
|
|
::SendMessage(mTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO)&ti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-18 17:55:34 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Convert nsEventStatus value to a windows boolean
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRBool nsWindow::ConvertStatus(nsEventStatus aStatus)
|
|
|
|
{
|
|
|
|
switch(aStatus) {
|
|
|
|
case nsEventStatus_eIgnore:
|
|
|
|
return(PR_FALSE);
|
|
|
|
break;
|
|
|
|
case nsEventStatus_eConsumeNoDefault:
|
|
|
|
return(PR_TRUE);
|
|
|
|
break;
|
|
|
|
case nsEventStatus_eConsumeDoDefault:
|
|
|
|
return(PR_FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "Illegal nsEventStatus enumeration value");
|
|
|
|
return(PR_FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-05-27 23:58:07 +00:00
|
|
|
event.widgetSupports = mOuter;
|
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
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRBool nsWindow::DispatchEvent(nsGUIEvent* event)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull != mEventCallback) {
|
|
|
|
result = ConvertStatus((*mEventCallback)(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dispatch to event listener if event was not consumed
|
|
|
|
if ((result != PR_TRUE) && (nsnull != mEventListener)) {
|
|
|
|
return ConvertStatus(mEventListener->ProcessEvent(*event));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
return(DispatchEvent(&event));
|
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
|
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)
|
|
|
|
{
|
1998-04-17 00:16:11 +00:00
|
|
|
// Get the window which caused the event and ask it to process the message
|
1998-04-13 20:24:54 +00:00
|
|
|
nsWindow *someWindow = (nsWindow*)::GetWindowLong(hWnd, GWL_USERDATA);
|
1998-04-17 00:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Re-direct a tab change message destined for it's parent window to the
|
|
|
|
// the actual window which generated the event.
|
|
|
|
if (msg == WM_NOTIFY) {
|
|
|
|
LPNMHDR pnmh = (LPNMHDR) lParam;
|
|
|
|
if (pnmh->code == TCN_SELCHANGE) {
|
|
|
|
someWindow = (nsWindow*)::GetWindowLong(pnmh->hwndFrom, GWL_USERDATA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != someWindow) {
|
|
|
|
LRESULT retValue;
|
|
|
|
if (PR_TRUE == someWindow->ProcessMessage(msg, wParam, lParam, &retValue)) {
|
|
|
|
return retValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ::CallWindowProc((FARPROC)someWindow->GetPrevWindowProc(), hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsWindow constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsWindow::nsWindow(nsISupports *aOuter) : nsObject(aOuter)
|
|
|
|
{
|
|
|
|
mWnd = 0;
|
|
|
|
mPrevWndProc = NULL;
|
|
|
|
mChildren = NULL;
|
|
|
|
mEventCallback = NULL;
|
|
|
|
mToolkit = NULL;
|
1998-07-29 18:51:45 +00:00
|
|
|
mAppShell = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
mMouseListener = NULL;
|
|
|
|
mEventListener = NULL;
|
1998-07-21 18:04:18 +00:00
|
|
|
mBackground = ::GetSysColor(COLOR_BTNFACE);
|
1998-04-13 20:24:54 +00:00
|
|
|
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
|
|
|
mForeground = ::GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
mPalette = NULL;
|
|
|
|
mCursor = eCursor_standard;
|
1998-04-18 00:27:48 +00:00
|
|
|
mBorderStyle = eBorderStyle_none;
|
1998-04-13 20:24:54 +00:00
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
mIsControlDown = PR_FALSE;
|
|
|
|
mIsAltDown = PR_FALSE;
|
1998-04-28 18:59:38 +00:00
|
|
|
mIsDestroying = PR_FALSE;
|
1998-05-04 19:25:25 +00:00
|
|
|
mTooltip = NULL;
|
1998-05-13 03:39:08 +00:00
|
|
|
mDeferredPositioner = NULL;
|
1998-05-29 22:44:13 +00:00
|
|
|
mLastPoint.x = 0;
|
|
|
|
mLastPoint.y = 0;
|
1998-06-19 02:46:25 +00:00
|
|
|
mWidth = mHeight = 0;
|
1998-08-07 05:19:40 +00:00
|
|
|
mClientData = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsWindow destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsWindow::~nsWindow()
|
|
|
|
{
|
1998-08-09 01:37:30 +00:00
|
|
|
mIsDestroying = PR_TRUE;
|
|
|
|
if (gCurrentWindow == this) {
|
|
|
|
gCurrentWindow = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the widget was released without calling Destroy() then the native
|
|
|
|
// window still exists, and we need to destroy it
|
|
|
|
if (NULL != mWnd) {
|
1998-04-13 20:24:54 +00:00
|
|
|
Destroy();
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Query interface implementation
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsresult nsWindow::QueryObject(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
nsresult result = nsObject::QueryObject(aIID, aInstancePtr);
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
|
|
|
if (result == NS_NOINTERFACE && aIID.Equals(kIWidgetIID)) {
|
|
|
|
*aInstancePtr = (void*) ((nsIWidget*)this);
|
|
|
|
AddRef();
|
|
|
|
result = NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Create the proper widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Create(nsIWidget *aParent,
|
|
|
|
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
|
|
|
{
|
|
|
|
if (NULL == mToolkit) {
|
|
|
|
if (NULL != aToolkit) {
|
|
|
|
mToolkit = (nsToolkit*)aToolkit;
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mToolkit);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (NULL != aParent) {
|
|
|
|
mToolkit = (nsToolkit*)(aParent->GetToolkit()); // the call AddRef's, we don't have to
|
|
|
|
}
|
|
|
|
// it's some top level window with no toolkit passed in.
|
|
|
|
// Create a default toolkit with the current thread
|
|
|
|
else {
|
|
|
|
mToolkit = new nsToolkit();
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mToolkit);
|
1998-04-13 20:24:54 +00:00
|
|
|
mToolkit->Init(PR_GetCurrentThread());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-07-29 18:51:45 +00:00
|
|
|
mAppShell = aAppShell;
|
|
|
|
NS_IF_ADDREF(mAppShell);
|
|
|
|
|
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"...
|
|
|
|
//
|
|
|
|
if (!mToolkit->IsGuiThread()) {
|
|
|
|
DWORD args[5];
|
|
|
|
args[0] = (DWORD)aParent;
|
|
|
|
args[1] = (DWORD)&aRect;
|
|
|
|
args[2] = (DWORD)aHandleEventFunction;
|
|
|
|
args[3] = (DWORD)aContext;
|
|
|
|
args[4] = (DWORD)aToolkit;
|
1998-04-24 21:37:30 +00:00
|
|
|
args[5] = (DWORD)aInitData;
|
|
|
|
MethodInfo info(this, nsWindow::CREATE, 6, args);
|
1998-04-13 20:24:54 +00:00
|
|
|
mToolkit->CallMethod(&info);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// save the event callback function
|
|
|
|
mEventCallback = aHandleEventFunction;
|
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// keep a reference to the device context
|
1998-04-13 20:24:54 +00:00
|
|
|
if (aContext) {
|
|
|
|
mContext = aContext;
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsresult res;
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
|
|
|
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
|
|
|
|
|
|
|
res = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext);
|
|
|
|
|
|
|
|
if (NS_OK == res)
|
1998-06-11 21:26:21 +00:00
|
|
|
mContext->Init(nsnull);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-24 21:37:30 +00:00
|
|
|
if (nsnull != aInitData) {
|
|
|
|
PreCreateWidget(aInitData);
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mWnd = ::CreateWindowEx(WindowExStyle(),
|
|
|
|
WindowClass(),
|
|
|
|
"",
|
|
|
|
WindowStyle(),
|
|
|
|
aRect.x,
|
|
|
|
aRect.y,
|
|
|
|
aRect.width,
|
1998-05-14 21:34:08 +00:00
|
|
|
GetHeight(aRect.height),
|
1998-04-13 20:24:54 +00:00
|
|
|
(aParent) ? (HWND)aParent->GetNativeData(NS_NATIVE_WINDOW):
|
|
|
|
(HWND)NULL,
|
|
|
|
NULL,
|
|
|
|
nsToolkit::mDllInstance,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
VERIFY(mWnd);
|
|
|
|
if (aParent) {
|
|
|
|
aParent->AddChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Force cursor to default setting
|
|
|
|
mCursor = eCursor_select;
|
|
|
|
SetCursor(eCursor_standard);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// create with a native parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-06-25 04:24:45 +00:00
|
|
|
void 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
|
|
|
{
|
|
|
|
|
|
|
|
if (NULL == mToolkit) {
|
|
|
|
if (NULL != aToolkit) {
|
|
|
|
mToolkit = (nsToolkit*)aToolkit;
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mToolkit);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mToolkit = new nsToolkit();
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mToolkit);
|
1998-04-13 20:24:54 +00:00
|
|
|
mToolkit->Init(PR_GetCurrentThread());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-07-29 18:51:45 +00:00
|
|
|
mAppShell = aAppShell;
|
|
|
|
NS_IF_ADDREF(aAppShell);
|
|
|
|
|
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"...
|
|
|
|
//
|
|
|
|
if (!mToolkit->IsGuiThread()) {
|
|
|
|
DWORD args[5];
|
|
|
|
args[0] = (DWORD)aParent;
|
|
|
|
args[1] = (DWORD)&aRect;
|
|
|
|
args[2] = (DWORD)aHandleEventFunction;
|
|
|
|
args[3] = (DWORD)aContext;
|
|
|
|
args[4] = (DWORD)aToolkit;
|
1998-04-24 21:37:30 +00:00
|
|
|
args[5] = (DWORD)aInitData;
|
1998-04-13 20:24:54 +00:00
|
|
|
MethodInfo info(this, nsWindow::CREATE_NATIVE, 5, args);
|
|
|
|
mToolkit->CallMethod(&info);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// save the event callback function
|
|
|
|
mEventCallback = aHandleEventFunction;
|
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// keep a reference to the device context
|
1998-04-13 20:24:54 +00:00
|
|
|
if (aContext) {
|
|
|
|
mContext = aContext;
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsresult res;
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
|
|
|
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
|
|
|
|
|
|
|
res = NSRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext);
|
|
|
|
|
|
|
|
if (NS_OK == res)
|
1998-06-11 21:26:21 +00:00
|
|
|
mContext->Init(nsnull);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-24 21:37:30 +00:00
|
|
|
if (nsnull != aInitData) {
|
|
|
|
PreCreateWidget(aInitData);
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mWnd = ::CreateWindowEx(WindowExStyle(),
|
|
|
|
WindowClass(),
|
|
|
|
"",
|
|
|
|
WindowStyle(),
|
|
|
|
aRect.x,
|
|
|
|
aRect.y,
|
|
|
|
aRect.width,
|
1998-05-14 21:34:08 +00:00
|
|
|
GetHeight(aRect.height),
|
1998-04-13 20:24:54 +00:00
|
|
|
aParent,
|
|
|
|
NULL,
|
|
|
|
nsToolkit::mDllInstance,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
VERIFY(mWnd);
|
|
|
|
|
|
|
|
// 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-08-07 05:19:40 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Accessor functions to get/set the client data
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::GetClientData(void*& aClientData)
|
|
|
|
{
|
|
|
|
aClientData = mClientData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::SetClientData(void* aClientData)
|
|
|
|
{
|
|
|
|
mClientData = aClientData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Close this nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Destroy()
|
|
|
|
{
|
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"...
|
|
|
|
if (mToolkit != nsnull && !mToolkit->IsGuiThread()) {
|
|
|
|
MethodInfo info(this, nsWindow::DESTROY);
|
|
|
|
mToolkit->CallMethod(&info);
|
|
|
|
return;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// disconnect from the parent
|
|
|
|
if (!mIsDestroying) {
|
|
|
|
nsIWidget *parent = GetParent();
|
|
|
|
if (parent) {
|
|
|
|
parent->RemoveChild(this);
|
|
|
|
NS_RELEASE(parent);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1998-05-04 19:25:25 +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-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsWindow parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsWindow::GetParent(void)
|
|
|
|
{
|
1998-08-09 01:37:30 +00:00
|
|
|
nsWindow* widget = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (mWnd) {
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
1998-08-09 01:37:30 +00:00
|
|
|
widget = (nsWindow *)::GetWindowLong(mWnd, GWL_USERDATA);
|
|
|
|
if (widget) {
|
|
|
|
// If the widget is in the process of being destroyed then
|
|
|
|
// do NOT return it
|
|
|
|
if (widget->mIsDestroying) {
|
|
|
|
widget = NULL;
|
|
|
|
} else {
|
|
|
|
NS_ADDREF(widget);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsWindow's list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIEnumerator* nsWindow::GetChildren()
|
|
|
|
{
|
|
|
|
if (mChildren) {
|
|
|
|
mChildren->Reset();
|
|
|
|
|
|
|
|
Enumerator * children = new Enumerator();
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(children);
|
1998-04-13 20:24:54 +00:00
|
|
|
nsISupports * next = mChildren->Next();
|
|
|
|
if (next) {
|
|
|
|
nsIWidget *widget;
|
|
|
|
if (NS_OK == next->QueryInterface(kIWidgetIID, (void**)&widget)) {
|
|
|
|
children->Append(widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (nsIEnumerator*)children;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Add a child to the list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::AddChild(nsIWidget* aChild)
|
|
|
|
{
|
|
|
|
if (!mChildren) {
|
|
|
|
mChildren = new Enumerator();
|
|
|
|
}
|
|
|
|
|
|
|
|
mChildren->Append(aChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Remove a child from the list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::RemoveChild(nsIWidget* aChild)
|
|
|
|
{
|
|
|
|
if (mChildren) {
|
|
|
|
mChildren->Remove(aChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hide or show this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Show(PRBool bState)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
if (bState) {
|
|
|
|
::SetWindowPos(mWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
::ShowWindow(mWnd, SW_HIDE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Move this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Move(PRUint32 aX, PRUint32 aY)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Resize this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-06-01 20:26:50 +00:00
|
|
|
void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Resize this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-06-01 20:26:50 +00:00
|
|
|
void nsWindow::Resize(PRUint32 aX,
|
|
|
|
PRUint32 aY,
|
|
|
|
PRUint32 aWidth,
|
|
|
|
PRUint32 aHeight,
|
|
|
|
PRBool aRepaint)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Enable/disable this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Enable(PRBool bState)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
::EnableWindow(mWnd, bState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Give the focus to this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::SetFocus(void)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
|
|
|
//
|
|
|
|
if (!mToolkit->IsGuiThread()) {
|
|
|
|
MethodInfo info(this, nsWindow::SET_FOCUS);
|
|
|
|
mToolkit->CallMethod(&info);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mWnd) {
|
|
|
|
::SetFocus(mWnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component dimension
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::GetBounds(nsRect &aRect)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
1998-06-01 17:04:16 +00:00
|
|
|
VERIFY(::GetClientRect(mWnd, &r));
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// 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) {
|
1998-06-16 17:16:59 +00:00
|
|
|
RECT pr;
|
|
|
|
VERIFY(::GetClientRect(parent, &pr));
|
|
|
|
VERIFY(::ClientToScreen(mWnd, (LPPOINT)&r));
|
|
|
|
VERIFY(::ClientToScreen(parent, (LPPOINT)&pr));
|
|
|
|
r.left -= pr.left;
|
|
|
|
r.top -= pr.top;
|
|
|
|
}
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//get the bounds, but don't take into account the client size
|
|
|
|
|
|
|
|
void nsWindow::GetNonClientBounds(nsRect &aRect)
|
|
|
|
{
|
|
|
|
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;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the foreground color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nscolor nsWindow::GetForegroundColor(void)
|
|
|
|
{
|
|
|
|
return mForeground;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the foreground color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::SetForegroundColor(const nscolor &aColor)
|
|
|
|
{
|
|
|
|
mForeground = aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the background color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nscolor nsWindow::GetBackgroundColor(void)
|
|
|
|
{
|
|
|
|
return mBackground;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the background color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::SetBackgroundColor(const nscolor &aColor)
|
|
|
|
{
|
|
|
|
mBackground = 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-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
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::SetFont(const nsFont &aFont)
|
|
|
|
{
|
|
|
|
nsIFontCache* fontCache = mContext->GetFontCache();
|
|
|
|
nsIFontMetrics* metrics = fontCache->GetMetricsFor(aFont);
|
|
|
|
HFONT hfont = metrics->GetFontHandle();
|
|
|
|
|
|
|
|
// Draw in the new font
|
|
|
|
::SendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0);
|
|
|
|
NS_RELEASE(metrics);
|
|
|
|
NS_RELEASE(fontCache);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component cursor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsCursor nsWindow::GetCursor()
|
|
|
|
{
|
|
|
|
return mCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this component cursor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define DLLQUOTE(x) #x
|
|
|
|
#define DLLNAME(x) DLLQUOTE(x)
|
|
|
|
|
|
|
|
void nsWindow::SetCursor(nsCursor aCursor)
|
|
|
|
{
|
|
|
|
// Only change cursor if it's changing
|
|
|
|
if (aCursor != mCursor) {
|
|
|
|
HCURSOR newCursor = NULL;
|
1998-08-07 14:45:46 +00:00
|
|
|
HMODULE hm ;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
switch(aCursor) {
|
|
|
|
case eCursor_select:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_IBEAM);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_wait:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_WAIT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_hyperlink: {
|
1998-08-07 14:45:46 +00:00
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
1998-04-13 20:24:54 +00:00
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_SELECTANCHOR));
|
|
|
|
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:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWNORTH));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_north_plus:
|
|
|
|
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWNORTHPLUS));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_south:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWSOUTH));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_south_plus:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWSOUTHPLUS));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_east:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWEAST));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_east_plus:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWEASTPLUS));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_west:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWWEST));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_arrow_west_plus:
|
|
|
|
hm = ::GetModuleHandle(DLLNAME(NS_DLLNAME));
|
|
|
|
newCursor = ::LoadCursor(hm, MAKEINTRESOURCE(IDC_ARROWWESTPLUS));
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invalidate this component visible area
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Invalidate(PRBool aIsSynchronous)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
VERIFY(::InvalidateRect(mWnd, NULL, TRUE));
|
|
|
|
if (aIsSynchronous) {
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// 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:
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Create a rendering context from this nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIRenderingContext* nsWindow::GetRenderingContext()
|
|
|
|
{
|
|
|
|
nsRect bounds;
|
|
|
|
|
|
|
|
nsIRenderingContext *renderingCtx = NULL;
|
|
|
|
if (mWnd) {
|
|
|
|
HDC aDC = ::GetDC(mWnd);
|
|
|
|
nsresult res;
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
|
|
|
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
|
|
|
|
|
|
|
res = NSRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&renderingCtx);
|
|
|
|
|
|
|
|
if (NS_OK == res)
|
|
|
|
renderingCtx->Init(mContext, (nsDrawingSurface)aDC);
|
|
|
|
|
|
|
|
NS_ASSERTION(NULL != renderingCtx, "Null rendering context");
|
|
|
|
}
|
|
|
|
|
|
|
|
return renderingCtx;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return the toolkit this widget was created on
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIToolkit* nsWindow::GetToolkit()
|
|
|
|
{
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_IF_ADDREF(mToolkit);
|
|
|
|
return mToolkit;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the colormap of the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::SetColorMap(nsColorMap *aColorMap)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return the used device context
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIDeviceContext* nsWindow::GetDeviceContext()
|
1998-08-06 05:06:24 +00:00
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mContext);
|
|
|
|
return mContext;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-07-29 18:51:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return the App Shell
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsIAppShell *nsWindow::GetAppShell()
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mAppShell);
|
|
|
|
return mAppShell;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Scroll the bits of a window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
|
|
|
|
{
|
|
|
|
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-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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// OnKey
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode)
|
|
|
|
{
|
1998-04-24 23:09:11 +00:00
|
|
|
nsKeyEvent event;
|
|
|
|
InitEvent(event, aEventType);
|
|
|
|
event.keyCode = aKeyCode;
|
|
|
|
event.isShift = mIsShiftDown;
|
|
|
|
event.isControl = mIsControlDown;
|
|
|
|
event.isAlt = mIsAltDown;
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_KEY_EVENT;
|
1998-04-24 23:09:11 +00:00
|
|
|
return(DispatchEvent(&event));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Process all nsWindows messages
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE; // call the default nsWindow proc
|
1998-04-17 00:16:11 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
*aRetValue = 0;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
|
1998-06-01 17:04:16 +00:00
|
|
|
case WM_COMMAND: {
|
|
|
|
WORD wNotifyCode = HIWORD(wParam); // notification code
|
|
|
|
if (wNotifyCode == 0) { // Menu selection
|
|
|
|
nsMenuEvent event;
|
|
|
|
event.menuItem = 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);
|
|
|
|
result = DispatchEvent(&event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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-05-18 17:55:34 +00:00
|
|
|
case TTN_SHOW: {
|
|
|
|
nsTooltipEvent event;
|
|
|
|
InitEvent(event, NS_SHOW_TOOLTIP);
|
|
|
|
event.tipIndex = (PRUint32)wParam;
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_TOOLTIP_EVENT;
|
1998-05-18 17:55:34 +00:00
|
|
|
result = DispatchEvent(&event);
|
|
|
|
}
|
|
|
|
break;
|
1998-05-04 19:25:25 +00:00
|
|
|
|
|
|
|
case TTN_POP:
|
|
|
|
result = DispatchStandardEvent(NS_HIDE_TOOLTIP);
|
|
|
|
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
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
// clean up.
|
|
|
|
OnDestroy();
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
result = OnPaint();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYUP:
|
|
|
|
if (wParam == NS_VK_SHIFT) {
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
}
|
|
|
|
if (wParam == NS_VK_CONTROL) {
|
|
|
|
mIsControlDown = PR_FALSE;
|
|
|
|
}
|
|
|
|
if (wParam == NS_VK_ALT) {
|
|
|
|
mIsAltDown = PR_FALSE;
|
|
|
|
}
|
|
|
|
result = OnKey(NS_KEY_UP, wParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
if (wParam == NS_VK_SHIFT) {
|
|
|
|
mIsShiftDown = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (wParam == NS_VK_CONTROL) {
|
|
|
|
mIsControlDown = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (wParam == NS_VK_ALT) {
|
|
|
|
mIsAltDown = PR_TRUE;
|
|
|
|
}
|
|
|
|
result = OnKey(NS_KEY_DOWN, wParam);
|
|
|
|
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:
|
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_DOWN);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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:
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_LEFT_BUTTON_DOWN);
|
1998-04-29 19:59:06 +00:00
|
|
|
if (result == PR_FALSE)
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_LEFT_DOUBLECLICK);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_MIDDLE_BUTTON_DOWN);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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:
|
1998-04-29 19:59:06 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_DOWN);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_UP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_BUTTON_DOWN);
|
1998-04-29 19:59:06 +00:00
|
|
|
if (result == PR_FALSE)
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_RIGHT_DOUBLECLICK);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_HSCROLL:
|
|
|
|
case WM_VSCROLL:
|
|
|
|
// 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:
|
1998-04-13 20:24:54 +00:00
|
|
|
case WM_CTLCOLORSCROLLBAR:
|
|
|
|
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;
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
case WM_SETFOCUS:
|
1998-04-13 20:24:54 +00:00
|
|
|
result = DispatchFocus(NS_GOTFOCUS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KILLFOCUS:
|
|
|
|
result = DispatchFocus(NS_LOSTFOCUS);
|
1998-08-07 04:45:03 +00:00
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
::GetClientRect(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);
|
|
|
|
if (newWidth > mWidth)
|
|
|
|
{
|
|
|
|
RECT drect;
|
|
|
|
|
|
|
|
//getting wider
|
|
|
|
|
|
|
|
drect.left = wp->x + mWidth;
|
|
|
|
drect.top = wp->y;
|
|
|
|
drect.right = drect.left + (newWidth - mWidth);
|
|
|
|
drect.bottom = drect.top + newHeight;
|
|
|
|
|
|
|
|
// ::InvalidateRect(mWnd, &drect, FALSE);
|
|
|
|
::RedrawWindow(mWnd, &drect, NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
|
|
|
|
}
|
|
|
|
if (newHeight > mHeight)
|
|
|
|
{
|
|
|
|
RECT drect;
|
|
|
|
|
|
|
|
//getting taller
|
|
|
|
|
|
|
|
drect.left = wp->x;
|
|
|
|
drect.top = wp->y + mHeight;
|
|
|
|
drect.right = drect.left + newWidth;
|
|
|
|
drect.bottom = drect.top + (newHeight - mHeight);
|
|
|
|
|
|
|
|
// ::InvalidateRect(mWnd, &drect, FALSE);
|
|
|
|
::RedrawWindow(mWnd, &drect, NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
|
|
|
|
}
|
|
|
|
mWidth = newWidth;
|
|
|
|
mHeight = newHeight;
|
1998-06-02 02:33:29 +00:00
|
|
|
///nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
|
|
|
|
result = OnResize(rect);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_QUERYNEWPALETTE:
|
|
|
|
if (mPalette) {
|
|
|
|
HDC hDC = ::GetDC(mWnd);
|
|
|
|
HPALETTE hOldPal = ::SelectPalette(hDC, mPalette, 0);
|
|
|
|
|
|
|
|
int i = ::RealizePalette(hDC);
|
|
|
|
|
|
|
|
::SelectPalette(hDC, hOldPal, 0);
|
|
|
|
::ReleaseDC(mWnd, hDC);
|
|
|
|
|
|
|
|
if (i) {
|
|
|
|
::InvalidateRect(mWnd, (LPRECT)(NULL), 1);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_PALETTECHANGED:
|
|
|
|
if (mPalette && (HWND)wParam != mWnd) {
|
|
|
|
HDC hDC = ::GetDC(mWnd);
|
|
|
|
HPALETTE hOldPal = ::SelectPalette(hDC, mPalette, 0);
|
|
|
|
|
|
|
|
int i = ::RealizePalette(hDC);
|
|
|
|
|
|
|
|
if (i) {
|
|
|
|
::InvalidateRect(mWnd, (LPRECT)(NULL), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
::SelectPalette(hDC, hOldPal, 0);
|
|
|
|
::ReleaseDC(mWnd, hDC);
|
|
|
|
}
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// 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;
|
1998-04-13 20:24:54 +00:00
|
|
|
wc.lpfnWndProc = ::DefWindowProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = nsToolkit::mDllInstance;
|
|
|
|
wc.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
return WS_EX_CLIENTEDGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Subclass (or remove the subclass from) this component's nsWindow
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void nsWindow::SubclassWindow(BOOL bState)
|
|
|
|
{
|
|
|
|
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 {
|
|
|
|
(void) ::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
|
|
|
|
mPrevWndProc = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// WM_DESTROY has been called
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::OnDestroy()
|
|
|
|
{
|
|
|
|
SubclassWindow(FALSE);
|
|
|
|
mWnd = 0;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// free tooltip window
|
|
|
|
if (mTooltip) {
|
|
|
|
VERIFY(::DestroyWindow(mTooltip));
|
|
|
|
mTooltip = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// 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-08-06 05:06:24 +00:00
|
|
|
NS_IF_RELEASE(mChildren);
|
|
|
|
NS_IF_RELEASE(mContext);
|
|
|
|
NS_IF_RELEASE(mToolkit);
|
1998-08-09 01:37:30 +00:00
|
|
|
NS_IF_RELEASE(mAppShell);
|
1998-08-06 02:11:43 +00:00
|
|
|
|
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-05-29 22:44:13 +00:00
|
|
|
return DispatchEvent(&event);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Paint
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnPaint()
|
|
|
|
{
|
|
|
|
nsRect bounds;
|
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hDC = ::BeginPaint(mWnd, &ps);
|
|
|
|
|
1998-07-21 18:04:18 +00:00
|
|
|
|
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
|
|
|
|
if (mEventCallback) {
|
|
|
|
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
|
|
|
|
1998-06-19 02:46:25 +00:00
|
|
|
::EndPaint(mWnd, &ps);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
|
|
|
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
|
|
|
|
|
|
|
if (NS_OK == NSRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext))
|
|
|
|
{
|
1998-06-19 02:46:25 +00:00
|
|
|
hDC = ::GetDC(mWnd);
|
1998-04-13 20:24:54 +00:00
|
|
|
event.renderingContext->Init(mContext, (nsDrawingSurface)hDC);
|
1998-04-24 23:09:11 +00:00
|
|
|
result = DispatchEvent(&event);
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_RELEASE(event.renderingContext);
|
1998-06-19 02:46:25 +00:00
|
|
|
::ReleaseDC(mWnd, hDC);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
1998-06-19 02:46:25 +00:00
|
|
|
else
|
|
|
|
::EndPaint(mWnd, &ps);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-06-19 02:46:25 +00:00
|
|
|
else
|
|
|
|
::EndPaint(mWnd, &ps);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-06-19 02:46:25 +00:00
|
|
|
// ::EndPaint(mWnd, &ps);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Send a resize message to the listener
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
|
|
|
{
|
|
|
|
// call the event callback
|
|
|
|
if (mEventCallback) {
|
|
|
|
nsSizeEvent event;
|
1998-04-24 23:09:11 +00:00
|
|
|
InitEvent(event, NS_SIZE);
|
1998-04-13 20:24:54 +00:00
|
|
|
event.windowSize = &aWindowRect;
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_SIZE_EVENT;
|
1998-04-24 23:09:11 +00:00
|
|
|
return(DispatchEvent(&event));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
1998-05-08 14:54:09 +00:00
|
|
|
event.isShift = GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0;
|
|
|
|
event.isControl = GetKeyState(VK_LCONTROL) < 0 || GetKeyState(VK_RCONTROL) < 0;
|
|
|
|
event.isAlt = GetKeyState(VK_LMENU) < 0 || GetKeyState(VK_RMENU) < 0;
|
|
|
|
event.clickCount = (aEventType == NS_MOUSE_LEFT_DOUBLECLICK ||
|
|
|
|
aEventType == NS_MOUSE_LEFT_DOUBLECLICK)? 2:1;
|
1998-07-23 02:55:33 +00:00
|
|
|
event.eventStructType = NS_MOUSE_EVENT;
|
1998-05-08 14:54:09 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// call the event callback
|
|
|
|
if (nsnull != mEventCallback) {
|
1998-05-29 22:44:13 +00:00
|
|
|
//printf(" %d %d %d (%d,%d) \n", event.widget, event.widgetSupports,
|
|
|
|
// event.message, event.point.x, event.point.y);
|
1998-04-24 23:09:11 +00:00
|
|
|
|
|
|
|
result = DispatchEvent(&event);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//printf("**result=%d%\n",result);
|
|
|
|
if (aEventType == NS_MOUSE_MOVE) {
|
|
|
|
|
|
|
|
MouseTrailer * mouseTrailer = MouseTrailer::GetMouseTrailer(0);
|
|
|
|
MouseTrailer::SetMouseTrailerWindow(this);
|
|
|
|
mouseTrailer->CreateTimer();
|
|
|
|
|
|
|
|
nsRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
//printf("Rect[%d, %d, %d, %d] Point[%d,%d]\n", rect.x, rect.y, rect.width, rect.height, event.position.x, event.position.y);
|
1998-05-29 22:44:13 +00:00
|
|
|
//printf("gCurrentWindow 0x%X\n", gCurrentWindow);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
1998-07-21 18:04:18 +00:00
|
|
|
//printf("Mouse enter");
|
1998-05-29 22:44:13 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with focus messages
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::DispatchFocus(PRUint32 aEventType)
|
|
|
|
{
|
|
|
|
// call the event callback
|
|
|
|
if (mEventCallback) {
|
1998-06-29 21:18:19 +00:00
|
|
|
if ((nsnull != gCurrentWindow) && (!gCurrentWindow->mIsDestroying)) {
|
1998-05-04 19:25:25 +00:00
|
|
|
return(DispatchStandardEvent(aEventType));
|
1998-06-29 21:18:19 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
#define INITIAL_SIZE 2
|
|
|
|
|
|
|
|
nsWindow::Enumerator::Enumerator()
|
|
|
|
{
|
1998-07-30 17:40:22 +00:00
|
|
|
mRefCnt = 1;
|
1998-04-13 20:24:54 +00:00
|
|
|
mArraySize = INITIAL_SIZE;
|
1998-08-06 05:06:24 +00:00
|
|
|
mChildrens = (nsIWidget**) new(nsIWidget*[mArraySize]);
|
|
|
|
memset(mChildrens, 0, sizeof(nsIWidget*) * mArraySize);
|
1998-04-13 20:24:54 +00:00
|
|
|
mCurrentPosition = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsWindow::Enumerator::~Enumerator()
|
|
|
|
{
|
1998-08-06 05:06:24 +00:00
|
|
|
if (mChildrens) {
|
1998-08-09 01:37:30 +00:00
|
|
|
// We add ref'd when adding the child widgets, so we need to release
|
|
|
|
// the references now
|
1998-08-06 05:06:24 +00:00
|
|
|
for (int i = 0; (i < mArraySize) && (nsnull != mChildrens[i]); i++) {
|
|
|
|
NS_RELEASE(mChildrens[i]);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-06 05:06:24 +00:00
|
|
|
|
|
|
|
delete[] mChildrens;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1998-04-14 23:20:49 +00:00
|
|
|
// nsISupports implementation macro
|
1998-04-13 20:24:54 +00:00
|
|
|
//
|
|
|
|
NS_IMPL_ISUPPORTS(nsWindow::Enumerator, NS_IENUMERATOR_IID);
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get enumeration next element. Return null at the end
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsISupports* nsWindow::Enumerator::Next()
|
|
|
|
{
|
|
|
|
if (mCurrentPosition < mArraySize && mChildrens[mCurrentPosition]) {
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(mChildrens[mCurrentPosition]);
|
1998-04-13 20:24:54 +00:00
|
|
|
return mChildrens[mCurrentPosition++];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Reset enumerator internal pointer to the beginning
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Enumerator::Reset()
|
|
|
|
{
|
|
|
|
mCurrentPosition = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Append an element
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Enumerator::Append(nsIWidget* aWidget)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aWidget, "Null widget");
|
|
|
|
if (aWidget) {
|
|
|
|
int pos;
|
|
|
|
for (pos = 0; pos < mArraySize && mChildrens[pos]; pos++);
|
|
|
|
if (pos == mArraySize) {
|
|
|
|
GrowArray();
|
|
|
|
}
|
|
|
|
mChildrens[pos] = aWidget;
|
1998-08-06 05:06:24 +00:00
|
|
|
NS_ADDREF(aWidget);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Remove an element
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Enumerator::Remove(nsIWidget* aWidget)
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
for(pos = 0; mChildrens[pos] && (mChildrens[pos] != aWidget); pos++);
|
|
|
|
if (mChildrens[pos] == aWidget) {
|
|
|
|
NS_RELEASE(aWidget);
|
|
|
|
memcpy(mChildrens + pos, mChildrens + pos + 1, mArraySize - pos - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Grow the size of the children array
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::Enumerator::GrowArray()
|
|
|
|
{
|
|
|
|
mArraySize <<= 1;
|
1998-08-06 05:06:24 +00:00
|
|
|
nsIWidget **newArray = (nsIWidget**) new(nsIWidget*[mArraySize]);
|
|
|
|
// XXX We really only need to zero out the new part of the space...
|
|
|
|
memset(newArray, 0, sizeof(nsIWidget*) * mArraySize);
|
|
|
|
memcpy(newArray, mChildrens, (mArraySize>>1) * sizeof(nsIWidget*));
|
|
|
|
delete[] mChildrens;
|
1998-04-13 20:24:54 +00:00
|
|
|
mChildrens = newArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return the style for a child nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD ChildWindow::WindowStyle()
|
|
|
|
{
|
1998-07-14 15:17:29 +00:00
|
|
|
return WS_CHILD | WS_CLIPCHILDREN | GetBorderStyle(mBorderStyle);
|
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:
|
|
|
|
SetCapture(mWnd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
|
|
|
case NS_MOUSE_RIGHT_BUTTON_UP:
|
|
|
|
ReleaseCapture();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
} // switch
|
|
|
|
|
|
|
|
return nsWindow::DispatchMouseEvent(aEventType, aPoint);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-17 23:45:07 +00:00
|
|
|
DWORD nsWindow::GetBorderStyle(nsBorderStyle aBorderStyle)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "unknown border style");
|
|
|
|
return(WS_OVERLAPPEDWINDOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsWindow::SetBorderStyle(nsBorderStyle aBorderStyle)
|
|
|
|
{
|
|
|
|
mBorderStyle = aBorderStyle;
|
|
|
|
}
|
|
|
|
|
1998-04-23 16:51:25 +00:00
|
|
|
void nsWindow::SetTitle(const nsString& aTitle)
|
1998-04-17 23:45:07 +00:00
|
|
|
{
|
|
|
|
NS_ALLOC_STR_BUF(buf, aTitle, 256);
|
|
|
|
::SendMessage(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCTSTR)buf);
|
|
|
|
NS_FREE_STR_BUF(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/**
|
|
|
|
* Processes a mouse pressed event
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
void nsWindow::AddMouseListener(nsIMouseListener * aListener)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(mMouseListener == nsnull, "Null mouse listener");
|
|
|
|
mMouseListener = aListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes a mouse pressed event
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
void nsWindow::AddEventListener(nsIEventListener * aListener)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(mEventListener == nsnull, "Null mouse listener");
|
|
|
|
mEventListener = aListener;
|
|
|
|
}
|
|
|
|
|
1998-04-28 19:24:52 +00:00
|
|
|
PRBool nsWindow::AutoErase()
|
|
|
|
{
|
|
|
|
return(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
1998-04-17 23:45:07 +00:00
|
|
|
|
|
|
|
|