зеркало из https://github.com/mozilla/gecko-dev.git
initial check in
This commit is contained in:
Родитель
7364d6fa4b
Коммит
48799ddd1f
|
@ -0,0 +1,108 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* 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 "nsAppShell.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the application shell
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void nsAppShell::Create(int* argc, char ** argv)
|
||||
{
|
||||
XtSetLanguageProc(NULL, NULL, NULL);
|
||||
mTopLevel = XtVaAppInitialize(&mAppContext, "nsAppShell", NULL,
|
||||
0, argc, argv, NULL, NULL);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Enter a message handler loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsresult nsAppShell::Run()
|
||||
{
|
||||
XtRealizeWidget(mTopLevel);
|
||||
XtAppMainLoop(mAppContext);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Exit a message handler loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void nsAppShell::Exit()
|
||||
{
|
||||
//PostQuitMessage(0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsAppShell::nsAppShell(nsISupports *aOuter) : nsObject(aOuter)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsAppShell::~nsAppShell()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsAppShell::QueryObject(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
static NS_DEFINE_IID(kInsAppShellIID, NS_IAPPSHELL_IID);
|
||||
if (result == NS_NOINTERFACE && aIID.Equals(kInsAppShellIID)) {
|
||||
*aInstancePtr = (void*) ((nsIAppShell*)this);
|
||||
AddRef();
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// GetNativeData
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void* nsAppShell::GetNativeData(PRUint32 aDataType)
|
||||
{
|
||||
if (aDataType == NS_NATIVE_SHELL) {
|
||||
return mTopLevel;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsAppShell_h__
|
||||
#define nsAppShell_h__
|
||||
|
||||
#include "nsObject.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
#include <Xm/MainW.h>
|
||||
|
||||
/**
|
||||
* Native MOTIF Application shell wrapper
|
||||
*/
|
||||
|
||||
class nsAppShell : public nsIAppShell, public nsObject
|
||||
{
|
||||
private:
|
||||
Widget mTopLevel;
|
||||
XtAppContext mAppContext;
|
||||
|
||||
public:
|
||||
nsAppShell(nsISupports *aOuter);
|
||||
virtual ~nsAppShell();
|
||||
|
||||
// nsISupports. Forward to the nsObject base class
|
||||
BASE_SUPPORT
|
||||
|
||||
virtual nsresult QueryObject(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
// nsIAppShellInterface
|
||||
|
||||
virtual void Create(int* argc, char ** argv);
|
||||
virtual nsresult Run();
|
||||
virtual void Exit();
|
||||
|
||||
virtual void* GetNativeData(PRUint32 aDataType);
|
||||
|
||||
};
|
||||
|
||||
#endif // nsAppShell_h__
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
/* -*- 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 "nsButton.h"
|
||||
#include "nsIButton.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsXtEventHandler.h"
|
||||
|
||||
#include <Xm/PushB.h>
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsButton constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsButton::nsButton(nsISupports *aOuter) : nsWindow(aOuter)
|
||||
{
|
||||
}
|
||||
|
||||
void nsButton::Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
Widget parentWidget = nsnull;
|
||||
|
||||
//fprintf(stderr, "aParent 0x%x\n", aParent);
|
||||
|
||||
if (aParent) {
|
||||
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
} else {
|
||||
parentWidget = (Widget) aInitData ;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Parent 0x%x\n", parentWidget);
|
||||
|
||||
mWidget = ::XtVaCreateManagedWidget("button",
|
||||
xmPushButtonWidgetClass,
|
||||
parentWidget,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
XmNrecomputeSize, False,
|
||||
XmNhighlightOnEnter, False,
|
||||
XmNx, aRect.x,
|
||||
XmNy, aRect.y,
|
||||
nsnull);
|
||||
|
||||
fprintf(stderr, "Button 0x%x this 0x%x\n", mWidget, this);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
InitCallbacks();
|
||||
|
||||
}
|
||||
|
||||
void nsButton::Create(nsNativeWindow aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsButton destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsButton::~nsButton()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsButton::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
|
||||
if (aIID.Equals(kIButtonIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
NS_ALLOC_STR_BUF(label, aText, 256);
|
||||
XmString str;
|
||||
str = XmStringCreate(label, XmFONTLIST_DEFAULT_TAG);
|
||||
XtVaSetValues(mWidget, XmNlabelString, str, nsnull);
|
||||
NS_FREE_STR_BUF(label);
|
||||
XmStringFree(str);
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
XmString str;
|
||||
XtVaGetValues(mWidget, XmNlabelString, &str, nsnull);
|
||||
char * text;
|
||||
if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &text)) {
|
||||
aBuffer.SetLength(0);
|
||||
aBuffer.Append(text);
|
||||
XtFree(text);
|
||||
}
|
||||
|
||||
XmStringFree(str);
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// paint message. Don't send the paint out
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsButton::OnPaint(nsPaintEvent &aEvent)
|
||||
{
|
||||
//printf("** nsButton::OnPaint **\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsButton::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
#define GET_OUTER() ((nsButton*) ((char*)this - nsButton::GetOuterOffset()))
|
||||
|
||||
void nsButton::AggButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
GET_OUTER()->GetLabel(aBuffer);
|
||||
}
|
||||
|
||||
void nsButton::AggButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
GET_OUTER()->SetLabel(aText);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
BASE_IWIDGET_IMPL(nsButton, AggButton);
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsButton_h__
|
||||
#define nsButton_h__
|
||||
|
||||
//#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsIButton.h"
|
||||
|
||||
/**
|
||||
* Native Motif button wrapper
|
||||
*/
|
||||
|
||||
class nsButton : public nsWindow
|
||||
{
|
||||
|
||||
public:
|
||||
nsButton(nsISupports *aOuter);
|
||||
virtual ~nsButton();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
void Create(nsNativeWindow aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
|
||||
// nsIButton part
|
||||
virtual void SetLabel(const nsString& aText);
|
||||
virtual void GetLabel(nsString& aBuffer);
|
||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
private:
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsButton,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIButton interface to nsButton w/o using multiple
|
||||
// inheritance.
|
||||
class AggButton : public nsIButton {
|
||||
public:
|
||||
AggButton();
|
||||
virtual ~AggButton();
|
||||
|
||||
AGGRRGATE_METHOD_DEF
|
||||
|
||||
// nsIButton
|
||||
virtual void SetLabel(const nsString &aText);
|
||||
virtual void GetLabel(nsString &aBuffer);
|
||||
|
||||
};
|
||||
AggButton mAggWidget;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // nsButton_h__
|
|
@ -0,0 +1,532 @@
|
|||
/* -*- 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 "nsScrollbar.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsUnitConversion.h"
|
||||
#include <Xm/ScrollBar.h>
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsScrollbar constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsScrollbar::nsScrollbar(nsISupports *aOuter, PRBool aIsVertical) : nsWindow(aOuter)
|
||||
{
|
||||
//mPositionFlag = (aIsVertical) ? SBS_VERT : SBS_HORZ;
|
||||
//mScaleFactor = 1.0;
|
||||
//mLineIncrement = 0;
|
||||
//mBackground = ::GetSysColor(COLOR_SCROLLBAR);
|
||||
//mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
Widget parentWidget = nsnull;
|
||||
|
||||
//fprintf(stderr, "aParent 0x%x\n", aParent);
|
||||
|
||||
if (aParent) {
|
||||
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
} else {
|
||||
parentWidget = (Widget) aInitData ;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Parent 0x%x\n", parentWidget);
|
||||
|
||||
mWidget = ::XtVaCreateManagedWidget("button",
|
||||
xmScrollBarWidgetClass,
|
||||
parentWidget,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
XmNrecomputeSize, False,
|
||||
XmNhighlightOnEnter, False,
|
||||
XmNx, aRect.x,
|
||||
XmNy, aRect.y,
|
||||
nsnull);
|
||||
|
||||
fprintf(stderr, "Button 0x%x this 0x%x\n", mWidget, this);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
//InitCallbacks();
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::Create(nsNativeWindow aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsScrollbar destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsScrollbar::~nsScrollbar()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kInsScrollbarIID, NS_ISCROLLBAR_IID);
|
||||
|
||||
if (aIID.Equals(kInsScrollbarIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Define the range settings
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::SetMaxRange(PRUint32 aEndRange)
|
||||
{
|
||||
//if (aEndRange > 32767)
|
||||
//mScaleFactor = aEndRange / 32767.0;
|
||||
//if (mWnd) {
|
||||
//VERIFY(::SetScrollRange(mWnd, SB_CTL, 0, NS_TO_INT_ROUND(aEndRange / mScaleFactor), TRUE));
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Return the range settings
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRUint32 nsScrollbar::GetMaxRange()
|
||||
{
|
||||
//int startRange, endRange;
|
||||
//if (mWnd) {
|
||||
//VERIFY(::GetScrollRange(mWnd, SB_CTL, &startRange, &endRange));
|
||||
//}
|
||||
|
||||
//return (PRUint32)NS_TO_INT_ROUND(endRange * mScaleFactor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the thumb position
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::SetPosition(PRUint32 aPos)
|
||||
{
|
||||
//::SetScrollPos(mWnd, SB_CTL, NS_TO_INT_ROUND(aPos / mScaleFactor), TRUE);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the current thumb position.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRUint32 nsScrollbar::GetPosition()
|
||||
{
|
||||
return (PRUint32)0;//NS_TO_INT_ROUND(::GetScrollPos(mWnd, SB_CTL) * mScaleFactor);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the thumb size
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::SetThumbSize(PRUint32 aSize)
|
||||
{
|
||||
//if (mWnd) {
|
||||
//SCROLLINFO si;
|
||||
//si.cbSize = sizeof(SCROLLINFO);
|
||||
//si.fMask = SIF_PAGE;
|
||||
//si.nPage = NS_TO_INT_ROUND(aSize / mScaleFactor);
|
||||
//::SetScrollInfo(mWnd, SB_CTL, &si, TRUE);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the thumb size
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRUint32 nsScrollbar::GetThumbSize()
|
||||
{
|
||||
//if (mWnd) {
|
||||
//SCROLLINFO si;
|
||||
//si.cbSize = sizeof(SCROLLINFO);
|
||||
//si.fMask = SIF_PAGE;
|
||||
//VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si));
|
||||
//return (PRUint32)NS_TO_INT_ROUND(si.nPage * mScaleFactor);
|
||||
//}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the line increment for this scrollbar
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::SetLineIncrement(PRUint32 aSize)
|
||||
{
|
||||
//mLineIncrement = NS_TO_INT_ROUND(aSize / mScaleFactor);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the line increment for this scrollbar
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRUint32 nsScrollbar::GetLineIncrement()
|
||||
{
|
||||
return (PRUint32)0;//NS_TO_INT_ROUND(mLineIncrement * mScaleFactor);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set all scrolling parameters
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
|
||||
PRUint32 aPosition, PRUint32 aLineIncrement)
|
||||
{
|
||||
//if (aMaxRange > 32767)
|
||||
//mScaleFactor = aMaxRange / 32767.0;
|
||||
|
||||
//if (mWnd) {
|
||||
//SCROLLINFO si;
|
||||
//si.cbSize = sizeof(SCROLLINFO);
|
||||
//si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
|
||||
//si.nPage = NS_TO_INT_ROUND(aThumbSize / mScaleFactor);
|
||||
//si.nPos = NS_TO_INT_ROUND(aPosition / mScaleFactor);
|
||||
//si.nMin = 0;
|
||||
//si.nMax = NS_TO_INT_ROUND(aMaxRange / mScaleFactor);
|
||||
//::SetScrollInfo(mWnd, SB_CTL, &si, TRUE);
|
||||
//}
|
||||
|
||||
//mLineIncrement = NS_TO_INT_ROUND(aLineIncrement / mScaleFactor);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// paint message. Don't send the paint out
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsScrollbar::OnPaint(nsPaintEvent & aEvent)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsScrollbar::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deal with scrollbar messages (actually implemented only in nsScrollbar)
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsScrollbar::OnScroll(PRUint32 scrollCode, PRUint32 cPos)
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
int newPosition;
|
||||
/*
|
||||
switch (scrollCode) {
|
||||
|
||||
// scroll one line right or down
|
||||
// SB_LINERIGHT and SB_LINEDOWN are actually the same value
|
||||
//case SB_LINERIGHT:
|
||||
case SB_LINEDOWN:
|
||||
{
|
||||
newPosition = ::GetScrollPos(mWnd, SB_CTL) + mLineIncrement;
|
||||
PRUint32 max = GetMaxRange() - GetThumbSize();
|
||||
if (newPosition > (int)max)
|
||||
newPosition = (int)max;
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
nsScrollbarEvent event;
|
||||
event.message = NS_SCROLLBAR_LINE_NEXT;
|
||||
event.widget = (nsWindow*)this;
|
||||
DWORD pos = ::GetMessagePos();
|
||||
POINT cpos;
|
||||
cpos.x = LOWORD(pos);
|
||||
cpos.y = HIWORD(pos);
|
||||
::ScreenToClient(mWnd, &cpos);
|
||||
event.point.x = cpos.x;
|
||||
event.point.y = cpos.y;
|
||||
event.time = ::GetMessageTime();
|
||||
event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor);
|
||||
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor);
|
||||
}
|
||||
|
||||
::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// scroll one line left or up
|
||||
//case SB_LINELEFT:
|
||||
case SB_LINEUP:
|
||||
{
|
||||
newPosition = ::GetScrollPos(mWnd, SB_CTL) - mLineIncrement;
|
||||
if (newPosition < 0)
|
||||
newPosition = 0;
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the decrement
|
||||
if (mEventCallback) {
|
||||
nsScrollbarEvent event;
|
||||
event.message = NS_SCROLLBAR_LINE_PREV;
|
||||
event.widget = (nsWindow*)this;
|
||||
DWORD pos = ::GetMessagePos();
|
||||
POINT cpos;
|
||||
cpos.x = LOWORD(pos);
|
||||
cpos.y = HIWORD(pos);
|
||||
::ScreenToClient(mWnd, &cpos);
|
||||
event.point.x = cpos.x;
|
||||
event.point.y = cpos.y;
|
||||
event.time = ::GetMessageTime();
|
||||
event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor);
|
||||
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor);
|
||||
}
|
||||
|
||||
::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Scrolls one page right or down
|
||||
// case SB_PAGERIGHT:
|
||||
case SB_PAGEDOWN:
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_PAGE;
|
||||
VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si));
|
||||
|
||||
newPosition = ::GetScrollPos(mWnd, SB_CTL) + si.nPage;
|
||||
PRUint32 max = GetMaxRange() - GetThumbSize();
|
||||
if (newPosition > (int)max)
|
||||
newPosition = (int)max;
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
nsScrollbarEvent event;
|
||||
event.message = NS_SCROLLBAR_PAGE_NEXT;
|
||||
event.widget = (nsWindow*)this;
|
||||
DWORD pos = ::GetMessagePos();
|
||||
POINT cpos;
|
||||
cpos.x = LOWORD(pos);
|
||||
cpos.y = HIWORD(pos);
|
||||
::ScreenToClient(mWnd, &cpos);
|
||||
event.point.x = cpos.x;
|
||||
event.point.y = cpos.y;
|
||||
event.time = ::GetMessageTime();
|
||||
event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor);;
|
||||
|
||||
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor);
|
||||
}
|
||||
|
||||
::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Scrolls one page left or up.
|
||||
//case SB_PAGELEFT:
|
||||
case SB_PAGEUP:
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_PAGE;
|
||||
VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si));
|
||||
|
||||
newPosition = ::GetScrollPos(mWnd, SB_CTL) - si.nPage;
|
||||
if (newPosition < 0)
|
||||
newPosition = 0;
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
nsScrollbarEvent event;
|
||||
event.message = NS_SCROLLBAR_PAGE_PREV;
|
||||
event.widget = (nsWindow*)this;
|
||||
DWORD pos = ::GetMessagePos();
|
||||
POINT cpos;
|
||||
cpos.x = LOWORD(pos);
|
||||
cpos.y = HIWORD(pos);
|
||||
::ScreenToClient(mWnd, &cpos);
|
||||
event.point.x = cpos.x;
|
||||
event.point.y = cpos.y;
|
||||
event.time = ::GetMessageTime();
|
||||
event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor);
|
||||
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor);
|
||||
}
|
||||
|
||||
::SetScrollPos(mWnd, SB_CTL, newPosition - 10, TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Scrolls to the absolute position. The current position is specified by
|
||||
// the cPos parameter.
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
{
|
||||
newPosition = cPos;
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
nsScrollbarEvent event;
|
||||
event.message = NS_SCROLLBAR_POS;
|
||||
event.widget = (nsWindow*)this;
|
||||
DWORD pos = ::GetMessagePos();
|
||||
POINT cpos;
|
||||
cpos.x = LOWORD(pos);
|
||||
cpos.y = HIWORD(pos);
|
||||
::ScreenToClient(mWnd, &cpos);
|
||||
event.point.x = cpos.x;
|
||||
event.point.y = cpos.y;
|
||||
event.time = ::GetMessageTime();
|
||||
event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor);
|
||||
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
newPosition = NS_TO_INT_ROUND(event.position * mScaleFactor);
|
||||
}
|
||||
|
||||
::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
#define GET_OUTER() ((nsScrollbar*) ((char*)this - nsScrollbar::GetOuterOffset()))
|
||||
|
||||
// nsIScrollbar part
|
||||
void nsScrollbar::AggScrollbar::SetMaxRange(PRUint32 aEndRange)
|
||||
{
|
||||
GET_OUTER()->SetMaxRange(aEndRange);
|
||||
}
|
||||
|
||||
PRUint32 nsScrollbar::AggScrollbar::GetMaxRange()
|
||||
{
|
||||
return GET_OUTER()->GetMaxRange();
|
||||
}
|
||||
|
||||
void nsScrollbar::AggScrollbar::SetPosition(PRUint32 aPos)
|
||||
{
|
||||
GET_OUTER()->SetPosition(aPos);
|
||||
}
|
||||
|
||||
PRUint32 nsScrollbar::AggScrollbar::GetPosition()
|
||||
{
|
||||
return GET_OUTER()->GetPosition();
|
||||
}
|
||||
|
||||
void nsScrollbar::AggScrollbar::SetThumbSize(PRUint32 aSize)
|
||||
{
|
||||
GET_OUTER()->SetThumbSize(aSize);
|
||||
}
|
||||
|
||||
PRUint32 nsScrollbar::AggScrollbar::GetThumbSize()
|
||||
{
|
||||
return GET_OUTER()->GetThumbSize();
|
||||
}
|
||||
|
||||
void nsScrollbar::AggScrollbar::SetLineIncrement(PRUint32 aSize)
|
||||
{
|
||||
GET_OUTER()->SetLineIncrement(aSize);
|
||||
}
|
||||
|
||||
PRUint32 nsScrollbar::AggScrollbar::GetLineIncrement()
|
||||
{
|
||||
return GET_OUTER()->GetLineIncrement();
|
||||
}
|
||||
|
||||
void nsScrollbar::AggScrollbar::SetParameters(PRUint32 aMaxRange,
|
||||
PRUint32 aThumbSize,
|
||||
PRUint32 aPosition,
|
||||
PRUint32 aLineIncrement)
|
||||
{
|
||||
GET_OUTER()->SetParameters(aMaxRange, aThumbSize, aPosition, aLineIncrement);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
BASE_IWIDGET_IMPL(nsScrollbar, AggScrollbar);
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsScrollbar_h__
|
||||
#define nsScrollbar_h__
|
||||
|
||||
#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
#include "nsIScrollbar.h"
|
||||
|
||||
/**
|
||||
* Native Motif scrollbar wrapper.
|
||||
*/
|
||||
|
||||
class nsScrollbar : public nsWindow
|
||||
{
|
||||
|
||||
public:
|
||||
nsScrollbar(nsISupports *aOuter, PRBool aIsVertical);
|
||||
virtual ~nsScrollbar();
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
void Create(nsNativeWindow aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
|
||||
// nsIScrollbar part
|
||||
virtual void SetMaxRange(PRUint32 aEndRange);
|
||||
virtual PRUint32 GetMaxRange();
|
||||
virtual void SetPosition(PRUint32 aPos);
|
||||
virtual PRUint32 GetPosition();
|
||||
virtual void SetThumbSize(PRUint32 aSize);
|
||||
virtual PRUint32 GetThumbSize();
|
||||
virtual void SetLineIncrement(PRUint32 aSize);
|
||||
virtual PRUint32 GetLineIncrement();
|
||||
virtual void SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
|
||||
PRUint32 aPosition, PRUint32 aLineIncrement);
|
||||
|
||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||
virtual PRBool OnScroll(PRUint32 scrollCode, PRUint32 cPos);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
|
||||
private:
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsScrollbar,mAggWidget);
|
||||
}
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIButton interface to nsButton w/o using multiple
|
||||
// inheritance.
|
||||
class AggScrollbar : public nsIScrollbar {
|
||||
public:
|
||||
AggScrollbar();
|
||||
virtual ~AggScrollbar();
|
||||
|
||||
AGGRRGATE_METHOD_DEF
|
||||
|
||||
// nsIScrollbar part
|
||||
virtual void SetMaxRange(PRUint32 aEndRange);
|
||||
virtual PRUint32 GetMaxRange();
|
||||
virtual void SetPosition(PRUint32 aPos);
|
||||
virtual PRUint32 GetPosition();
|
||||
virtual void SetThumbSize(PRUint32 aSize);
|
||||
virtual PRUint32 GetThumbSize();
|
||||
virtual void SetLineIncrement(PRUint32 aSize);
|
||||
virtual PRUint32 GetLineIncrement();
|
||||
virtual void SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
|
||||
PRUint32 aPosition, PRUint32 aLineIncrement);
|
||||
};
|
||||
AggScrollbar mAggWidget;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScrollbar_
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
#include "nsToolkit.h"
|
||||
#include "nsWindow.h"
|
||||
#include "prmon.h"
|
||||
#include "prtime.h"
|
||||
//#include "prmon.h"
|
||||
//#include "prtime.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
|
||||
|
|
|
@ -33,15 +33,14 @@ class nsToolkit : public nsIToolkit
|
|||
{
|
||||
|
||||
public:
|
||||
nsToolkit();
|
||||
nsToolkit();
|
||||
virtual ~nsToolkit();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual void Init(PRThread *aThread);
|
||||
|
||||
|
||||
private:
|
||||
~nsToolkit();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -18,18 +18,29 @@
|
|||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIButton.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include "nsToolkit.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsButton.h"
|
||||
#include "nsScrollbar.h"
|
||||
|
||||
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kIWidget, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
||||
static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_IID(kCHorzScrollbarCID, NS_HORZSCROLLBAR_CID);
|
||||
static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID);
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIWidget, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID);
|
||||
static NS_DEFINE_IID(kIScrollbar, NS_ISCROLLBAR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
|
||||
|
||||
class nsWidgetFactory : public nsIFactory
|
||||
{
|
||||
|
@ -44,15 +55,18 @@ public:
|
|||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsWidgetFactory();
|
||||
nsWidgetFactory(const nsCID &aClass);
|
||||
~nsWidgetFactory();
|
||||
private:
|
||||
nsCID mClassID;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
nsWidgetFactory::nsWidgetFactory()
|
||||
nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
|
||||
{
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
nsWidgetFactory::~nsWidgetFactory()
|
||||
|
@ -88,6 +102,8 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
fprintf(stderr, "_________________________________\n");
|
||||
fprintf(stderr, "Entering Eidget Factory\n");fflush(stderr);
|
||||
if (aResult == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -99,16 +115,44 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
|
||||
nsIWidget *inst = nsnull;
|
||||
if (aIID.Equals(kCWindow)) {
|
||||
inst = (nsIWidget*)new nsWindow(aOuter);
|
||||
}
|
||||
else if (aIID.Equals(kIButton)) {
|
||||
inst = (nsIWidget*)new nsButton(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCVertScrollbarCID)) {
|
||||
inst = (nsIWidget*)new nsScrollbar(aOuter, PR_TRUE);
|
||||
fprintf(stderr, "Created Vert Scrollbar\n");
|
||||
}
|
||||
else if (mClassID.Equals(kCHorzScrollbarCID)) {
|
||||
inst = (nsIWidget*)new nsScrollbar(aOuter, PR_FALSE);
|
||||
fprintf(stderr, "Created Horz Scrollbar\n");
|
||||
}
|
||||
else if (aIID.Equals(kIScrollbar)) {
|
||||
inst = (nsIWidget*)nsnull;
|
||||
fprintf(stderr, "------ kIScrollbar Scrollbar\n");
|
||||
}
|
||||
else if (aIID.Equals(kIWidget)) {
|
||||
inst = (nsIWidget*)new nsWindow(aOuter);
|
||||
}
|
||||
else if (aIID.Equals(kCChild)) {
|
||||
else if (mClassID.Equals(kCChild)) {
|
||||
inst = (nsIWidget*)new ChildWindow(aOuter);
|
||||
}
|
||||
|
||||
else if (aIID.Equals(kIAppShellIID)) {
|
||||
nsIAppShell *appInst = (nsIAppShell*)new nsAppShell(aOuter);
|
||||
if (appInst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res = appInst->QueryInterface(aIID, aResult);
|
||||
if (res != NS_OK) {
|
||||
delete appInst ;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -135,11 +179,12 @@ nsresult nsWidgetFactory::LockFactory(PRBool aLock)
|
|||
// return the proper factory to the caller
|
||||
extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
|
||||
{
|
||||
fprintf(stderr, "**** Factory created\n");
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aFactory = new nsWidgetFactory();
|
||||
*aFactory = new nsWidgetFactory(aClass);
|
||||
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "nsXtEventHandler.h"
|
||||
|
||||
#include "X11/Xlib.h"
|
||||
#include "Xm/Xm.h"
|
||||
#include "Xm/Xm.h"
|
||||
#include "Xm/MainW.h"
|
||||
#include "Xm/Frame.h"
|
||||
|
@ -85,14 +87,19 @@ void nsWindow::RemoveTooltips()
|
|||
// nsWindow constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsWindow::nsWindow(nsISupports *aOuter)
|
||||
nsWindow::nsWindow(nsISupports *aOuter):
|
||||
mEventListener(nsnull),
|
||||
mMouseListener(nsnull),
|
||||
mToolkit(nsnull),
|
||||
mFontMetrics(nsnull),
|
||||
mContext(nsnull),
|
||||
mWidget(nsnull),
|
||||
mEventCallback(nsnull)
|
||||
{
|
||||
// XXX Til can deal with ColorMaps!
|
||||
SetForegroundColor(1);
|
||||
SetBackgroundColor(2);
|
||||
|
||||
mToolkit = nsnull ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,7 +165,7 @@ void nsWindow::Create(nsIWidget *aParent,
|
|||
|
||||
#define GFXWIN_DLL "libgfxunix.so"
|
||||
|
||||
static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID);
|
||||
/*static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);
|
||||
static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);
|
||||
|
@ -168,32 +175,35 @@ void nsWindow::Create(nsIWidget *aParent,
|
|||
NSRepository::RegisterFactory(kCFontMetricsIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
|
||||
NSRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
|
||||
*/
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
|
||||
//res = !NS_OK;
|
||||
res = NSRepository::CreateInstance(kDeviceContextCID,
|
||||
nsnull,
|
||||
kDeviceContextIID,
|
||||
(void **)&mContext);
|
||||
|
||||
if (NS_OK == res)
|
||||
if (NS_OK == res) {
|
||||
mContext->Init();
|
||||
}
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
if (aParent) {
|
||||
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
else
|
||||
} else {
|
||||
parentWidget = (Widget) aInitData ;
|
||||
}
|
||||
|
||||
if (!aParent)
|
||||
if (!aParent) {
|
||||
mainWindow = ::XtVaCreateManagedWidget("mainWindow",
|
||||
xmMainWindowWidgetClass,
|
||||
parentWidget,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
nsnull);
|
||||
}
|
||||
|
||||
frame = ::XtVaCreateManagedWidget("frame",
|
||||
xmDrawingAreaWidgetClass,
|
||||
|
@ -202,8 +212,9 @@ void nsWindow::Create(nsIWidget *aParent,
|
|||
XmNheight, aRect.height,
|
||||
nsnull);
|
||||
|
||||
if (!aParent)
|
||||
if (!aParent) {
|
||||
XmMainWindowSetAreas (mainWindow, nsnull, nsnull, nsnull, nsnull, frame);
|
||||
}
|
||||
|
||||
mWidget = frame ;
|
||||
|
||||
|
@ -211,13 +222,28 @@ void nsWindow::Create(nsIWidget *aParent,
|
|||
aParent->AddChild(this);
|
||||
}
|
||||
|
||||
// setup the event Handlers
|
||||
// Force cursor to default setting
|
||||
mCursor = eCursor_select;
|
||||
SetCursor(eCursor_standard);
|
||||
|
||||
XtAddEventHandler(mWidget,
|
||||
ExposureMask,
|
||||
PR_FALSE,
|
||||
nsXtWidget_ExposureMask_EventHandler,
|
||||
this);
|
||||
|
||||
InitCallbacks();
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Initialize all the Callbacks
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::InitCallbacks()
|
||||
{
|
||||
// setup the event Handlers
|
||||
XtAddEventHandler(mWidget,
|
||||
ButtonPressMask,
|
||||
PR_FALSE,
|
||||
|
@ -236,10 +262,23 @@ void nsWindow::Create(nsIWidget *aParent,
|
|||
nsXtWidget_ButtonMotionMask_EventHandler,
|
||||
this);
|
||||
|
||||
XtAddEventHandler(mWidget,
|
||||
PointerMotionMask,
|
||||
PR_FALSE,
|
||||
nsXtWidget_MotionMask_EventHandler,
|
||||
this);
|
||||
|
||||
// Force cursor to default setting
|
||||
mCursor = eCursor_select;
|
||||
SetCursor(eCursor_standard);
|
||||
XtAddEventHandler(mWidget,
|
||||
EnterWindowMask,
|
||||
PR_FALSE,
|
||||
nsXtWidget_EnterMask_EventHandler,
|
||||
this);
|
||||
|
||||
XtAddEventHandler(mWidget,
|
||||
LeaveWindowMask,
|
||||
PR_FALSE,
|
||||
nsXtWidget_LeaveMask_EventHandler,
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
|
@ -256,6 +295,7 @@ void nsWindow::Create(nsNativeWindow aParent,
|
|||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
NS_ASSERTION(0, "nsWindow Constructor is not implemented\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -334,7 +374,7 @@ void nsWindow::Move(PRUint32 aX, PRUint32 aY)
|
|||
// Resize this component
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
||||
void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -344,11 +384,7 @@ void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
|||
// Resize this component
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::Resize(PRUint32 aX,
|
||||
PRUint32 aY,
|
||||
PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRBool aRepaint)
|
||||
void nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -568,6 +604,7 @@ void nsWindow::SetColorMap(nsColorMap *aColorMap)
|
|||
//-------------------------------------------------------------------------
|
||||
nsIDeviceContext* nsWindow::GetDeviceContext()
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
|
||||
|
@ -641,7 +678,6 @@ PRBool nsWindow::DispatchEvent(nsGUIEvent* event)
|
|||
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));
|
||||
|
@ -651,11 +687,97 @@ PRBool nsWindow::DispatchEvent(nsGUIEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deal with all sort of mouse event
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsWindow::DispatchMouseEvent(nsMouseEvent aEvent)
|
||||
{
|
||||
PRBool result = PR_FALSE;
|
||||
|
||||
if (nsnull == mEventCallback && nsnull == mMouseListener) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// call the event callback
|
||||
if (nsnull != mEventCallback) {
|
||||
|
||||
result = DispatchEvent(&aEvent);
|
||||
|
||||
//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);
|
||||
//printf("mCurrentWindow 0x%X\n", mCurrentWindow);
|
||||
|
||||
if (rect.Contains(event.point.x, event.point.y)) {
|
||||
if (mCurrentWindow == NULL || mCurrentWindow != this) {
|
||||
if ((nsnull != mCurrentWindow) && (!mCurrentWindow->mIsDestroying)) {
|
||||
mCurrentWindow->DispatchMouseEvent(NS_MOUSE_EXIT);
|
||||
}
|
||||
mCurrentWindow = this;
|
||||
mCurrentWindow->DispatchMouseEvent(NS_MOUSE_ENTER);
|
||||
}
|
||||
}
|
||||
} else if (aEventType == NS_MOUSE_EXIT) {
|
||||
if (mCurrentWindow == this) {
|
||||
mCurrentWindow = nsnull;
|
||||
}
|
||||
}*/
|
||||
|
||||
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)) {
|
||||
if (mCurrentWindow == NULL || mCurrentWindow != this) {
|
||||
printf("Mouse enter");
|
||||
mCurrentWindow = this;
|
||||
}
|
||||
} else {
|
||||
printf("Mouse exit");
|
||||
}
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes an Expose Event
|
||||
*
|
||||
**/
|
||||
void nsWindow::OnPaint(nsPaintEvent &event)
|
||||
PRBool nsWindow::OnPaint(nsPaintEvent &event)
|
||||
{
|
||||
nsresult result ;
|
||||
|
||||
|
@ -668,6 +790,10 @@ void nsWindow::OnPaint(nsPaintEvent &event)
|
|||
|
||||
event.rect = &rr;
|
||||
|
||||
event.renderingContext = nsnull;
|
||||
|
||||
result = DispatchEvent(&event);
|
||||
|
||||
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
|
||||
|
@ -680,10 +806,12 @@ void nsWindow::OnPaint(nsPaintEvent &event)
|
|||
result = DispatchEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
}
|
||||
else
|
||||
result = PR_FALSE;
|
||||
else
|
||||
{
|
||||
result = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -696,4 +824,29 @@ void nsWindow::EndResizingChildren(void)
|
|||
}
|
||||
|
||||
|
||||
void nsWindow::OnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsWindow::DispatchFocus(PRUint32 aEventType)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PRBool nsWindow::OnScroll(PRUint32 scrollCode, PRUint32 cPos)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,13 +67,11 @@ public:
|
|||
virtual void Show(PRBool bState);
|
||||
virtual void Move(PRUint32 aX, PRUint32 aY);
|
||||
virtual void Resize(PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRBool aRepaint);
|
||||
PRUint32 aHeight);
|
||||
virtual void Resize(PRUint32 aX,
|
||||
PRUint32 aY,
|
||||
PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRBool aRepaint);
|
||||
PRUint32 aHeight);
|
||||
virtual void Enable(PRBool bState);
|
||||
virtual void SetFocus(void);
|
||||
virtual void GetBounds(nsRect &aRect);
|
||||
|
@ -102,14 +100,25 @@ public:
|
|||
virtual void ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
|
||||
virtual void AddMouseListener(nsIMouseListener * aListener);
|
||||
virtual void AddEventListener(nsIEventListener * aListener);
|
||||
virtual void OnPaint(nsPaintEvent &event);
|
||||
PRBool DispatchEvent(nsGUIEvent* event);
|
||||
static PRBool ConvertStatus(nsEventStatus aStatus);
|
||||
virtual void BeginResizingChildren(void);
|
||||
virtual void EndResizingChildren(void);
|
||||
|
||||
static PRBool ConvertStatus(nsEventStatus aStatus);
|
||||
virtual PRBool DispatchEvent(nsGUIEvent* event);
|
||||
virtual PRBool DispatchMouseEvent(nsMouseEvent aEvent);
|
||||
|
||||
virtual void OnDestroy();
|
||||
virtual PRBool OnPaint(nsPaintEvent &event);
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode);
|
||||
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
||||
virtual PRBool OnScroll(PRUint32 scrollCode, PRUint32 cPos);
|
||||
|
||||
protected:
|
||||
void InitCallbacks();
|
||||
|
||||
virtual void BeginResizingChildren(void);
|
||||
virtual void EndResizingChildren(void);
|
||||
|
||||
private:
|
||||
Widget mWidget;
|
||||
EVENT_CALLBACK mEventCallback;
|
||||
nsIDeviceContext *mContext;
|
||||
|
@ -136,184 +145,306 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#define BASE_IWIDGET_IMPL BASE_INITIALIZE_IMPL BASE_WINDOWS_METHODS
|
||||
#define AGGRRGATE_METHOD_DEF \
|
||||
public: \
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, \
|
||||
void** aInstancePtr); \
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void); \
|
||||
NS_IMETHOD_(nsrefcnt) Release(void); \
|
||||
protected: \
|
||||
nsrefcnt mRefCnt; \
|
||||
public: \
|
||||
virtual void Create(nsIWidget *aParent, \
|
||||
const nsRect &aRect, \
|
||||
EVENT_CALLBACK aHandleEventFunction, \
|
||||
nsIDeviceContext *aContext, \
|
||||
nsIToolkit *aToolkit = nsnull, \
|
||||
nsWidgetInitData *aInitData = nsnull); \
|
||||
virtual void Create(nsNativeWindow aParent, \
|
||||
const nsRect &aRect, \
|
||||
EVENT_CALLBACK aHandleEventFunction, \
|
||||
nsIDeviceContext *aContext, \
|
||||
nsIToolkit *aToolkit = nsnull, \
|
||||
nsWidgetInitData *aInitData = nsnull); \
|
||||
virtual void Destroy(); \
|
||||
virtual nsIWidget* GetParent(void); \
|
||||
virtual nsIEnumerator* GetChildren(); \
|
||||
virtual void AddChild(nsIWidget* aChild); \
|
||||
virtual void RemoveChild(nsIWidget* aChild); \
|
||||
virtual void Show(PRBool bState); \
|
||||
virtual void Move(PRUint32 aX, PRUint32 aY); \
|
||||
virtual void Resize(PRUint32 aWidth, \
|
||||
PRUint32 aHeight); \
|
||||
virtual void Resize(PRUint32 aX, \
|
||||
PRUint32 aY, \
|
||||
PRUint32 aWidth, \
|
||||
PRUint32 aHeight); \
|
||||
virtual void Enable(PRBool bState); \
|
||||
virtual void SetFocus(void); \
|
||||
virtual void GetBounds(nsRect &aRect); \
|
||||
virtual nscolor GetForegroundColor(void); \
|
||||
virtual void SetForegroundColor(const nscolor &aColor); \
|
||||
virtual nscolor GetBackgroundColor(void); \
|
||||
virtual void SetBackgroundColor(const nscolor &aColor); \
|
||||
virtual nsIFontMetrics* GetFont(void); \
|
||||
virtual void SetFont(const nsFont &aFont); \
|
||||
virtual nsCursor GetCursor(); \
|
||||
virtual void SetCursor(nsCursor aCursor); \
|
||||
virtual void Invalidate(PRBool aIsSynchronous); \
|
||||
virtual void* GetNativeData(PRUint32 aDataType); \
|
||||
virtual nsIRenderingContext* GetRenderingContext(); \
|
||||
virtual void SetColorMap(nsColorMap *aColorMap); \
|
||||
virtual nsIDeviceContext* GetDeviceContext(); \
|
||||
virtual void Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect); \
|
||||
virtual nsIToolkit* GetToolkit(); \
|
||||
virtual void SetBorderStyle(nsBorderStyle aBorderStyle); \
|
||||
virtual void SetTitle(const nsString& aTitle); \
|
||||
virtual void SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]); \
|
||||
virtual void RemoveTooltips(); \
|
||||
virtual void UpdateTooltips(nsRect* aNewTips[]); \
|
||||
virtual void WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); \
|
||||
virtual void ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); \
|
||||
virtual void AddMouseListener(nsIMouseListener * aListener); \
|
||||
virtual void AddEventListener(nsIEventListener * aListener); \
|
||||
virtual void BeginResizingChildren(void); \
|
||||
virtual void EndResizingChildren(void); \
|
||||
static PRBool ConvertStatus(nsEventStatus aStatus); \
|
||||
virtual PRBool DispatchEvent(nsGUIEvent* event); \
|
||||
virtual PRBool DispatchMouseEvent(nsMouseEvent aEvent); \
|
||||
virtual void OnDestroy(); \
|
||||
virtual PRBool OnPaint(nsPaintEvent & event); \
|
||||
virtual PRBool OnResize(nsRect &aWindowRect); \
|
||||
virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode); \
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType); \
|
||||
virtual PRBool OnScroll(PRUint32 scrollCode, PRUint32 cPos);
|
||||
|
||||
|
||||
#define BASE_INITIALIZE_IMPL \
|
||||
void Create(nsIWidget *aParent, \
|
||||
#define BASE_IWIDGET_IMPL(_classname, _aggname) \
|
||||
_classname::_aggname::_aggname() \
|
||||
{ \
|
||||
} \
|
||||
_classname::_aggname::~_aggname() \
|
||||
{ \
|
||||
} \
|
||||
nsrefcnt _classname::_aggname::AddRef() \
|
||||
{ \
|
||||
return GET_OUTER()->AddRef(); \
|
||||
} \
|
||||
nsrefcnt _classname::_aggname::Release() \
|
||||
{ \
|
||||
return GET_OUTER()->Release(); \
|
||||
} \
|
||||
nsresult _classname::_aggname::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
return GET_OUTER()->QueryInterface(aIID, aInstancePtr); \
|
||||
} \
|
||||
void _classname::_aggname::Create(nsIWidget *aParent, \
|
||||
const nsRect &aRect, \
|
||||
EVENT_CALLBACK aHandleEventFunction, \
|
||||
nsIDeviceContext *aContext, \
|
||||
nsIToolkit *aToolkit = nsnull, \
|
||||
void *aInitData = nsnull) \
|
||||
nsIToolkit *aToolkit, \
|
||||
nsWidgetInitData *aInitData) \
|
||||
{ \
|
||||
nsWindow::Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \
|
||||
GET_OUTER()->Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \
|
||||
} \
|
||||
|
||||
#define BASE_WINDOWS_METHODS \
|
||||
void Create(nsNativeWindow aParent, \
|
||||
void _classname::_aggname::Create(nsNativeWindow aParent, \
|
||||
const nsRect &aRect, \
|
||||
EVENT_CALLBACK aHandleEventFunction, \
|
||||
nsIDeviceContext *aContext, \
|
||||
nsIToolkit *aToolkit = nsnull, \
|
||||
void *aInitData = nsnull) \
|
||||
nsIToolkit *aToolkit, \
|
||||
nsWidgetInitData *aInitData) \
|
||||
{ \
|
||||
nsWindow::Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \
|
||||
GET_OUTER()->Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \
|
||||
} \
|
||||
void Destroy(void) \
|
||||
void _classname::_aggname::Destroy() \
|
||||
{ \
|
||||
nsWindow::Destroy(); \
|
||||
GET_OUTER()->Destroy(); \
|
||||
} \
|
||||
nsIWidget* GetParent(void) \
|
||||
nsIWidget* _classname::_aggname::GetParent(void) \
|
||||
{ \
|
||||
return nsWindow::GetParent(); \
|
||||
return GET_OUTER()->GetParent(); \
|
||||
} \
|
||||
nsIEnumerator* GetChildren(void) \
|
||||
nsIEnumerator* _classname::_aggname::GetChildren() \
|
||||
{ \
|
||||
return nsWindow::GetChildren(); \
|
||||
return GET_OUTER()->GetChildren(); \
|
||||
} \
|
||||
void AddChild(nsIWidget* aChild) \
|
||||
void _classname::_aggname::AddChild(nsIWidget* aChild) \
|
||||
{ \
|
||||
nsWindow::AddChild(aChild); \
|
||||
GET_OUTER()->AddChild(aChild); \
|
||||
} \
|
||||
void RemoveChild(nsIWidget* aChild) \
|
||||
void _classname::_aggname::RemoveChild(nsIWidget* aChild) \
|
||||
{ \
|
||||
nsWindow::RemoveChild(aChild); \
|
||||
GET_OUTER()->RemoveChild(aChild); \
|
||||
} \
|
||||
void Show(PRBool bState) \
|
||||
void _classname::_aggname::Show(PRBool bState) \
|
||||
{ \
|
||||
nsWindow::Show(bState); \
|
||||
GET_OUTER()->Show(bState); \
|
||||
} \
|
||||
void Move(PRUint32 aX, PRUint32 aY) \
|
||||
void _classname::_aggname::Move(PRUint32 aX, PRUint32 aY) \
|
||||
{ \
|
||||
nsWindow::Move(aX, aY); \
|
||||
GET_OUTER()->Move(aX, aY); \
|
||||
} \
|
||||
void Resize(PRUint32 aWidth, \
|
||||
PRUint32 aHeight, \
|
||||
PRBool aRepaint) \
|
||||
void _classname::_aggname::Resize(PRUint32 aWidth, \
|
||||
PRUint32 aHeight) \
|
||||
{ \
|
||||
nsWindow::Resize(aWidth, aHeight, aRepaint); \
|
||||
GET_OUTER()->Resize(aWidth, aHeight); \
|
||||
} \
|
||||
void Resize(PRUint32 aX, \
|
||||
void _classname::_aggname::Resize(PRUint32 aX, \
|
||||
PRUint32 aY, \
|
||||
PRUint32 aWidth, \
|
||||
PRUint32 aHeight, \
|
||||
PRBool aRepaint) \
|
||||
PRUint32 aHeight) \
|
||||
{ \
|
||||
nsWindow::Resize(aX, aY, aWidth, aHeight, aRepaint); \
|
||||
GET_OUTER()->Resize(aX, aY, aWidth, aHeight); \
|
||||
} \
|
||||
void Enable(PRBool bState) \
|
||||
void _classname::_aggname::Enable(PRBool bState) \
|
||||
{ \
|
||||
nsWindow::Enable(bState); \
|
||||
GET_OUTER()->Enable(bState); \
|
||||
} \
|
||||
void SetFocus(void) \
|
||||
void _classname::_aggname::SetFocus(void) \
|
||||
{ \
|
||||
nsWindow::SetFocus(); \
|
||||
GET_OUTER()->SetFocus(); \
|
||||
} \
|
||||
void GetBounds(nsRect &aRect) \
|
||||
void _classname::_aggname::GetBounds(nsRect &aRect) \
|
||||
{ \
|
||||
nsWindow::GetBounds(aRect); \
|
||||
GET_OUTER()->GetBounds(aRect); \
|
||||
} \
|
||||
nscolor GetForegroundColor(void) \
|
||||
nscolor _classname::_aggname::GetForegroundColor(void) \
|
||||
{ \
|
||||
return nsWindow::GetForegroundColor(); \
|
||||
return GET_OUTER()->GetForegroundColor(); \
|
||||
} \
|
||||
void SetForegroundColor(const nscolor &aColor) \
|
||||
void _classname::_aggname::SetForegroundColor(const nscolor &aColor) \
|
||||
{ \
|
||||
nsWindow::SetForegroundColor(aColor); \
|
||||
GET_OUTER()->SetForegroundColor(aColor); \
|
||||
} \
|
||||
nscolor GetBackgroundColor(void) \
|
||||
nscolor _classname::_aggname::GetBackgroundColor(void) \
|
||||
{ \
|
||||
return nsWindow::GetBackgroundColor(); \
|
||||
return GET_OUTER()->GetBackgroundColor(); \
|
||||
} \
|
||||
void SetBackgroundColor(const nscolor &aColor) \
|
||||
void _classname::_aggname::SetBackgroundColor(const nscolor &aColor) \
|
||||
{ \
|
||||
nsWindow::SetBackgroundColor(aColor); \
|
||||
GET_OUTER()->SetBackgroundColor(aColor); \
|
||||
} \
|
||||
nsIFontMetrics* GetFont(void) \
|
||||
nsIFontMetrics* _classname::_aggname::GetFont(void) \
|
||||
{ \
|
||||
return nsWindow::GetFont(); \
|
||||
return GET_OUTER()->GetFont(); \
|
||||
} \
|
||||
void SetFont(const nsFont &aFont) \
|
||||
void _classname::_aggname::SetFont(const nsFont &aFont) \
|
||||
{ \
|
||||
nsWindow::SetFont(aFont); \
|
||||
GET_OUTER()->SetFont(aFont); \
|
||||
} \
|
||||
nsCursor GetCursor() \
|
||||
nsCursor _classname::_aggname::GetCursor() \
|
||||
{ \
|
||||
return nsWindow::GetCursor(); \
|
||||
return GET_OUTER()->GetCursor(); \
|
||||
} \
|
||||
void SetCursor(nsCursor aCursor) \
|
||||
void _classname::_aggname::SetCursor(nsCursor aCursor) \
|
||||
{ \
|
||||
nsWindow::SetCursor(aCursor); \
|
||||
GET_OUTER()->SetCursor(aCursor); \
|
||||
} \
|
||||
void Invalidate(PRBool aIsSynchronous) \
|
||||
void _classname::_aggname::Invalidate(PRBool aIsSynchronous) \
|
||||
{ \
|
||||
nsWindow::Invalidate(aIsSynchronous); \
|
||||
GET_OUTER()->Invalidate(aIsSynchronous); \
|
||||
} \
|
||||
void* GetNativeData(PRUint32 aDataType) \
|
||||
void* _classname::_aggname::GetNativeData(PRUint32 aDataType) \
|
||||
{ \
|
||||
return nsWindow::GetNativeData(aDataType); \
|
||||
return GET_OUTER()->GetNativeData(aDataType); \
|
||||
} \
|
||||
nsIRenderingContext* GetRenderingContext() \
|
||||
nsIRenderingContext* _classname::_aggname::GetRenderingContext() \
|
||||
{ \
|
||||
return nsWindow::GetRenderingContext(); \
|
||||
return GET_OUTER()->GetRenderingContext(); \
|
||||
} \
|
||||
nsIDeviceContext* GetDeviceContext() \
|
||||
nsIDeviceContext* _classname::_aggname::GetDeviceContext() \
|
||||
{ \
|
||||
return nsWindow::GetDeviceContext(); \
|
||||
return GET_OUTER()->GetDeviceContext(); \
|
||||
} \
|
||||
void Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) \
|
||||
void _classname::_aggname::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) \
|
||||
{ \
|
||||
nsWindow::Scroll(aDx, aDy, aClipRect); \
|
||||
GET_OUTER()->Scroll(aDx, aDy, aClipRect); \
|
||||
} \
|
||||
nsIToolkit* GetToolkit() \
|
||||
nsIToolkit* _classname::_aggname::GetToolkit() \
|
||||
{ \
|
||||
return nsWindow::GetToolkit(); \
|
||||
return GET_OUTER()->GetToolkit(); \
|
||||
} \
|
||||
void SetColorMap(nsColorMap *aColorMap) \
|
||||
void _classname::_aggname::SetColorMap(nsColorMap *aColorMap) \
|
||||
{ \
|
||||
nsWindow::SetColorMap(aColorMap); \
|
||||
GET_OUTER()->SetColorMap(aColorMap); \
|
||||
} \
|
||||
void AddMouseListener(nsIMouseListener * aListener) \
|
||||
void _classname::_aggname::AddMouseListener(nsIMouseListener * aListener) \
|
||||
{ \
|
||||
nsWindow::AddMouseListener(aListener); \
|
||||
GET_OUTER()->AddMouseListener(aListener); \
|
||||
} \
|
||||
void AddEventListener(nsIEventListener * aListener) \
|
||||
void _classname::_aggname::AddEventListener(nsIEventListener * aListener) \
|
||||
{ \
|
||||
nsWindow::AddEventListener(aListener); \
|
||||
GET_OUTER()->AddEventListener(aListener); \
|
||||
} \
|
||||
PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode) \
|
||||
void _classname::_aggname::SetBorderStyle(nsBorderStyle aBorderStyle) \
|
||||
{ \
|
||||
return nsWindow::OnKey(aEventType, aKeyCode); \
|
||||
GET_OUTER()->SetBorderStyle(aBorderStyle); \
|
||||
} \
|
||||
void SetBorderStyle(nsBorderStyle aBorderStyle) \
|
||||
void _classname::_aggname::SetTitle(const nsString& aTitle) \
|
||||
{ \
|
||||
nsWindow::SetBorderStyle(aBorderStyle); \
|
||||
GET_OUTER()->SetTitle(aTitle); \
|
||||
} \
|
||||
void SetTitle(const nsString& aTitle) \
|
||||
void _classname::_aggname::SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]) \
|
||||
{ \
|
||||
nsWindow::SetTitle(aTitle); \
|
||||
GET_OUTER()->SetTooltips(aNumberOfTips, aTooltipAreas); \
|
||||
} \
|
||||
void SetTooltips(PRUint32 aNumberOfTips,const nsRect* aTooltipAreas) \
|
||||
void _classname::_aggname::UpdateTooltips(nsRect* aNewTips[]) \
|
||||
{ \
|
||||
nsWindow::SetTooltips(aNumberOfTips, aTooltipAreas); \
|
||||
GET_OUTER()->UpdateTooltips(aNewTips); \
|
||||
} \
|
||||
void UpdateTooltips(const nsRect* aNewTips) \
|
||||
void _classname::_aggname::RemoveTooltips() \
|
||||
{ \
|
||||
nsWindow::UpdateTooltips(aNewTips); \
|
||||
GET_OUTER()->RemoveTooltips(); \
|
||||
} \
|
||||
void RemoveTooltips() \
|
||||
void _classname::_aggname::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) \
|
||||
{ \
|
||||
nsWindow::RemoveTooltips(); \
|
||||
GET_OUTER()->WidgetToScreen(aOldRect, aNewRect); \
|
||||
} \
|
||||
void WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) \
|
||||
void _classname::_aggname::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) \
|
||||
{ \
|
||||
nsWindow::WidgetToScreen(aOldRect, aNewRect); \
|
||||
GET_OUTER()->ScreenToWidget(aOldRect, aNewRect); \
|
||||
} \
|
||||
void ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) \
|
||||
PRBool _classname::_aggname::DispatchEvent(nsGUIEvent* event) \
|
||||
{ \
|
||||
nsWindow::ScreenToWidget(aOldRect, aNewRect); \
|
||||
}
|
||||
return GET_OUTER()->DispatchEvent(event); \
|
||||
} \
|
||||
PRBool _classname::_aggname::DispatchMouseEvent(nsMouseEvent event) \
|
||||
{ \
|
||||
return GET_OUTER()->DispatchMouseEvent(event); \
|
||||
} \
|
||||
PRBool _classname::_aggname::OnPaint(nsPaintEvent &event) \
|
||||
{ \
|
||||
return GET_OUTER()->OnPaint(event); \
|
||||
} \
|
||||
void _classname::_aggname::BeginResizingChildren() \
|
||||
{ \
|
||||
GET_OUTER()->BeginResizingChildren(); \
|
||||
} \
|
||||
void _classname::_aggname::EndResizingChildren() \
|
||||
{ \
|
||||
GET_OUTER()->EndResizingChildren(); \
|
||||
} \
|
||||
void _classname::_aggname::OnDestroy() \
|
||||
{ \
|
||||
GET_OUTER()->OnDestroy(); \
|
||||
} \
|
||||
PRBool _classname::_aggname::OnResize(nsRect &aWindowRect) \
|
||||
{ \
|
||||
GET_OUTER()->OnResize(aWindowRect); \
|
||||
} \
|
||||
PRBool _classname::_aggname::OnKey(PRUint32 aEventType, PRUint32 aKeyCode) \
|
||||
{ \
|
||||
return GET_OUTER()->OnKey(aEventType, aKeyCode); \
|
||||
} \
|
||||
PRBool _classname::_aggname::DispatchFocus(PRUint32 aEventType) \
|
||||
{ \
|
||||
return GET_OUTER()->DispatchFocus(aEventType); \
|
||||
} \
|
||||
PRBool _classname::_aggname::OnScroll(PRUint32 scrollCode, PRUint32 cPos) \
|
||||
{ \
|
||||
GET_OUTER()->OnScroll(scrollCode, cPos); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,9 +20,45 @@
|
|||
#include "nsXtEventHandler.h"
|
||||
|
||||
#include "nsWindow.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
|
||||
void nsXtWidget_InitNSEvent(XEvent * anXEv,
|
||||
XtPointer p,
|
||||
nsGUIEvent &anEvent,
|
||||
PRUint32 aEventType)
|
||||
{
|
||||
anEvent.message = aEventType;
|
||||
anEvent.widget = (nsWindow *) p;
|
||||
|
||||
anEvent.point.x = anXEv->xbutton.x;
|
||||
anEvent.point.y = anXEv->xbutton.y;
|
||||
|
||||
anEvent.time = 0; //TBD
|
||||
|
||||
}
|
||||
|
||||
void nsXtWidget_InitNSMouseEvent(XEvent * anXEv,
|
||||
XtPointer p,
|
||||
nsMouseEvent &anEvent,
|
||||
PRUint32 aEventType)
|
||||
{
|
||||
// Do base initialization
|
||||
nsXtWidget_InitNSEvent(anXEv, p, anEvent, aEventType);
|
||||
|
||||
// Do Mouse Event specific intialization
|
||||
anEvent.time = anXEv->xbutton.time;
|
||||
anEvent.isShift = anXEv->xbutton.state | ShiftMask;
|
||||
anEvent.isControl = anXEv->xbutton.state | ControlMask;
|
||||
|
||||
//anEvent.isAlt = GetKeyState(VK_LMENU) < 0 || GetKeyState(VK_RMENU) < 0;
|
||||
////anEvent.clickCount = (aEventType == NS_MOUSE_LEFT_DOUBLECLICK ||
|
||||
//aEventType == NS_MOUSE_LEFT_DOUBLECLICK)? 2:1;
|
||||
|
||||
}
|
||||
|
||||
void nsXtWidget_ExposureMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsPaintEvent pevent ;
|
||||
|
@ -31,31 +67,68 @@ void nsXtWidget_ExposureMask_EventHandler(Widget w, XtPointer p, XEvent * event,
|
|||
if (event->xexpose.count != 0)
|
||||
return ;
|
||||
|
||||
pevent.widget = widgetWindow;
|
||||
|
||||
pevent.point.x = event->xbutton.x;
|
||||
pevent.point.y = event->xbutton.y;
|
||||
|
||||
pevent.time = 0; // XXX TBD...
|
||||
pevent.message = NS_PAINT ;
|
||||
nsXtWidget_InitNSEvent(event, p, pevent, NS_PAINT);
|
||||
|
||||
widgetWindow->OnPaint(pevent);
|
||||
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_ButtonPressMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsWindow * widgetWindow = (nsWindow *) p;
|
||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||
nsMouseEvent mevent;
|
||||
nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN);
|
||||
widgetWindow->DispatchMouseEvent(mevent);
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_ButtonReleaseMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||
nsMouseEvent mevent;
|
||||
nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
|
||||
widgetWindow->DispatchMouseEvent(mevent);
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_ButtonMotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||
//fprintf(stderr, "nsXtWidget_ButtonMotionMask_EventHandler\n");
|
||||
nsMouseEvent mevent;
|
||||
nsXtWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
|
||||
widgetWindow->DispatchMouseEvent(mevent);
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_MotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||
//fprintf(stderr, "nsXtWidget_MotionMask_EventHandler\n");
|
||||
nsGUIEvent mevent;
|
||||
nsXtWidget_InitNSEvent(event, p, mevent, NS_MOUSE_MOVE);
|
||||
widgetWindow->DispatchEvent(&mevent);
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_EnterMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||
fprintf(stderr, "***************** nsXtWidget_EnterMask_EventHandler\n");
|
||||
nsGUIEvent mevent;
|
||||
nsXtWidget_InitNSEvent(event, p, mevent, NS_MOUSE_ENTER);
|
||||
widgetWindow->DispatchEvent(&mevent);
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
void nsXtWidget_LeaveMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)
|
||||
{
|
||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||
fprintf(stderr, "***************** nsXtWidget_LeaveMask_EventHandler\n");
|
||||
nsGUIEvent mevent;
|
||||
nsXtWidget_InitNSEvent(event, p, mevent, NS_MOUSE_EXIT);
|
||||
widgetWindow->DispatchEvent(&mevent);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ void nsXtWidget_ExposureMask_EventHandler(Widget w, XtPointer p, XEvent * event,
|
|||
void nsXtWidget_ButtonPressMask_EventHandler(Widget w,XtPointer p, XEvent * event, Boolean * b);
|
||||
void nsXtWidget_ButtonReleaseMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b);
|
||||
void nsXtWidget_ButtonMotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b);
|
||||
void nsXtWidget_MotionMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b);
|
||||
void nsXtWidget_EnterMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b);
|
||||
void nsXtWidget_LeaveMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b);
|
||||
|
||||
#endif // __nsXtEventHandler.h
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче