Remove qt toolkit support from the tree.

Use the QT_LAST_RITES tag to pull the last known "good" tree to continue work on the port.
Bug #178987 r=bryner
This commit is contained in:
seawood%netscape.com 2003-02-22 07:14:37 +00:00
Родитель 28243cf27e
Коммит b44c065b1d
74 изменённых файлов: 3 добавлений и 17537 удалений

Просмотреть файл

@ -140,7 +140,6 @@ gfx/src/gtk/Makefile
gfx/src/ps/Makefile
gfx/src/photon/Makefile
gfx/src/mac/Makefile
gfx/src/qt/Makefile
gfx/src/xlib/Makefile
gfx/src/os2/Makefile
gfx/src/xlibrgb/Makefile
@ -522,7 +521,6 @@ webshell/tests/viewer/Makefile
webshell/tests/viewer/public/Makefile
webshell/tests/viewer/unix/Makefile
webshell/tests/viewer/unix/gtk/Makefile
webshell/tests/viewer/unix/qt/Makefile
webshell/tests/viewer/unix/xlib/Makefile
"
@ -542,7 +540,6 @@ widget/src/cocoa/Makefile
widget/src/xlib/Makefile
widget/src/os2/Makefile
widget/src/os2/tests/Makefile
widget/src/qt/Makefile
widget/src/windows/Makefile
widget/src/windows/expose/Makefile
widget/src/windows/expose/ISimpleDOMNode/Makefile

Просмотреть файл

@ -326,7 +326,6 @@ MOZ_TOOLKIT_REGISTRY_CFLAGS = \
MOZ_ENABLE_GTK = @MOZ_ENABLE_GTK@
MOZ_ENABLE_GTK2 = @MOZ_ENABLE_GTK2@
MOZ_ENABLE_XLIB = @MOZ_ENABLE_XLIB@
MOZ_ENABLE_QT = @MOZ_ENABLE_QT@
MOZ_ENABLE_PHOTON = @MOZ_ENABLE_PHOTON@
MOZ_ENABLE_COCOA = @MOZ_ENABLE_COCOA@
MOZ_ENABLE_XREMOTE = @MOZ_ENABLE_XREMOTE@
@ -340,9 +339,6 @@ MOZ_GTK2_LIBS = @MOZ_GTK2_LIBS@
MOZ_XLIB_CFLAGS = @MOZ_XLIB_CFLAGS@
MOZ_XLIB_LDFLAGS = @MOZ_XLIB_LDFLAGS@
MOZ_QT_CFLAGS = @MOZ_QT_CFLAGS@
MOZ_QT_LDFLAGS = @MOZ_QT_LDFLAGS@
MOZ_XPRINT_CFLAGS = @MOZ_XPRINT_CFLAGS@
MOZ_XPRINT_LDFLAGS = @MOZ_XPRINT_LDFLAGS@
MOZ_ENABLE_XPRINT = @MOZ_ENABLE_XPRINT@

Просмотреть файл

@ -87,8 +87,6 @@ GLIB_VERSION=1.2.0
GTK_VERSION=1.2.0
LIBIDL_VERSION=0.6.3
PERL_VERSION=5.004
QT_VERSION=2.2.0
QT_VERSION_NUM=220
LIBART_VERSION=2.3.4
GTK2_VERSION=1.3.7
@ -676,11 +674,6 @@ if test "$GNU_CXX"; then
# Turn on GNU specific features
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy"
dnl The following warning breaks Qt
if test ! "$QTDIR"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS}"
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
_USE_CPP_INCLUDE_FLAG=1
else
@ -2972,7 +2965,6 @@ MOZ_ARG_HEADER(Toolkit Options)
[ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
if test "$_DEFAULT_TOOLKIT" = "gtk" \
-o "$_DEFAULT_TOOLKIT" = "qt" \
-o "$_DEFAULT_TOOLKIT" = "gtk2" \
-o "$_DEFAULT_TOOLKIT" = "xlib" \
-o "$_DEFAULT_TOOLKIT" = "os2" \
@ -2987,7 +2979,7 @@ MOZ_ARG_HEADER(Toolkit Options)
MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
else
if test "$no_x" != "yes"; then
AC_MSG_ERROR([Toolkit must be xlib, gtk, gtk2 or qt.])
AC_MSG_ERROR([Toolkit must be xlib, gtk or gtk2.])
else
AC_MSG_ERROR([Toolkit must be $_PLATFORM_DEFAULT_TOOLKIT.])
fi
@ -3011,14 +3003,6 @@ if test "$no_x" != "yes"; then
MOZ_ENABLE_XLIB=1,
MOZ_ENABLE_XLIB= )
dnl ========================================================
dnl = Qt support hackery =
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(toolkit-qt,
[ --enable-toolkit-qt Enable Qt Toolkit support ],
MOZ_ENABLE_QT=1,
MOZ_ENABLE_QT= )
fi # !no_x
AC_DEFINE_UNQUOTED(MOZ_DEFAULT_TOOLKIT,"$MOZ_WIDGET_TOOLKIT")
@ -3052,14 +3036,6 @@ xlib)
AC_DEFINE(MOZ_WIDGET_XLIB)
;;
qt)
MOZ_ENABLE_QT=1
MOZ_ENABLE_XREMOTE=1
TK_CFLAGS='$(MOZ_QT_CFLAGS)'
TK_LIBS='$(MOZ_QT_LDFLAGS)'
AC_DEFINE(MOZ_WIDGET_QT)
;;
photon)
MOZ_ENABLE_PHOTON=1
AC_DEFINE(MOZ_WIDGET_PHOTON)
@ -3117,77 +3093,6 @@ then
MOZ_XLIB_LDFLAGS="$MOZ_XLIB_LDFLAGS $XEXT_LIBS $X11_LIBS"
fi
if test "$MOZ_ENABLE_QT"
then
MOZ_ARG_WITH_STRING(qtdir,
[ --with-qtdir=\$dir Specify Qt directory ],
[ QTDIR=$withval])
if test -z "$QTDIR"; then
QTDIR="/usr"
fi
QTINCDIR="/include/qt"
if test ! -d "$QTDIR$QTINCDIR"; then
QTINCDIR="/include/X11/qt"
fi
if test ! -d "$QTDIR$QTINCDIR"; then
QTINCDIR="/include"
fi
if test -x "$QTDIR/bin/moc"; then
HOST_MOC="$QTDIR/bin/moc"
else
AC_CHECK_PROGS(HOST_MOC, moc, "")
fi
if test -z "$HOST_MOC"; then
AC_MSG_ERROR([no acceptable moc preprocessor found])
fi
MOC=$HOST_MOC
QT_CFLAGS="-I${QTDIR}${QTINCDIR} -DQT_GENUINE_STR -DQT_NO_STL"
if test -z "$MOZ_DEBUG"; then
QT_CFLAGS="$QT_CFLAGS -DQT_NO_DEBUG -DNO_DEBUG"
fi
_SAVE_LDFLAGS=$LDFLAGS
QT_LDFLAGS=-L${QTDIR}/lib
LDFLAGS="$LDFLAGS $QT_LDFLAGS"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_CHECK_LIB(qt, main, QT_LIB=-lqt,
AC_CHECK_LIB(qt-mt, main, QT_LIB=-lqt-mt,
AC_MSG_ERROR([Cannot find QT libraries.])))
LDFLAGS=$_SAVE_LDFLAGS
QT_LIBS="-L/usr/X11R6/lib $QT_LDFLAGS $QT_LIB -lXext -lX11"
dnl AM_PATH_QT($QT_VERSION,,
dnl AC_MSG_ERROR(Test for QT failed.))
MOZ_QT_LDFLAGS=$QT_LIBS
MOZ_QT_CFLAGS=$QT_CFLAGS
_SAVE_CXXFLAGS=$CXXFLAGS
_SAVE_LIBS=$LIBS
CXXFLAGS="$CXXFLAGS $QT_CFLAGS"
LIBS="$LIBS $QT_LIBS"
AC_MSG_CHECKING(Qt - version >= $QT_VERSION)
AC_TRY_COMPILE([#include <qglobal.h>],
[
#if (QT_VERSION < $QT_VERSION_NUM)
#error "QT_VERSION too old"
#endif
],result="yes",result="no")
AC_MSG_RESULT("$result")
if test "$result" = "no"; then
AC_MSG_ERROR([Qt Mozilla requires at least version $QT_VERSION of Qt])
fi
CXXFLAGS=$_SAVE_CXXFLAGS
LIBS=$_SAVE_LIBS
AC_LANG_RESTORE
fi
AC_SUBST(MOZ_DEFAULT_TOOLKIT)
AC_SUBST(GTK_CONFIG)
@ -3197,7 +3102,6 @@ AC_SUBST(TK_LIBS)
AC_SUBST(MOZ_ENABLE_GTK)
AC_SUBST(MOZ_ENABLE_XLIB)
AC_SUBST(MOZ_ENABLE_GTK2)
AC_SUBST(MOZ_ENABLE_QT)
AC_SUBST(MOZ_ENABLE_PHOTON)
AC_SUBST(MOZ_ENABLE_COCOA)
AC_SUBST(MOZ_ENABLE_XREMOTE)
@ -3207,12 +3111,10 @@ AC_SUBST(MOZ_GTK2_CFLAGS)
AC_SUBST(MOZ_GTK2_LIBS)
AC_SUBST(MOZ_XLIB_CFLAGS)
AC_SUBST(MOZ_XLIB_LDFLAGS)
AC_SUBST(MOZ_QT_CFLAGS)
AC_SUBST(MOZ_QT_LDFLAGS)
AC_SUBST(MOC)
if test "$MOZ_ENABLE_GTK" || test "$MOZ_ENABLE_QT" \
if test "$MOZ_ENABLE_GTK" \
|| test "$MOZ_ENABLE_XLIB" \
|| test "$MOZ_ENABLE_GTK2"
then

Просмотреть файл

@ -71,9 +71,6 @@ endif
ifdef MOZ_ENABLE_GTK2
DIRS += gtk
endif
ifdef MOZ_ENABLE_QT
DIRS += qt
endif
ifdef MOZ_ENABLE_XLIB
DIRS += xlib
endif

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,113 +0,0 @@
#
# 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>
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
LIBRARY_NAME = gfx_qt
EXPORT_LIBRARY = 1
GRE_MODULE = 1
REQUIRES = xpcom \
string \
widget \
view \
uconv \
pref \
util \
js \
mozcomps \
unicharutil \
intl \
locale \
$(NULL)
IS_COMPONENT = 1
MODULE_NAME = nsGfxQTModule
CPPSRCS = \
nsDeviceContextQT.cpp \
nsDeviceContextSpecFactoryQT.cpp \
nsDeviceContextSpecQT.cpp \
nsDrawingSurfaceQT.cpp \
nsFontMetricsQT.cpp \
nsGfxFactoryQT.cpp \
nsImageQT.cpp \
nsRegionQT.cpp \
nsRenderingContextQT.cpp \
nsScreenManagerQT.cpp \
nsScreenQT.cpp \
$(NULL)
# If not primary toolkit, install in secondary path
ifneq (qt,$(MOZ_GFX_TOOLKIT))
INACTIVE_COMPONENT = 1
endif
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_QT_CFLAGS)
CFLAGS += $(MOZ_QT_CFLAGS)
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
$(MOZ_JS_LIBS) \
-lgkgfx \
-lgfxshared_s \
$(XPCOM_LIBS) \
$(XPCOM_GLUE_LIBS) \
$(MOZ_QT_LDFLAGS) \
$(NSPR_LIBS) \
$(NULL)
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif
ifdef MOZ_ENABLE_POSTSCRIPT
DEFINES += -DUSE_POSTSCRIPT
endif
ifdef MOZ_ENABLE_XPRINT
DEFINES += -DUSE_XPRINT -DUSE_MOZILLA_TYPES
EXTRA_DSO_LDOPTS += $(MOZ_XPRINT_LDFLAGS)
endif
LOCAL_INCLUDES = \
-I$(srcdir)/. \
-I$(srcdir)/.. \
-I$(srcdir)/../shared \
$(NULL)

Просмотреть файл

@ -1,560 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
* Esben Mose Hansen <esben@despammed.com>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <math.h>
#include "nspr.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"
#include "nsDeviceContextQT.h"
#include "nsFontMetricsQT.h"
#include "nsFont.h"
#include "nsGfxCIID.h"
#include "nsRenderingContextQT.h"
#include "nsDeviceContextSpecQT.h"
#ifdef USE_POSTSCRIPT
#include "nsGfxPSCID.h"
#include "nsIDeviceContextPS.h"
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
#include "nsGfxXPrintCID.h"
#include "nsIDeviceContextXPrint.h"
#endif /* USE_XPRINT */
#include <qpaintdevicemetrics.h>
#include <qscrollbar.h>
#include <qpalette.h>
#include <qapplication.h>
#include <qstyle.h>
#include "nsIScreenManager.h"
#include "qtlog.h"
#define QCOLOR_TO_NS_RGB(c) \
((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
nscoord nsDeviceContextQT::mDpi = 96;
#define dmsg(level, item) traceMessage(level, item);
enum Trace_level { ENTER, EXIT };
void traceMessage(Trace_level level, const char* const item) {
char logBuf[1024] = ""; // let's trust that these messages won't get longer than this
static int indent = 0;
if (EXIT == level && indent>0) --indent;
for (int i=0; i<indent; i++) strcat(logBuf, " ");
strcat(logBuf, item);
PR_LOG(gQTLogModule, QT_BASIC, ("%s", logBuf));
if (ENTER == level) ++indent;
}
nsDeviceContextQT::nsDeviceContextQT()
: DeviceContextImpl()
{
dmsg(ENTER, "nsDeviceContextQT");
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mDepth = 0 ;
mNumCells = 0;
mWidthFloat = 0.0f;
mHeightFloat = 0.0f;
mWidth = -1;
mHeight = -1;
dmsg(EXIT, "nsDeviceContextQT");
}
nsDeviceContextQT::~nsDeviceContextQT()
{
dmsg(ENTER, "~nsDeviceContextQT");
nsresult rv;
nsCOMPtr<nsIPrefBranchInternal> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (pbi) {
pbi->RemoveObserver("browser.display.screen_resolution", this);
}
dmsg(EXIT, "~nsDeviceContextQT");
}
NS_IMETHODIMP nsDeviceContextQT::Init(nsNativeWidget aNativeWidget)
{
dmsg(ENTER, "Init");
PRBool bCleanUp = PR_FALSE;
QWidget *pWidget = nsnull;
mWidget = (QWidget*)aNativeWidget;
if (mWidget != nsnull)
pWidget = mWidget;
else {
pWidget = new QWidget();
bCleanUp = PR_TRUE;
}
QPaintDeviceMetrics qPaintMetrics(pWidget);
nsresult ignore;
nsCOMPtr<nsIScreenManager> sm(do_GetService("@mozilla.org/gfx/screenmanager;1",
&ignore));
if (sm) {
nsCOMPtr<nsIScreen> screen;
sm->GetPrimaryScreen(getter_AddRefs(screen));
if (screen) {
PRInt32 x,y,width,height,depth;
screen->GetAvailRect(&x,&y,&width,&height);
screen->GetPixelDepth(&depth);
mWidthFloat = float(width);
mHeightFloat = float(height);
mDepth = NS_STATIC_CAST(PRUint32,depth);
}
}
static int initialized = 0;
if (!initialized) {
initialized = 1;
// Set prefVal the value of the preference "browser.display.screen_resolution"
// or -1 if we can't get it.
// If it's negative, we pretend it's not set.
// If it's 0, it means force use of the operating system's logical resolution.
// If it's positive, we use it as the logical resolution
PRInt32 prefVal = -1;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
nsresult res = prefBranch->GetIntPref("browser.display.screen_resolution",
&prefVal);
if (NS_FAILED(res)) {
prefVal = -1;
}
nsCOMPtr<nsIPrefBranchInternal> pbi(do_QueryInterface(prefBranch));
pbi->AddObserver("browser.display.screen_resolution", this, PR_FALSE);
}
// Set OSVal to what the operating system thinks the logical resolution is.
PRInt32 OSVal = qPaintMetrics.logicalDpiX();
if (prefVal > 0) {
// If there's a valid pref value for the logical resolution,
// use it.
mDpi = prefVal;
}
else if (prefVal == 0 || OSVal > 96) {
// Either if the pref is 0 (force use of OS value) or the OS
// value is bigger than 96, use the OS value.
mDpi = OSVal;
}
else {
// if we couldn't get the pref or it's negative, and the OS
// value is under 96ppi, then use 96.
mDpi = 96;
}
}
SetDPI(mDpi);
#ifdef MOZ_LOGGING
static PRBool once = PR_TRUE;
if (once) {
PR_LOG(gQTLogModule, QT_BASIC, ("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n",
mDpi,mTwipsToPixels,mPixelsToTwips,mDepth));
once = PR_FALSE;
}
#endif
QScrollBar * sb = new QScrollBar(nsnull,nsnull);
if (sb) {
sb->setOrientation(QScrollBar::Vertical);
QSize size = sb->sizeHint();
mScrollbarWidth = size.width();
sb->setOrientation(QScrollBar::Horizontal);
size = sb->sizeHint();
mScrollbarHeight = size.height();
}
QRect rect = pWidget->frameGeometry();
mWindowBorderWidth = rect.width();
mWindowBorderHeight = rect.height();
DeviceContextImpl::CommonInit();
delete sb;
if (bCleanUp)
delete pWidget;
return NS_OK;
dmsg(EXIT, "Init");
}
NS_IMETHODIMP
nsDeviceContextQT::CreateRenderingContext(nsIRenderingContext *&aContext)
{
dmsg(ENTER, "CreateRenderingContext");
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceQT *surf;
QPaintDevice *pDev = nsnull;
if (mWidget)
pDev = (QPaintDevice*)mWidget;
// to call init for this, we need to have a valid nsDrawingSurfaceQT created
pContext = new nsRenderingContextQT();
if (nsnull != pContext) {
NS_ADDREF(pContext);
// create the nsDrawingSurfaceQT
surf = new nsDrawingSurfaceQT();
if (surf) {
QPainter *gc = new QPainter();
// init the nsDrawingSurfaceQT
if (pDev)
rv = surf->Init(pDev,gc);
else
rv = surf->Init(gc,10,10,0);
if (NS_OK == rv)
// Init the nsRenderingContextQT
rv = pContext->Init(this,surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv) {
NS_IF_RELEASE(pContext);
}
aContext = pContext;
dmsg(EXIT, "CreateRenderingContext");
return rv;
}
NS_IMETHODIMP
nsDeviceContextQT::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
dmsg(ENTER, "SupportsNativeWidgets");
//XXX it is very critical that this not lie!! MMP
// read the comments in the mac code for this
aSupportsWidgets = PR_TRUE;
dmsg(EXIT, "SupportsNativeWidgets");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::GetScrollBarDimensions(float &aWidth,
float &aHeight) const
{
dmsg(ENTER, "GetScrollBarDimensions");
float scale;
GetCanonicalPixelScale(scale);
aWidth = mScrollbarWidth * mPixelsToTwips * scale;
aHeight = mScrollbarHeight * mPixelsToTwips * scale;
dmsg(EXIT, "GetScrollBarDimensions");
return NS_OK;
}
NS_IMETHODIMP
nsDeviceContextQT::GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
{
dmsg(ENTER, "GetSystemFont");
nsresult status = NS_OK;
switch (anID) {
case eSystemFont_Caption:
case eSystemFont_Icon:
case eSystemFont_Menu:
case eSystemFont_MessageBox:
case eSystemFont_SmallCaption:
case eSystemFont_StatusBar:
case eSystemFont_Window: // css3
case eSystemFont_Document:
case eSystemFont_Workspace:
case eSystemFont_Desktop:
case eSystemFont_Info:
case eSystemFont_Dialog:
case eSystemFont_Button:
case eSystemFont_PullDownMenu:
case eSystemFont_List:
case eSystemFont_Field:
case eSystemFont_Tooltips:
case eSystemFont_Widget:
status = GetSystemFontInfo(aFont);
break;
}
dmsg(EXIT, "GetSystemFont");
return status;
}
NS_IMETHODIMP nsDeviceContextQT::ConvertPixel(nscolor aColor,
PRUint32 &aPixel)
{
dmsg(ENTER, "ConvertPixel");
QColor color(NS_GET_R(aColor),NS_GET_G(aColor),NS_GET_B(aColor));
aPixel = color.pixel();
dmsg(ENTER, "ConvertPixel");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::CheckFontExistence(const nsString& aFontName)
{
dmsg(ENTER, "CheckFontExistence");
dmsg(EXIT, "CheckFontExistence");
return nsFontMetricsQT::FamilyExists(aFontName);
}
NS_IMETHODIMP nsDeviceContextQT::GetDeviceSurfaceDimensions(PRInt32 &aWidth,
PRInt32 &aHeight)
{
dmsg(ENTER, "GetDeviceSurfaceDimensions");
if (-1 == mWidth)
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
if (-1 == mHeight)
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
aWidth = mWidth;
aHeight = mHeight;
dmsg(EXIT, "GetDeviceSurfaceDimensions");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::GetRect(nsRect &aRect)
{
dmsg(ENTER, "GetRect");
PRInt32 width,height;
nsresult rv;
rv = GetDeviceSurfaceDimensions(width,height);
aRect.x = 0;
aRect.y = 0;
aRect.width = width;
aRect.height = height;
dmsg(EXIT, "GetRect");
return rv;
}
NS_IMETHODIMP nsDeviceContextQT::GetClientRect(nsRect &aRect)
{
dmsg(ENTER, "GetClientRect");
dmsg(EXIT, "GetClientRect");
return GetRect(aRect);
}
NS_IMETHODIMP nsDeviceContextQT::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
nsresult rv;
PrintMethod method;
nsDeviceContextSpecQT *spec = NS_STATIC_CAST(nsDeviceContextSpecQT *, aDevice);
rv = spec->GetPrintMethod(method);
if (NS_FAILED(rv))
return rv;
#ifdef USE_XPRINT
if (method == pmXprint) { // XPRINT
static NS_DEFINE_CID(kCDeviceContextXp, NS_DEVICECONTEXTXP_CID);
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context.");
if (NS_FAILED(rv))
return rv;
rv = dcxp->SetSpec(aDevice);
if (NS_FAILED(rv))
return rv;
rv = dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
if (NS_FAILED(rv))
return rv;
rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
else
#endif /* USE_XPRINT */
#ifdef USE_POSTSCRIPT
if (method == pmPostScript) { // PostScript
// default/PS
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
// Create a Postscript device context
nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context.");
if (NS_FAILED(rv))
return rv;
rv = dcps->SetSpec(aDevice);
if (NS_FAILED(rv))
return rv;
rv = dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
if (NS_FAILED(rv))
return rv;
rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
#endif /* USE_POSTSCRIPT */
NS_WARNING("no print module created.");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsDeviceContextQT::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
{
dmsg(ENTER, "BeginDocument");
dmsg(EXIT, "BeginDocument");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::EndDocument(void)
{
dmsg(ENTER, "EndDocument");
dmsg(EXIT, "EndDocument");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::BeginPage(void)
{
dmsg(ENTER, "BeginPage");
dmsg(EXIT, "BeginPage");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::EndPage(void)
{
dmsg(ENTER, "EndPage");
dmsg(EXIT, "EndPage");
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextQT::GetDepth(PRUint32& aDepth)
{
dmsg(ENTER, "GetDepth");
aDepth = mDepth;
dmsg(EXIT, "GetDepth");
return NS_OK;
}
nsresult nsDeviceContextQT::SetDPI(PRInt32 aDpi)
{
dmsg(ENTER, "SetDPI");
mDpi = aDpi;
int pt2t = 72;
// make p2t a nice round number - this prevents rounding problems
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(pt2t)) / float(aDpi)));
mTwipsToPixels = 1.0f / mPixelsToTwips;
// XXX need to reflow all documents
dmsg(EXIT, "SetDPI");
return NS_OK;
}
NS_IMETHODIMP
nsDeviceContextQT::Observe(nsISupports* aSubject, const char* aTopic,
const PRUnichar* aData)
{
dmsg(ENTER, "observe");
if (nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) != 0) {
// Our local observer only handles pref changes.
// Forward everything else to our super class.
dmsg(EXIT, "observe");
return DeviceContextImpl::Observe(aSubject, aTopic, aData);
}
nsCOMPtr<nsIPrefBranch> prefBranch(do_QueryInterface(aSubject));
NS_ASSERTION(prefBranch,
"All pref change observer subjects implement nsIPrefBranch");
nsCAutoString prefName(NS_LossyConvertUCS2toASCII(aData).get());
if (prefName.Equals(NS_LITERAL_CSTRING("browser.display.screen_resolution"))) {
PRInt32 dpi;
nsresult rv = prefBranch->GetIntPref(prefName.get(), &dpi);
if (NS_SUCCEEDED(rv))
SetDPI(dpi);
}
dmsg(EXIT, "observe");
return NS_OK;
}
nsresult
nsDeviceContextQT::GetSystemFontInfo(nsFont* aFont) const
{
dmsg(ENTER, "GetSystemFontInfo");
nsresult status = NS_OK;
int rawWeight;
QFont theFont = QApplication::font();
QFontInfo theFontInfo(theFont);
aFont->style = NS_FONT_STYLE_NORMAL;
aFont->weight = NS_FONT_WEIGHT_NORMAL;
aFont->decorations = NS_FONT_DECORATION_NONE;
aFont->name.AssignWithConversion(theFontInfo.family().latin1());
if (theFontInfo.bold()) {
aFont->weight = NS_FONT_WEIGHT_BOLD;
}
rawWeight = theFontInfo.pointSize();
aFont->size = NSIntPixelsToTwips(rawWeight,mPixelsToTwips);
if (theFontInfo.italic()) {
aFont->style = NS_FONT_STYLE_ITALIC;
}
if (theFontInfo.underline()) {
aFont->decorations = NS_FONT_DECORATION_UNDERLINE;
}
dmsg(EXIT, "GetSystemFontInfo");
return (status);
}

Просмотреть файл

@ -1,119 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextQT_h___
#define nsDeviceContextQT_h___
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsIRenderingContext.h"
class QWidget;
class nsDeviceContextQT : public DeviceContextImpl
{
public:
nsDeviceContextQT();
virtual ~nsDeviceContextQT();
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIView *aView,nsIRenderingContext *&aContext)
{
return(DeviceContextImpl::CreateRenderingContext(aView,aContext));
}
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget,nsIRenderingContext *&aContext)
{
return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));
}
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetScrollBarDimensions(float &aWidth,float &aHeight) const;
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
NS_IMETHOD ConvertPixel(nscolor aColor,PRUint32 &aPixel);
NS_IMETHOD CheckFontExistence(const nsString &aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth,PRInt32 &aHeight);
NS_IMETHOD GetClientRect(nsRect &aRect);
NS_IMETHOD GetRect(nsRect &aRect);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
// Overridden DeviceContextImpl functions.
NS_IMETHOD GetDepth(PRUint32 &aDepth);
// Preferences observer
NS_DECL_NSIOBSERVER
nsresult SetDPI(PRInt32 dpi);
private:
PRUint32 mDepth;
PRBool mWriteable;
PRUint32 mNumCells;
PRInt16 mScrollbarHeight;
PRInt16 mScrollbarWidth;
PRInt16 mWindowBorderWidth;
PRInt16 mWindowBorderHeight;
QWidget *mWidget;
PRInt32 mWidth;
PRInt32 mHeight;
float mWidthFloat;
float mHeightFloat;
static nscoord mDpi;
nsresult GetSystemFontInfo(nsFont *aFont) const;
PRUint32 mID;
};
#endif /* nsDeviceContextQT_h___ */

Просмотреть файл

@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecFactoryQT.h"
#include "nsDeviceContextSpecQT.h"
#include "nsGfxCIID.h"
#include "plstr.h"
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryQT, nsIDeviceContextSpecFactory)
nsDeviceContextSpecFactoryQT::nsDeviceContextSpecFactoryQT()
{
}
nsDeviceContextSpecFactoryQT::~nsDeviceContextSpecFactoryQT()
{
}
NS_IMETHODIMP nsDeviceContextSpecFactoryQT::Init(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecFactoryQT::CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecQT *)devSpec.get())->Init(aPrintSettings);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);
}
}
return rv;
}

Просмотреть файл

@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecFactoryQT_h___
#define nsDeviceContextSpecFactoryQT_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryQT : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryQT();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
protected:
virtual ~nsDeviceContextSpecFactoryQT();
};
#endif /* !nsDeviceContextSpecFactoryQT_h___ */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,130 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecQT_h___
#define nsDeviceContextSpecQT_h___
#include "nsCOMPtr.h"
#include "nsIDeviceContextSpec.h"
#include "nsIPrintSettings.h"
#include "nsIPrintOptions.h"
#include "nsVoidArray.h"
#include <limits.h>
#ifdef USE_POSTSCRIPT
#include "nsIDeviceContextSpecPS.h"
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
#include "nsIDeviceContextSpecXPrint.h"
#endif /* USE_XPRINT */
#define NS_PORTRAIT 0
#define NS_LANDSCAPE 1
typedef enum
{
pmInvalid = 0,
pmXprint,
pmPostScript
} PrintMethod;
class nsDeviceContextSpecQT : public nsIDeviceContextSpec
#ifdef USE_POSTSCRIPT
, public nsIDeviceContextSpecPS
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXp
#endif /* USE_XPRINT */
{
public:
nsDeviceContextSpecQT();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIPrintSettings* aPS);
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
NS_IMETHOD GetPrinterName ( const char **aPrinter );
NS_IMETHOD GetCopies ( int &aCopies );
NS_IMETHOD GetFirstPageFirst(PRBool &aFpf);
NS_IMETHOD GetGrayscale(PRBool &aGrayscale);
NS_IMETHOD GetTopMargin(float &value);
NS_IMETHOD GetBottomMargin(float &value);
NS_IMETHOD GetLeftMargin(float &value);
NS_IMETHOD GetRightMargin(float &value);
NS_IMETHOD GetCommand(const char **aCommand);
NS_IMETHOD GetPath (const char **aPath);
NS_IMETHOD GetLandscape (PRBool &aLandscape);
NS_IMETHOD GetUserCancelled(PRBool &aCancel);
NS_IMETHOD GetPrintMethod(PrintMethod &aMethod);
static nsresult GetPrintMethod(const char *aPrinter, PrintMethod &aMethod);
NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD GetPaperName(const char **aPaperName);
virtual ~nsDeviceContextSpecQT();
protected:
nsCOMPtr<nsIPrintSettings> mPrintSettings;
PRBool mToPrinter; /* If PR_TRUE, print to printer */
PRBool mFpf; /* If PR_TRUE, first page first */
PRBool mGrayscale; /* If PR_TRUE, print grayscale */
int mOrientation; /* Orientation e.g. Portrait */
char mCommand[PATH_MAX]; /* Print command e.g., lpr */
char mPath[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */
char mPrinter[256]; /* Printer name */
char mPaperName[256]; /* Printer name */
int mCopies; /* number of copies */
PRBool mCancel; /* If PR_TRUE, user cancelled */
float mLeft; /* left margin */
float mRight; /* right margin */
float mTop; /* top margin */
float mBottom; /* bottom margin */
};
//-------------------------------------------------------------------------
// Printer Enumerator
//-------------------------------------------------------------------------
class nsPrinterEnumeratorQT : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorQT();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
};
#endif /* !nsDeviceContextSpecQT_h___ */

Просмотреть файл

@ -1,262 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDrawingSurfaceQT.h"
#include "nsRenderingContextQT.h"
#include <qpaintdevicemetrics.h>
#include "qtlog.h"
#ifdef DEBUG
PRUint32 gDSCount = 0;
PRUint32 gDSID = 0;
#endif
NS_IMPL_ISUPPORTS2(nsDrawingSurfaceQT, nsIDrawingSurface, nsIDrawingSurfaceQT)
nsDrawingSurfaceQT::nsDrawingSurfaceQT()
{
#ifdef DEBUG
gDSCount++;
mID = gDSID++;
PR_LOG(gQTLogModule, QT_BASIC,
("nsDrawingSurfaceQT CTOR (%p) ID: %d, Count: %d\n",
this, mID, gDSCount));
#endif
mPaintDevice = nsnull;
mPixmap = nsnull;
mGC = nsnull;
mDepth = -1;
mWidth = 0;
mHeight = 0;
mFlags = 0;
mLockWidth = 0;
mLockHeight = 0;
mLockFlags = 0;
mLocked = PR_FALSE;
// I have no idea how to compute these values.
// FIXME
mPixFormat.mRedMask = 0;
mPixFormat.mGreenMask = 0;
mPixFormat.mBlueMask = 0;
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedShift = 0;
mPixFormat.mGreenShift = 0;
mPixFormat.mBlueShift = 0;
mPixFormat.mAlphaShift = 0;
}
nsDrawingSurfaceQT::~nsDrawingSurfaceQT()
{
#ifdef DEBUG
gDSCount--;
PR_LOG(gQTLogModule, QT_BASIC,
("nsDrawingSurfaceQT DTOR (%p) ID: %d, Count: %d\n",
this, mID, gDSCount));
#endif
if (mGC && mGC->isActive()) {
mGC->end();
}
if (mGC) {
delete mGC;
mGC = nsnull;
}
if (mPixmap) {
delete mPixmap;
mPixmap = nsnull;
}
if (mPaintDevice) {
if (mIsOffscreen && !mPaintDevice->paintingActive())
delete mPaintDevice;
mPaintDevice = nsnull;
}
}
NS_IMETHODIMP nsDrawingSurfaceQT::Lock(PRInt32 aX,PRInt32 aY,
PRUint32 aWidth,PRUint32 aHeight,
void **aBits,PRInt32 *aStride,
PRInt32 *aWidthBytes,PRUint32 aFlags)
{
if (mLocked) {
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
if (!mPixmap) {
NS_ASSERTION(0, "NULL pixmap in lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
if (mImage.isNull())
mImage = mPixmap->convertToImage();
*aBits = mImage.bits();
*aStride = mImage.bytesPerLine();
*aWidthBytes = mImage.bytesPerLine();
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQT::Unlock(void)
{
if (!mLocked) {
NS_ASSERTION(0,"attempting to unlock an DrawingSurface that isn't locked");
return NS_ERROR_FAILURE;
}
if (!mPixmap) {
NS_ASSERTION(0, "NULL pixmap in unlock attempt");
return NS_ERROR_FAILURE;
}
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY)) {
mGC->drawPixmap(0,0,*mPixmap,mLockY,mLockY,mLockWidth,mLockHeight);
}
mLocked = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQT::GetDimensions(PRUint32 *aWidth,
PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQT::IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQT::IsPixelAddressable(PRBool *aAddressable)
{
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQT::GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQT::Init(QPaintDevice *aPaintDevice,
QPainter *aGC)
{
PR_LOG(gQTLogModule, QT_BASIC, ("[%p] nsDrawingSurface::Init\n", this));
NS_ASSERTION(aPaintDevice, "need paint dev.");
QPaintDeviceMetrics qMetrics(aPaintDevice);
mGC = aGC;
mPaintDevice = aPaintDevice;
mWidth = qMetrics.width();
mHeight = qMetrics.height();
mDepth = qMetrics.depth();
mIsOffscreen = PR_FALSE;
if (!mImage.isNull())
mImage.reset();
return CommonInit();
}
NS_IMETHODIMP nsDrawingSurfaceQT::Init(QPainter *aGC,
PRUint32 aWidth,
PRUint32 aHeight,
PRUint32 aFlags)
{
PR_LOG(gQTLogModule, QT_BASIC, ("[%p] nsDrawingSurface::Init\n", this));
if (nsnull == aGC || aWidth <= 0 || aHeight <= 0) {
return NS_ERROR_FAILURE;
}
mGC = aGC;
mWidth = aWidth;
mHeight = aHeight;
mFlags = aFlags;
mPixmap = new QPixmap(mWidth, mHeight, mDepth);
mPaintDevice = mPixmap;
NS_ASSERTION(mPaintDevice, "this better not fail");
mIsOffscreen = PR_TRUE;
if (!mImage.isNull())
mImage.reset();
return CommonInit();
}
NS_IMETHODIMP nsDrawingSurfaceQT::CommonInit()
{
PR_LOG(gQTLogModule, QT_BASIC, ("[%p] nsDrawingSurface::CommonInit\n", this));
if (nsnull == mGC || nsnull == mPaintDevice) {
return NS_ERROR_FAILURE;
}
if (mGC->isActive()) {
mGC->end();
}
mGC->begin(mPaintDevice);
return NS_OK;
}
QPainter* nsDrawingSurfaceQT::GetGC()
{
return mGC;
}
QPaintDevice* nsDrawingSurfaceQT::GetPaintDevice()
{
PR_LOG(gQTLogModule, QT_BASIC, ("[%p] nsDrawingSurfaceQt::GetPaintDevice\n", this));
NS_ASSERTION(mPaintDevice, "No paint device! Something will probably crash soon.");
return mPaintDevice;
}

Просмотреть файл

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDrawingSurfaceQT_h___
#define nsDrawingSurfaceQT_h___
#include "nsIDrawingSurface.h"
#include "nsIDrawingSurfaceQT.h"
#include <qpainter.h>
#include <qimage.h>
class QPixmap;
class nsDrawingSurfaceQT : public nsIDrawingSurface,
public nsIDrawingSurfaceQT
{
public:
nsDrawingSurfaceQT();
virtual ~nsDrawingSurfaceQT();
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX,PRInt32 aY,
PRUint32 aWidth,PRUint32 aHeight,
void **aBits,PRInt32 *aStride,
PRInt32 *aWidthBytes,PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
//nsIDrawingSurfaceQT interface
NS_IMETHOD Init(QPaintDevice * aPaintDevice, QPainter *aGC);
NS_IMETHOD Init(QPainter *aGC,PRUint32 aWidth,PRUint32 aHeight,
PRUint32 aFlags);
// utility functions.
PRInt32 GetDepth() { return mDepth; }
QPainter *GetGC(void);
QPaintDevice *GetPaintDevice(void);
protected:
NS_IMETHOD CommonInit();
private:
/* general */
QPaintDevice *mPaintDevice;
QPixmap *mPixmap;
QPainter *mGC;
int mDepth;
nsPixelFormat mPixFormat;
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
/* for locks */
QImage mImage;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
PRUint32 mID;
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,234 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <jcgriggs@sympatico.ca>
* Jean Claude Batista <jcb@macadamian.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFontMetricsQT_h__
#define nsFontMetricsQT_h__
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsICharRepresentable.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetConverterManager2.h"
#include "nsVoidArray.h"
#include <qintdict.h>
#include <qfontmetrics.h>
class nsFont;
class nsString;
class nsRenderingContextQT;
class nsDrawingSurfaceQT;
class nsFontMetricsQT;
class nsFontQTUserDefined;
class QString;
class QFont;
class QFontInfo;
class QFontDatabase;
#undef FONT_HAS_GLYPH
#define FONT_HAS_GLYPH(map,char) IS_REPRESENTABLE(map,char)
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
class nsFontQT
{
public:
nsFontQT();
nsFontQT(QFont *aQFont);
virtual ~nsFontQT();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
virtual QFont *GetQFont(void);
virtual PRUint32 *GetCharSetMap();
PRBool IsUnicodeFont();
inline int HasChar(PRUnichar aChar)
{
return(mFontMetrics && mFontMetrics->inFont(QChar(aChar)));
};
virtual int SupportsChar(PRUnichar aChar);
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual int DrawString(nsRenderingContextQT* aContext,
nsDrawingSurfaceQT* aSurface, nscoord aX,
nscoord aY, const PRUnichar* aString,
PRUint32 aLength) = 0;
#ifdef MOZ_MATHML
// bounding metrics for a string
// remember returned values are not in app units
// - to emulate GetWidth () above
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif
QFont* mFont;
QFontInfo* mFontInfo;
QFontMetrics* mFontMetrics;
nsFontCharSetInfo* mCharSetInfo;
#ifdef DEBUG
private:
PRUint32 mID;
#endif
};
class nsFontMetricsQT : public nsIFontMetrics
{
public:
nsFontMetricsQT();
virtual ~nsFontMetricsQT();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext* aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetEmHeight(nscoord &aHeight);
NS_IMETHOD GetEmAscent(nscoord &aAscent);
NS_IMETHOD GetEmDescent(nscoord &aDescent);
NS_IMETHOD GetMaxHeight(nscoord &aHeight);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
nsFontQT* FindFont(PRUnichar aChar);
nsFontQT* FindUserDefinedFont(PRUnichar aChar);
nsFontQT* FindLangGroupPrefFont(nsIAtom *aLangGroup,PRUnichar aChar);
nsFontQT* FindLocalFont(PRUnichar aChar);
nsFontQT* FindGenericFont(PRUnichar aChar);
nsFontQT* FindGlobalFont(PRUnichar aChar);
nsFontQT* FindSubstituteFont(PRUnichar aChar);
nsFontQT* LookUpFontPref(nsCAutoString &aName,PRUnichar aChar);
nsFontQT* LoadFont(QString &aName,PRUnichar aChar);
nsFontQT* LoadFont(QString &aName,const QString &aCharSet,
PRUnichar aChar);
QFont* LoadQFont(QString &aName);
static nsresult FamilyExists(const nsString& aFontName);
nsFontQT **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsFontQT *mSubstituteFont;
nsFontQTUserDefined *mUserDefinedFont;
nsCOMPtr<nsIAtom> mLangGroup;
nsCStringArray mFonts;
PRUint16 mFontsIndex;
nsVoidArray mFontIsGeneric;
nsCAutoString mDefaultFont;
nsCString *mGeneric;
nsCAutoString mUserDefined;
PRUint8 mTriedAllGenerics;
PRUint8 mIsUserDefined;
static QFontDatabase *GetQFontDB();
protected:
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
nsFontQT *mWesternFont;
QString *mQStyle;
PRUint16 mPixelSize;
PRUint16 mWeight;
QIntDict<char> mCharSubst;
nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
nscoord mEmDescent;
nscoord mMaxHeight;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mAveCharWidth;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
nscoord mSpaceWidth;
static QFontDatabase *mQFontDB;
#ifdef DEBUG
private:
PRUint32 mID;
#endif
};
class nsFontEnumeratorQT : public nsIFontEnumerator
{
public:
nsFontEnumeratorQT();
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTENUMERATOR
};
#endif

Просмотреть файл

@ -1,175 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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
* Christopher Blizzard.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsBlender.h"
#include "nsFontMetricsQT.h"
#include "nsRenderingContextQT.h"
#include "nsDeviceContextSpecQT.h"
#include "nsDeviceContextSpecFactoryQT.h"
#include "nsScreenManagerQT.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextQT.h"
#include "nsImageQT.h"
#include "nsFontList.h"
#include "nsPrintSession.h"
#include "gfxImageFrame.h"
#include "qtlog.h"
// Initialize qt logging
PRLogModuleInfo *gQTLogModule = PR_NewLogModule("QtGfx");
// objects that just require generic constructors
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorQT)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerQT)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
// our custom constructors
static nsresult nsScriptableRegionConstructor(nsISupports *aOuter,REFNSIID aIID,void **aResult)
{
nsresult rv;
nsIScriptableRegion *inst;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
// create an nsRegionQT and get the scriptable region from it
nsCOMPtr <nsIRegion> rgn;
NS_NEWXPCOM(rgn, nsRegionQT);
if (rgn != nsnull) {
nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
inst = scriptableRgn;
}
if (NULL == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
return rv;
}
static const nsModuleComponentInfo components[] =
{
{ "Qt Font Metrics",
NS_FONT_METRICS_CID,
"@mozilla.org/gfx/fontmetrics;1",
nsFontMetricsQTConstructor },
{ "Qt Device Context",
NS_DEVICE_CONTEXT_CID,
"@mozilla.org/gfx/devicecontext;1",
nsDeviceContextQTConstructor },
{ "Qt Rendering Context",
NS_RENDERING_CONTEXT_CID,
"@mozilla.org/gfx/renderingcontext;1",
nsRenderingContextQTConstructor },
{ "Qt Image",
NS_IMAGE_CID,
"@mozilla.org/gfx/image;1",
nsImageQTConstructor },
{ "Qt Region",
NS_REGION_CID,
"@mozilla.org/gfx/region/qt;1",
nsRegionQTConstructor },
{ "Scriptable Region",
NS_SCRIPTABLE_REGION_CID,
"@mozilla.org/gfx/region;1",
nsScriptableRegionConstructor },
{ "Blender",
NS_BLENDER_CID,
"@mozilla.org/gfx/blender;1",
nsBlenderConstructor },
{ "Qt Device Context Spec",
NS_DEVICE_CONTEXT_SPEC_CID,
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecQTConstructor },
{ "Qt Device Context Spec Factory",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
"@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryQTConstructor },
{ "Qt Font Enumerator",
NS_FONT_ENUMERATOR_CID,
"@mozilla.org/gfx/fontenumerator;1",
nsFontEnumeratorQTConstructor },
{ "Font List",
NS_FONTLIST_CID,
// "@mozilla.org/gfx/fontlist;1"
NS_FONTLIST_CONTRACTID,
nsFontListConstructor },
{ "Qt Screen Manager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerQTConstructor },
{ "shared image frame",
GFX_IMAGEFRAME_CID,
"@mozilla.org/gfx/image/frame;2",
gfxImageFrameConstructor, },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor }
};
NS_IMPL_NSGETMODULE(nsGfxQTModule, components)

Просмотреть файл

@ -1,86 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDrawingSurfaceQT_h___
#define nsIDrawingSurfaceQT_h___
#include "nsIDrawingSurface.h"
class QPainter;
class QPaintDevice;
// windows specific drawing surface method set
#define NS_IDRAWING_SURFACE_QT_IID \
{ 0x1ed958b0, 0xcab6, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurfaceQT : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_QT_IID)
/**
* Initialize a drawing surface using a QPainter and QPaintDevice.
* these are "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aGC QPainter to initialize drawing surface with
* @param aPaintDevice QPixmap to initialize drawing surface with
* @return error status
**/
NS_IMETHOD Init(QPaintDevice *aPaintDevice, QPainter *aGC) = 0;
/**
* Initialize an offscreen drawing surface using a
* QPainter. aGC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aGC. if width or height are less than zero, aGC will
* be created with no offscreen bitmap installed.
* @param aGC QPainter to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
NS_IMETHOD Init(QPainter * aGC,PRUint32 aWidth,PRUint32 aHeight,
PRUint32 aFlags) = 0;
};
#endif // nsIDrawingSurfaceQT_h___

Просмотреть файл

@ -1,480 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsImageQT.h"
#include "nsRenderingContextQT.h"
#include "nspr.h"
#include "qtlog.h"
#define IsFlagSet(a,b) ((a) & (b))
#ifdef DEBUG
PRUint32 gImageCount = 0;
PRUint32 gImageID = 0;
#endif
NS_IMPL_ISUPPORTS1(nsImageQT, nsIImage)
//------------------------------------------------------------
nsImageQT::nsImageQT()
: mImageBits(nsnull)
, mWidth(0)
, mHeight(0)
, mDepth(0)
, mRequestDepth(0)
, mAlphaBits(nsnull)
, mAlphaPixmap(nsnull)
, mImagePixmap(nsnull)
, mAlphaDepth(0)
, mRowBytes(0)
, mSizeImage(0)
, mAlphaRowBytes(0)
, mNumBytesPixel(0)
, mDecodedX1(0)
, mDecodedY1(0)
, mDecodedX2(0)
, mDecodedY2(0)
{
#ifdef DEBUG
gImageCount++;
mID = gImageID++;
PR_LOG(gQTLogModule, QT_BASIC,
("nsImageQT CTOR (%p) ID: %d, Count: %d\n", this, mID, gImageCount));
#endif
}
//------------------------------------------------------------
nsImageQT::~nsImageQT()
{
#ifdef DEBUG
gImageCount--;
PR_LOG(gQTLogModule, QT_BASIC,
("nsImageQT DTOR (%p) ID: %d, Count: %d\n", this, mID, gImageCount));
#endif
if (nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
delete mAlphaPixmap;
}
if (nsnull != mImagePixmap) {
delete mImagePixmap;
}
}
//------------------------------------------------------------
nsresult nsImageQT::Init(PRInt32 aWidth,PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements)
{
// gfxImageFrame forces only one nsImageQT::Init
if (aWidth == 0 || aHeight == 0) {
return NS_ERROR_FAILURE;
}
// mImagePixmap gets created once per unique image bits in Draw()
// ImageUpdated(nsImageUpdateFlags_kBitsChanged) can cause the
// image bits to change and mImagePixmap will be unrefed and nulled.
if (nsnull != mImagePixmap) {
delete mImagePixmap;
mImagePixmap = nsnull;
}
if (32 == aDepth) {
mNumBytesPixel = 4;
mDepth = aDepth;
mRequestDepth = mDepth;
}
else if (24 == aDepth) {
mNumBytesPixel = 4;
mDepth = 32;
mRequestDepth = aDepth;
}
else {
NS_NOTREACHED("unexpected image depth");
return NS_ERROR_UNEXPECTED;
}
mWidth = aWidth;
mHeight = aHeight;
// create the memory for the image
ComputeMetrics();
mImageBits = (PRUint8*)new PRUint8[mSizeImage];
switch (aMaskRequirements) {
case nsMaskRequirements_kNeeds1Bit:
mAlphaRowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
break;
case nsMaskRequirements_kNeeds8Bit:
mAlphaRowBytes = aWidth;
mAlphaDepth = 8;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
break;
}
PR_LOG(gQTLogModule, QT_BASIC, ("nsImageQT::Init succeeded"));
return NS_OK;
}
//------------------------------------------------------------
void nsImageQT::ComputeMetrics()
{
mRowBytes = CalcBytesSpan(mWidth);
mSizeImage = mRowBytes * mHeight;
}
PRInt32 nsImageQT::GetHeight()
{
return mHeight;
}
PRInt32 nsImageQT::GetWidth()
{
return mWidth;
}
PRUint8 *nsImageQT::GetBits()
{
return mImageBits;
}
void *nsImageQT::GetBitInfo()
{
return nsnull;
}
PRInt32 nsImageQT::GetLineStride()
{
return mRowBytes;
}
nsColorMap *nsImageQT::GetColorMap()
{
return nsnull;
}
PRUint8 *nsImageQT::GetAlphaBits()
{
return mAlphaBits;
}
PRInt32 nsImageQT::GetAlphaLineStride()
{
return mAlphaRowBytes;
}
//------------------------------------------------------------
PRInt32 nsImageQT::CalcBytesSpan(PRUint32 aWidth)
{
PRInt32 spanbytes;
spanbytes = (aWidth * mDepth) >> 5;
if (((PRUint32)aWidth * mDepth) & 0x1F) {
spanbytes++;
}
spanbytes <<= 2;
return(spanbytes);
}
//------------------------------------------------------------
// set up the palette to the passed in color array, RGB only in this array
void nsImageQT::ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags,nsRect *aUpdateRect)
{
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged,aFlags)) {
if (nsnull != mAlphaPixmap) {
delete mAlphaPixmap;
mAlphaPixmap = nsnull;
}
// mImagePixmap gets created once per unique image bits in Draw()
// ImageUpdated(nsImageUpdateFlags_kBitsChanged) can cause the
// image bits to change and mImagePixmap will be unrefed and nulled.
if (nsnull != mImagePixmap) {
delete mImagePixmap;
mImagePixmap = nsnull;
}
}
if (aUpdateRect->YMost() > mDecodedY2)
mDecodedY2 = aUpdateRect->YMost();
if (aUpdateRect->XMost() > mDecodedX2)
mDecodedX2 = aUpdateRect->XMost();
}
// Draw the bitmap, this method has a source and destination coordinates
NS_IMETHODIMP nsImageQT::Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY,
PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY,
PRInt32 aDWidth, PRInt32 aDHeight)
{
if (nsnull == aSurface) {
return NS_ERROR_FAILURE;
}
// Render unique image bits onto an off screen pixmap only once
// The image bits can change as a result of ImageUpdated() - for
// example: animated GIFs.
if (nsnull == mImagePixmap) {
CreateImagePixmap();
}
if (nsnull == mImagePixmap)
return NS_ERROR_FAILURE;
// Copy data from mImageBits to the drawing surface specified by aSurface.
// We only want a subset of the data in mImageBits, and the data might
// need to be scaled.
nsDrawingSurfaceQT *drawing = (nsDrawingSurfaceQT*)aSurface;
drawing->GetGC()->drawImage(aDX,aDY,*mImagePixmap,aSX,aSY,
aSWidth,aSHeight);
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
NS_IMETHODIMP nsImageQT::Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
if (nsnull == aSurface) {
return NS_ERROR_FAILURE;
}
// XXX kipp: this is temporary code until we eliminate the
// width/height arguments from the draw method.
if ((aWidth != mWidth) || (aHeight != mHeight)) {
aWidth = mWidth;
aHeight = mHeight;
}
nsDrawingSurfaceQT *drawing = (nsDrawingSurfaceQT*)aSurface;
// Render unique image bits onto an off screen pixmap only once
// The image bits can change as a result of ImageUpdated() - for
// example: animated GIFs.
if (nsnull == mImagePixmap) {
CreateImagePixmap();
}
if (nsnull == mImagePixmap)
return NS_ERROR_FAILURE;
drawing->GetGC()->drawImage(aX,aY,*mImagePixmap,0,0,aWidth,aHeight);
return NS_OK;
}
void nsImageQT::CreateOffscreenPixmap(PRInt32 aWidth,PRInt32 aHeight)
{
if (mImagePixmap)
delete mImagePixmap;
mImagePixmap = new QImage(aWidth,aHeight,mDepth);
if (mImagePixmap) {
mImagePixmap->setAlphaBuffer(PR_TRUE);
mImagePixmap->fill(0);
}
}
void nsImageQT::CreateImagePixmap()
{
mImagePixmap = new QImage(mWidth,mHeight,mDepth);
if (mImagePixmap) {
PRInt8 bytesPerPixel = mRequestDepth / 8;
PRUint8 *alpha = mAlphaBits;
PRUint8 *image = mImageBits;
PRUint8 *imagePtr;
PRUint32 pixel;
PRInt32 i,j;
QRgb *line;
mImagePixmap->setAlphaBuffer(PR_TRUE);
for (i = 0; i < mHeight; i++) {
line = (QRgb*)mImagePixmap->scanLine(i);
imagePtr = image;
for (j = 0; j < mWidth; j++) {
pixel = 0xFF000000 | *(imagePtr + bytesPerPixel - 1)
| (*(imagePtr + bytesPerPixel - 2) << 8)
| (*(imagePtr + bytesPerPixel - 3) << 16);
if (mAlphaBits) {
if (mAlphaDepth == 1) {
if (!(alpha[j / 8] & (1 << (7 - (j % 8))))) {
pixel &= 0x00FFFFFF;
}
}
else {
pixel &= (alpha[j] << 24);
}
}
else if (bytesPerPixel == 4)
pixel &= (*(imagePtr + bytesPerPixel - 4) << 24);
line[j] = pixel;
imagePtr += bytesPerPixel;
}
alpha += mAlphaRowBytes;
image += mRowBytes;
}
}
}
NS_IMETHODIMP nsImageQT::DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
nsRect &aSrcRect, nsRect &aTileRect)
{
nsDrawingSurfaceQT *drawing = (nsDrawingSurfaceQT*)aSurface;
if (aTileRect.width <= 0 || aTileRect.height <= 0) {
NS_ASSERTION(aTileRect.width > 0 && aTileRect.height > 0,
"Error: image has 0 width or height!");
return NS_OK;
}
if (drawing->GetDepth() == 8 || mAlphaDepth == 8) {
PRInt32 aY0 = aTileRect.y, aX0 = aTileRect.x;
PRInt32 aY1 = aTileRect.y + aTileRect.height;
PRInt32 aX1 = aTileRect.x + aTileRect.width;
for (PRInt32 y = aY0; y < aY1; y += aSrcRect.height)
for (PRInt32 x = aX0; x < aX1; x += aSrcRect.width)
Draw(aContext,aSurface,x,y, PR_MIN(aSrcRect.width, aX1 - x),
PR_MIN(aSrcRect.height, aY1 - y));
return NS_OK;
}
// Render unique image bits onto an off screen pixmap only once
// The image bits can change as a result of ImageUpdated() - for
// example: animated GIFs.
if (nsnull == mImagePixmap) {
CreateImagePixmap();
}
if (nsnull == mImagePixmap)
return NS_ERROR_FAILURE;
QPixmap qPmap;
qPmap.convertFromImage(*mImagePixmap);
drawing->GetGC()->drawTiledPixmap(aTileRect.x,aTileRect.y,
aTileRect.width,aTileRect.height,
qPmap,aSrcRect.x,aSrcRect.y);
return NS_OK;
}
NS_IMETHODIMP nsImageQT::DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &aTileRect)
{
nsRect srcRect(aSXOffset,aSYOffset,mWidth,mHeight);
nsRect dstRect(aTileRect);
return DrawTile(aContext, aSurface, srcRect, dstRect);
}
//------------------------------------------------------------
nsresult nsImageQT::Optimize(nsIDeviceContext* aContext)
{
return NS_OK;
}
PRInt32 nsImageQT::GetBytesPix()
{
return mNumBytesPixel;
}
//------------------------------------------------------------
// lock the image pixels. Implement this if you need it.
NS_IMETHODIMP
nsImageQT::LockImagePixels(PRBool aMaskPixels)
{
return NS_OK;
}
//------------------------------------------------------------
// unlock the image pixels. Implement this if you need it.
NS_IMETHODIMP
nsImageQT::UnlockImagePixels(PRBool aMaskPixels)
{
return NS_OK;
}
NS_IMETHODIMP nsImageQT::DrawToImage(nsIImage *aDstImage,
nscoord aDX,nscoord aDY,
nscoord aDWidth,nscoord aDHeight)
{
nsImageQT *dest = NS_STATIC_CAST(nsImageQT*,aDstImage);
if (!dest)
return NS_ERROR_FAILURE;
if (!mImagePixmap)
CreateImagePixmap();
if (!mImagePixmap)
return NS_ERROR_FAILURE;
if (!dest->mImagePixmap)
dest->CreateOffscreenPixmap(dest->mWidth,dest->mHeight);
if (!dest->mImagePixmap)
return NS_ERROR_FAILURE;
bitBlt(dest->mImagePixmap,aDX,aDY,mImagePixmap,0,0,mWidth,mHeight,
Qt::CopyROP);
return NS_OK;
}

Просмотреть файл

@ -1,157 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsImageQT_h___
#define nsImageQT_h___
#include "nsIImage.h"
#include <qpixmap.h>
#include <qimage.h>
#undef Bool
class nsImageQT : public nsIImage
{
public:
nsImageQT();
virtual ~nsImageQT();
NS_DECL_ISUPPORTS
/**
* @see nsIImage.h
*/
virtual PRInt32 GetBytesPix();
virtual PRBool GetIsRowOrderTopToBottom() {return PR_TRUE;}
virtual PRInt32 GetHeight();
virtual PRInt32 GetWidth();
virtual PRUint8 *GetBits();
virtual void *GetBitInfo();
virtual PRInt32 GetLineStride();
virtual nsColorMap *GetColorMap();
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY,
PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY,
PRInt32 aDWidth, PRInt32 aDHeight);
void CreateOffscreenPixmap(PRInt32 aWidth,PRInt32 aHeight);
NS_IMETHOD DrawToImage(nsIImage *aDstImage,nscoord aDX,nscoord aDY,
nscoord aDWidth,nscoord aDHeight);
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
nsRect &aSrcRect,
nsRect &aTileRect);
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &aTileRect);
virtual void ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags,nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth,PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
virtual nsresult Optimize(nsIDeviceContext *aContext);
virtual PRBool GetHasAlphaMask() {return mAlphaBits != nsnull;}
virtual PRUint8 *GetAlphaBits();
virtual PRInt32 GetAlphaLineStride();
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
PRInt32 CalcBytesSpan(PRUint32 aWidth);
/**
* Get the alpha depth for the image mask
* @update - lordpixel 2001/05/16
* @return the alpha mask depth for the image, ie, 0, 1 or 8
*/
virtual PRInt8 GetAlphaDepth() {return(mAlphaDepth);}
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
private:
/**
* Calculate the amount of memory needed for the initialization of the
* image
*/
void ComputeMetrics();
void ComputePaletteSize(PRIntn nBitCount);
void CreateImagePixmap();
private:
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // actual bits per pixel
PRInt32 mRequestDepth; // requested bits per pixel
PRInt32 mRowBytes;
PRUint8 *mImageBits;
PRInt32 mSizeImage;
PRInt8 mNumBytesPixel;
PRInt32 mDecodedX1; //Keeps track of what part of image
PRInt32 mDecodedY1; // has been decoded.
PRInt32 mDecodedX2;
PRInt32 mDecodedY2;
// alpha layer members
PRUint8 *mAlphaBits;
QImage *mAlphaPixmap;
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mAlphaRowBytes; // alpha bytes per row
QImage *mImagePixmap;
PRUint32 mID;
};
#endif

Просмотреть файл

@ -1,263 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsRegionQT.h"
#include "prmem.h"
#include "nsRenderingContextQT.h"
#include <qregion.h>
#include "qtlog.h"
#ifdef DEBUG
PRUint32 gRegionCount = 0;
PRUint32 gRegionID = 0;
#endif
nsRegionQT::nsRegionQT() : mRegion()
{
#ifdef DEBUG
gRegionCount++;
mID = gRegionID++;
PR_LOG(gQTLogModule, QT_BASIC,
("nsRegionQT CTOR (%p) ID: %d, Count: %d\n", this, mID, gRegionCount));
#endif
}
nsRegionQT::~nsRegionQT()
{
#ifdef DEBUG
gRegionCount--;
PR_LOG(gQTLogModule, QT_BASIC,
("nsRegionQT DTOR (%p) ID: %d, Count: %d\n", this, mID, gRegionCount));
#endif
}
NS_IMPL_ISUPPORTS1(nsRegionQT, nsIRegion)
nsresult nsRegionQT::Init(void)
{
SetRegionEmpty();
return NS_OK;
}
void nsRegionQT::SetTo(const nsIRegion &aRegion)
{
nsRegionQT *pRegion = (nsRegionQT*)&aRegion;
SetRegionEmpty();
SetTo(pRegion);
}
void nsRegionQT::SetTo(const nsRegionQT *aRegion)
{
SetRegionEmpty();
mRegion = aRegion->mRegion;
}
void nsRegionQT::SetTo(PRInt32 aX,PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight)
{
SetRegionEmpty();
QRegion nRegion(aX, aY, aWidth, aHeight);
mRegion = nRegion;
}
void nsRegionQT::Intersect(const nsIRegion &aRegion)
{
nsRegionQT *pRegion = (nsRegionQT*)&aRegion;
mRegion = mRegion.intersect(pRegion->mRegion);
}
void nsRegionQT::Intersect(PRInt32 aX,PRInt32 aY,
PRInt32 aWidth,PRInt32 aHeight)
{
QRegion region(aX, aY, aWidth, aHeight);
mRegion = mRegion.intersect(region);
}
void nsRegionQT::Union(const nsIRegion &aRegion)
{
nsRegionQT *pRegion = (nsRegionQT*)&aRegion;
mRegion = mRegion.unite(pRegion->mRegion);
}
void nsRegionQT::Union(PRInt32 aX,PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight)
{
QRegion region(aX, aY, aWidth, aHeight);
mRegion = mRegion.unite(region);
}
void nsRegionQT::Subtract(const nsIRegion &aRegion)
{
nsRegionQT *pRegion = (nsRegionQT*)&aRegion;
mRegion = mRegion.subtract(pRegion->mRegion);
}
void nsRegionQT::Subtract(PRInt32 aX,PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight)
{
QRegion aRegion(aX, aY, aWidth, aHeight);
mRegion = mRegion.subtract(aRegion);
}
PRBool nsRegionQT::IsEmpty(void)
{
return mRegion.isEmpty();
}
PRBool nsRegionQT::IsEqual(const nsIRegion &aRegion)
{
nsRegionQT *pRegion = (nsRegionQT*)&aRegion;
return (mRegion == pRegion->mRegion);
}
void nsRegionQT::GetBoundingBox(PRInt32 *aX,PRInt32 *aY,
PRInt32 *aWidth,PRInt32 *aHeight)
{
QRect rect = mRegion.boundingRect();
*aX = rect.x();
*aY = rect.y();
*aWidth = rect.width();
*aHeight = rect.height();
}
void nsRegionQT::Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
mRegion.translate(aXOffset, aYOffset);
}
PRBool nsRegionQT::ContainsRect(PRInt32 aX,PRInt32 aY,
PRInt32 aWidth,PRInt32 aHeight)
{
QRect rect(aX, aY, aWidth, aHeight);
return mRegion.contains(rect);
}
NS_IMETHODIMP nsRegionQT::GetRects(nsRegionRectSet **aRects)
{
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
QArray<QRect> array = mRegion.rects();
PRUint32 size = array.size();
nsRegionRect *rect = nsnull;
nsRegionRectSet *rects = *aRects;
if (nsnull == rects || rects->mRectsLen < (PRUint32)size) {
void *buf = PR_Realloc(rects,
sizeof(nsRegionRectSet)
+ (sizeof(nsRegionRect) * (size - 1)));
if (nsnull == buf) {
if (nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet*)buf;
rects->mRectsLen = size;
}
rects->mNumRects = size;
rects->mArea = 0;
rect = &rects->mRects[0];
for (PRUint32 i = 0; i < size; i++) {
QRect qRect = array[i];
rect->x = qRect.x();
rect->y = qRect.y();
rect->width = qRect.width();
rect->height = qRect.height();
rects->mArea += rect->width * rect->height;
rect++;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP nsRegionQT::FreeRects(nsRegionRectSet *aRects)
{
if (nsnull != aRects) {
PR_Free((void*)aRects);
}
return NS_OK;
}
NS_IMETHODIMP nsRegionQT::GetNativeRegion(void *&aRegion) const
{
aRegion = (void*)&mRegion;
return NS_OK;
}
NS_IMETHODIMP nsRegionQT::GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
// cast to avoid const-ness problems on some compilers
if (((nsRegionQT*)this)->IsEmpty()) {
aComplexity = eRegionComplexity_empty;
}
else {
aComplexity = eRegionComplexity_rect;
}
return NS_OK;
}
void nsRegionQT::SetRegionEmpty()
{
if (!IsEmpty()) {
QRegion empty;
mRegion = empty;
}
}
NS_IMETHODIMP nsRegionQT::GetNumRects(PRUint32 *aRects) const
{
*aRects = mRegion.rects().size();
return NS_OK;
}

Просмотреть файл

@ -1,87 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRegionQT_h___
#define nsRegionQT_h___
#include "nsIRegion.h"
#include <qregion.h>
class nsRegionQT : public nsIRegion
{
public:
nsRegionQT();
virtual ~nsRegionQT();
NS_DECL_ISUPPORTS
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void SetTo(const nsRegionQT *aRegion);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
NS_IMETHOD GetNumRects(PRUint32* aRects) const;
private:
virtual void SetRegionEmpty();
private:
QRegion mRegion;
#ifdef DEBUG
PRUint32 mID;
#endif
};
#endif // nsRegionQT_h___

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,243 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRenderingContextQT_h___
#define nsRenderingContextQT_h___
#include "nsRenderingContextImpl.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#include "nsRegionQT.h"
#include "nsDrawingSurfaceQT.h"
#include "prlog.h"
class nsFontQT;
class nsRenderingContextQT : public nsRenderingContextImpl
{
public:
nsRenderingContextQT();
virtual ~nsRenderingContextQT();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface(PRInt32 aX,PRInt32 aY,PRUint32 aWidth,
PRUint32 aHeight,void **aBits,
PRInt32 *aStride,PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect,nsClipCombine aCombine,
PRBool &aClipEmpty);
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion,nsClipCombine aCombine,
PRBool &aClipEmpty);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds,PRUint32 aSurfFlags,
nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawStdLine(nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX,nscoord aY,nscoord aWidth,nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX,nscoord aY,nscoord aWidth,nscoord aHeight);
NS_IMETHOD InvertRect(const nsRect& aRect);
NS_IMETHOD InvertRect(nscoord aX,nscoord aY,nscoord aWidth,nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX,nscoord aY,nscoord aWidth,
nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX,nscoord aY,nscoord aWidth,
nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,float aStartAngle,float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX,nscoord aY,nscoord aWidth,nscoord aHeight,
float aStartAngle,float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,float aStartAngle,float aEndAngle);
NS_IMETHOD FillArc(nscoord aX,nscoord aY,nscoord aWidth,nscoord aHeight,
float aStartAngle,float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth, PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString,nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString,PRUint32 aLength,nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString,PRUint32 aLength,
nscoord &aWidth,PRInt32 *aFontID);
NS_IMETHOD GetTextDimensions(const char* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions);
NS_IMETHOD GetTextDimensions(const PRUnichar *aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32 *aFontID);
NS_IMETHOD GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID);
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID);
#ifdef MOZ_MATHML
/* Returns metrics (in app units) of an 8-bit character string */
NS_IMETHOD GetBoundingMetrics(const char *aString,PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
/* Returns metrics (in app units) of a Unicode character string */
NS_IMETHOD GetBoundingMetrics(const PRUnichar *aString,PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32 *aFontID = nsnull);
#endif /* MOZ_MATHML */
void MyDrawString(QPainter *aGC,nscoord aX,nscoord aY,QString &aText);
NS_IMETHOD DrawString(const char *aString,PRUint32 aLength,
nscoord aX,nscoord aY,const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString,PRUint32 aLength,
nscoord aX,nscoord aY,PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString,nscoord aX,nscoord aY,
PRInt32 aFontID,const nscoord* aSpacing);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf,
PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds,
PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 *ngd);
//locals
NS_IMETHOD CommonInit();
void UpdateGC();
void ConditionRect(nscoord &x, nscoord &y, nscoord &w, nscoord &h);
void CreateClipRegion();
protected:
nsDrawingSurfaceQT *mOffscreenSurface;
nsDrawingSurfaceQT *mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsCOMPtr<nsIRegion> mClipRegion;
float mP2T;
// graphic state stack (GraphicsState)
nsVoidArray *mStateCache;
nscolor mCurrentColor;
nsLineStyle mCurrentLineStyle;
nsFontQT *mCurrentFont;
Qt::PenStyle mQLineStyle;
Qt::RasterOp mFunction;
QPainter *mGC;
QPaintDevice *mPaintDev;
PRUint32 mID;
};
#endif /* nsRenderingContextQT_h___ */

Просмотреть файл

@ -1,137 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerQT.h"
#include "nsScreenQT.h"
#include "qtlog.h"
#ifdef DEBUG
PRUint32 gSMCount = 0;
PRUint32 gSMID = 0;
#endif
nsScreenManagerQT::nsScreenManagerQT()
{
#ifdef DEBUG
gSMCount++;
mID = gSMID++;
PR_LOG(gQTLogModule, QT_BASIC,
("nsScreenManagerQT CTOR (%p) ID: %d, Count: %d\n", this, mID, gSMCount));
#endif
// nothing else to do. I guess we could cache a bunch of information
// here, but we want to ask the device at runtime in case anything
// has changed.
}
nsScreenManagerQT::~nsScreenManagerQT()
{
#ifdef DEBUG
gSMCount--;
PR_LOG(gQTLogModule, QT_BASIC,
("nsScreenManagerQT DTOR (%p) ID: %d, Count: %d\n", this, mID, gSMCount));
#endif
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenManagerQT, nsIScreenManager)
//
// CreateNewScreenObject
//
// Utility routine. Creates a new screen object from the given device handle
//
// NOTE: For this "single-monitor" impl, we just always return the cached primary
// screen. This should change when a multi-monitor impl is done.
//
nsIScreen*
nsScreenManagerQT::CreateNewScreenObject()
{
nsIScreen *retval = nsnull;
if (!mCachedMainScreen)
mCachedMainScreen = new nsScreenQT();
NS_IF_ADDREF(retval = mCachedMainScreen.get());
return retval;
}
//
// ScreenForRect
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
NS_IMETHODIMP
nsScreenManagerQT::ScreenForRect(PRInt32 /*inLeft*/, PRInt32 /*inTop*/,
PRInt32 /*inWidth*/, PRInt32 /*inHeight*/,
nsIScreen **outScreen)
{
GetPrimaryScreen(outScreen);
return NS_OK;
} // ScreenForRect
//
// GetPrimaryScreen
//
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
//
NS_IMETHODIMP
nsScreenManagerQT::GetPrimaryScreen(nsIScreen **aPrimaryScreen)
{
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
return NS_OK;
} // GetPrimaryScreen
//
// GetNumberOfScreens
//
// Returns how many physical screens are available.
//
NS_IMETHODIMP
nsScreenManagerQT::GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
*aNumberOfScreens = 1;
return NS_OK;
} // GetNumberOfScreens

Просмотреть файл

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerQt_h___
#define nsScreenManagerQt_h___
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsCOMPtr.h"
//------------------------------------------------------------------------
class nsScreenManagerQT : public nsIScreenManager
{
public:
nsScreenManagerQT ( );
virtual ~nsScreenManagerQT();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsIScreen* CreateNewScreenObject ( ) ;
// cache the primary screen object to avoid memory allocation every time
nsCOMPtr<nsIScreen> mCachedMainScreen;
#ifdef DEBUG
PRUint32 mID;
#endif
};
#endif // nsScreenManagerQt_h___

Просмотреть файл

@ -1,113 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenQT.h"
#include <qcolor.h>
#include <qapplication.h>
#include "qtlog.h"
#ifdef DEBUG
PRUint32 gScreenCount = 0;
PRUint32 gScreenID = 0;
#endif
nsScreenQT::nsScreenQT()
{
#ifdef DEBUG
gScreenCount++;
mID = gScreenID++;
PR_LOG(gQTLogModule, QT_BASIC,
("nsScreenQT CTOR (%p) ID: %d, Count: %d\n", this, mID, gScreenCount));
#endif
// nothing else to do. I guess we could cache a bunch of information
// here, but we want to ask the device at runtime in case anything
// has changed.
}
nsScreenQT::~nsScreenQT()
{
#ifdef DEBUG
gScreenCount--;
PR_LOG(gQTLogModule, QT_BASIC,
("nsScreenQT DTOR (%p) ID: %d, Count: %d\n", this, mID, gScreenCount));
#endif
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenQT, nsIScreen)
NS_IMETHODIMP
nsScreenQT::GetRect(PRInt32 *outLeft,PRInt32 *outTop,
PRInt32 *outWidth,PRInt32 *outHeight)
{
*outTop = 0;
*outLeft = 0;
*outWidth = QApplication::desktop()->width();
*outHeight = QApplication::desktop()->height();
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenQT::GetAvailRect(PRInt32 *outLeft,PRInt32 *outTop,
PRInt32 *outWidth,PRInt32 *outHeight)
{
*outTop = 0;
*outLeft = 0;
*outWidth = QApplication::desktop()->width();
*outHeight = QApplication::desktop()->height();
return NS_OK;
} // GetAvailRect
NS_IMETHODIMP
nsScreenQT::GetPixelDepth(PRInt32 *aPixelDepth)
{
*aPixelDepth = (PRInt32)QColor::numBitPlanes();
return NS_OK;
} // GetPixelDepth
NS_IMETHODIMP
nsScreenQT::GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth(aColorDepth);
} // GetColorDepth

Просмотреть файл

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenQT_h___
#define nsScreenQT_h___
#include "nsIScreen.h"
//------------------------------------------------------------------------
class nsScreenQT : public nsIScreen
{
public:
nsScreenQT ( );
virtual ~nsScreenQT();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
private:
#ifdef DEBUG
PRUint32 mID;
#endif
};
#endif // nsScreenQT_h___

Просмотреть файл

@ -1,49 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the QT Port logging code.
*
* The Initial Developer of the Original Code is
* Christian Biesinger <cbiesinger@web.de>.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef QT_LOG_H__
#define QT_LOG_H__
#define FORCE_PR_LOG
#include "prlog.h"
extern PRLogModuleInfo *gQTLogModule;
const int QT_BASIC = 3;
const int QT_FONTS = 4;
const int QT_EXTRA_FONTS = 5;
#endif

Просмотреть файл

@ -155,9 +155,3 @@ CFLAGS += $(TK_CFLAGS)
endif #MOZ_MONOLITHIC_TOOLKIT
endif #MOZ_ENABLE_XLIB
ifdef MOZ_ENABLE_QT
EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS)
CXXFLAGS += $(MOZ_QT_CFLAGS)
CFLAGS += $(MOZ_QT_CFLAGS)
endif #MOZ_ENABLE_QT

Просмотреть файл

@ -41,11 +41,6 @@
#include "nscore.h"
#include "nsPluginHostImpl.h"
#ifdef MOZ_WIDGET_QT
#undef CursorShape /*X.h defines it as 0,
qnamespace.h makes an enum type by that name
*/
#endif
#include <stdio.h>
#include "prio.h"
#include "prmem.h"
@ -171,8 +166,6 @@
#ifdef XP_UNIX
#if defined(MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
#include <gdk/gdkx.h> // for GDK_DISPLAY()
#elif defined(MOZ_WIDGET_QT)
#include <qwindowdefs.h> // for qt_xdisplay()
#elif defined(MOZ_WIDGET_XLIB)
#include "xlibrgb.h" // for xlib_rgb_get_display()
#endif
@ -2653,8 +2646,6 @@ NS_IMETHODIMP nsPluginHostImpl::GetValue(nsPluginManagerVariable aVariable, void
Display** value = NS_REINTERPRET_CAST(Display**, aValue);
#if defined(MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
*value = GDK_DISPLAY();
#elif defined(MOZ_WIDGET_QT)
*value = qt_xdisplay();
#elif defined(MOZ_WIDGET_XLIB)
*value = xxlib_rgb_get_display(xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE));
#endif

Просмотреть файл

@ -2,7 +2,4 @@ Makefile
viewer
viewer_gtk
viewer_xlib
viewer_qt
viewer_motif

Просмотреть файл

@ -155,7 +155,6 @@ LIBS = \
$(PROFILER_LIBS) \
$(NULL)
QT_LIBS = unix/qt/libviewer_qt_s.a $(XP_LIBS) $(MOZ_QT_LDFLAGS)
XLIB_LIBS = unix/xlib/libviewer_xlib_s.a $(XP_LIBS) $(MOZ_XLIB_LDFLAGS)
GTK_LIBS = unix/gtk/libviewer_gtk_s.a -lgtksuperwin $(XP_LIBS) $(MOZ_GTK_LDFLAGS)
@ -189,7 +188,6 @@ ifneq ($(OS_ARCH),WINNT)
EXTRA_LIBS += -L$(DEPTH)/dist/lib/components
endif # !WINNT
EXTRA_LIBS += $(EXTRA_DSO_LIBS) $(STATIC_EXTRA_LIBS)
QT_LIBS += $(EXTRA_LIBS)
XLIB_LIBS += $(EXTRA_LIBS)
GTK_LIBS += $(EXTRA_LIBS)
DEFINES += $(STATIC_DEFINES)
@ -216,7 +214,7 @@ ifeq ($(OS_ARCH),WINNT)
DEFINES += -DUSE_LOCAL_WIDGETS
endif
GARBAGE += $(PROGRAM)_gtk $(PROGRAM)_qt $(PROGRAM)_xlib
GARBAGE += $(PROGRAM)_gtk $(PROGRAM)_xlib
ifeq ($(OS_ARCH),WINNT)
OS_LIBS += shell32.lib ole32.lib oleaut32.lib oleacc.lib \
@ -238,9 +236,6 @@ endif
unix/gtk/libviewer_gtk_s.a:
@$(MAKE) -C $(@D) $(@F)
unix/qt/libviewer_qt_s.a:
@$(MAKE) -C $(@D) $(@F)
unix/xlib/libviewer_xlib_s.a:
@$(MAKE) -C $(@D) $(@F)
@ -250,12 +245,6 @@ ifdef ENABLE_STRIP
$(STRIP) $@
endif
$(PROGRAM)_qt: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in unix/qt/libviewer_qt_s.a
$(CCC) $(CXXFLAGS) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(QT_LIBS) $(OS_LIBS) $(PROFILER_LIBS)
ifdef ENABLE_STRIP
$(STRIP) $@
endif
$(PROGRAM)_xlib: $(PROGOBJS) $(EXTRA_DEPS) Makefile Makefile.in unix/xlib/libviewer_xlib_s.a
$(CCC) $(CXXFLAGS) -o $@ $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(XLIB_LIBS) $(OS_LIBS) $(PROFILER_LIBS)
ifdef ENABLE_STRIP
@ -267,11 +256,6 @@ libs:: $(PROGRAM)_gtk
$(INSTALL) -m 555 $< $(DIST)/bin
endif
ifdef MOZ_ENABLE_QT
libs:: $(PROGRAM)_qt
$(INSTALL) -m 555 $< $(DIST)/bin
endif
ifdef MOZ_ENABLE_XLIB
libs:: $(PROGRAM)_xlib
$(INSTALL) -m 555 $< $(DIST)/bin

Просмотреть файл

@ -62,10 +62,6 @@ DIRS += xlibxtbin
DIRS += xlib
endif
ifdef MOZ_ENABLE_QT
DIRS += qt
endif
ifdef MOZ_ENABLE_PHOTON
DIRS += photon
endif

Просмотреть файл

@ -1,10 +0,0 @@
Makefile
moc_nsQApplication.cpp
moc_nsLabel.cpp
moc_nsScrollbar.cpp
moc_nsButton.cpp
moc_nsCheckButton.cpp
moc_nsTextWidget.cpp
moc_nsTabWidget.cpp
moc_nsQEventHandler.cpp
moc_nsWindow.cpp

Просмотреть файл

@ -1,113 +0,0 @@
#
# 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>
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = widget
LIBRARY_NAME = widget_qt
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsWidgetQTModule
GRE_MODULE = 1
REQUIRES = xpcom \
string \
gfx \
layout \
content \
dom \
appshell \
pref \
uconv \
$(NULL)
CPPSRCS = \
$(MOCSRCS) \
nsQApplication.cpp \
nsAppShell.cpp \
nsBidiKeyboard.cpp \
nsScrollbar.cpp \
nsLookAndFeel.cpp \
nsToolkit.cpp \
nsQWidget.cpp \
nsWidget.cpp \
nsWindow.cpp \
nsDragService.cpp \
nsClipboard.cpp \
nsWidgetFactory.cpp \
nsMime.cpp \
$(NULL)
MOCSRCS = \
moc_nsQApplication.cpp \
moc_nsScrollbar.cpp \
moc_nsQWidget.cpp \
moc_nsMime.cpp \
$(NULL)
SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
EXTRA_DSO_LDOPTS = \
$(MOZ_COMPONENT_LIBS) \
-lgkgfx \
-I$(topsrcdir)/gfx/src/qt \
$(MOZ_JS_LIBS) \
$(NULL)
EXTRA_DSO_LDOPTS += -L$(DIST)/lib $(MOZ_QT_LDFLAGS) $(MOZ_XLIB_LDFLAGS)
# If not primary toolkit, install in secondary path
ifneq (qt,$(MOZ_WIDGET_TOOLKIT))
INACTIVE_COMPONENT = 1
endif
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_QT_CFLAGS)
CFLAGS += $(MOZ_QT_CFLAGS)
DEFINES += -D_IMPL_NS_WIDGET
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif
LOCAL_INCLUDES = -I$(srcdir)/../xpwidgets \
-I$(srcdir) \
-I$(topsrcdir)/gfx/src/qt \
$(NULL)

Просмотреть файл

@ -1,263 +0,0 @@
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsAppShell.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsICmdLineService.h"
//JCG #define DBG_JCG 1
#ifdef DBG_JCG
PRInt32 gAppShellCount = 0;
PRInt32 gAppShellID = 0;
#endif
//-------------------------------------------------------------------------
//
// XPCOM CIDs
//
//-------------------------------------------------------------------------
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
//-------------------------------------------------------------------------
//
// nsAppShell constructor
//
//-------------------------------------------------------------------------
nsAppShell::nsAppShell() :
mDispatchListener(0),
mApplication(nsnull)
{
#ifdef DBG_JCG
gAppShellCount++;
mID = gAppShellID++;
printf("JCG: nsAppShell CTOR (%p) ID: %d, Count: %d\n",this,mID,gAppShellCount);
#endif
}
//-------------------------------------------------------------------------
//
// nsAppShell destructor
//
//-------------------------------------------------------------------------
nsAppShell::~nsAppShell()
{
if (mApplication) {
mApplication->Release();
}
mApplication = nsnull;
#ifdef DBG_JCG
gAppShellCount--;
printf("JCG: nsAppShell DTOR (%p) ID: %d, Count: %d\n",this,mID,gAppShellCount);
#endif
}
//-------------------------------------------------------------------------
//
// nsISupports implementation macro
//
//-------------------------------------------------------------------------
NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
//-------------------------------------------------------------------------
NS_METHOD
nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
{
mDispatchListener = aDispatchListener;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Create the application shell
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Create(int *bac, char **bav)
{
int argc = bac ? *bac : 0;
char **argv = bav;
nsresult rv;
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;
}
}
mApplication = nsQApplication::Instance(argc,argv);
if (!mApplication) {
return NS_ERROR_NOT_INITIALIZED;
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Spinup - do any preparation necessary for running a message loop
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Spinup()
{
nsresult rv = NS_OK;
if (mApplication == nsnull)
return NS_ERROR_NOT_INITIALIZED;
// 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;
}
//-------------------------------------------------------------------------
//
// Spindown - do any cleanup necessary for finishing a message loop
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Spindown()
{
if (mApplication == nsnull)
return NS_ERROR_NOT_INITIALIZED;
if (mEventQueue) {
mApplication->RemoveEventProcessorCallback(mEventQueue);
mEventQueue = nsnull;
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Run
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Run()
{
if (mApplication == nsnull)
return NS_ERROR_NOT_INITIALIZED;
if (!mEventQueue) {
Spinup();
}
if (!mEventQueue) {
return NS_ERROR_NOT_INITIALIZED;
}
mApplication->exec();
Spindown();
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Exit a message handler loop
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Exit()
{
if (mApplication == nsnull)
return NS_ERROR_NOT_INITIALIZED;
mApplication->exit(0);
return NS_OK;
}
NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *& aEvent)
{
aRealEvent = PR_FALSE;
aEvent = 0;
return NS_OK;
}
NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
{
if (mApplication == nsnull)
return NS_ERROR_NOT_INITIALIZED;
mApplication->processEvents(1);
return NS_OK;
}
NS_IMETHODIMP nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue,
PRBool aListen)
{
if (mApplication == nsnull)
return NS_ERROR_NOT_INITIALIZED;
if (aListen) {
mApplication->AddEventProcessorCallback(aQueue);
}
else {
mApplication->RemoveEventProcessorCallback(aQueue);
}
return NS_OK;
}

Просмотреть файл

@ -1,63 +0,0 @@
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAppShell_h__
#define nsAppShell_h__
#include "nsIAppShell.h"
#include "nsIEventQueue.h"
#include "nsQApplication.h"
/* Native QT Application shell wrapper */
class nsAppShell : public nsIAppShell
{
public:
nsAppShell();
virtual ~nsAppShell();
NS_DECL_ISUPPORTS
NS_DECL_NSIAPPSHELL
private:
nsDispatchListener *mDispatchListener;
nsCOMPtr<nsIEventQueue> mEventQueue;
nsQApplication *mApplication;
PRInt32 mID;
};
#endif // nsAppShell_h__

Просмотреть файл

@ -1,46 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 IBM code.
*
* The Initial Developer of the Original Code is IBM.
* Portions created by IBM are
* Copyright (C) International Business Machines
* Corporation, 2000. All Rights Reserved.
*
* Contributor(s): Simon Montagu
*/
#include "nsBidiKeyboard.h"
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
{
}
nsBidiKeyboard::~nsBidiKeyboard()
{
}
NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
{
*aIsRTL = PR_FALSE;
// XXX Insert platform specific code to determine keyboard direction
return NS_OK;
}
NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
{
// XXX Insert platform specific code to set keyboard language
return NS_OK;
}

Просмотреть файл

@ -1,39 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 IBM code.
*
* The Initial Developer of the Original Code is IBM.
* Portions created by IBM are
* Copyright (C) International Business Machines
* Corporation, 2000. All Rights Reserved.
*
* Contributor(s): Simon Montagu
*/
#ifndef __nsBidiKeyboard
#define __nsBidiKeyboard
#include "nsIBidiKeyboard.h"
class nsBidiKeyboard : public nsIBidiKeyboard
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIBIDIKEYBOARD
nsBidiKeyboard();
virtual ~nsBidiKeyboard();
/* additional members */
};
#endif // __nsBidiKeyboard

Просмотреть файл

@ -1,125 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsButton.h"
#include "nsToolkit.h"
#include "nsColor.h"
#include "nsGUIEvent.h"
#include "nsString.h"
//=============================================================================
//
// nsQPushButton class
//
//=============================================================================
nsQPushButton::nsQPushButton(nsWidget * widget,
QWidget * parent,
const char * name)
: QPushButton(parent, name), nsQBaseWidget(widget)
{
}
nsQPushButton::~nsQPushButton()
{
}
NS_IMPL_ADDREF_INHERITED(nsButton, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsButton, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsButton, nsIButton, nsIWidget)
//-------------------------------------------------------------------------
//
// nsButton constructor
//
//-------------------------------------------------------------------------
nsButton::nsButton() : nsWidget() , nsIButton()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsButton::nsButton()\n"));
}
//-------------------------------------------------------------------------
//
// nsButton destructor
//
//-------------------------------------------------------------------------
nsButton::~nsButton()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsButton::~nsButton()\n"));
if (mWidget)
{
delete ((QPushButton *) mWidget);
mWidget = nsnull;
}
}
void nsButton::InitCallbacks(char * aName)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsButton::InitCallbacks()\n"));
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsButton::SetLabel(const nsString& aText)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG,
("nsButton::SetLabel to %s()\n",
NS_LossyConvertUCS2toASCII(aText).get()));
((QPushButton *)mWidget)->setText(NS_LossyConvertUCS2toASCII(aText).get());
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsButton::GetLabel(nsString& aBuffer)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsButton::GetLabel()\n"));
QString string = ((QPushButton *)mWidget)->text();
aBuffer.SetLength(0);
aBuffer.AppendWithConversion((const char *) string);
return (NS_OK);
}

Просмотреть файл

@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsButton_h__
#define nsButton_h__
#include "nsWidget.h"
#include "nsIButton.h"
#include <qpushbutton.h>
//=============================================================================
//
// nsQPushButton class
//
//=============================================================================
class nsQPushButton : public QPushButton, public nsQBaseWidget
{
Q_OBJECT
public:
nsQPushButton(nsWidget * widget,
QWidget * parent = 0,
const char * name = 0);
~nsQPushButton();
protected:
#if 0
bool eventFilter(QObject * object, QEvent * event);
virtual void mousePressedEvent(QMouseEvent * event);
virtual void mouseReleasedEvent(QMouseEvent * event);
#endif
};
/**
* Native QT button wrapper
*/
class nsButton : public nsWidget,
public nsIButton
{
public:
nsButton();
virtual ~nsButton();
NS_DECL_ISUPPORTS_INHERITED
// nsIButton
NS_IMETHOD SetLabel(const nsString& aText);
NS_IMETHOD GetLabel(nsString& aBuffer);
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; }
virtual PRBool OnPaint(nsPaintEvent &aEvent) { return PR_FALSE; }
virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; }
protected:
virtual void InitCallbacks(char * aName = nsnull);
};
#endif // nsButton_h__

Просмотреть файл

@ -1,147 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCheckButton.h"
#include "nsColor.h"
#include "nsGUIEvent.h"
#include "nsString.h"
//=============================================================================
//
// nsQCheckBox class
//
//=============================================================================
nsQCheckBox::nsQCheckBox(nsWidget * widget,
QWidget * parent,
const char * name)
: QCheckBox(parent, name), nsQBaseWidget(widget)
{
}
nsQCheckBox::~nsQCheckBox()
{
}
NS_IMPL_ADDREF_INHERITED(nsCheckButton, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsCheckButton, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsCheckButton, nsICheckButton, nsIWidget)
//-------------------------------------------------------------------------
//
// nsCheckButton constructor
//
//-------------------------------------------------------------------------
nsCheckButton::nsCheckButton() : nsWidget() , nsICheckButton()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsCheckButton::nsCheckButton()\n"));
mWidget = nsnull;
}
//-------------------------------------------------------------------------
//
// nsCheckButton destructor
//
//-------------------------------------------------------------------------
nsCheckButton::~nsCheckButton()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsCheckButton::~nsCheckButton()\n"));
if (mWidget)
{
delete ((QCheckBox *)mWidget);
mWidget = nsnull;
}
}
//-------------------------------------------------------------------------
//
// Set this Checkbox state
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetState(const PRBool aState)
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsCheckButton::SetState() %p:%d\n", this, aState));
((QCheckBox *)mWidget)->setChecked(aState);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this Checkbox state
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetState(PRBool& aState)
{
aState = ((QCheckBox *)mWidget)->isChecked();
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsCheckButton::GetState() %p:%d\n", this, aState));
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set this Checkbox label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsCheckButton::SetLabel()\n"));
((QButton *)mWidget)->setText(NS_LossyConvertUCS2toASCII(aText).get());
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsCheckButton::GetLabel()\n"));
QString string = ((QButton *)mWidget)->text();
aBuffer.SetLength(0);
aBuffer.AppendWithConversion((const char *) string);
return (NS_OK);
}

Просмотреть файл

@ -1,88 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCheckButton_h__
#define nsCheckButton_h__
#include "nsWidget.h"
#include "nsICheckButton.h"
#include <qcheckbox.h>
//=============================================================================
//
// nsQCheckBox class
//
//=============================================================================
class nsQCheckBox : public QCheckBox, public nsQBaseWidget
{
Q_OBJECT
public:
nsQCheckBox(nsWidget * widget,
QWidget * parent = 0,
const char * name = 0);
~nsQCheckBox();
};
/**
* Native QT Checkbox wrapper
*/
class nsCheckButton : public nsWidget,
public nsICheckButton
{
public:
nsCheckButton();
virtual ~nsCheckButton();
NS_DECL_ISUPPORTS_INHERITED
// nsICheckButton
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetState(const PRBool aState);
NS_IMETHOD GetState(PRBool& aState);
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; }
virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; }
virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; }
protected:
QWidget *mLabel;
};
#endif // nsCheckButton_h__

Просмотреть файл

@ -1,361 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Denis Issoupov <denis@macadamian.com>
* John C. Griggs <johng@corel.com>
* Dan Rosen <dr@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifdef NDEBUG
#define NO_DEBUG
#endif
#include "nsClipboard.h"
#include "nsMime.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsString.h"
#include "nsISupportsArray.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"
#include "nsIComponentManager.h"
#include "nsWidgetsCID.h"
#include <qapplication.h>
#include <qclipboard.h>
#include <qdragobject.h>
// interface definitions
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard);
//-------------------------------------------------------------------------
//
// nsClipboard constructor
//
//-------------------------------------------------------------------------
nsClipboard::nsClipboard() :
mSelectionOwner (nsnull),
mGlobalOwner (nsnull),
mSelectionTransferable (nsnull),
mGlobalTransferable (nsnull),
mIgnoreEmptyNotification (PR_FALSE)
{
}
//-------------------------------------------------------------------------
//
// nsClipboard destructor
//
//-------------------------------------------------------------------------
nsClipboard::~nsClipboard()
{
}
#ifdef DEBUG_timeless
// XXX nsBaseClipboard will have an init method to allow for constructors to fail
NS_IMETHODIMP nsClipboard::Init()
{
return NS_OK;
}
#endif
NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
{
mIgnoreEmptyNotification = PR_TRUE;
nsCOMPtr<nsITransferable> transferable(getter_AddRefs(GetTransferable(aWhichClipboard)));
// make sure we have a good transferable
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;
flavorList->Count(&cnt);
for (PRUint32 i = 0; i < cnt; ++i) {
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt(i,getter_AddRefs(genericFlavor));
nsCOMPtr<nsISupportsCString> 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)
{
// 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));
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<nsISupportsCString> 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.get(),
(void*)ba.data(),len,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(foundFlavor.get(),genericDataWrapper,len);
}
}
}
return NS_OK;
}
NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard)
{
// 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<nsISupportsCString> 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)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = PR_TRUE; // we support the selection clipboard on unix.
return NS_OK;
}

Просмотреть файл

@ -1,78 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Denis Issoupov <denis@macadamian.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsClipboard_h__
#define nsClipboard_h__
#include "nsIClipboard.h"
#include "nsITransferable.h"
#include "nsIClipboardOwner.h"
#include "nsCOMPtr.h"
#include <qlist.h>
#include <qcstring.h>
#include <qmime.h>
/* Native QT Clipboard wrapper */
class nsClipboard : public nsIClipboard
{
public:
nsClipboard();
virtual ~nsClipboard();
//nsISupports
NS_DECL_ISUPPORTS
// nsIClipboard
NS_DECL_NSICLIPBOARD
protected:
NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
NS_IMETHOD GetNativeClipboardData(nsITransferable *aTransferable,
PRInt32 aWhichClipboard);
inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard);
nsCOMPtr<nsIClipboardOwner> mSelectionOwner;
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> mSelectionTransferable;
nsCOMPtr<nsITransferable> mGlobalTransferable;
PRBool mIgnoreEmptyNotification;
};
#endif // nsClipboard_h__

Просмотреть файл

@ -1,299 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Denis Issoupov <denis@macadamian.com>
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifdef NDEBUG
#define NO_DEBUG
#endif
#include "nsDragService.h"
#include "nsIServiceManager.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"
#include "nsMime.h"
#include "nsWidgetsCID.h"
#include "nsString.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);
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;
//-------------------------------------------------------------------------
//
// DragService constructor
//
//-------------------------------------------------------------------------
nsDragService::nsDragService()
{
// our hidden source widget
mHiddenWidget = new QWidget(0,QWidget::tr("DragDrop"),0);
}
//-------------------------------------------------------------------------
//
// DragService destructor
//
//-------------------------------------------------------------------------
nsDragService::~nsDragService()
{
delete mHiddenWidget;
}
//---------------------------------------------------------
NS_IMETHODIMP
nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
nsISupportsArray *aArrayTransferables,
nsIScriptableRegion *aRegion,
PRUint32 aActionType)
{
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;
}
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<nsISupportsCString> 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)
{
// make sure that we have a transferable
if (!aTransferable)
return NS_ERROR_INVALID_ARG;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsISupportsArray> flavorList;
rv = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
if (NS_FAILED(rv))
return rv;
// count the number of flavors
PRUint32 cnt;
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<nsISupportsCString> 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.get(),
(void*)ba.data(),len,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(foundFlavor.get(),genericDataWrapper,len);
}
}
}
return NS_OK;
}
NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor,
PRBool *_retval)
{
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;
}
NS_IMETHODIMP nsDragService::SetDragReference(QMimeSource* aDragRef)
{
nsMimeStore* pMimeStore = new nsMimeStore();
int c = 0;
const char* format;
while ((format = aDragRef->format(c++)) != 0) {
// this is usualy between different processes
// so, we need to copy datafrom one to onother
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;
}

Просмотреть файл

@ -1,89 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Denis Issoupov <denis@macadamian.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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, public nsIDragSessionQt
{
public:
nsDragService();
virtual ~nsDragService();
//nsISupports
NS_DECL_ISUPPORTS_INHERITED
//nsIDragService
NS_IMETHOD InvokeDragSession(nsIDOMNode *aDOMNode,
nsISupportsArray *anArrayTransferables,
nsIScriptableRegion *aRegion,
PRUint32 aActionType);
NS_IMETHOD StartDragSession();
NS_IMETHOD EndDragSession();
// 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);
// nsIDragSessionQt
NS_IMETHOD SetDragReference(QMimeSource* aDragRef);
protected:
QDragObject *RegisterDragFlavors(nsITransferable* transferable);
private:
// the source of our drags
QWidget *mHiddenWidget;
QDragObject *mDragObject;
// our source data items
nsCOMPtr<nsISupportsArray> mSourceDataItems;
};
#endif // nsDragService_h__

Просмотреть файл

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Denis Issoupov <denis@macadamian.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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

Просмотреть файл

@ -1,183 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLabel.h"
#include "nsToolkit.h"
#include "nsColor.h"
#include "nsGUIEvent.h"
#include "nsString.h"
//=============================================================================
//
// nsQLabel class
//
//=============================================================================
nsQLabel::nsQLabel(nsWidget * widget,
QWidget * parent,
const char * name, WFlags f)
: QLabel(parent, name, f), nsQBaseWidget(widget)
{
}
nsQLabel::~nsQLabel()
{
}
NS_IMPL_ADDREF_INHERITED(nsLabel,nsWidget)
NS_IMPL_RELEASE_INHERITED(nsLabel,nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsLabel, nsILabel, nsIWidget)
//-------------------------------------------------------------------------
//
// nsLabel constructor
//
//-------------------------------------------------------------------------
nsLabel::nsLabel() : nsWidget(), nsILabel()
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::nsLabel()\n"));
mAlignment = eAlign_Left;
}
//-------------------------------------------------------------------------
//
//
//-------------------------------------------------------------------------
NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData)
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::PreCreateWidget()\n"));
if (nsnull != aInitData)
{
nsLabelInitData* data = (nsLabelInitData *) aInitData;
mAlignment = data->mAlignment;
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set alignment
//
//-------------------------------------------------------------------------
NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment)
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::SetAlignment()\n"));
mAlignment = aAlignment;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// nsLabel destructor
//
//-------------------------------------------------------------------------
nsLabel::~nsLabel()
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::~nsLabel()\n"));
}
//-------------------------------------------------------------------------
//
//
//
//-------------------------------------------------------------------------
int nsLabel::GetNativeAlignment()
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::GetNativeAlignment()\n"));
int alignment = QLabel::AlignVCenter;
switch (mAlignment)
{
case eAlign_Right:
alignment |= QLabel::AlignRight;
break;
case eAlign_Left:
alignment |= QLabel::AlignLeft;
break;
case eAlign_Center:
alignment |= QLabel::AlignCenter;
break;
default:
alignment |= QLabel::AlignCenter;
break;
}
return alignment;
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsLabel::SetLabel(const nsString& aText)
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::SetLabel()\n"));
((QLabel *)mWidget)->setText(NS_LossyConvertUCS2toASCII(aText).get());
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsLabel::GetLabel(nsString& aBuffer)
{
PR_LOG(QtWidgetsLM,
PR_LOG_DEBUG,
("nsLabel::GetLabel()\n"));
QString string = ((QLabel *)mWidget)->text();
aBuffer.SetLength(0);
aBuffer.AppendWithConversion((const char *)string);
return NS_OK;
}

Просмотреть файл

@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsLabel_h__
#define nsLabel_h__
#include "nsWidget.h"
#include "nsIAppShell.h"
#include "nsILabel.h"
#include <qlabel.h>
//=============================================================================
//
// nsQLabel class
//
//=============================================================================
class nsQLabel : public QLabel, public nsQBaseWidget
{
Q_OBJECT
public:
nsQLabel(nsWidget * widget,
QWidget * parent = 0,
const char * name = 0,
WFlags f = 0);
~nsQLabel();
};
/**
* Native QT Label wrapper
*/
class nsLabel : public nsWidget,
public nsILabel
{
public:
nsLabel();
virtual ~nsLabel();
NS_DECL_ISUPPORTS_INHERITED
// nsILabel part
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; }
virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; }
virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; }
protected:
int GetNativeAlignment();
nsLabelAlignment mAlignment;
};
#endif // nsLabel_h__

Просмотреть файл

@ -1,425 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLookAndFeel.h"
#include "nsQApplication.h"
#include <qpalette.h>
#define QCOLOR_TO_NS_RGB(c) \
((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
//-------------------------------------------------------------------------
//
// Query interface implementation
//
//-------------------------------------------------------------------------
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
{
}
nsLookAndFeel::~nsLookAndFeel()
{
}
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID,nscolor &aColor)
{
nsresult 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();
switch (aID) {
case eColor_WindowBackground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_WindowForeground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.foreground());
break;
case eColor_WidgetBackground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_WidgetForeground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.foreground());
break;
case eColor_WidgetSelectBackground:
aColor = QCOLOR_TO_NS_RGB(activeGroup.background());
break;
case eColor_WidgetSelectForeground:
aColor = QCOLOR_TO_NS_RGB(activeGroup.foreground());
break;
case eColor_Widget3DHighlight:
aColor = NS_RGB(0xa0,0xa0,0xa0);
break;
case eColor_Widget3DShadow:
aColor = NS_RGB(0x40,0x40,0x40);
break;
case eColor_TextBackground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_TextForeground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor_TextSelectBackground:
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlight());
break;
case eColor_TextSelectForeground:
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlightedText());
break;
case eColor_activeborder:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_activecaption:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_appworkspace:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_background:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_captiontext:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor_graytext:
aColor = QCOLOR_TO_NS_RGB(disabledGroup.text());
break;
case eColor_highlight:
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlight());
break;
case eColor_highlighttext:
aColor = QCOLOR_TO_NS_RGB(activeGroup.highlightedText());
break;
case eColor_inactiveborder:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_inactivecaption:
aColor = QCOLOR_TO_NS_RGB(disabledGroup.background());
break;
case eColor_inactivecaptiontext:
aColor = QCOLOR_TO_NS_RGB(disabledGroup.text());
break;
case eColor_infobackground:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_infotext:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor_menu:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_menutext:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor_scrollbar:
aColor = QCOLOR_TO_NS_RGB(activeGroup.background());
break;
case eColor_threedface:
case eColor_buttonface:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_buttonhighlight:
case eColor_threedhighlight:
aColor = QCOLOR_TO_NS_RGB(normalGroup.light());
break;
case eColor_buttontext:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor_buttonshadow:
case eColor_threedshadow:
aColor = QCOLOR_TO_NS_RGB(normalGroup.shadow());
break;
case eColor_threeddarkshadow:
aColor = QCOLOR_TO_NS_RGB(normalGroup.dark());
break;
case eColor_threedlightshadow:
aColor = QCOLOR_TO_NS_RGB(normalGroup.light());
break;
case eColor_window:
case eColor_windowframe:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor_windowtext:
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_fieldtext:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor__moz_dialog:
aColor = QCOLOR_TO_NS_RGB(normalGroup.background());
break;
case eColor__moz_dialogtext:
aColor = QCOLOR_TO_NS_RGB(normalGroup.text());
break;
case eColor__moz_dragtargetzone:
aColor = QCOLOR_TO_NS_RGB(activeGroup.background());
break;
default:
aColor = 0;
res = NS_ERROR_FAILURE;
break;
}
return res;
}
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID,PRInt32 &aMetric)
{
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
if (NS_SUCCEEDED(res))
return res;
res = NS_OK;
switch (aID) {
case eMetric_WindowTitleHeight:
aMetric = 0;
break;
case eMetric_WindowBorderWidth:
// There was once code in nsDeviceContextQT::GetSystemAttribute to
// use the border width obtained from a widget in its Init method.
break;
case eMetric_WindowBorderHeight:
// There was once code in nsDeviceContextQT::GetSystemAttribute to
// use the border width obtained from a widget in its Init method.
break;
case eMetric_Widget3DBorder:
aMetric = 4;
break;
case eMetric_TextFieldHeight:
aMetric = 15;
break;
case eMetric_TextFieldBorder:
aMetric = 2;
break;
case eMetric_TextVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_TextShouldUseVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_TextHorizontalInsideMinimumPadding:
aMetric = 15;
break;
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
aMetric = 1;
break;
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
aMetric = 10;
break;
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
aMetric = 8;
break;
case eMetric_CheckboxSize:
aMetric = 15;
break;
case eMetric_RadioboxSize:
aMetric = 15;
break;
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
aMetric = 15;
break;
case eMetric_ListHorizontalInsideMinimumPadding:
aMetric = 15;
break;
case eMetric_ListShouldUseVerticalInsidePadding:
aMetric = 1;
break;
case eMetric_ListVerticalInsidePadding:
aMetric = 1;
break;
case eMetric_CaretBlinkTime:
aMetric = 500;
break;
case eMetric_SingleLineCaretWidth:
case eMetric_MultiLineCaretWidth:
aMetric = 1;
break;
case eMetric_ShowCaretDuringSelection:
aMetric = 0;
break;
case eMetric_SelectTextfieldsOnKeyFocus:
// Select textfield content when focused by kbd
// used by nsEventStateManager::sTextfieldSelectModel
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;
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)
{
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
if (NS_SUCCEEDED(res))
return res;
res = NS_OK;
switch (aID) {
case eMetricFloat_TextFieldVerticalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_TextFieldHorizontalInsidePadding:
aMetric = 0.95f; // large number on purpose so minimum padding is used
break;
case eMetricFloat_TextAreaVerticalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_TextAreaHorizontalInsidePadding:
aMetric = 0.40f; // large number on purpose so minimum padding is used
break;
case eMetricFloat_ListVerticalInsidePadding:
aMetric = 0.10f;
break;
case eMetricFloat_ListHorizontalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_ButtonVerticalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_ButtonHorizontalInsidePadding:
aMetric = 0.25f;
break;
default:
aMetric = -1.0;
res = NS_ERROR_FAILURE;
}
return res;
}

Просмотреть файл

@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
#include "nsXPLookAndFeel.h"
class nsLookAndFeel: public nsXPLookAndFeel
{
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
nsresult NativeGetColor(const nsColorID aID, nscolor &aColor);
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric);
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric);
};
#endif

Просмотреть файл

@ -1,174 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Denis Issoupov <denis@macadamian.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDragService.h"
#include "nsIServiceManager.h"
#include "nsWidget.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"
#include "nsReadableUtils.h"
#include "nsClipboard.h"
#include "nsMime.h"
#include "nsCRT.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 unknown %s\n", name);
#endif
return qba;
}
PRBool nsMimeStore::ContainsFlavor(const char* name)
{
for (nsMimeStoreData *msd = mMimeStore.first(); msd; msd = mMimeStore.next()) {
if (!strcmp(name, msd->flavorName))
return PR_TRUE;
}
return PR_FALSE;
}
PRBool nsMimeStore::AddFlavorData(const char* name, void* data, PRInt32 len)
{
if (ContainsFlavor(name))
return PR_FALSE;
mMimeStore.append(new nsMimeStoreData(name, data, len));
// we're done unless we're given text/unicode,
// and text/plain is not already advertised,
if (strcmp(name, kUnicodeMime) || ContainsFlavor(kTextMime))
return PR_TRUE;
// in which case we also advertise text/plain
// which we will convert on our own in nsDataObj::GetText().
char *as = ToNewCString(nsDependentString((PRUnichar*)data));
// let's text/plain be first for stupid programs
// Ownership of |as| is transfered to mMimeStore
mMimeStore.insert(0,new nsMimeStoreData(kTextMime,as,nsCRT::strlen(as) + 1));
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);
}

Просмотреть файл

@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Denis Issoupov <denis@macadamian.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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);
PRBool ContainsFlavor(const char* name);
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

Просмотреть файл

@ -1,443 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//JCG #define DBG_JCG 1
#include "nsQApplication.h"
#include "nsQWidget.h"
#if QT_VERSION >= 300
#include <qstylefactory.h>
#else
#include <qwindowsstyle.h>
#endif
#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;
#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)
{
printf("Enter nsQApplication::Instance\n");
if (!mInstance)
mInstance = new nsQApplication(argc,argv);
mRefCnt++;
printf("Exit nsQApplication::Instance\n");
return mInstance;
}
void nsQApplication::Release()
{
printf("Enter nsQApplication::Release\n");
mRefCnt--;
if (mRefCnt <= 0) {
if (mMasterWidget) {
delete mMasterWidget;
mMasterWidget = nsnull;
}
delete mInstance;
mInstance = nsnull;
}
printf("Exit nsQApplication::Release\n");
}
QWidget *nsQApplication::GetMasterWidget()
{
printf("Enter nsQApplication::GetMasterWidget\n");
if (!mMasterWidget)
mMasterWidget = new QWidget();
printf("Exit nsQApplication::GetMasterWidget\n");
return mMasterWidget;
}
nsQApplication::nsQApplication(int argc,char** argv)
: QApplication(argc,argv)
{
printf("Enter: QApplication::QApplication\n");
#ifdef DBG_JCG
gQAppCount++;
mID = gQAppID++;
printf("JCG nsQApplication CTOR (%p) ID: %d, Count: %d\n",this,mID,gQAppCount);
XSetErrorHandler (_x_error);
#endif
NS_ASSERTION(!mInstance, "Attempt to create duplicate QApplication Object.");
mInstance = this;
setGlobalMouseTracking(true);
#if QT_VERSION >= 300
setStyle(QStyleFactory::create("windows"));
#else
//XXX this line seems to have linking problems w/ debian
// this code should eventually be changed anyway for nsITheme reasons
setStyle(new QWindowsStyle());
#endif
setOverrideCursor(QCursor(ArrowCursor),PR_TRUE);
connect(this,SIGNAL(lastWindowClosed()),this,SLOT(quit()));
printf("Exit: QApplication::QApplication\n");
}
nsQApplication::~nsQApplication()
{
printf("Enter: QApplication::~QApplication\n");
#ifdef DBG_JCG
gQAppCount--;
printf("JCG nsQApplication DTOR (%p) ID: %d, Count: %d\n",this,mID,gQAppCount);
#endif
setGlobalMouseTracking(false);
printf("Exit: QApplication::~QApplication\n");
}
void nsQApplication::AddEventProcessorCallback(nsIEventQueue* EQueue)
{
nsQtEventQueue* que = nsnull;
if ((que = mQueueDict.find(EQueue->GetEventQueueSelectFD()))) {
que->IncRefCnt();
}
else {
mQueueDict.insert(EQueue->GetEventQueueSelectFD(),
new nsQtEventQueue(EQueue));
}
}
void nsQApplication::RemoveEventProcessorCallback(nsIEventQueue* EQueue)
{
nsQtEventQueue* que = nsnull;
if ((que = mQueueDict.find(EQueue->GetEventQueueSelectFD()))) {
que->DataReceived();
if (que->DecRefCnt() <= 0) {
mQueueDict.take(EQueue->GetEventQueueSelectFD());
delete que;
}
}
}
/* Hook for capturing X11 Events before they are processed by Qt */
bool nsQApplication::x11EventFilter(XEvent* event)
{
#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;
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;
}
nsQtEventQueue::nsQtEventQueue(nsIEventQueue* EQueue)
{
#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()));
}
nsQtEventQueue::~nsQtEventQueue()
{
#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;
}
unsigned long nsQtEventQueue::DecRefCnt()
{
return --mRefCnt;
}
void nsQtEventQueue::DataReceived()
{
if (mEventQueue)
mEventQueue->ProcessPendingEvents();
}

Просмотреть файл

@ -1,93 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsQApplication_h__
#define nsQApplication_h__
#include "nsIEventQueue.h"
#include <qapplication.h>
#include <qsocketnotifier.h>
#include <qintdict.h>
class nsQtEventQueue : public QObject
{
Q_OBJECT
public:
nsQtEventQueue(nsIEventQueue *EQueue);
~nsQtEventQueue();
unsigned long IncRefCnt();
unsigned long DecRefCnt();
public slots:
void DataReceived();
private:
nsIEventQueue *mEventQueue;
QSocketNotifier *mQSocket;
PRUint32 mRefCnt;
PRInt32 mID;
};
class nsQApplication : public QApplication
{
Q_OBJECT
public:
static nsQApplication *Instance(int argc,char **argv);
static void Release();
static void AddEventProcessorCallback(nsIEventQueue *EQueue);
static void RemoveEventProcessorCallback(nsIEventQueue *EQueue);
static QWidget *GetMasterWidget();
///Hook for debugging X11 Events
bool x11EventFilter(XEvent *event);
protected:
nsQApplication(int argc,char **argv);
~nsQApplication();
private:
PRInt32 mID;
static QIntDict<nsQtEventQueue> mQueueDict;
static nsQApplication *mInstance;
static PRUint32 mRefCnt;
static QWidget *mMasterWidget;
};
#endif // nsQApplication_h__

Просмотреть файл

@ -1,806 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsWidget.h"
#include "nsWindow.h"
#include "nsGUIEvent.h"
#include "nsQEventHandler.h"
//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);
#if 0 //JCG
struct nsKeyConverter
{
int vkCode; // Platform independent key code
int keysym; // QT key code
};
struct nsKeyConverter nsKeycodes[] =
{
// { NS_VK_CANCEL, Qt::Key_Cancel },
{ NS_VK_BACK, Qt::Key_BackSpace },
{ NS_VK_TAB, Qt::Key_Tab },
// { NS_VK_CLEAR, Qt::Key_Clear },
{ NS_VK_RETURN, Qt::Key_Return },
{ NS_VK_RETURN, Qt::Key_Enter },
{ NS_VK_SHIFT, Qt::Key_Shift },
{ NS_VK_CONTROL, Qt::Key_Control },
{ NS_VK_ALT, Qt::Key_Alt },
{ NS_VK_ALT, Qt::Key_Meta },
{ NS_VK_PAUSE, Qt::Key_Pause },
{ NS_VK_CAPS_LOCK, Qt::Key_CapsLock },
{ NS_VK_ESCAPE, Qt::Key_Escape },
{ NS_VK_SPACE, Qt::Key_Space },
{ NS_VK_PAGE_UP, Qt::Key_PageUp },
{ NS_VK_PAGE_DOWN, Qt::Key_PageDown },
{ NS_VK_END, Qt::Key_End },
{ NS_VK_HOME, Qt::Key_Home },
{ NS_VK_LEFT, Qt::Key_Left },
{ NS_VK_UP, Qt::Key_Up },
{ NS_VK_RIGHT, Qt::Key_Right },
{ NS_VK_DOWN, Qt::Key_Down },
{ NS_VK_PRINTSCREEN, Qt::Key_Print },
{ NS_VK_INSERT, Qt::Key_Insert },
{ NS_VK_DELETE, Qt::Key_Delete },
{ NS_VK_0, Qt::Key_0 },
{ NS_VK_1, Qt::Key_1 },
{ NS_VK_2, Qt::Key_2 },
{ NS_VK_3, Qt::Key_3 },
{ NS_VK_4, Qt::Key_4 },
{ NS_VK_5, Qt::Key_5 },
{ NS_VK_6, Qt::Key_6 },
{ NS_VK_7, Qt::Key_7 },
{ NS_VK_8, Qt::Key_8 },
{ NS_VK_9, Qt::Key_9 },
{ NS_VK_SEMICOLON, Qt::Key_Semicolon },
{ NS_VK_EQUALS, Qt::Key_Equal },
{ NS_VK_A, Qt::Key_A },
{ NS_VK_B, Qt::Key_B },
{ NS_VK_C, Qt::Key_C },
{ NS_VK_D, Qt::Key_D },
{ NS_VK_E, Qt::Key_E },
{ NS_VK_F, Qt::Key_F },
{ NS_VK_G, Qt::Key_G },
{ NS_VK_H, Qt::Key_H },
{ NS_VK_I, Qt::Key_I },
{ NS_VK_J, Qt::Key_J },
{ NS_VK_K, Qt::Key_K },
{ NS_VK_L, Qt::Key_L },
{ NS_VK_M, Qt::Key_M },
{ NS_VK_N, Qt::Key_N },
{ NS_VK_O, Qt::Key_O },
{ NS_VK_P, Qt::Key_P },
{ NS_VK_Q, Qt::Key_Q },
{ NS_VK_R, Qt::Key_R },
{ NS_VK_S, Qt::Key_S },
{ NS_VK_T, Qt::Key_T },
{ NS_VK_U, Qt::Key_U },
{ NS_VK_V, Qt::Key_V },
{ NS_VK_W, Qt::Key_W },
{ NS_VK_X, Qt::Key_X },
{ NS_VK_Y, Qt::Key_Y },
{ NS_VK_Z, Qt::Key_Z },
{ NS_VK_NUMPAD0, Qt::Key_0 },
{ NS_VK_NUMPAD1, Qt::Key_1 },
{ NS_VK_NUMPAD2, Qt::Key_2 },
{ NS_VK_NUMPAD3, Qt::Key_3 },
{ NS_VK_NUMPAD4, Qt::Key_4 },
{ NS_VK_NUMPAD5, Qt::Key_5 },
{ NS_VK_NUMPAD6, Qt::Key_6 },
{ NS_VK_NUMPAD7, Qt::Key_7 },
{ NS_VK_NUMPAD8, Qt::Key_8 },
{ NS_VK_NUMPAD9, Qt::Key_9 },
{ NS_VK_MULTIPLY, Qt::Key_Asterisk },
{ NS_VK_ADD, Qt::Key_Plus },
// { NS_VK_SEPARATOR, Qt::Key_Separator },
{ NS_VK_SUBTRACT, Qt::Key_Minus },
{ NS_VK_DECIMAL, Qt::Key_Period },
{ NS_VK_DIVIDE, Qt::Key_Slash },
{ NS_VK_F1, Qt::Key_F1 },
{ NS_VK_F2, Qt::Key_F2 },
{ NS_VK_F3, Qt::Key_F3 },
{ NS_VK_F4, Qt::Key_F4 },
{ NS_VK_F5, Qt::Key_F5 },
{ NS_VK_F6, Qt::Key_F6 },
{ NS_VK_F7, Qt::Key_F7 },
{ NS_VK_F8, Qt::Key_F8 },
{ NS_VK_F9, Qt::Key_F9 },
{ NS_VK_F10, Qt::Key_F10 },
{ NS_VK_F11, Qt::Key_F11 },
{ NS_VK_F12, Qt::Key_F12 },
{ NS_VK_F13, Qt::Key_F13 },
{ NS_VK_F14, Qt::Key_F14 },
{ NS_VK_F15, Qt::Key_F15 },
{ NS_VK_F16, Qt::Key_F16 },
{ NS_VK_F17, Qt::Key_F17 },
{ NS_VK_F18, Qt::Key_F18 },
{ NS_VK_F19, Qt::Key_F19 },
{ NS_VK_F20, Qt::Key_F20 },
{ NS_VK_F21, Qt::Key_F21 },
{ NS_VK_F22, Qt::Key_F22 },
{ NS_VK_F23, Qt::Key_F23 },
{ NS_VK_F24, Qt::Key_F24 },
{ NS_VK_NUM_LOCK, Qt::Key_NumLock },
{ NS_VK_SCROLL_LOCK, Qt::Key_ScrollLock },
{ NS_VK_COMMA, Qt::Key_Comma },
{ NS_VK_PERIOD, Qt::Key_Period },
{ NS_VK_SLASH, Qt::Key_Slash },
{ NS_VK_BACK_QUOTE, Qt::Key_QuoteLeft },
{ NS_VK_OPEN_BRACKET, Qt::Key_ParenLeft },
{ NS_VK_CLOSE_BRACKET, Qt::Key_ParenRight },
{ NS_VK_QUOTE, Qt::Key_QuoteDbl }
};
#endif //JCG
PRLogModuleInfo * QtEventsLM = PR_NewLogModule("QtEvents");
/**
* Constructor for QT event handler.
*
*/
nsQEventHandler::nsQEventHandler(nsWidget *aWidget) : QObject()
{
PR_LOG(QtEventsLM, PR_LOG_DEBUG, ("nsQEventHandler::nsQEventHandler()\n"));
mEnabled = true;
mDestroyed = false;
mWidget = aWidget;
#ifdef DBG_JCG
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_JCG
gQEventHandlerCount--;
printf("JCG: nsQEventHandler DTOR. Count: %d\n",gQEventHandlerCount);
#endif
}
void nsQEventHandler::Enable(bool aEnable)
{
mEnabled = aEnable;
}
void nsQEventHandler::Destroy()
{
mDestroyed = true;
mWidget = nsnull;
}
bool nsQEventHandler::eventFilter(QObject* object, QEvent* event)
{
bool handled = false;
if (mDestroyed)
return true;
switch (event->type()) {
#if 0 //JCG
case QEvent::MouseButtonPress:
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) {
#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) {
#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) {
#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) {
#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) {
#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) {
#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) {
#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()) {
#ifdef DBG_JCG
printf("JCG: Close widget: %p\n",mWidget);
#endif
handled = DestroyEvent((QCloseEvent*)event, mWidget);
}
break;
case QEvent::Destroy:
#ifdef DBG_JCG
printf("JCG: Destroy widget: %p\n",mWidget);
#endif
handled = DestroyEvent((QCloseEvent*)event, mWidget);
break;
case QEvent::Resize:
#ifdef DBG_JCG
printf("JCG: Resize widget: %p\n",mWidget);
#endif
handled = ResizeEvent((QResizeEvent*)event, mWidget);
break;
case QEvent::Move:
#ifdef DBG_JCG
printf("JCG: Move widget: %p\n",mWidget);
#endif
handled = MoveEvent((QMoveEvent*)event, mWidget);
break;
#endif //JCG
case QEvent::Paint:
#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) {
#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) {
#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)
{
if (event && widget) {
nsMouseEvent nsEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::MouseButtonEvent for %s(%p) at (%d,%y)\n",
widget->GetName(), widget, event->x(), event->y()));
switch (event->button()) {
case LeftButton:
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;
break;
case MidButton:
nsEvent.message = buttonDown ? NS_MOUSE_MIDDLE_BUTTON_DOWN
: NS_MOUSE_MIDDLE_BUTTON_UP;
break;
default:
// This shouldn't happen!
NS_ASSERTION(0, "Bad MousePressedEvent!");
nsEvent.message = NS_MOUSE_MOVE;
break;
}
nsEvent.point.x = event->x();
nsEvent.point.y = event->y();
nsEvent.widget = widget;
nsEvent.nativeMsg = (void*)event;
nsEvent.eventStructType = NS_MOUSE_EVENT;
nsEvent.clickCount = clickCnt;
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;
nsEvent.time = PR_IntervalNow();
widget->AddRef();
widget->DispatchMouseEvent(nsEvent);
widget->Release();
}
/* Below are a series of slimey hacks to do the right thing with */
/* Mouse Events - Qt gets a go at all events for native widgets */
/* (i.e. NOT nsWidget or nsWindow) and at Button Press Events for */
/* 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) {
handled = false;
}
}
else {
handled = false;
}
}
return handled;
}
bool nsQEventHandler::MouseMovedEvent(QMouseEvent *event,
nsWidget *widget)
{
if (event && widget) {
// Generate XPFE mouse moved event
nsMouseEvent nsEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::MouseMovedEvent for %s(%p) at (%d,%d)\n",
widget->GetName(), widget, event->x(), event->y()));
nsEvent.point.x = event->x();
nsEvent.point.y = event->y();
nsEvent.message = NS_MOUSE_MOVE;
nsEvent.widget = widget;
nsEvent.nativeMsg = (void*)event;
nsEvent.eventStructType = NS_MOUSE_EVENT;
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();
}
/* Below are a series of slimey hacks to do the right thing with */
/* Mouse Move Events - Qt only gets a go at events for non-deleted */
/* 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")) {
handled = true;
}
}
else
handled = true;
return handled;
}
bool nsQEventHandler::MouseEnterEvent(QEvent *event,
nsWidget *widget)
{
if (event && widget) {
nsMouseEvent nsEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::MouseEnterEvent for %s\n",
widget->GetName()));
nsEvent.message = NS_MOUSE_ENTER;
nsEvent.widget = widget;
nsEvent.nativeMsg = (void*)event;
nsEvent.eventStructType = NS_MOUSE_EVENT;
nsEvent.time = PR_IntervalNow();
widget->AddRef();
widget->DispatchMouseEvent(nsEvent);
widget->Release();
}
return true;
}
bool nsQEventHandler::MouseExitEvent(QEvent *event,
nsWidget *widget)
{
if (event && widget) {
nsMouseEvent nsEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::MouseExitEvent for %s\n",
widget->GetName()));
nsEvent.message = NS_MOUSE_EXIT;
nsEvent.widget = widget;
nsEvent.nativeMsg = (void*)event;
nsEvent.eventStructType = NS_MOUSE_EVENT;
nsEvent.time = PR_IntervalNow();
widget->AddRef();
widget->DispatchMouseEvent(nsEvent);
widget->Release();
}
return true;
}
bool nsQEventHandler::DestroyEvent(QCloseEvent *event,
nsWidget *widget)
{
if (event && widget) {
// Generate XPFE destroy event
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::DestroyEvent for %s\n",
widget->GetName()));
widget->Destroy();
}
return true;
}
bool nsQEventHandler::ResizeEvent(QResizeEvent *event,
nsWidget *widget)
{
if (event && widget) {
// Generate XPFE resize event
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::ResizeEvent for %s(%p)\n",
widget->GetName(),
widget));
nsRect rect;
widget->GetBounds(rect);
rect.width = event->size().width();
rect.height = event->size().height();
widget->OnResize(rect);
}
return false;
}
bool nsQEventHandler::MoveEvent(QMoveEvent *event,
nsWidget *widget)
{
if (event && widget) {
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::MoveEvent for %s\n",
widget->GetName()));
// Generate XPFE move event
widget->OnMove(event->pos().x(),event->pos().y());
}
return true;
}
bool nsQEventHandler::PaintEvent(QPaintEvent *event,
nsWidget *widget)
{
if (event && widget) {
// Generate XPFE paint event
nsPaintEvent nsEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::PaintEvent for %s(%p)\n",
widget->GetName(),
widget));
nsEvent.message = NS_PAINT;
nsEvent.widget = widget;
nsEvent.eventStructType = NS_PAINT_EVENT;
nsEvent.time = PR_IntervalNow();
PR_LOG(QtEventsLM,PR_LOG_DEBUG,
("nsQEventHandler::PaintEvent: need to paint:x=%d,y=%d,w=%d,h=%d\n",
event->rect().x(),event->rect().y(),
event->rect().width(),event->rect().height()));
nsRect rect(event->rect().x(),event->rect().y(),
event->rect().width(),event->rect().height());
nsEvent.rect = &rect;
widget->AddRef();
widget->OnPaint(nsEvent);
widget->Release();
}
if (widget && widget->GetName() == QWidget::tr("nsWindow")
|| widget->GetName() == QWidget::tr("nsWidget")) {
return true;
}
else {
return false;
}
}
bool nsQEventHandler::KeyPressEvent(QKeyEvent *event,
nsWidget *widget)
{
if (event && widget) {
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::KeyPressEvent for %s\n",
widget->GetName()));
if (event->key() == Qt::Key_Shift
|| event->key() == Qt::Key_Control
|| event->key() == Qt::Key_Alt)
return false;
nsKeyEvent nsEvent;
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;
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.charCode = 0;
widget->AddRef();
((nsWindow*)widget)->OnKey(nsEvent);
nsEvent.message = NS_KEY_PRESS;
nsEvent.eventStructType = NS_KEY_EVENT;
nsEvent.widget = widget;
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();
if (event->text().length() && event->text()[0].isPrint()) {
nsEvent.charCode = (PRInt32)event->text()[0].unicode();
}
else {
nsEvent.charCode = 0;
}
if (nsEvent.charCode) {
nsEvent.keyCode = 0;
}
else
nsEvent.keyCode = GetNSKey(event->key(),event->state());
((nsWindow*)widget)->OnKey(nsEvent);
widget->Release();
}
return true;
}
bool nsQEventHandler::KeyReleaseEvent(QKeyEvent *event,
nsWidget *widget)
{
if (event && widget) {
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::KeyReleaseEvent for %s\n",
widget->GetName()));
if (event->key() == Qt::Key_Shift || event->key() == Qt::Key_Control
|| event->key() == Qt::Key_Alt)
return false;
nsKeyEvent nsEvent;
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();
widget->AddRef();
((nsWindow*)widget)->OnKey(nsEvent);
widget->Release();
}
return true;
}
#if 0 //JCG
PRInt32 nsQEventHandler::GetNSKey(PRInt32 key,PRInt32 state)
{
PRInt32 length = sizeof(nsKeycodes) / sizeof(nsKeyConverter);
for (PRInt32 i = 0; i < length; i++) {
if (nsKeycodes[i].keysym == key) {
return nsKeycodes[i].vkCode;
}
}
return 0;
}
#endif //JCG
bool nsQEventHandler::FocusInEvent(QFocusEvent *event,
nsWidget *widget)
{
if (event && widget) {
nsGUIEvent aEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::FocusInEvent for %s\n",
widget->GetName()));
aEvent.message = NS_GOTFOCUS;
aEvent.eventStructType = NS_GUI_EVENT;
aEvent.widget = widget;
aEvent.time = PR_IntervalNow();
aEvent.point.x = 0;
aEvent.point.y = 0;
widget->AddRef();
((nsWindow*)widget)->DispatchFocus(aEvent);
widget->Release();
}
return true;
}
bool nsQEventHandler::FocusOutEvent(QFocusEvent *event,
nsWidget *widget)
{
if (event && widget) {
nsGUIEvent aEvent;
PR_LOG(QtEventsLM,
PR_LOG_DEBUG,
("nsQEventHandler::FocusOutEvent for %s\n",
widget->GetName()));
aEvent.message = NS_LOSTFOCUS;
aEvent.eventStructType = NS_GUI_EVENT;
aEvent.widget = widget;
aEvent.time = PR_IntervalNow();
aEvent.point.x = 0;
aEvent.point.y = 0;
widget->AddRef();
((nsWindow*)widget)->DispatchFocus(aEvent);
widget->Release();
}
return true;
}

Просмотреть файл

@ -1,82 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsQTEventHandler_h
#define __nsQTEventHandler_h
#include "nsWidget.h"
#include <qobject.h>
#include <qevent.h>
class nsQEventHandler : public QObject
{
Q_OBJECT
public:
nsQEventHandler(nsWidget *aWidget);
~nsQEventHandler();
void Enable(bool aEnable);
void Destroy();
bool eventFilter(QObject * object, QEvent * event);
bool MouseButtonEvent(QMouseEvent *event,nsWidget *widget,
bool buttonDown,int clickCnt);
bool MouseMovedEvent(QMouseEvent * event, nsWidget * widget);
bool MouseEnterEvent(QEvent * event, nsWidget * widget);
bool MouseExitEvent(QEvent * event, nsWidget * widget);
bool DestroyEvent(QCloseEvent * event, nsWidget * widget);
bool HideEvent(QHideEvent * event, nsWidget * widget);
bool ResizeEvent(QResizeEvent * event, nsWidget * widget);
bool MoveEvent(QMoveEvent * event, nsWidget * widget);
bool PaintEvent(QPaintEvent * event, nsWidget * widget);
bool KeyPressEvent(QKeyEvent * event, nsWidget * widget);
bool KeyReleaseEvent(QKeyEvent * event, nsWidget * widget);
bool FocusInEvent(QFocusEvent * event, nsWidget * widget);
bool FocusOutEvent(QFocusEvent * event, nsWidget * widget);
protected:
PRInt32 GetNSKey(PRInt32 key, PRInt32 state);
private:
nsWidget *mWidget;
bool mEnabled;
bool mDestroyed;
};
#endif // __nsQEventHandler.h

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,189 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <jcgriggs@sympatico.ca>
* Denis Issoupov <denis@macadamian.com>
* Wes Morgan <wmorga13@calvin.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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() { printf("ESBEN: Show called\n"); mQWidget->show();};
virtual void Hide() {mQWidget->hide();};
virtual PRBool IsVisible() {return mQWidget->isVisible();};
virtual void SetFocus() {mQWidget->setFocus();};
virtual void SetTopLevelFocus() {mQWidget->topLevelWidget()->setFocus();};
virtual void RaiseTopLevel() {mQWidget->topLevelWidget()->raise();};
virtual PRBool IsTopLevelActive()
{
return(mQWidget->topLevelWidget()->isActiveWindow());
};
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 Polish() {mQWidget->polish();};
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 MouseWheelEvent(QWheelEvent *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__

Просмотреть файл

@ -1,402 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScrollbar.h"
#include "nsGUIEvent.h"
//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
//=============================================================================
// nsQBaseScrollBar class
//=============================================================================
nsQBaseScrollBar::nsQBaseScrollBar(nsWidget *aWidget)
: nsQBaseWidget(aWidget)
{
#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::closeEvent(QCloseEvent *aEvent)
{
aEvent->ignore();
}
//=============================================================================
// 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()
{
#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()
{
#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)
{
mMaxValue = aEndRange;
((nsQBaseScrollBar*)mWidget)->SetRange(0,mMaxValue - mPageStep);
return NS_OK;
}
//-------------------------------------------------------------------------
// Return the range settings
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetMaxRange(PRUint32 &aMaxRange)
{
aMaxRange = mMaxValue;
return NS_OK;
}
//-------------------------------------------------------------------------
// Set the thumb position
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos)
{
mValue = aPos;
((nsQBaseScrollBar*)mWidget)->SetValue(mValue);
return NS_OK;
}
//-------------------------------------------------------------------------
// Get the current thumb position.
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetPosition(PRUint32 &aPos)
{
aPos = mValue;
return NS_OK;
}
//-------------------------------------------------------------------------
// Set the thumb size
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize)
{
if (aSize > 0) {
mPageStep = aSize;
((nsQBaseScrollBar*)mWidget)->SetSteps(mLineStep,mPageStep);
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Get the thumb size
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetThumbSize(PRUint32 &aThumbSize)
{
aThumbSize = mPageStep;
return NS_OK;
}
//-------------------------------------------------------------------------
// Set the line increment for this scrollbar
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement)
{
if (aLineIncrement > 0) {
mLineStep = aLineIncrement;
((nsQBaseScrollBar*)mWidget)->SetSteps(mLineStep,mPageStep);
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Get the line increment for this scrollbar
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 &aLineInc)
{
aLineInc = mLineStep;
return NS_OK;
}
//-------------------------------------------------------------------------
// Set all scrolling parameters
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange,PRUint32 aThumbSize,
PRUint32 aPosition,PRUint32 aLineIncrement)
{
mPageStep = (aThumbSize > 0) ? aThumbSize : 1;
mValue = (aPosition > 0) ? aPosition : 0;
mLineStep = (aLineIncrement > 0) ? aLineIncrement : 1;
mMaxValue = (aMaxRange > 0) ? aMaxRange : 10;
((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 result = PR_TRUE;
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;
// 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;
// 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;
// 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;
// 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;
}
return result;
}
//-------------------------------------------------------------------------
// Create the native scrollbar widget
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::CreateNative(QWidget *aParentWindow)
{
mWidget = new nsQBaseScrollBar(this);
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);
}

Просмотреть файл

@ -1,155 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScrollbar_h__
#define nsScrollbar_h__
#include "nsWidget.h"
#include "nsQWidget.h"
#include "nsIScrollbar.h"
#include <qscrollbar.h>
//=============================================================================
// 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 nsQBaseScrollBar : public nsQBaseWidget
{
Q_OBJECT
public:
nsQBaseScrollBar(nsWidget *aWidget);
~nsQBaseScrollBar();
/*** 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 ValueChanged(int aValue);
private:
PRUint32 mQBaseSBID;
};
//=============================================================================
// 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,351 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsTextHelper.h"
#include "nsTextWidget.h"
#include "nsToolkit.h"
#include "nsColor.h"
#include "nsGUIEvent.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsWindow.h"
#include <qlineedit.h>
#include <qmultilineedit.h>
#define DBG 0
//-------------------------------------------------------------------------
//
// nsTextHelper constructor
//
//-------------------------------------------------------------------------
nsTextHelper::nsTextHelper() : nsWidget(), nsITextWidget()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::nsTextHelper()\n"));
mIsReadOnly = PR_FALSE;
mIsPassword = PR_FALSE;
}
//-------------------------------------------------------------------------
//
// nsTextHelper destructor
//
//-------------------------------------------------------------------------
nsTextHelper::~nsTextHelper()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::~nsTextHelper()\n"));
}
//-------------------------------------------------------------------------
//
// Set initial parameters
//
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::PreCreateWidget(nsWidgetInitData *aInitData)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::PreCreateWidget()\n"));
if (nsnull != aInitData)
{
nsTextWidgetInitData* data = (nsTextWidgetInitData *) aInitData;
mIsPassword = data->mIsPassword;
mIsReadOnly = data->mIsReadOnly;
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SetMaxTextLength(PRUint32 aChars)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetMaxTextLength()\n"));
if (mWidget->isA("nsQLineEdit"))
{
((QLineEdit *)mWidget)->setMaxLength((int) aChars);
}
else
{
//((QMultiLineEdit *)mWidget)->setMaxLength((int) aChars);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::GetText(nsString& aTextBuffer,
PRUint32 aBufferSize,
PRUint32& aActualSize)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::GetText()\n"));
QString string;
if (mWidget->isA("nsQLineEdit"))
{
string = ((QLineEdit *)mWidget)->text();
}
else
{
string = ((QMultiLineEdit *)mWidget)->text();
}
aTextBuffer.SetLength(0);
aTextBuffer.AppendWithConversion((const char *) string);
aActualSize = (PRUint32) string.length();
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SetText(const nsString& aText, PRUint32& aActualSize)
{
char *buf = ToNewCString(aText);
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetText to \"%s\"\n",
buf));
QString string = buf;
//mWidget->setUpdatesEnabled(PR_FALSE);
if (mWidget->isA("nsQLineEdit"))
{
((QLineEdit *)mWidget)->setText(string);
}
else
{
((QMultiLineEdit *)mWidget)->setText(string);
}
//mWidget->setUpdatesEnabled(PR_TRUE);
aActualSize = aText.Length();
delete[] buf;
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::InsertText(const nsString &aText,
PRUint32 aStartPos,
PRUint32 aEndPos,
PRUint32& aActualSize)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::InsertText()\n"));
nsString currentText;
PRUint32 actualSize;
GetText(currentText, 256, actualSize);
nsString newText(aText);
currentText.Insert(newText, aStartPos);
SetText(currentText,actualSize);
aActualSize = aText.Length();
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::RemoveText()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::RemoveText()\n"));
if (mWidget->isA("nsQLineEdit"))
{
((QLineEdit *)mWidget)->clear();
}
else
{
((QMultiLineEdit *)mWidget)->clear();
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetPassword()\n"));
if (mWidget->isA("nsQLineEdit"))
{
QLineEdit::EchoMode mode = aIsPassword ?
QLineEdit::Password :
QLineEdit::Normal;
((QLineEdit *)mWidget)->setEchoMode(mode);
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag,
PRBool& aOldReadOnlyFlag)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetReadOnly()\n"));
NS_ASSERTION(nsnull != mWidget,
"SetReadOnly - Widget is NULL, Create may not have been called!");
aOldReadOnlyFlag = mIsReadOnly;
mIsReadOnly = aReadOnlyFlag?PR_FALSE:PR_TRUE;
if (mWidget->isA("nsQLineEdit"))
{
((QLineEdit *)mWidget)->setEnabled(mIsReadOnly);
}
else
{
((QMultiLineEdit *)mWidget)->setReadOnly(mIsReadOnly);
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SelectAll()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SelectAll()\n"));
if (mWidget->isA("nsQLineEdit"))
{
((QLineEdit *)mWidget)->selectAll();
}
else
{
((QMultiLineEdit *)mWidget)->selectAll();
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetSelection()\n"));
if (mWidget->isA("nsQLineEdit"))
{
if (aStartSel || aEndSel)
{
((QLineEdit *)mWidget)->setSelection(aStartSel, aEndSel - aStartSel);
}
else
{
((QLineEdit *)mWidget)->deselect();
}
}
else
{
//((QMultiLineEdit *)mWidget)->setSelection(aStartSel,
// aEndSel - aStartSel);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::GetSelection()\n"));
if (mWidget->isA("nsQLineEdit"))
{
if (((QLineEdit *)mWidget)->hasMarkedText())
{
QString string = ((QLineEdit *)mWidget)->markedText();
PRUint32 actualSize = 0;
nsString text;
GetText(text, 0, actualSize);
PRInt32 start = text.Find((const char *)string);
if (start >= 0)
{
*aStartSel = start;
*aEndSel = *aStartSel + string.length();
}
else
{
return NS_ERROR_FAILURE;
}
}
else
{
*aStartSel = 0;
*aEndSel = 0;
}
}
else
{
return NS_ERROR_FAILURE;
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::SetCaretPosition(PRUint32 aPosition)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetCaretPosition()\n"));
if (mWidget->isA("nsQLineEdit"))
{
((QLineEdit *)mWidget)->setCursorPosition((int) aPosition);
}
else
{
// based on the index into the text field, calculate the row and
// column.
int row = 0;
int col = 0;
((QMultiLineEdit *)mWidget)->setCursorPosition(row, col);
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_METHOD nsTextHelper::GetCaretPosition(PRUint32& aPosition)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::GetCaretPosition()\n"));
if (mWidget->isA("nsQLineEdit"))
{
aPosition = (PRUint32) ((QLineEdit *)mWidget)->cursorPosition();
}
return NS_OK;
}

Просмотреть файл

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTextHelper_h__
#define nsTextHelper_h__
#include "nsITextWidget.h"
#include "nsWidget.h"
/**
* Base class for nsTextAreaWidget (obsolete) and nsTextWidget
*/
class nsTextHelper : public nsWidget,
public nsITextWidget
{
public:
nsTextHelper();
virtual ~nsTextHelper();
NS_IMETHOD SelectAll();
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
NS_IMETHOD SetMaxTextLength(PRUint32 aChars);
NS_IMETHOD GetText(nsString& aTextBuffer,
PRUint32 aBufferSize,
PRUint32& aActualSize);
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize);
NS_IMETHOD InsertText(const nsString &aText,
PRUint32 aStartPos,
PRUint32 aEndPos,
PRUint32& aActualSize);
NS_IMETHOD RemoveText();
NS_IMETHOD SetPassword(PRBool aIsPassword);
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag,
PRBool& aOldReadOnlyFlag);
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
NS_IMETHOD SetCaretPosition(PRUint32 aPosition);
NS_IMETHOD GetCaretPosition(PRUint32& aPosition);
protected:
PRBool mIsPassword;
PRBool mIsReadOnly;
};
#endif // nsTextHelper_h__

Просмотреть файл

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsTextWidget.h"
#include "nsToolkit.h"
#include "nsColor.h"
#include "nsGUIEvent.h"
#include "nsString.h"
#define DBG 0
extern int mIsPasswordCallBacksInstalled;
//=============================================================================
//
// nsQLineEdit class
//
//=============================================================================
nsQLineEdit::nsQLineEdit(nsWidget * widget,
QWidget * parent,
const char * name)
: QLineEdit(parent, name), nsQBaseWidget(widget)
{
}
nsQLineEdit::~nsQLineEdit()
{
}
NS_IMPL_ADDREF_INHERITED(nsTextWidget, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsTextWidget, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsTextWidget, nsITextWidget, nsIWidget)
//-------------------------------------------------------------------------
//
// nsTextWidget constructor
//
//-------------------------------------------------------------------------
nsTextWidget::nsTextWidget() : nsTextHelper()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextWidget::nsTextWidget()\n"));
}
//-------------------------------------------------------------------------
//
// nsTextWidget destructor
//
//-------------------------------------------------------------------------
nsTextWidget::~nsTextWidget()
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextWidget::~nsTextWidget()\n"));
}
//-------------------------------------------------------------------------
//
// paint, resizes message - ignore
//
//-------------------------------------------------------------------------
PRBool nsTextWidget::OnPaint(nsPaintEvent & aEvent)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextWidget::OnPaint()\n"));
return PR_FALSE;
}
//--------------------------------------------------------------
PRBool nsTextWidget::OnResize(nsRect &aRect)
{
PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextWidget::OnResize()\n"));
return PR_FALSE;
}

Просмотреть файл

@ -1,78 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTextWidget_h__
#define nsTextWidget_h__
#include "nsWidget.h"
#include "nsTextHelper.h"
#include "nsITextWidget.h"
#include <qlineedit.h>
//=============================================================================
//
// nsQLineEdit class
//
//=============================================================================
class nsQLineEdit : public QLineEdit, public nsQBaseWidget
{
Q_OBJECT
public:
nsQLineEdit(nsWidget * widget,
QWidget * parent = 0,
const char * name = 0);
~nsQLineEdit();
};
/**
* Native QT single line edit control wrapper.
*/
class nsTextWidget : public nsTextHelper
{
public:
nsTextWidget();
virtual ~nsTextWidget();
NS_DECL_ISUPPORTS_INHERITED
virtual PRBool OnPaint(nsPaintEvent & aEvent);
virtual PRBool OnResize(nsRect &aRect);
};
#endif // nsTextWidget_h__

Просмотреть файл

@ -1,117 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h" // needed for 'nsnull'
#include "nsToolkit.h"
#include "nsGUIEvent.h"
#include "plevent.h"
// Static thread local storage index of the Toolkit
// object associated with a given thread...
static PRUintn gToolkitTLSIndex = 0;
//-------------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------------
nsToolkit::nsToolkit()
{
}
//-------------------------------------------------------------------------
// destructor
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
// 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)
{
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)
{
nsIToolkit* toolkit = nsnull;
nsresult rv = NS_OK;
PRStatus status;
// Create the TLS index the first time through...
if (0 == gToolkitTLSIndex) {
status = PR_NewThreadPrivateIndex(&gToolkitTLSIndex, NULL);
if (PR_FAILURE == status) {
rv = NS_ERROR_FAILURE;
}
}
if (NS_SUCCEEDED(rv)) {
toolkit = (nsIToolkit*)PR_GetThreadPrivate(gToolkitTLSIndex);
// Create a new toolkit for this thread...
if (!toolkit) {
toolkit = new nsToolkit();
if (!toolkit) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
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 {
NS_ADDREF(toolkit);
}
*aResult = toolkit;
}
return rv;
}

Просмотреть файл

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsToolkit_h__
#define nsToolkit_h__
#include "nsIToolkit.h"
/**
* 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();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(PRThread *aThread);
};
#endif // nsToolkit_h__

Просмотреть файл

@ -1,892 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <jcgriggs@sympatico.ca>
* Wes Morgan <wmorga13@calvin.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsWidget.h"
#include "nsIDeviceContext.h"
#include "nsGfxCIID.h"
#include "nsIComponentManager.h"
#include "nsIMenuRollup.h"
#include "nsFontMetricsQT.h"
#include "nsReadableUtils.h"
#include <qapplication.h>
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
nsCOMPtr<nsIRollupListener> nsWidget::gRollupListener;
nsWeakPtr nsWidget::gRollupWidget;
PRBool nsWidget::gRollupConsumeRollupEvent = PR_FALSE;
//JCG #define DBG_JCG 1
#ifdef DBG_JCG
PRUint32 gWidgetCount = 0;
PRUint32 gWidgetID = 0;
#endif
nsWidget::nsWidget()
{
// get the proper color from the look and feel code
nsILookAndFeel *lookAndFeel;
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID,
nsnull,
kILookAndFeelIID,
(void**)&lookAndFeel)) {
lookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground,
mBackground);
}
NS_IF_RELEASE(lookAndFeel);
mWidget = nsnull;
mParent = nsnull;
mPreferredWidth = 0;
mPreferredHeight = 0;
mBounds.x = 0;
mBounds.y = 0;
mBounds.width = 0;
mBounds.height = 0;
mListenForResizes = PR_FALSE;
mIsToplevel = PR_FALSE;
mUpdateArea = do_CreateInstance(kRegionCID);
if (mUpdateArea) {
mUpdateArea->Init();
mUpdateArea->SetTo(0,0,0,0);
}
#ifdef DBG_JCG
gWidgetCount++;
mWidgetID = gWidgetID++;
printf("JCG: nsWidget CTOR (%p). ID: %d, Count: %d\n",this,mWidgetID,gWidgetCount);
#endif
}
nsWidget::~nsWidget()
{
Destroy();
if (mWidget) {
delete mWidget;
mWidget = nsnull;
}
#ifdef DBG_JCG
gWidgetCount--;
if (mIsToplevel) {
printf("JCG: nsWidget DTOR (%p, ID: %d) of toplevel: %d widgets still exist.\n",
this,mWidgetID,gWidgetCount);
}
else {
printf("JCG: nsWidget DTOR (%p). ID: %d, Count: %d\n",this,mWidgetID,gWidgetCount);
}
#endif
}
NS_IMPL_ISUPPORTS_INHERITED2(nsWidget,nsBaseWidget,nsIKBStateControl,nsISupportsWeakReference)
const char *nsWidget::GetName()
{
return ((mWidget != nsnull) ? mWidget->Name() : "");
}
NS_IMETHODIMP nsWidget::WidgetToScreen(const nsRect& aOldRect,nsRect& aNewRect)
{
aNewRect.width = aOldRect.width;
aNewRect.height = aOldRect.height;
if (mWidget) {
PRInt32 X,Y;
mWidget->OffsetXYToGlobal(&X,&Y);
aNewRect.x = aOldRect.x + X;
aNewRect.y = aOldRect.y + Y;
}
return NS_OK;
}
NS_METHOD nsWidget::ScreenToWidget(const nsRect& aOldRect,nsRect& aNewRect)
{
if (mWidget) {
PRInt32 X,Y;
mWidget->OffsetXYFromGlobal(&X,&Y);
aNewRect.x = aOldRect.x + X;
aNewRect.y = aOldRect.y + Y;
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Close this nsWidget
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWidget::Destroy(void)
{
if (mIsDestroying)
return NS_OK;
mIsDestroying = PR_TRUE;
nsBaseWidget::Destroy();
if (mWidget) {
mWidget->Destroy();
}
if (PR_FALSE == mOnDestroyCalled)
OnDestroy();
mEventCallback = nsnull;
return NS_OK;
}
// make sure that we clean up here
void nsWidget::OnDestroy()
{
// release references to children, device context, toolkit + app shell
mOnDestroyCalled = PR_TRUE;
nsBaseWidget::OnDestroy();
// dispatch the event
// dispatching of the event may cause the reference count to drop to 0
// and result in this object being destroyed. To avoid that, add a
// reference and then release it after dispatching the event
nsCOMPtr<nsIWidget> kungFuDeathGrip = this;
DispatchStandardEvent(NS_DESTROY);
}
//-------------------------------------------------------------------------
// Get this nsWidget parent
//-------------------------------------------------------------------------
nsIWidget *nsWidget::GetParent(void)
{
nsIWidget *ret;
ret = mParent;
NS_IF_ADDREF(ret);
return ret;
}
//-------------------------------------------------------------------------
// Hide or show this component
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Show(PRBool bState)
{
printf("Show. bState=%s, mWidget=%p\n", bState?"true":"false", mWidget);
if (!mWidget) {
return NS_OK; // Will be null during printing
}
if (bState) {
mWidget->Show();
}
else {
mWidget->Hide();
}
return NS_OK;
}
NS_IMETHODIMP nsWidget::CaptureRollupEvents(nsIRollupListener *aListener,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
return NS_OK;
}
NS_IMETHODIMP nsWidget::SetModal(PRBool aModal)
{
if (mWidget)
mWidget->SetModal(aModal);
else
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_METHOD nsWidget::IsVisible(PRBool &aState)
{
if (mWidget) {
aState = mWidget->IsVisible();
}
else {
aState = PR_FALSE;
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Constrain a potential move so that it remains onscreen
//-------------------------------------------------------------------------
NS_METHOD nsWidget::ConstrainPosition(PRBool aAllowSlop,
PRInt32 *aX, PRInt32 *aY)
{
return NS_OK;
}
//-------------------------------------------------------------------------
// Move this component
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Move(PRInt32 aX, PRInt32 aY)
{
if (aX == mBounds.x && aY == mBounds.y) {
return NS_OK;
}
mBounds.x = aX;
mBounds.y = aY;
if (mWidget) {
mWidget->Move(aX, aY);
}
return NS_OK;
}
NS_METHOD nsWidget::Resize(PRInt32 aWidth,PRInt32 aHeight,PRBool aRepaint)
{
if (mWidget && (mWidget->Width() != aWidth
|| mWidget->Height() != aHeight)) {
mBounds.width = aWidth;
mBounds.height = aHeight;
mWidget->Resize(aWidth,aHeight);
if (mListenForResizes) {
nsSizeEvent sevent;
nsRect rect(0,0,aWidth,aHeight);
sevent.message = NS_SIZE;
sevent.widget = this;
sevent.eventStructType = NS_SIZE_EVENT;
sevent.windowSize = &rect;
sevent.point.x = 0;
sevent.point.y = 0;
sevent.mWinWidth = aWidth;
sevent.mWinHeight = aHeight;
sevent.time = PR_IntervalNow();
NS_ADDREF_THIS();
OnResize(sevent);
NS_RELEASE_THIS();
}
if (aRepaint) {
if (mWidget->IsVisible()) {
mWidget->Repaint(false);
}
}
}
return NS_OK;
}
NS_METHOD nsWidget::Resize(PRInt32 aX,PRInt32 aY,
PRInt32 aWidth,PRInt32 aHeight,
PRBool aRepaint)
{
Move(aX,aY);
Resize(aWidth,aHeight,aRepaint);
return NS_OK;
}
//-------------------------------------------------------------------------
// Send a resize message to the listener
//-------------------------------------------------------------------------
PRBool nsWidget::OnResize(nsSizeEvent event)
{
mBounds.width = event.mWinWidth;
mBounds.height = event.mWinHeight;
return DispatchWindowEvent(&event);
}
PRBool nsWidget::OnResize(nsRect &aRect)
{
nsSizeEvent event;
PRBool ret;
InitEvent(event, NS_SIZE);
event.eventStructType = NS_SIZE_EVENT;
nsRect foo(0,0,aRect.width,aRect.height);
event.windowSize = &foo;
event.point.x = 0;
event.point.y = 0;
event.mWinWidth = aRect.width;
event.mWinHeight = aRect.height;
NS_ADDREF_THIS();
ret = OnResize(event);
NS_RELEASE_THIS();
return ret;
}
PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY)
{
nsGUIEvent event;
mBounds.x = aX;
mBounds.y = aY;
InitEvent(event,NS_MOVE);
event.point.x = aX;
event.point.y = aY;
event.eventStructType = NS_GUI_EVENT;
PRBool result = DispatchWindowEvent(&event);
return result;
}
//-------------------------------------------------------------------------
// Enable/disable this component
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Enable(PRBool aState)
{
if (mWidget) {
mWidget->Enable(aState);
}
return NS_OK;
}
NS_METHOD nsWidget::IsEnabled(PRBool *aState)
{
NS_ENSURE_ARG_POINTER(aState);
*aState = PR_TRUE;
return NS_ERROR_NOT_IMPLEMENTED;
}
//-------------------------------------------------------------------------
// Give the focus to this component
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetFocus(PRBool aRaise)
{
if (mWidget) {
mWidget->SetFocus();
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Get this component font
//-------------------------------------------------------------------------
nsIFontMetrics *nsWidget::GetFont(void)
{
NS_NOTYETIMPLEMENTED("nsWidget::GetFont");
return nsnull;
}
//-------------------------------------------------------------------------
// Set this component font
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetFont(const nsFont &aFont)
{
nsCOMPtr<nsIFontMetrics> fontMetrics;
mContext->GetMetricsFor(aFont,*getter_AddRefs(fontMetrics));
if (!fontMetrics)
return NS_ERROR_FAILURE;
nsFontHandle fontHandle;
fontMetrics->GetFontHandle(fontHandle);
if (fontHandle && mWidget) {
nsFontQT *qtFontHandle = (nsFontQT*)fontHandle;
mWidget->SetFont(qtFontHandle);
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Set the background color
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetBackgroundColor(const nscolor &aColor)
{
nsBaseWidget::SetBackgroundColor(aColor);
if (mWidget) {
mWidget->SetBackgroundColor(aColor);
}
return NS_OK;
}
//-------------------------------------------------------------------------
// Set this component cursor
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetCursor(nsCursor aCursor)
{
if (mWidget) {
if (mCursor != aCursor) {
mWidget->SetCursor(aCursor);
mCursor = aCursor;
}
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_METHOD nsWidget::Invalidate(PRBool aIsSynchronous)
{
if (!mWidget)
return NS_OK; // mWidget will be null during printing.
if (aIsSynchronous) {
mWidget->Repaint(false);
mUpdateArea->SetTo(0,0,0,0);
}
else {
mWidget->Update();
mUpdateArea->SetTo(0,0,mBounds.width,mBounds.height);
}
return NS_OK;
}
NS_METHOD nsWidget::Invalidate(const nsRect &aRect,PRBool aIsSynchronous)
{
if (mWidget == nsnull) {
return NS_OK; // mWidget is null during printing
}
mUpdateArea->Union(aRect.x,aRect.y,aRect.width,aRect.height);
if (aIsSynchronous) {
mWidget->Repaint(aRect.x,aRect.y,aRect.width,aRect.height,false);
}
else {
mWidget->Update(aRect.x,aRect.y,aRect.width,aRect.height);
}
return NS_OK;
}
NS_IMETHODIMP nsWidget::InvalidateRegion(const nsIRegion *aRegion,
PRBool aIsSynchronous)
{
nsRegionRectSet *regionRectSet = nsnull;
if (!mWidget)
return NS_OK;
mUpdateArea->Union(*aRegion);
if (NS_FAILED(mUpdateArea->GetRects(&regionRectSet)))
return NS_ERROR_FAILURE;
PRUint32 len;
PRUint32 i;
len = regionRectSet->mRectsLen;
for (i = 0; i < len; ++i) {
nsRegionRect *r = &(regionRectSet->mRects[i]);
if (aIsSynchronous)
mWidget->Repaint(r->x,r->y,r->width,r->height,false);
else
mWidget->Update(r->x,r->y,r->width,r->height);
}
// drop the const.. whats the right thing to do here?
((nsIRegion*)aRegion)->FreeRects(regionRectSet);
return NS_OK;
}
NS_METHOD nsWidget::Update(void)
{
if (mIsDestroying)
return NS_ERROR_FAILURE;
return InvalidateRegion(mUpdateArea, PR_TRUE);
}
//-------------------------------------------------------------------------
// Return some native data according to aDataType
//-------------------------------------------------------------------------
void *nsWidget::GetNativeData(PRUint32 aDataType)
{
switch(aDataType) {
case NS_NATIVE_WINDOW:
if (mWidget)
return mWidget->GetNativeWindow();
break;
case NS_NATIVE_DISPLAY:
if (mWidget)
return mWidget->X11Display();
break;
case NS_NATIVE_WIDGET:
if (mWidget)
return mWidget->GetNativeWidget();
break;
case NS_NATIVE_PLUGIN_PORT:
if (mWidget)
return mWidget->WinID();
break;
default:
break;
}
return nsnull;
}
//-------------------------------------------------------------------------
// Set the colormap of the window
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetColorMap(nsColorMap *aColorMap)
{
return NS_OK;
}
//Stub for nsWindow functionality
NS_METHOD nsWidget::Scroll(PRInt32 aDx,PRInt32 aDy,nsRect *aClipRect)
{
return NS_ERROR_FAILURE;
}
NS_METHOD nsWidget::BeginResizingChildren(void)
{
return NS_OK;
}
NS_METHOD nsWidget::EndResizingChildren(void)
{
return NS_OK;
}
NS_METHOD nsWidget::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
{
aWidth = mPreferredWidth;
aHeight = mPreferredHeight;
return (mPreferredWidth != 0 && mPreferredHeight != 0) ? NS_OK
: NS_ERROR_FAILURE;
}
NS_METHOD nsWidget::SetPreferredSize(PRInt32 aWidth,PRInt32 aHeight)
{
mPreferredWidth = aWidth;
mPreferredHeight = aHeight;
return NS_OK;
}
NS_METHOD nsWidget::SetTitle(const nsString &aTitle)
{
if (mWidget) {
char *title = ToNewCString(aTitle);
mWidget->SetTitle(title);
nsMemory::Free(title);
}
return NS_OK;
}
nsresult nsWidget::CreateWidget(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent)
{
QWidget *parentWidget = nsnull;
nsIWidget *baseParent;
baseParent = aInitData
&& (aInitData->mWindowType == eWindowType_dialog
|| aInitData->mWindowType == eWindowType_toplevel)
? nsnull : aParent;
BaseCreate(baseParent,aRect,aHandleEventFunction,aContext,
aAppShell,aToolkit,aInitData);
mParent = aParent;
if (aNativeParent) {
parentWidget = (QWidget*)aNativeParent;
mListenForResizes = PR_TRUE;
}
else if (aParent) {
parentWidget = (QWidget*)aParent->GetNativeData(NS_NATIVE_WIDGET);
}
mBounds = aRect;
CreateNative(parentWidget);
Resize(aRect.width,aRect.height,PR_FALSE);
mWidget->Polish();
if (mIsToplevel) {
/* We have to Spin the Qt Event loop to make top level windows */
/* come up with the correct size, but it creates problems for */
/* menus, etc. */
qApp->processEvents(1);
}
DispatchStandardEvent(NS_CREATE);
return NS_OK;
}
//-------------------------------------------------------------------------
// create with nsIWidget parent
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
return(CreateWidget(aParent,aRect,aHandleEventFunction,
aContext,aAppShell,aToolkit,aInitData,
nsnull));
}
//-------------------------------------------------------------------------
// create with a native parent
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
return(CreateWidget(nsnull,aRect,aHandleEventFunction,
aContext,aAppShell,aToolkit,aInitData,
aParent));
}
//-------------------------------------------------------------------------
// Initialize all the Callbacks
//-------------------------------------------------------------------------
void nsWidget::InitCallbacks(char *aName)
{
}
void nsWidget::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
{
}
void nsWidget::InitEvent(nsGUIEvent& event,
PRUint32 aEventType,
nsPoint* aPoint)
{
event.widget = this;
if (aPoint == nsnull) {
event.point.x = 0;
event.point.y = 0;
}
else {
// use the point override if provided
event.point.x = aPoint->x;
event.point.y = aPoint->y;
}
event.time = PR_IntervalNow();
event.message = aEventType;
}
PRBool nsWidget::ConvertStatus(nsEventStatus aStatus)
{
switch(aStatus) {
case nsEventStatus_eIgnore:
return(PR_FALSE);
case nsEventStatus_eConsumeNoDefault:
return(PR_TRUE);
case nsEventStatus_eConsumeDoDefault:
return(PR_FALSE);
default:
NS_ASSERTION(0,"Illegal nsEventStatus enumeration value");
break;
}
return(PR_FALSE);
}
PRBool nsWidget::DispatchWindowEvent(nsGUIEvent* event)
{
nsEventStatus status;
DispatchEvent(event,status);
return ConvertStatus(status);
}
//-------------------------------------------------------------------------
// Dispatch standard event
//-------------------------------------------------------------------------
PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg)
{
nsGUIEvent event;
event.eventStructType = NS_GUI_EVENT;
InitEvent(event,aMsg);
PRBool result = DispatchWindowEvent(&event);
return result;
}
//-------------------------------------------------------------------------
// Invokes callback and ProcessEvent method on Event Listener object
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *event,
nsEventStatus &aStatus)
{
NS_IF_ADDREF(event->widget);
if (nsnull != mMenuListener) {
if (NS_MENU_EVENT == event->eventStructType)
aStatus = mMenuListener->MenuSelected(NS_STATIC_CAST(nsMenuEvent&,
*event));
}
aStatus = nsEventStatus_eIgnore;
if (nsnull != mEventCallback) {
aStatus = (*mEventCallback)(event);
}
// Dispatch to event listener if event was not consumed
if (aStatus != nsEventStatus_eIgnore && nsnull != mEventListener) {
aStatus = mEventListener->ProcessEvent(*event);
}
NS_IF_RELEASE(event->widget);
return NS_OK;
}
PRBool nsWidget::DispatchMouseScrollEvent(nsMouseScrollEvent& aEvent)
{
if (nsnull != mEventCallback) {
return DispatchWindowEvent(&aEvent);
}
return PR_FALSE;
}
//-------------------------------------------------------------------------
// Deal with all sorts of mouse event
//-------------------------------------------------------------------------
PRBool nsWidget::DispatchMouseEvent(nsMouseEvent& aEvent)
{
PRBool result = PR_FALSE;
if (nsnull == mWidget
|| (nsnull == mEventCallback && nsnull == mMouseListener)) {
return result;
}
if (aEvent.message == NS_MOUSE_LEFT_BUTTON_DOWN
|| aEvent.message == NS_MOUSE_RIGHT_BUTTON_DOWN
|| aEvent.message == NS_MOUSE_MIDDLE_BUTTON_DOWN) {
if (mWidget->HandlePopup((void*)aEvent.nativeMsg))
return result;
}
// call the event callback
if (nsnull != mEventCallback) {
result = DispatchWindowEvent(&aEvent);
return result;
}
if (nsnull != mMouseListener) {
switch (aEvent.message) {
case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
result = ConvertStatus(mMouseListener->MousePressed(aEvent));
break;
case NS_MOUSE_LEFT_BUTTON_UP:
case NS_MOUSE_MIDDLE_BUTTON_UP:
case NS_MOUSE_RIGHT_BUTTON_UP:
result = ConvertStatus(mMouseListener->MouseReleased(aEvent));
result = ConvertStatus(mMouseListener->MouseClicked(aEvent));
break;
default:
break;
} // switch
}
return result;
}
// HandlePopup
// Deal with rollup of popups (xpmenus, etc)
PRBool nsWidget::HandlePopup(PRInt32 inMouseX,PRInt32 inMouseY)
{
PRBool retVal = PR_FALSE;
nsCOMPtr<nsIWidget> rollupWidget = do_QueryReferent(gRollupWidget);
if (rollupWidget && gRollupListener) {
void *currentPopup = rollupWidget->GetNativeData(NS_NATIVE_WIDGET);
if (currentPopup
&& !NS_IsMouseInWindow(currentPopup,inMouseX,inMouseY)) {
PRBool rollup = PR_TRUE;
// if we're dealing with menus, we probably have submenus and we don't
// want to rollup if the clickis in a parent menu of the current submenu
nsCOMPtr<nsIMenuRollup> menuRollup(do_QueryInterface(gRollupListener));
if (menuRollup) {
nsCOMPtr<nsISupportsArray> widgetChain;
menuRollup->GetSubmenuWidgetChain(getter_AddRefs(widgetChain));
if (widgetChain) {
PRUint32 count = 0;
widgetChain->Count(&count);
for (PRUint32 i = 0; i < count; ++i) {
nsCOMPtr<nsISupports> genericWidget;
widgetChain->GetElementAt(i,getter_AddRefs(genericWidget));
nsCOMPtr<nsIWidget> widget(do_QueryInterface(genericWidget));
if (widget) {
void *currWindow = widget->GetNativeData(NS_NATIVE_WIDGET);
if (currWindow
&& NS_IsMouseInWindow(currWindow,inMouseX,inMouseY)) {
rollup = PR_FALSE;
break;
}
}
} // foreach parent menu widget
}
} // if rollup listener knows about menus
// if we've determined that we should still rollup, do it.
if (rollup) {
gRollupListener->Rollup();
retVal = PR_TRUE;
}
}
}
else {
gRollupWidget = nsnull;
gRollupListener = nsnull;
}
return retVal;
} // HandlePopup
//-------------------------------------------------------------------------
// Base implementation of CreateNative.
//-------------------------------------------------------------------------
NS_METHOD nsWidget::CreateNative(QWidget *parentWindow)
{
if (!mWidget)
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_IMETHODIMP nsWidget::ResetInputState()
{
return NS_OK;
}
NS_IMETHODIMP nsWidget::PasswordFieldInit()
{
return NS_OK;
}

Просмотреть файл

@ -1,199 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <jcgriggs@sympatico.ca>
* Wes Morgan <wmorga13@calvin.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsWidget_h__
#define nsWidget_h__
#include "nsBaseWidget.h"
#include "nsWeakReference.h"
#include "nsIKBStateControl.h"
#include "nsWidgetsCID.h"
#include "nsIRegion.h"
#include "nsIRollupListener.h"
#include "nsLookAndFeel.h"
#include "nsQWidget.h"
class nsIAppShell;
class nsIToolkit;
class nsWidget : public nsBaseWidget, public nsIKBStateControl, public nsSupportsWeakReference
{
public:
nsWidget();
virtual ~nsWidget();
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Destroy(void);
nsIWidget* GetParent(void);
NS_IMETHOD SetModal(PRBool aModal);
NS_IMETHOD Show(PRBool state);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);
NS_IMETHOD IsVisible(PRBool &aState);
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop, 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,
PRBool aRepaint);
NS_IMETHOD Enable(PRBool aState);
NS_IMETHOD IsEnabled(PRBool *aState);
NS_IMETHOD SetFocus(PRBool aRaise);
PRBool OnResize(nsSizeEvent event);
virtual PRBool OnResize(nsRect &aRect);
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
nsIFontMetrics *GetFont(void);
NS_IMETHOD SetFont(const nsFont &aFont);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD WidgetToScreen(const nsRect &aOldRect, nsRect &aNewRect);
NS_IMETHOD ScreenToWidget(const nsRect &aOldRect, nsRect &aNewRect);
NS_IMETHOD BeginResizingChildren(void);
NS_IMETHOD EndResizingChildren(void);
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
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 OnText(nsTextEvent &aEvent) { return PR_FALSE; };
virtual PRBool OnComposition(nsCompositionEvent &aEvent) { return PR_FALSE; };
virtual PRBool DispatchFocus(nsGUIEvent &aEvent) { return PR_FALSE; };
virtual PRBool DispatchFocusInEvent() { return PR_FALSE; };
virtual PRBool DispatchFocusOutEvent() { return PR_FALSE; };
virtual PRBool DispatchActivateEvent() { return PR_FALSE; };
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
NS_IMETHOD Update(void);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
// nsIKBStateControl
NS_IMETHOD ResetInputState();
NS_IMETHOD PasswordFieldInit();
void InitEvent(nsGUIEvent& event,PRUint32 aEventType,nsPoint* aPoint = nsnull);
// Utility functions
const char *GetName();
PRBool ConvertStatus(nsEventStatus aStatus);
PRBool DispatchMouseEvent(nsMouseEvent& aEvent);
PRBool DispatchStandardEvent(PRUint32 aMsg);
PRBool DispatchMouseScrollEvent(nsMouseScrollEvent& aEvent);
virtual PRBool IsPopup() const { return PR_FALSE; };
virtual PRBool IsDialog() const { return PR_FALSE; };
// Deal with rollup for popups
PRBool HandlePopup(PRInt32 inMouseX,PRInt32 inMouseY);
protected:
virtual void InitCallbacks(char * aName = nsnull);
virtual void OnDestroy();
NS_IMETHOD CreateNative(QWidget *parentWindow);
nsresult CreateWidget(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
PRBool DispatchWindowEvent(nsGUIEvent* event);
protected:
nsQBaseWidget *mWidget;
nsCOMPtr<nsIWidget> mParent;
// composite update area - union of all Invalidate calls
nsCOMPtr<nsIRegion> mUpdateArea;
PRUint32 mPreferredWidth;
PRUint32 mPreferredHeight;
PRBool mListenForResizes;
PRBool mIsToplevel;
PRUint32 mWidgetID;
// this is the rollup listener variables
static nsCOMPtr<nsIRollupListener> gRollupListener;
static nsWeakPtr gRollupWidget;
static PRBool gRollupConsumeRollupEvent;
};
#endif /* nsWidget_h__ */

Просмотреть файл

@ -1,178 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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
* Christopher Blizzard.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
* Dan Rosen <dr@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsWidgetsCID.h"
#include "nsWindow.h"
#include "nsAppShell.h"
#include "nsToolkit.h"
#include "nsLookAndFeel.h"
#include "nsTransferable.h"
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
#include "nsHTMLFormatConverter.h"
#include "nsDragService.h"
#include "nsScrollbar.h"
#include "nsBidiKeyboard.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
static nsresult nsHorizScrollbarConstructor(nsISupports *aOuter,REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsISupports *inst = nsnull;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
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);
NS_RELEASE(inst);
return rv;
}
static nsresult nsVertScrollbarConstructor(nsISupports *aOuter,REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsISupports *inst = nsnull;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
inst = (nsISupports*)(nsBaseWidget*)(nsWidget*)new nsScrollbar(PR_TRUE);
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
return rv;
}
static const nsModuleComponentInfo components[] =
{
{ "Qt nsWindow",
NS_WINDOW_CID,
"@mozilla.org/widgets/window/qt;1",
nsWindowConstructor },
{ "Qt Child nsWindow",
NS_CHILD_CID,
"@mozilla.org/widgets/child_window/qt;1",
ChildWindowConstructor },
{ "Qt Horiz Scrollbar",
NS_HORZSCROLLBAR_CID,
"@mozilla.org/widgets/horizscroll/qt;1",
nsHorizScrollbarConstructor },
{ "Qt Vert Scrollbar",
NS_VERTSCROLLBAR_CID,
"@mozilla.org/widgets/vertscroll/qt;1",
nsVertScrollbarConstructor },
{ "Qt AppShell",
NS_APPSHELL_CID,
"@mozilla.org/widget/appshell/qt;1",
nsAppShellConstructor },
{ "Qt Toolkit",
NS_TOOLKIT_CID,
"@mozilla.org/widget/toolkit/qt;1",
nsToolkitConstructor },
{ "Qt Look And Feel",
NS_LOOKANDFEEL_CID,
"@mozilla.org/widget/lookandfeel/qt;1",
nsLookAndFeelConstructor },
{ "Transferrable",
NS_TRANSFERABLE_CID,
"@mozilla.org/widget/transferable;1",
nsTransferableConstructor },
{ "Qt Clipboard",
NS_CLIPBOARD_CID,
"@mozilla.org/widget/clipboard;1",
nsClipboardConstructor },
{ "Clipboard Helper",
NS_CLIPBOARDHELPER_CID,
"@mozilla.org/widget/clipboardhelper;1",
nsClipboardHelperConstructor },
{ "HTML Format Converter",
NS_HTMLFORMATCONVERTER_CID,
"@mozilla.org/widget/htmlformatconverter/qt;1",
nsHTMLFormatConverterConstructor },
{ "Qt Drag Service",
NS_DRAGSERVICE_CID,
"@mozilla.org/widget/dragservice;1",
nsDragServiceConstructor },
{ "Qt Bidi Keyboard",
NS_BIDIKEYBOARD_CID,
"@mozilla.org/widget/bidikeyboard;1",
nsBidiKeyboardConstructor }
};
NS_IMPL_NSGETMODULE(nsWidgetQTModule,components)

Просмотреть файл

@ -1,537 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIServiceManager.h"
#include "nsQWidget.h"
#include "nsWindow.h"
#include "nsGUIEvent.h"
#include "nsIRenderingContext.h"
#include "nsRect.h"
#include "nsGfxCIID.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include <qapplication.h>
//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
PRBool nsWindow::mIsGrabbing = PR_FALSE;
nsWindow *nsWindow::mGrabWindow = NULL;
nsQBaseWidget *nsWindow::mFocusWidget = NULL;
PRBool nsWindow::mGlobalsInitialized = PR_FALSE;
PRBool nsWindow::mRaiseWindows = PR_TRUE;
PRBool nsWindow::mGotActivate = PR_FALSE;
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsWidget)
//-------------------------------------------------------------------------
// nsWindow constructor
//-------------------------------------------------------------------------
nsWindow::nsWindow()
{
#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;
mBlockFocusEvents = PR_FALSE;
mWindowType = eWindowType_child;
mBorderStyle = eBorderStyle_default;
// initialize globals
if (!mGlobalsInitialized) {
mGlobalsInitialized = PR_TRUE;
// check to see if we should set our raise pref
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
PRBool val = PR_TRUE;
nsresult rv = prefBranch->GetBoolPref("mozilla.widget.raise-on-setfocus",
&val);
if (NS_SUCCEEDED(rv))
mRaiseWindows = val;
}
}
}
//-------------------------------------------------------------------------
// nsWindow destructor
//-------------------------------------------------------------------------
nsWindow::~nsWindow()
{
#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;
mGrabWindow = NULL;
}
}
//-------------------------------------------------------------------------
PRBool nsWindow::IsChild() const
{
return PR_FALSE;
}
//-------------------------------------------------------------------------
void nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
{
}
//-------------------------------------------------------------------------
// Setup initial tooltip rectangles
//-------------------------------------------------------------------------
NS_METHOD nsWindow::SetTooltips(PRUint32 aNumberOfTips,
nsRect *aTooltipAreas[])
{
return NS_OK;
}
//-------------------------------------------------------------------------
// Update all tooltip rectangles
//-------------------------------------------------------------------------
NS_METHOD nsWindow::UpdateTooltips(nsRect* aNewTips[])
{
return NS_OK;
}
//-------------------------------------------------------------------------
// Remove all tooltip rectangles
//-------------------------------------------------------------------------
NS_METHOD nsWindow::RemoveTooltips()
{
return NS_OK;
}
NS_METHOD nsWindow::SetFocus(PRBool aRaise)
{
if (mBlockFocusEvents) {
return NS_OK;
}
PRBool sendActivate = mGotActivate;
mGotActivate = PR_FALSE;
if (mWidget) {
if (!mWidget->IsTopLevelActive()) {
if (aRaise && mRaiseWindows) {
mWidget->RaiseTopLevel();
}
mBlockFocusEvents = PR_TRUE;
mWidget->SetTopLevelFocus();
mBlockFocusEvents = PR_FALSE;
mGotActivate = PR_TRUE;
}
else {
if (mWidget == mFocusWidget) {
return NS_OK;
}
else {
mFocusWidget = mWidget;
}
}
}
DispatchFocusInEvent();
if (sendActivate) {
mGotActivate = PR_FALSE;
DispatchActivateEvent();
}
return NS_OK;
}
NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData)
{
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)
{
switch (mWindowType) {
case eWindowType_toplevel:
#ifdef DBG_JCG
printf("JCG: Top Level Create: %p\n",this);
#endif
break;
case eWindowType_dialog:
#ifdef DBG_JCG
printf("JCG: Dialog Create: %p\n",this);
#endif
mIsDialog = PR_TRUE;
break;
case eWindowType_popup:
#ifdef DBG_JCG
printf("JCG: Popup Create: %p\n",this);
#endif
mIsPopup = PR_TRUE;
break;
case eWindowType_child:
#ifdef DBG_JCG
printf("JCG: Child Create: %p\n",this);
#endif
break;
}
mWidget = new nsQBaseWidget(this);
if (!mWidget)
return NS_ERROR_OUT_OF_MEMORY;
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)
{
}
//-------------------------------------------------------------------------
// Set the colormap of the window
//-------------------------------------------------------------------------
NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
{
return NS_OK;
}
//-------------------------------------------------------------------------
// Scroll the bits of a window
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Scroll(PRInt32 aDx,PRInt32 aDy,nsRect *aClipRect)
{
if (mWidget) {
mWidget->Scroll(aDx,aDy);
}
return NS_OK;
}
/* Processes an Expose Event */
PRBool nsWindow::OnPaint(nsPaintEvent &event)
{
nsresult result;
PRInt32 x;
PRInt32 y;
PRInt32 width;
PRInt32 height;
// 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;
}
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)
{
return NS_OK;
}
NS_METHOD nsWindow::EndResizingChildren(void)
{
return NS_OK;
}
PRBool nsWindow::OnKey(nsKeyEvent &aEvent)
{
if (mEventCallback) {
return DispatchWindowEvent(&aEvent);
}
return PR_FALSE;
}
PRBool nsWindow::OnText(nsTextEvent &aEvent)
{
if (mEventCallback) {
return DispatchWindowEvent(&aEvent);
}
return PR_FALSE;
}
PRBool nsWindow::OnComposition(nsCompositionEvent &aEvent)
{
if (mEventCallback) {
return DispatchWindowEvent(&aEvent);
}
return PR_FALSE;
}
PRBool nsWindow::DispatchActivateEvent()
{
nsGUIEvent nsEvent;
nsEvent.message = NS_ACTIVATE;
nsEvent.eventStructType = NS_GUI_EVENT;
nsEvent.widget = this;
nsEvent.time = 0;
nsEvent.point.x = 0;
nsEvent.point.y = 0;
return DispatchFocus(nsEvent);
}
PRBool nsWindow::DispatchFocusOutEvent()
{
nsGUIEvent nsEvent;
if (mFocusWidget == mWidget)
mFocusWidget = nsnull;
nsEvent.message = NS_LOSTFOCUS;
nsEvent.eventStructType = NS_GUI_EVENT;
nsEvent.widget = this;
nsEvent.time = 0;
nsEvent.point.x = 0;
nsEvent.point.y = 0;
return DispatchFocus(nsEvent);
}
PRBool nsWindow::DispatchFocusInEvent()
{
if (mBlockFocusEvents) {
return PR_TRUE;
}
PRBool ret;
nsGUIEvent nsEvent;
nsEvent.message = NS_GOTFOCUS;
nsEvent.eventStructType = NS_GUI_EVENT;
nsEvent.widget = this;
nsEvent.time = 0;
nsEvent.point.x = 0;
nsEvent.point.y = 0;
mBlockFocusEvents = PR_TRUE;
ret = DispatchFocus(nsEvent);
mBlockFocusEvents = PR_FALSE;
return ret;
}
PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent)
{
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)
{
return PR_FALSE;
}
NS_METHOD nsWindow::ConstrainPosition(PRBool aAllowSlop,
PRInt32 *aX, PRInt32 *aY)
{
return NS_OK;
}
NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
{
if (mWidget && mParent && mWindowType == eWindowType_popup) {
nsRect oldrect, newrect;
mBounds.x = aX;
mBounds.y = aY;
oldrect.x = aX;
oldrect.y = aY;
mParent->WidgetToScreen(oldrect,newrect);
mWidget->Move(newrect.x,newrect.y);
return NS_OK;
}
else
return(nsWidget::Move(aX,aY));
}
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
PRBool aDoCapture,
PRBool aConsumeRollupEvent)
{
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)));
}
else {
// make sure that the grab window is marked as released
if (mGrabWindow == this) {
mGrabWindow = NULL;
}
mIsGrabbing = PR_FALSE;
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()
{
#ifdef NOISY_DESTROY
IndentByDepth(stdout);
printf("ChildWindow::~ChildWindow:%p\n", this);
#endif
#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;
}

Просмотреть файл

@ -1,126 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef Window_h__
#define Window_h__
#include "nsWidget.h"
/* Native QT window wrapper */
class nsWindow : public nsWidget
{
public:
nsWindow();
virtual ~nsWindow();
// nsIsupports
NS_DECL_ISUPPORTS_INHERITED
// nsIWidget interface
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 ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX,PRInt32 *aY);
NS_IMETHOD Move(PRInt32 aX,PRInt32 aY);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]);
NS_IMETHOD RemoveTooltips();
NS_IMETHOD BeginResizingChildren(void);
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; };
// Utility methods
virtual PRBool OnPaint(nsPaintEvent &event);
virtual PRBool OnKey(nsKeyEvent &aEvent);
virtual PRBool OnText(nsTextEvent &aEvent);
virtual PRBool OnComposition(nsCompositionEvent &aEvent);
virtual PRBool DispatchFocusInEvent();
virtual PRBool DispatchFocusOutEvent();
virtual PRBool DispatchActivateEvent();
virtual PRBool DispatchFocus(nsGUIEvent &aEvent);
virtual PRBool OnScroll(nsScrollbarEvent &aEvent,PRUint32 cPos);
protected:
virtual void InitCallbacks(char *aName = nsnull);
NS_IMETHOD CreateNative(QWidget *parentWidget);
PRBool mIsDialog;
PRBool mIsPopup;
PRBool mBlockFocusEvents;
// are we doing a grab?
static PRBool mIsGrabbing;
static nsWindow *mGrabWindow;
static nsQBaseWidget *mFocusWidget;
static PRBool mGlobalsInitialized;
static PRBool mRaiseWindows;
static PRBool mGotActivate;
PRInt32 mWindowID;
};
//
// A child window is a window with different style
//
class ChildWindow : public nsWindow
{
public:
ChildWindow();
~ChildWindow();
virtual PRBool IsChild() const;
PRInt32 mChildID;
};
#endif // Window_h__