Qt Mozilla port. For now the best way to start playing with it is the
TestQGeckoEmbed from the embedding/browser/qt/tests. Build patch sr=jst, r=biesi. Rest: r=dbaron,biesi
This commit is contained in:
Родитель
d9b0e617fb
Коммит
1c549dd488
|
@ -163,6 +163,7 @@ gfx/src/ps/Makefile
|
|||
gfx/src/psshared/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
|
||||
|
@ -540,6 +541,7 @@ 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
|
||||
"
|
||||
|
||||
|
@ -552,6 +554,7 @@ widget/src/build/Makefile
|
|||
widget/src/gtk/Makefile
|
||||
widget/src/gtksuperwin/Makefile
|
||||
widget/src/gtkxtbin/Makefile
|
||||
widget/src/qt/Makefile
|
||||
widget/src/photon/Makefile
|
||||
widget/src/mac/Makefile
|
||||
widget/src/cocoa/Makefile
|
||||
|
|
|
@ -383,6 +383,7 @@ MOZ_ENABLE_CAIRO_GFX = @MOZ_ENABLE_CAIRO_GFX@
|
|||
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@
|
||||
|
@ -396,6 +397,9 @@ 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@
|
||||
|
|
85
configure.in
85
configure.in
|
@ -86,6 +86,8 @@ GLIB_VERSION=1.2.0
|
|||
GTK_VERSION=1.2.0
|
||||
LIBIDL_VERSION=0.6.3
|
||||
PERL_VERSION=5.004
|
||||
QT_VERSION=3.2.0
|
||||
QT_VERSION_NUM=320
|
||||
LIBART_VERSION=2.3.4
|
||||
CAIRO_VERSION=0.1.17
|
||||
GTK2_VERSION=1.3.7
|
||||
|
@ -3171,6 +3173,7 @@ 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" \
|
||||
|
@ -3187,7 +3190,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 or gtk2.])
|
||||
AC_MSG_ERROR([Toolkit must be xlib, gtk, gtk2 or qt.])
|
||||
else
|
||||
AC_MSG_ERROR([Toolkit must be $_PLATFORM_DEFAULT_TOOLKIT.])
|
||||
fi
|
||||
|
@ -3223,6 +3226,13 @@ xlib)
|
|||
AC_DEFINE(MOZ_WIDGET_XLIB)
|
||||
;;
|
||||
|
||||
qt)
|
||||
MOZ_ENABLE_QT=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)
|
||||
|
@ -3290,6 +3300,75 @@ 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"
|
||||
|
||||
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)
|
||||
|
@ -3301,6 +3380,7 @@ AC_SUBST(MOZ_ENABLE_CAIRO)
|
|||
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_CAIRO_GFX)
|
||||
|
@ -3311,10 +3391,13 @@ 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" \
|
||||
|| test "$MOZ_ENABLE_XLIB" \
|
||||
|| test "$MOZ_ENABLE_GTK2"
|
||||
then
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = qgeckoembed
|
||||
DIRS=src tests
|
||||
|
||||
PACKAGE_FILE = qgeckoembed.pkg
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,2 @@
|
|||
.deps
|
||||
Makefile
|
|
@ -0,0 +1,160 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include <strings.h>
|
||||
#include <nsXPIDLString.h>
|
||||
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "EmbedContentListener.h"
|
||||
#include "qgeckoembed.h"
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
|
||||
EmbedContentListener::EmbedContentListener(QGeckoEmbed *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
}
|
||||
|
||||
EmbedContentListener::~EmbedContentListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(EmbedContentListener,
|
||||
nsIURIContentListener,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
PRBool *aAbortOpen)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString specString;
|
||||
rv = aURI->GetSpec(specString);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
//we stop loading here because we want to pass the
|
||||
//control to kio to check for mimetypes and all the other jazz
|
||||
bool abort = false;
|
||||
mOwner->startURIOpen(specString.get(), abort);
|
||||
*aAbortOpen = abort;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::DoContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::IsPreferred(const char *aContentType,
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
qDebug("HANDLING:");
|
||||
|
||||
if (aContentType) {
|
||||
nsCOMPtr<nsICategoryManager> catMgr;
|
||||
nsresult rv;
|
||||
catMgr = do_GetService("@mozilla.org/categorymanager;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsXPIDLCString value;
|
||||
rv = catMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
||||
aContentType,
|
||||
getter_Copies(value));
|
||||
|
||||
// If the category manager can't find what we're looking for
|
||||
// it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
|
||||
// that to the caller since it's really not a failure
|
||||
|
||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
|
||||
return rv;
|
||||
|
||||
if (value && *value)
|
||||
*_retval = PR_TRUE;
|
||||
}
|
||||
|
||||
qDebug("\tCan handle content %s: %d", aContentType, *_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::GetLoadCookie(nsISupports **aLoadCookie)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::SetLoadCookie(nsISupports *aLoadCookie)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::GetParentContentListener(nsIURIContentListener **aParent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::SetParentContentListener(nsIURIContentListener *aParent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "EmbedGlobalHistory.h"
|
||||
#include "nsIGlobalHistory.h"
|
||||
|
||||
#if 0
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(EmbedGlobalHistory, Init)
|
||||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "Global History",
|
||||
NS_EMBEDGLOBALHISTORY_CID,
|
||||
"@mozilla.org/browser/global-history;1",
|
||||
EmbedGlobalHistoryConstructor,
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("Qt components", components)
|
||||
#endif
|
|
@ -0,0 +1,316 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include <nsIPipe.h>
|
||||
#include <nsIInputStream.h>
|
||||
#include <nsIOutputStream.h>
|
||||
#include <nsIContentViewerContainer.h>
|
||||
#include <nsIDocumentLoaderFactory.h>
|
||||
#include <nsNetUtil.h>
|
||||
#include <prmem.h>
|
||||
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsIContentViewer.h"
|
||||
|
||||
#include "EmbedStream.h"
|
||||
#include "qgeckoembed.h"
|
||||
#include "EmbedWindow.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
// nsIInputStream interface
|
||||
|
||||
NS_IMPL_ISUPPORTS1(EmbedStream, nsIInputStream)
|
||||
|
||||
EmbedStream::EmbedStream()
|
||||
{
|
||||
mOwner = nsnull;
|
||||
mOffset = 0;
|
||||
mDoingStream = PR_FALSE;
|
||||
}
|
||||
|
||||
EmbedStream::~EmbedStream()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
EmbedStream::InitOwner(QGeckoEmbed *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
EmbedStream::Init(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIInputStream> bufInStream;
|
||||
nsCOMPtr<nsIOutputStream> bufOutStream;
|
||||
|
||||
rv = NS_NewPipe(getter_AddRefs(bufInStream),
|
||||
getter_AddRefs(bufOutStream));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mInputStream = bufInStream;
|
||||
mOutputStream = bufOutStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
EmbedStream::OpenStream(const char *aBaseURI, const char *aContentType)
|
||||
{
|
||||
qDebug("==================> OpenStream: %s (%s)", aBaseURI, aContentType);
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
NS_ENSURE_ARG_POINTER(aContentType);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// if we're already doing a stream then close the current one
|
||||
if (mDoingStream)
|
||||
CloseStream();
|
||||
|
||||
// set our state
|
||||
mDoingStream = PR_TRUE;
|
||||
|
||||
// initialize our streams
|
||||
rv = Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// get the content area of our web browser
|
||||
nsCOMPtr<nsIWebBrowser> browser;
|
||||
|
||||
|
||||
mOwner->window()->GetWebBrowser(getter_AddRefs(browser));
|
||||
|
||||
// get the viewer container
|
||||
nsCOMPtr<nsIContentViewerContainer> viewerContainer;
|
||||
viewerContainer = do_GetInterface(browser);
|
||||
|
||||
// create a new uri object
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCAutoString spec(aBaseURI);
|
||||
rv = NS_NewURI(getter_AddRefs(uri), spec.get());
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// create a new load group
|
||||
rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// create a new input stream channel
|
||||
rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), uri,
|
||||
this,
|
||||
nsDependentCString(aContentType),
|
||||
EmptyCString());
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// set the channel's load group
|
||||
rv = mChannel->SetLoadGroup(mLoadGroup);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// find a document loader for this content type
|
||||
|
||||
nsXPIDLCString docLoaderContractID;
|
||||
nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", aContentType,
|
||||
getter_Copies(docLoaderContractID));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory;
|
||||
docLoaderFactory = do_GetService(docLoaderContractID.get(), &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// ok, create an instance of the content viewer for that command and
|
||||
// mime type
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
rv = docLoaderFactory->CreateInstance("view", mChannel, mLoadGroup,
|
||||
aContentType, viewerContainer,
|
||||
nsnull,
|
||||
getter_AddRefs(mStreamListener),
|
||||
getter_AddRefs(contentViewer));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// set the container viewer container for this content view
|
||||
rv = contentViewer->SetContainer(viewerContainer);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// embed this sucker
|
||||
rv = viewerContainer->Embed(contentViewer, "view", nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// start our request
|
||||
nsCOMPtr<nsIRequest> request = do_QueryInterface(mChannel);
|
||||
rv = mStreamListener->OnStartRequest(request, NULL);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
EmbedStream::AppendToStream(const char *aData, PRInt32 aLen)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// append the data
|
||||
rv = Append(aData, aLen);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// notify our listeners
|
||||
nsCOMPtr<nsIRequest> request = do_QueryInterface(mChannel);
|
||||
rv = mStreamListener->OnDataAvailable(request,
|
||||
NULL,
|
||||
NS_STATIC_CAST(nsIInputStream *, this),
|
||||
mOffset, /* offset */
|
||||
aLen); /* len */
|
||||
// move our counter
|
||||
mOffset += aLen;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
EmbedStream::CloseStream(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_STATE(mDoingStream);
|
||||
mDoingStream = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIRequest> request = do_QueryInterface(mChannel, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto loser;
|
||||
|
||||
rv = mStreamListener->OnStopRequest(request, NULL, NS_OK);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
loser:
|
||||
mLoadGroup = nsnull;
|
||||
mChannel = nsnull;
|
||||
mStreamListener = nsnull;
|
||||
mOffset = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
EmbedStream::Append(const char *aData, PRUint32 aLen)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 bytesWritten = 0;
|
||||
rv = mOutputStream->Write(aData, aLen, &bytesWritten);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ASSERTION(bytesWritten == aLen,
|
||||
"underlying byffer couldn't handle the write");
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedStream::Available(PRUint32 *_retval)
|
||||
{
|
||||
return mInputStream->Available(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedStream::Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval)
|
||||
{
|
||||
return mInputStream->Read(aBuf, aCount, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP EmbedStream::Close(void)
|
||||
{
|
||||
return mInputStream->Close();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedStream::ReadSegments(nsWriteSegmentFun aWriter, void * aClosure,
|
||||
PRUint32 aCount, PRUint32 *_retval)
|
||||
{
|
||||
char *readBuf = (char *)nsMemory::Alloc(aCount);
|
||||
PRUint32 nBytes;
|
||||
|
||||
if (!readBuf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = mInputStream->Read(readBuf, aCount, &nBytes);
|
||||
|
||||
*_retval = 0;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRUint32 writeCount = 0;
|
||||
rv = aWriter(this, aClosure, readBuf, 0, nBytes, &writeCount);
|
||||
|
||||
// XXX writeCount may be less than nBytes!! This is the wrong
|
||||
// way to synthesize ReadSegments.
|
||||
NS_ASSERTION(writeCount == nBytes, "data loss");
|
||||
|
||||
// errors returned from the writer end here!
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
nsMemory::Free(readBuf);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedStream::IsNonBlocking(PRBool *aNonBlocking)
|
||||
{
|
||||
return mInputStream->IsNonBlocking(aNonBlocking);
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = qgeckoembed
|
||||
LIBRARY_NAME = qgeckoembed
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
docshell \
|
||||
webshell \
|
||||
necko \
|
||||
widget \
|
||||
dom \
|
||||
js \
|
||||
gfx \
|
||||
layout \
|
||||
content \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
shistory \
|
||||
embed_base \
|
||||
pref \
|
||||
windowwatcher \
|
||||
profdirserviceprovider \
|
||||
$(NULL)
|
||||
|
||||
ifdef ACCESSIBILITY
|
||||
REQUIRES += accessibility
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
$(MOCSRCS) \
|
||||
qgeckoembed.cpp \
|
||||
EmbedWindow.cpp \
|
||||
EmbedProgress.cpp \
|
||||
EmbedContentListener.cpp \
|
||||
EmbedEventListener.cpp \
|
||||
EmbedWindowCreator.cpp \
|
||||
EmbedStream.cpp \
|
||||
qgeckoglobals.cpp
|
||||
|
||||
MOCSRCS = \
|
||||
moc_qgeckoembed.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Include config.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
# Force applications to be built non-statically
|
||||
# when building the mozcomps meta component
|
||||
ifneq (,$(filter mozcomps,$(MOZ_META_COMPONENTS)))
|
||||
BUILD_STATIC_LIBS=
|
||||
BUILD_SHARED_LIBS=1
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS= \
|
||||
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libprofdirserviceprovider_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = qgeckoembed.h
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_QT_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
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
|
||||
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS) -g02
|
||||
CFLAGS += $(MOZ_QT_CFLAGS) -g02
|
|
@ -0,0 +1,728 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "qgeckoembed.h"
|
||||
|
||||
#include "EmbedWindow.h"
|
||||
#include "EmbedProgress.h"
|
||||
#include "EmbedStream.h"
|
||||
#include "EmbedEventListener.h"
|
||||
#include "EmbedContentListener.h"
|
||||
#include "EmbedWindowCreator.h"
|
||||
#include "qgeckoglobals.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include <nsIDocShell.h>
|
||||
#include <nsIWebProgress.h>
|
||||
#include <nsIWebNavigation.h>
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsISHistory.h>
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include "nsIWidget.h"
|
||||
#include "nsCRT.h"
|
||||
#include <nsIWindowWatcher.h>
|
||||
#include <nsILocalFile.h>
|
||||
#include <nsEmbedAPI.h>
|
||||
#include <nsWidgetsCID.h>
|
||||
#include <nsIDOMUIEvent.h>
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
#include <nsIComponentManager.h>
|
||||
#include <nsIFocusController.h>
|
||||
#include <nsProfileDirServiceProvider.h>
|
||||
#include <nsIGenericFactory.h>
|
||||
#include <nsIComponentRegistrar.h>
|
||||
#include <nsIPref.h>
|
||||
#include <nsVoidArray.h>
|
||||
#include <nsIDOMDocument.h>
|
||||
#include <nsIDOMBarProp.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
#include <nsIDOMEventReceiver.h>
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsPIDOMWindow.h>
|
||||
|
||||
#include "prenv.h"
|
||||
|
||||
#include <qlayout.h>
|
||||
|
||||
class QGeckoEmbedPrivate
|
||||
{
|
||||
public:
|
||||
QGeckoEmbedPrivate(QGeckoEmbed *qq);
|
||||
~QGeckoEmbedPrivate();
|
||||
|
||||
QGeckoEmbed *q;
|
||||
|
||||
QWidget *mMainWidget;
|
||||
|
||||
// all of the objects that we own
|
||||
EmbedWindow *window;
|
||||
nsCOMPtr<nsISupports> windowGuard;
|
||||
EmbedProgress *progress;
|
||||
nsCOMPtr<nsISupports> progressGuard;
|
||||
EmbedContentListener *contentListener;
|
||||
nsCOMPtr<nsISupports> contentListenerGuard;
|
||||
EmbedEventListener *eventListener;
|
||||
nsCOMPtr<nsISupports> eventListenerGuard;
|
||||
EmbedStream *stream;
|
||||
nsCOMPtr<nsISupports> streamGuard;
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> navigation;
|
||||
nsCOMPtr<nsISHistory> sessionHistory;
|
||||
|
||||
// our event receiver
|
||||
nsCOMPtr<nsIDOMEventReceiver> eventReceiver;
|
||||
|
||||
// chrome mask
|
||||
PRUint32 chromeMask;
|
||||
|
||||
bool isChrome;
|
||||
bool chromeLoaded;
|
||||
bool listenersAttached;
|
||||
|
||||
void initGUI();
|
||||
void init();
|
||||
void ApplyChromeMask();
|
||||
};
|
||||
|
||||
|
||||
QGeckoEmbedPrivate::QGeckoEmbedPrivate(QGeckoEmbed *qq)
|
||||
: q(qq),
|
||||
mMainWidget(0),
|
||||
chromeMask(nsIWebBrowserChrome::CHROME_ALL),
|
||||
isChrome(FALSE),
|
||||
chromeLoaded(FALSE),
|
||||
listenersAttached(FALSE)
|
||||
{
|
||||
initGUI();
|
||||
init();
|
||||
}
|
||||
|
||||
QGeckoEmbedPrivate::~QGeckoEmbedPrivate()
|
||||
{
|
||||
QGeckoGlobals::removeEngine(q);
|
||||
QGeckoGlobals::popStartup();
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbedPrivate::init()
|
||||
{
|
||||
QGeckoGlobals::initializeGlobalObjects();
|
||||
QGeckoGlobals::pushStartup();
|
||||
QGeckoGlobals::addEngine(q);
|
||||
|
||||
// Create our embed window, and create an owning reference to it and
|
||||
// initialize it. It is assumed that this window will be destroyed
|
||||
// when we go out of scope.
|
||||
window = new EmbedWindow();
|
||||
windowGuard = NS_STATIC_CAST(nsIWebBrowserChrome *, window);
|
||||
window->Init(q);
|
||||
// Create our progress listener object, make an owning reference,
|
||||
// and initialize it. It is assumed that this progress listener
|
||||
// will be destroyed when we go out of scope.
|
||||
progress = new EmbedProgress(q);
|
||||
progressGuard = NS_STATIC_CAST(nsIWebProgressListener *,
|
||||
progress);
|
||||
|
||||
// Create our content listener object, initialize it and attach it.
|
||||
// It is assumed that this will be destroyed when we go out of
|
||||
// scope.
|
||||
contentListener = new EmbedContentListener(q);
|
||||
contentListenerGuard = NS_STATIC_CAST(nsISupports*,
|
||||
NS_STATIC_CAST(nsIURIContentListener*, contentListener));
|
||||
|
||||
// Create our key listener object and initialize it. It is assumed
|
||||
// that this will be destroyed before we go out of scope.
|
||||
eventListener = new EmbedEventListener(q);
|
||||
eventListenerGuard =
|
||||
NS_STATIC_CAST(nsISupports *, NS_STATIC_CAST(nsIDOMKeyListener *,
|
||||
eventListener));
|
||||
|
||||
// has the window creator service been set up?
|
||||
static int initialized = PR_FALSE;
|
||||
// Set up our window creator ( only once )
|
||||
if (!initialized) {
|
||||
// create our local object
|
||||
nsCOMPtr<nsIWindowCreator> windowCreator = new EmbedWindowCreator();
|
||||
|
||||
// Attach it via the watcher service
|
||||
nsCOMPtr<nsIWindowWatcher> watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
||||
if (watcher)
|
||||
watcher->SetWindowCreator(windowCreator);
|
||||
initialized = PR_TRUE;
|
||||
}
|
||||
|
||||
// Get the nsIWebBrowser object for our embedded window.
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
window->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
// get a handle on the navigation object
|
||||
navigation = do_QueryInterface(webBrowser);
|
||||
|
||||
// Create our session history object and tell the navigation object
|
||||
// to use it. We need to do this before we create the web browser
|
||||
// window.
|
||||
sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID);
|
||||
navigation->SetSessionHistory(sessionHistory);
|
||||
|
||||
// create the window
|
||||
window->CreateWindow();
|
||||
|
||||
// bind the progress listener to the browser object
|
||||
nsCOMPtr<nsISupportsWeakReference> supportsWeak;
|
||||
supportsWeak = do_QueryInterface(progressGuard);
|
||||
nsCOMPtr<nsIWeakReference> weakRef;
|
||||
supportsWeak->GetWeakReference(getter_AddRefs(weakRef));
|
||||
webBrowser->AddWebBrowserListener(weakRef,
|
||||
nsIWebProgressListener::GetIID());
|
||||
|
||||
// set ourselves as the parent uri content listener
|
||||
webBrowser->SetParentURIContentListener(contentListener);
|
||||
|
||||
// save the window id of the newly created window
|
||||
nsCOMPtr<nsIWidget> qtWidget;
|
||||
window->mBaseWindow->GetMainWidget(getter_AddRefs(qtWidget));
|
||||
// get the native drawing area
|
||||
mMainWidget = NS_STATIC_CAST(QWidget*, qtWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
|
||||
// Apply the current chrome mask
|
||||
ApplyChromeMask();
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbedPrivate::initGUI()
|
||||
{
|
||||
QBoxLayout *l = new QHBoxLayout(q);
|
||||
l->setAutoAdd(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbedPrivate::ApplyChromeMask()
|
||||
{
|
||||
if (window) {
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
window->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (domWindow) {
|
||||
nsCOMPtr<nsIDOMBarProp> scrollbars;
|
||||
domWindow->GetScrollbars(getter_AddRefs(scrollbars));
|
||||
if (scrollbars) {
|
||||
|
||||
scrollbars->SetVisible(
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_SCROLLBARS ?
|
||||
PR_TRUE : PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QGeckoEmbed::QGeckoEmbed(QWidget *parent, const char *name)
|
||||
: QWidget(parent, name)
|
||||
{
|
||||
d = new QGeckoEmbedPrivate(this);
|
||||
}
|
||||
|
||||
QGeckoEmbed::~QGeckoEmbed()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
QGeckoEmbed::canGoBack() const
|
||||
{
|
||||
PRBool retval = PR_FALSE;
|
||||
if (d->navigation)
|
||||
d->navigation->GetCanGoBack(&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::canGoForward() const
|
||||
{
|
||||
PRBool retval = PR_FALSE;
|
||||
if (d->navigation)
|
||||
d->navigation->GetCanGoForward(&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::loadURL(const QString &url)
|
||||
{
|
||||
if (!url.isEmpty()) {
|
||||
d->navigation->LoadURI((const PRUnichar*)url.ucs2(),
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, // Load flags
|
||||
nsnull, // Referring URI
|
||||
nsnull, // Post data
|
||||
nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::stopLoad()
|
||||
{
|
||||
if (d->navigation)
|
||||
d->navigation->Stop(nsIWebNavigation::STOP_NETWORK);
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::goForward()
|
||||
{
|
||||
if (d->navigation)
|
||||
d->navigation->GoForward();
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::goBack()
|
||||
{
|
||||
if (d->navigation)
|
||||
d->navigation->GoBack();
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::renderData(const QCString &data, const QString &baseURI,
|
||||
const QString &mimeType)
|
||||
{
|
||||
openStream(baseURI, mimeType);
|
||||
appendData(data);
|
||||
closeStream();
|
||||
}
|
||||
|
||||
int
|
||||
QGeckoEmbed::openStream(const QString &baseURI, const QString &mimeType)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!d->stream) {
|
||||
d->stream = new EmbedStream();
|
||||
d->streamGuard = do_QueryInterface(d->stream);
|
||||
d->stream->InitOwner(this);
|
||||
rv = d->stream->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = d->stream->OpenStream(baseURI, mimeType);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
QGeckoEmbed::appendData(const QCString &data)
|
||||
{
|
||||
if (!d->stream)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Attach listeners to this document since in some cases we don't
|
||||
// get updates for content added this way.
|
||||
contentStateChanged();
|
||||
|
||||
return d->stream->AppendToStream(data, data.length());
|
||||
}
|
||||
|
||||
int
|
||||
QGeckoEmbed::closeStream()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!d->stream)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = d->stream->CloseStream();
|
||||
|
||||
// release
|
||||
d->stream = 0;
|
||||
d->streamGuard = 0;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::reload(ReloadFlags flags)
|
||||
{
|
||||
int qeckoFlags = 0;
|
||||
switch(flags) {
|
||||
case Normal:
|
||||
qeckoFlags = 0;
|
||||
break;
|
||||
case BypassCache:
|
||||
qeckoFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE;
|
||||
break;
|
||||
case BypassProxy:
|
||||
qeckoFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
|
||||
break;
|
||||
case BypassProxyAndCache:
|
||||
qeckoFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
|
||||
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
|
||||
break;
|
||||
case CharsetChange:
|
||||
qeckoFlags = nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE;
|
||||
break;
|
||||
default:
|
||||
qeckoFlags = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> wn;
|
||||
|
||||
if (d->sessionHistory) {
|
||||
wn = do_QueryInterface(d->sessionHistory);
|
||||
}
|
||||
if (!wn)
|
||||
wn = d->navigation;
|
||||
|
||||
if (wn)
|
||||
wn->Reload(qeckoFlags);
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domKeyDownEvent(nsIDOMKeyEvent *keyEvent)
|
||||
{
|
||||
qDebug("key event start");
|
||||
emit domKeyDown(keyEvent);
|
||||
qDebug("key event stop");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domKeyPressEvent(nsIDOMKeyEvent *keyEvent)
|
||||
{
|
||||
emit domKeyPress(keyEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domKeyUpEvent(nsIDOMKeyEvent *keyEvent)
|
||||
{
|
||||
emit domKeyUp(keyEvent);
|
||||
qDebug("key release event stop");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domMouseDownEvent(nsIDOMMouseEvent *mouseEvent)
|
||||
{
|
||||
emit domMouseDown(mouseEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domMouseUpEvent(nsIDOMMouseEvent *mouseEvent)
|
||||
{
|
||||
emit domMouseUp(mouseEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domMouseClickEvent(nsIDOMMouseEvent *mouseEvent)
|
||||
{
|
||||
emit domMouseClick(mouseEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domMouseDblClickEvent(nsIDOMMouseEvent *mouseEvent)
|
||||
{
|
||||
emit domMouseDblClick(mouseEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domMouseOverEvent(nsIDOMMouseEvent *mouseEvent)
|
||||
{
|
||||
emit domMouseOver(mouseEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domMouseOutEvent(nsIDOMMouseEvent *mouseEvent)
|
||||
{
|
||||
emit domMouseOut(mouseEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domActivateEvent(nsIDOMUIEvent *event)
|
||||
{
|
||||
emit domActivate(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domFocusInEvent(nsIDOMUIEvent *event)
|
||||
{
|
||||
emit domFocusIn(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QGeckoEmbed::domFocusOutEvent(nsIDOMUIEvent *event)
|
||||
{
|
||||
emit domFocusOut(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::emitScriptStatus(const QString &str)
|
||||
{
|
||||
emit jsStatusMessage(str);
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::emitLinkStatus(const QString &str)
|
||||
{
|
||||
emit linkMessage(str);
|
||||
}
|
||||
|
||||
int
|
||||
QGeckoEmbed::chromeMask() const
|
||||
{
|
||||
return d->chromeMask;
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::setChromeMask(int mask)
|
||||
{
|
||||
d->chromeMask = mask;
|
||||
|
||||
d->ApplyChromeMask();
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
d->window->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER,
|
||||
0, 0, e->size().width(), e->size().height());
|
||||
}
|
||||
|
||||
nsIDOMDocument*
|
||||
QGeckoEmbed::document() const
|
||||
{
|
||||
nsIDOMDocument *doc = 0;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
|
||||
d->window->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(window));
|
||||
if (window) {
|
||||
window->GetDocument(&doc);
|
||||
}
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::contentStateChanged()
|
||||
{
|
||||
// we don't attach listeners to chrome
|
||||
if (d->listenersAttached && !d->isChrome)
|
||||
return;
|
||||
|
||||
setupListener();
|
||||
|
||||
if (!d->eventReceiver)
|
||||
return;
|
||||
|
||||
attachListeners();
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::contentFinishedLoading()
|
||||
{
|
||||
if (d->isChrome) {
|
||||
// We're done loading.
|
||||
d->chromeLoaded = PR_TRUE;
|
||||
|
||||
// get the web browser
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
d->window->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
// get the content DOM window for that web browser
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (!domWindow) {
|
||||
NS_WARNING("no dom window in content finished loading\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// resize the content
|
||||
domWindow->SizeToContent();
|
||||
|
||||
// and since we're done loading show the window, assuming that the
|
||||
// visibility flag has been set.
|
||||
PRBool visibility;
|
||||
d->window->GetVisibility(&visibility);
|
||||
if (visibility)
|
||||
d->window->SetVisibility(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::setupListener()
|
||||
{
|
||||
if (d->eventReceiver)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> piWin;
|
||||
GetPIDOMWindow(getter_AddRefs(piWin));
|
||||
|
||||
if (!piWin)
|
||||
return;
|
||||
|
||||
d->eventReceiver = do_QueryInterface(piWin->GetChromeEventHandler());
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoEmbed::attachListeners()
|
||||
{
|
||||
if (!d->eventReceiver || d->listenersAttached)
|
||||
return;
|
||||
|
||||
nsIDOMEventListener *eventListener =
|
||||
NS_STATIC_CAST(nsIDOMEventListener *,
|
||||
NS_STATIC_CAST(nsIDOMKeyListener *, d->eventListener));
|
||||
|
||||
// add the key listener
|
||||
nsresult rv;
|
||||
rv = d->eventReceiver->AddEventListenerByIID(eventListener,
|
||||
NS_GET_IID(nsIDOMKeyListener));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to add key listener\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = d->eventReceiver->AddEventListenerByIID(eventListener,
|
||||
NS_GET_IID(nsIDOMMouseListener));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to add mouse listener\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = d->eventReceiver->AddEventListenerByIID(eventListener,
|
||||
NS_GET_IID(nsIDOMUIListener));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to add UI listener\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// ok, all set.
|
||||
d->listenersAttached = PR_TRUE;
|
||||
}
|
||||
|
||||
EmbedWindow * QGeckoEmbed::window() const
|
||||
{
|
||||
return d->window;
|
||||
}
|
||||
|
||||
|
||||
int QGeckoEmbed::GetPIDOMWindow(nsPIDOMWindow **aPIWin)
|
||||
{
|
||||
*aPIWin = nsnull;
|
||||
|
||||
// get the web browser
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
d->window->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
// get the content DOM window for that web browser
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if (!domWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get the private DOM window
|
||||
nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(domWindow);
|
||||
// and the root window for that DOM window
|
||||
*aPIWin = domWindowPrivate->GetPrivateRoot();
|
||||
|
||||
if (*aPIWin) {
|
||||
NS_ADDREF(*aPIWin);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
}
|
||||
|
||||
void QGeckoEmbed::setIsChrome(bool isChrome)
|
||||
{
|
||||
d->isChrome = isChrome;
|
||||
}
|
||||
|
||||
bool QGeckoEmbed::isChrome() const
|
||||
{
|
||||
return d->isChrome;
|
||||
}
|
||||
|
||||
bool QGeckoEmbed::chromeLoaded() const
|
||||
{
|
||||
return d->chromeLoaded;
|
||||
}
|
||||
|
||||
QString QGeckoEmbed::url() const
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
d->navigation->GetCurrentURI(getter_AddRefs(uri));
|
||||
nsCAutoString acstring;
|
||||
uri->GetSpec(acstring);
|
||||
|
||||
return QString::fromUtf8(acstring.get());
|
||||
}
|
||||
|
||||
QString QGeckoEmbed::resolvedUrl(const QString &relativepath) const
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
d->navigation->GetCurrentURI(getter_AddRefs(uri));
|
||||
nsCAutoString rel;
|
||||
rel.Assign(relativepath.utf8().data());
|
||||
nsCAutoString resolved;
|
||||
uri->Resolve(rel, resolved);
|
||||
|
||||
return QString::fromUtf8(resolved.get());
|
||||
}
|
||||
|
||||
void QGeckoEmbed::initialize(const char *aDir, const char *aName)
|
||||
{
|
||||
QGeckoGlobals::setProfilePath(aDir, aName);
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 QECKOEMBED_H
|
||||
#define QECKOEMBED_H
|
||||
|
||||
#include <qwidget.h>
|
||||
|
||||
class nsIDOMKeyEvent;
|
||||
class nsIDOMMouseEvent;
|
||||
class nsIDOMUIEvent;
|
||||
class nsModuleComponentInfo;
|
||||
class nsIDirectoryServiceProvider;
|
||||
class nsIAppShell;
|
||||
class nsVoidArray;
|
||||
class nsProfileDirServiceProvider;
|
||||
class nsIPref;
|
||||
class nsISupports;
|
||||
class EmbedWindow;
|
||||
class EmbedEventListener;
|
||||
class EmbedProgress;
|
||||
class nsIWebNavigation;
|
||||
class nsISHistory;
|
||||
class nsIDOMEventReceiver;
|
||||
class EmbedContentListener;
|
||||
class EmbedStream;
|
||||
class QHBox;
|
||||
class nsIDOMDocument;
|
||||
class nsPIDOMWindow;
|
||||
class QPaintEvent;
|
||||
|
||||
class QGeckoEmbedPrivate;
|
||||
|
||||
class QGeckoEmbed : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static void initialize(const char *aDir, const char *aName);
|
||||
public:
|
||||
enum ReloadFlags
|
||||
{
|
||||
Normal,
|
||||
BypassCache,
|
||||
BypassProxy,
|
||||
BypassProxyAndCache,
|
||||
CharsetChange
|
||||
};
|
||||
public:
|
||||
QGeckoEmbed(QWidget *parent, const char *name);
|
||||
~QGeckoEmbed();
|
||||
|
||||
bool canGoBack() const;
|
||||
bool canGoForward() const;
|
||||
|
||||
void setIsChrome(bool);
|
||||
int chromeMask() const;
|
||||
|
||||
nsIDOMDocument *document() const;
|
||||
QString url() const;
|
||||
QString resolvedUrl(const QString &relativepath) const;
|
||||
|
||||
public slots:
|
||||
void loadURL(const QString &url);
|
||||
void stopLoad();
|
||||
void goForward();
|
||||
void goBack();
|
||||
|
||||
void renderData(const QCString &data, const QString &baseURI,
|
||||
const QString &mimeType);
|
||||
|
||||
int openStream(const QString &baseURI, const QString &mimeType);
|
||||
int appendData(const QCString &data);
|
||||
int closeStream();
|
||||
|
||||
void reload(ReloadFlags flags = Normal);
|
||||
|
||||
void setChromeMask(int);
|
||||
|
||||
signals:
|
||||
void linkMessage(const QString &message);
|
||||
void jsStatusMessage(const QString &message);
|
||||
void locationChanged(const QString &location);
|
||||
void windowTitleChanged(const QString &title);
|
||||
|
||||
void progress(int current, int max);
|
||||
void progressAll(const QString &url, int current, int max);
|
||||
|
||||
void netState(int state, int status);
|
||||
void netStateAll(const QString &url, int state, int status);
|
||||
|
||||
void netStart();
|
||||
void netStop();
|
||||
|
||||
void newWindow(QGeckoEmbed *newWindow, int chromeMask);
|
||||
void visibilityChanged(bool visible);
|
||||
void destroyBrowser();
|
||||
void openURI(const QString &url);
|
||||
void sizeTo(int width, int height);
|
||||
|
||||
void securityChange(void *request, int status, void *message);
|
||||
void statusChange(void *request, int status, void *message);
|
||||
|
||||
void showContextMenu(const QPoint &p, const QString &url);
|
||||
|
||||
/**
|
||||
* The dom signals are called only if the dom* methods
|
||||
* are not reimplemented.
|
||||
*/
|
||||
void domKeyDown(nsIDOMKeyEvent *keyEvent);
|
||||
void domKeyPress(nsIDOMKeyEvent *keyEvent);
|
||||
void domKeyUp(nsIDOMKeyEvent *keyEvent);
|
||||
void domMouseDown(nsIDOMMouseEvent *mouseEvent);
|
||||
void domMouseUp(nsIDOMMouseEvent *mouseEvent);
|
||||
void domMouseClick(nsIDOMMouseEvent *mouseEvent);
|
||||
void domMouseDblClick(nsIDOMMouseEvent *mouseEvent);
|
||||
void domMouseOver(nsIDOMMouseEvent *mouseEvent);
|
||||
void domMouseOut(nsIDOMMouseEvent *mouseEvent);
|
||||
void domActivate(nsIDOMUIEvent *event);
|
||||
void domFocusIn(nsIDOMUIEvent *event);
|
||||
void domFocusOut(nsIDOMUIEvent *event);
|
||||
|
||||
|
||||
void startURIOpen(const QString &url, bool &abort);
|
||||
|
||||
protected:
|
||||
friend class EmbedEventListener;
|
||||
friend class EmbedContentListener;
|
||||
/**
|
||||
* return true if you want to stop the propagation
|
||||
* of the event. By default the events are being
|
||||
* propagated
|
||||
*/
|
||||
|
||||
virtual bool domKeyDownEvent(nsIDOMKeyEvent *keyEvent);
|
||||
virtual bool domKeyPressEvent(nsIDOMKeyEvent *keyEvent);
|
||||
virtual bool domKeyUpEvent(nsIDOMKeyEvent *keyEvent);
|
||||
|
||||
virtual bool domMouseDownEvent(nsIDOMMouseEvent *mouseEvent);
|
||||
virtual bool domMouseUpEvent(nsIDOMMouseEvent *mouseEvent);
|
||||
virtual bool domMouseClickEvent(nsIDOMMouseEvent *mouseEvent);
|
||||
virtual bool domMouseDblClickEvent(nsIDOMMouseEvent *mouseEvent);
|
||||
virtual bool domMouseOverEvent(nsIDOMMouseEvent *mouseEvent);
|
||||
virtual bool domMouseOutEvent(nsIDOMMouseEvent *mouseEvent);
|
||||
|
||||
virtual bool domActivateEvent(nsIDOMUIEvent *event);
|
||||
virtual bool domFocusInEvent(nsIDOMUIEvent *event);
|
||||
virtual bool domFocusOutEvent(nsIDOMUIEvent *event);
|
||||
|
||||
|
||||
protected:
|
||||
friend class EmbedWindow;
|
||||
friend class EmbedWindowCreator;
|
||||
friend class EmbedProgress;
|
||||
friend class EmbedContextMenuListener;
|
||||
friend class EmbedStream;
|
||||
friend class QGeckoGlobals;
|
||||
void emitScriptStatus(const QString &str);
|
||||
void emitLinkStatus(const QString &str);
|
||||
void contentStateChanged();
|
||||
void contentFinishedLoading();
|
||||
|
||||
bool isChrome() const;
|
||||
bool chromeLoaded() const;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
void setupListener();
|
||||
void attachListeners();
|
||||
|
||||
EmbedWindow *window() const;
|
||||
int GetPIDOMWindow(nsPIDOMWindow **aPIWin);
|
||||
|
||||
protected:
|
||||
QGeckoEmbedPrivate *d;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,293 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "qgeckoglobals.h"
|
||||
|
||||
#include "qgeckoembed.h"
|
||||
#include "EmbedWindow.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include <nsIDocShell.h>
|
||||
#include <nsIWebProgress.h>
|
||||
#include <nsIWebNavigation.h>
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsISHistory.h>
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include "nsIWidget.h"
|
||||
#include "nsCRT.h"
|
||||
#include <nsIWindowWatcher.h>
|
||||
#include <nsILocalFile.h>
|
||||
#include <nsEmbedAPI.h>
|
||||
#include <nsWidgetsCID.h>
|
||||
#include <nsIDOMUIEvent.h>
|
||||
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
#include <nsIComponentManager.h>
|
||||
#include <nsIFocusController.h>
|
||||
#include <nsProfileDirServiceProvider.h>
|
||||
#include <nsIGenericFactory.h>
|
||||
#include <nsIComponentRegistrar.h>
|
||||
#include <nsIPref.h>
|
||||
#include <nsVoidArray.h>
|
||||
#include <nsIDOMBarProp.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
#include <nsIDOMEventReceiver.h>
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
PRUint32 QGeckoGlobals::sWidgetCount = 0;
|
||||
char *QGeckoGlobals::sCompPath = nsnull;
|
||||
nsIAppShell *QGeckoGlobals::sAppShell = nsnull;
|
||||
char *QGeckoGlobals::sProfileDir = nsnull;
|
||||
char *QGeckoGlobals::sProfileName = nsnull;
|
||||
nsIPref *QGeckoGlobals::sPrefs = nsnull;
|
||||
nsVoidArray *QGeckoGlobals::sWindowList = nsnull;
|
||||
nsIDirectoryServiceProvider *QGeckoGlobals::sAppFileLocProvider = nsnull;
|
||||
nsProfileDirServiceProvider *QGeckoGlobals::sProfileDirServiceProvider = nsnull;
|
||||
|
||||
void
|
||||
QGeckoGlobals::pushStartup()
|
||||
{
|
||||
// increment the number of widgets
|
||||
sWidgetCount++;
|
||||
|
||||
// if this is the first widget, fire up xpcom
|
||||
if (sWidgetCount == 1) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> binDir;
|
||||
|
||||
if (sCompPath) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
}
|
||||
|
||||
rv = NS_InitEmbedding(binDir, sAppFileLocProvider);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
// we no longer need a reference to the DirectoryServiceProvider
|
||||
if (sAppFileLocProvider) {
|
||||
NS_RELEASE(sAppFileLocProvider);
|
||||
sAppFileLocProvider = nsnull;
|
||||
}
|
||||
|
||||
rv = startupProfile();
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Warning: Failed to start up profiles.\n");
|
||||
|
||||
// XXX startup appshell service?
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell;
|
||||
appShell = do_CreateInstance(kAppShellCID);
|
||||
if (!appShell) {
|
||||
NS_WARNING("Failed to create appshell in QGeckoGlobals::pushStartup!\n");
|
||||
return;
|
||||
}
|
||||
sAppShell = appShell.get();
|
||||
NS_ADDREF(sAppShell);
|
||||
sAppShell->Create(0, nsnull);
|
||||
sAppShell->Spinup();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoGlobals::popStartup()
|
||||
{
|
||||
sWidgetCount--;
|
||||
if (sWidgetCount == 0) {
|
||||
// shut down the profiles
|
||||
shutdownProfile();
|
||||
|
||||
if (sAppShell) {
|
||||
// Shutdown the appshell service.
|
||||
sAppShell->Spindown();
|
||||
NS_RELEASE(sAppShell);
|
||||
sAppShell = 0;
|
||||
}
|
||||
|
||||
// shut down XPCOM/Embedding
|
||||
NS_TermEmbedding();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoGlobals::setCompPath(const char *aPath)
|
||||
{
|
||||
if (sCompPath)
|
||||
free(sCompPath);
|
||||
if (aPath)
|
||||
sCompPath = strdup(aPath);
|
||||
else
|
||||
sCompPath = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoGlobals::setAppComponents(const nsModuleComponentInfo *,
|
||||
int)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoGlobals::setProfilePath(const char *aDir, const char *aName)
|
||||
{
|
||||
if (sProfileDir) {
|
||||
nsMemory::Free(sProfileDir);
|
||||
sProfileDir = nsnull;
|
||||
}
|
||||
|
||||
if (sProfileName) {
|
||||
nsMemory::Free(sProfileName);
|
||||
sProfileName = nsnull;
|
||||
}
|
||||
|
||||
if (aDir)
|
||||
sProfileDir = (char *)nsMemory::Clone(aDir, strlen(aDir) + 1);
|
||||
|
||||
if (aName)
|
||||
sProfileName = (char *)nsMemory::Clone(aName, strlen(aDir) + 1);
|
||||
}
|
||||
|
||||
void
|
||||
QGeckoGlobals::setDirectoryServiceProvider(nsIDirectoryServiceProvider
|
||||
*appFileLocProvider)
|
||||
{
|
||||
if (sAppFileLocProvider)
|
||||
NS_RELEASE(sAppFileLocProvider);
|
||||
|
||||
if (appFileLocProvider) {
|
||||
sAppFileLocProvider = appFileLocProvider;
|
||||
NS_ADDREF(sAppFileLocProvider);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
int
|
||||
QGeckoGlobals::startupProfile(void)
|
||||
{
|
||||
// initialize profiles
|
||||
if (sProfileDir && sProfileName) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> profileDir;
|
||||
NS_NewNativeLocalFile(nsDependentCString(sProfileDir), PR_TRUE,
|
||||
getter_AddRefs(profileDir));
|
||||
if (!profileDir)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = profileDir->AppendNative(nsDependentCString(sProfileName));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsProfileDirServiceProvider> locProvider;
|
||||
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
|
||||
if (!locProvider)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = locProvider->Register();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = locProvider->SetProfileDir(profileDir);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
// Keep a ref so we can shut it down.
|
||||
NS_ADDREF(sProfileDirServiceProvider = locProvider);
|
||||
|
||||
// get prefs
|
||||
nsCOMPtr<nsIPref> pref;
|
||||
pref = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (!pref)
|
||||
return NS_ERROR_FAILURE;
|
||||
sPrefs = pref.get();
|
||||
NS_ADDREF(sPrefs);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
QGeckoGlobals::shutdownProfile(void)
|
||||
{
|
||||
if (sProfileDirServiceProvider) {
|
||||
sProfileDirServiceProvider->Shutdown();
|
||||
NS_RELEASE(sProfileDirServiceProvider);
|
||||
sProfileDirServiceProvider = 0;
|
||||
}
|
||||
if (sPrefs) {
|
||||
NS_RELEASE(sPrefs);
|
||||
sPrefs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QGeckoGlobals::initializeGlobalObjects()
|
||||
{
|
||||
if (!sWindowList) {
|
||||
sWindowList = new nsVoidArray();
|
||||
}
|
||||
}
|
||||
|
||||
void QGeckoGlobals::addEngine(QGeckoEmbed *embed)
|
||||
{
|
||||
sWindowList->AppendElement(embed);
|
||||
}
|
||||
|
||||
void QGeckoGlobals::removeEngine(QGeckoEmbed *embed)
|
||||
{
|
||||
sWindowList->RemoveElement(embed);
|
||||
}
|
||||
|
||||
QGeckoEmbed *QGeckoGlobals::findPrivateForBrowser(nsIWebBrowserChrome *aBrowser)
|
||||
{
|
||||
if (!sWindowList)
|
||||
return nsnull;
|
||||
|
||||
// Get the number of browser windows.
|
||||
PRInt32 count = sWindowList->Count();
|
||||
// This function doesn't get called very often at all ( only when
|
||||
// creating a new window ) so it's OK to walk the list of open
|
||||
// windows.
|
||||
for (int i = 0; i < count; i++) {
|
||||
QGeckoEmbed *tmpPrivate = NS_STATIC_CAST(QGeckoEmbed *,
|
||||
sWindowList->ElementAt(i));
|
||||
// get the browser object for that window
|
||||
nsIWebBrowserChrome *chrome = NS_STATIC_CAST(nsIWebBrowserChrome *,
|
||||
tmpPrivate->window());
|
||||
if (chrome == aBrowser)
|
||||
return tmpPrivate;
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 QECKOGLOBALS_H
|
||||
#define QECKOGLOBALS_H
|
||||
|
||||
#include "prenv.h"
|
||||
|
||||
class nsModuleComponentInfo;
|
||||
class nsIDirectoryServiceProvider;
|
||||
class nsModuleComponentInfo;
|
||||
class nsIAppShell;
|
||||
class nsVoidArray;
|
||||
class nsProfileDirServiceProvider;
|
||||
class nsIPref;
|
||||
class nsIDirectoryServiceProvider;
|
||||
class nsIWebBrowserChrome;
|
||||
|
||||
class QGeckoGlobals
|
||||
{
|
||||
friend class QGeckoEmbed;
|
||||
public:
|
||||
static void initializeGlobalObjects();
|
||||
static void pushStartup();
|
||||
static void popStartup();
|
||||
static void setCompPath(const char *aPath);
|
||||
static void setAppComponents(const nsModuleComponentInfo *aComps,
|
||||
int aNumComponents);
|
||||
static void setProfilePath(const char *aDir, const char *aName);
|
||||
static void setDirectoryServiceProvider(nsIDirectoryServiceProvider
|
||||
*appFileLocProvider);
|
||||
static int startupProfile(void);
|
||||
static void shutdownProfile(void);
|
||||
|
||||
static void addEngine(QGeckoEmbed *embed);
|
||||
static void removeEngine(QGeckoEmbed *embed);
|
||||
static QGeckoEmbed *findPrivateForBrowser(nsIWebBrowserChrome *aBrowser);
|
||||
private:
|
||||
static PRUint32 sWidgetCount;
|
||||
// the path to components
|
||||
static char *sCompPath;
|
||||
// the list of application-specific components to register
|
||||
static const nsModuleComponentInfo *sAppComps;
|
||||
static int sNumAppComps;
|
||||
// the appshell we have created
|
||||
static nsIAppShell *sAppShell;
|
||||
// what is our profile path?
|
||||
static char *sProfileDir;
|
||||
static char *sProfileName;
|
||||
// for profiles
|
||||
static nsProfileDirServiceProvider *sProfileDirServiceProvider;
|
||||
static nsIPref *sPrefs;
|
||||
static nsIDirectoryServiceProvider *sAppFileLocProvider;
|
||||
|
||||
// the list of all open windows
|
||||
static nsVoidArray *sWindowList;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,2 @@
|
|||
Makefile
|
||||
.deps
|
|
@ -0,0 +1,87 @@
|
|||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = qgeckoembed
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
$(NULL)
|
||||
|
||||
ifdef NS_TRACE_MALLOC
|
||||
REQUIRES += tracemalloc
|
||||
endif
|
||||
|
||||
ifdef MOZ_JPROF
|
||||
REQUIRES += jprof
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
$(MOCSRCS) \
|
||||
mainwindow.cpp \
|
||||
TestQGeckoEmbed.cpp
|
||||
|
||||
MOCSRCS = \
|
||||
moc_mainwindow.cpp \
|
||||
$(NULL)
|
||||
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
PROGRAM = $(CPPSRCS:.cpp=)
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
LIBS += \
|
||||
-lqgeckoembed \
|
||||
$(XLDFLAGS) \
|
||||
$(XLIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
# Force applications to be built non-statically
|
||||
# when building the mozcomps meta component
|
||||
ifneq (,$(filter mozcomps,$(MOZ_META_COMPONENTS)))
|
||||
BUILD_STATIC_LIBS=
|
||||
BUILD_SHARED_LIBS=1
|
||||
endif
|
||||
|
||||
ifdef NS_TRACE_MALLOC
|
||||
EXTRA_LIBS += -ltracemalloc
|
||||
endif
|
||||
|
||||
ifdef MOZ_PERF_METRICS
|
||||
EXTRA_LIBS += -lmozutil_s
|
||||
endif
|
||||
|
||||
ifdef MOZ_JPROF
|
||||
EXTRA_LIBS += -ljprof
|
||||
endif
|
||||
|
||||
EXTRA_LIBS += $(MOZ_JS_LIBS)
|
||||
EXTRA_LIBS += $(MOZ_COMPONENT_LIBS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
|
||||
EXTRA_LIBS += \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
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
|
||||
|
||||
ifeq ($(OS_ARCH), OpenVMS)
|
||||
DEFINES += -DGENERIC_MOTIF_REDEFINES
|
||||
endif
|
|
@ -0,0 +1,52 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <qaction.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qhbox.h>
|
||||
|
||||
#include "qgeckoembed.h"
|
||||
|
||||
|
||||
MyMainWindow::MyMainWindow()
|
||||
{
|
||||
QHBox *box = new QHBox(this);
|
||||
qecko = new QGeckoEmbed(box, "qgecko");
|
||||
box->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
setCentralWidget( box );
|
||||
|
||||
//QToolBar *toolbar = new QToolBar(this);
|
||||
|
||||
QPopupMenu *menu = new QPopupMenu(this);
|
||||
menuBar()->insertItem( tr( "&File" ), menu );
|
||||
|
||||
QAction *a = new QAction( QPixmap::fromMimeSource( "filenew.xpm" ), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
|
||||
connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
|
||||
//a->addTo( toolbar );
|
||||
a->addTo( menu );
|
||||
|
||||
|
||||
connect( qecko, SIGNAL(linkMessage(const QString &)),
|
||||
statusBar(), SLOT(message(const QString &)) );
|
||||
connect( qecko, SIGNAL(jsStatusMessage(const QString &)),
|
||||
statusBar(), SLOT(message(const QString &)) );
|
||||
connect( qecko, SIGNAL(windowTitleChanged(const QString &)),
|
||||
SLOT(setCaption(const QString &)) );
|
||||
connect( qecko, SIGNAL(startURIOpen(const QString &, bool &)),
|
||||
SLOT(startURIOpen(const QString &, bool &)) );
|
||||
|
||||
}
|
||||
|
||||
void MyMainWindow::fileOpen()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName( QString::null, tr( "HTML-Files (*.htm *.html);;All Files (*)" ), this );
|
||||
if ( !fn.isEmpty() )
|
||||
qecko->loadURL( fn );
|
||||
}
|
||||
|
||||
void MyMainWindow::startURIOpen(const QString &, bool &)
|
||||
{
|
||||
qDebug("XX in the signal");
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <qmainwindow.h>
|
||||
|
||||
class QGeckoEmbed;
|
||||
|
||||
class MyMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyMainWindow();
|
||||
|
||||
public slots:
|
||||
void fileOpen();
|
||||
void startURIOpen(const QString &, bool &);
|
||||
public:
|
||||
QGeckoEmbed *qecko;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -96,12 +96,16 @@ else
|
|||
ifdef MOZ_ENABLE_GTK2
|
||||
DIRS += gtk
|
||||
endif
|
||||
ifdef MOZ_ENABLE_QT
|
||||
DIRS += qt
|
||||
endif
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
DIRS += xlib
|
||||
endif
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
#
|
||||
# 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>
|
||||
# Zack Rusin <zack@kde.org>
|
||||
#
|
||||
|
||||
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
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxQtModule
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
widget \
|
||||
view \
|
||||
uconv \
|
||||
pref \
|
||||
util \
|
||||
js \
|
||||
mozcomps \
|
||||
unicharutil \
|
||||
intl \
|
||||
locale \
|
||||
content \
|
||||
$(NULL)
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextQt.cpp \
|
||||
nsDeviceContextSpecFactoryQt.cpp \
|
||||
nsDeviceContextSpecQt.cpp \
|
||||
nsDrawingSurfaceQt.cpp \
|
||||
nsFontMetricsQt.cpp \
|
||||
nsGfxFactoryQt.cpp \
|
||||
nsImageQt.cpp \
|
||||
nsNativeThemeQt.cpp \
|
||||
nsRegionQt.cpp \
|
||||
nsRenderingContextQt.cpp \
|
||||
nsScreenManagerQt.cpp \
|
||||
nsScreenQt.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LIBS = gkgfx gfxshared_s
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
CFLAGS += $(MOZ_QT_CFLAGS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_QT_LDFLAGS) \
|
||||
$(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
|
||||
REQUIRES += xprintutil
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/. \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../shared \
|
||||
$(NULL)
|
||||
|
|
@ -0,0 +1,512 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 "nsIPrefService.h"
|
||||
#include "nsIPrefBranchInternal.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 <qfontdatabase.h>
|
||||
#include <qfontmetrics.h>
|
||||
#include <qwidgetlist.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 = 0;
|
||||
|
||||
nsDeviceContextQt::nsDeviceContextQt()
|
||||
: DeviceContextImpl()
|
||||
{
|
||||
mTwipsToPixels = 1.0;
|
||||
mPixelsToTwips = 1.0;
|
||||
mDepth = 0 ;
|
||||
mWidthFloat = 0.0f;
|
||||
mHeightFloat = 0.0f;
|
||||
mWidth = -1;
|
||||
mHeight = -1;
|
||||
}
|
||||
|
||||
nsDeviceContextQt::~nsDeviceContextQt()
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranchInternal> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (pbi) {
|
||||
pbi->RemoveObserver("browser.display.screen_resolution", this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::Init(nsNativeWidget aNativeWidget)
|
||||
{
|
||||
PRBool bCleanUp = PR_FALSE;
|
||||
QWidget *pWidget = nsnull;
|
||||
|
||||
mWidget = (QWidget*)aNativeWidget;
|
||||
|
||||
if (mWidget != nsnull)
|
||||
pWidget = mWidget;
|
||||
else {
|
||||
pWidget = new QWidget();
|
||||
bCleanUp = PR_TRUE;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mDpi) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
SetDPI(prefVal);
|
||||
} else {
|
||||
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
|
||||
|
||||
QStyle &style = pWidget->style();
|
||||
mScrollbarWidth = mScrollbarHeight = style.pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||
|
||||
DeviceContextImpl::CommonInit();
|
||||
|
||||
if (bCleanUp)
|
||||
delete pWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceContextQt::CreateRenderingContext(nsIRenderingContext *&aContext)
|
||||
{
|
||||
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
|
||||
nsCOMPtr<nsRenderingContextQt> pContext( new nsRenderingContextQt() );
|
||||
|
||||
// create the nsDrawingSurfaceQt
|
||||
surf = new nsDrawingSurfaceQt();
|
||||
|
||||
if (surf) {
|
||||
//Handled by the nsDrawingSurfaceQt
|
||||
//FIXME: instead of passing it around
|
||||
// create it in the nsDrawingSurface init method
|
||||
QPainter *gc = new QPainter();
|
||||
|
||||
// init the nsDrawingSurfaceQt
|
||||
if (pDev)
|
||||
rv = surf->Init(pDev,gc);
|
||||
else
|
||||
rv = surf->Init(gc,10,10,0);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
// Init the nsRenderingContextQt
|
||||
rv = pContext->Init(this,surf);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aContext = pContext;
|
||||
NS_ADDREF(aContext);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::CreateRenderingContextInstance(nsIRenderingContext *&aContext)
|
||||
{
|
||||
return CreateRenderingContext(aContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceContextQt::SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||
{
|
||||
//XXX it is very critical that this not lie!! MMP
|
||||
// read the comments in the mac code for this
|
||||
// ##############
|
||||
aSupportsWidgets = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::GetScrollBarDimensions(float &aWidth,
|
||||
float &aHeight) const
|
||||
{
|
||||
float scale;
|
||||
GetCanonicalPixelScale(scale);
|
||||
aWidth = mScrollbarWidth * mPixelsToTwips * scale;
|
||||
aHeight = mScrollbarHeight * mPixelsToTwips * scale;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceContextQt::GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
QString family = QString::fromUcs2(aFontName.get());
|
||||
QStringList families = QFontDatabase().families();
|
||||
return families.find(family) != families.end();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::GetDeviceSurfaceDimensions(PRInt32 &aWidth,
|
||||
PRInt32 &aHeight)
|
||||
{
|
||||
if (-1 == mWidth)
|
||||
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
|
||||
|
||||
if (-1 == mHeight)
|
||||
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
|
||||
|
||||
aWidth = mWidth;
|
||||
aHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::GetRect(nsRect &aRect)
|
||||
{
|
||||
PRInt32 width,height;
|
||||
nsresult rv;
|
||||
|
||||
rv = GetDeviceSurfaceDimensions(width,height);
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = width;
|
||||
aRect.height = height;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::GetClientRect(nsRect &aRect)
|
||||
{
|
||||
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*/)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::EndDocument(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::BeginPage(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::EndPage(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQt::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
aDepth = mDepth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextQt::SetDPI(PRInt32 aDpi)
|
||||
{
|
||||
// Set OSVal to what the operating system thinks the logical resolution is.
|
||||
PRInt32 OSVal = 0;
|
||||
|
||||
QWidget *pDev = mWidget;
|
||||
if (!pDev) {
|
||||
QWidgetList *wlist = QApplication::allWidgets();
|
||||
pDev = wlist->first();
|
||||
qDebug("number of widgets is %d", wlist->count() );
|
||||
delete wlist;
|
||||
}
|
||||
|
||||
QPaintDeviceMetrics qPaintMetrics(pDev);
|
||||
OSVal = qPaintMetrics.logicalDpiX();
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!pDev)
|
||||
qDebug("nsDeviceContextQt::SetDPI called without widget (find cleaner solution)");
|
||||
#endif
|
||||
|
||||
if (aDpi > 0) {
|
||||
// If there's a valid pref value for the logical resolution,
|
||||
// use it.
|
||||
mDpi = aDpi;
|
||||
}
|
||||
else if (aDpi == 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;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceContextQt::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) != 0) {
|
||||
// Our local observer only handles pref changes.
|
||||
// Forward everything else to our super class.
|
||||
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);
|
||||
return NS_OK;
|
||||
} else
|
||||
return DeviceContextImpl::Observe(aSubject, aTopic, aData);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContextQt::GetSystemFontInfo(nsFont* aFont) const
|
||||
{
|
||||
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.Assign(theFontInfo.family().ucs2());
|
||||
if (theFontInfo.bold()) {
|
||||
aFont->weight = NS_FONT_WEIGHT_BOLD;
|
||||
}
|
||||
rawWeight = theFontInfo.pixelSize();
|
||||
aFont->size = NSIntPixelsToTwips(rawWeight,mPixelsToTwips);
|
||||
if (theFontInfo.italic()) {
|
||||
aFont->style = NS_FONT_STYLE_ITALIC;
|
||||
}
|
||||
if (theFontInfo.underline()) {
|
||||
aFont->decorations = NS_FONT_DECORATION_UNDERLINE;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 CreateRenderingContext(nsIDrawingSurface* aSurface, nsIRenderingContext *&aContext)
|
||||
{return (DeviceContextImpl::CreateRenderingContext(aSurface, aContext));}
|
||||
NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext);
|
||||
|
||||
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
|
||||
|
||||
NS_IMETHOD GetScrollBarDimensions(float &aWidth,float &aHeight) const;
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
|
||||
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);
|
||||
|
||||
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData);
|
||||
|
||||
nsresult SetDPI(PRInt32 dpi);
|
||||
|
||||
private:
|
||||
PRUint32 mDepth;
|
||||
PRInt16 mScrollbarHeight;
|
||||
PRInt16 mScrollbarWidth;
|
||||
QWidget *mWidget;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
float mWidthFloat;
|
||||
float mHeightFloat;
|
||||
|
||||
static nscoord mDpi;
|
||||
|
||||
nsresult GetSystemFontInfo(nsFont *aFont) const;
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextQt_h___ */
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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___ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,136 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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
|
||||
#warning "postscript hardcore disabled"
|
||||
#if 0
|
||||
|
||||
, public nsIDeviceContextSpecPS
|
||||
#endif
|
||||
#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___ */
|
|
@ -0,0 +1,258 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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_ISUPPORTS1(nsDrawingSurfaceQt, nsIDrawingSurface)
|
||||
|
||||
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;
|
||||
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();
|
||||
}
|
||||
|
||||
delete mGC;
|
||||
mGC = nsnull;
|
||||
|
||||
if (mPaintDevice) {
|
||||
if (mIsOffscreen && !mPaintDevice->paintingActive() && mPaintDevice != &mPixmap)
|
||||
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.isNull()) {
|
||||
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.isNull()) {
|
||||
NS_ASSERTION(0, "NULL pixmap in unlock attempt");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY)) {
|
||||
qDebug("nsDrawingSurfaceQt::Unlock: w/h=%d/%d", mPixmap.width(), mPixmap.height());
|
||||
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;
|
||||
|
||||
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 = QPixmap(mWidth, mHeight, mDepth);
|
||||
mPaintDevice = &mPixmap;
|
||||
NS_ASSERTION(mPaintDevice, "this better not fail");
|
||||
|
||||
mIsOffscreen = PR_TRUE;
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 <qpainter.h>
|
||||
#include <qimage.h>
|
||||
|
||||
class QPixmap;
|
||||
|
||||
class nsDrawingSurfaceQt : public nsIDrawingSurface
|
||||
{
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
// 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
|
|
@ -0,0 +1,381 @@
|
|||
/* ***** 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 ***** */
|
||||
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsFontMetricsQt.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISaveAsCharset.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nspr.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsDrawingSurfaceQt.h"
|
||||
#include "nsRenderingContextQt.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
#include "nsDrawingSurfaceQt.h"
|
||||
#include "nsRenderingContextQt.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qfont.h>
|
||||
#include <qfontdatabase.h>
|
||||
|
||||
#include "qtlog.h"
|
||||
|
||||
nsFontQt::nsFontQt(const nsFont &aFont, nsIAtom *aLangGroup, nsIDeviceContext *aContext)
|
||||
{
|
||||
mFont = aFont;
|
||||
mLangGroup = aLangGroup;
|
||||
mDeviceContext = aContext;
|
||||
|
||||
float a2d = aContext->AppUnitsToDevUnits();
|
||||
mPixelSize = NSToIntRound(a2d * mFont.size);
|
||||
|
||||
if (mLangGroup) {
|
||||
nsCAutoString name("font.min-size.variable.");
|
||||
const char* langGroup = nsnull;
|
||||
mLangGroup->GetUTF8String(&langGroup);
|
||||
|
||||
PRInt32 minimum = 0;
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIPrefBranch> branch;
|
||||
prefs->GetBranch(name.get(), getter_AddRefs(branch));
|
||||
branch->GetIntPref(langGroup, &minimum);
|
||||
}
|
||||
if (minimum < 0) {
|
||||
minimum = 0;
|
||||
}
|
||||
if (mPixelSize < minimum) {
|
||||
mPixelSize = minimum;
|
||||
}
|
||||
}
|
||||
|
||||
font.setFamily(QString::fromUcs2(mFont.name.get()));
|
||||
font.setPixelSize(mPixelSize);
|
||||
font.setWeight(mFont.weight/10);
|
||||
font.setItalic(mFont.style != NS_FONT_STYLE_NORMAL);
|
||||
|
||||
RealizeFont();
|
||||
}
|
||||
|
||||
void nsFontQt::RealizeFont()
|
||||
{
|
||||
QFontMetrics fm(font);
|
||||
|
||||
float f = mDeviceContext->DevUnitsToAppUnits();
|
||||
|
||||
mMaxAscent = nscoord(fm.ascent() * f) ;
|
||||
mMaxDescent = nscoord(fm.descent() * f);
|
||||
mMaxHeight = mMaxAscent + mMaxDescent;
|
||||
|
||||
mEmHeight = nscoord(fm.height() * f);
|
||||
mMaxAdvance = nscoord(fm.maxWidth() * f);
|
||||
|
||||
mAveCharWidth = nscoord(fm.width(QChar('x')) * f);
|
||||
|
||||
mEmAscent = mMaxAscent;
|
||||
mEmDescent = mMaxDescent;
|
||||
|
||||
mXHeight = NSToCoordRound(fm.boundingRect('x').height() * f);
|
||||
|
||||
mUnderlineOffset = - nscoord(fm.underlinePos() * f);
|
||||
|
||||
mUnderlineSize = NSToIntRound(fm.lineWidth() * f);
|
||||
|
||||
mSuperscriptOffset = mXHeight;
|
||||
mSubscriptOffset = mXHeight;
|
||||
|
||||
mStrikeoutOffset = nscoord(fm.strikeOutPos() * f);
|
||||
mStrikeoutSize = mUnderlineSize;
|
||||
|
||||
mLeading = nscoord(fm.leading() * f);
|
||||
mSpaceWidth = nscoord(fm.width(QChar(' ')) * f);
|
||||
}
|
||||
|
||||
nsFontMetricsQt::nsFontMetricsQt()
|
||||
{
|
||||
qFont = 0;
|
||||
}
|
||||
|
||||
nsFontMetricsQt::~nsFontMetricsQt()
|
||||
{
|
||||
NS_ASSERTION(qFont == 0, "deleting non destroyed nsFontMetricsQt");
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFontMetricsQt,nsIFontMetrics)
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::Init(const nsFont &aFont, nsIAtom *aLangGroup,
|
||||
nsIDeviceContext *aContext)
|
||||
{
|
||||
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
|
||||
|
||||
qFont = new nsFontQt(aFont, aLangGroup, aContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::Destroy()
|
||||
{
|
||||
delete qFont;
|
||||
qFont = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetXHeight(nscoord &aResult)
|
||||
{
|
||||
aResult = qFont->mXHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetSuperscriptOffset(nscoord &aResult)
|
||||
{
|
||||
aResult = qFont->mSuperscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetSubscriptOffset(nscoord &aResult)
|
||||
{
|
||||
aResult = qFont->mSubscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetStrikeout(nscoord &aOffset,nscoord &aSize)
|
||||
{
|
||||
aOffset = qFont->mStrikeoutOffset;
|
||||
aSize = qFont->mStrikeoutSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetUnderline(nscoord &aOffset,nscoord &aSize)
|
||||
{
|
||||
aOffset = qFont->mUnderlineOffset;
|
||||
aSize = qFont->mUnderlineSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = qFont->mMaxHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetNormalLineHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = qFont->mEmHeight + qFont->mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetLeading(nscoord &aLeading)
|
||||
{
|
||||
aLeading = qFont->mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetEmHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = qFont->mEmHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetEmAscent(nscoord &aAscent)
|
||||
{
|
||||
aAscent = qFont->mEmAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetEmDescent(nscoord &aDescent)
|
||||
{
|
||||
aDescent = qFont->mEmDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetMaxHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = qFont->mMaxHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetMaxAscent(nscoord &aAscent)
|
||||
{
|
||||
aAscent = qFont->mMaxAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetMaxDescent(nscoord &aDescent)
|
||||
{
|
||||
aDescent = qFont->mMaxDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetMaxAdvance(nscoord &aAdvance)
|
||||
{
|
||||
aAdvance = qFont->mMaxAdvance;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetAveCharWidth(nscoord &aAveCharWidth)
|
||||
{
|
||||
aAveCharWidth = qFont->mAveCharWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetSpaceWidth(nscoord &aSpaceWidth)
|
||||
{
|
||||
aSpaceWidth = qFont->mSpaceWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetFont(const nsFont *&aFont)
|
||||
{
|
||||
aFont = &qFont->mFont;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetLangGroup(nsIAtom **aLangGroup)
|
||||
{
|
||||
if (!aLangGroup) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aLangGroup = qFont->mLangGroup;
|
||||
NS_IF_ADDREF(*aLangGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsQt::GetFontHandle(nsFontHandle &aHandle)
|
||||
{
|
||||
aHandle = (nsFontHandle)qFont;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult EnumFonts(nsIAtom *aLangGroup,const char *aGeneric,
|
||||
PRUint32 *aCount,PRUnichar ***aResult)
|
||||
{
|
||||
/* Get list of all fonts */
|
||||
QStringList qFamilies = QFontDatabase().families();
|
||||
int count = qFamilies.count();
|
||||
|
||||
PRUnichar **array = (PRUnichar**)nsMemory::Alloc(count * sizeof(PRUnichar*));
|
||||
|
||||
int i = 0;
|
||||
for (QStringList::ConstIterator famIt = qFamilies.begin(); famIt != qFamilies.end(); ++famIt) {
|
||||
QString family = *famIt;
|
||||
array[i] = new PRUnichar[family.length()];
|
||||
memcpy(array[i], family.unicode(), family.length()*sizeof(PRUnichar));
|
||||
}
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsFontEnumeratorQt::nsFontEnumeratorQt()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFontEnumeratorQt, nsIFontEnumerator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorQt::EnumerateAllFonts(PRUint32 *aCount,PRUnichar ***aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aCount);
|
||||
*aCount = 0;
|
||||
|
||||
return EnumFonts(nsnull,nsnull,aCount,aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorQt::EnumerateFonts(const char *aLangGroup,const char *aGeneric,
|
||||
PRUint32 *aCount,PRUnichar ***aResult)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aCount);
|
||||
*aCount = 0;
|
||||
NS_ENSURE_ARG_POINTER(aGeneric);
|
||||
NS_ENSURE_ARG_POINTER(aLangGroup);
|
||||
|
||||
nsIAtom *langGroup = NS_NewAtom(aLangGroup);
|
||||
res = EnumFonts(langGroup,aGeneric,aCount,aResult);
|
||||
NS_IF_RELEASE(langGroup);
|
||||
return(res);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorQt::HaveFontFor(const char *aLangGroup,PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aLangGroup);
|
||||
|
||||
*aResult = PR_TRUE; // always return true for now.
|
||||
// Finish me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorQt::GetDefaultFont(const char *aLangGroup,
|
||||
const char *aGeneric,
|
||||
PRUnichar **aResult)
|
||||
{
|
||||
// aLangGroup=null or "" means any (i.e., don't care)
|
||||
// aGeneric=null or "" means any (i.e, don't care)
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorQt::UpdateFontList(PRBool *updateFontList)
|
||||
{
|
||||
*updateFontList = PR_FALSE; // always return false for now
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 "nsVoidArray.h"
|
||||
#include "nsFont.h"
|
||||
|
||||
#include <qfont.h>
|
||||
#include <qfontmetrics.h>
|
||||
|
||||
class nsFont;
|
||||
class nsString;
|
||||
class nsRenderingContextQt;
|
||||
class nsDrawingSurfaceQt;
|
||||
class nsFontMetricsQt;
|
||||
class nsFontQtUserDefined;
|
||||
class QString;
|
||||
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(const nsFont &afont, nsIAtom *aLangGroup, nsIDeviceContext *acontext);
|
||||
~nsFontQt() {}
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
bool SupportsChar(PRUnichar c) { return QFontMetrics(font).inFont(QChar(c)); }
|
||||
|
||||
QFont font;
|
||||
|
||||
nsIDeviceContext *mDeviceContext;
|
||||
nsCOMPtr<nsIAtom> mLangGroup;
|
||||
nsFont mFont;
|
||||
|
||||
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;
|
||||
|
||||
PRUint16 mPixelSize;
|
||||
PRUint16 mWeight;
|
||||
|
||||
void RealizeFont();
|
||||
|
||||
#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 *qFont;
|
||||
|
||||
#if 0
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
QIntDict<char> mCharSubst;
|
||||
|
||||
|
||||
static QFontDatabase *mQFontDB;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
private:
|
||||
PRUint32 mID;
|
||||
#endif
|
||||
};
|
||||
|
||||
class nsFontEnumeratorQt : public nsIFontEnumerator
|
||||
{
|
||||
public:
|
||||
nsFontEnumeratorQt();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFONTENUMERATOR
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,182 @@
|
|||
/* ***** 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 "nsNativeThemeQt.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)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeQt)
|
||||
|
||||
// our custom constructors
|
||||
static nsresult nsScriptableRegionConstructor(nsISupports *aOuter,REFNSIID aIID,void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIScriptableRegion *inst = 0;
|
||||
|
||||
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, },
|
||||
{ "Native Theme Renderer",
|
||||
NS_THEMERENDERER_CID,
|
||||
"@mozilla.org/chrome/chrome-native-theme;1",
|
||||
nsNativeThemeQtConstructor },
|
||||
{ "Print Session",
|
||||
NS_PRINTSESSION_CID,
|
||||
"@mozilla.org/gfx/printsession;1",
|
||||
nsPrintSessionConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsGfxQtModule, components)
|
||||
|
|
@ -0,0 +1,524 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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()
|
||||
: mWidth(0)
|
||||
, mHeight(0)
|
||||
, mDepth(0)
|
||||
, mRowBytes(0)
|
||||
, mImageBits(nsnull)
|
||||
, mAlphaDepth(0)
|
||||
, mAlphaRowBytes(0)
|
||||
, mAlphaBits(nsnull)
|
||||
, mNumBytesPixel(0)
|
||||
, pixmapDirty(PR_FALSE)
|
||||
{
|
||||
#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[] mImageBits;
|
||||
mImageBits = nsnull;
|
||||
}
|
||||
if (nsnull != mAlphaBits) {
|
||||
delete[] mAlphaBits;
|
||||
mAlphaBits = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
|
||||
// if (32 == aDepth) {
|
||||
// mNumBytesPixel = 4;
|
||||
// mDepth = aDepth;
|
||||
// }
|
||||
// else
|
||||
if (24 == aDepth) {
|
||||
mNumBytesPixel = 3;
|
||||
mDepth = aDepth;
|
||||
}
|
||||
else {
|
||||
NS_NOTREACHED("unexpected image depth");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
mRowBytes = (mWidth*mDepth/8 + 3) & ~0x3;
|
||||
|
||||
switch (aMaskRequirements) {
|
||||
case nsMaskRequirements_kNeeds1Bit:
|
||||
mAlphaRowBytes = (aWidth + 7) / 8;
|
||||
mAlphaDepth = 1;
|
||||
// 32-bit align each row
|
||||
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
|
||||
break;
|
||||
|
||||
case nsMaskRequirements_kNeeds8Bit:
|
||||
mAlphaRowBytes = aWidth;
|
||||
mAlphaDepth = 8;
|
||||
// 32-bit align each row
|
||||
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
|
||||
break;
|
||||
default:
|
||||
mAlphaDepth = 0;
|
||||
mAlphaRowBytes = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
mImageBits = (PRUint8*)new PRUint8[mRowBytes * mHeight];
|
||||
mAlphaBits = new PRUint8[mAlphaRowBytes * mHeight];
|
||||
|
||||
pixmapDirty = PR_TRUE;
|
||||
|
||||
PR_LOG(gQtLogModule, QT_BASIC, ("nsImageQt::Init succeeded"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// set up the palette to the passed in color array, RGB only in this array
|
||||
void nsImageQt::ImageUpdated(nsIDeviceContext *aContext,
|
||||
PRUint8 aFlags,nsRect *aUpdateRect)
|
||||
{
|
||||
//qDebug("image updated");
|
||||
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged,aFlags))
|
||||
pixmapDirty = PR_TRUE;
|
||||
|
||||
mDecodedRect.UnionRect(mDecodedRect, *aUpdateRect);
|
||||
}
|
||||
|
||||
// Draw the bitmap, this method has a source and destination coordinates
|
||||
NS_IMETHODIMP nsImageQt::Draw(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY,
|
||||
PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
{
|
||||
// qDebug("draw x = %d, y = %d, w = %d, h = %d, dx = %d, dy = %d, dw = %d, dy = %d",
|
||||
// aSX, aSY, aSWidth, aSHeight, aDX, aDY, aDWidth, aDHeight);
|
||||
if (aSWidth <= 0 || aDWidth <= 0 || aSHeight <= 0 || aDHeight <= 0)
|
||||
return NS_OK;
|
||||
if (nsnull == aSurface) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (pixmapDirty)
|
||||
updatePixmap();
|
||||
|
||||
nsDrawingSurfaceQt *drawing = (nsDrawingSurfaceQt*)aSurface;
|
||||
|
||||
// The code below seems to be wrong and not what gecko expects.
|
||||
// if ((aSWidth != aDWidth || aSHeight != aDHeight)
|
||||
// && (aSWidth != mWidth || aSHeight != mHeight)) {
|
||||
// QPixmap tmp(aSWidth, aSHeight);
|
||||
// copyBlt(&tmp, 0, 0, &pixmap, aSX, aSY, aSWidth, aSHeight);
|
||||
// drawing->GetGC()->drawPixmap(aDX, aDY, pixmap, aSX, aSY, aSWidth, aSHeight);
|
||||
// }
|
||||
|
||||
nsRect sourceRect(aSX, aSY, aSWidth, aSHeight);
|
||||
if (!sourceRect.IntersectRect(sourceRect, mDecodedRect))
|
||||
return NS_OK;
|
||||
|
||||
// Now get the part of the image that should be drawn
|
||||
// Copy into a new image so we can scale afterwards
|
||||
QImage image(pixmap.convertToImage().copy(sourceRect.x, sourceRect.y,
|
||||
sourceRect.width, sourceRect.height));
|
||||
|
||||
if (image.isNull())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Find the scale factor
|
||||
float w_factor = (float)aDWidth / aSWidth;
|
||||
float h_factor = (float)aDHeight / aSHeight;
|
||||
|
||||
// If we had to draw only part of the requested image, must adjust
|
||||
// destination coordinates
|
||||
aDX += PRInt32((sourceRect.x - aSX) * w_factor);
|
||||
aDY += PRInt32((sourceRect.y - aSY) * h_factor);
|
||||
image = image.scale(int(sourceRect.width * w_factor), int(sourceRect.height * h_factor));
|
||||
drawing->GetGC()->drawImage(QPoint(aDX, aDY), image);
|
||||
|
||||
//drawing->GetGC()->drawPixmap(aDX, aDY, pixmap, aSX, aSY, aSWidth, aSHeight);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Draw the bitmap, this draw just has destination coordinates
|
||||
NS_IMETHODIMP nsImageQt::Draw(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
return Draw(aContext, aSurface, 0, 0, mWidth, mHeight, aX, aY, aWidth, aHeight);
|
||||
}
|
||||
|
||||
void nsImageQt::updatePixmap()
|
||||
{
|
||||
//qDebug("updatePixmap");
|
||||
QImage qimage(mWidth, mHeight, 32);
|
||||
const PRInt32 bytesPerPixel = mDepth / 8;
|
||||
PRUint8 *image = mImageBits;
|
||||
PRUint8 *alpha = mAlphaBits;
|
||||
|
||||
PRInt32 i,j;
|
||||
QRgb *line;
|
||||
|
||||
qimage.setAlphaBuffer(mAlphaDepth != 0);
|
||||
switch(mAlphaDepth) {
|
||||
case 0:
|
||||
for (i = 0; i < mHeight; i++) {
|
||||
line = (QRgb*)qimage.scanLine(i);
|
||||
|
||||
PRUint8 *imagePtr = image;
|
||||
for (j = 0; j < mWidth; j++) {
|
||||
line[j] = qRgb(*imagePtr, *(imagePtr+1), *(imagePtr+2));
|
||||
imagePtr += bytesPerPixel;
|
||||
}
|
||||
image += mRowBytes;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = 0; i < mHeight; i++) {
|
||||
line = (QRgb*)qimage.scanLine(i);
|
||||
|
||||
PRUint8 *imagePtr = image;
|
||||
for (j = 0; j < mWidth; j++) {
|
||||
uchar a = (alpha[j / 8] & (1 << (7 - (j % 8)))) ? 0xff : 0;
|
||||
line[j] = qRgba(*imagePtr, *(imagePtr+1), *(imagePtr+2), a);
|
||||
imagePtr += bytesPerPixel;
|
||||
}
|
||||
image += mRowBytes;
|
||||
alpha += mAlphaRowBytes;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (i = 0; i < mHeight; i++) {
|
||||
line = (QRgb*)qimage.scanLine(i);
|
||||
|
||||
PRUint8 *imagePtr = image;
|
||||
PRUint8 *alphaPtr = alpha;
|
||||
for (j = 0; j < mWidth; j++) {
|
||||
line[j] = qRgba(*imagePtr, *(imagePtr+1), *(imagePtr+2), *alphaPtr);
|
||||
imagePtr += bytesPerPixel;
|
||||
alphaPtr++;
|
||||
}
|
||||
image += mRowBytes;
|
||||
alpha += mAlphaRowBytes;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pixmap = QPixmap(qimage);
|
||||
pixmapDirty = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageQt::DrawTile(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
PRInt32 aPadX, PRInt32 aPadY,
|
||||
const nsRect &aTileRect)
|
||||
{
|
||||
//qDebug("draw tile");
|
||||
#if 1
|
||||
nsRect aSrcRect(aSXOffset, aSYOffset, mWidth, mHeight);
|
||||
|
||||
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 + aPadY)
|
||||
for (PRInt32 x = aX0; x < aX1; x += aSrcRect.width + aPadX)
|
||||
Draw(aContext, aSurface, x, y, PR_MIN(aSrcRect.width, aX1 - x),
|
||||
PR_MIN(aSrcRect.height, aY1 - y));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#if 0
|
||||
// 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);
|
||||
#endif
|
||||
/*qDebug("draw tilePixmap x = %d, y = %d, wid = %d, hei = %d, sx = %d, sy = %d",
|
||||
aTileRect.x, aTileRect.y, aTileRect.width, aTileRect.height,
|
||||
aSrcRect.x, aSrcRect.y);*/
|
||||
drawing->GetGC()->drawTiledPixmap(aTileRect.x, aTileRect.y,
|
||||
aTileRect.width, aTileRect.height,
|
||||
pixmap, aSrcRect.x, aSrcRect.y);
|
||||
//qPmap, aSrcRect.x, aSrcRect.y);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
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)
|
||||
{
|
||||
//qDebug("DrawToIMAGE");
|
||||
nsImageQt *dest = NS_STATIC_CAST(nsImageQt *, aDstImage);
|
||||
|
||||
if (!dest)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aDX >= dest->mWidth || aDY >= dest->mHeight)
|
||||
return NS_OK;
|
||||
|
||||
PRUint8 *rgbPtr=0, *alphaPtr=0;
|
||||
PRUint32 rgbStride, alphaStride;
|
||||
|
||||
rgbPtr = mImageBits;
|
||||
rgbStride = mRowBytes;
|
||||
alphaPtr = mAlphaBits;
|
||||
alphaStride = mAlphaRowBytes;
|
||||
|
||||
PRInt32 y;
|
||||
PRInt32 ValidWidth = ( aDWidth < ( dest->mWidth - aDX ) ) ? aDWidth : ( dest->mWidth - aDX );
|
||||
PRInt32 ValidHeight = ( aDHeight < ( dest->mHeight - aDY ) ) ? aDHeight : ( dest->mHeight - aDY );
|
||||
|
||||
// now composite the two images together
|
||||
switch (mAlphaDepth) {
|
||||
case 1:
|
||||
{
|
||||
PRUint8 *dst = dest->mImageBits + aDY*dest->mRowBytes + 3*aDX;
|
||||
PRUint8 *dstAlpha = dest->mAlphaBits + aDY*dest->mAlphaRowBytes;
|
||||
PRUint8 *src = rgbPtr;
|
||||
PRUint8 *alpha = alphaPtr;
|
||||
PRUint8 offset = aDX & 0x7; // x starts at 0
|
||||
int iterations = (ValidWidth+7)/8; // round up
|
||||
|
||||
for (y=0; y<ValidHeight; y++) {
|
||||
for (int x=0; x<ValidWidth; x += 8, dst += 3*8, src += 3*8) {
|
||||
PRUint8 alphaPixels = *alpha++;
|
||||
if (alphaPixels == 0) {
|
||||
// all 8 transparent; jump forward
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1 or more bits are set, handle dstAlpha now - may not be aligned.
|
||||
// Are all 8 of these alpha pixels used?
|
||||
if (x+7 >= ValidWidth) {
|
||||
alphaPixels &= 0xff << (8 - (ValidWidth-x)); // no, mask off unused
|
||||
if (alphaPixels == 0)
|
||||
continue; // no 1 alpha pixels left
|
||||
}
|
||||
if (offset == 0) {
|
||||
dstAlpha[(aDX+x)>>3] |= alphaPixels; // the cheap aligned case
|
||||
}
|
||||
else {
|
||||
dstAlpha[(aDX+x)>>3] |= alphaPixels >> offset;
|
||||
// avoid write if no 1's to write - also avoids going past end of array
|
||||
PRUint8 alphaTemp = alphaPixels << (8U - offset);
|
||||
if (alphaTemp & 0xff)
|
||||
dstAlpha[((aDX+x)>>3) + 1] |= alphaTemp;
|
||||
}
|
||||
|
||||
if (alphaPixels == 0xff) {
|
||||
// fix - could speed up by gathering a run of 0xff's and doing 1 memcpy
|
||||
// all 8 pixels set; copy and jump forward
|
||||
memcpy(dst,src,8*3);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
// else mix of 1's and 0's in alphaPixels, do 1 bit at a time
|
||||
// Don't go past end of line!
|
||||
PRUint8 *d = dst, *s = src;
|
||||
for (PRUint8 aMask = 1<<7, j = 0; aMask && j < ValidWidth-x; aMask >>= 1, j++) {
|
||||
// if this pixel is opaque then copy into the destination image
|
||||
if (alphaPixels & aMask) {
|
||||
// might be faster with *d++ = *s++ 3 times?
|
||||
d[0] = s[0];
|
||||
d[1] = s[1];
|
||||
d[2] = s[2];
|
||||
// dstAlpha bit already set
|
||||
}
|
||||
d += 3;
|
||||
s += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
// at end of each line, bump pointers. Use wordy code because of
|
||||
// bug 127455 to avoid possibility of unsigned underflow
|
||||
dst = (dst - 3*8*iterations) + dest->mRowBytes;
|
||||
src = (src - 3*8*iterations) + rgbStride;
|
||||
alpha = (alpha - iterations) + alphaStride;
|
||||
dstAlpha += dest->mAlphaRowBytes;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
for (y=0; y<ValidHeight; y++)
|
||||
memcpy(dest->mImageBits + (y+aDY)*dest->mRowBytes + 3*aDX,
|
||||
rgbPtr + y*rgbStride,
|
||||
3*ValidWidth);
|
||||
}
|
||||
|
||||
nsRect rect(aDX, aDY, ValidWidth, ValidHeight);
|
||||
dest->ImageUpdated(nsnull, 0, &rect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 "nsRect.h"
|
||||
|
||||
#include <qpixmap.h>
|
||||
#include <qimage.h>
|
||||
|
||||
#undef Bool
|
||||
|
||||
class nsImageQt : public nsIImage
|
||||
{
|
||||
public:
|
||||
nsImageQt();
|
||||
virtual ~nsImageQt();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* @see nsIImage.h
|
||||
*/
|
||||
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
|
||||
PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
|
||||
|
||||
virtual PRInt32 GetBytesPix();
|
||||
virtual PRBool GetIsRowOrderTopToBottom() {return PR_TRUE;}
|
||||
virtual PRInt32 GetHeight();
|
||||
virtual PRInt32 GetWidth();
|
||||
virtual PRUint8 *GetBits();
|
||||
virtual PRInt32 GetLineStride();
|
||||
virtual PRBool GetHasAlphaMask() {return mAlphaBits != nsnull;}
|
||||
virtual PRUint8 *GetAlphaBits();
|
||||
virtual PRInt32 GetAlphaLineStride();
|
||||
|
||||
virtual void ImageUpdated(nsIDeviceContext *aContext,
|
||||
PRUint8 aFlags,nsRect *aUpdateRect);
|
||||
|
||||
virtual nsresult Optimize(nsIDeviceContext *aContext);
|
||||
|
||||
virtual nsColorMap *GetColorMap();
|
||||
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface* aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY,
|
||||
PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface* aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
PRInt32 aPadX, PRInt32 aPadY,
|
||||
const nsRect &aTileRect);
|
||||
|
||||
NS_IMETHOD DrawToImage(nsIImage *aDstImage, PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
|
||||
virtual PRInt8 GetAlphaDepth() { return(mAlphaDepth); }
|
||||
|
||||
virtual void *GetBitInfo();
|
||||
|
||||
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
|
||||
|
||||
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calculate the amount of memory needed for the initialization of the
|
||||
* image
|
||||
*/
|
||||
void updatePixmap();
|
||||
|
||||
private:
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
PRInt32 mDepth;
|
||||
PRInt32 mRowBytes;
|
||||
PRUint8 *mImageBits;
|
||||
|
||||
PRInt8 mAlphaDepth; // alpha layer depth
|
||||
PRInt16 mAlphaRowBytes; // alpha bytes per row
|
||||
PRUint8 *mAlphaBits;
|
||||
|
||||
|
||||
PRInt8 mNumBytesPixel;
|
||||
|
||||
nsRect mDecodedRect; // Keeps track of what part of image has been decoded.
|
||||
|
||||
QPixmap pixmap;
|
||||
PRBool pixmapDirty;
|
||||
|
||||
PRUint32 mID;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,328 @@
|
|||
/* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* David Hyatt (hyatt@netscape.com).
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* Tim Hill (tim@prismelite.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#include "nsNativeThemeQt.h"
|
||||
#include "nsRenderingContextQt.h"
|
||||
#include "nsDeviceContextQt.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsThemeConstants.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qstyle.h>
|
||||
#include <qpalette.h>
|
||||
#include <qcombobox.h>
|
||||
|
||||
nsNativeThemeQt::nsNativeThemeQt()
|
||||
{
|
||||
combo = new QComboBox((QWidget *)0);
|
||||
ThemeChanged();
|
||||
}
|
||||
|
||||
nsNativeThemeQt::~nsNativeThemeQt()
|
||||
{
|
||||
delete combo;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsNativeThemeQt, nsITheme)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeQt::DrawWidgetBackground(nsIRenderingContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
const nsRect& aRect,
|
||||
const nsRect& aClipRect)
|
||||
{
|
||||
nsRenderingContextQt *context = (nsRenderingContextQt *)aContext;
|
||||
QPainter *p = context->painter();
|
||||
|
||||
//qDebug("aWidgetType = %d", aWidgetType);
|
||||
if (!p)
|
||||
return NS_OK;
|
||||
|
||||
QStyle &s = qApp->style();
|
||||
const QColorGroup &cg = qApp->palette().active();
|
||||
|
||||
QRect r = context->qRect(aRect);
|
||||
QRect cr = context->qRect(aClipRect);
|
||||
context->UpdateGC();
|
||||
//qDebug("rect=%d %d %d %d", aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
p->save();
|
||||
p->translate(r.x(), r.y());
|
||||
r.moveBy(-r.x(), -r.y());
|
||||
|
||||
QStyle::PrimitiveElement pe = QStyle::PE_CustomBase;
|
||||
QStyle::SFlags flags = IsDisabled(aFrame) ?
|
||||
QStyle::Style_Default :
|
||||
QStyle::Style_Enabled;
|
||||
|
||||
PRInt32 eventState = GetContentState(aFrame, aWidgetType);
|
||||
//qDebug("eventState = %d", eventState);
|
||||
|
||||
if (eventState & NS_EVENT_STATE_HOVER)
|
||||
flags |= QStyle::Style_MouseOver;
|
||||
if (eventState & NS_EVENT_STATE_FOCUS)
|
||||
flags |= QStyle::Style_HasFocus;
|
||||
if (eventState & NS_EVENT_STATE_ACTIVE)
|
||||
flags |= QStyle::Style_Down;
|
||||
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_RADIO:
|
||||
flags |= (IsChecked(aFrame) ? QStyle::Style_On : QStyle::Style_Off);
|
||||
pe = QStyle::PE_ExclusiveIndicator;
|
||||
break;
|
||||
case NS_THEME_CHECKBOX:
|
||||
flags |= (IsChecked(aFrame) ? QStyle::Style_On : QStyle::Style_Off);
|
||||
pe = QStyle::PE_Indicator;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR:
|
||||
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
||||
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
||||
p->fillRect(r, qApp->palette().brush(QPalette::Active, QColorGroup::Background));
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
||||
flags |= QStyle::Style_Horizontal;
|
||||
// fall through
|
||||
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
||||
pe = QStyle::PE_ScrollBarSubLine;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
||||
flags |= QStyle::Style_Horizontal;
|
||||
// fall through
|
||||
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
||||
pe = QStyle::PE_ScrollBarAddLine;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
|
||||
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
||||
flags |= QStyle::Style_Horizontal;
|
||||
// fall through
|
||||
case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
|
||||
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
||||
pe = QStyle::PE_ScrollBarSlider;
|
||||
break;
|
||||
case NS_THEME_BUTTON_BEVEL:
|
||||
pe = QStyle::PE_ButtonBevel;
|
||||
flags |= QStyle::Style_Raised;
|
||||
break;
|
||||
case NS_THEME_BUTTON:
|
||||
pe = IsDefaultButton(aFrame) ? QStyle::PE_ButtonDefault : QStyle::PE_ButtonCommand;
|
||||
flags |= QStyle::Style_Raised;
|
||||
break;
|
||||
case NS_THEME_DROPDOWN:
|
||||
s.drawComplexControl(QStyle::CC_ComboBox, p, combo, r, cg, flags, QStyle::SC_ComboBoxFrame);
|
||||
break;
|
||||
case NS_THEME_DROPDOWN_BUTTON:
|
||||
r.moveBy(frameWidth, -frameWidth);
|
||||
r.setHeight(r.height() + 2*frameWidth);
|
||||
s.drawComplexControl(QStyle::CC_ComboBox, p, combo, r, cg, flags, QStyle::SC_ComboBoxArrow);
|
||||
break;
|
||||
case NS_THEME_DROPDOWN_TEXT:
|
||||
case NS_THEME_DROPDOWN_TEXTFIELD:
|
||||
break;
|
||||
case NS_THEME_TEXTFIELD:
|
||||
case NS_THEME_LISTBOX:
|
||||
pe = QStyle::PE_PanelLineEdit;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (pe != QStyle::PE_CustomBase)
|
||||
s.drawPrimitive(pe, p, r, cg, flags);
|
||||
p->restore();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeQt::GetWidgetBorder(nsIDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsMargin* aResult)
|
||||
{
|
||||
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
|
||||
|
||||
switch(aWidgetType) {
|
||||
case NS_THEME_TEXTFIELD:
|
||||
case NS_THEME_LISTBOX:
|
||||
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right =
|
||||
frameWidth;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsNativeThemeQt::GetWidgetPadding(nsIDeviceContext* ,
|
||||
nsIFrame*, PRUint8 aWidgetType,
|
||||
nsMargin* aResult)
|
||||
{
|
||||
//XXX: is this really correct?
|
||||
if (aWidgetType == NS_THEME_BUTTON_FOCUS ||
|
||||
aWidgetType == NS_THEME_TOOLBAR_BUTTON ||
|
||||
aWidgetType == NS_THEME_TOOLBAR_DUAL_BUTTON) {
|
||||
aResult->SizeTo(0, 0, 0, 0);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeQt::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsSize* aResult, PRBool* aIsOverridable)
|
||||
{
|
||||
(*aResult).width = (*aResult).height = 0;
|
||||
*aIsOverridable = PR_TRUE;
|
||||
|
||||
QStyle &s = qApp->style();
|
||||
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_RADIO:
|
||||
case NS_THEME_CHECKBOX: {
|
||||
QRect rect = s.subRect(aWidgetType == NS_THEME_CHECKBOX
|
||||
? QStyle::SR_CheckBoxIndicator
|
||||
: QStyle::SR_RadioButtonIndicator,
|
||||
0);
|
||||
(*aResult).width = rect.width();
|
||||
(*aResult).height = rect.height();
|
||||
break;
|
||||
}
|
||||
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
||||
(*aResult).width = s.pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||
(*aResult).height = (*aResult).width;
|
||||
*aIsOverridable = PR_FALSE;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
||||
(*aResult).width = s.pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||
(*aResult).height = s.pixelMetric(QStyle::PM_ScrollBarSliderMin);
|
||||
*aIsOverridable = PR_FALSE;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
||||
(*aResult).width = s.pixelMetric(QStyle::PM_ScrollBarSliderMin);
|
||||
(*aResult).height = s.pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||
*aIsOverridable = PR_FALSE;
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
||||
break;
|
||||
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
||||
break;
|
||||
case NS_THEME_DROPDOWN_BUTTON: {
|
||||
QRect r = s.querySubControlMetrics(QStyle::CC_ComboBox, combo, QStyle::SC_ComboBoxArrow);
|
||||
(*aResult).width = r.width() - 2*frameWidth;
|
||||
(*aResult).height = r.height() - 2*frameWidth;
|
||||
break;
|
||||
}
|
||||
case NS_THEME_DROPDOWN:
|
||||
case NS_THEME_DROPDOWN_TEXT:
|
||||
case NS_THEME_DROPDOWN_TEXTFIELD:
|
||||
case NS_THEME_TEXTFIELD:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeQt::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
||||
nsIAtom* aAttribute, PRBool* aShouldRepaint)
|
||||
{
|
||||
*aShouldRepaint = TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeThemeQt::ThemeChanged()
|
||||
{
|
||||
QStyle & s = qApp->style();
|
||||
frameWidth = s.pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsNativeThemeQt::ThemeSupportsWidget(nsPresContext* aPresContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType)
|
||||
{
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_SCROLLBAR:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
||||
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
||||
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
||||
case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
|
||||
case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
|
||||
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
||||
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
||||
case NS_THEME_RADIO:
|
||||
case NS_THEME_CHECKBOX:
|
||||
case NS_THEME_BUTTON_BEVEL:
|
||||
case NS_THEME_BUTTON:
|
||||
case NS_THEME_DROPDOWN:
|
||||
case NS_THEME_DROPDOWN_BUTTON:
|
||||
case NS_THEME_DROPDOWN_TEXT:
|
||||
case NS_THEME_DROPDOWN_TEXTFIELD:
|
||||
case NS_THEME_TEXTFIELD:
|
||||
case NS_THEME_LISTBOX:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsNativeThemeQt::WidgetIsContainer(PRUint8 aWidgetType)
|
||||
{
|
||||
// XXXdwh At some point flesh all of this out.
|
||||
if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
|
||||
aWidgetType == NS_THEME_RADIO ||
|
||||
aWidgetType == NS_THEME_CHECKBOX)
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
|
@ -0,0 +1,247 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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)
|
||||
{
|
||||
mRegion = QRegion();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsRegionQt::SetTo(const nsIRegion &aRegion)
|
||||
{
|
||||
nsRegionQt *pRegion = (nsRegionQt*)&aRegion;
|
||||
|
||||
mRegion = pRegion->mRegion;
|
||||
}
|
||||
|
||||
void nsRegionQt::SetTo(const nsRegionQt *aRegion)
|
||||
{
|
||||
mRegion = aRegion->mRegion;
|
||||
}
|
||||
|
||||
void nsRegionQt::SetTo(PRInt32 aX,PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight)
|
||||
{
|
||||
mRegion = QRegion(aX, aY, aWidth, aHeight);;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
mRegion = mRegion.intersect(QRect(aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
mRegion = mRegion.unite(QRect(aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
mRegion = mRegion.subtract(QRect(aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return mRegion.contains(QRect(aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRegionQt::GetRects(nsRegionRectSet **aRects)
|
||||
{
|
||||
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
|
||||
|
||||
QMemArray<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++) {
|
||||
const QRect &qRect = array.at(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 (mRegion.isEmpty()) {
|
||||
aComplexity = eRegionComplexity_empty;
|
||||
}
|
||||
else {
|
||||
aComplexity = eRegionComplexity_rect;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsRegionQt::SetRegionEmpty()
|
||||
{
|
||||
mRegion = QRegion();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRegionQt::GetNumRects(PRUint32 *aRects) const
|
||||
{
|
||||
*aRects = mRegion.rects().size();
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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___
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,254 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 nsDrawingSurface;
|
||||
|
||||
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, nsIDrawingSurface* 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(nsIDrawingSurface* aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsIDrawingSurface* *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
||||
NS_IMETHOD PushState(void);
|
||||
NS_IMETHOD PopState(void);
|
||||
|
||||
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
|
||||
|
||||
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
|
||||
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
|
||||
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
|
||||
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
|
||||
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,
|
||||
nsIDrawingSurface* &aSurface);
|
||||
NS_IMETHOD DestroyDrawingSurface(nsIDrawingSurface* 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 */
|
||||
|
||||
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(nsIDrawingSurface* 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();
|
||||
|
||||
QPainter *painter() const { return mSurface->GetGC(); }
|
||||
QPaintDevice *paintDevice() const { return mSurface->GetPaintDevice(); }
|
||||
nsTransform2D *matrix() const { return mTranMatrix; }
|
||||
|
||||
QRect qRect(const nsRect &aRect) {
|
||||
int x = aRect.x;
|
||||
int y = aRect.y;
|
||||
int w = aRect.width;
|
||||
int h = aRect.height;
|
||||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
return QRect (x, y, w, h);
|
||||
}
|
||||
|
||||
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;
|
||||
PRUint32 mID;
|
||||
};
|
||||
|
||||
#endif /* nsRenderingContextQt_h___ */
|
|
@ -0,0 +1,153 @@
|
|||
/* ***** 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 "qdesktopwidget.h"
|
||||
#include "qapplication.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
|
||||
|
||||
desktop = 0;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
||||
void nsScreenManagerQt::init()
|
||||
{
|
||||
if (desktop)
|
||||
return;
|
||||
|
||||
desktop = QApplication::desktop();
|
||||
nScreens = desktop->numScreens();
|
||||
screens = new nsCOMPtr<nsIScreen>[nScreens];
|
||||
|
||||
for (int i = 0; i < nScreens; ++i)
|
||||
screens[i] = new nsScreenQt(i);
|
||||
}
|
||||
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
if (!desktop)
|
||||
init();
|
||||
|
||||
QRect r(inLeft, inTop, inWidth, inHeight);
|
||||
int best = 0;
|
||||
int area = 0;
|
||||
for (int i = 0; i < nScreens; ++i) {
|
||||
const QRect& rect = desktop->screenGeometry(i);
|
||||
QRect intersection = r▭
|
||||
int a = intersection.width()*intersection.height();
|
||||
if (a > area) {
|
||||
best = i;
|
||||
area = a;
|
||||
}
|
||||
}
|
||||
NS_IF_ADDREF(*outScreen = screens[best]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// GetPrimaryScreen
|
||||
//
|
||||
// The screen with the menubar/taskbar. This shouldn't be needed very
|
||||
// often.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerQt::GetPrimaryScreen(nsIScreen **aPrimaryScreen)
|
||||
{
|
||||
if (!desktop)
|
||||
init();
|
||||
|
||||
NS_IF_ADDREF(*aPrimaryScreen = screens[0]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// GetNumberOfScreens
|
||||
//
|
||||
// Returns how many physical screens are available.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerQt::GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
||||
{
|
||||
if (!desktop)
|
||||
init();
|
||||
|
||||
*aNumberOfScreens = desktop->numScreens();
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 QDesktopWidget;
|
||||
|
||||
class nsScreenManagerQt : public nsIScreenManager
|
||||
{
|
||||
public:
|
||||
nsScreenManagerQt ( );
|
||||
virtual ~nsScreenManagerQt();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREENMANAGER
|
||||
|
||||
private:
|
||||
|
||||
void init ();
|
||||
|
||||
nsCOMPtr<nsIScreen> *screens;
|
||||
QDesktopWidget *desktop;
|
||||
int nScreens;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRUint32 mID;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScreenManagerQt_h___
|
|
@ -0,0 +1,120 @@
|
|||
/* ***** 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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(int aScreen)
|
||||
{
|
||||
screen = aScreen;
|
||||
|
||||
#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)
|
||||
{
|
||||
QRect r = QApplication::desktop()->screenGeometry(screen);
|
||||
*outTop = r.x();
|
||||
*outLeft = r.y();
|
||||
*outWidth = r.width();
|
||||
*outHeight = r.height();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenQt::GetAvailRect(PRInt32 *outLeft,PRInt32 *outTop,
|
||||
PRInt32 *outWidth,PRInt32 *outHeight)
|
||||
{
|
||||
QRect r = QApplication::desktop()->availableGeometry(screen);
|
||||
*outTop = r.x();
|
||||
*outLeft = r.y();
|
||||
*outWidth = r.width();
|
||||
*outHeight = r.height();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenQt::GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
// #############
|
||||
*aPixelDepth = (PRInt32)QColor::numBitPlanes();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenQt::GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
// ###############
|
||||
return GetPixelDepth(aColorDepth);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 (int aScreen);
|
||||
virtual ~nsScreenQt();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREEN
|
||||
|
||||
private:
|
||||
int screen;
|
||||
#ifdef DEBUG
|
||||
PRUint32 mID;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScreenQt_h___
|
|
@ -64,8 +64,7 @@ CPPSRCS = \
|
|||
gfxImageFrame.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
ifneq (,$(filter gtk gtk2 windows mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifneq (,$(filter gtk gtk2 qt windows mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += nsNativeTheme.cpp
|
||||
endif
|
||||
|
||||
|
|
|
@ -178,3 +178,9 @@ CXXFLAGS += $(MOZ_XLIB_CFLAGS)
|
|||
CFLAGS += $(MOZ_XLIB_CFLAGS)
|
||||
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
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,58 +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 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 of 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS =
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
DIRS += gtk
|
||||
endif
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
DIRS += gtk2
|
||||
endif
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
DIRS += xlib
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# 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):
|
||||
#
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = webshell_tests
|
||||
LIBRARY_NAME = viewer_qt_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
docshell \
|
||||
necko \
|
||||
dom \
|
||||
widget \
|
||||
gfx \
|
||||
layout \
|
||||
content \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
webshell \
|
||||
locale \
|
||||
util \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsQtMain.cpp \
|
||||
nsQtMenu.cpp \
|
||||
moc_nsQtMenu.cpp \
|
||||
$(NULL)
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../..
|
||||
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
DEFINES += -D_XOPEN_SOURCE=500
|
||||
endif
|
||||
|
||||
CXXFLAGS += $(MOZ_QT_CFLAGS)
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 <qwidget.h>
|
||||
#include "nsBrowserWindow.h"
|
||||
#include "nsQtMenu.h"
|
||||
#include "resources.h"
|
||||
#include "nscore.h"
|
||||
#include <stdio.h>
|
||||
|
||||
nsMenuEventHandler::nsMenuEventHandler(nsBrowserWindow * window)
|
||||
{
|
||||
mWindow = window;
|
||||
}
|
||||
|
||||
void nsMenuEventHandler::MenuItemActivated(int id)
|
||||
{
|
||||
mWindow->DispatchMenuItem(id);
|
||||
}
|
||||
|
||||
void CreateViewerMenus(nsIWidget * aParentInterface, void *data, QWidget ** aMenuBarOut)
|
||||
{
|
||||
QWidget *aParent = (QWidget *)aParentInterface->GetNativeData(NS_NATIVE_WIDGET);
|
||||
|
||||
nsBrowserWindow * window = (nsBrowserWindow *) data;
|
||||
|
||||
nsMenuEventHandler * eventHandler = new nsMenuEventHandler(window);
|
||||
|
||||
QMenuBar * menuBar = new QMenuBar(aParent);
|
||||
QPopupMenu * file = new QPopupMenu(aParent);
|
||||
QObject::connect(file,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * samples = new QPopupMenu(aParent);
|
||||
QObject::connect(samples,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * xptests = new QPopupMenu(aParent);
|
||||
QObject::connect(xptests,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * edit = new QPopupMenu(aParent);
|
||||
QObject::connect(edit,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * debug = new QPopupMenu(aParent);
|
||||
QObject::connect(debug,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * eventdebug = new QPopupMenu(aParent);
|
||||
QObject::connect(eventdebug,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * style = new QPopupMenu(aParent);
|
||||
QObject::connect(style,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * tools = new QPopupMenu(aParent);
|
||||
QObject::connect(tools,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * select = new QPopupMenu(aParent);
|
||||
QObject::connect(select,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * compatibility = new QPopupMenu(aParent);
|
||||
QObject::connect(compatibility,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
QPopupMenu * render = new QPopupMenu(aParent);
|
||||
QObject::connect(render,
|
||||
SIGNAL(activated(int)),
|
||||
eventHandler,
|
||||
SLOT(MenuItemActivated(int)));
|
||||
|
||||
InsertMenuItem(file, "&New Window", eventHandler, VIEWER_WINDOW_OPEN);
|
||||
InsertMenuItem(file, "&Open", eventHandler, VIEWER_FILE_OPEN);
|
||||
InsertMenuItem(file, "&View Source", eventHandler, VIEW_SOURCE);
|
||||
|
||||
InsertMenuItem(samples, "demo #0", eventHandler, VIEWER_DEMO0);
|
||||
InsertMenuItem(samples, "demo #1", eventHandler, VIEWER_DEMO1);
|
||||
InsertMenuItem(samples, "demo #2", eventHandler, VIEWER_DEMO2);
|
||||
InsertMenuItem(samples, "demo #3", eventHandler, VIEWER_DEMO3);
|
||||
InsertMenuItem(samples, "demo #4", eventHandler, VIEWER_DEMO4);
|
||||
InsertMenuItem(samples, "demo #5", eventHandler, VIEWER_DEMO5);
|
||||
InsertMenuItem(samples, "demo #6", eventHandler, VIEWER_DEMO6);
|
||||
InsertMenuItem(samples, "demo #7", eventHandler, VIEWER_DEMO7);
|
||||
InsertMenuItem(samples, "demo #8", eventHandler, VIEWER_DEMO8);
|
||||
InsertMenuItem(samples, "demo #9", eventHandler, VIEWER_DEMO9);
|
||||
InsertMenuItem(samples, "demo #10", eventHandler, VIEWER_DEMO10);
|
||||
InsertMenuItem(samples, "demo #11", eventHandler, VIEWER_DEMO11);
|
||||
InsertMenuItem(samples, "demo #12", eventHandler, VIEWER_DEMO12);
|
||||
InsertMenuItem(samples, "demo #13", eventHandler, VIEWER_DEMO13);
|
||||
InsertMenuItem(samples, "demo #14", eventHandler, VIEWER_DEMO14);
|
||||
InsertMenuItem(samples, "demo #15", eventHandler, VIEWER_DEMO15);
|
||||
InsertMenuItem(samples, "demo #16", eventHandler, VIEWER_DEMO16);
|
||||
InsertMenuItem(samples, "demo #17", eventHandler, VIEWER_DEMO17);
|
||||
|
||||
file->insertItem("&Samples", samples);
|
||||
|
||||
InsertMenuItem(file, "&Test Sites", eventHandler, VIEWER_TOP100);
|
||||
|
||||
InsertMenuItem(xptests, "Toolbar Test 1", eventHandler, VIEWER_XPTOOLKITTOOLBAR1);
|
||||
InsertMenuItem(xptests, "Tree Test 1", eventHandler, VIEWER_XPTOOLKITTREE1);
|
||||
|
||||
file->insertItem("XPToolkit Tests", xptests);
|
||||
|
||||
InsertMenuItem(file, nsnull, nsnull, 0);
|
||||
InsertMenuItem(file, "Print Preview", eventHandler, VIEWER_ONE_COLUMN);
|
||||
InsertMenuItem(file, "Print", eventHandler, VIEWER_PRINT);
|
||||
InsertMenuItem(file, nsnull, nsnull, 0);
|
||||
InsertMenuItem(file, "&Exit", eventHandler, VIEWER_EXIT);
|
||||
|
||||
InsertMenuItem(edit, "Cu&t", eventHandler, VIEWER_EDIT_CUT);
|
||||
InsertMenuItem(edit, "&Copy", eventHandler, VIEWER_EDIT_COPY);
|
||||
InsertMenuItem(edit, "&Paste", eventHandler, VIEWER_EDIT_PASTE);
|
||||
InsertMenuItem(edit, nsnull, nsnull, 0);
|
||||
InsertMenuItem(edit, "Select All", eventHandler, VIEWER_EDIT_SELECTALL);
|
||||
InsertMenuItem(edit, nsnull, nsnull, 0);
|
||||
InsertMenuItem(edit, "Find in Page", eventHandler, VIEWER_EDIT_FINDINPAGE);
|
||||
|
||||
InsertMenuItem(debug, "&Visual Debugging", eventHandler, VIEWER_VISUAL_DEBUGGING);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
|
||||
InsertMenuItem(eventdebug, "Toggle Paint Flashing", eventHandler, VIEWER_TOGGLE_PAINT_FLASHING);
|
||||
InsertMenuItem(eventdebug, "Toggle Paint Dumping", eventHandler, VIEWER_TOGGLE_PAINT_DUMPING);
|
||||
InsertMenuItem(eventdebug, "Toggle Invalidate Dumping", eventHandler, VIEWER_TOGGLE_INVALIDATE_DUMPING);
|
||||
InsertMenuItem(eventdebug, "Toggle Event Dumping", eventHandler, VIEWER_TOGGLE_EVENT_DUMPING);
|
||||
InsertMenuItem(eventdebug, nsnull, nsnull, 0);
|
||||
InsertMenuItem(eventdebug, "Toggle Motion Event Dumping", eventHandler, VIEWER_TOGGLE_MOTION_EVENT_DUMPING);
|
||||
InsertMenuItem(eventdebug, "Toggle Crossing Event Dumping", eventHandler, VIEWER_TOGGLE_CROSSING_EVENT_DUMPING);
|
||||
|
||||
debug->insertItem("Event Debugging", eventdebug);
|
||||
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
InsertMenuItem(debug, "&Reflow Test", eventHandler, VIEWER_REFLOW_TEST);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
InsertMenuItem(debug, "Dump &Content", eventHandler, VIEWER_DUMP_CONTENT);
|
||||
InsertMenuItem(debug, "Dump &Frames", eventHandler, VIEWER_DUMP_FRAMES);
|
||||
InsertMenuItem(debug, "Dump &Views", eventHandler, VIEWER_DUMP_VIEWS);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
InsertMenuItem(debug, "Dump &Style Sheets", eventHandler, VIEWER_DUMP_STYLE_SHEETS);
|
||||
InsertMenuItem(debug, "Dump &Style Contexts", eventHandler, VIEWER_DUMP_STYLE_CONTEXTS);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
// InsertMenuItem(debug, "Show Content Size", eventHandler, VIEWER_SHOW_CONTENT_SIZE);
|
||||
// InsertMenuItem(debug, "Show Frame Size", eventHandler, VIEWER_SHOW_FRAME_SIZE);
|
||||
// InsertMenuItem(debug, "Show Style Size", eventHandler, VIEWER_SHOW_STYLE_SIZE);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
InsertMenuItem(debug, "Debug Save", eventHandler, VIEWER_DEBUGSAVE);
|
||||
InsertMenuItem(debug, "Debug Output Text", eventHandler, VIEWER_DISPLAYTEXT);
|
||||
InsertMenuItem(debug, "Debug Output HTML", eventHandler, VIEWER_DISPLAYHTML);
|
||||
InsertMenuItem(debug, "Debug Toggle Selection", eventHandler, VIEWER_TOGGLE_SELECTION);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
InsertMenuItem(debug, "Debug Robot", eventHandler, VIEWER_DEBUGROBOT);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
// InsertMenuItem(debug, "Show Content Quality", eventHandler, VIEWER_SHOW_CONTENT_QUALITY);
|
||||
InsertMenuItem(debug, nsnull, nsnull, 0);
|
||||
debug->insertItem("Style", style);
|
||||
|
||||
InsertMenuItem(select, "List Available Sheets", eventHandler, VIEWER_SELECT_STYLE_LIST);
|
||||
InsertMenuItem(select, nsnull, nsnull, 0);
|
||||
InsertMenuItem(select, "Select Default", eventHandler, VIEWER_SELECT_STYLE_DEFAULT);
|
||||
InsertMenuItem(select, nsnull, nsnull, 0);
|
||||
InsertMenuItem(select, "Select Alternative 1", eventHandler, VIEWER_SELECT_STYLE_ONE);
|
||||
InsertMenuItem(select, "Select Alternative 2", eventHandler, VIEWER_SELECT_STYLE_TWO);
|
||||
InsertMenuItem(select, "Select Alternative 3", eventHandler, VIEWER_SELECT_STYLE_THREE);
|
||||
InsertMenuItem(select, "Select Alternative 4", eventHandler, VIEWER_SELECT_STYLE_FOUR);
|
||||
|
||||
style->insertItem("Select &Style Sheet", select);
|
||||
|
||||
InsertMenuItem(compatibility, "Use DTD", eventHandler, VIEWER_USE_DTD_MODE);
|
||||
InsertMenuItem(compatibility, "Nav Quirks", eventHandler, VIEWER_NAV_QUIRKS_MODE);
|
||||
InsertMenuItem(compatibility, "Standard", eventHandler, VIEWER_STANDARD_MODE);
|
||||
|
||||
style->insertItem("&Compatibility Mode", compatibility);
|
||||
|
||||
InsertMenuItem(render, "Native", eventHandler, VIEWER_NATIVE_WIDGET_MODE);
|
||||
InsertMenuItem(render, "Gfx", eventHandler, VIEWER_GFX_WIDGET_MODE);
|
||||
|
||||
style->insertItem("&Widget Render Mode", render);
|
||||
|
||||
InsertMenuItem(tools, "&JavaScript Console", eventHandler, JS_CONSOLE);
|
||||
InsertMenuItem(tools, "&Editor Mode", eventHandler, EDITOR_MODE);
|
||||
|
||||
menuBar->insertItem("&File", file);
|
||||
menuBar->insertItem("&Edit", edit);
|
||||
menuBar->insertItem("&Debug", debug);
|
||||
menuBar->insertItem("&Tools", tools);
|
||||
|
||||
qDebug("menubar height = %d", menuBar->height());
|
||||
menuBar->resize(menuBar->sizeHint());
|
||||
menuBar->show();
|
||||
}
|
||||
|
||||
|
||||
void InsertMenuItem(QPopupMenu * popup, const char * string, QObject * receiver, int id)
|
||||
{
|
||||
if (popup)
|
||||
{
|
||||
if (string)
|
||||
{
|
||||
popup->insertItem(string, id);
|
||||
|
||||
//popup->connectItem(id, receiver, SLOT(MenuItemActivated(int)));
|
||||
#if 0
|
||||
popup->insertItem(string,
|
||||
receiver,
|
||||
SLOT(MenuItemActivated(int)),
|
||||
0,
|
||||
id);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
popup->insertSeparator();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 _nsMotifMenu_h_
|
||||
#define _nsMotifMenu_h_
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#include <qpopupmenu.h>
|
||||
#include <qmenubar.h>
|
||||
|
||||
class nsBrowserWindow;
|
||||
class nsIWidget;
|
||||
class QWidget;
|
||||
|
||||
class nsMenuEventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
nsMenuEventHandler(nsBrowserWindow * window);
|
||||
|
||||
public slots:
|
||||
void MenuItemActivated(int id);
|
||||
|
||||
private:
|
||||
nsBrowserWindow * mWindow;
|
||||
};
|
||||
|
||||
|
||||
void CreateViewerMenus(nsIWidget * aParent,
|
||||
void * data,
|
||||
QWidget ** aMenuBarOut);
|
||||
void InsertMenuItem(QPopupMenu * popup,
|
||||
const char * string,
|
||||
QObject * receiver,
|
||||
int id);
|
||||
|
||||
#endif // _nsMotifMenu_h_
|
|
@ -86,6 +86,10 @@ DIRS += xlibxtbin
|
|||
DIRS += xlib
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_QT
|
||||
DIRS += qt
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
endif
|
||||
|
|
|
@ -144,8 +144,8 @@ static void style_set_cb (GtkWidget *widget,
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
static GdkFilterReturn plugin_window_filter_func (GdkXEvent *gdk_xevent,
|
||||
GdkEvent *event,
|
||||
static GdkFilterReturn plugin_window_filter_func (GdkXEvent *gdk_xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static GdkFilterReturn plugin_client_message_filter (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
|
@ -181,7 +181,7 @@ static void drag_data_received_event_cb(GtkWidget *aWidget,
|
|||
|
||||
/* initialization static functions */
|
||||
static nsresult initialize_prefs (void);
|
||||
|
||||
|
||||
// this is the last window that had a drag event happen on it.
|
||||
nsWindow *nsWindow::mLastDragMotionWindow = NULL;
|
||||
PRBool nsWindow::sIsDraggingOutOf = PR_FALSE;
|
||||
|
@ -258,7 +258,7 @@ nsWindow::nsWindow()
|
|||
// It's OK if either of these fail, but it may not be one day.
|
||||
initialize_prefs();
|
||||
}
|
||||
|
||||
|
||||
if (mLastDragMotionWindow == this)
|
||||
mLastDragMotionWindow = NULL;
|
||||
mDragMotionWidget = 0;
|
||||
|
@ -396,7 +396,7 @@ nsWindow::Destroy(void)
|
|||
gtk_widget_destroy(GTK_WIDGET(mContainer));
|
||||
mContainer = nsnull;
|
||||
}
|
||||
|
||||
|
||||
if (mDrawingarea) {
|
||||
g_object_unref(mDrawingarea);
|
||||
mDrawingarea = nsnull;
|
||||
|
@ -525,7 +525,7 @@ nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|||
nsIWidget *aWidget,
|
||||
PRBool aActivate)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -645,11 +645,11 @@ nsWindow::SetFocus(PRBool aRaise)
|
|||
IMESetFocus();
|
||||
#endif
|
||||
|
||||
LOGFOCUS((" widget now has focus - dispatching events [%p]\n",
|
||||
LOGFOCUS((" widget now has focus - dispatching events [%p]\n",
|
||||
(void *)this));
|
||||
|
||||
DispatchGotFocusEvent();
|
||||
|
||||
|
||||
// unset the activate flag
|
||||
if (owningWindow->mActivatePending) {
|
||||
owningWindow->mActivatePending = PR_FALSE;
|
||||
|
@ -951,7 +951,7 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
|||
if (iconFile) {
|
||||
iconFile->GetNativePath(path);
|
||||
iconList.AppendCString(path);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the 16px icon path as well
|
||||
ResolveIconName(aIconSpec, NS_LITERAL_STRING("16.xpm"),
|
||||
|
@ -1052,7 +1052,7 @@ nsWindow::CaptureMouse(PRBool aCapture)
|
|||
if (!mDrawingarea)
|
||||
return NS_OK;
|
||||
|
||||
GtkWidget *widget =
|
||||
GtkWidget *widget =
|
||||
get_gtk_widget_for_gdk_window(mDrawingarea->inner_window);
|
||||
|
||||
if (aCapture) {
|
||||
|
@ -1075,7 +1075,7 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
|
|||
if (!mDrawingarea)
|
||||
return NS_OK;
|
||||
|
||||
GtkWidget *widget =
|
||||
GtkWidget *widget =
|
||||
get_gtk_widget_for_gdk_window(mDrawingarea->inner_window);
|
||||
|
||||
LOG(("CaptureRollupEvents %p\n", (void *)this));
|
||||
|
@ -1113,7 +1113,7 @@ nsWindow::GetAttention(PRInt32 aCycleCount)
|
|||
if (top_window && GTK_WIDGET_VISIBLE(top_window)) {
|
||||
gdk_window_show(top_window->window);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1624,7 +1624,7 @@ nsWindow::OnKeyReleaseEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
|
|||
#endif
|
||||
|
||||
nsEventStatus status;
|
||||
|
||||
|
||||
// unset the repeat flag
|
||||
mInKeyRepeat = PR_FALSE;
|
||||
|
||||
|
@ -1722,7 +1722,7 @@ nsWindow::ThemeChanged()
|
|||
return;
|
||||
|
||||
// Dispatch NS_THEMECHANGED to all child windows
|
||||
GList *children =
|
||||
GList *children =
|
||||
gdk_window_peek_children(mDrawingarea->inner_window);
|
||||
while (children) {
|
||||
GdkWindow *gdkWin = GDK_WINDOW(children->data);
|
||||
|
@ -1817,7 +1817,7 @@ nsWindow::OnDragMotionEvent(GtkWidget *aWidget,
|
|||
|
||||
// we're done with the drag motion event. notify the drag service.
|
||||
dragSessionGTK->TargetEndDragMotion(aWidget, aDragContext, aTime);
|
||||
|
||||
|
||||
// and unset our context
|
||||
dragSessionGTK->TargetSetLastContext(0, 0, 0);
|
||||
|
||||
|
@ -1867,7 +1867,7 @@ nsWindow::OnDragDropEvent(GtkWidget *aWidget,
|
|||
|
||||
nscoord retx = 0;
|
||||
nscoord rety = 0;
|
||||
|
||||
|
||||
GdkWindow *thisWindow = aWidget->window;
|
||||
GdkWindow *returnWindow = NULL;
|
||||
returnWindow = get_inner_gdk_window(thisWindow, aX, aY, &retx, &rety);
|
||||
|
@ -2000,7 +2000,7 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY)
|
|||
// XXX Do we want to pass this on only if the event's subwindow is null?
|
||||
|
||||
LOG(("nsWindow::OnDragEnter(%p)\n", this));
|
||||
|
||||
|
||||
nsMouseEvent event(NS_DRAGDROP_ENTER, this);
|
||||
|
||||
event.point.x = aX;
|
||||
|
@ -2064,7 +2064,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
|
|||
if (parentGdkWindow) {
|
||||
// find the mozarea on that window
|
||||
gpointer user_data = nsnull;
|
||||
user_data = g_object_get_data(G_OBJECT(parentGdkWindow),
|
||||
user_data = g_object_get_data(G_OBJECT(parentGdkWindow),
|
||||
"mozdrawingarea");
|
||||
parentArea = MOZ_DRAWINGAREA(user_data);
|
||||
|
||||
|
@ -2131,7 +2131,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
|
|||
else if (mWindowType == eWindowType_popup) {
|
||||
mShell = gtk_window_new(GTK_WINDOW_POPUP);
|
||||
if (topLevelParent) {
|
||||
gtk_window_set_transient_for(GTK_WINDOW(mShell),
|
||||
gtk_window_set_transient_for(GTK_WINDOW(mShell),
|
||||
topLevelParent);
|
||||
mTransientParent = topLevelParent;
|
||||
|
||||
|
@ -2199,7 +2199,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
|
|||
break;
|
||||
}
|
||||
// Disable the double buffer because it will make the caret crazy
|
||||
// For bug#153805 (Gtk2 double buffer makes carets misbehave)
|
||||
// For bug#153805 (Gtk2 double buffer makes carets misbehave)
|
||||
if (mContainer)
|
||||
gtk_widget_set_double_buffered (GTK_WIDGET(mContainer),FALSE);
|
||||
|
||||
|
@ -2266,7 +2266,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
|
|||
G_CALLBACK(scroll_event_cb), NULL);
|
||||
g_signal_connect(G_OBJECT(mContainer), "visibility_notify_event",
|
||||
G_CALLBACK(visibility_notify_event_cb), NULL);
|
||||
|
||||
|
||||
gtk_drag_dest_set((GtkWidget *)mContainer,
|
||||
(GtkDestDefaults)0,
|
||||
NULL,
|
||||
|
@ -2784,7 +2784,7 @@ nsWindow::GetToplevelWidget(GtkWidget **aWidget)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mDrawingarea)
|
||||
if (!mDrawingarea)
|
||||
return;
|
||||
|
||||
GtkWidget *widget =
|
||||
|
@ -2798,7 +2798,7 @@ nsWindow::GetToplevelWidget(GtkWidget **aWidget)
|
|||
void
|
||||
nsWindow::GetContainerWindow(nsWindow **aWindow)
|
||||
{
|
||||
if (!mDrawingarea)
|
||||
if (!mDrawingarea)
|
||||
return;
|
||||
|
||||
GtkWidget *owningWidget =
|
||||
|
@ -2828,7 +2828,7 @@ nsWindow::SetupPluginPort(void)
|
|||
xattrs.your_event_mask |
|
||||
SubstructureNotifyMask);
|
||||
|
||||
gdk_window_add_filter(mDrawingarea->inner_window,
|
||||
gdk_window_add_filter(mDrawingarea->inner_window,
|
||||
plugin_window_filter_func,
|
||||
this);
|
||||
|
||||
|
@ -2938,9 +2938,9 @@ nsWindow::SetNonXEmbedPluginFocus()
|
|||
gdk_error_trap_pop();
|
||||
gPluginFocusWindow = this;
|
||||
gdk_window_add_filter(NULL, plugin_client_message_filter, this);
|
||||
|
||||
|
||||
LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus oldfocus=%p new=%p\n",
|
||||
mOldFocusWindow,
|
||||
mOldFocusWindow,
|
||||
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window)));
|
||||
}
|
||||
|
||||
|
@ -2962,11 +2962,11 @@ nsWindow::LoseNonXEmbedPluginFocus()
|
|||
&curFocusWindow,
|
||||
&focusState);
|
||||
|
||||
// we only switch focus between plugin window and focus proxy. If the
|
||||
// current focused window is not the plugin window, just removing the
|
||||
// we only switch focus between plugin window and focus proxy. If the
|
||||
// current focused window is not the plugin window, just removing the
|
||||
// event filter that blocks the WM_TAKE_FOCUS is enough. WM and gtk2
|
||||
// will take care of the focus later.
|
||||
if (!curFocusWindow ||
|
||||
if (!curFocusWindow ||
|
||||
curFocusWindow == GDK_WINDOW_XWINDOW(mDrawingarea->inner_window)) {
|
||||
|
||||
gdk_error_trap_push();
|
||||
|
@ -3033,9 +3033,9 @@ nsWindow::HideWindowChrome(PRBool aShouldHide)
|
|||
// confused if we change the window decorations while the window
|
||||
// is visible.
|
||||
#if GTK_CHECK_VERSION(2,2,0)
|
||||
if (aShouldHide)
|
||||
if (aShouldHide)
|
||||
gdk_window_fullscreen (mShell->window);
|
||||
else
|
||||
else
|
||||
gdk_window_unfullscreen (mShell->window);
|
||||
#else
|
||||
gdk_window_hide(mShell->window);
|
||||
|
@ -3550,7 +3550,7 @@ plugin_window_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data
|
|||
|
||||
nsWindow *nswindow = (nsWindow*)data;
|
||||
GdkFilterReturn return_val;
|
||||
|
||||
|
||||
xevent = (XEvent *)gdk_xevent;
|
||||
return_val = GDK_FILTER_CONTINUE;
|
||||
|
||||
|
@ -3602,7 +3602,7 @@ plugin_window_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data
|
|||
}
|
||||
|
||||
/* static */
|
||||
GdkFilterReturn
|
||||
GdkFilterReturn
|
||||
plugin_client_message_filter (GdkXEvent *gdk_xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
|
@ -3624,12 +3624,12 @@ plugin_client_message_filter (GdkXEvent *gdk_xevent,
|
|||
Display *dpy ;
|
||||
dpy = GDK_WINDOW_XDISPLAY((GdkWindow*)(gPluginFocusWindow->
|
||||
GetNativeData(NS_NATIVE_WINDOW)));
|
||||
if (gdk_x11_get_xatom_by_name("WM_PROTOCOLS")
|
||||
if (gdk_x11_get_xatom_by_name("WM_PROTOCOLS")
|
||||
!= xevent->xclient.message_type) {
|
||||
return return_val;
|
||||
}
|
||||
|
||||
if ((Atom) xevent->xclient.data.l[0] ==
|
||||
|
||||
if ((Atom) xevent->xclient.data.l[0] ==
|
||||
gdk_x11_get_xatom_by_name("WM_TAKE_FOCUS")) {
|
||||
// block it from gtk2.0 focus proxy
|
||||
return_val = GDK_FILTER_REMOVE;
|
||||
|
@ -3755,11 +3755,11 @@ nsWindow::UpdateDragStatus(nsMouseEvent &aEvent,
|
|||
{
|
||||
// default is to do nothing
|
||||
int action = nsIDragService::DRAGDROP_ACTION_NONE;
|
||||
|
||||
|
||||
// set the default just in case nothing matches below
|
||||
if (aDragContext->actions & GDK_ACTION_DEFAULT)
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
|
||||
// first check to see if move is set
|
||||
if (aDragContext->actions & GDK_ACTION_MOVE)
|
||||
action = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
@ -3767,7 +3767,7 @@ nsWindow::UpdateDragStatus(nsMouseEvent &aEvent,
|
|||
// then fall to the others
|
||||
else if (aDragContext->actions & GDK_ACTION_LINK)
|
||||
action = nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
|
||||
|
||||
// copy is ctrl
|
||||
else if (aDragContext->actions & GDK_ACTION_COPY)
|
||||
action = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
|
@ -3793,7 +3793,7 @@ drag_motion_event_cb(GtkWidget *aWidget,
|
|||
nsWindow *window = get_window_for_gtk_widget(aWidget);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
|
||||
return window->OnDragMotionEvent(aWidget,
|
||||
aDragContext,
|
||||
aX, aY, aTime, aData);
|
||||
|
@ -3825,7 +3825,7 @@ drag_drop_event_cb(GtkWidget *aWidget,
|
|||
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
|
||||
return window->OnDragDropEvent(aWidget,
|
||||
aDragContext,
|
||||
aX, aY, aTime, aData);
|
||||
|
@ -3876,7 +3876,7 @@ nsWindow::ResetDragMotionTimer(GtkWidget *aWidget,
|
|||
GdkDragContext *aDragContext,
|
||||
gint aX, gint aY, guint aTime)
|
||||
{
|
||||
|
||||
|
||||
// We have to be careful about ref ordering here. if aWidget ==
|
||||
// mDraMotionWidget be careful not to let the refcnt drop to zero.
|
||||
// Same with the drag context.
|
||||
|
@ -3908,7 +3908,7 @@ nsWindow::ResetDragMotionTimer(GtkWidget *aWidget,
|
|||
if (!aWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// otherwise we create a new timer
|
||||
mDragMotionTimerID = gtk_timeout_add(100,
|
||||
(GtkFunction)DragMotionTimerCallback,
|
||||
|
@ -4063,7 +4063,7 @@ nsWindow::GetRootAccessible(nsIAccessible** aAccessible)
|
|||
*aAccessible = docAcc;
|
||||
NS_ADDREF(*aAccessible);
|
||||
break;
|
||||
}
|
||||
}
|
||||
docAcc->GetParent(getter_AddRefs(parentAcc));
|
||||
docAcc = parentAcc;
|
||||
}
|
||||
|
@ -4228,7 +4228,7 @@ nsWindow::IMEComposeText (const PRUnichar *aText,
|
|||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&textEvent, status);
|
||||
|
||||
|
||||
if (textEvent.rangeArray) {
|
||||
delete[] textEvent.rangeArray;
|
||||
}
|
||||
|
@ -4276,7 +4276,7 @@ nsWindow::IMECreateContext(void)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsWindow::IMEFilterEvent(GdkEventKey *aEvent)
|
||||
nsWindow::IMEFilterEvent(GdkEventKey *aEvent)
|
||||
{
|
||||
GtkIMContext *im = IMEGetContext();
|
||||
if (!im)
|
||||
|
@ -4320,11 +4320,11 @@ IM_preedit_changed_cb(GtkIMContext *aContext,
|
|||
nsWindow *window = gFocusWindow ? gFocusWindow : gIMEFocusWindow;
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
||||
// Should use cursor_pos ?
|
||||
gtk_im_context_get_preedit_string(aContext, &preedit_string,
|
||||
&feedback_list, &cursor_pos);
|
||||
|
||||
|
||||
LOGIM(("preedit string is: %s length is: %d\n",
|
||||
preedit_string, strlen(preedit_string)));
|
||||
|
||||
|
@ -4443,7 +4443,7 @@ IM_set_text_range(const PRInt32 aLen,
|
|||
aTextRangeListResult = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PangoAttrIterator * aFeedbackIterator;
|
||||
aFeedbackIterator = pango_attr_list_get_iterator((PangoAttrList*)aFeedback);
|
||||
//(NS_REINTERPRET_CAST(PangoAttrList*, aFeedback));
|
||||
|
@ -4460,7 +4460,7 @@ IM_set_text_range(const PRInt32 aLen,
|
|||
aMaxLenOfTextRange = 2*aLen + 1;
|
||||
*aTextRangeListResult = new nsTextRange[aMaxLenOfTextRange];
|
||||
NS_ASSERTION(*aTextRangeListResult, "No enough memory.");
|
||||
|
||||
|
||||
// Set caret's postion
|
||||
SET_FEEDBACKTYPE(0, NS_TEXTRANGE_CARETPOSITION);
|
||||
START_OFFSET(0) = aLen;
|
||||
|
@ -4515,7 +4515,7 @@ IM_set_text_range(const PRInt32 aLen,
|
|||
count++;
|
||||
START_OFFSET(count) = 0;
|
||||
END_OFFSET(count) = 0;
|
||||
|
||||
|
||||
uniStr = NULL;
|
||||
if (start > 0) {
|
||||
uniStr = g_utf8_to_utf16(aPreeditString, start,
|
||||
|
@ -4525,7 +4525,7 @@ IM_set_text_range(const PRInt32 aLen,
|
|||
START_OFFSET(count) = uniStrLen;
|
||||
g_free(uniStr);
|
||||
}
|
||||
|
||||
|
||||
uniStr = NULL;
|
||||
uniStr = g_utf8_to_utf16(aPreeditString + start, end - start,
|
||||
NULL, &uniStrLen, NULL);
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
#
|
||||
# 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 \
|
||||
necko \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
$(MOCSRCS) \
|
||||
nsAppShell.cpp \
|
||||
nsBidiKeyboard.cpp \
|
||||
nsClipboard.cpp \
|
||||
nsCommonWidget.cpp \
|
||||
nsDragService.cpp \
|
||||
nsEventQueueWatcher.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsMime.cpp \
|
||||
nsQtEventDispatcher.cpp \
|
||||
nsSound.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
nsScrollbar.cpp \
|
||||
nsWindow.cpp \
|
||||
nsFilePicker.cpp \
|
||||
$(NULL)
|
||||
|
||||
MOCSRCS = \
|
||||
moc_nsMime.cpp \
|
||||
moc_nsEventQueueWatcher.cpp \
|
||||
moc_nsQtEventDispatcher.cpp \
|
||||
moc_nsScrollbar.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)
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "nsAppShell.h"
|
||||
|
||||
#include "nsEventQueueWatcher.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
nsAppShell::nsAppShell()
|
||||
{
|
||||
}
|
||||
|
||||
nsAppShell::~nsAppShell()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// nsISupports implementation macro
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Create(int *argc, char **argv)
|
||||
{
|
||||
qDebug("Qt: nsAppShell::create");
|
||||
|
||||
/**
|
||||
* If !qApp then it means we're not embedding
|
||||
* but running a full application.
|
||||
*/
|
||||
if (!qApp) {
|
||||
//oh, this is fun. yes, argc can be null here
|
||||
int argcSafe = 0;
|
||||
if (argc)
|
||||
argcSafe = *argc;
|
||||
|
||||
new QApplication(argcSafe, argv);
|
||||
|
||||
if (argc)
|
||||
*argc = argcSafe;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Run(void)
|
||||
{
|
||||
if (!mEventQueue)
|
||||
Spinup();
|
||||
|
||||
if (!mEventQueue)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
qApp->exec();
|
||||
|
||||
Spindown();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//i don't like this method flow, but i left it because it follows what
|
||||
//other ports are doing here
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Spinup()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get the event queue service
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID,&rv);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Could not obtain event queue service");
|
||||
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_WARNING("Could not create the thread event queue");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Ask again for the event queue now that we have create one.
|
||||
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:
|
||||
AddEventQueue(mEventQueue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Spindown(void)
|
||||
{
|
||||
// stop listening to the event queue
|
||||
if (mEventQueue) {
|
||||
RemoveEventQueue(mEventQueue);
|
||||
mEventQueue->ProcessPendingEvents();
|
||||
mEventQueue = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen)
|
||||
{
|
||||
// whoever came up with the idea of passing bool to this
|
||||
// method to decide what its effect should be is getting
|
||||
// his ass kicked
|
||||
|
||||
if (aListen)
|
||||
AddEventQueue(aQueue);
|
||||
else
|
||||
RemoveEventQueue(aQueue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAppShell::AddEventQueue(nsIEventQueue *aQueue)
|
||||
{
|
||||
nsEventQueueWatcher *que = 0;
|
||||
|
||||
if ((que = mQueueDict.find(aQueue->GetEventQueueSelectFD()))) {
|
||||
que->ref();
|
||||
}
|
||||
else {
|
||||
mQueueDict.insert(aQueue->GetEventQueueSelectFD(),
|
||||
new nsEventQueueWatcher(aQueue, qApp));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsAppShell::RemoveEventQueue(nsIEventQueue *aQueue)
|
||||
{
|
||||
nsEventQueueWatcher *qtQueue = 0;
|
||||
|
||||
if ((qtQueue = mQueueDict.find(aQueue->GetEventQueueSelectFD()))) {
|
||||
qtQueue->DataReceived();
|
||||
qtQueue->deref();
|
||||
if (qtQueue->count <= 0) {
|
||||
mQueueDict.take(aQueue->GetEventQueueSelectFD());
|
||||
delete qtQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::GetNativeEvent(PRBool &aRealEvent, void * &aEvent)
|
||||
{
|
||||
aRealEvent = PR_FALSE;
|
||||
aEvent = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
|
||||
{
|
||||
if (!mEventQueue)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Exit(void)
|
||||
{
|
||||
qApp->exit(0);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- 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;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/* -*- 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
|
|
@ -0,0 +1,362 @@
|
|||
/* ***** 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 ***** */
|
||||
|
||||
#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)
|
||||
{
|
||||
qDebug("SetNativeClipboardData");
|
||||
mIgnoreEmptyNotification = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsITransferable> transferable(
|
||||
getter_AddRefs(GetTransferable(aWhichClipboard)));
|
||||
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == transferable) {
|
||||
qDebug("nsClipboard::SetNativeClipboardData(): no transferable!\n");
|
||||
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)) {
|
||||
qDebug("nsClipboard::SetNativeClipboardData(): no FlavorsTransferable !\n");
|
||||
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);
|
||||
|
||||
QString str = QString::fromAscii((const char*)data, len);
|
||||
qDebug("HERE %s '%s'", flavorStr.get(), str.latin1());
|
||||
|
||||
mimeStore->AddFlavorData(flavorStr,data,len);
|
||||
}
|
||||
}
|
||||
cb->setData(mimeStore);
|
||||
mIgnoreEmptyNotification = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable,
|
||||
PRInt32 aWhichClipboard)
|
||||
{
|
||||
qDebug("GetNativeClipboardData");
|
||||
// make sure we have a good transferable
|
||||
if (nsnull == aTransferable) {
|
||||
qDebug(" GetNativeClipboardData: Transferable is null!\n");
|
||||
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)) {
|
||||
qDebug("nsClipboard::GetNativeClipboardData(): no FlavorsTransferable %i !\n",
|
||||
errCode);
|
||||
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;
|
||||
}
|
||||
|
||||
/* inline */
|
||||
nsITransferable *
|
||||
nsClipboard::GetTransferable(PRInt32 aWhichClipboard)
|
||||
{
|
||||
qDebug("GetTransferable");
|
||||
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)
|
||||
{
|
||||
qDebug("HasDataMatchingFlavors");
|
||||
*_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));
|
||||
|
||||
if (strcmp(flavorStr,kTextMime) == 0)
|
||||
NS_WARNING("DO NOT USE THE text/plain DATA FLAVOR ANY MORE. USE text/unicode INSTEAD");
|
||||
|
||||
if (ms->provides((const char*)flavorStr)) {
|
||||
*_retval = PR_TRUE;
|
||||
qDebug("GetFormat %s\n",(const char*)flavorStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transferable object
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::SetData(nsITransferable *aTransferable,
|
||||
nsIClipboardOwner *anOwner,
|
||||
PRInt32 aWhichClipboard)
|
||||
{
|
||||
qDebug("SetData");
|
||||
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)
|
||||
{
|
||||
qDebug("GetData");
|
||||
if (nsnull != aTransferable) {
|
||||
return GetNativeClipboardData(aTransferable,aWhichClipboard);
|
||||
} else {
|
||||
qDebug(" nsClipboard::GetData(), aTransferable is NULL.\n");
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
|
||||
{
|
||||
qDebug("EmptyClipoard");
|
||||
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)
|
||||
{
|
||||
qDebug("SuppotsSelectionClipboard");
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
*_retval = PR_TRUE; // we support the selection clipboard on unix.
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* -*- 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__
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,206 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 NSCOMMONWIDGET_H
|
||||
#define NSCOMMONWIDGET_H
|
||||
|
||||
#include "nsBaseWidget.h"
|
||||
|
||||
#include "nsEvent.h"
|
||||
|
||||
#include <qevent.h> //XXX switch for forward-decl
|
||||
|
||||
class nsIToolkit;
|
||||
class nsWidgetInitData;
|
||||
class nsIDeviceContext;
|
||||
class nsIAppShell;
|
||||
class nsIFontMetrics;
|
||||
class nsColorMap;
|
||||
class nsFont;
|
||||
class nsRect;
|
||||
class nsAString;
|
||||
class nsIMenuBar;
|
||||
class nsGUIEvent;
|
||||
class nsIRollupListener;
|
||||
class QWidget;
|
||||
class nsQtEventDispatcher;
|
||||
|
||||
class nsCommonWidget : public nsBaseWidget
|
||||
{
|
||||
public:
|
||||
nsCommonWidget();
|
||||
~nsCommonWidget();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD Show(PRBool);
|
||||
NS_IMETHOD IsVisible(PRBool&);
|
||||
|
||||
NS_IMETHOD ConstrainPosition(int, PRInt32*, PRInt32*);
|
||||
NS_IMETHOD Move(int, int);
|
||||
NS_IMETHOD Resize(int, int, int);
|
||||
NS_IMETHOD Resize(int, int, int, int, int);
|
||||
NS_IMETHOD Enable(int);
|
||||
NS_IMETHOD IsEnabled(PRBool*);
|
||||
NS_IMETHOD SetFocus(int);
|
||||
|
||||
virtual nsIFontMetrics* GetFont();
|
||||
|
||||
NS_IMETHOD SetFont(const nsFont&);
|
||||
NS_IMETHOD Invalidate(int);
|
||||
NS_IMETHOD Invalidate(const nsRect&, int);
|
||||
NS_IMETHOD Update();
|
||||
NS_IMETHOD SetColorMap(nsColorMap*);
|
||||
NS_IMETHOD Scroll(int, int, nsRect*);
|
||||
NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy);
|
||||
|
||||
NS_METHOD SetModal(PRBool aModal);
|
||||
NS_METHOD ModalEventFilter(PRBool aRealEvent, void *aEvent, PRBool *aForWindow);
|
||||
|
||||
virtual void* GetNativeData(unsigned int);
|
||||
|
||||
NS_IMETHOD SetTitle(const nsAString&);
|
||||
NS_IMETHOD SetMenuBar(nsIMenuBar*);
|
||||
NS_IMETHOD ShowMenuBar(int);
|
||||
NS_IMETHOD WidgetToScreen(const nsRect&, nsRect&);
|
||||
NS_IMETHOD ScreenToWidget(const nsRect&, nsRect&);
|
||||
NS_IMETHOD BeginResizingChildren();
|
||||
NS_IMETHOD EndResizingChildren();
|
||||
NS_IMETHOD GetPreferredSize(PRInt32&, PRInt32&);
|
||||
NS_IMETHOD SetPreferredSize(int, int);
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent*, nsEventStatus&);
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener*, int, int);
|
||||
|
||||
// nsIWidget
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
NS_IMETHOD Create(nsNativeWidget aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
|
||||
nsCursor GetCursor();
|
||||
NS_METHOD SetCursor(nsCursor aCursor);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Event handlers (proxied from the actual qwidget).
|
||||
* They follow normal Qt widget semantics.
|
||||
*/
|
||||
friend class nsQtEventDispatcher;
|
||||
|
||||
virtual bool mousePressEvent(QMouseEvent *);
|
||||
virtual bool mouseReleaseEvent(QMouseEvent *);
|
||||
virtual bool mouseDoubleClickEvent(QMouseEvent *);
|
||||
virtual bool mouseMoveEvent(QMouseEvent *);
|
||||
virtual bool wheelEvent(QWheelEvent *);
|
||||
virtual bool keyPressEvent(QKeyEvent *);
|
||||
virtual bool keyReleaseEvent(QKeyEvent *);
|
||||
virtual bool focusInEvent(QFocusEvent *);
|
||||
virtual bool focusOutEvent(QFocusEvent *);
|
||||
virtual bool enterEvent(QEvent *);
|
||||
virtual bool leaveEvent(QEvent *);
|
||||
virtual bool paintEvent(QPaintEvent *);
|
||||
virtual bool moveEvent(QMoveEvent *);
|
||||
virtual bool resizeEvent(QResizeEvent *);
|
||||
virtual bool closeEvent(QCloseEvent *);
|
||||
virtual bool contextMenuEvent(QContextMenuEvent *);
|
||||
virtual bool imStartEvent(QIMEvent *);
|
||||
virtual bool imComposeEvent(QIMEvent *);
|
||||
virtual bool imEndEvent(QIMEvent *);
|
||||
virtual bool dragEnterEvent(QDragEnterEvent *);
|
||||
virtual bool dragMoveEvent(QDragMoveEvent *);
|
||||
virtual bool dragLeaveEvent(QDragLeaveEvent *);
|
||||
virtual bool dropEvent(QDropEvent *);
|
||||
virtual bool showEvent(QShowEvent *);
|
||||
virtual bool hideEvent(QHideEvent *);
|
||||
|
||||
protected:
|
||||
virtual QWidget *createQWidget(QWidget *parent, nsWidgetInitData *aInitData) = 0;
|
||||
bool ignoreEvent(nsEventStatus aStatus) const;
|
||||
|
||||
/**
|
||||
* Has to be called in subclasses after they created
|
||||
* the actual QWidget if they overwrite the Create
|
||||
* calls from the nsCommonWidget class.
|
||||
*/
|
||||
void Initialize(QWidget *widget);
|
||||
|
||||
void DispatchGotFocusEvent(void);
|
||||
void DispatchLostFocusEvent(void);
|
||||
void DispatchActivateEvent(void);
|
||||
void DispatchDeactivateEvent(void);
|
||||
void DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus);
|
||||
|
||||
void InitKeyEvent(nsKeyEvent *nsEvent, QKeyEvent *qEvent);
|
||||
void InitMouseEvent(nsMouseEvent *nsEvent, QMouseEvent *qEvent, int aClickCount);
|
||||
void InitMouseWheelEvent(nsMouseScrollEvent *aEvent, QWheelEvent *qEvent);
|
||||
|
||||
void CommonCreate(nsIWidget *aParent, PRBool aListenForResizes);
|
||||
|
||||
PRBool AreBoundsSane() const;
|
||||
|
||||
protected:
|
||||
QWidget *mContainer;
|
||||
QWidget *mWidget;
|
||||
nsQtEventDispatcher *mDispatcher;
|
||||
PRPackedBool mListenForResizes;
|
||||
nsCOMPtr<nsIWidget> mParent;
|
||||
|
||||
private:
|
||||
nsresult NativeCreate(nsIWidget *aParent,
|
||||
QWidget *aNativeParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,301 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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;
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/* -*- 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__
|
|
@ -0,0 +1,286 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "nsFilePicker.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include <qfiledialog.h>
|
||||
#include <qfile.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsFilePicker, nsIFilePicker)
|
||||
|
||||
nsFilePicker::nsFilePicker()
|
||||
: mDialog(0),
|
||||
mMode(nsIFilePicker::modeOpen)
|
||||
{
|
||||
}
|
||||
|
||||
nsFilePicker::~nsFilePicker()
|
||||
{
|
||||
delete mDialog;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::Init(nsIDOMWindow *parent, const nsAString & title, PRInt16 mode)
|
||||
{
|
||||
return nsBaseFilePicker::Init(parent, title, mode);
|
||||
}
|
||||
|
||||
/* void appendFilters (in long filterMask); */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::AppendFilters(PRInt32 filterMask)
|
||||
{
|
||||
return nsBaseFilePicker::AppendFilters(filterMask);
|
||||
}
|
||||
|
||||
/* void appendFilter (in AString title, in AString filter); */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::AppendFilter(const nsAString & aTitle, const nsAString & aFilter)
|
||||
{
|
||||
if (aFilter.Equals(NS_LITERAL_STRING("..apps"))) {
|
||||
// No platform specific thing we can do here, really....
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCAutoString filter, name;
|
||||
CopyUTF16toUTF8(aFilter, filter);
|
||||
CopyUTF16toUTF8(aTitle, name);
|
||||
|
||||
mFilters.AppendCString(filter);
|
||||
mFilterNames.AppendCString(name);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute AString defaultString; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetDefaultString(nsAString & aDefaultString)
|
||||
{
|
||||
mDefault = aDefaultString;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::SetDefaultString(const nsAString & aDefaultString)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* attribute AString defaultExtension; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetDefaultExtension(nsAString & aDefaultExtension)
|
||||
{
|
||||
aDefaultExtension = mDefaultExtension;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::SetDefaultExtension(const nsAString & aDefaultExtension)
|
||||
{
|
||||
mDefaultExtension = aDefaultExtension;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long filterIndex; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetFilterIndex(PRInt32 *aFilterIndex)
|
||||
{
|
||||
*aFilterIndex = mSelectedType;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::SetFilterIndex(PRInt32 aFilterIndex)
|
||||
{
|
||||
mSelectedType = aFilterIndex;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsILocalFile displayDirectory; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetDisplayDirectory(nsILocalFile * *aDisplayDirectory)
|
||||
{
|
||||
NS_IF_ADDREF(*aDisplayDirectory = mDisplayDirectory);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::SetDisplayDirectory(nsILocalFile * aDisplayDirectory)
|
||||
{
|
||||
mDisplayDirectory = aDisplayDirectory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsILocalFile file; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetFile(nsILocalFile * *aFile)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
|
||||
*aFile = nsnull;
|
||||
if (mFile.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
|
||||
NS_ENSURE_TRUE(file, NS_ERROR_FAILURE);
|
||||
|
||||
file->InitWithNativePath(mFile);
|
||||
|
||||
NS_ADDREF(*aFile = file);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIFileURL fileURL; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetFileURL(nsIFileURL * *aFileURL)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
GetFile(getter_AddRefs(file));
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewFileURI(getter_AddRefs(uri), file);
|
||||
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
||||
|
||||
return CallQueryInterface(uri, aFileURL);
|
||||
}
|
||||
|
||||
/* readonly attribute nsISimpleEnumerator files; */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::GetFiles(nsISimpleEnumerator * *aFiles)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFiles);
|
||||
|
||||
if (mMode == nsIFilePicker::modeOpenMultiple) {
|
||||
return NS_NewArrayEnumerator(aFiles, mFiles);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* short show (); */
|
||||
NS_IMETHODIMP
|
||||
nsFilePicker::Show(PRInt16 *aReturn)
|
||||
{
|
||||
nsCAutoString directory;
|
||||
if (mDisplayDirectory) {
|
||||
mDisplayDirectory->GetNativePath(directory);
|
||||
}
|
||||
|
||||
switch (mMode) {
|
||||
case nsIFilePicker::modeOpen:
|
||||
break;
|
||||
case nsIFilePicker::modeOpenMultiple:
|
||||
mDialog->setMode(QFileDialog::ExistingFiles);
|
||||
break;
|
||||
case nsIFilePicker::modeSave:
|
||||
mDialog->setMode(QFileDialog::AnyFile);
|
||||
break;
|
||||
case nsIFilePicker::modeGetFolder:
|
||||
mDialog->setMode(QFileDialog::DirectoryOnly);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
mDialog->setSelection(QString::fromUcs2(mDefault.get()));
|
||||
|
||||
mDialog->setDir(directory.get());
|
||||
|
||||
QStringList filters;
|
||||
PRInt32 count = mFilters.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
filters.append( mFilters[i]->get() );
|
||||
}
|
||||
mDialog->setFilters(filters);
|
||||
|
||||
switch (mDialog->exec()) {
|
||||
case QDialog::Accepted: {
|
||||
QCString path = QFile::encodeName(mDialog->selectedFile());
|
||||
qDebug("path is '%s'", path.data());
|
||||
mFile.Assign(path);
|
||||
*aReturn = nsIFilePicker::returnOK;
|
||||
if (mMode == modeSave) {
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
GetFile(getter_AddRefs(file));
|
||||
if (file) {
|
||||
PRBool exists = PR_FALSE;
|
||||
file->Exists(&exists);
|
||||
if (exists) {
|
||||
*aReturn = nsIFilePicker::returnReplace;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QDialog::Rejected: {
|
||||
*aReturn = nsIFilePicker::returnCancel;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
*aReturn = nsIFilePicker::returnCancel;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsFilePicker::InitNative(nsIWidget *parent, const nsAString &title, PRInt16 mode)
|
||||
{
|
||||
QWidget *parentWidget = (parent)? (QWidget*)parent->GetNativeData(NS_NATIVE_WIDGET):0;
|
||||
|
||||
nsAutoString str(title);
|
||||
mDialog = new QFileDialog(parentWidget);
|
||||
mDialog->setCaption(QString::fromUcs2(str.get()));
|
||||
mMode = mode;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 NSFILEPICKER_H
|
||||
#define NSFILEPICKER_H
|
||||
|
||||
#include "nsBaseFilePicker.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIWidget;
|
||||
class nsILocalFile;
|
||||
class nsISupportsArray;
|
||||
class QFileDialog;
|
||||
|
||||
class nsFilePicker : public nsBaseFilePicker
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFILEPICKER
|
||||
|
||||
nsFilePicker();
|
||||
|
||||
private:
|
||||
~nsFilePicker();
|
||||
void InitNative(nsIWidget*, const nsAString&, short int);
|
||||
|
||||
protected:
|
||||
QFileDialog *mDialog;
|
||||
nsCOMPtr<nsILocalFile> mDisplayDirectory;
|
||||
nsCOMPtr<nsISupportsArray> mFiles;
|
||||
|
||||
PRInt16 mMode;
|
||||
PRInt16 mSelectedType;
|
||||
nsCString mFile;
|
||||
nsString mTitle;
|
||||
nsString mDefault;
|
||||
nsString mDefaultExtension;
|
||||
|
||||
nsCStringArray mFilters;
|
||||
nsCStringArray mFilterNames;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- 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
|
|
@ -0,0 +1,474 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 <qpalette.h>
|
||||
#include <qapplication.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;
|
||||
}
|
||||
|
||||
static const char *metricToString[] = {
|
||||
"eMetric_WindowTitleHeight",
|
||||
"eMetric_WindowBorderWidth",
|
||||
"eMetric_WindowBorderHeight",
|
||||
"eMetric_Widget3DBorder",
|
||||
"eMetric_TextFieldBorder"
|
||||
"eMetric_TextFieldHeight",
|
||||
"eMetric_TextVerticalInsidePadding",
|
||||
"eMetric_TextShouldUseVerticalInsidePadding",
|
||||
"eMetric_TextHorizontalInsideMinimumPadding",
|
||||
"eMetric_TextShouldUseHorizontalInsideMinimumPadding",
|
||||
"eMetric_ButtonHorizontalInsidePaddingNavQuirks",
|
||||
"eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks",
|
||||
"eMetric_CheckboxSize",
|
||||
"eMetric_RadioboxSize",
|
||||
|
||||
"eMetric_ListShouldUseHorizontalInsideMinimumPadding",
|
||||
"eMetric_ListHorizontalInsideMinimumPadding",
|
||||
|
||||
"eMetric_ListShouldUseVerticalInsidePadding",
|
||||
"eMetric_ListVerticalInsidePadding",
|
||||
|
||||
"eMetric_CaretBlinkTime",
|
||||
"eMetric_SingleLineCaretWidth",
|
||||
"eMetric_MultiLineCaretWidth",
|
||||
"eMetric_ShowCaretDuringSelection",
|
||||
"eMetric_SelectTextfieldsOnKeyFocus",
|
||||
"eMetric_SubmenuDelay",
|
||||
"eMetric_MenusCanOverlapOSBar",
|
||||
"eMetric_DragFullWindow",
|
||||
"eMetric_DragThresholdX",
|
||||
"eMetric_DragThresholdY",
|
||||
"eMetric_UseAccessibilityTheme",
|
||||
|
||||
"eMetric_ScrollArrowStyle",
|
||||
"eMetric_ScrollSliderStyle",
|
||||
|
||||
"eMetric_TreeOpenDelay",
|
||||
"eMetric_TreeCloseDelay",
|
||||
"eMetric_TreeLazyScrollDelay",
|
||||
"eMetric_TreeScrollDelay",
|
||||
"eMetric_TreeScrollLinesMax"
|
||||
};
|
||||
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID,PRInt32 &aMetric)
|
||||
{
|
||||
// qDebug("nsLookAndFeel::GetMetric aID = %s", metricToString[aID]);
|
||||
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
||||
if (NS_SUCCEEDED(res))
|
||||
return res;
|
||||
// qDebug(" checking ourselves");
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* 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
|
|
@ -0,0 +1,184 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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 "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
|
||||
|
||||
const nsMimeStoreData* msd;
|
||||
msd = mMimeStore.at(n);
|
||||
|
||||
return msd->flavorName;
|
||||
}
|
||||
|
||||
QByteArray nsMimeStore::encodedData(const char* name) const
|
||||
{
|
||||
QByteArray qba;
|
||||
|
||||
QString mime(name);
|
||||
|
||||
/* XXX: for some reason in here we're getting mimetype
|
||||
* with charset, eg "text/plain;charset=UTF-8" so here
|
||||
* we remove the charset
|
||||
*/
|
||||
int n = mime.findRev(";");
|
||||
mime = mime.remove(n, mime.length() - n);
|
||||
|
||||
// because of const
|
||||
nsMimeStoreData* msd;
|
||||
QPtrList<nsMimeStoreData>::const_iterator it = mMimeStore.begin();
|
||||
while ((msd = *it)) {
|
||||
if (mime.utf8() == msd->flavorName) {
|
||||
qba = msd->flavorData;
|
||||
return qba;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
#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);
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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:
|
||||
mutable QPtrList<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
|
|
@ -0,0 +1,292 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zack Rusin <zack@kde.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "nsScrollbar.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
#define mScroll ((QScrollBar*)mWidget)
|
||||
|
||||
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)
|
||||
{
|
||||
qDebug("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
|
||||
connect(this,SIGNAL(valueChanged(int)),
|
||||
SLOT(slotValueChanged(int)));
|
||||
}
|
||||
|
||||
void nsQScrollBar::slotValueChanged(int aValue)
|
||||
{
|
||||
ScrollBarMoved(NS_SCROLLBAR_POS,aValue);
|
||||
}
|
||||
|
||||
void nsQScrollBar::ScrollBarMoved(int aMessage,int aValue)
|
||||
{
|
||||
nsScrollbarEvent nsEvent;
|
||||
|
||||
nsEvent.message = aMessage;
|
||||
nsEvent.widget = 0;
|
||||
nsEvent.eventStructType = NS_SCROLLBAR_EVENT;
|
||||
nsEvent.position = aValue;
|
||||
|
||||
//mReceiver->scrollEvent(nsEvent,aValue);
|
||||
//FIXME:
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// nsScrollBar class
|
||||
//=============================================================================
|
||||
NS_IMPL_ADDREF_INHERITED(nsNativeScrollbar,nsCommonWidget)
|
||||
NS_IMPL_RELEASE_INHERITED(nsNativeScrollbar,nsCommonWidget)
|
||||
NS_IMPL_QUERY_INTERFACE2(nsNativeScrollbar,nsINativeScrollbar,nsIWidget)
|
||||
|
||||
nsNativeScrollbar::nsNativeScrollbar()
|
||||
: nsCommonWidget(),
|
||||
nsINativeScrollbar()
|
||||
{
|
||||
|
||||
qDebug("YESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS");
|
||||
mOrientation = true ? QScrollBar::Vertical : QScrollBar::Horizontal;
|
||||
mLineStep = 1;
|
||||
mPageStep = 10;
|
||||
mMaxValue = 100;
|
||||
mValue = 0;
|
||||
mListenForResizes = PR_TRUE;
|
||||
}
|
||||
|
||||
nsNativeScrollbar::~nsNativeScrollbar()
|
||||
{
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsNativeScrollbar::SetMaxRange(PRUint32 aEndRange)
|
||||
{
|
||||
mMaxValue = aEndRange;
|
||||
|
||||
mScroll->setRange(0,mMaxValue - mPageStep);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsNativeScrollbar::GetMaxRange(PRUint32 *aMaxRange)
|
||||
{
|
||||
*aMaxRange = mMaxValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsNativeScrollbar::SetPosition(PRUint32 aPos)
|
||||
{
|
||||
mValue = aPos;
|
||||
|
||||
mScroll->setValue(mValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsNativeScrollbar::GetPosition(PRUint32 *aPos)
|
||||
{
|
||||
*aPos = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Set the line increment for this scrollbar
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD
|
||||
nsNativeScrollbar::SetLineIncrement(PRUint32 aLineIncrement)
|
||||
{
|
||||
if (aLineIncrement > 0) {
|
||||
mLineStep = aLineIncrement;
|
||||
|
||||
mScroll->setSteps(mLineStep,mPageStep);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Get the line increment for this scrollbar
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD
|
||||
nsNativeScrollbar::GetLineIncrement(PRUint32 *aLineInc)
|
||||
{
|
||||
*aLineInc = mLineStep;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_METHOD
|
||||
nsNativeScrollbar::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;
|
||||
|
||||
mScroll->setValue(mValue);
|
||||
mScroll->setSteps(mLineStep,mPageStep);
|
||||
mScroll->setRange(0,mMaxValue - mPageStep);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Deal with scrollbar messages (actually implemented only in nsNativeScrollbar)
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsNativeScrollbar::OnScroll(nsScrollbarEvent &aEvent,PRUint32 cPos)
|
||||
{
|
||||
nsEventStatus result = nsEventStatus_eIgnore;
|
||||
|
||||
switch (aEvent.message) {
|
||||
// scroll one line right or down
|
||||
case NS_SCROLLBAR_LINE_NEXT:
|
||||
mScroll->addLine();
|
||||
mValue = mScroll->value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = (*mEventCallback)(&aEvent);
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// scroll one line left or up
|
||||
case NS_SCROLLBAR_LINE_PREV:
|
||||
mScroll->subtractLine();
|
||||
mValue = mScroll->value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the decrement
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = (*mEventCallback)(&aEvent);
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// Scrolls one page right or down
|
||||
case NS_SCROLLBAR_PAGE_NEXT:
|
||||
mScroll->addPage();
|
||||
mValue = mScroll->value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = (*mEventCallback)(&aEvent);
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
|
||||
// Scrolls one page left or up.
|
||||
case NS_SCROLLBAR_PAGE_PREV:
|
||||
mScroll->subtractPage();
|
||||
mValue = mScroll->value();
|
||||
|
||||
// if an event callback is registered, give it the chance
|
||||
// to change the increment
|
||||
if (mEventCallback) {
|
||||
aEvent.position = (PRUint32)mValue;
|
||||
result = (*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 = (*mEventCallback)(&aEvent);
|
||||
mValue = aEvent.position;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ignoreEvent(result);
|
||||
}
|
||||
|
||||
QWidget*
|
||||
nsNativeScrollbar::createQWidget(QWidget *parent, nsWidgetInitData */*aInitData*/)
|
||||
{
|
||||
mWidget = new nsQScrollBar(0, mMaxValue, mLineStep, mPageStep,
|
||||
mValue, mOrientation, parent);
|
||||
mWidget->setMouseTracking(PR_TRUE);
|
||||
|
||||
return mWidget;
|
||||
}
|
||||
|
||||
/* void setContent (in nsIContent content, in nsISupports scrollbar, in nsIScrollbarMediator mediator); */
|
||||
NS_IMETHODIMP
|
||||
nsNativeScrollbar::SetContent(nsIContent *content, nsISupports *scrollbar, nsIScrollbarMediator *mediator)
|
||||
{
|
||||
qDebug("XXXXXXXX SetContent");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute long narrowSize; */
|
||||
NS_IMETHODIMP
|
||||
nsNativeScrollbar::GetNarrowSize(PRInt32 *aNarrowSize)
|
||||
{
|
||||
qDebug("XXXXXXXXXXXX GetNarrowSize");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
/* attribute unsigned long viewSize; */
|
||||
NS_IMETHODIMP
|
||||
nsNativeScrollbar::GetViewSize(PRUint32 *aViewSize)
|
||||
{
|
||||
qDebug("XXXXXXXXX GetViewSize");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsNativeScrollbar::SetViewSize(PRUint32 aViewSize)
|
||||
{
|
||||
qDebug("XXXXXXXXXXX SetViewSize");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** 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 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nscore.h"
|
||||
#include "plstr.h"
|
||||
#include "prlink.h"
|
||||
|
||||
#include "nsSound.h"
|
||||
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSound, nsISound)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
nsSound::nsSound()
|
||||
{
|
||||
}
|
||||
|
||||
nsSound::~nsSound()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsSound::Beep()
|
||||
{
|
||||
QApplication::beep();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsSound::Play(nsIURL *aURL)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
if (!aSoundAlias)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (strcmp(aSoundAlias, "_moz_mailbeep") == 0) {
|
||||
QApplication::beep();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// nsresult rv;
|
||||
// nsCOMPtr <nsIURI> fileURI;
|
||||
|
||||
// // create a nsILocalFile and then a nsIFileURL from that
|
||||
// nsCOMPtr <nsILocalFile> soundFile;
|
||||
// rv = NS_NewNativeLocalFile(nsDependentCString(aSoundAlias), PR_TRUE,
|
||||
// getter_AddRefs(soundFile));
|
||||
// NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
|
||||
// NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(fileURI,&rv);
|
||||
// NS_ENSURE_SUCCESS(rv,rv);
|
||||
// rv = Play(fileURL);
|
||||
// return rv;
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/* -*- 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):
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* 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;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- 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__
|
|
@ -0,0 +1,155 @@
|
|||
/* -*- 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
|
||||
* John C. Griggs <johng@corel.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Zack Rusin <zack@kde.org>
|
||||
* Lars Knoll <knoll@kde.org>
|
||||
* 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 "nsIComponentRegistrar.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsAutoPtr.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 "nsFilePicker.h"
|
||||
#include "nsSound.h"
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsQtEventDispatcher.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsBidiKeyboard.h"
|
||||
|
||||
static NS_DEFINE_CID(kNativeScrollCID, NS_NATIVESCROLLBAR_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(PopupWindow)
|
||||
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)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeScrollbar)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
|
||||
|
||||
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 Popup nsWindow",
|
||||
NS_POPUP_CID,
|
||||
"@mozilla.org/widgets/popup_window/qt;1",
|
||||
PopupWindowConstructor },
|
||||
{ "Qt Native Scrollbar",
|
||||
NS_NATIVESCROLLBAR_CID,
|
||||
"@mozilla.org/widget/nativescrollbar/qt;1",
|
||||
nsNativeScrollbarConstructor},
|
||||
{ "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 },
|
||||
{ "Qt Sound",
|
||||
NS_SOUND_CID,
|
||||
"@mozilla.org/sound;1",
|
||||
nsSoundConstructor },
|
||||
{ "Qt File Picker",
|
||||
NS_FILEPICKER_CID,
|
||||
"@mozilla.org/filepicker;1",
|
||||
nsFilePickerConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsWidgetQtModule,components)
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче