Latest source for Qt-Mozilla from Bugzilla #70511
This commit is contained in:
Родитель
9c98204052
Коммит
32101b14f6
|
@ -17,6 +17,7 @@
|
|||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# John C. Griggs <johng@corel.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
|
@ -30,7 +31,6 @@ MODULE = layout
|
|||
LIBRARY_NAME = gfx_qt
|
||||
IS_COMPONENT = 1
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextQT.cpp \
|
||||
nsDeviceContextSpecFactoryQT.cpp \
|
||||
|
@ -61,7 +61,6 @@ EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
|||
-lgkgfx \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NULL)
|
||||
# -lraptorgfx \
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXNONXP
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
|
@ -82,4 +81,3 @@ INCLUDES += \
|
|||
-I$(srcdir)/. \
|
||||
-I$(srcdir)/.. \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsIDrawingSurfaceQT_h___
|
||||
|
@ -62,9 +64,7 @@ public:
|
|||
* surface created
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD Init(QPainter * aGC,
|
||||
PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
NS_IMETHOD Init(QPainter * aGC,PRUint32 aWidth,PRUint32 aHeight,
|
||||
PRUint32 aFlags) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# John C. Griggs <johng@corel.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
|
@ -29,51 +30,28 @@ include $(DEPTH)/config/autoconf.mk
|
|||
LIBRARY_NAME = widget_qt
|
||||
IS_COMPONENT = 1
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
$(MOCSRCS) \
|
||||
nsQApplication.cpp \
|
||||
nsAppShell.cpp \
|
||||
nsBidiKeyboard.cpp \
|
||||
nsComboBox.cpp \
|
||||
nsLabel.cpp \
|
||||
nsScrollbar.cpp \
|
||||
nsButton.cpp \
|
||||
nsListBox.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsTextAreaWidget.cpp \
|
||||
nsCheckButton.cpp \
|
||||
nsMenu.cpp \
|
||||
nsTextHelper.cpp \
|
||||
nsMenuBar.cpp \
|
||||
nsFontRetrieverService.cpp \
|
||||
nsFontSizeIterator.cpp \
|
||||
nsTextWidget.cpp \
|
||||
nsFileWidget.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsQEventHandler.cpp \
|
||||
nsRadioButton.cpp \
|
||||
nsPopUpMenu.cpp \
|
||||
nsQWidget.cpp \
|
||||
nsWidget.cpp \
|
||||
nsWindow.cpp \
|
||||
nsDragService.cpp \
|
||||
nsClipboard.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
nsMime.cpp \
|
||||
$(NULL)
|
||||
|
||||
MOCSRCS = \
|
||||
moc_nsQApplication.cpp \
|
||||
moc_nsComboBox.cpp \
|
||||
moc_nsLabel.cpp \
|
||||
moc_nsScrollbar.cpp \
|
||||
moc_nsButton.cpp \
|
||||
moc_nsListBox.cpp \
|
||||
moc_nsTextAreaWidget.cpp \
|
||||
moc_nsCheckButton.cpp \
|
||||
moc_nsTextWidget.cpp \
|
||||
moc_nsQEventHandler.cpp \
|
||||
moc_nsRadioButton.cpp \
|
||||
moc_nsWindow.cpp \
|
||||
moc_nsQWidget.cpp \
|
||||
moc_nsMime.cpp \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
|
||||
|
@ -81,9 +59,9 @@ SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
|
|||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
-lgkgfx \
|
||||
-I$(topsrcdir)/gfx/src/qt \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NULL)
|
||||
# -lraptorgfx \
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += -L$(DIST)/lib $(MOZ_QT_LDFLAGS) $(MOZ_XLIB_LDFLAGS)
|
||||
|
@ -117,5 +95,7 @@ DEFINES += -D_TIME_H=1
|
|||
endif
|
||||
endif
|
||||
|
||||
INCLUDES += -I$(srcdir)/../xpwidgets -I$(srcdir)
|
||||
|
||||
INCLUDES += -I$(srcdir)/../xpwidgets \
|
||||
-I$(srcdir) \
|
||||
-I$(topsrcdir)/gfx/src/qt \
|
||||
$(NULL)
|
||||
|
|
|
@ -18,19 +18,22 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include <stdlib.h>
|
||||
#include "nsWidget.h"
|
||||
#include <qwindowdefs.h>
|
||||
#include "X11/Xlib.h"
|
||||
|
||||
//JCG #define DBG_JCG 1
|
||||
|
||||
#ifdef DBG_JCG
|
||||
PRInt32 gAppShellCount = 0;
|
||||
PRInt32 gAppShellID = 0;
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -49,13 +52,15 @@ PRBool nsAppShell::mRunning = PR_FALSE;
|
|||
//-------------------------------------------------------------------------
|
||||
nsAppShell::nsAppShell()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::nsAppShell()\n"));
|
||||
NS_INIT_REFCNT();
|
||||
mDispatchListener = 0;
|
||||
mEventQueue = nsnull;
|
||||
mApplication = nsnull;
|
||||
NS_INIT_REFCNT();
|
||||
mDispatchListener = 0;
|
||||
mEventQueue = nsnull;
|
||||
mApplication = nsnull;
|
||||
#ifdef DBG_JCG
|
||||
gAppShellCount++;
|
||||
mID = gAppShellID++;
|
||||
printf("JCG: nsAppShell CTOR (%p) ID: %d, Count: %d\n",this,mID,gAppShellCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -65,11 +70,14 @@ nsAppShell::nsAppShell()
|
|||
//-------------------------------------------------------------------------
|
||||
nsAppShell::~nsAppShell()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::~nsAppShell()\n"));
|
||||
mApplication->Release();
|
||||
mApplication = nsnull;
|
||||
if (mApplication) {
|
||||
mApplication->Release();
|
||||
}
|
||||
mApplication = nsnull;
|
||||
#ifdef DBG_JCG
|
||||
gAppShellCount--;
|
||||
printf("JCG: nsAppShell DTOR (%p) ID: %d, Count: %d\n",this,mID,gAppShellCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -83,11 +91,8 @@ NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
|
|||
NS_METHOD
|
||||
nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::SetDispatchListener()\n"));
|
||||
mDispatchListener = aDispatchListener;
|
||||
return NS_OK;
|
||||
mDispatchListener = aDispatchListener;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -98,53 +103,26 @@ nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
|||
|
||||
NS_METHOD nsAppShell::Create(int *bac, char **bav)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::Create()\n"));
|
||||
int argc = bac ? *bac : 0;
|
||||
char **argv = bav;
|
||||
nsresult rv;
|
||||
|
||||
int argc = bac ? *bac : 0;
|
||||
char ** argv = bav;
|
||||
nsresult rv = NS_OK;
|
||||
Display * aDisplay = nsnull;
|
||||
Screen * aScreen = nsnull;
|
||||
|
||||
// Open the display
|
||||
aDisplay = XOpenDisplay(NULL);
|
||||
|
||||
if (aDisplay == NULL) {
|
||||
fprintf(stderr, "%s: Cannot connect to X server\n",argv[0]);
|
||||
exit(1);
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs = do_GetService(kCmdLineServiceCID);
|
||||
if (cmdLineArgs) {
|
||||
rv = cmdLineArgs->GetArgc(&argc);
|
||||
if (NS_FAILED(rv)) {
|
||||
argc = bac ? *bac : 0;
|
||||
}
|
||||
|
||||
aScreen = DefaultScreenOfDisplay(aDisplay);
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs = do_GetService(kCmdLineServiceCID);
|
||||
if (cmdLineArgs) {
|
||||
rv = cmdLineArgs->GetArgc(&argc);
|
||||
if(NS_FAILED(rv)) {
|
||||
argc = bac ? *bac : 0;
|
||||
}
|
||||
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
if(NS_FAILED(rv)) {
|
||||
argv = bav;
|
||||
}
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
if (NS_FAILED(rv)) {
|
||||
argv = bav;
|
||||
}
|
||||
|
||||
if (aDisplay && aScreen) {
|
||||
mApplication = nsQApplication::Instance(aDisplay);
|
||||
}
|
||||
else {
|
||||
mApplication = nsQApplication::Instance(argc, argv);
|
||||
}
|
||||
|
||||
if (!mApplication) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mApplication->setStyle(new QWindowsStyle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
mApplication = nsQApplication::Instance(argc,argv);
|
||||
if (!mApplication) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -154,39 +132,39 @@ NS_METHOD nsAppShell::Create(int *bac, char **bav)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::Spinup()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::Spinup()\n"));
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get the event queue service
|
||||
nsCOMPtr<nsIEventQueueService> eventQService = do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION("Could not obtain event queue service", PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
//Get the event queue for the thread.
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
if (mApplication == nsnull)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// If a queue already present use it.
|
||||
if (mEventQueue) {
|
||||
goto done;
|
||||
}
|
||||
// Create the event queue for the thread
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
if (NS_OK != rv) {
|
||||
NS_ASSERTION("Could not create the thread event queue", PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
//Get the event queue for the thread
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
if (NS_OK != rv) {
|
||||
NS_ASSERTION("Could not obtain the thread event queue", PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
// Get the event queue service
|
||||
nsCOMPtr<nsIEventQueueService> eventQService = do_GetService(kEventQueueServiceCID,&rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION("Could not obtain event queue service",PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
//Get the event queue for the thread.
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,getter_AddRefs(mEventQueue));
|
||||
|
||||
// If a queue already present use it.
|
||||
if (mEventQueue) {
|
||||
goto done;
|
||||
}
|
||||
// Create the event queue for the thread
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION("Could not create the thread event queue",PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
//Get the event queue for the thread
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,getter_AddRefs(mEventQueue));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION("Could not obtain the thread event queue",PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
done:
|
||||
mApplication->AddEventProcessorCallback(mEventQueue);
|
||||
return NS_OK;
|
||||
mApplication->AddEventProcessorCallback(mEventQueue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -196,16 +174,15 @@ done:
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::Spindown()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::Spindown()\n"));
|
||||
if (mEventQueue) {
|
||||
mApplication->RemoveEventProcessorCallback(mEventQueue);
|
||||
mEventQueue = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (mApplication == nsnull)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (mEventQueue) {
|
||||
mApplication->RemoveEventProcessorCallback(mEventQueue);
|
||||
mEventQueue = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -214,22 +191,21 @@ NS_METHOD nsAppShell::Spindown()
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::Run()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::Run()\n"));
|
||||
if (mApplication == nsnull)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (!mEventQueue)
|
||||
Spinup();
|
||||
if (!mEventQueue) {
|
||||
Spinup();
|
||||
}
|
||||
if (!mEventQueue) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
mRunning = PR_TRUE;
|
||||
mApplication->exec();
|
||||
mRunning = PR_FALSE;
|
||||
|
||||
if (!mEventQueue)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
mRunning = PR_TRUE;
|
||||
mApplication->exec();
|
||||
mRunning = PR_FALSE;
|
||||
|
||||
Spindown();
|
||||
return NS_OK;
|
||||
Spindown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -240,36 +216,31 @@ NS_METHOD nsAppShell::Run()
|
|||
|
||||
NS_METHOD nsAppShell::Exit()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::Exit()\n"));
|
||||
if (mRunning)
|
||||
mApplication->exit(0);
|
||||
if (mApplication == nsnull)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
if (mRunning)
|
||||
mApplication->exit(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *& aEvent)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::GetNativeEvent()\n"));
|
||||
aRealEvent = PR_FALSE;
|
||||
aEvent = 0;
|
||||
return NS_OK;
|
||||
aRealEvent = PR_FALSE;
|
||||
aEvent = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsAppShell::DispatchNativeEvent()\n"));
|
||||
if (!mRunning)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (mApplication == nsnull)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
mApplication->processEvents();
|
||||
if (!mRunning)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
mApplication->processEvents(1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue,
|
||||
|
|
|
@ -18,21 +18,17 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsAppShell_h__
|
||||
#define nsAppShell_h__
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
||||
#include "nsQApplication.h"
|
||||
#include <qwindowsstyle.h>
|
||||
|
||||
/**
|
||||
* Native QT Application shell wrapper
|
||||
*/
|
||||
|
||||
/* Native QT Application shell wrapper */
|
||||
class nsAppShell : public nsIAppShell
|
||||
{
|
||||
public:
|
||||
|
@ -47,8 +43,8 @@ private:
|
|||
nsDispatchListener *mDispatchListener;
|
||||
nsCOMPtr<nsIEventQueue> mEventQueue;
|
||||
nsQApplication *mApplication;
|
||||
PRInt32 mID;
|
||||
static PRBool mRunning;
|
||||
};
|
||||
|
||||
#endif // nsAppShell_h__
|
||||
|
||||
|
|
|
@ -18,39 +18,49 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define NO_DEBUG
|
||||
#endif
|
||||
|
||||
#include "nsClipboard.h"
|
||||
|
||||
// XXXX #include "nsDataObj.h"
|
||||
#include "nsMime.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIClipboardOwner.h"
|
||||
#include "nsITransferable.h"
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsPrimitiveHelpers.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsWidget.h"
|
||||
#include <qapplication.h>
|
||||
|
||||
// XXXX #include "DDCOMM.h"
|
||||
#include <qapplication.h>
|
||||
#include <qclipboard.h>
|
||||
#include <qdragobject.h>
|
||||
|
||||
// interface definitions
|
||||
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsClipboard, nsBaseClipboard)
|
||||
NS_IMPL_RELEASE_INHERITED(nsClipboard, nsBaseClipboard)
|
||||
NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsClipboard constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsClipboard::nsClipboard() : nsBaseClipboard()
|
||||
nsClipboard::nsClipboard()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsClipboard::nsClipboard()\n"));
|
||||
mIgnoreEmptyNotification = PR_FALSE;
|
||||
mWindow = nsnull;
|
||||
NS_INIT_REFCNT();
|
||||
mIgnoreEmptyNotification = PR_FALSE;
|
||||
mGlobalTransferable = nsnull;
|
||||
mSelectionTransferable = nsnull;
|
||||
mGlobalOwner = nsnull;
|
||||
mSelectionOwner = nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -60,89 +70,267 @@ nsClipboard::nsClipboard() : nsBaseClipboard()
|
|||
//-------------------------------------------------------------------------
|
||||
nsClipboard::~nsClipboard()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsClipboard::~nsClipboard()\n"));
|
||||
NS_IF_RELEASE(mWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsClipboard::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsClipboard::QueryInterface()\n"));
|
||||
if (NULL == aInstancePtr)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
static NS_DEFINE_IID(kIClipboard, NS_ICLIPBOARD_IID);
|
||||
if (aIID.Equals(kIClipboard))
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIClipboard*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsClipboard::SetNativeClipboardData()\n"));
|
||||
mIgnoreEmptyNotification = PR_TRUE;
|
||||
mIgnoreEmptyNotification = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsITransferable> transferable(getter_AddRefs(GetTransferable(aWhichClipboard)));
|
||||
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == mTransferable)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (nsnull == transferable) {
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsClipboard::SetNativeClipboardData(): no transferable!\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// get flavor list that includes all flavors that can be written (including
|
||||
// ones obtained through conversion)
|
||||
nsCOMPtr<nsISupportsArray> flavorList;
|
||||
nsresult errCode = transferable->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
|
||||
if (NS_FAILED(errCode)) {
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsClipboard::SetNativeClipboardData(): no FlavorsTransferable !\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
QClipboard *cb = QApplication::clipboard();
|
||||
nsMimeStore* mimeStore = new nsMimeStore();
|
||||
PRUint32 cnt;
|
||||
|
||||
return NS_OK;
|
||||
flavorList->Count(&cnt);
|
||||
for (PRUint32 i = 0; i < cnt; ++i) {
|
||||
nsCOMPtr<nsISupports> genericFlavor;
|
||||
|
||||
flavorList->GetElementAt(i,getter_AddRefs(genericFlavor));
|
||||
|
||||
nsCOMPtr<nsISupportsString> currentFlavor(do_QueryInterface(genericFlavor));
|
||||
|
||||
if (currentFlavor) {
|
||||
nsXPIDLCString flavorStr;
|
||||
|
||||
currentFlavor->ToString(getter_Copies(flavorStr));
|
||||
|
||||
// add these types as selection targets
|
||||
PRUint32 len;
|
||||
void* data;
|
||||
nsCOMPtr<nsISupports> clip;
|
||||
|
||||
transferable->GetTransferData(flavorStr,getter_AddRefs(clip),&len);
|
||||
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr,clip,&data,len);
|
||||
mimeStore->AddFlavorData(flavorStr,data,len);
|
||||
}
|
||||
}
|
||||
cb->setData(mimeStore);
|
||||
mIgnoreEmptyNotification = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable, PRInt32 aWhichClipboard)
|
||||
nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable,
|
||||
PRInt32 aWhichClipboard)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsClipboard::GetNativeClipboardData()\n"));
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == aTransferable)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == aTransferable) {
|
||||
#ifdef NS_DEBUG
|
||||
printf(" GetNativeClipboardData: Transferable is null!\n");
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// get flavor list that includes all acceptable flavors (including
|
||||
// ones obtained through conversion)
|
||||
nsCOMPtr<nsISupportsArray> flavorList;
|
||||
nsresult errCode = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
|
||||
|
||||
return NS_OK;
|
||||
if (NS_FAILED(errCode)) {
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsClipboard::GetNativeClipboardData(): no FlavorsTransferable %i !\n",
|
||||
errCode);
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
QClipboard *cb = QApplication::clipboard();
|
||||
QMimeSource *ms = cb->data();
|
||||
|
||||
// Walk through flavors and see which flavor matches the one being pasted:
|
||||
PRUint32 cnt;
|
||||
|
||||
flavorList->Count(&cnt);
|
||||
|
||||
nsCAutoString foundFlavor;
|
||||
for (PRUint32 i = 0; i < cnt; ++i) {
|
||||
nsCOMPtr<nsISupports> genericFlavor;
|
||||
|
||||
flavorList->GetElementAt(i,getter_AddRefs(genericFlavor));
|
||||
nsCOMPtr<nsISupportsString> currentFlavor(do_QueryInterface(genericFlavor));
|
||||
|
||||
if (currentFlavor) {
|
||||
nsXPIDLCString flavorStr;
|
||||
|
||||
currentFlavor->ToString(getter_Copies(flavorStr));
|
||||
foundFlavor = nsCAutoString(flavorStr);
|
||||
|
||||
if (ms->provides((const char*)flavorStr)) {
|
||||
QByteArray ba = ms->encodedData((const char*)flavorStr);
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
PRUint32 len = (PRUint32)ba.count();
|
||||
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor,
|
||||
(void*)ba.data(),len,
|
||||
getter_AddRefs(genericDataWrapper));
|
||||
aTransferable->SetTransferData(foundFlavor,genericDataWrapper,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsClipboard::ForceDataToClipboard()\n"));
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == mTransferable)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
// make sure we have a good transferable
|
||||
nsCOMPtr<nsITransferable> transferable(getter_AddRefs(GetTransferable(aWhichClipboard)));
|
||||
if (nsnull == transferable) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* inline */
|
||||
nsITransferable *nsClipboard::GetTransferable(PRInt32 aWhichClipboard)
|
||||
{
|
||||
nsITransferable *transferable = nsnull;
|
||||
|
||||
switch (aWhichClipboard) {
|
||||
case kGlobalClipboard:
|
||||
transferable = mGlobalTransferable;
|
||||
break;
|
||||
|
||||
case kSelectionClipboard:
|
||||
transferable = mSelectionTransferable;
|
||||
break;
|
||||
}
|
||||
NS_IF_ADDREF(transferable);
|
||||
return transferable;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList,
|
||||
PRInt32 aWhichClipboard,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
if (aWhichClipboard != kGlobalClipboard)
|
||||
return NS_OK;
|
||||
|
||||
QClipboard *cb = QApplication::clipboard();
|
||||
QMimeSource *ms = cb->data();
|
||||
PRUint32 cnt;
|
||||
|
||||
aFlavorList->Count(&cnt);
|
||||
for (PRUint32 i = 0;i < cnt; ++i) {
|
||||
nsCOMPtr<nsISupports> genericFlavor;
|
||||
|
||||
aFlavorList->GetElementAt(i,getter_AddRefs(genericFlavor));
|
||||
|
||||
nsCOMPtr<nsISupportsString> currentFlavor(do_QueryInterface(genericFlavor));
|
||||
if (currentFlavor) {
|
||||
nsXPIDLCString flavorStr;
|
||||
|
||||
currentFlavor->ToString(getter_Copies(flavorStr));
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (strcmp(flavorStr,kTextMime) == 0)
|
||||
NS_WARNING("DO NOT USE THE text/plain DATA FLAVOR ANY MORE. USE text/unicode INSTEAD");
|
||||
#endif
|
||||
|
||||
if (ms->provides((const char*)flavorStr)) {
|
||||
*_retval = PR_TRUE;
|
||||
#ifdef NS_DEBUG
|
||||
printf("GetFormat %s\n",(const char*)flavorStr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transferable object
|
||||
*/
|
||||
NS_IMETHODIMP nsClipboard::SetData(nsITransferable *aTransferable,
|
||||
nsIClipboardOwner *anOwner,
|
||||
PRInt32 aWhichClipboard)
|
||||
{
|
||||
if ((aTransferable == mGlobalTransferable.get()
|
||||
&& anOwner == mGlobalOwner.get()
|
||||
&& aWhichClipboard == kGlobalClipboard)
|
||||
|| (aTransferable == mSelectionTransferable.get()
|
||||
&& anOwner == mSelectionOwner.get()
|
||||
&& aWhichClipboard == kSelectionClipboard)) {
|
||||
return NS_OK;
|
||||
}
|
||||
EmptyClipboard(aWhichClipboard);
|
||||
|
||||
switch (aWhichClipboard) {
|
||||
case kSelectionClipboard:
|
||||
mSelectionOwner = anOwner;
|
||||
mSelectionTransferable = aTransferable;
|
||||
break;
|
||||
|
||||
case kGlobalClipboard:
|
||||
mGlobalOwner = anOwner;
|
||||
mGlobalTransferable = aTransferable;
|
||||
break;
|
||||
}
|
||||
QApplication::clipboard()->clear();
|
||||
return SetNativeClipboardData(aWhichClipboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transferable object
|
||||
*/
|
||||
NS_IMETHODIMP nsClipboard::GetData(nsITransferable *aTransferable,PRInt32 aWhichClipboard)
|
||||
{
|
||||
if (nsnull != aTransferable) {
|
||||
return GetNativeClipboardData(aTransferable,aWhichClipboard);
|
||||
#ifdef NS_DEBUG
|
||||
} else {
|
||||
printf(" nsClipboard::GetData(), aTransferable is NULL.\n");
|
||||
#endif
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
|
||||
{
|
||||
if (mIgnoreEmptyNotification) {
|
||||
return NS_OK;
|
||||
}
|
||||
switch(aWhichClipboard) {
|
||||
case kSelectionClipboard:
|
||||
if (mSelectionOwner) {
|
||||
mSelectionOwner->LosingOwnership(mSelectionTransferable);
|
||||
mSelectionOwner = nsnull;
|
||||
}
|
||||
mSelectionTransferable = nsnull;
|
||||
break;
|
||||
|
||||
case kGlobalClipboard:
|
||||
if (mGlobalOwner) {
|
||||
mGlobalOwner->LosingOwnership(mGlobalTransferable);
|
||||
mGlobalOwner = nsnull;
|
||||
}
|
||||
mGlobalTransferable = nsnull;
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE; // we support the selection clipboard by default.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -18,44 +18,47 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsClipboard_h__
|
||||
#define nsClipboard_h__
|
||||
|
||||
#include "nsBaseClipboard.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsIClipboardOwner.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsITransferable;
|
||||
class nsIClipboardOwner;
|
||||
class nsIWidget;
|
||||
#include <qlist.h>
|
||||
#include <qcstring.h>
|
||||
#include <qmime.h>
|
||||
|
||||
/**
|
||||
* Native QT Clipboard wrapper
|
||||
*/
|
||||
|
||||
class nsClipboard : public nsBaseClipboard
|
||||
/* Native QT Clipboard wrapper */
|
||||
class nsClipboard : public nsIClipboard
|
||||
{
|
||||
|
||||
public:
|
||||
nsClipboard();
|
||||
virtual ~nsClipboard();
|
||||
|
||||
//nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIClipboard
|
||||
NS_IMETHOD ForceDataToClipboard(PRInt32 aWhichClipboard);
|
||||
NS_DECL_NSICLIPBOARD
|
||||
|
||||
protected:
|
||||
NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
|
||||
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable, PRInt32 aWhichClipboard);
|
||||
NS_IMETHOD GetNativeClipboardData(nsITransferable *aTransferable,
|
||||
PRInt32 aWhichClipboard);
|
||||
|
||||
inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard);
|
||||
|
||||
PRBool mIgnoreEmptyNotification;
|
||||
|
||||
nsIClipboardOwner * mClipboardOwner;
|
||||
nsITransferable * mTransferable;
|
||||
nsIWidget * mWindow;
|
||||
|
||||
nsCOMPtr<nsIClipboardOwner> mSelectionOwner;
|
||||
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
|
||||
nsCOMPtr<nsITransferable> mSelectionTransferable;
|
||||
nsCOMPtr<nsITransferable> mGlobalTransferable;
|
||||
};
|
||||
|
||||
#endif // nsClipboard_h__
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "nsStringUtil.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
|
||||
//JCG #define DBG 0
|
||||
#define DBG 0
|
||||
|
||||
#define INITIAL_MAX_ITEMS 128
|
||||
#define ITEMS_GROWSIZE 128
|
||||
|
|
|
@ -19,27 +19,35 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define NO_DEBUG
|
||||
#endif
|
||||
|
||||
#include "nsDragService.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsPrimitiveHelpers.h"
|
||||
#include "nsMime.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDragServiceIID, NS_IDRAGSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIDragSessionQtIID, NS_IDRAGSESSIONQT_IID);
|
||||
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||
|
||||
// The class statics:
|
||||
//GtkWidget* nsDragService::sWidget = 0;
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
|
||||
NS_IMPL_QUERY_INTERFACE3(nsDragService, nsIDragService, nsIDragSession, nsIDragSessionQt )
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// static variables
|
||||
//-------------------------------------------------------------------------
|
||||
//static PRBool gHaveDrag = PR_FALSE;
|
||||
static PRBool gHaveDrag = PR_FALSE;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -48,7 +56,10 @@ NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
|
|||
//-------------------------------------------------------------------------
|
||||
nsDragService::nsDragService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// our hidden source widget
|
||||
mHiddenWidget = new QWidget(0,QWidget::tr("DragDrop"),0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -58,139 +69,217 @@ nsDragService::nsDragService()
|
|||
//-------------------------------------------------------------------------
|
||||
nsDragService::~nsDragService()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*
|
||||
*/
|
||||
nsresult nsDragService::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
if (NULL == aInstancePtr)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDragService)))
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIDragService*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
delete mHiddenWidget;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::StartDragSession(nsITransferable * aTransferable,
|
||||
PRUint32 aActionType)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray *aArrayTransferables,
|
||||
nsIScriptableRegion *aRegion,
|
||||
PRUint32 aActionType)
|
||||
{
|
||||
return NS_OK;
|
||||
PRUint32 numItemsToDrag = 0;
|
||||
|
||||
nsBaseDragService::InvokeDragSession(aDOMNode, aArrayTransferables,
|
||||
aRegion, aActionType);
|
||||
|
||||
// make sure that we have an array of transferables to use
|
||||
if (!aArrayTransferables) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
// set our reference to the transferables. this will also addref
|
||||
// the transferables since we're going to hang onto this beyond the
|
||||
// length of this call
|
||||
mSourceDataItems = aArrayTransferables;
|
||||
|
||||
mSourceDataItems->Count(&numItemsToDrag);
|
||||
if (!numItemsToDrag) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (numItemsToDrag > 1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsISupports> genericItem;
|
||||
|
||||
mSourceDataItems->GetElementAt(0,getter_AddRefs(genericItem));
|
||||
|
||||
nsCOMPtr<nsITransferable> transferable(do_QueryInterface(genericItem));
|
||||
|
||||
mDragObject = RegisterDragFlavors(transferable);
|
||||
gHaveDrag = PR_TRUE;
|
||||
|
||||
if (aActionType == DRAGDROP_ACTION_MOVE)
|
||||
mDragObject->dragMove();
|
||||
else
|
||||
mDragObject->dragCopy();
|
||||
|
||||
gHaveDrag = PR_FALSE;
|
||||
mDragObject = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0 //JCG
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::GetData(nsITransferable * aTransferable,
|
||||
QDragObject *nsDragService::RegisterDragFlavors(nsITransferable *transferable)
|
||||
{
|
||||
nsMimeStore *pMimeStore = new nsMimeStore();
|
||||
nsCOMPtr<nsISupportsArray> flavorList;
|
||||
|
||||
if (NS_SUCCEEDED(transferable->FlavorsTransferableCanExport(getter_AddRefs(flavorList)))) {
|
||||
PRUint32 numFlavors;
|
||||
|
||||
flavorList->Count(&numFlavors);
|
||||
|
||||
for (PRUint32 flavorIndex = 0; flavorIndex < numFlavors; ++flavorIndex) {
|
||||
nsCOMPtr<nsISupports> genericWrapper;
|
||||
|
||||
flavorList->GetElementAt(flavorIndex,getter_AddRefs(genericWrapper));
|
||||
|
||||
nsCOMPtr<nsISupportsString> currentFlavor(do_QueryInterface(genericWrapper));
|
||||
|
||||
if (currentFlavor) {
|
||||
nsXPIDLCString flavorStr;
|
||||
|
||||
currentFlavor->ToString(getter_Copies(flavorStr));
|
||||
|
||||
PRUint32 len;
|
||||
void* data;
|
||||
nsCOMPtr<nsISupports> clip;
|
||||
|
||||
transferable->GetTransferData(flavorStr,getter_AddRefs(clip),&len);
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr,clip,&data,len);
|
||||
pMimeStore->AddFlavorData(flavorStr,data,len);
|
||||
}
|
||||
} // foreach flavor in item
|
||||
} // if valid flavor list
|
||||
#ifdef NS_DEBUG
|
||||
else
|
||||
printf(" DnD ERROR: cannot export any flavor\n");
|
||||
#endif
|
||||
return new nsDragObject(pMimeStore,mHiddenWidget);
|
||||
} // RegisterDragItemsAndFlavors
|
||||
|
||||
NS_IMETHODIMP nsDragService::StartDragSession()
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf(" DnD: StartDragSession\n");
|
||||
#endif
|
||||
return nsBaseDragService::StartDragSession();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::EndDragSession()
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf(" DnD: EndDragSession\n");
|
||||
#endif
|
||||
mDragObject = 0;
|
||||
return nsBaseDragService::EndDragSession();
|
||||
}
|
||||
|
||||
// nsIDragSession
|
||||
NS_IMETHODIMP nsDragService::SetCanDrop(PRBool aCanDrop)
|
||||
{
|
||||
mCanDrop = aCanDrop;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::GetCanDrop(PRBool *aCanDrop)
|
||||
{
|
||||
*aCanDrop = mCanDrop;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::GetNumDropItems(PRUint32 *aNumItems)
|
||||
{
|
||||
*aNumItems = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::GetData(nsITransferable *aTransferable,
|
||||
PRUint32 aItemIndex)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// make sure that we have a transferable
|
||||
if (!aTransferable)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void nsDragService::SetTopLevelWidget(QWidget* w)
|
||||
{
|
||||
printf(" nsDragService::SetTopLevelWidget\n");
|
||||
|
||||
// Don't set up any more event handlers if we're being called twice
|
||||
// for the same toplevel widget
|
||||
if (sWidget == w)
|
||||
return;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISupportsArray> flavorList;
|
||||
|
||||
sWidget = w;
|
||||
rv = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Get the DragService from the service manager.
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIDragService, dragService, kCDragServiceCID, &rv);
|
||||
// count the number of flavors
|
||||
PRUint32 cnt;
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
return;
|
||||
flavorList->Count(&cnt);
|
||||
|
||||
// Now walk down the list of flavors. When we find one that is
|
||||
// actually present, copy out the data into the transferable in that
|
||||
// format. SetTransferData() implicitly handles conversions.
|
||||
for (unsigned int i = 0; i < cnt; ++i) {
|
||||
nsCAutoString foundFlavor;
|
||||
nsCOMPtr<nsISupports> genericWrapper;
|
||||
|
||||
flavorList->GetElementAt(i,getter_AddRefs(genericWrapper));
|
||||
|
||||
nsCOMPtr<nsISupportsString> currentFlavor;
|
||||
|
||||
currentFlavor = do_QueryInterface(genericWrapper);
|
||||
if (currentFlavor) {
|
||||
nsXPIDLCString flavorStr;
|
||||
|
||||
currentFlavor->ToString(getter_Copies(flavorStr));
|
||||
foundFlavor = nsCAutoString(flavorStr);
|
||||
|
||||
if (mDragObject && mDragObject->provides(flavorStr)) {
|
||||
QByteArray ba = mDragObject->encodedData((const char*)flavorStr);
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
PRUint32 len = (PRUint32)ba.count();
|
||||
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor,
|
||||
(void*)ba.data(),len,
|
||||
getter_AddRefs(genericDataWrapper));
|
||||
|
||||
aTransferable->SetTransferData(foundFlavor,genericDataWrapper,len);
|
||||
}
|
||||
}
|
||||
|
||||
// We're done with our reference to the dragService.
|
||||
//NS_IF_RELEASE(dragService);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragLeave(QWidget *widget,
|
||||
QDragContext *context,
|
||||
unsigned int time)
|
||||
NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor,
|
||||
PRBool *_retval)
|
||||
{
|
||||
printf("leave\n");
|
||||
if (!_retval)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
if (mDragObject)
|
||||
*_retval = mDragObject->provides(aDataFlavor);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if (!*_retval)
|
||||
printf("nsDragService::IsDataFlavorSupported not provides [%s] \n", aDataFlavor);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool
|
||||
nsDragService::DragMotion(QWidget *widget,
|
||||
QDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time)
|
||||
NS_IMETHODIMP nsDragService::SetDragReference(QMimeSource* aDragRef)
|
||||
{
|
||||
printf("drag motion\n");
|
||||
return PR_TRUE;
|
||||
}
|
||||
nsMimeStore* pMimeStore = new nsMimeStore();
|
||||
int c = 0;
|
||||
const char* format;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool
|
||||
nsDragService::DragDrop(QWidget *widget,
|
||||
QDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time)
|
||||
{
|
||||
printf("drop\n");
|
||||
return PR_FALSE;
|
||||
}
|
||||
while ((format = aDragRef->format(c++)) != 0) {
|
||||
// this is usualy between different processes
|
||||
// so, we need to copy datafrom one to onother
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragDataReceived(QWidget *widget,
|
||||
QDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
QSelectionData *data,
|
||||
unsigned int info,
|
||||
guint time)
|
||||
{
|
||||
printf("Data Received!\n");
|
||||
QByteArray ba = aDragRef->encodedData(format);
|
||||
char *data = new char[ba.size()];
|
||||
memcpy(data,ba.data(),ba.size());
|
||||
pMimeStore->AddFlavorData(format,data,ba.size());
|
||||
}
|
||||
mDragObject = new nsDragObject(pMimeStore,mHiddenWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragDataGet(QWidget *widget,
|
||||
QDragContext *context,
|
||||
QSelectionData *selection_data,
|
||||
unsigned int info,
|
||||
unsigned int time,
|
||||
void *data)
|
||||
{
|
||||
printf("Get the data!\n");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragDataDelete(QWidget *widget,
|
||||
QDragContext *context,
|
||||
void *data)
|
||||
{
|
||||
printf("Delete the data!\n");
|
||||
}
|
||||
#endif /* JCG */
|
||||
|
|
|
@ -18,79 +18,58 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsDragService_h__
|
||||
#define nsDragService_h__
|
||||
|
||||
#include "nsBaseDragService.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsIDragSessionQt.h"
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qdragobject.h>
|
||||
|
||||
/**
|
||||
* Native QT DragService wrapper
|
||||
*/
|
||||
|
||||
class nsDragService : public nsBaseDragService
|
||||
//----------------------------------------------------------
|
||||
/* Native Qt DragService wrapper */
|
||||
class nsDragService : public nsBaseDragService, public nsIDragSessionQt
|
||||
{
|
||||
|
||||
public:
|
||||
nsDragService();
|
||||
virtual ~nsDragService();
|
||||
nsDragService();
|
||||
virtual ~nsDragService();
|
||||
|
||||
//nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
//nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
//nsIDragService
|
||||
NS_IMETHOD StartDragSession (nsITransferable * aTransferable,
|
||||
PRUint32 aActionType);
|
||||
NS_IMETHOD InvokeDragSession(nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray *anArrayTransferables,
|
||||
nsIScriptableRegion *aRegion,
|
||||
PRUint32 aActionType);
|
||||
NS_IMETHOD StartDragSession();
|
||||
NS_IMETHOD EndDragSession();
|
||||
|
||||
#if 0
|
||||
// Native Impl.
|
||||
NS_IMETHOD GetData (nsITransferable * aTransferable, PRUint32 aItemIndex);
|
||||
// nsIDragSession
|
||||
NS_IMETHOD SetCanDrop(PRBool aCanDrop);
|
||||
NS_IMETHOD GetCanDrop(PRBool *aCanDrop);
|
||||
NS_IMETHOD GetNumDropItems(PRUint32 *aNumItems);
|
||||
NS_IMETHOD GetData(nsITransferable *aTransferable,PRUint32 aItemIndex);
|
||||
NS_IMETHOD IsDataFlavorSupported(const char *aDataFlavor,PRBool *_retval);
|
||||
|
||||
static void SetTopLevelWidget(QWidget* w);
|
||||
|
||||
static Qwidget *sWidget;
|
||||
// nsIDragSessionQt
|
||||
NS_IMETHOD SetDragReference(QMimeSource* aDragRef);
|
||||
|
||||
protected:
|
||||
static PRBool gHaveDrag;
|
||||
QDragObject *RegisterDragFlavors(nsITransferable* transferable);
|
||||
|
||||
static void DragLeave(QWidget *widget,
|
||||
QDragContext *context,
|
||||
unsigned int time);
|
||||
private:
|
||||
// the source of our drags
|
||||
QWidget *mHiddenWidget;
|
||||
QDragObject *mDragObject;
|
||||
|
||||
static PRBool DragMotion(QWidget *widget,
|
||||
QDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time);
|
||||
|
||||
static PRBool DragDrop(QWidget *widget,
|
||||
QDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time);
|
||||
|
||||
static void DragDataReceived(QWidget *widget,
|
||||
QDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
QSelectionData *data,
|
||||
unsigned int info,
|
||||
unsigned int time);
|
||||
|
||||
static void DragDataGet(QWidget *widget,
|
||||
QDragContext *context,
|
||||
QSelectionData *selection_data,
|
||||
unsigned int info,
|
||||
unsigned int time,
|
||||
void* data);
|
||||
|
||||
static void DragDataDelete(QWidget *widget,
|
||||
QDragContext *context,
|
||||
void* data);
|
||||
#endif
|
||||
// our source data items
|
||||
nsCOMPtr<nsISupportsArray> mSourceDataItems;
|
||||
};
|
||||
|
||||
#endif // nsDragService_h__
|
||||
|
|
|
@ -39,7 +39,8 @@ NS_IMPL_ISUPPORTS2(nsFontRetrieverService, nsIFontRetrieverService, nsIFontNameI
|
|||
//----------------------------------------------------------
|
||||
nsFontRetrieverService::nsFontRetrieverService()
|
||||
{
|
||||
printf("JCG: nsFontRetrieverService CTOR.\n");
|
||||
printf("JCG nsFontRetrieverService CTOR\n");
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mFontList = nsnull;
|
||||
|
@ -50,7 +51,8 @@ printf("JCG: nsFontRetrieverService CTOR.\n");
|
|||
//----------------------------------------------------------
|
||||
nsFontRetrieverService::~nsFontRetrieverService()
|
||||
{
|
||||
printf("JCG: nsFontRetrieverService DTOR.\n");
|
||||
printf("JCG nsFontRetrieverService DTOR\n");
|
||||
|
||||
if (nsnull != mFontList) {
|
||||
for (PRInt32 i=0;i<mFontList->Count();i++) {
|
||||
FontInfo * font = (FontInfo *)mFontList->ElementAt(i);
|
||||
|
@ -131,10 +133,6 @@ NS_IMETHODIMP nsFontRetrieverService::Reset()
|
|||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName )
|
||||
{
|
||||
char *tmp;
|
||||
printf("JCG: nsFontRetrieverService::Get. FontName: %s\n",(tmp = aFontName->ToNewCString()));
|
||||
nsMemory::Free((void*)tmp);
|
||||
|
||||
if (mNameIterInx < mFontList->Count()) {
|
||||
FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx);
|
||||
*aFontName = fontInfo->mName;
|
||||
|
|
|
@ -33,6 +33,8 @@ NS_IMPL_QUERY_INTERFACE(nsFontSizeIterator, NS_GET_IID(nsIFontSizeIterator))
|
|||
//----------------------------------------------------------
|
||||
nsFontSizeIterator::nsFontSizeIterator()
|
||||
{
|
||||
printf("JCG nsFontSizeIterator CTOR\n");
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
mFontInfo = nsnull;
|
||||
mSizeIterInx = 0;
|
||||
|
@ -41,6 +43,8 @@ nsFontSizeIterator::nsFontSizeIterator()
|
|||
//----------------------------------------------------------
|
||||
nsFontSizeIterator::~nsFontSizeIterator()
|
||||
{
|
||||
printf("JCG nsFontSizeIterator DTOR\n");
|
||||
|
||||
}
|
||||
|
||||
///----------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
*
|
||||
*/
|
||||
#ifndef nsIDragSessionQt_h__
|
||||
#define nsIDragSessionQt_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include <qdragobject.h>
|
||||
|
||||
#define NS_IDRAGSESSIONQT_IID \
|
||||
{ 0x36c4c381, 0x09e3, 0x11d4, { 0xb0, 0x33, 0xa4, 0x20, 0xf4, 0x2c, 0xfd, 0x7c } };
|
||||
|
||||
class nsIDragSessionQt : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAGSESSIONQT_IID)
|
||||
|
||||
/**
|
||||
* Since the drag may originate in an external application, we need some
|
||||
* way of communicating the QDragObject to the session so it can use it
|
||||
* when filling in data requests.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetDragReference(QMimeSource* aDragRef) = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -18,16 +18,18 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsLookAndFeel.h"
|
||||
|
||||
#include "nsQApplication.h"
|
||||
#include <qpalette.h>
|
||||
#include "nsWidget.h"
|
||||
|
||||
#include "nsXPLookAndFeel.h"
|
||||
|
||||
#include <qpalette.h>
|
||||
|
||||
#define QCOLOR_TO_NS_RGB(c) \
|
||||
((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsLookAndFeel, nsILookAndFeel)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -37,312 +39,382 @@ NS_IMPL_ISUPPORTS1(nsLookAndFeel, nsILookAndFeel)
|
|||
//-------------------------------------------------------------------------
|
||||
nsLookAndFeel::nsLookAndFeel()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::nsLookAndFeel()\n"));
|
||||
NS_INIT_REFCNT();
|
||||
(void)NS_NewXPLookAndFeel(getter_AddRefs(mXPLookAndFeel));
|
||||
NS_INIT_REFCNT();
|
||||
NS_NewXPLookAndFeel(getter_AddRefs(mXPLookAndFeel));
|
||||
}
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::~nsLookAndFeel()\n"));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
|
||||
NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID,nscolor &aColor)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetColor()\n"));
|
||||
nsresult res = NS_OK;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (mXPLookAndFeel)
|
||||
{
|
||||
res = mXPLookAndFeel->GetColor(aID, aColor);
|
||||
if (NS_SUCCEEDED(res))
|
||||
return res;
|
||||
res = NS_OK;
|
||||
if (mXPLookAndFeel) {
|
||||
res = mXPLookAndFeel->GetColor(aID,aColor);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
return res;
|
||||
}
|
||||
res = NS_OK;
|
||||
}
|
||||
if (!qApp)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
QPalette palette = qApp->palette();
|
||||
QColorGroup normalGroup = palette.inactive();
|
||||
QColorGroup activeGroup = palette.active();
|
||||
QColorGroup disabledGroup = palette.disabled();
|
||||
QPalette palette = qApp->palette();
|
||||
QColorGroup normalGroup = palette.inactive();
|
||||
QColorGroup activeGroup = palette.active();
|
||||
QColorGroup disabledGroup = palette.disabled();
|
||||
|
||||
switch (aID)
|
||||
{
|
||||
switch (aID) {
|
||||
case eColor_WindowBackground:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_WindowForeground:
|
||||
aColor = normalGroup.foreground().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.foreground());
|
||||
break;
|
||||
|
||||
case eColor_WidgetBackground:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_WidgetForeground:
|
||||
aColor = normalGroup.foreground().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.foreground());
|
||||
break;
|
||||
|
||||
case eColor_WidgetSelectBackground:
|
||||
aColor = activeGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_WidgetSelectForeground:
|
||||
aColor = activeGroup.foreground().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.foreground());
|
||||
break;
|
||||
|
||||
case eColor_Widget3DHighlight:
|
||||
aColor = normalGroup.highlight().rgb();
|
||||
break;
|
||||
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
||||
break;
|
||||
|
||||
case eColor_Widget3DShadow:
|
||||
aColor = normalGroup.shadow().rgb();
|
||||
break;
|
||||
aColor = NS_RGB(0x40,0x40,0x40);
|
||||
break;
|
||||
|
||||
case eColor_TextBackground:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_TextForeground:
|
||||
aColor = normalGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_TextSelectBackground:
|
||||
aColor = activeGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlight());
|
||||
break;
|
||||
|
||||
case eColor_TextSelectForeground:
|
||||
aColor = activeGroup.foreground().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlightedText());
|
||||
break;
|
||||
|
||||
case eColor_activeborder:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_activecaption:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_appworkspace:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_background:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_captiontext:
|
||||
aColor = normalGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_graytext:
|
||||
aColor = disabledGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(disabledGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_highlight:
|
||||
aColor = activeGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlight());
|
||||
break;
|
||||
|
||||
case eColor_highlighttext:
|
||||
aColor = activeGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlightedText());
|
||||
break;
|
||||
|
||||
case eColor_inactiveborder:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_inactivecaption:
|
||||
aColor = disabledGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(disabledGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_inactivecaptiontext:
|
||||
aColor = disabledGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(disabledGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_infobackground:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_infotext:
|
||||
aColor = normalGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_menu:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_menutext:
|
||||
aColor = normalGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_scrollbar:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_threedface:
|
||||
case eColor_buttonface:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_buttonhighlight:
|
||||
case eColor_threedhighlight:
|
||||
aColor = normalGroup.light().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.light());
|
||||
break;
|
||||
|
||||
case eColor_buttontext:
|
||||
aColor = normalGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
|
||||
break;
|
||||
|
||||
case eColor_buttonshadow:
|
||||
case eColor_threeddarkshadow:
|
||||
case eColor_threedshadow: // i think these should be the same
|
||||
aColor = normalGroup.dark().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.shadow());
|
||||
break;
|
||||
|
||||
case eColor_threeddarkshadow:
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.dark());
|
||||
break;
|
||||
|
||||
case eColor_threedlightshadow:
|
||||
aColor = normalGroup.light().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.light());
|
||||
break;
|
||||
|
||||
case eColor_window:
|
||||
case eColor_windowframe:
|
||||
aColor = normalGroup.background().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
|
||||
break;
|
||||
|
||||
case eColor_windowtext:
|
||||
aColor = normalGroup.text().rgb();
|
||||
break;
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
|
||||
break;
|
||||
|
||||
// from the CSS3 working draft (not yet finalized)
|
||||
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
|
||||
case eColor__moz_field:
|
||||
aColor = QCOLOR_TO_NS_RGB(normalGroup.base());
|
||||
break;
|
||||
|
||||
case eColor__moz_dragtargetzone:
|
||||
aColor = QCOLOR_TO_NS_RGB(activeGroup.background());
|
||||
break;
|
||||
|
||||
default:
|
||||
aColor = 0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
aColor = 0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
||||
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID,PRInt32 &aMetric)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n"));
|
||||
nsresult res = NS_OK;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (mXPLookAndFeel)
|
||||
{
|
||||
res = mXPLookAndFeel->GetMetric(aID, aMetric);
|
||||
if (NS_SUCCEEDED(res))
|
||||
return res;
|
||||
res = NS_OK;
|
||||
}
|
||||
|
||||
switch (aID)
|
||||
{
|
||||
if (mXPLookAndFeel) {
|
||||
res = mXPLookAndFeel->GetMetric(aID, aMetric);
|
||||
if (NS_SUCCEEDED(res))
|
||||
return res;
|
||||
res = NS_OK;
|
||||
}
|
||||
switch (aID) {
|
||||
case eMetric_WindowTitleHeight:
|
||||
aMetric = 0;
|
||||
break;
|
||||
aMetric = 0;
|
||||
break;
|
||||
|
||||
case eMetric_WindowBorderWidth:
|
||||
break;
|
||||
break;
|
||||
|
||||
case eMetric_WindowBorderHeight:
|
||||
break;
|
||||
break;
|
||||
|
||||
case eMetric_Widget3DBorder:
|
||||
break;
|
||||
break;
|
||||
|
||||
case eMetric_TextFieldHeight:
|
||||
aMetric = 15;
|
||||
break;
|
||||
aMetric = 15;
|
||||
break;
|
||||
|
||||
case eMetric_TextFieldBorder:
|
||||
aMetric = 2;
|
||||
break;
|
||||
aMetric = 2;
|
||||
break;
|
||||
|
||||
case eMetric_TextVerticalInsidePadding:
|
||||
aMetric = 0;
|
||||
break;
|
||||
aMetric = 0;
|
||||
break;
|
||||
|
||||
case eMetric_TextShouldUseVerticalInsidePadding:
|
||||
aMetric = 0;
|
||||
break;
|
||||
aMetric = 0;
|
||||
break;
|
||||
|
||||
case eMetric_TextHorizontalInsideMinimumPadding:
|
||||
aMetric = 15;
|
||||
break;
|
||||
aMetric = 15;
|
||||
break;
|
||||
|
||||
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
|
||||
aMetric = 1;
|
||||
break;
|
||||
aMetric = 1;
|
||||
break;
|
||||
|
||||
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
|
||||
aMetric = 10;
|
||||
break;
|
||||
aMetric = 10;
|
||||
break;
|
||||
|
||||
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
|
||||
aMetric = 8;
|
||||
break;
|
||||
aMetric = 8;
|
||||
break;
|
||||
|
||||
case eMetric_CheckboxSize:
|
||||
aMetric = 15;
|
||||
break;
|
||||
aMetric = 15;
|
||||
break;
|
||||
|
||||
case eMetric_RadioboxSize:
|
||||
aMetric = 15;
|
||||
break;
|
||||
aMetric = 15;
|
||||
break;
|
||||
|
||||
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
|
||||
aMetric = 15;
|
||||
break;
|
||||
aMetric = 15;
|
||||
break;
|
||||
|
||||
case eMetric_ListHorizontalInsideMinimumPadding:
|
||||
aMetric = 15;
|
||||
break;
|
||||
aMetric = 15;
|
||||
break;
|
||||
|
||||
case eMetric_ListShouldUseVerticalInsidePadding:
|
||||
aMetric = 1;
|
||||
break;
|
||||
aMetric = 1;
|
||||
break;
|
||||
|
||||
case eMetric_ListVerticalInsidePadding:
|
||||
aMetric = 1;
|
||||
break;
|
||||
aMetric = 1;
|
||||
break;
|
||||
|
||||
case eMetric_CaretBlinkTime:
|
||||
aMetric = 500;
|
||||
break;
|
||||
aMetric = 500;
|
||||
break;
|
||||
|
||||
case eMetric_SingleLineCaretWidth:
|
||||
case eMetric_MultiLineCaretWidth:
|
||||
aMetric = 1;
|
||||
break;
|
||||
case eMetric_SubmenuDelay:
|
||||
aMetric = 200;
|
||||
break;
|
||||
case eMetric_MenusCanOverlapOSBar:
|
||||
// we want XUL popups to be able to overlap the task bar.
|
||||
aMetric = 1;
|
||||
break;
|
||||
default:
|
||||
aMetric = 0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
aMetric = 1;
|
||||
break;
|
||||
|
||||
return res;
|
||||
case eMetric_ShowCaretDuringSelection:
|
||||
aMetric = 0;
|
||||
break;
|
||||
|
||||
case eMetric_SubmenuDelay:
|
||||
aMetric = 200;
|
||||
break;
|
||||
|
||||
case eMetric_MenusCanOverlapOSBar:
|
||||
// we want XUL popups to be able to overlap the task bar.
|
||||
aMetric = 1;
|
||||
break;
|
||||
|
||||
case eMetric_DragFullWindow:
|
||||
aMetric = 1;
|
||||
break;
|
||||
|
||||
case eMetric_ScrollArrowStyle:
|
||||
aMetric = eMetric_ScrollArrowStyleSingle;
|
||||
break;
|
||||
|
||||
case eMetric_ScrollSliderStyle:
|
||||
aMetric = eMetric_ScrollThumbStyleProportional;
|
||||
break;
|
||||
|
||||
default:
|
||||
aMetric = 0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID,
|
||||
float & aMetric)
|
||||
float &aMetric)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n"));
|
||||
nsresult res = NS_OK;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (mXPLookAndFeel)
|
||||
{
|
||||
res = mXPLookAndFeel->GetMetric(aID, aMetric);
|
||||
if (NS_SUCCEEDED(res))
|
||||
return res;
|
||||
res = NS_OK;
|
||||
}
|
||||
|
||||
switch (aID)
|
||||
{
|
||||
if (mXPLookAndFeel) {
|
||||
res = mXPLookAndFeel->GetMetric(aID, aMetric);
|
||||
if (NS_SUCCEEDED(res))
|
||||
return res;
|
||||
res = NS_OK;
|
||||
}
|
||||
switch (aID) {
|
||||
case eMetricFloat_TextFieldVerticalInsidePadding:
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
|
||||
case eMetricFloat_TextFieldHorizontalInsidePadding:
|
||||
aMetric = 0.95f; // large number on purpose so minimum padding is used
|
||||
break;
|
||||
aMetric = 0.95f; // large number on purpose so minimum padding is used
|
||||
break;
|
||||
|
||||
case eMetricFloat_TextAreaVerticalInsidePadding:
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
|
||||
case eMetricFloat_TextAreaHorizontalInsidePadding:
|
||||
aMetric = 0.40f; // large number on purpose so minimum padding is used
|
||||
break;
|
||||
aMetric = 0.40f; // large number on purpose so minimum padding is used
|
||||
break;
|
||||
|
||||
case eMetricFloat_ListVerticalInsidePadding:
|
||||
aMetric = 0.10f;
|
||||
break;
|
||||
aMetric = 0.10f;
|
||||
break;
|
||||
|
||||
case eMetricFloat_ListHorizontalInsidePadding:
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
|
||||
case eMetricFloat_ButtonVerticalInsidePadding:
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
|
||||
case eMetricFloat_ButtonHorizontalInsidePadding:
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
|
||||
default:
|
||||
aMetric = -1.0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
return res;
|
||||
aMetric = -1.0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID,
|
||||
const nsMetricNavFontID aFontID,
|
||||
const PRInt32 aFontSize,
|
||||
nsSize &aSize)
|
||||
const nsMetricNavFontID aFontID,
|
||||
const PRInt32 aFontSize,nsSize &aSize)
|
||||
{
|
||||
if (mXPLookAndFeel)
|
||||
{
|
||||
nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize);
|
||||
if (mXPLookAndFeel) {
|
||||
nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID,aFontID,aFontSize,aSize);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
aSize.width = 0;
|
||||
aSize.height = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -18,18 +18,20 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __nsLookAndFeel
|
||||
#define __nsLookAndFeel
|
||||
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsLookAndFeel: public nsILookAndFeel
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
nsLookAndFeel();
|
||||
virtual ~nsLookAndFeel();
|
||||
|
||||
|
@ -43,9 +45,8 @@ public:
|
|||
// and font size. This is used in NavQuirks mode to see how closely
|
||||
// we match its size
|
||||
NS_IMETHOD GetNavSize(const nsMetricNavWidgetID aWidgetID,
|
||||
const nsMetricNavFontID aFontID,
|
||||
const PRInt32 aFontSize,
|
||||
nsSize &aSize);
|
||||
const nsMetricNavFontID aFontID,
|
||||
const PRInt32 aFontSize,nsSize &aSize);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsDragService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsWidget.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsPrimitiveHelpers.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsMime.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qclipboard.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsMimeStoreData::nsMimeStoreData(QCString& name, QByteArray& data)
|
||||
{
|
||||
flavorName = name;
|
||||
flavorData = data;
|
||||
}
|
||||
|
||||
nsMimeStoreData::nsMimeStoreData(const char* name,void* rawdata,PRInt32 rawlen)
|
||||
{
|
||||
flavorName = name;
|
||||
flavorData.assign((char*)rawdata,(unsigned int)rawlen);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsMimeStore::nsMimeStore()
|
||||
{
|
||||
mMimeStore.setAutoDelete(TRUE);
|
||||
}
|
||||
|
||||
nsMimeStore::~nsMimeStore()
|
||||
{
|
||||
}
|
||||
|
||||
const char* nsMimeStore::format(int n) const
|
||||
{
|
||||
if (n >= (int)mMimeStore.count())
|
||||
return 0;
|
||||
|
||||
// because of const
|
||||
QList<nsMimeStoreData> *pMimeStore = (QList<nsMimeStoreData>*)&mMimeStore;
|
||||
|
||||
nsMimeStoreData* msd;
|
||||
msd = pMimeStore->at((unsigned int)n);
|
||||
return msd->flavorName;
|
||||
}
|
||||
|
||||
QByteArray nsMimeStore::encodedData(const char* name) const
|
||||
{
|
||||
QByteArray qba;
|
||||
|
||||
// because of const
|
||||
QList<nsMimeStoreData> *pMimeStore = (QList<nsMimeStoreData>*)&mMimeStore;
|
||||
|
||||
nsMimeStoreData* msd;
|
||||
for (msd = pMimeStore->first(); msd != 0; msd = pMimeStore->next()) {
|
||||
if (strcmp(name, msd->flavorName) == 0) {
|
||||
qba = msd->flavorData;
|
||||
return qba;
|
||||
}
|
||||
}
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsMimeStore::encodedData requested unkown %s\n", name);
|
||||
#endif
|
||||
return qba;
|
||||
}
|
||||
|
||||
PRBool nsMimeStore::AddFlavorData(const char* name, void* data, PRInt32 len)
|
||||
{
|
||||
nsMimeStoreData* msd;
|
||||
for (msd = mMimeStore.first(); msd != 0; msd = mMimeStore.next()) {
|
||||
if (strcmp(name, msd->flavorName) == 0)
|
||||
return PR_FALSE;
|
||||
}
|
||||
mMimeStore.append(new nsMimeStoreData(name, data, len));
|
||||
|
||||
if (strcmp(name, kUnicodeMime) == 0) {
|
||||
// let's look if text/plain is not present yet
|
||||
for (msd = mMimeStore.first(); msd != 0; msd = mMimeStore.next()) {
|
||||
if (strcmp("text/plain", msd->flavorName) == 0)
|
||||
return PR_TRUE;
|
||||
}
|
||||
// if we find text/unicode, also advertise text/plain (which we will convert
|
||||
// on our own in nsDataObj::GetText().
|
||||
len /= 2;
|
||||
QChar* qch = new QChar[len];
|
||||
for (PRInt32 c = 0; c < len; c++)
|
||||
qch[c] = (QChar)((PRUnichar*)data)[c];
|
||||
|
||||
QString ascii(qch, len);
|
||||
delete qch;
|
||||
char *as = new char[len];
|
||||
for (PRInt32 c = 0; c < len; c++)
|
||||
as[c] = ((const char*)ascii)[c];
|
||||
|
||||
// let's text/plain be first for stupid programms
|
||||
mMimeStore.insert(0, new nsMimeStoreData("text/plain", as, len));
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
nsDragObject::nsDragObject(nsMimeStore* mimeStore,QWidget* dragSource,
|
||||
const char* name)
|
||||
: QDragObject(dragSource, name)
|
||||
{
|
||||
if (!mimeStore)
|
||||
NS_ASSERTION(PR_TRUE, "Invalid pointer.");
|
||||
|
||||
mMimeStore = mimeStore;
|
||||
}
|
||||
|
||||
nsDragObject::~nsDragObject()
|
||||
{
|
||||
delete mMimeStore;
|
||||
}
|
||||
|
||||
const char* nsDragObject::format(int i) const
|
||||
{
|
||||
if (i >= (int)mMimeStore->count())
|
||||
return 0;
|
||||
|
||||
const char* frm = mMimeStore->format(i);
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsDragObject::format i=%i %s\n",i, frm);
|
||||
#endif
|
||||
return frm;
|
||||
}
|
||||
|
||||
QByteArray nsDragObject::encodedData(const char* frm) const
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsDragObject::encodedData %s\n",frm);
|
||||
#endif
|
||||
return mMimeStore->encodedData(frm);
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
*
|
||||
*/
|
||||
#ifndef nsMime_h__
|
||||
#define nsMime_h__
|
||||
|
||||
#include "nsITransferable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qcstring.h>
|
||||
#include <qmime.h>
|
||||
#include <qwidget.h>
|
||||
#include <qdragobject.h>
|
||||
|
||||
class nsMimeStoreData
|
||||
{
|
||||
public:
|
||||
nsMimeStoreData(QCString& name, QByteArray& data);
|
||||
nsMimeStoreData(const char* name, void* rawdata, PRInt32 rawlen);
|
||||
|
||||
QCString flavorName;
|
||||
QByteArray flavorData;
|
||||
};
|
||||
|
||||
class nsMimeStore: public QMimeSource
|
||||
{
|
||||
public:
|
||||
nsMimeStore();
|
||||
virtual ~nsMimeStore();
|
||||
|
||||
virtual const char* format(int n = 0) const ;
|
||||
virtual QByteArray encodedData(const char*) const;
|
||||
|
||||
PRBool AddFlavorData(const char* name, void* data, PRInt32 len);
|
||||
|
||||
PRUint32 count();
|
||||
|
||||
protected:
|
||||
QList<nsMimeStoreData> mMimeStore;
|
||||
nsMimeStoreData* at(int n);
|
||||
};
|
||||
|
||||
inline PRUint32 nsMimeStore::count() { return mMimeStore.count(); }
|
||||
|
||||
//----------------------------------------------------------
|
||||
class nsDragObject : public QDragObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsDragObject(nsMimeStore* mimeStore,QWidget* dragSource = 0,
|
||||
const char* name = 0);
|
||||
~nsDragObject();
|
||||
|
||||
const char* format(int i) const;
|
||||
virtual QByteArray encodedData(const char*) const;
|
||||
|
||||
protected:
|
||||
nsMimeStore* mMimeStore;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -18,82 +18,134 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsQApplication.h"
|
||||
//JCG #define DBG_JCG 1
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Required for x11EventFilter debugging hook */
|
||||
#include "nsQApplication.h"
|
||||
#include "nsQWidget.h"
|
||||
|
||||
#include <qwindowsstyle.h>
|
||||
#include <qcursor.h>
|
||||
|
||||
#ifdef DBG_JCG
|
||||
/* Required for x11EventFilter & _x_error debugging hooks */
|
||||
#include "X11/Xlib.h"
|
||||
#include <assert.h>
|
||||
|
||||
PRInt32 gQAppID = 0;
|
||||
PRInt32 gQAppCount = 0;
|
||||
|
||||
PRInt32 gQQueueID = 0;
|
||||
PRInt32 gQQueueCount = 0;
|
||||
#endif
|
||||
|
||||
nsQApplication *nsQApplication::mInstance = nsnull;
|
||||
QIntDict<nsQtEventQueue> nsQApplication::mQueueDict;
|
||||
PRUint32 nsQApplication::mRefCnt = 0;
|
||||
QWidget *nsQApplication::mMasterWidget = nsnull;
|
||||
|
||||
nsQApplication *nsQApplication::Instance(int argc, char ** argv)
|
||||
#ifdef DBG_JCG
|
||||
int _x_error(Display *display, XErrorEvent *error)
|
||||
{
|
||||
if (error->error_code) {
|
||||
char buf[64];
|
||||
|
||||
XGetErrorText (display, error->error_code, buf, 63);
|
||||
|
||||
fprintf(stderr,
|
||||
"X-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d, resourceId: %ld\n",
|
||||
buf, error->serial, error->error_code, error->request_code,
|
||||
error->minor_code,error->resourceid);
|
||||
|
||||
printf("X-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d, resourceId: %ld\n",
|
||||
buf, error->serial, error->error_code, error->request_code,
|
||||
error->minor_code,error->resourceid);
|
||||
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif //DBG_JCG
|
||||
|
||||
nsQApplication* nsQApplication::Instance(int argc,char** argv)
|
||||
{
|
||||
if (!mInstance)
|
||||
mInstance = new nsQApplication(argc,argv);
|
||||
|
||||
mRefCnt++;
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
nsQApplication *nsQApplication::Instance(Display * display)
|
||||
{
|
||||
if (!mInstance)
|
||||
mInstance = new nsQApplication(display);
|
||||
|
||||
mRefCnt++;
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
void nsQApplication::Release()
|
||||
{
|
||||
mRefCnt--;
|
||||
if (mRefCnt <= 0)
|
||||
if (mRefCnt <= 0) {
|
||||
if (mMasterWidget) {
|
||||
delete mMasterWidget;
|
||||
mMasterWidget = nsnull;
|
||||
}
|
||||
delete mInstance;
|
||||
mInstance = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsQApplication::nsQApplication(int argc, char ** argv)
|
||||
: QApplication(argc, argv)
|
||||
QWidget *nsQApplication::GetMasterWidget()
|
||||
{
|
||||
if (mInstance)
|
||||
NS_ASSERTION(mInstance == nsnull,"Attempt to create duplicate QApplication Object.");
|
||||
mInstance = this;
|
||||
setGlobalMouseTracking(true);
|
||||
if (!mMasterWidget)
|
||||
mMasterWidget = new QWidget();
|
||||
|
||||
return mMasterWidget;
|
||||
}
|
||||
|
||||
nsQApplication::nsQApplication(Display * display)
|
||||
: QApplication(display)
|
||||
nsQApplication::nsQApplication(int argc,char** argv)
|
||||
: QApplication(argc,argv)
|
||||
{
|
||||
if (mInstance)
|
||||
NS_ASSERTION(mInstance == nsnull,"Attempt to create duplicate QApplication Object.");
|
||||
mInstance = this;
|
||||
setGlobalMouseTracking(true);
|
||||
#ifdef DBG_JCG
|
||||
gQAppCount++;
|
||||
mID = gQAppID++;
|
||||
printf("JCG nsQApplication CTOR (%p) ID: %d, Count: %d\n",this,mID,gQAppCount);
|
||||
|
||||
XSetErrorHandler (_x_error);
|
||||
#endif
|
||||
if (mInstance)
|
||||
NS_ASSERTION(mInstance == nsnull,
|
||||
"Attempt to create duplicate QApplication Object.");
|
||||
mInstance = this;
|
||||
setGlobalMouseTracking(true);
|
||||
setStyle(new QWindowsStyle);
|
||||
setOverrideCursor(QCursor(ArrowCursor),PR_TRUE);
|
||||
connect(this,SIGNAL(lastWindowClosed()),this,SLOT(quit()));
|
||||
}
|
||||
|
||||
nsQApplication::~nsQApplication()
|
||||
{
|
||||
setGlobalMouseTracking(false);
|
||||
#ifdef DBG_JCG
|
||||
gQAppCount--;
|
||||
printf("JCG nsQApplication DTOR (%p) ID: %d, Count: %d\n",this,mID,gQAppCount);
|
||||
#endif
|
||||
setGlobalMouseTracking(false);
|
||||
}
|
||||
|
||||
void nsQApplication::AddEventProcessorCallback(nsIEventQueue * EQueue)
|
||||
void nsQApplication::AddEventProcessorCallback(nsIEventQueue* EQueue)
|
||||
{
|
||||
nsQtEventQueue *que = nsnull;
|
||||
nsQtEventQueue* que = nsnull;
|
||||
|
||||
if ((que = mQueueDict.find(EQueue->GetEventQueueSelectFD()))) {
|
||||
que->IncRefCnt();
|
||||
}
|
||||
else {
|
||||
mQueueDict.insert(EQueue->GetEventQueueSelectFD(),new nsQtEventQueue(EQueue));
|
||||
mQueueDict.insert(EQueue->GetEventQueueSelectFD(),
|
||||
new nsQtEventQueue(EQueue));
|
||||
}
|
||||
}
|
||||
|
||||
void nsQApplication::RemoveEventProcessorCallback(nsIEventQueue * EQueue)
|
||||
void nsQApplication::RemoveEventProcessorCallback(nsIEventQueue* EQueue)
|
||||
{
|
||||
nsQtEventQueue *que = nsnull;
|
||||
nsQtEventQueue* que = nsnull;
|
||||
|
||||
if ((que = mQueueDict.find(EQueue->GetEventQueueSelectFD()))) {
|
||||
que->DataReceived();
|
||||
|
@ -104,52 +156,256 @@ void nsQApplication::RemoveEventProcessorCallback(nsIEventQueue * EQueue)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Hook for capturing X11 Events before they are processed by Qt */
|
||||
bool nsQApplication::x11EventFilter(XEvent *event)
|
||||
bool nsQApplication::x11EventFilter(XEvent* event)
|
||||
{
|
||||
if (event->type == ButtonPress || event->type == ButtonRelease) {
|
||||
int i;
|
||||
#ifdef DBG_JCG
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
{
|
||||
XButtonPressedEvent *ptr = (XButtonPressedEvent*)event;
|
||||
printf("JCG: ButtonPress/Release: serial %ld, Window: %ld, Root: %ld, Child: %ld\n",ptr->serial,ptr->window,ptr->root,ptr->subwindow);
|
||||
}
|
||||
break;
|
||||
|
||||
/* Break here to see Mouse Button Events */
|
||||
i = 0;
|
||||
case CirculateNotify:
|
||||
{
|
||||
XCirculateEvent *ptr = (XCirculateEvent*)event;
|
||||
printf("JCG: CirculateNotify: serial %ld, Event: %ld, Window: %ld\n",ptr->serial,ptr->event,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case CirculateRequest:
|
||||
{
|
||||
XCirculateRequestEvent *ptr = (XCirculateRequestEvent*)event;
|
||||
printf("JCG: CirculateRequest: serial %ld, Parent: %ld, Window: %ld\n",ptr->serial,ptr->parent,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case ClientMessage:
|
||||
{
|
||||
XClientMessageEvent *ptr = (XClientMessageEvent*)event;
|
||||
printf("JCG: ClientMessage: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case ColormapNotify:
|
||||
{
|
||||
XColormapEvent *ptr = (XColormapEvent*)event;
|
||||
printf("JCG: ColormapNotify: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
{
|
||||
XConfigureEvent *ptr = (XConfigureEvent*)event;
|
||||
printf("JCG: ConfigureNotify: serial %ld, Event: %ld, Window: %ld\n",ptr->serial,ptr->event,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case ConfigureRequest:
|
||||
{
|
||||
XConfigureRequestEvent *ptr = (XConfigureRequestEvent*)event;
|
||||
printf("JCG: ConfigureRequest: serial %ld, Parent: %ld, Window: %ld\n",ptr->serial,ptr->parent,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case CreateNotify:
|
||||
{
|
||||
XCreateWindowEvent *ptr = (XCreateWindowEvent*)event;
|
||||
printf("JCG: CreateNotify: serial %ld, Parent: %ld, Window: %ld\n",ptr->serial,ptr->parent,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
{
|
||||
XDestroyWindowEvent *ptr = (XDestroyWindowEvent*)event;
|
||||
printf("JCG: DestroyNotify: serial %ld, Event: %ld, Window: %ld\n",ptr->serial,ptr->event,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
{
|
||||
XCrossingEvent *ptr = (XCrossingEvent*)event;
|
||||
printf("JCG: Enter/LeaveNotify: serial %ld, Window: %ld, Parent: %ld, Child: %ld\n",ptr->serial,ptr->window,ptr->root,ptr->subwindow);
|
||||
}
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
{
|
||||
XExposeEvent *ptr = (XExposeEvent*)event;
|
||||
printf("JCG: Expose: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case FocusIn:
|
||||
case FocusOut:
|
||||
{
|
||||
XFocusChangeEvent *ptr = (XFocusChangeEvent*)event;
|
||||
printf("JCG: FocusIn/Out: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case GraphicsExpose:
|
||||
case NoExpose:
|
||||
{
|
||||
printf("JCG: Graphics/NoExpose\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case GravityNotify:
|
||||
{
|
||||
XGravityEvent *ptr = (XGravityEvent*)event;
|
||||
printf("JCG: GravityNotify: serial %ld, Event: %ld, Window: %ld\n",ptr->serial,ptr->event,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case KeymapNotify:
|
||||
{
|
||||
XKeymapEvent *ptr = (XKeymapEvent*)event;
|
||||
printf("JCG: KeymapNotify: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
{
|
||||
XKeyEvent *ptr = (XKeyEvent*)event;
|
||||
printf("JCG: KeyPress/Release: serial %ld, Window: %ld, Parent: %ld, Child: %ld\n",ptr->serial,ptr->window,ptr->root,ptr->subwindow);
|
||||
}
|
||||
break;
|
||||
|
||||
case MapNotify:
|
||||
case UnmapNotify:
|
||||
{
|
||||
XMapEvent *ptr = (XMapEvent*)event;
|
||||
printf("JCG: Map/UnmapNotify: serial %ld, Window: %ld, Event: %ld\n",ptr->serial,ptr->window,ptr->event);
|
||||
}
|
||||
break;
|
||||
|
||||
case MappingNotify:
|
||||
{
|
||||
XMappingEvent *ptr = (XMappingEvent*)event;
|
||||
printf("JCG: MappingNotify: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case MapRequest:
|
||||
{
|
||||
XMapRequestEvent *ptr = (XMapRequestEvent*)event;
|
||||
printf("JCG: MapRequest: serial %ld, Window: %ld, Parent: %ld\n",ptr->serial,ptr->window,ptr->parent);
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
{
|
||||
XMotionEvent *ptr = (XMotionEvent*)event;
|
||||
printf("JCG: MotionNotify: serial %ld, Window: %ld, Parent: %ld, Child: %ld\n",ptr->serial,ptr->window,ptr->root,ptr->subwindow);
|
||||
}
|
||||
break;
|
||||
|
||||
case PropertyNotify:
|
||||
{
|
||||
XPropertyEvent *ptr = (XPropertyEvent*)event;
|
||||
printf("JCG: PropertyNotify: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case ReparentNotify:
|
||||
{
|
||||
XReparentEvent *ptr = (XReparentEvent*)event;
|
||||
printf("JCG: ReparentNotify: serial %ld, Window: %ld, Parent: %ld, Event: %ld\n",ptr->serial,ptr->window,ptr->parent,ptr->event);
|
||||
}
|
||||
break;
|
||||
|
||||
case ResizeRequest:
|
||||
{
|
||||
XResizeRequestEvent *ptr = (XResizeRequestEvent*)event;
|
||||
printf("JCG: ResizeRequest: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case SelectionClear:
|
||||
{
|
||||
XSelectionClearEvent *ptr = (XSelectionClearEvent*)event;
|
||||
printf("JCG: SelectionClear: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case SelectionNotify:
|
||||
{
|
||||
XSelectionEvent *ptr = (XSelectionEvent*)event;
|
||||
printf("JCG: SelectionNotify: serial %ld, Requestor: %ld\n",ptr->serial,ptr->requestor);
|
||||
}
|
||||
break;
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
XSelectionRequestEvent *ptr = (XSelectionRequestEvent*)event;
|
||||
printf("JCG: SelectionRequest: serial %ld, Owner: %ld, Requestor: %ld\n",ptr->serial,ptr->owner,ptr->requestor);
|
||||
}
|
||||
break;
|
||||
|
||||
case VisibilityNotify:
|
||||
{
|
||||
XVisibilityEvent *ptr = (XVisibilityEvent*)event;
|
||||
printf("JCG: VisibilityNotify: serial %ld, Window: %ld\n",ptr->serial,ptr->window);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
printf("JCG: Unknown Event: %d\n",event->type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif //DBG_JCG
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsQtEventQueue::nsQtEventQueue(nsIEventQueue * EQueue)
|
||||
nsQtEventQueue::nsQtEventQueue(nsIEventQueue* EQueue)
|
||||
{
|
||||
mQSocket = nsnull;
|
||||
mEventQueue = EQueue;
|
||||
NS_IF_ADDREF(mEventQueue);
|
||||
mRefCnt = 1;
|
||||
#ifdef DBG_JCG
|
||||
mID = gQQueueID++;
|
||||
gQQueueCount++;
|
||||
printf("JCG nsQtEventQueue CTOR (%p) ID: %d, Count: %d\n",this,mID,gQQueueCount);
|
||||
#endif
|
||||
mQSocket = nsnull;
|
||||
mEventQueue = EQueue;
|
||||
NS_IF_ADDREF(mEventQueue);
|
||||
mRefCnt = 1;
|
||||
|
||||
mQSocket = new QSocketNotifier(mEventQueue->GetEventQueueSelectFD(),
|
||||
QSocketNotifier::Read,this);
|
||||
if (mQSocket)
|
||||
connect(mQSocket, SIGNAL(activated(int)), this, SLOT(DataReceived()));
|
||||
mQSocket = new QSocketNotifier(mEventQueue->GetEventQueueSelectFD(),
|
||||
QSocketNotifier::Read,this);
|
||||
if (mQSocket)
|
||||
connect(mQSocket,SIGNAL(activated(int)),this,SLOT(DataReceived()));
|
||||
}
|
||||
|
||||
nsQtEventQueue::~nsQtEventQueue()
|
||||
{
|
||||
if (mQSocket)
|
||||
delete mQSocket;
|
||||
NS_IF_RELEASE(mEventQueue);
|
||||
#ifdef DBG_JCG
|
||||
gQQueueCount--;
|
||||
printf("JCG nsQtEventQueue DTOR (%p) ID: %d, Count: %d\n",this,mID,gQQueueCount);
|
||||
#endif
|
||||
if (mQSocket)
|
||||
delete mQSocket;
|
||||
NS_IF_RELEASE(mEventQueue);
|
||||
}
|
||||
|
||||
unsigned long nsQtEventQueue::IncRefCnt()
|
||||
{
|
||||
return --mRefCnt;
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
unsigned long nsQtEventQueue::DecRefCnt()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
return --mRefCnt;
|
||||
}
|
||||
|
||||
void nsQtEventQueue::DataReceived()
|
||||
{
|
||||
if (mEventQueue)
|
||||
mEventQueue->ProcessPendingEvents();
|
||||
if (mEventQueue)
|
||||
mEventQueue->ProcessPendingEvents();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsQApplication_h__
|
||||
#define nsQApplication_h__
|
||||
|
||||
|
@ -29,47 +30,49 @@
|
|||
|
||||
class nsQtEventQueue : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsQtEventQueue(nsIEventQueue *EQueue);
|
||||
~nsQtEventQueue();
|
||||
unsigned long IncRefCnt();
|
||||
unsigned long DecRefCnt();
|
||||
nsQtEventQueue(nsIEventQueue *EQueue);
|
||||
~nsQtEventQueue();
|
||||
unsigned long IncRefCnt();
|
||||
unsigned long DecRefCnt();
|
||||
|
||||
public slots:
|
||||
void DataReceived();
|
||||
void DataReceived();
|
||||
|
||||
private:
|
||||
nsIEventQueue *mEventQueue;
|
||||
QSocketNotifier *mQSocket;
|
||||
unsigned long mRefCnt;
|
||||
nsIEventQueue *mEventQueue;
|
||||
QSocketNotifier *mQSocket;
|
||||
PRUint32 mRefCnt;
|
||||
PRInt32 mID;
|
||||
};
|
||||
|
||||
class nsQApplication : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
static nsQApplication *Instance(int argc, char ** argv);
|
||||
static nsQApplication *Instance(Display * display);
|
||||
static nsQApplication *Instance(int argc,char **argv);
|
||||
|
||||
static void Release();
|
||||
static void Release();
|
||||
|
||||
static void AddEventProcessorCallback(nsIEventQueue * EQueue);
|
||||
static void RemoveEventProcessorCallback(nsIEventQueue * EQueue);
|
||||
static void AddEventProcessorCallback(nsIEventQueue *EQueue);
|
||||
static void RemoveEventProcessorCallback(nsIEventQueue *EQueue);
|
||||
|
||||
#ifdef DEBUG
|
||||
bool x11EventFilter(XEvent *event);
|
||||
#endif
|
||||
static QWidget *GetMasterWidget();
|
||||
|
||||
///Hook for debugging X11 Events
|
||||
bool x11EventFilter(XEvent *event);
|
||||
|
||||
protected:
|
||||
nsQApplication(int argc, char ** argv);
|
||||
nsQApplication(Display * display);
|
||||
~nsQApplication();
|
||||
nsQApplication(int argc,char **argv);
|
||||
~nsQApplication();
|
||||
|
||||
private:
|
||||
static QIntDict<nsQtEventQueue> mQueueDict;
|
||||
static nsQApplication *mInstance;
|
||||
static PRUint32 mRefCnt;
|
||||
PRInt32 mID;
|
||||
static QIntDict<nsQtEventQueue> mQueueDict;
|
||||
static nsQApplication *mInstance;
|
||||
static PRUint32 mRefCnt;
|
||||
static QWidget *mMasterWidget;
|
||||
};
|
||||
|
||||
#endif // nsQApplication_h__
|
||||
|
|
|
@ -18,37 +18,24 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "nsWidget.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsTextWidget.h"
|
||||
#include "nsCheckButton.h"
|
||||
#include "nsRadioButton.h"
|
||||
#include "nsScrollbar.h"
|
||||
#include "nsFileWidget.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIMenuItem.h"
|
||||
#include "nsIMenuListener.h"
|
||||
#include "stdio.h"
|
||||
#include "nsQEventHandler.h"
|
||||
|
||||
//JCG #define DBG 1
|
||||
#ifdef DBG
|
||||
PRUint32 gQEventHandlerCount = 0;
|
||||
//JCG #define DBG_JCG 1
|
||||
#ifdef DBG_JCG
|
||||
PRUint32 gQEventHandlerCount = 0;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
||||
|
||||
struct EventInfo
|
||||
{
|
||||
nsWidget *widget; // the widget
|
||||
nsRect *rect; // the rect
|
||||
};
|
||||
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
||||
|
||||
#if 0 //JCG
|
||||
struct nsKeyConverter
|
||||
{
|
||||
int vkCode; // Platform independent key code
|
||||
|
@ -176,6 +163,7 @@ struct nsKeyConverter nsKeycodes[] =
|
|||
{ NS_VK_CLOSE_BRACKET, Qt::Key_ParenRight },
|
||||
{ NS_VK_QUOTE, Qt::Key_QuoteDbl }
|
||||
};
|
||||
#endif //JCG
|
||||
|
||||
PRLogModuleInfo * QtEventsLM = PR_NewLogModule("QtEvents");
|
||||
|
||||
|
@ -185,23 +173,23 @@ PRLogModuleInfo * QtEventsLM = PR_NewLogModule("QtEvents");
|
|||
*/
|
||||
nsQEventHandler::nsQEventHandler(nsWidget *aWidget) : QObject()
|
||||
{
|
||||
PR_LOG(QtEventsLM, PR_LOG_DEBUG, ("nsQEventHandler::nsQEventHandler()\n"));
|
||||
mEnabled = true;
|
||||
mDestroyed = false;
|
||||
mWidget = aWidget;
|
||||
#ifdef DBG
|
||||
PR_LOG(QtEventsLM, PR_LOG_DEBUG, ("nsQEventHandler::nsQEventHandler()\n"));
|
||||
mEnabled = true;
|
||||
mDestroyed = false;
|
||||
mWidget = aWidget;
|
||||
#ifdef DBG_JCG
|
||||
gQEventHandlerCount++;
|
||||
printf("DBG: nsQEventHandler CTOR. Count: %d\n",gQEventHandlerCount);
|
||||
printf("JCG: nsQEventHandler CTOR. Count: %d\n",gQEventHandlerCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsQEventHandler::~nsQEventHandler()
|
||||
{
|
||||
PR_LOG(QtEventsLM, PR_LOG_DEBUG, ("nsQEventHandler::~nsQEventHandler()\n"));
|
||||
mWidget = nsnull;
|
||||
#ifdef DBG
|
||||
PR_LOG(QtEventsLM, PR_LOG_DEBUG, ("nsQEventHandler::~nsQEventHandler()\n"));
|
||||
mWidget = nsnull;
|
||||
#ifdef DBG_JCG
|
||||
gQEventHandlerCount--;
|
||||
printf("DBG: nsQEventHandler DTOR. Count: %d\n",gQEventHandlerCount);
|
||||
printf("JCG: nsQEventHandler DTOR. Count: %d\n",gQEventHandlerCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -210,13 +198,13 @@ void nsQEventHandler::Enable(bool aEnable)
|
|||
mEnabled = aEnable;
|
||||
}
|
||||
|
||||
void nsQEventHandler::Destroy(void)
|
||||
void nsQEventHandler::Destroy()
|
||||
{
|
||||
mDestroyed = true;
|
||||
mWidget = nsnull;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::eventFilter(QObject * object, QEvent * event)
|
||||
bool nsQEventHandler::eventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
bool handled = false;
|
||||
|
||||
|
@ -224,109 +212,173 @@ bool nsQEventHandler::eventFilter(QObject * object, QEvent * event)
|
|||
return true;
|
||||
|
||||
switch (event->type()) {
|
||||
#if 0 //JCG
|
||||
case QEvent::MouseButtonPress:
|
||||
if (mEnabled)
|
||||
handled = MouseButtonEvent((QMouseEvent *) event, mWidget, true, 1);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Mouse Button Pushed. Widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MouseButtonEvent((QMouseEvent*)event, mWidget, true, 1);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::MouseButtonRelease:
|
||||
if (mEnabled)
|
||||
handled = MouseButtonEvent((QMouseEvent *) event, mWidget, false, 1);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Mouse Button Released widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MouseButtonEvent((QMouseEvent*)event, mWidget, false, 1);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::MouseButtonDblClick:
|
||||
if (mEnabled)
|
||||
handled = MouseButtonEvent((QMouseEvent *) event, mWidget, true, 2);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Mouse Button Double-clicked widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MouseButtonEvent((QMouseEvent*)event, mWidget, true, 2);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
#endif //JCG
|
||||
|
||||
case QEvent::MouseMove:
|
||||
if (mEnabled)
|
||||
handled = MouseMovedEvent((QMouseEvent *) event, mWidget);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Mouse Moved widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MouseMovedEvent((QMouseEvent*)event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
#if 0 //JCG
|
||||
case QEvent::KeyPress:
|
||||
if (mEnabled)
|
||||
handled = KeyPressEvent((QKeyEvent *) event, mWidget);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Key Pressed widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = KeyPressEvent((QKeyEvent*)event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::KeyRelease:
|
||||
if (mEnabled)
|
||||
handled = KeyReleaseEvent((QKeyEvent *) event, mWidget);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Key Released widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = KeyReleaseEvent((QKeyEvent*)event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::Enter:
|
||||
if (mEnabled)
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Mouse Enter widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MouseEnterEvent(event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::Leave:
|
||||
if (mEnabled)
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Mouse Exit widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MouseExitEvent(event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::Close:
|
||||
if (!mWidget->IsPopup()) {
|
||||
handled = DestroyEvent((QCloseEvent *) event, mWidget);
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Close widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = DestroyEvent((QCloseEvent*)event, mWidget);
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::Destroy:
|
||||
handled = DestroyEvent((QCloseEvent *) event, mWidget);
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Destroy widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = DestroyEvent((QCloseEvent*)event, mWidget);
|
||||
break;
|
||||
|
||||
case QEvent::Resize:
|
||||
handled = ResizeEvent((QResizeEvent *) event, mWidget);
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Resize widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = ResizeEvent((QResizeEvent*)event, mWidget);
|
||||
break;
|
||||
|
||||
case QEvent::Move:
|
||||
handled = MoveEvent((QMoveEvent *) event, mWidget);
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Move widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = MoveEvent((QMoveEvent*)event, mWidget);
|
||||
break;
|
||||
#endif //JCG
|
||||
|
||||
case QEvent::Paint:
|
||||
handled = PaintEvent((QPaintEvent *) event, mWidget);
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Paint widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = PaintEvent((QPaintEvent*)event, mWidget);
|
||||
break;
|
||||
|
||||
#if 0 //JCG
|
||||
case QEvent::FocusIn:
|
||||
if (mEnabled)
|
||||
handled = FocusInEvent((QFocusEvent *) event, mWidget);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Focus In widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = FocusInEvent((QFocusEvent*)event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case QEvent::FocusOut:
|
||||
if (mEnabled)
|
||||
handled = FocusOutEvent((QFocusEvent *) event, mWidget);
|
||||
if (mEnabled) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Focus In widget: %p\n",mWidget);
|
||||
#endif
|
||||
handled = FocusOutEvent((QFocusEvent*)event, mWidget);
|
||||
}
|
||||
else
|
||||
handled = true;
|
||||
break;
|
||||
#endif //JCG
|
||||
|
||||
default:
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: widget: %p, Other: %d\n",mWidget,event->type());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
bool nsQEventHandler::MouseButtonEvent(QMouseEvent * event,
|
||||
nsWidget * widget,
|
||||
bool buttonDown,
|
||||
int clickCnt)
|
||||
bool nsQEventHandler::MouseButtonEvent(QMouseEvent *event,
|
||||
nsWidget *widget,
|
||||
bool buttonDown,
|
||||
int clickCnt)
|
||||
{
|
||||
if (event && widget) {
|
||||
nsMouseEvent nsEvent;
|
||||
|
@ -338,18 +390,18 @@ bool nsQEventHandler::MouseButtonEvent(QMouseEvent * event,
|
|||
|
||||
switch (event->button()) {
|
||||
case LeftButton:
|
||||
nsEvent.message = buttonDown ? NS_MOUSE_LEFT_BUTTON_DOWN :
|
||||
NS_MOUSE_LEFT_BUTTON_UP;
|
||||
nsEvent.message = buttonDown ? NS_MOUSE_LEFT_BUTTON_DOWN
|
||||
: NS_MOUSE_LEFT_BUTTON_UP;
|
||||
break;
|
||||
|
||||
case RightButton:
|
||||
nsEvent.message = buttonDown ? NS_MOUSE_RIGHT_BUTTON_DOWN :
|
||||
NS_MOUSE_RIGHT_BUTTON_UP;
|
||||
nsEvent.message = buttonDown ? NS_MOUSE_RIGHT_BUTTON_DOWN
|
||||
: NS_MOUSE_RIGHT_BUTTON_UP;
|
||||
break;
|
||||
|
||||
case MidButton:
|
||||
nsEvent.message = buttonDown ? NS_MOUSE_MIDDLE_BUTTON_DOWN :
|
||||
NS_MOUSE_MIDDLE_BUTTON_UP;
|
||||
nsEvent.message = buttonDown ? NS_MOUSE_MIDDLE_BUTTON_DOWN
|
||||
: NS_MOUSE_MIDDLE_BUTTON_UP;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -369,7 +421,7 @@ bool nsQEventHandler::MouseButtonEvent(QMouseEvent * event,
|
|||
nsEvent.isControl = (event->state() & ControlButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isAlt = (event->state() & AltButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isMeta = PR_FALSE;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
widget->AddRef();
|
||||
widget->DispatchMouseEvent(nsEvent);
|
||||
widget->Release();
|
||||
|
@ -380,26 +432,23 @@ bool nsQEventHandler::MouseButtonEvent(QMouseEvent * event,
|
|||
/* nsWidget & nsWindow, unless either the EventHandler is destroyed */
|
||||
/* (i.e. "widget" is NULL) or the widget is deleted (i.e. IsInDTOR */
|
||||
/* returns TRUE). The last item is particularly slimey... */
|
||||
|
||||
bool handled = true;
|
||||
if (widget && !widget->IsInDTOR()) {
|
||||
if (widget->GetName() == QWidget::tr("nsWindow")
|
||||
|| widget->GetName() == QWidget::tr("nsWidget")) {
|
||||
if (buttonDown) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
handled = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
handled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return handled;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::MouseMovedEvent(QMouseEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::MouseMovedEvent(QMouseEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
// Generate XPFE mouse moved event
|
||||
|
@ -414,9 +463,14 @@ bool nsQEventHandler::MouseMovedEvent(QMouseEvent * event, nsWidget * widget)
|
|||
nsEvent.point.y = event->y();
|
||||
nsEvent.message = NS_MOUSE_MOVE;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.nativeMsg = (void*)event;
|
||||
nsEvent.nativeMsg = (void*)event;
|
||||
nsEvent.eventStructType = NS_MOUSE_EVENT;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.isShift = (event->state() & ShiftButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isControl = (event->state() & ControlButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isAlt = (event->state() & AltButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isMeta = PR_FALSE;
|
||||
|
||||
widget->AddRef();
|
||||
widget->DispatchMouseEvent(nsEvent);
|
||||
widget->Release();
|
||||
|
@ -426,19 +480,21 @@ bool nsQEventHandler::MouseMovedEvent(QMouseEvent * event, nsWidget * widget)
|
|||
/* native widgets (i.e. NOT nsWidget or nsWindow AND IsInDTOR */
|
||||
/* returns FALSE) Using IsInDTOR like this is particularly slimey! */
|
||||
|
||||
bool handled = false;
|
||||
if (widget && !widget->IsInDTOR()) {
|
||||
if (widget->GetName() == QWidget::tr("nsWindow")
|
||||
|| widget->GetName() == QWidget::tr("nsWidget")) {
|
||||
return true;
|
||||
handled = true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
handled = true;
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::MouseEnterEvent(QEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::MouseEnterEvent(QEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
nsMouseEvent nsEvent;
|
||||
|
@ -452,7 +508,8 @@ bool nsQEventHandler::MouseEnterEvent(QEvent * event, nsWidget * widget)
|
|||
nsEvent.widget = widget;
|
||||
nsEvent.nativeMsg = (void*)event;
|
||||
nsEvent.eventStructType = NS_MOUSE_EVENT;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
|
||||
widget->AddRef();
|
||||
widget->DispatchMouseEvent(nsEvent);
|
||||
widget->Release();
|
||||
|
@ -460,7 +517,8 @@ bool nsQEventHandler::MouseEnterEvent(QEvent * event, nsWidget * widget)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::MouseExitEvent(QEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::MouseExitEvent(QEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
nsMouseEvent nsEvent;
|
||||
|
@ -474,7 +532,8 @@ bool nsQEventHandler::MouseExitEvent(QEvent * event, nsWidget * widget)
|
|||
nsEvent.widget = widget;
|
||||
nsEvent.nativeMsg = (void*)event;
|
||||
nsEvent.eventStructType = NS_MOUSE_EVENT;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
|
||||
widget->AddRef();
|
||||
widget->DispatchMouseEvent(nsEvent);
|
||||
widget->Release();
|
||||
|
@ -482,7 +541,8 @@ bool nsQEventHandler::MouseExitEvent(QEvent * event, nsWidget * widget)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::DestroyEvent(QCloseEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::DestroyEvent(QCloseEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
// Generate XPFE destroy event
|
||||
|
@ -492,55 +552,34 @@ bool nsQEventHandler::DestroyEvent(QCloseEvent * event, nsWidget * widget)
|
|||
("nsQEventHandler::DestroyEvent for %s\n",
|
||||
widget->GetName()));
|
||||
|
||||
((nsWindow *)widget)->SetIsDestroying(PR_TRUE);
|
||||
widget->Destroy();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::ResizeEvent(QResizeEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::ResizeEvent(QResizeEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
// Generate XPFE resize event
|
||||
nsSizeEvent nsEvent;
|
||||
|
||||
PR_LOG(QtEventsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQEventHandler::ResizeEvent for %s(%p)\n",
|
||||
widget->GetName(),
|
||||
widget));
|
||||
|
||||
nsEvent.message = NS_SIZE;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.eventStructType = NS_SIZE_EVENT;
|
||||
nsRect rect;
|
||||
widget->GetBounds(rect);
|
||||
rect.width = event->size().width();
|
||||
rect.height = event->size().height();
|
||||
|
||||
PR_LOG(QtEventsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQEventHandler::ResizeEvent: old size:%dx%d, new size:%dx%d\n",
|
||||
event->oldSize().width(),
|
||||
event->oldSize().height(),
|
||||
event->size().width(),
|
||||
event->size().height()));
|
||||
|
||||
nsRect * rect = new nsRect();
|
||||
widget->GetBounds(*rect);
|
||||
rect->width = event->size().width();
|
||||
rect->height = event->size().height();
|
||||
|
||||
nsEvent.point.x = 0;
|
||||
nsEvent.point.y = 0;
|
||||
nsEvent.windowSize = rect;
|
||||
nsEvent.mWinHeight = event->size().height();
|
||||
nsEvent.mWinWidth = event->size().width();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
|
||||
widget->OnResize(*rect);
|
||||
delete rect;
|
||||
widget->OnResize(rect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::MoveEvent(QMoveEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::MoveEvent(QMoveEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
PR_LOG(QtEventsLM,
|
||||
|
@ -554,7 +593,8 @@ bool nsQEventHandler::MoveEvent(QMoveEvent * event, nsWidget * widget)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::PaintEvent(QPaintEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::PaintEvent(QPaintEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
// Generate XPFE paint event
|
||||
|
@ -566,26 +606,23 @@ bool nsQEventHandler::PaintEvent(QPaintEvent * event, nsWidget * widget)
|
|||
widget->GetName(),
|
||||
widget));
|
||||
|
||||
nsEvent.message = NS_PAINT;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.message = NS_PAINT;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.eventStructType = NS_PAINT_EVENT;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
|
||||
QRect qrect = event->rect();
|
||||
|
||||
PR_LOG(QtEventsLM,
|
||||
PR_LOG_DEBUG,
|
||||
PR_LOG(QtEventsLM,PR_LOG_DEBUG,
|
||||
("nsQEventHandler::PaintEvent: need to paint:x=%d,y=%d,w=%d,h=%d\n",
|
||||
qrect.x(), qrect.y(), qrect.width(), qrect.height()));
|
||||
event->rect().x(),event->rect().y(),
|
||||
event->rect().width(),event->rect().height()));
|
||||
|
||||
nsRect * rect = new nsRect(qrect.x(), qrect.y(), qrect.width(), qrect.height());
|
||||
nsEvent.rect = rect;
|
||||
nsRect rect(event->rect().x(),event->rect().y(),
|
||||
event->rect().width(),event->rect().height());
|
||||
nsEvent.rect = ▭
|
||||
|
||||
widget->AddRef();
|
||||
widget->OnPaint(nsEvent);
|
||||
widget->Release();
|
||||
|
||||
delete rect;
|
||||
}
|
||||
if (widget && widget->GetName() == QWidget::tr("nsWindow")
|
||||
|| widget->GetName() == QWidget::tr("nsWidget")) {
|
||||
|
@ -596,7 +633,8 @@ bool nsQEventHandler::PaintEvent(QPaintEvent * event, nsWidget * widget)
|
|||
}
|
||||
}
|
||||
|
||||
bool nsQEventHandler::KeyPressEvent(QKeyEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::KeyPressEvent(QKeyEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
PR_LOG(QtEventsLM,
|
||||
|
@ -604,8 +642,9 @@ bool nsQEventHandler::KeyPressEvent(QKeyEvent * event, nsWidget * widget)
|
|||
("nsQEventHandler::KeyPressEvent for %s\n",
|
||||
widget->GetName()));
|
||||
|
||||
if (event->key() == Qt::Key_Shift || event->key() == Qt::Key_Control
|
||||
|| event->key() == Qt::Key_Alt)
|
||||
if (event->key() == Qt::Key_Shift
|
||||
|| event->key() == Qt::Key_Control
|
||||
|| event->key() == Qt::Key_Alt)
|
||||
return false;
|
||||
|
||||
nsKeyEvent nsEvent;
|
||||
|
@ -613,29 +652,29 @@ bool nsQEventHandler::KeyPressEvent(QKeyEvent * event, nsWidget * widget)
|
|||
nsEvent.message = NS_KEY_DOWN;
|
||||
nsEvent.eventStructType = NS_KEY_EVENT;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.keyCode = GetNSKey(event->key(), event->state());
|
||||
nsEvent.isShift = (event->state() & ShiftButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isControl = (event->state() & ControlButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isAlt = (event->state() & AltButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.keyCode = GetNSKey(event->key(),event->state());
|
||||
nsEvent.isShift = event->state() & ShiftButton;
|
||||
nsEvent.isControl = event->state() & ControlButton;
|
||||
nsEvent.isAlt = event->state() & AltButton;
|
||||
nsEvent.isMeta = PR_FALSE;
|
||||
nsEvent.point.x = 0;
|
||||
nsEvent.point.y = 0;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
|
||||
nsEvent.charCode = 0;
|
||||
widget->AddRef();
|
||||
((nsWindow *)widget)->OnKey(nsEvent);
|
||||
((nsWindow*)widget)->OnKey(nsEvent);
|
||||
|
||||
nsEvent.message = NS_KEY_PRESS;
|
||||
nsEvent.eventStructType = NS_KEY_EVENT;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.isShift = (event->state() & ShiftButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isControl = (event->state() & ControlButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isAlt = (event->state() & AltButton) ? PR_TRUE : PR_FALSE;
|
||||
nsEvent.isShift = event->state() & ShiftButton;
|
||||
nsEvent.isControl = event->state() & ControlButton;
|
||||
nsEvent.isAlt = event->state() & AltButton;
|
||||
nsEvent.isMeta = PR_FALSE;
|
||||
nsEvent.point.x = 0;
|
||||
nsEvent.point.y = 0;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
if (event->text().length() && event->text()[0].isPrint()) {
|
||||
nsEvent.charCode = (PRInt32)event->text()[0].unicode();
|
||||
}
|
||||
|
@ -647,15 +686,16 @@ bool nsQEventHandler::KeyPressEvent(QKeyEvent * event, nsWidget * widget)
|
|||
nsEvent.isShift = PR_FALSE;
|
||||
}
|
||||
else
|
||||
nsEvent.keyCode = GetNSKey(event->key(), event->state());
|
||||
nsEvent.keyCode = GetNSKey(event->key(),event->state());
|
||||
|
||||
((nsWindow *)widget)->OnKey(nsEvent);
|
||||
((nsWindow*)widget)->OnKey(nsEvent);
|
||||
widget->Release();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::KeyReleaseEvent(QKeyEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::KeyReleaseEvent(QKeyEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
|
||||
|
@ -670,26 +710,27 @@ bool nsQEventHandler::KeyReleaseEvent(QKeyEvent * event, nsWidget * widget)
|
|||
|
||||
nsKeyEvent nsEvent;
|
||||
|
||||
nsEvent.message = NS_KEY_UP;
|
||||
nsEvent.message = NS_KEY_UP;
|
||||
nsEvent.eventStructType = NS_KEY_EVENT;
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.charCode = 0;
|
||||
nsEvent.keyCode = GetNSKey(event->key(), event->state());
|
||||
nsEvent.isShift = event->state() & ShiftButton;
|
||||
nsEvent.isControl = event->state() & ControlButton;
|
||||
nsEvent.isAlt = event->state() & AltButton;
|
||||
nsEvent.isMeta = PR_FALSE;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
nsEvent.widget = widget;
|
||||
nsEvent.charCode = 0;
|
||||
nsEvent.keyCode = GetNSKey(event->key(), event->state());
|
||||
nsEvent.isShift = event->state() & ShiftButton;
|
||||
nsEvent.isControl = event->state() & ControlButton;
|
||||
nsEvent.isAlt = event->state() & AltButton;
|
||||
nsEvent.isMeta = PR_FALSE;
|
||||
nsEvent.time = PR_IntervalNow();
|
||||
|
||||
widget->AddRef();
|
||||
((nsWindow *)widget)->OnKey(nsEvent);
|
||||
((nsWindow*)widget)->OnKey(nsEvent);
|
||||
widget->Release();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PRInt32 nsQEventHandler::GetNSKey(PRInt32 key, PRInt32 state)
|
||||
#if 0 //JCG
|
||||
PRInt32 nsQEventHandler::GetNSKey(PRInt32 key,PRInt32 state)
|
||||
{
|
||||
PRInt32 nsKey = 0;
|
||||
PRInt32 length = sizeof(nsKeycodes) / sizeof(nsKeyConverter);
|
||||
|
||||
for (PRInt32 i = 0; i < length; i++) {
|
||||
|
@ -697,10 +738,12 @@ PRInt32 nsQEventHandler::GetNSKey(PRInt32 key, PRInt32 state)
|
|||
return nsKeycodes[i].vkCode;
|
||||
}
|
||||
}
|
||||
return nsKey;
|
||||
return 0;
|
||||
}
|
||||
#endif //JCG
|
||||
|
||||
bool nsQEventHandler::FocusInEvent(QFocusEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::FocusInEvent(QFocusEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
nsGUIEvent aEvent;
|
||||
|
@ -713,17 +756,19 @@ bool nsQEventHandler::FocusInEvent(QFocusEvent * event, nsWidget * widget)
|
|||
aEvent.message = NS_GOTFOCUS;
|
||||
aEvent.eventStructType = NS_GUI_EVENT;
|
||||
aEvent.widget = widget;
|
||||
aEvent.time = PR_IntervalNow();
|
||||
aEvent.point.x = 0;
|
||||
aEvent.point.y = 0;
|
||||
aEvent.time = PR_IntervalNow();
|
||||
aEvent.point.x = 0;
|
||||
aEvent.point.y = 0;
|
||||
|
||||
widget->AddRef();
|
||||
((nsWindow *)widget)->DispatchFocus(aEvent);
|
||||
((nsWindow*)widget)->DispatchFocus(aEvent);
|
||||
widget->Release();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsQEventHandler::FocusOutEvent(QFocusEvent * event, nsWidget * widget)
|
||||
bool nsQEventHandler::FocusOutEvent(QFocusEvent *event,
|
||||
nsWidget *widget)
|
||||
{
|
||||
if (event && widget) {
|
||||
nsGUIEvent aEvent;
|
||||
|
@ -736,12 +781,12 @@ bool nsQEventHandler::FocusOutEvent(QFocusEvent * event, nsWidget * widget)
|
|||
aEvent.message = NS_LOSTFOCUS;
|
||||
aEvent.eventStructType = NS_GUI_EVENT;
|
||||
aEvent.widget = widget;
|
||||
aEvent.time = PR_IntervalNow();
|
||||
aEvent.point.x = 0;
|
||||
aEvent.point.y = 0;
|
||||
aEvent.time = PR_IntervalNow();
|
||||
aEvent.point.x = 0;
|
||||
aEvent.point.y = 0;
|
||||
|
||||
widget->AddRef();
|
||||
((nsWindow *)widget)->DispatchFocus(aEvent);
|
||||
((nsWindow*)widget)->DispatchFocus(aEvent);
|
||||
widget->Release();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -18,14 +18,12 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __nsQTEventHandler_h
|
||||
#define __nsQTEventHandler_h
|
||||
|
||||
class nsIWidget;
|
||||
class nsIMenuItem;
|
||||
|
||||
#include "nsWidget.h"
|
||||
|
||||
#include <qobject.h>
|
||||
|
@ -40,7 +38,7 @@ public:
|
|||
~nsQEventHandler();
|
||||
|
||||
void Enable(bool aEnable);
|
||||
void Destroy(void);
|
||||
void Destroy();
|
||||
bool eventFilter(QObject * object, QEvent * event);
|
||||
|
||||
bool MouseButtonEvent(QMouseEvent *event,nsWidget *widget,
|
||||
|
@ -62,9 +60,9 @@ protected:
|
|||
PRInt32 GetNSKey(PRInt32 key, PRInt32 state);
|
||||
|
||||
private:
|
||||
nsWidget * mWidget;
|
||||
bool mEnabled;
|
||||
bool mDestroyed;
|
||||
nsWidget *mWidget;
|
||||
bool mEnabled;
|
||||
bool mDestroyed;
|
||||
};
|
||||
|
||||
#endif // __nsQEventHandler.h
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,166 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
* Denis Issoupov <denis@macadamian.com>
|
||||
*
|
||||
*/
|
||||
#ifndef nsQWidget_h__
|
||||
#define nsQWidget_h__
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qstring.h>
|
||||
|
||||
#include "nsIWidget.h"
|
||||
|
||||
class nsFontQT;
|
||||
class nsWidget;
|
||||
|
||||
/* Utility Functions */
|
||||
PRBool NS_IsMouseInWindow(void *aWin,PRInt32 aMouseX,PRInt32 aMouseY);
|
||||
unsigned int NS_GetQWFlags(nsBorderStyle aBorder,nsWindowType aType);
|
||||
|
||||
//=============================================================================
|
||||
// nsQWidget class:
|
||||
// Customizes QWidget for use in XPFE
|
||||
//=============================================================================
|
||||
class nsQWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsQWidget(QWidget *aParent,const char *aName = 0,WFlags aFlags = WResizeNoErase);
|
||||
virtual ~nsQWidget();
|
||||
|
||||
virtual void SetModal(PRBool aState);
|
||||
|
||||
private:
|
||||
PRUint32 mQWidgetID;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// nsQBaseWidget class
|
||||
// Provides a "two-way" interface, allowing XPFE to access Qt Widget
|
||||
// functionality and hooking the relevant Qt Events into the XPFE Event
|
||||
// Handling
|
||||
//=============================================================================
|
||||
class nsQBaseWidget : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsQBaseWidget(nsWidget *aWidget);
|
||||
virtual ~nsQBaseWidget();
|
||||
|
||||
/*** Lifecycle Management ***/
|
||||
PRBool CreateNative(QWidget *aParent = 0,const char *aName = 0,
|
||||
unsigned int aFlags = WResizeNoErase);
|
||||
virtual void Destroy();
|
||||
|
||||
/*** Interface to Qt Widget functionality for XPFE ***/
|
||||
void Enable(PRBool aState);
|
||||
PRBool HandlePopup(void *aEvent);
|
||||
virtual void SetCursor(nsCursor aCursor);
|
||||
virtual void SetFont(nsFontQT *aFont);
|
||||
virtual void SetModal(PRBool aState)
|
||||
{
|
||||
((nsQWidget*)mQWidget)->SetModal(aState);
|
||||
};
|
||||
virtual const char *Name() {return mQWidget->name();};
|
||||
virtual int Width() {return mQWidget->width();};
|
||||
virtual int Height() {return mQWidget->height();};
|
||||
virtual int BoundsX() {return 0;};
|
||||
virtual int BoundsY() {return 0;};
|
||||
virtual void OffsetXYToGlobal(PRInt32 *aX,PRInt32 *aY)
|
||||
{
|
||||
QPoint offset(0,0);
|
||||
offset = mQWidget->mapToGlobal(offset);
|
||||
*aX = offset.x();
|
||||
*aY = offset.y();
|
||||
};
|
||||
virtual void OffsetXYFromGlobal(PRInt32 *aX,PRInt32 *aY)
|
||||
{
|
||||
QPoint offset(0,0);
|
||||
offset = mQWidget->mapFromGlobal(offset);
|
||||
*aX = offset.x();
|
||||
*aY = offset.y();
|
||||
};
|
||||
virtual void Move(PRInt32 aX,PRInt32 aY) {mQWidget->move(aX,aY);};
|
||||
virtual void Resize(PRInt32 aW,PRInt32 aH) {mQWidget->resize(aW,aH);};
|
||||
virtual void Scroll(PRInt32 aDx,PRInt32 aDy) {mQWidget->scroll(aDx,aDy);};
|
||||
virtual void Show() {mQWidget->show();};
|
||||
virtual void Hide() {mQWidget->hide();};
|
||||
virtual bool IsVisible() {return mQWidget->isVisible();};
|
||||
virtual void SetFocus() {mQWidget->setFocus();};
|
||||
virtual void SetTitle(const char *aTitleStr)
|
||||
{
|
||||
mQWidget->setCaption(QString::fromLocal8Bit(aTitleStr));
|
||||
};
|
||||
virtual void SetBackgroundColor(const nscolor &aColor)
|
||||
{
|
||||
QColor color(NS_GET_R(aColor),NS_GET_G(aColor),NS_GET_B(aColor));
|
||||
mQWidget->setBackgroundColor(color);
|
||||
};
|
||||
virtual void Repaint(PRBool aErase) {mQWidget->repaint(aErase);};
|
||||
virtual void Repaint(PRInt32 aX,PRInt32 aY,PRInt32 aW, PRInt32 aH,PRBool aErase)
|
||||
{
|
||||
mQWidget->repaint(aX,aY,aW,aH,aErase);
|
||||
};
|
||||
virtual void Update() {mQWidget->update();};
|
||||
virtual void Update(PRInt32 aX,PRInt32 aY,PRInt32 aW, PRInt32 aH)
|
||||
{
|
||||
mQWidget->update(aX,aY,aW,aH);
|
||||
};
|
||||
virtual void *GetNativeWindow() {return((void*)(QPaintDevice*)mQWidget);};
|
||||
virtual void *GetNativeWidget() {return((void*)mQWidget);};
|
||||
|
||||
virtual void* X11Display() {return (void*)mQWidget->x11Display();};
|
||||
virtual void* WinID() {return (void*)mQWidget->winId();};
|
||||
|
||||
/*** Interface to XPFE Event Handling from Qt ***/
|
||||
bool eventFilter(QObject *aObj,QEvent *aEvent);
|
||||
|
||||
virtual PRBool MouseButtonEvent(QMouseEvent *aEvent,PRBool aButtonDown,
|
||||
int aClickCount);
|
||||
virtual PRBool MouseMovedEvent(QMouseEvent *aEvent);
|
||||
virtual PRBool MouseEnterEvent(QEvent *aEvent);
|
||||
virtual PRBool MouseExitEvent(QEvent *aEvent);
|
||||
virtual PRBool DestroyEvent();
|
||||
virtual PRBool ResizeEvent(QResizeEvent *aEvent);
|
||||
virtual PRBool MoveEvent(QMoveEvent *aEvent);
|
||||
virtual PRBool PaintEvent(QPaintEvent *aEvent);
|
||||
virtual PRBool KeyPressEvent(QKeyEvent *aEvent);
|
||||
virtual PRBool KeyReleaseEvent(QKeyEvent *aEvent);
|
||||
virtual PRBool FocusInEvent();
|
||||
virtual PRBool FocusOutEvent();
|
||||
virtual PRBool DragEnterEvent(QDragEnterEvent *aEvent);
|
||||
virtual PRBool DragMoveEvent(QDragMoveEvent *aEvent);
|
||||
virtual PRBool DragLeaveEvent(QDragLeaveEvent *aEvent);
|
||||
virtual PRBool DropEvent(QDropEvent *aEvent);
|
||||
|
||||
protected:
|
||||
nsWidget *mWidget;
|
||||
QWidget *mQWidget;
|
||||
PRBool mEnabled;
|
||||
PRBool mDestroyed;
|
||||
|
||||
private:
|
||||
PRUint32 mQBaseID;
|
||||
};
|
||||
|
||||
#endif //nsQWidget_h__
|
|
@ -18,442 +18,371 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsScrollbar.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
PRLogModuleInfo * QtScrollLM = PR_NewLogModule("QtScroll");
|
||||
//JCG #define DBG_JCG 1
|
||||
|
||||
#ifdef DBG_JCG
|
||||
PRUint32 gQBaseSBCount = 0;
|
||||
PRUint32 gQBaseSBID = 0;
|
||||
|
||||
PRUint32 gQSBCount = 0;
|
||||
PRUint32 gQSBID = 0;
|
||||
|
||||
PRUint32 gNsSBCount = 0;
|
||||
PRUint32 gNsSBID = 0;
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// nsQScrollBar class
|
||||
//
|
||||
// nsQBaseScrollBar class
|
||||
//=============================================================================
|
||||
nsQScrollBar::nsQScrollBar(nsWidget * widget,
|
||||
int minValue,
|
||||
int maxValue,
|
||||
int LineStep,
|
||||
int PageStep,
|
||||
int value,
|
||||
Orientation orientation,
|
||||
QWidget * parent,
|
||||
const char * name)
|
||||
: QScrollBar(minValue,
|
||||
maxValue,
|
||||
LineStep,
|
||||
PageStep,
|
||||
value,
|
||||
orientation,
|
||||
parent,
|
||||
name),
|
||||
nsQBaseWidget(widget)
|
||||
nsQBaseScrollBar::nsQBaseScrollBar(nsWidget *aWidget)
|
||||
: nsQBaseWidget(aWidget)
|
||||
{
|
||||
connect((QScrollBar *)this,
|
||||
SIGNAL(valueChanged(int)),
|
||||
SLOT(SetValue(int)));
|
||||
#ifdef DBG_JCG
|
||||
gQBaseSBCount++;
|
||||
mQBaseSBID = gQBaseSBID++;
|
||||
printf("JCG: nsQBaseScrollBar CTOR (%p) ID: %d, Count: %d\n",
|
||||
this,mQBaseSBID,gQBaseSBCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsQBaseScrollBar::~nsQBaseScrollBar()
|
||||
{
|
||||
#ifdef DBG_JCG
|
||||
gQBaseSBCount--;
|
||||
printf("JCG: nsQBaseScrollBar DTOR (%p) ID: %d, Count: %d\n",
|
||||
this,mQBaseSBID,gQBaseSBCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsQBaseScrollBar::ValueChanged(int aValue)
|
||||
{
|
||||
ScrollBarMoved(NS_SCROLLBAR_POS,aValue);
|
||||
}
|
||||
|
||||
void nsQBaseScrollBar::ScrollBarMoved(int aMessage,int aValue)
|
||||
{
|
||||
if (mWidget) {
|
||||
nsScrollbarEvent nsEvent;
|
||||
|
||||
nsEvent.message = aMessage;
|
||||
nsEvent.widget = mWidget;
|
||||
nsEvent.eventStructType = NS_SCROLLBAR_EVENT;
|
||||
nsEvent.position = aValue;
|
||||
|
||||
((nsScrollbar*)mWidget)->OnScroll(nsEvent,aValue);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool nsQBaseScrollBar::CreateNative(int aMinValue,int aMaxValue,
|
||||
int aLineStep,int aPageStep,int aValue,
|
||||
Orientation aOrientation,QWidget *aParent,
|
||||
const char *aName)
|
||||
{
|
||||
if (!(mQWidget = new nsQScrollBar(aMinValue,aMaxValue,aLineStep,aPageStep,aValue,
|
||||
aOrientation,aParent,aName))) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
connect((QScrollBar*)mQWidget,SIGNAL(valueChanged(int)),this,SLOT(ValueChanged(int)));
|
||||
mQWidget->installEventFilter(this);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void nsQBaseScrollBar::Destroy()
|
||||
{
|
||||
mEnabled = PR_FALSE;
|
||||
|
||||
if (mWidget) {
|
||||
mWidget = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool nsQBaseScrollBar::MouseButtonEvent(QMouseEvent *aEvent,PRBool aButtonDown,
|
||||
int aClickCount)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsQBaseScrollBar::MouseMovedEvent(QMouseEvent *aEvent)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsQBaseScrollBar::PaintEvent(QPaintEvent *aEvent)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// nsQScrollBar class
|
||||
//=============================================================================
|
||||
nsQScrollBar::nsQScrollBar(int aMinValue,int aMaxValue,
|
||||
int aLineStep,int aPageStep,int aValue,
|
||||
Orientation aOrientation,QWidget *aParent,
|
||||
const char *aName)
|
||||
: QScrollBar(aMinValue,aMaxValue,aLineStep,aPageStep,aValue,
|
||||
aOrientation,aParent,aName)
|
||||
{
|
||||
#ifdef DBG_JCG
|
||||
gQSBCount++;
|
||||
mQSBID = gQSBID++;
|
||||
printf("JCG: nsQScrollBar CTOR (%p) ID: %d, Count: %d\n",this,mQSBID,gQSBCount);
|
||||
#endif
|
||||
setMouseTracking(PR_TRUE);
|
||||
setTracking(PR_TRUE);
|
||||
}
|
||||
|
||||
nsQScrollBar::~nsQScrollBar()
|
||||
{
|
||||
#ifdef DBG_JCG
|
||||
gQSBCount--;
|
||||
printf("JCG: nsQScrollBar DTOR (%p) ID: %d, Count: %d\n",this,mQSBID,gQSBCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsQScrollBar::SetValue(int value)
|
||||
void nsQScrollBar::closeEvent(QCloseEvent *aEvent)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQScrollBar::SetValue: setting %d\n",
|
||||
value));
|
||||
ScrollBarMoved(NS_SCROLLBAR_POS, value);
|
||||
aEvent->ignore();
|
||||
}
|
||||
|
||||
void nsQScrollBar::PreviousLine()
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQScrollBar::PreviousLine()\n"));
|
||||
ScrollBarMoved(NS_SCROLLBAR_LINE_PREV);
|
||||
}
|
||||
|
||||
void nsQScrollBar::NextLine()
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQScrollBar::NextLine()\n"));
|
||||
ScrollBarMoved(NS_SCROLLBAR_LINE_NEXT);
|
||||
}
|
||||
|
||||
void nsQScrollBar::PreviousPage()
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQScrollBar::PreviousPage()\n"));
|
||||
ScrollBarMoved(NS_SCROLLBAR_PAGE_PREV);
|
||||
}
|
||||
|
||||
void nsQScrollBar::NextPage()
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQScrollBar::NextPage()\n"));
|
||||
ScrollBarMoved(NS_SCROLLBAR_PAGE_NEXT);
|
||||
}
|
||||
|
||||
void nsQScrollBar::ScrollBarMoved(int message, int value)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsQScrollBar::ScrollBarMoved()\n"));
|
||||
if (mWidget)
|
||||
{
|
||||
nsScrollbarEvent nsEvent;
|
||||
|
||||
nsEvent.message = message;
|
||||
nsEvent.widget = mWidget;
|
||||
NS_IF_ADDREF(nsEvent.widget);
|
||||
nsEvent.eventStructType = NS_SCROLLBAR_EVENT;
|
||||
nsEvent.position = value;
|
||||
|
||||
((nsScrollbar *)mWidget)->OnScroll(nsEvent, value);
|
||||
NS_IF_RELEASE(nsEvent.widget);
|
||||
}
|
||||
}
|
||||
|
||||
void nsQScrollBar::closeEvent(QCloseEvent *ce)
|
||||
{
|
||||
ce->ignore();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsWidget);
|
||||
NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsWidget);
|
||||
NS_IMPL_QUERY_INTERFACE2(nsScrollbar, nsIScrollbar, nsIWidget)
|
||||
//=============================================================================
|
||||
// nsScrollBar class
|
||||
//=============================================================================
|
||||
NS_IMPL_ADDREF_INHERITED(nsScrollbar,nsWidget);
|
||||
NS_IMPL_RELEASE_INHERITED(nsScrollbar,nsWidget);
|
||||
NS_IMPL_QUERY_INTERFACE2(nsScrollbar,nsIScrollbar,nsIWidget)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsScrollbar constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget (), nsIScrollbar ()
|
||||
nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget(), nsIScrollbar()
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::nsScrollbar()\n"));
|
||||
mOrientation = aIsVertical ? QScrollBar::Vertical : QScrollBar::Horizontal;
|
||||
mLineStep = 1;
|
||||
mPageStep = 10;
|
||||
mMaxValue = 100;
|
||||
mValue = 0;
|
||||
mListenForResizes = PR_TRUE;
|
||||
#ifdef DBG_JCG
|
||||
gNsSBCount++;
|
||||
mNsSBID = gNsSBID++;
|
||||
printf("JCG: nsScrollBar CTOR (%p) ID: %d, Count: %d\n",this,mNsSBID,gNsSBCount);
|
||||
#endif
|
||||
mOrientation = aIsVertical ? QScrollBar::Vertical : QScrollBar::Horizontal;
|
||||
mLineStep = 1;
|
||||
mPageStep = 10;
|
||||
mMaxValue = 100;
|
||||
mValue = 0;
|
||||
mListenForResizes = PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsScrollbar destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsScrollbar::~nsScrollbar()
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::~nsScrollbar()\n"));
|
||||
#ifdef DBG_JCG
|
||||
gNsSBCount--;
|
||||
printf("JCG: nsScrollBar DTOR (%p) ID: %d, Count: %d\n",this,mNsSBID,gNsSBCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Define the range settings
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::SetMaxRange()\n"));
|
||||
mMaxValue = aEndRange;
|
||||
|
||||
((QScrollBar*)mWidget)->setRange(0, mMaxValue - mPageStep);
|
||||
|
||||
return NS_OK;
|
||||
mMaxValue = aEndRange;
|
||||
((nsQBaseScrollBar*)mWidget)->SetRange(0,mMaxValue - mPageStep);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Return the range settings
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetMaxRange(PRUint32 & aMaxRange)
|
||||
NS_METHOD nsScrollbar::GetMaxRange(PRUint32 &aMaxRange)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::GetMaxRange: %d\n",
|
||||
aMaxRange));
|
||||
aMaxRange = mMaxValue;
|
||||
|
||||
return NS_OK;
|
||||
aMaxRange = mMaxValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the thumb position
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::SetPosition()\n"));
|
||||
mValue = aPos;
|
||||
|
||||
((QScrollBar*)mWidget)->setValue(mValue);
|
||||
|
||||
return NS_OK;
|
||||
mValue = aPos;
|
||||
((nsQBaseScrollBar*)mWidget)->SetValue(mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the current thumb position.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetPosition(PRUint32 & aPos)
|
||||
NS_METHOD nsScrollbar::GetPosition(PRUint32 &aPos)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::GetPosition %u\n",
|
||||
mValue));
|
||||
aPos = mValue;
|
||||
|
||||
return NS_OK;
|
||||
aPos = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the thumb size
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::SetThumbSize()\n"));
|
||||
if (aSize > 0)
|
||||
{
|
||||
mPageStep = aSize;
|
||||
if (aSize > 0) {
|
||||
mPageStep = aSize;
|
||||
|
||||
((QScrollBar*)mWidget)->setSteps(mLineStep, mPageStep);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
((nsQBaseScrollBar*)mWidget)->SetSteps(mLineStep,mPageStep);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the thumb size
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetThumbSize(PRUint32 & aThumbSize)
|
||||
NS_METHOD nsScrollbar::GetThumbSize(PRUint32 &aThumbSize)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::GetThumbSize: %u\n",
|
||||
mPageStep));
|
||||
aThumbSize = mPageStep;
|
||||
|
||||
return NS_OK;
|
||||
aThumbSize = mPageStep;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the line increment for this scrollbar
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::SetLineIncrement\n"));
|
||||
if (aLineIncrement > 0)
|
||||
{
|
||||
mLineStep = aLineIncrement;
|
||||
if (aLineIncrement > 0) {
|
||||
mLineStep = aLineIncrement;
|
||||
|
||||
((QScrollBar*)mWidget)->setSteps(mLineStep, mPageStep);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
((nsQBaseScrollBar*)mWidget)->SetSteps(mLineStep,mPageStep);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the line increment for this scrollbar
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 & aLineInc)
|
||||
NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 &aLineInc)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::GetLineIncrement: %u\n",
|
||||
mLineStep));
|
||||
aLineInc = mLineStep;
|
||||
|
||||
return NS_OK;
|
||||
aLineInc = mLineStep;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set all scrolling parameters
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange,
|
||||
PRUint32 aThumbSize,
|
||||
PRUint32 aPosition,
|
||||
PRUint32 aLineIncrement)
|
||||
NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange,PRUint32 aThumbSize,
|
||||
PRUint32 aPosition,PRUint32 aLineIncrement)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::SetParameters: max=%d,thumb=%d,pos=%d,inc=%d\n",
|
||||
aMaxRange,
|
||||
aThumbSize,
|
||||
aPosition,
|
||||
aLineIncrement));
|
||||
mPageStep = (int)(((int)aThumbSize > 0) ? aThumbSize : 1);
|
||||
mValue = (int)(((int)aPosition > 0) ? aPosition : 0);
|
||||
mLineStep = (int)(((int)aLineIncrement > 0) ? aLineIncrement : 1);
|
||||
mMaxValue = (int)(((int)aMaxRange > 0) ? aMaxRange : 10);
|
||||
mPageStep = (aThumbSize > 0) ? aThumbSize : 1;
|
||||
mValue = (aPosition > 0) ? aPosition : 0;
|
||||
mLineStep = (aLineIncrement > 0) ? aLineIncrement : 1;
|
||||
mMaxValue = (aMaxRange > 0) ? aMaxRange : 10;
|
||||
|
||||
((QScrollBar*)mWidget)->setValue(mValue);
|
||||
((QScrollBar*)mWidget)->setSteps(mLineStep, mPageStep);
|
||||
((QScrollBar*)mWidget)->setRange(0, mMaxValue - mPageStep);
|
||||
|
||||
return NS_OK;
|
||||
((nsQBaseScrollBar*)mWidget)->SetValue(mValue);
|
||||
((nsQBaseScrollBar*)mWidget)->SetSteps(mLineStep,mPageStep);
|
||||
((nsQBaseScrollBar*)mWidget)->SetRange(0,mMaxValue - mPageStep);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deal with scrollbar messages (actually implemented only in nsScrollbar)
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
|
||||
PRBool nsScrollbar::OnScroll(nsScrollbarEvent &aEvent,PRUint32 cPos)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::OnScroll()\n"));
|
||||
PRBool result = PR_TRUE;
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
switch (aEvent.message)
|
||||
{
|
||||
// scroll one line right or down
|
||||
case NS_SCROLLBAR_LINE_NEXT:
|
||||
((QScrollBar*)mWidget)->addLine();
|
||||
|
||||
mValue = ((QScrollBar*)mWidget)->value();
|
||||
switch (aEvent.message) {
|
||||
// scroll one line right or down
|
||||
case NS_SCROLLBAR_LINE_NEXT:
|
||||
((nsQBaseScrollBar*)mWidget)->AddLine();
|
||||
mValue = ((nsQBaseScrollBar*)mWidget)->Value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback)
|
||||
{
|
||||
aEvent.position = (PRUint32) mValue;
|
||||
result = ConvertStatus ((*mEventCallback) (&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = ConvertStatus((*mEventCallback)(&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// scroll one line left or up
|
||||
case NS_SCROLLBAR_LINE_PREV:
|
||||
((QScrollBar*)mWidget)->subtractLine();
|
||||
mValue = ((QScrollBar*)mWidget)->value();
|
||||
// scroll one line left or up
|
||||
case NS_SCROLLBAR_LINE_PREV:
|
||||
((nsQBaseScrollBar*)mWidget)->SubtractLine();
|
||||
mValue = ((nsQBaseScrollBar*)mWidget)->Value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the decrement
|
||||
if (mEventCallback)
|
||||
{
|
||||
aEvent.position = (PRUint32) mValue;
|
||||
result = ConvertStatus ((*mEventCallback) (&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the decrement
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = ConvertStatus((*mEventCallback)(&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// Scrolls one page right or down
|
||||
case NS_SCROLLBAR_PAGE_NEXT:
|
||||
((QScrollBar*)mWidget)->addPage();
|
||||
mValue = ((QScrollBar*)mWidget)->value();
|
||||
// Scrolls one page right or down
|
||||
case NS_SCROLLBAR_PAGE_NEXT:
|
||||
((nsQBaseScrollBar*)mWidget)->AddPage();
|
||||
mValue = ((nsQBaseScrollBar*)mWidget)->Value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback)
|
||||
{
|
||||
aEvent.position = (PRUint32) mValue;
|
||||
result = ConvertStatus ((*mEventCallback) (&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = ConvertStatus((*mEventCallback)(&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// Scrolls one page left or up.
|
||||
case NS_SCROLLBAR_PAGE_PREV:
|
||||
((QScrollBar*)mWidget)->subtractPage();
|
||||
mValue = ((QScrollBar*)mWidget)->value();
|
||||
// Scrolls one page left or up.
|
||||
case NS_SCROLLBAR_PAGE_PREV:
|
||||
((nsQBaseScrollBar*)mWidget)->SubtractPage();
|
||||
mValue = ((nsQBaseScrollBar*)mWidget)->Value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback)
|
||||
{
|
||||
aEvent.position = (PRUint32) mValue;
|
||||
result = ConvertStatus ((*mEventCallback) (&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = ConvertStatus((*mEventCallback)(&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// Scrolls to the absolute position. The current position is specified by
|
||||
// the cPos parameter.
|
||||
case NS_SCROLLBAR_POS:
|
||||
mValue = cPos;
|
||||
// Scrolls to the absolute position. The current position is specified by
|
||||
// the cPos parameter.
|
||||
case NS_SCROLLBAR_POS:
|
||||
mValue = cPos;
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback)
|
||||
{
|
||||
aEvent.position = (PRUint32) mValue;
|
||||
result = ConvertStatus ((*mEventCallback) (&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = ConvertStatus((*mEventCallback)(&aEvent));
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the native scrollbar widget
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::CreateNative(QWidget * parentWindow)
|
||||
NS_METHOD nsScrollbar::CreateNative(QWidget *aParentWindow)
|
||||
{
|
||||
PR_LOG(QtScrollLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsScrollBar::CreateNative: max=%d, linestep=%d, pagestep=%d\n",
|
||||
mMaxValue,
|
||||
mLineStep,
|
||||
mPageStep));
|
||||
mWidget = new nsQScrollBar(this, 0, mMaxValue, mLineStep, mPageStep,
|
||||
mValue, mOrientation, parentWindow,
|
||||
QScrollBar::tr("nsScrollBar"));
|
||||
|
||||
if (mWidget) {
|
||||
((QScrollBar*)mWidget)->setTracking(true);
|
||||
}
|
||||
|
||||
return nsWidget::CreateNative(parentWindow);
|
||||
}
|
||||
mWidget = new nsQBaseScrollBar(this);
|
||||
|
||||
const char *nsScrollbar::GetName()
|
||||
{
|
||||
return nsWidget::GetName();
|
||||
if (!mWidget)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (!((nsQBaseScrollBar*)mWidget)->CreateNative(0,mMaxValue,mLineStep,mPageStep,
|
||||
mValue,mOrientation,aParentWindow,
|
||||
QScrollBar::tr("nsScrollBar"))) {
|
||||
delete mWidget;
|
||||
mWidget = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return nsWidget::CreateNative(aParentWindow);
|
||||
}
|
||||
|
|
|
@ -18,88 +18,124 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsScrollbar_h__
|
||||
#define nsScrollbar_h__
|
||||
|
||||
#include "nsWidget.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsQWidget.h"
|
||||
#include "nsIScrollbar.h"
|
||||
|
||||
#include <qscrollbar.h>
|
||||
#include <qevent.h>
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// nsQScrollBar class
|
||||
//
|
||||
// nsQScrollBar class:
|
||||
// Provides a "two-way" interface, allowing XPFE to access Qt Scrollbar
|
||||
// functionality and hooking the relevant Qt Events into the XPFE Event
|
||||
// Handling. Inherits basic functionality from nsQBaseWidget.
|
||||
//=============================================================================
|
||||
class nsQScrollBar : public QScrollBar, public nsQBaseWidget
|
||||
class nsQBaseScrollBar : public nsQBaseWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsQScrollBar(nsWidget * widget,
|
||||
int minValue,
|
||||
int maxValue,
|
||||
int LineStep,
|
||||
int PageStep,
|
||||
int value,
|
||||
Orientation orientation,
|
||||
QWidget * parent,
|
||||
const char * name=0 );
|
||||
~nsQScrollBar();
|
||||
nsQBaseScrollBar(nsWidget *aWidget);
|
||||
~nsQBaseScrollBar();
|
||||
|
||||
void ScrollBarMoved(int message, int value = -1);
|
||||
void closeEvent(QCloseEvent *ce);
|
||||
/*** Lifecycle Management ***/
|
||||
PRBool CreateNative(int aMinValue,int aMaxValue,
|
||||
int aLineStep,int aPageStep,int aValue,
|
||||
Orientation aOrientation,QWidget *aParent,
|
||||
const char *aName = 0);
|
||||
virtual void Destroy();
|
||||
|
||||
/*** Interface to Qt ScrollBar functionality for XPFE ***/
|
||||
virtual void SetModal(PRBool aState) {};
|
||||
void SetRange(PRUint32 aMin,PRUint32 aMax) {((QScrollBar*)mQWidget)->setRange(aMin,aMax);};
|
||||
void SetValue(PRUint32 aValue) {((QScrollBar*)mQWidget)->setValue(aValue);};
|
||||
void SetSteps(PRUint32 aLineStep,PRUint32 aPageStep)
|
||||
{
|
||||
((QScrollBar*)mQWidget)->setSteps(aLineStep,aPageStep);
|
||||
};
|
||||
void AddLine() {((QScrollBar*)mQWidget)->addLine();};
|
||||
void SubtractLine() {((QScrollBar*)mQWidget)->subtractLine();};
|
||||
void AddPage() {((QScrollBar*)mQWidget)->addPage();};
|
||||
void SubtractPage() {((QScrollBar*)mQWidget)->subtractPage();};
|
||||
int Value() {return(((QScrollBar*)mQWidget)->value());};
|
||||
|
||||
/*** Interface to XPFE Event Handling from Qt ***/
|
||||
virtual PRBool MouseButtonEvent(QMouseEvent *aEvent,PRBool aButtonDown,
|
||||
int aClickCount);
|
||||
virtual PRBool MouseMovedEvent(QMouseEvent *aEvent);
|
||||
virtual PRBool PaintEvent(QPaintEvent *aEvent);
|
||||
|
||||
void ScrollBarMoved(int aMessage,int aValue = -1);
|
||||
|
||||
public slots:
|
||||
void PreviousLine();
|
||||
void NextLine();
|
||||
void PreviousPage();
|
||||
void NextPage();
|
||||
void SetValue(int value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Native QT scrollbar wrapper.
|
||||
*/
|
||||
|
||||
class nsScrollbar : public nsWidget,
|
||||
public nsIScrollbar
|
||||
{
|
||||
|
||||
public:
|
||||
nsScrollbar(PRBool aIsVertical);
|
||||
virtual ~nsScrollbar();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIScrollBar implementation
|
||||
NS_IMETHOD SetMaxRange(PRUint32 aEndRange);
|
||||
NS_IMETHOD GetMaxRange(PRUint32& aMaxRange);
|
||||
NS_IMETHOD SetPosition(PRUint32 aPos);
|
||||
NS_IMETHOD GetPosition(PRUint32& aPos);
|
||||
NS_IMETHOD SetThumbSize(PRUint32 aSize);
|
||||
NS_IMETHOD GetThumbSize(PRUint32& aSize);
|
||||
NS_IMETHOD SetLineIncrement(PRUint32 aSize);
|
||||
NS_IMETHOD GetLineIncrement(PRUint32& aSize);
|
||||
NS_IMETHOD SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
|
||||
PRUint32 aPosition, PRUint32 aLineIncrement);
|
||||
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
||||
const char *GetName();
|
||||
|
||||
protected:
|
||||
NS_IMETHOD CreateNative(QWidget *parentWindow);
|
||||
void ValueChanged(int aValue);
|
||||
|
||||
private:
|
||||
QScrollBar::Orientation mOrientation;
|
||||
int mMaxValue;
|
||||
int mLineStep;
|
||||
int mPageStep;
|
||||
int mValue;
|
||||
PRUint32 mQBaseSBID;
|
||||
};
|
||||
|
||||
#endif // nsScrollbar_
|
||||
//=============================================================================
|
||||
// nsQScrollBar class:
|
||||
// Customizes QScrollBar for use by XPFE
|
||||
//=============================================================================
|
||||
class nsQScrollBar : public QScrollBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsQScrollBar(int aMinValue,int aMaxValue,int aLineStep,int aPageStep,int aValue,
|
||||
Orientation aOrientation,QWidget *aParent,const char *aName = 0);
|
||||
~nsQScrollBar();
|
||||
|
||||
void closeEvent(QCloseEvent *aEvent);
|
||||
|
||||
private:
|
||||
PRUint32 mQSBID;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// nsScrollBar class:
|
||||
// the XPFE Scrollbar
|
||||
//=============================================================================
|
||||
class nsScrollbar : public nsWidget, public nsIScrollbar
|
||||
{
|
||||
public:
|
||||
nsScrollbar(PRBool aIsVertical);
|
||||
virtual ~nsScrollbar();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIScrollBar implementation
|
||||
NS_IMETHOD SetMaxRange(PRUint32 aEndRange);
|
||||
NS_IMETHOD GetMaxRange(PRUint32& aMaxRange);
|
||||
NS_IMETHOD SetPosition(PRUint32 aPos);
|
||||
NS_IMETHOD GetPosition(PRUint32& aPos);
|
||||
NS_IMETHOD SetThumbSize(PRUint32 aSize);
|
||||
NS_IMETHOD GetThumbSize(PRUint32& aSize);
|
||||
NS_IMETHOD SetLineIncrement(PRUint32 aSize);
|
||||
NS_IMETHOD GetLineIncrement(PRUint32& aSize);
|
||||
NS_IMETHOD SetParameters(PRUint32 aMaxRange,PRUint32 aThumbSize,
|
||||
PRUint32 aPosition,PRUint32 aLineIncrement);
|
||||
|
||||
virtual PRBool OnScroll(nsScrollbarEvent &aEvent,PRUint32 cPos);
|
||||
|
||||
virtual PRBool IsScrollBar() const { return PR_TRUE; };
|
||||
|
||||
protected:
|
||||
NS_IMETHOD CreateNative(QWidget *aParentWindow);
|
||||
|
||||
private:
|
||||
QScrollBar::Orientation mOrientation;
|
||||
int mMaxValue;
|
||||
int mLineStep;
|
||||
int mPageStep;
|
||||
int mValue;
|
||||
PRUint32 mNsSBID;
|
||||
};
|
||||
|
||||
#endif // nsScrollbar_h__
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsTextAreaWidget.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
|
||||
//JCG #define DBG 0
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// nsQMultiLineEdit class
|
||||
//
|
||||
//=============================================================================
|
||||
nsQMultiLineEdit::nsQMultiLineEdit(nsWidget * widget,
|
||||
QWidget * parent,
|
||||
const char * name)
|
||||
: QMultiLineEdit(parent, name), nsQBaseWidget(widget)
|
||||
{
|
||||
}
|
||||
|
||||
nsQMultiLineEdit::~nsQMultiLineEdit()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsTextAreaWidget)
|
||||
NS_IMPL_RELEASE(nsTextAreaWidget)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsTextAreaWidget constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsTextAreaWidget::nsTextAreaWidget()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextAreaWidget::nsTextAreaWidget()\n"));
|
||||
mBackground = NS_RGB(124, 124, 124);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsTextAreaWidget destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsTextAreaWidget::~nsTextAreaWidget()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextAreaWidget::~nsTextAreaWidget()\n"));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextAreaWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextAreaWidget::QueryInterface()\n"));
|
||||
static NS_DEFINE_IID(kITextAreaWidgetIID, NS_ITEXTAREAWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kITextAreaWidgetIID))
|
||||
{
|
||||
nsITextAreaWidget* textArea = this;
|
||||
*aInstancePtr = (void*) (textArea);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIWidgetIID))
|
||||
{
|
||||
nsIWidget* widget = this;
|
||||
*aInstancePtr = (void*) (widget);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWidget::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsTextAreaWidget::OnPaint(nsPaintEvent & aEvent)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextAreaWidget::OnPaint()\n"));
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool nsTextAreaWidget::OnResize(nsRect &aRect)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextAreaWidget::OnResize()\n"));
|
||||
return PR_FALSE;
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
#include <qlineedit.h>
|
||||
#include <qmultilineedit.h>
|
||||
|
||||
//JCG #define DBG 0
|
||||
#define DBG 0
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
|
||||
//JCG #define DBG 0
|
||||
#define DBG 0
|
||||
|
||||
extern int mIsPasswordCallBacksInstalled;
|
||||
|
||||
|
|
|
@ -18,66 +18,50 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nscore.h" // needed for 'nsnull'
|
||||
#include "nsToolkit.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "plevent.h"
|
||||
#include "nsWidget.h"
|
||||
|
||||
//
|
||||
// Static thread local storage index of the Toolkit
|
||||
// object associated with a given thread...
|
||||
//
|
||||
static PRUintn gToolkitTLSIndex = 0;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::nsToolkit()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsToolkit::nsToolkit()\n"));
|
||||
NS_INIT_REFCNT();
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::~nsToolkit()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsToolkit::~nsToolkit()\n"));
|
||||
|
||||
// Remove the TLS reference to the toolkit...
|
||||
PR_SetThreadPrivate(gToolkitTLSIndex, nsnull);
|
||||
// Remove the TLS reference to the toolkit...
|
||||
PR_SetThreadPrivate(gToolkitTLSIndex, nsnull);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsISupports implementation macro
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsToolkit::Init(PRThread *aThread)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsToolkit::Init()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Return the nsIToolkit for the current thread. If a toolkit does not
|
||||
// yet exist, then one will be created...
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult)
|
||||
{
|
||||
|
@ -86,47 +70,35 @@ NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult)
|
|||
PRStatus status;
|
||||
|
||||
// Create the TLS index the first time through...
|
||||
if (0 == gToolkitTLSIndex)
|
||||
{
|
||||
if (0 == gToolkitTLSIndex) {
|
||||
status = PR_NewThreadPrivateIndex(&gToolkitTLSIndex, NULL);
|
||||
if (PR_FAILURE == status)
|
||||
{
|
||||
if (PR_FAILURE == status) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
toolkit = (nsIToolkit*)PR_GetThreadPrivate(gToolkitTLSIndex);
|
||||
|
||||
//
|
||||
// Create a new toolkit for this thread...
|
||||
//
|
||||
if (!toolkit)
|
||||
{
|
||||
if (!toolkit) {
|
||||
toolkit = new nsToolkit();
|
||||
|
||||
if (!toolkit)
|
||||
{
|
||||
if (!toolkit) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
NS_ADDREF(toolkit);
|
||||
toolkit->Init(PR_GetCurrentThread());
|
||||
//
|
||||
|
||||
// The reference stored in the TLS is weak. It is removed in the
|
||||
// nsToolkit destructor...
|
||||
//
|
||||
PR_SetThreadPrivate(gToolkitTLSIndex, (void*)toolkit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
NS_ADDREF(toolkit);
|
||||
}
|
||||
*aResult = toolkit;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,25 +18,21 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TOOLKIT_H
|
||||
#define TOOLKIT_H
|
||||
#ifndef nsToolkit_h__
|
||||
#define nsToolkit_h__
|
||||
|
||||
#include "nsIToolkit.h"
|
||||
|
||||
struct PLEventQueue;
|
||||
struct MethodInfo;
|
||||
|
||||
/**
|
||||
* Wrapper around the thread running the message pump.
|
||||
* The toolkit abstraction is necessary because the message pump must
|
||||
* execute within the same thread that created the widget under Win32.
|
||||
*/
|
||||
|
||||
class nsToolkit : public nsIToolkit
|
||||
{
|
||||
|
||||
public:
|
||||
nsToolkit();
|
||||
virtual ~nsToolkit();
|
||||
|
@ -45,4 +41,4 @@ public:
|
|||
NS_IMETHOD Init(PRThread *aThread);
|
||||
};
|
||||
|
||||
#endif // TOOLKIT_H
|
||||
#endif // nsToolkit_h__
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -18,8 +18,9 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsWidget_h__
|
||||
#define nsWidget_h__
|
||||
|
||||
|
@ -30,24 +31,10 @@
|
|||
#include "nsIRegion.h"
|
||||
#include "nsIRollupListener.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "prlog.h"
|
||||
#include <qwidget.h>
|
||||
#include <qptrdict.h>
|
||||
|
||||
extern PRLogModuleInfo * QtWidgetsLM;
|
||||
extern PRLogModuleInfo * QtScrollingLM;
|
||||
#include "nsQWidget.h"
|
||||
|
||||
class nsIAppShell;
|
||||
class nsIToolkit;
|
||||
class nsQWidget;
|
||||
class QPainter;
|
||||
class QPixmap;
|
||||
|
||||
class nsQEventHandler;
|
||||
|
||||
/**
|
||||
* Base of all QT native widgets.
|
||||
*/
|
||||
|
||||
class nsWidget : public nsBaseWidget, public nsIKBStateControl, public nsSupportsWeakReference
|
||||
{
|
||||
|
@ -75,6 +62,7 @@ public:
|
|||
NS_IMETHOD Destroy(void);
|
||||
nsIWidget* GetParent(void);
|
||||
|
||||
NS_IMETHOD SetModal(PRBool aModal);
|
||||
NS_IMETHOD Show(PRBool state);
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
||||
PRBool aDoCapture,
|
||||
|
@ -84,10 +72,7 @@ public:
|
|||
NS_IMETHOD ConstrainPosition(PRInt32 *aX, PRInt32 *aY);
|
||||
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
||||
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
|
||||
NS_IMETHOD Resize(PRInt32 aX,
|
||||
PRInt32 aY,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aHeight,
|
||||
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
|
||||
PRBool aRepaint);
|
||||
|
||||
NS_IMETHOD Enable(PRBool aState);
|
||||
|
@ -117,18 +102,18 @@ public:
|
|||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
||||
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
// Use this to set the name of a widget for normal widgets.. not the same
|
||||
// as the nsWindow version
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
|
||||
|
||||
// the following are nsWindow specific, and just stubbed here
|
||||
|
||||
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
|
||||
NS_IMETHOD SetMenuBar(nsIMenuBar *aMenuBar) { return NS_ERROR_FAILURE; }
|
||||
NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_ERROR_FAILURE; }
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture) { return NS_ERROR_FAILURE; }
|
||||
virtual PRBool OnPaint(nsPaintEvent &event) { return PR_FALSE; };
|
||||
virtual PRBool OnKey(nsKeyEvent &aEvent) { return PR_FALSE; };
|
||||
virtual PRBool DispatchFocus(nsGUIEvent &aEvent) { return PR_FALSE; };
|
||||
|
||||
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
||||
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
|
||||
|
@ -138,32 +123,25 @@ public:
|
|||
|
||||
// nsIKBStateControl
|
||||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD PasswordFieldInit();
|
||||
|
||||
void InitEvent(nsGUIEvent& event,
|
||||
PRUint32 aEventType,
|
||||
nsPoint* aPoint = nsnull);
|
||||
|
||||
nsQEventHandler * GetEventHandler() { return mEventHandler; }
|
||||
const char *GetName();
|
||||
void AddChildEventHandler(nsQEventHandler *aEHandler);
|
||||
void RemoveChildEventHandler(nsQEventHandler *aEHandler);
|
||||
void InitEvent(nsGUIEvent& event,PRUint32 aEventType,nsPoint* aPoint = nsnull);
|
||||
|
||||
// Utility functions
|
||||
|
||||
virtual PRBool OnPaint(nsPaintEvent &event) { return PR_FALSE; }
|
||||
const char *GetName();
|
||||
PRBool ConvertStatus(nsEventStatus aStatus);
|
||||
PRBool DispatchMouseEvent(nsMouseEvent& aEvent);
|
||||
PRBool DispatchStandardEvent(PRUint32 aMsg);
|
||||
|
||||
PRBool IsToplevel() const { return mIsToplevel; };
|
||||
virtual PRBool IsPopup() const { return PR_FALSE; };
|
||||
virtual PRBool IsDialog() const { return PR_FALSE; };
|
||||
PRBool IsInDTOR() const { return mInDTOR; };
|
||||
|
||||
// Deal with rollup for popups
|
||||
PRBool HandlePopup(PRInt32 inMouseX,PRInt32 inMouseY);
|
||||
|
||||
protected:
|
||||
virtual void InitCallbacks(char * aName = nsnull);
|
||||
virtual void OnDestroy();
|
||||
virtual void DestroyChildren();
|
||||
|
||||
NS_IMETHOD CreateNative(QWidget *parentWindow);
|
||||
|
||||
|
@ -178,46 +156,22 @@ protected:
|
|||
|
||||
PRBool DispatchWindowEvent(nsGUIEvent* event);
|
||||
|
||||
// Deal with rollup for popups
|
||||
PRBool HandlePopup(PRInt32 inMouseX,PRInt32 inMouseY);
|
||||
PRBool IsMouseInWindow(QWidget* inWindow,PRInt32 inMouseX,PRInt32 inMouseY);
|
||||
|
||||
protected:
|
||||
QWidget *mWidget;
|
||||
QPixmap *mPixmap;
|
||||
QPainter *mPainter;
|
||||
nsQBaseWidget *mWidget;
|
||||
nsCOMPtr<nsIWidget> mParent;
|
||||
|
||||
// composite update area - union of all Invalidate calls
|
||||
nsCOMPtr<nsIRegion> mUpdateArea;
|
||||
PRBool mShown;
|
||||
PRUint32 mPreferredWidth;
|
||||
PRUint32 mPreferredHeight;
|
||||
nsQEventHandler *mEventHandler;
|
||||
PRBool mListenForResizes;
|
||||
PRBool mIsToplevel;
|
||||
PRBool mInDTOR;
|
||||
QPtrDict<nsQEventHandler> mChildEventHandlers;
|
||||
PRUint32 mWidgetID;
|
||||
|
||||
// this is the rollup listener variables
|
||||
static nsCOMPtr<nsIRollupListener> gRollupListener;
|
||||
static nsWeakPtr gRollupWidget;
|
||||
static PRBool gRollupConsumeRollupEvent;
|
||||
static PRUint32 gWidgetCount;
|
||||
};
|
||||
|
||||
class nsQBaseWidget
|
||||
{
|
||||
public:
|
||||
nsQBaseWidget(nsWidget * widget);
|
||||
virtual ~nsQBaseWidget();
|
||||
|
||||
public:
|
||||
nsWidget * GetWidget() { return mWidget; }
|
||||
void Destroy();
|
||||
|
||||
protected:
|
||||
nsWidget * mWidget;
|
||||
};
|
||||
|
||||
#endif /* nsWidget_h__ */
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* Copyright (C) 2000 Christopher Blizzard. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzzard <blizzard@mozilla.org>
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -27,18 +27,12 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include "nsWindow.h"
|
||||
#include "nsButton.h"
|
||||
#include "nsCheckButton.h"
|
||||
#include "nsFileWidget.h"
|
||||
#include "nsTextWidget.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "nsLabel.h"
|
||||
#include "nsTransferable.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "nsHTMLFormatConverter.h"
|
||||
#include "nsFontRetrieverService.h"
|
||||
#include "nsDragService.h"
|
||||
#include "nsFileSpecWithUIImpl.h"
|
||||
#include "nsScrollbar.h"
|
||||
|
@ -49,71 +43,61 @@
|
|||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl)
|
||||
#ifdef IBMBIDI
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
|
||||
#endif
|
||||
|
||||
static nsresult nsHorizScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
static nsresult nsHorizScrollbarConstructor(nsISupports *aOuter,REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsISupports *inst = nsnull;
|
||||
|
||||
if ( NULL == aResult )
|
||||
{
|
||||
if (NULL == aResult) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = NULL;
|
||||
if (NULL != aOuter)
|
||||
{
|
||||
if (NULL != aOuter) {
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_FALSE);
|
||||
if (inst == NULL)
|
||||
{
|
||||
inst = (nsISupports*)(nsBaseWidget*)(nsWidget*)new nsScrollbar(PR_FALSE);
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
rv = inst->QueryInterface(aIID,aResult);
|
||||
NS_RELEASE(inst);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
static nsresult nsVertScrollbarConstructor(nsISupports *aOuter,REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsISupports *inst = nsnull;
|
||||
|
||||
if ( NULL == aResult )
|
||||
{
|
||||
if (NULL == aResult) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = NULL;
|
||||
if (NULL != aOuter)
|
||||
{
|
||||
if (NULL != aOuter) {
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
inst = (nsISupports *)(nsBaseWidget *)(nsWidget *)new nsScrollbar(PR_TRUE);
|
||||
if (inst == NULL)
|
||||
{
|
||||
inst = (nsISupports*)(nsBaseWidget*)(nsWidget*)new nsScrollbar(PR_TRUE);
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
|
@ -133,18 +117,6 @@ static nsModuleComponentInfo components[] =
|
|||
NS_CHILD_CID,
|
||||
"@mozilla.org/widgets/child_window/qt;1",
|
||||
ChildWindowConstructor },
|
||||
{ "Qt Button",
|
||||
NS_BUTTON_CID,
|
||||
"@mozilla.org/widgets/button/qt;1",
|
||||
nsButtonConstructor },
|
||||
{ "Qt Check Button",
|
||||
NS_CHECKBUTTON_CID,
|
||||
"@mozilla.org/widgets/checkbutton/qt;1",
|
||||
nsCheckButtonConstructor },
|
||||
{ "Qt File Widget",
|
||||
NS_FILEWIDGET_CID,
|
||||
"@mozilla.org/widgets/filewidget/qt;1",
|
||||
nsFileWidgetConstructor },
|
||||
{ "Qt Horiz Scrollbar",
|
||||
NS_HORZSCROLLBAR_CID,
|
||||
"@mozilla.org/widgets/horizscroll/qt;1",
|
||||
|
@ -153,10 +125,6 @@ static nsModuleComponentInfo components[] =
|
|||
NS_VERTSCROLLBAR_CID,
|
||||
"@mozilla.org/widgets/vertscroll/qt;1",
|
||||
nsVertScrollbarConstructor },
|
||||
{ "Qt Text Widget",
|
||||
NS_TEXTFIELD_CID,
|
||||
"@mozilla.org/widgets/textwidget/qt;1",
|
||||
nsTextWidgetConstructor },
|
||||
{ "Qt AppShell",
|
||||
NS_APPSHELL_CID,
|
||||
"@mozilla.org/widget/appshell/qt;1",
|
||||
|
@ -169,10 +137,6 @@ static nsModuleComponentInfo components[] =
|
|||
NS_LOOKANDFEEL_CID,
|
||||
"@mozilla.org/widget/lookandfeel/qt;1",
|
||||
nsLookAndFeelConstructor },
|
||||
{ "Qt Label",
|
||||
NS_LABEL_CID,
|
||||
"@mozilla.org/widget/label/qt;1",
|
||||
nsLabelConstructor },
|
||||
{ "Transferrable",
|
||||
NS_TRANSFERABLE_CID,
|
||||
"@mozilla.org/widget/transferable;1",
|
||||
|
@ -185,10 +149,6 @@ static nsModuleComponentInfo components[] =
|
|||
NS_HTMLFORMATCONVERTER_CID,
|
||||
"@mozilla.org/widget/htmlformatconverter/qt;1",
|
||||
nsHTMLFormatConverterConstructor },
|
||||
{ "Qt Font Retriever Service",
|
||||
NS_FONTRETRIEVERSERVICE_CID,
|
||||
"@mozilla.org/widget/fontretrieverservice/qt;1",
|
||||
nsFontRetrieverServiceConstructor },
|
||||
{ "Qt Drag Service",
|
||||
NS_DRAGSERVICE_CID,
|
||||
"@mozilla.org/widget/dragservice;1",
|
||||
|
@ -205,4 +165,4 @@ static nsModuleComponentInfo components[] =
|
|||
nsFileSpecWithUIImplConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsWidgetQTModule", components)
|
||||
NS_IMPL_NSGETMODULE("nsWidgetQTModule",components)
|
||||
|
|
|
@ -18,84 +18,61 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsQWidget.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsMenuBar.h"
|
||||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsClipboard.h"
|
||||
|
||||
#include "stdio.h"
|
||||
#include <qapplication.h>
|
||||
#include <qobjectlist.h>
|
||||
|
||||
static bool gAppTopWindowSet = PR_FALSE;
|
||||
//JCG #define DBG_JCG = 1
|
||||
|
||||
#ifdef DBG_JCG
|
||||
static PRInt32 gWindowCount = 0;
|
||||
static PRInt32 gWindowID = 0;
|
||||
static PRInt32 gChildCount = 0;
|
||||
static PRInt32 gChildID = 0;
|
||||
#endif
|
||||
|
||||
// are we grabbing?
|
||||
PRBool nsWindow::mIsGrabbing = PR_FALSE;
|
||||
nsWindow *nsWindow::mGrabWindow = NULL;
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// nsQWidget class
|
||||
//
|
||||
//=============================================================================
|
||||
nsQWidget::nsQWidget(nsWidget * widget, QWidget * parent, const char * name, WFlags f)
|
||||
: QWidget(parent, name, f), nsQBaseWidget(widget)
|
||||
{
|
||||
}
|
||||
|
||||
nsQWidget::~nsQWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void nsQWidget::Destroy()
|
||||
{
|
||||
nsQBaseWidget::Destroy();
|
||||
}
|
||||
PRBool nsWindow::mIsGrabbing = PR_FALSE;
|
||||
nsWindow *nsWindow::mGrabWindow = NULL;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsWidget)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsWindow constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsWindow::nsWindow()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::nsWindow()\n"));
|
||||
mResized = PR_FALSE;
|
||||
mVisible = PR_FALSE;
|
||||
mDisplayed = PR_FALSE;
|
||||
mLowerLeft = PR_FALSE;
|
||||
mIsDestroying = PR_FALSE;
|
||||
mIsDialog = PR_FALSE;
|
||||
mIsPopup = PR_FALSE;
|
||||
mOnDestroyCalled = PR_FALSE;
|
||||
mFont = nsnull;
|
||||
mWindowType = eWindowType_child;
|
||||
mBorderStyle = eBorderStyle_default;
|
||||
mBlockFocusEvents = PR_FALSE;
|
||||
#ifdef DBG_JCG
|
||||
gWindowCount++;
|
||||
mWindowID = gWindowID++;
|
||||
printf("JCG: nsWindow CTOR. (%p) ID: %d, Count: %d\n",this,mWindowID,gWindowCount);
|
||||
#endif
|
||||
mIsDialog = PR_FALSE;
|
||||
mIsPopup = PR_FALSE;
|
||||
mWindowType = eWindowType_child;
|
||||
mBorderStyle = eBorderStyle_default;
|
||||
mBlockFocusEvents = PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsWindow destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsWindow::~nsWindow()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::~nsWindow()\n"));
|
||||
|
||||
#ifdef DBG_JCG
|
||||
gWindowCount--;
|
||||
printf("JCG: nsWindow DTOR. (%p) ID: %d, Count: %d\n",this,mWindowID,gWindowCount);
|
||||
#endif
|
||||
// make sure that we release the grab indicator here
|
||||
if (mGrabWindow == this) {
|
||||
mIsGrabbing = PR_FALSE;
|
||||
|
@ -106,366 +83,278 @@ nsWindow::~nsWindow()
|
|||
//-------------------------------------------------------------------------
|
||||
PRBool nsWindow::IsChild() const
|
||||
{
|
||||
return PR_FALSE;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsWindow::ConvertToDeviceCoordinates()\n"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Setup initial tooltip rectangles
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[])
|
||||
NS_METHOD nsWindow::SetTooltips(PRUint32 aNumberOfTips,
|
||||
nsRect *aTooltipAreas[])
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::SetTooltips()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Update all tooltip rectangles
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsWindow::UpdateTooltips(nsRect* aNewTips[])
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::UpdateTooltips()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Remove all tooltip rectangles
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsWindow::RemoveTooltips()
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::RemoveTooltips()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::SetFocus(PRBool aRaise)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsWindow::SetFocus %s\n",
|
||||
mWidget ? mWidget->name() : "(null)"));
|
||||
if (mWidget) {
|
||||
mWidget->setFocus();
|
||||
}
|
||||
// don't recurse
|
||||
if (mBlockFocusEvents) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mBlockFocusEvents = PR_TRUE;
|
||||
|
||||
nsGUIEvent event;
|
||||
|
||||
event.message = NS_GOTFOCUS;
|
||||
event.widget = this;
|
||||
|
||||
event.eventStructType = NS_GUI_EVENT;
|
||||
|
||||
event.time = 0;
|
||||
event.point.x = 0;
|
||||
event.point.y = 0;
|
||||
|
||||
DispatchFocus(event);
|
||||
|
||||
mBlockFocusEvents = PR_FALSE;
|
||||
|
||||
if (mWidget) {
|
||||
mWidget->SetFocus();
|
||||
}
|
||||
// don't recurse
|
||||
if (mBlockFocusEvents) {
|
||||
return NS_OK;
|
||||
}
|
||||
mBlockFocusEvents = PR_TRUE;
|
||||
|
||||
nsGUIEvent event;
|
||||
|
||||
event.message = NS_GOTFOCUS;
|
||||
event.widget = this;
|
||||
event.eventStructType = NS_GUI_EVENT;
|
||||
event.time = 0;
|
||||
event.point.x = 0;
|
||||
event.point.y = 0;
|
||||
|
||||
DispatchFocus(event);
|
||||
|
||||
mBlockFocusEvents = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::PreCreateWidget()\n"));
|
||||
if (nsnull != aInitData) {
|
||||
SetWindowType(aInitData->mWindowType);
|
||||
SetBorderStyle(aInitData->mBorderStyle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nsnull != aInitData) {
|
||||
SetWindowType(aInitData->mWindowType);
|
||||
SetBorderStyle(aInitData->mBorderStyle);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the native widget
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::CreateNative(QWidget *parentWidget)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::CreateNative()\n"));
|
||||
switch (mWindowType) {
|
||||
case eWindowType_toplevel:
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Top Level Create: %p\n",this);
|
||||
#endif
|
||||
break;
|
||||
|
||||
QWidget::WFlags w = 0;
|
||||
case eWindowType_dialog:
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Dialog Create: %p\n",this);
|
||||
#endif
|
||||
mIsDialog = PR_TRUE;
|
||||
break;
|
||||
|
||||
if (mBorderStyle == eBorderStyle_default) {
|
||||
w = 0;
|
||||
}
|
||||
else {
|
||||
if (mBorderStyle & eBorderStyle_all) {
|
||||
w |= 0;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_border) {
|
||||
w |= Qt::WStyle_DialogBorder;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_resizeh) {
|
||||
w |= Qt::WStyle_NormalBorder;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_title) {
|
||||
w |= Qt::WStyle_Title;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_menu) {
|
||||
w |= Qt::WStyle_SysMenu | Qt::WStyle_Title;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_minimize) {
|
||||
w |= Qt::WStyle_Minimize;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_maximize) {
|
||||
w |= Qt::WStyle_Maximize;
|
||||
}
|
||||
if (mBorderStyle & eBorderStyle_close) {
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("eBorderStyle_close isn't handled yet... please fix me\n"));
|
||||
}
|
||||
}
|
||||
case eWindowType_popup:
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Popup Create: %p\n",this);
|
||||
#endif
|
||||
mIsPopup = PR_TRUE;
|
||||
break;
|
||||
|
||||
w |= (w) ? Qt::WStyle_Customize : 0;
|
||||
case eWindowType_child:
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: Child Create: %p\n",this);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
mWidget = new nsQBaseWidget(this);
|
||||
|
||||
switch (mWindowType) {
|
||||
case eWindowType_toplevel:
|
||||
w |= Qt::WType_TopLevel | Qt::WDestructiveClose;
|
||||
break;
|
||||
if (!mWidget)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
case eWindowType_dialog:
|
||||
mIsDialog = PR_TRUE;
|
||||
w |= Qt::WType_Modal;
|
||||
break;
|
||||
|
||||
case eWindowType_popup:
|
||||
mIsPopup = PR_TRUE;
|
||||
w |= Qt::WType_Popup;
|
||||
break;
|
||||
|
||||
case eWindowType_child:
|
||||
break;
|
||||
}
|
||||
w |= Qt::WRepaintNoErase;
|
||||
w |= Qt::WResizeNoErase;
|
||||
|
||||
mWidget = (QWidget*)new nsQWidget(this, parentWidget, QWidget::tr("nsWindow"), w);
|
||||
if (!mWidget)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (!parentWidget) {
|
||||
// This is a top-level window. I'm not sure what special actions need
|
||||
// to be taken here.
|
||||
mWidget->resize(mBounds.width, mBounds.height);
|
||||
mIsToplevel = PR_TRUE;
|
||||
mListenForResizes = PR_TRUE;
|
||||
if (!gAppTopWindowSet) {
|
||||
qApp->setMainWidget(mWidget);
|
||||
gAppTopWindowSet = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mIsToplevel = PR_FALSE;
|
||||
}
|
||||
// Force cursor to default setting
|
||||
mCursor = eCursor_select;
|
||||
SetCursor(eCursor_standard);
|
||||
|
||||
return nsWidget::CreateNative(parentWidget);
|
||||
if (!mWidget->CreateNative(parentWidget,QWidget::tr("nsWindow"),
|
||||
NS_GetQWFlags(mBorderStyle,mWindowType))) {
|
||||
delete mWidget;
|
||||
mWidget = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!parentWidget && !mIsDialog) {
|
||||
// This is a top-level window. I'm not sure what special actions
|
||||
// need to be taken here.
|
||||
mIsToplevel = PR_TRUE;
|
||||
mListenForResizes = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
mIsToplevel = PR_FALSE;
|
||||
}
|
||||
return nsWidget::CreateNative(parentWidget);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Initialize all the Callbacks
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::InitCallbacks(char * aName)
|
||||
void nsWindow::InitCallbacks(char *aName)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::InitCallbacks()\n"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the colormap of the window
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::SetColorMap()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Scroll the bits of a window
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
|
||||
NS_METHOD nsWindow::Scroll(PRInt32 aDx,PRInt32 aDy,nsRect *aClipRect)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::Scroll: (%d,%d)\n",
|
||||
aDx, aDy));
|
||||
if (mWidget) {
|
||||
mWidget->scroll(aDx, aDy);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
if (mWidget) {
|
||||
mWidget->Scroll(aDx,aDy);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::SetTitle(const nsString& aTitle)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::SetTitle()\n"));
|
||||
if (!mWidget) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
const char * titleStr = aTitle.ToNewCString();
|
||||
mWidget->setCaption(QString::fromLocal8Bit(titleStr));
|
||||
delete[] titleStr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes an Expose Event
|
||||
*
|
||||
**/
|
||||
/* Processes an Expose Event */
|
||||
PRBool nsWindow::OnPaint(nsPaintEvent &event)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::OnPaint()\n"));
|
||||
nsresult result ;
|
||||
PRInt32 x;
|
||||
PRInt32 y;
|
||||
PRInt32 width;
|
||||
PRInt32 height;
|
||||
nsresult result;
|
||||
PRInt32 x;
|
||||
PRInt32 y;
|
||||
PRInt32 width;
|
||||
PRInt32 height;
|
||||
|
||||
|
||||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
|
||||
event.renderingContext = nsnull;
|
||||
if (event.rect) {
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsWindow::OnPaint: this=%p, {%d,%d,%d,%d}\n",
|
||||
this,
|
||||
event.rect->x,
|
||||
event.rect->y,
|
||||
event.rect->width,
|
||||
event.rect->height));
|
||||
x = event.rect->x;
|
||||
y = event.rect->y;
|
||||
width = event.rect->width;
|
||||
height = event.rect->height;
|
||||
}
|
||||
else {
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsWindow::OnPaint: this=%p, NO RECT\n",
|
||||
this));
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (mWidget) {
|
||||
width = mWidget->width();
|
||||
height = mWidget->height();
|
||||
}
|
||||
else {
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID,
|
||||
nsnull,
|
||||
kRenderingContextIID,
|
||||
(void **)&event.renderingContext)) {
|
||||
if (mBounds.width && mBounds.height) {
|
||||
event.renderingContext->Init(mContext, this);
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
if (mWidget && mPixmap) {
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsWindow::OnPaint: bitBlt: {%d,%d,%d,%d}\n",
|
||||
x, y, width, height));
|
||||
bitBlt(mWidget, x, y, mPixmap, x, y, width, height, Qt::CopyROP);
|
||||
mPixmap->fill(mWidget, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = PR_FALSE;
|
||||
}
|
||||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
event.renderingContext = nsnull;
|
||||
if (event.rect) {
|
||||
x = event.rect->x;
|
||||
y = event.rect->y;
|
||||
width = event.rect->width;
|
||||
height = event.rect->height;
|
||||
}
|
||||
return result;
|
||||
else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (mWidget) {
|
||||
width = mWidget->Width();
|
||||
height = mWidget->Height();
|
||||
}
|
||||
else {
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID,
|
||||
nsnull,
|
||||
kRenderingContextIID,
|
||||
(void **)&event.renderingContext)) {
|
||||
if (mBounds.width && mBounds.height) {
|
||||
event.renderingContext->Init(mContext, this);
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_IF_RELEASE(event.renderingContext);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = PR_FALSE;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsWindow::BeginResizingChildren(void)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::BeginResizingChildren()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::EndResizingChildren(void)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::EndResizingChildren()\n"));
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsWindow::OnKey(nsKeyEvent &aEvent)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::OnKey()\n"));
|
||||
if (mEventCallback) {
|
||||
return DispatchWindowEvent(&aEvent);
|
||||
}
|
||||
return PR_FALSE;
|
||||
if (mEventCallback) {
|
||||
return DispatchWindowEvent(&aEvent);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::DispatchFocus()\n"));
|
||||
if (mEventCallback) {
|
||||
return DispatchWindowEvent(&aEvent);
|
||||
}
|
||||
return PR_FALSE;
|
||||
if (mEventCallback) {
|
||||
return DispatchWindowEvent(&aEvent);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::GetClientBounds(nsRect &aRect)
|
||||
{
|
||||
return GetBounds(aRect);
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::GetBounds(nsRect &aRect)
|
||||
{
|
||||
nsRect Rct(mWidget->BoundsX(),mWidget->BoundsX(),
|
||||
mWidget->Width(),mWidget->Height());
|
||||
|
||||
aRect = Rct;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::GetScreenBounds(nsRect &aRect)
|
||||
{
|
||||
nsRect nBounds(0,0,mBounds.width,mBounds.height);
|
||||
|
||||
aRect = nBounds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::GetBoundsAppUnits(nsRect &aRect, float aAppUnits)
|
||||
{
|
||||
GetBounds(aRect);
|
||||
|
||||
// Convert to twips
|
||||
aRect.x = nscoord((PRFloat64)aRect.x * aAppUnits);
|
||||
aRect.y = nscoord((PRFloat64)aRect.y * aAppUnits);
|
||||
aRect.width = nscoord((PRFloat64)aRect.width * aAppUnits);
|
||||
aRect.height = nscoord((PRFloat64)aRect.height * aAppUnits);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsWindow::OnScroll(nsScrollbarEvent &aEvent, PRUint32 cPos)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsWindow::OnScroll()\n"));
|
||||
return PR_FALSE;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::ConstrainPosition(PRInt32 *aX, PRInt32 *aY)
|
||||
{
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
|
||||
{
|
||||
PR_LOG(QtWidgetsLM,
|
||||
PR_LOG_DEBUG,
|
||||
("nsWindow::Move %s by (%d,%d)\n",
|
||||
mWidget ? mWidget->name() : "(null)",
|
||||
aX, aY));
|
||||
|
||||
if (mWidget && mParent && mWindowType == eWindowType_popup) {
|
||||
nsRect oldrect, newrect;
|
||||
|
||||
|
@ -474,8 +363,8 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
|
|||
|
||||
oldrect.x = aX;
|
||||
oldrect.y = aY;
|
||||
mParent->WidgetToScreen(oldrect, newrect);
|
||||
mWidget->move(newrect.x,newrect.y);
|
||||
mParent->WidgetToScreen(oldrect,newrect);
|
||||
mWidget->Move(newrect.x,newrect.y);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -483,39 +372,40 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
|
|||
return(nsWidget::Move(aX,aY));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
|
||||
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
|
||||
PRBool aDoCapture,
|
||||
PRBool aConsumeRollupEvent)
|
||||
{
|
||||
if (aDoCapture)
|
||||
{
|
||||
/* Create a pointer region */
|
||||
mIsGrabbing = PR_TRUE;
|
||||
mGrabWindow = this;
|
||||
if (aDoCapture) {
|
||||
/* Create a pointer region */
|
||||
mIsGrabbing = PR_TRUE;
|
||||
mGrabWindow = this;
|
||||
|
||||
gRollupConsumeRollupEvent = PR_TRUE;
|
||||
gRollupListener = aListener;
|
||||
gRollupWidget = getter_AddRefs(NS_GetWeakReference(NS_STATIC_CAST(nsIWidget*,this)));
|
||||
gRollupConsumeRollupEvent = PR_TRUE;
|
||||
gRollupListener = aListener;
|
||||
gRollupWidget = getter_AddRefs(NS_GetWeakReference(NS_STATIC_CAST(nsIWidget*,this)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure that the grab window is marked as released
|
||||
if (mGrabWindow == this) {
|
||||
mGrabWindow = NULL;
|
||||
}
|
||||
mIsGrabbing = PR_FALSE;
|
||||
else {
|
||||
// make sure that the grab window is marked as released
|
||||
if (mGrabWindow == this) {
|
||||
mGrabWindow = NULL;
|
||||
}
|
||||
mIsGrabbing = PR_FALSE;
|
||||
|
||||
gRollupListener = nsnull;
|
||||
gRollupWidget = nsnull;
|
||||
gRollupListener = nsnull;
|
||||
gRollupWidget = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
ChildWindow::ChildWindow()
|
||||
{
|
||||
#ifdef DBG_JCG
|
||||
gChildCount++;
|
||||
mChildID = gChildID++;
|
||||
printf("JCG: nsChildWindow CTOR. (%p) ID: %d, Count: %d\n",this,mChildID,gChildCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
ChildWindow::~ChildWindow()
|
||||
|
@ -524,22 +414,13 @@ ChildWindow::~ChildWindow()
|
|||
IndentByDepth(stdout);
|
||||
printf("ChildWindow::~ChildWindow:%p\n", this);
|
||||
#endif
|
||||
if (mEventHandler && mParent) {
|
||||
((nsWidget*)(mParent.get()))->RemoveChildEventHandler(mEventHandler);
|
||||
}
|
||||
#ifdef DBG_JCG
|
||||
gChildCount--;
|
||||
printf("JCG: nsChildWindow DTOR. (%p) ID: %d, Count: %d\n",this,mChildID,gChildCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
PRBool ChildWindow::IsChild() const
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_METHOD ChildWindow::CreateNative(QWidget *parentWidget)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsWindow::CreateNative(parentWidget);
|
||||
if (rv == NS_OK && mEventHandler && mParent)
|
||||
((nsWidget*)(mParent.get()))->AddChildEventHandler(mEventHandler);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -18,45 +18,15 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
#ifndef Window_h__
|
||||
#define Window_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsWidget.h"
|
||||
#include "nsQEventHandler.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include <qlayout.h>
|
||||
|
||||
class nsFont;
|
||||
|
||||
#define NSRGB_2_COLOREF(color) \
|
||||
RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// nsQWidget class
|
||||
//
|
||||
//=============================================================================
|
||||
class nsQWidget : public QWidget , public nsQBaseWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsQWidget(nsWidget * widget,
|
||||
QWidget * parent = 0,
|
||||
const char * name = 0,
|
||||
WFlags f = WResizeNoErase);
|
||||
~nsQWidget();
|
||||
void Destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
* Native QT window wrapper.
|
||||
*/
|
||||
|
||||
/* Native QT window wrapper */
|
||||
class nsWindow : public nsWidget
|
||||
{
|
||||
public:
|
||||
|
@ -67,20 +37,19 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIWidget interface
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY);
|
||||
|
||||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData);
|
||||
|
||||
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
|
||||
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
|
||||
NS_IMETHOD Scroll(PRInt32 aDx,PRInt32 aDy,nsRect *aClipRect);
|
||||
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
NS_IMETHOD ConstrainPosition(PRInt32 *aX,PRInt32 *aY);
|
||||
NS_IMETHOD Move(PRInt32 aX,PRInt32 aY);
|
||||
|
||||
NS_IMETHOD ConstrainPosition(PRInt32 *aX, PRInt32 *aY);
|
||||
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
||||
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
|
||||
PRBool aDoCapture,PRBool aConsumeRollupEvent);
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
||||
PRBool aDoCapture,
|
||||
PRBool aConsumeRollupEvent);
|
||||
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
|
||||
NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]);
|
||||
NS_IMETHOD RemoveTooltips();
|
||||
|
@ -89,45 +58,33 @@ public:
|
|||
NS_IMETHOD EndResizingChildren(void);
|
||||
NS_IMETHOD SetFocus(PRBool aRaise);
|
||||
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetBoundsAppUnits(nsRect &aRect,float aAppUnits);
|
||||
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetScreenBounds(nsRect &aRect);
|
||||
|
||||
virtual PRBool IsChild() const;
|
||||
virtual PRBool IsPopup() const { return mIsPopup; };
|
||||
virtual PRBool IsDialog() const { return mIsDialog; };
|
||||
|
||||
virtual void SetIsDestroying( PRBool val) { mIsDestroying = val; };
|
||||
|
||||
PRBool IsDestroying() const { return mIsDestroying; }
|
||||
|
||||
// Utility methods
|
||||
virtual PRBool OnPaint(nsPaintEvent &event);
|
||||
PRBool OnKey(nsKeyEvent &aEvent);
|
||||
PRBool DispatchFocus(nsGUIEvent &aEvent);
|
||||
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
||||
virtual PRBool OnKey(nsKeyEvent &aEvent);
|
||||
virtual PRBool DispatchFocus(nsGUIEvent &aEvent);
|
||||
virtual PRBool OnScroll(nsScrollbarEvent &aEvent,PRUint32 cPos);
|
||||
|
||||
char gInstanceClassName[256];
|
||||
|
||||
protected:
|
||||
virtual void InitCallbacks(char * aName = nsnull);
|
||||
virtual void InitCallbacks(char *aName = nsnull);
|
||||
NS_IMETHOD CreateNative(QWidget *parentWidget);
|
||||
|
||||
nsIFontMetrics * mFontMetrics;
|
||||
PRBool mVisible;
|
||||
PRBool mDisplayed;
|
||||
PRBool mIsDestroying;
|
||||
PRBool mBlockFocusEvents;
|
||||
PRBool mIsDialog;
|
||||
PRBool mIsPopup;
|
||||
|
||||
// XXX Temporary, should not be caching the font
|
||||
nsFont * mFont;
|
||||
|
||||
// Resize event management
|
||||
nsRect mResizeRect;
|
||||
int mResized;
|
||||
PRBool mLowerLeft;
|
||||
PRBool mBlockFocusEvents;
|
||||
PRBool mIsDialog;
|
||||
PRBool mIsPopup;
|
||||
|
||||
// are we doing a grab?
|
||||
static PRBool mIsGrabbing;
|
||||
static nsWindow *mGrabWindow;
|
||||
static PRBool mIsGrabbing;
|
||||
static nsWindow *mGrabWindow;
|
||||
PRInt32 mWindowID;
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -139,7 +96,8 @@ public:
|
|||
ChildWindow();
|
||||
~ChildWindow();
|
||||
virtual PRBool IsChild() const;
|
||||
NS_IMETHOD CreateNative(QWidget *parentWidget);
|
||||
|
||||
PRInt32 mChildID;
|
||||
};
|
||||
|
||||
#endif // Window_h__
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# John C. Griggs <johng@corel.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../../..
|
||||
|
@ -26,25 +27,26 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = timer
|
||||
LIBRARY_NAME = timer_$(TIMER_SUFFIX)
|
||||
REQUIRES = xpcom
|
||||
|
||||
CPPSRCS = \
|
||||
moc_nsTimerEventHandler.cpp \
|
||||
$(MOCSRCS) \
|
||||
nsTimerEventHandler.cpp \
|
||||
nsTimerQt.cpp \
|
||||
$(NULL)
|
||||
|
||||
MOCSRCS = \
|
||||
moc_nsTimerEventHandler.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
TIMER_SUFFIX = qt
|
||||
IS_COMPONENT = 1
|
||||
CPPSRCS += nsTimerQtFactory.cpp
|
||||
EXTRA_DSO_LDOPTS = $(MOZ_QT_LDFLAGS) $(MOZ_COMPONENT_LIBS)
|
||||
#CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
#CFLAGS += $(MOZ_QT_CFLAGS)
|
||||
else
|
||||
#EXTRA_DSO_LDOPTS = $(TK_LIBS)
|
||||
#CXXFLAGS += $(TK_CFLAGS)
|
||||
#CFLAGS += $(TK_CFLAGS)
|
||||
TIMER_SUFFIX = s
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
@ -58,7 +60,3 @@ else
|
|||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
endif
|
||||
|
||||
#INCLUDES += \
|
||||
# -I$(srcdir)/..
|
||||
|
||||
|
|
|
@ -18,35 +18,63 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsTimerEventHandler.h"
|
||||
|
||||
#include <qtimer.h>
|
||||
//JCG #define DBG_JCG 1
|
||||
|
||||
nsTimerEventHandler::nsTimerEventHandler(nsITimer * aTimer,
|
||||
#ifdef DBG_JCG
|
||||
PRUint32 gTimerHandlerCount = 0;
|
||||
PRUint32 gTimerHandlerID = 0;
|
||||
#endif
|
||||
|
||||
nsTimerEventHandler::nsTimerEventHandler(nsITimer *aTimer,
|
||||
nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
nsITimerCallback *aCallback)
|
||||
{
|
||||
mTimer = aTimer;
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
mCallback = aCallback;
|
||||
#ifdef DBG_JCG
|
||||
gTimerHandlerCount++;
|
||||
mTimerHandlerID = gTimerHandlerID++;
|
||||
printf("JCG: nsTimerEventHandler CTOR (%p) ID: %d, Count: %d\n",
|
||||
this,mTimerHandlerID,gTimerHandlerCount);
|
||||
#endif
|
||||
mTimer = aTimer;
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
mCallback = aCallback;
|
||||
}
|
||||
|
||||
nsTimerEventHandler::~nsTimerEventHandler()
|
||||
{
|
||||
#ifdef DBG_JCG
|
||||
gTimerHandlerCount--;
|
||||
printf("JCG: nsTimerEventHandler DTOR (%p) ID: %d, Count: %d\n",
|
||||
this,mTimerHandlerID,gTimerHandlerCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsTimerEventHandler::FireTimeout()
|
||||
{
|
||||
//debug("nsTimerEventHandler::FireTimeout called");
|
||||
if (mFunc != NULL)
|
||||
{
|
||||
(*mFunc)(mTimer, mClosure);
|
||||
}
|
||||
else if (mCallback != NULL)
|
||||
{
|
||||
mCallback->Notify(mTimer); // Fire the timer
|
||||
}
|
||||
|
||||
// Always repeating here
|
||||
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: nsTimerEventHandler::FireTimeout (%p) ID: %d\n",
|
||||
this,mTimerHandlerID);
|
||||
#endif
|
||||
//because Notify can cause 'this' to get destroyed,
|
||||
// we need to hold a ref
|
||||
nsCOMPtr<nsITimer> kungFuDeathGrip = mTimer;
|
||||
if (mFunc != NULL) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: nsTimerEventHandler::FireTimeout: Calling Function\n");
|
||||
#endif
|
||||
(*mFunc)(mTimer,mClosure);
|
||||
}
|
||||
else if (mCallback != NULL) {
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: nsTimerEventHandler::FireTimeout: Calling Notify\n");
|
||||
#endif
|
||||
mCallback->Notify(mTimer); // Fire the timer
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __nsTimerEventHandler_h__
|
||||
#define __nsTimerEventHandler_h__
|
||||
|
||||
|
@ -31,22 +32,22 @@
|
|||
class nsTimerEventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
nsTimerEventHandler(nsITimer * aTimer,
|
||||
nsTimerEventHandler(nsITimer *aTimer,
|
||||
nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
nsITimerCallback *aCallback);
|
||||
~nsTimerEventHandler();
|
||||
|
||||
public slots:
|
||||
void FireTimeout();
|
||||
|
||||
private:
|
||||
nsTimerCallbackFunc mFunc;
|
||||
void * mClosure;
|
||||
nsITimerCallback * mCallback;
|
||||
nsITimer * mTimer;
|
||||
void *mClosure;
|
||||
nsITimerCallback *mCallback;
|
||||
nsITimer *mTimer;
|
||||
PRUint32 mTimerHandlerID;
|
||||
};
|
||||
|
||||
#endif // __nsTimerEventHandler_h__
|
||||
|
||||
|
|
|
@ -18,120 +18,137 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsTimerQt.h"
|
||||
#include "nsTimerEventHandler.h"
|
||||
|
||||
#include <qtimer.h>
|
||||
|
||||
#include <stdio.h>
|
||||
//JCG #define DBG_JCG 1
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
#ifdef DBG_JCG
|
||||
PRUint32 gTimerCount = 0;
|
||||
PRUint32 gTimerID = 0;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID,NS_ITIMER_IID);
|
||||
|
||||
nsTimerQt::nsTimerQt()
|
||||
{
|
||||
//debug("nsTimerQt::nsTimerQt called for %p", this);
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = nsnull;
|
||||
mCallback = nsnull;
|
||||
mNext = nsnull;
|
||||
mTimer = nsnull;
|
||||
mDelay = 0;
|
||||
mClosure = nsnull;
|
||||
mEventHandler = nsnull;
|
||||
#ifdef DBG_JCG
|
||||
gTimerCount++;
|
||||
mTimerID = gTimerID++;
|
||||
printf("JCG: nsTimerQT CTOR (%p) ID: %d, Count: %d\n",this,mTimerID,gTimerCount);
|
||||
#endif
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = nsnull;
|
||||
mCallback = nsnull;
|
||||
mNext = nsnull;
|
||||
mTimer = nsnull;
|
||||
mDelay = 0;
|
||||
mClosure = nsnull;
|
||||
mEventHandler = nsnull;
|
||||
mPriority = 0;
|
||||
mType = NS_TYPE_ONE_SHOT;
|
||||
}
|
||||
|
||||
nsTimerQt::~nsTimerQt()
|
||||
{
|
||||
//debug("nsTimerQt::~nsTimerQt called for %p", this);
|
||||
Cancel();
|
||||
#ifdef DBG_JCG
|
||||
gTimerCount--;
|
||||
printf("JCG: nsTimerQT DTOR (%p) ID: %d, Count: %d\n",this,mTimerID,gTimerCount);
|
||||
#endif
|
||||
Cancel();
|
||||
|
||||
NS_IF_RELEASE(mCallback);
|
||||
NS_IF_RELEASE(mCallback);
|
||||
|
||||
if (mEventHandler) {
|
||||
delete mEventHandler;
|
||||
mEventHandler = nsnull;
|
||||
}
|
||||
|
||||
if (mTimer) {
|
||||
delete mTimer;
|
||||
mTimer = nsnull;
|
||||
}
|
||||
if (mEventHandler) {
|
||||
delete mEventHandler;
|
||||
mEventHandler = nsnull;
|
||||
}
|
||||
if (mTimer) {
|
||||
delete mTimer;
|
||||
mTimer = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTimerQt::Init(nsTimerCallbackFunc aFunc, void *aClosure, PRUint32 aDelay,
|
||||
PRUint32 aPriority, PRUint32 aType)
|
||||
{
|
||||
//debug("nsTimerQt::Init called with func + closure with %u delay", aDelay);
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: nsTimerQT::Init (%p) ID: %d WITH Function\n",this,mTimerID);
|
||||
printf("JCG: Priority: %d, Delay: %d, OneShot: %s\n",aPriority,aDelay,
|
||||
(aType == NS_TYPE_ONE_SHOT)?"Y":"N");
|
||||
#endif
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
mPriority = aPriority;
|
||||
mType = aType;
|
||||
|
||||
return Init(aDelay);
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTimerQt::Init(nsITimerCallback *aCallback, PRUint32 aDelay,
|
||||
PRUint32 aPriority, PRUint32 aType)
|
||||
{
|
||||
//debug("nsTimerQt::Init called with callback only with %u delay", aDelay);
|
||||
mCallback = aCallback;
|
||||
NS_ADDREF(mCallback);
|
||||
return Init(aDelay);
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: nsTimerQT::Init (%p) ID: %d WITH Callback\n",this,mTimerID);
|
||||
printf("JCG: Priority: %d, Delay: %d, OneShot: %s, Now: %ld\n",aPriority,aDelay,
|
||||
(aType == NS_TYPE_ONE_SHOT)?"Y":"N",PR_Now());
|
||||
#endif
|
||||
mCallback = aCallback;
|
||||
NS_ADDREF(mCallback);
|
||||
mPriority = aPriority;
|
||||
mType = aType;
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTimerQt::Init(PRUint32 aDelay)
|
||||
{
|
||||
//debug("nsTimerQt::Init called with delay %d only for %p", aDelay, this);
|
||||
mEventHandler = new nsTimerEventHandler(this,mFunc,mClosure,mCallback);
|
||||
|
||||
mEventHandler = new nsTimerEventHandler(this, mFunc, mClosure, mCallback);
|
||||
mTimer = new QTimer();
|
||||
if (!mTimer) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
QObject::connect((QTimer*)mTimer,SIGNAL(timeout()),
|
||||
mEventHandler,SLOT(FireTimeout()));
|
||||
|
||||
mTimer = new QTimer();
|
||||
|
||||
if (!mTimer) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
QObject::connect((QTimer *)mTimer,
|
||||
SIGNAL(timeout()),
|
||||
mEventHandler,
|
||||
SLOT(FireTimeout()));
|
||||
|
||||
mTimer->start(aDelay);
|
||||
|
||||
mDelay = aDelay;
|
||||
|
||||
return NS_OK;
|
||||
mTimer->start(aDelay,mType == NS_TYPE_ONE_SHOT);
|
||||
mDelay = aDelay;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsTimerQt, nsITimer)
|
||||
|
||||
|
||||
|
||||
void
|
||||
nsTimerQt::Cancel()
|
||||
{
|
||||
//debug("nsTimerQt::Cancel called for %p", this);
|
||||
if (mTimer) {
|
||||
mTimer->stop();
|
||||
}
|
||||
#ifdef DBG_JCG
|
||||
printf("JCG: nsTimerQT::Cancel (%p) ID: %d\n",this,mTimerID);
|
||||
#endif
|
||||
if (mTimer) {
|
||||
mTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_MONOLITHIC_TOOLKIT
|
||||
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsTimerQt *timer = new nsTimerQt();
|
||||
if (nsnull == timer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsTimerQt *timer = new nsTimerQt();
|
||||
if (nsnull == timer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return timer->QueryInterface(kITimerIID,(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer)
|
||||
|
|
|
@ -18,70 +18,66 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __nsTimerQt_h__
|
||||
#define __nsTimerQt_h__
|
||||
|
||||
#include "nsTimerEventHandler.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
|
||||
/*
|
||||
* Implementation of timers using Qt QTimer class
|
||||
*/
|
||||
class nsTimerEventHandler;
|
||||
class QTimer;
|
||||
|
||||
/* Implementation of timers using Qt QTimer class */
|
||||
class nsTimerQt : public nsITimer
|
||||
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
nsTimerQt();
|
||||
virtual ~nsTimerQt();
|
||||
|
||||
virtual nsresult Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority = NS_PRIORITY_NORMAL,
|
||||
PRUint32 aType = NS_TYPE_ONE_SHOT
|
||||
);
|
||||
void *aClosure,PRUint32 aDelay,
|
||||
PRUint32 aPriority = NS_PRIORITY_NORMAL,
|
||||
PRUint32 aType = NS_TYPE_ONE_SHOT);
|
||||
|
||||
virtual nsresult Init(nsITimerCallback *aCallback,
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority = NS_PRIORITY_NORMAL,
|
||||
PRUint32 aType = NS_TYPE_ONE_SHOT
|
||||
);
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority = NS_PRIORITY_NORMAL,
|
||||
PRUint32 aType = NS_TYPE_ONE_SHOT);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual void Cancel();
|
||||
|
||||
virtual PRUint32 GetDelay() { return mDelay; }
|
||||
virtual void SetDelay(PRUint32 aDelay) { mDelay=aDelay; };
|
||||
virtual void SetDelay(PRUint32 aDelay) { mDelay = aDelay; };
|
||||
|
||||
virtual PRUint32 GetPriority() { return mPriority; }
|
||||
virtual void SetPriority(PRUint32 aPriority) { mPriority=aPriority; }
|
||||
virtual void SetPriority(PRUint32 aPriority) { mPriority = aPriority; }
|
||||
|
||||
virtual PRUint32 GetType() { return mType; }
|
||||
virtual void SetType(PRUint32 aType) { mType=aType; }
|
||||
virtual void SetType(PRUint32 aType) { mType = aType; }
|
||||
|
||||
virtual void* GetClosure() { return mClosure; }
|
||||
virtual void *GetClosure() { return mClosure; }
|
||||
|
||||
void FireTimeout();
|
||||
|
||||
private:
|
||||
nsresult Init(PRUint32 aDelay);
|
||||
|
||||
private:
|
||||
PRUint32 mDelay;
|
||||
PRUint32 mPriority;
|
||||
PRUint32 mType;
|
||||
nsTimerCallbackFunc mFunc;
|
||||
void * mClosure;
|
||||
nsITimerCallback * mCallback;
|
||||
void *mClosure;
|
||||
nsITimerCallback *mCallback;
|
||||
PRBool mRepeat;
|
||||
nsTimerQt * mNext;
|
||||
QTimer * mTimer;
|
||||
nsTimerEventHandler * mEventHandler;
|
||||
nsTimerQt *mNext;
|
||||
QTimer *mTimer;
|
||||
nsTimerEventHandler *mEventHandler;
|
||||
PRUint32 mTimerID;
|
||||
};
|
||||
|
||||
#endif // __nsTimerQt_h__
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -42,4 +43,5 @@ static nsModuleComponentInfo components[] =
|
|||
nsTimerQtConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsQtTimerModule", components)
|
||||
NS_IMPL_NSGETMODULE("nsQtTimerModule",components)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче