diff options
author | Sven de Marothy <sven@physto.se> | 2005-08-11 17:06:48 +0000 |
---|---|---|
committer | Sven de Marothy <sven@physto.se> | 2005-08-11 17:06:48 +0000 |
commit | 334981d27e6cacf23a0a6bd5ab8f27ae2191a89e (patch) | |
tree | 98d9bd95f067ddd0e14717568ced5ab87719fb63 /native/jni/qt-peer/qttoolkit.cpp | |
parent | e636b4eefbcedc5ae1f1a2c6796317989c46dcb0 (diff) | |
download | classpath-334981d27e6cacf23a0a6bd5ab8f27ae2191a89e.tar.gz |
2005-08-11 Sven de Marothy <sven@physto.se>
* gnu/java/awt/peer/qt/QtMenuComponentPeer.java,
gnu/java/awt/peer/qt/QtGraphics.java,
gnu/java/awt/peer/qt/QtTextFieldPeer.java,
gnu/java/awt/peer/qt/QtFramePeer.java,
gnu/java/awt/peer/qt/QtPanelPeer.java,
gnu/java/awt/peer/qt/QtToolkit.java,
gnu/java/awt/peer/qt/QtWindowPeer.java,
gnu/java/awt/peer/qt/QtButtonPeer.java,
gnu/java/awt/peer/qt/QtImageGraphics.java,
gnu/java/awt/peer/qt/QtContainerPeer.java,
gnu/java/awt/peer/qt/QtComponentPeer.java,
gnu/java/awt/peer/qt/QtListPeer.java,
gnu/java/awt/peer/qt/QtChoicePeer.java,
gnu/java/awt/peer/qt/QtScrollPanePeer.java,
gnu/java/awt/peer/qt/MainQtThread.java,
gnu/java/awt/peer/qt/QtImage.java,
gnu/java/awt/peer/qt/NativeWrapper.java,
gnu/java/awt/peer/qt/QtCheckboxPeer.java,
gnu/java/awt/peer/qt/QtScreenDeviceConfiguration.java,
gnu/java/awt/peer/qt/QtTextAreaPeer.java,
gnu/java/awt/peer/qt/QtDialogPeer.java,
gnu/java/awt/peer/qt/QPen.java,
gnu/java/awt/peer/qt/QtCanvasPeer.java,
gnu/java/awt/peer/qt/QtLabelPeer.java,
gnu/java/awt/peer/qt/QtGraphicsEnvironment.java,
gnu/java/awt/peer/qt/QtImageConsumer.java,
gnu/java/awt/peer/qt/QtScrollbarPeer.java,
gnu/java/awt/peer/qt/QtFontMetrics.java,
gnu/java/awt/peer/qt/QtMenuBarPeer.java,
gnu/java/awt/peer/qt/QtFontPeer.java,
gnu/java/awt/peer/qt/QMatrix.java,
gnu/java/awt/peer/qt/QtVolatileImage.java,
gnu/java/awt/peer/qt/QPainterPath.java,
gnu/java/awt/peer/qt/QtComponentGraphics.java,
gnu/java/awt/peer/qt/QtScreenDevice.java,
gnu/java/awt/peer/qt/QtMenuPeer.java,
gnu/java/awt/peer/qt/QtAudioClip.java,
gnu/java/awt/peer/qt/QtPopupMenuPeer.java,
gnu/java/awt/peer/qt/QtFileDialogPeer.java,
gnu/java/awt/peer/qt/QtMenuItemPeer.java,
* native/jni/qt-peer/qpen.cpp,
native/jni/qt-peer/keybindings.cpp,
native/jni/qt-peer/qtcomponentpeer.cpp,
native/jni/qt-peer/buttonevent.h,
native/jni/qt-peer/qtdialogpeer.cpp,
native/jni/qt-peer/qtmenubarpeer.cpp,
native/jni/qt-peer/mainqtthread.cpp,
native/jni/qt-peer/qtpanelpeer.cpp,
native/jni/qt-peer/qmatrix.cpp,
native/jni/qt-peer/qtmenucomponentpeer.cpp,
native/jni/qt-peer/qtgraphics.cpp,
native/jni/qt-peer/qttoolkit.cpp,
native/jni/qt-peer/qtbuttonpeer.cpp,
native/jni/qt-peer/keybindings.h,
native/jni/qt-peer/qtvolatileimage.cpp,
native/jni/qt-peer/qtcomponent.h,
native/jni/qt-peer/slotcallbacks.cpp,
native/jni/qt-peer/qtpopupmenupeer.cpp,
native/jni/qt-peer/qtmenuitempeer.cpp,
native/jni/qt-peer/qtchoicepeer.cpp,
native/jni/qt-peer/nativewrapper.cpp,
native/jni/qt-peer/qtscreendevice.cpp,
native/jni/qt-peer/qtfontpeer.cpp,
native/jni/qt-peer/qpainterpath.cpp,
native/jni/qt-peer/qtstrings.h,
native/jni/qt-peer/qttextfieldpeer.cpp,
native/jni/qt-peer/qtimage.cpp,
native/jni/qt-peer/componentevent.h,
native/jni/qt-peer/qtwindowpeer.cpp,
native/jni/qt-peer/qtframepeer.cpp,
native/jni/qt-peer/qtscrollpanepeer.cpp,
native/jni/qt-peer/qtfontmetrics.cpp,
native/jni/qt-peer/qtlistpeer.cpp,
native/jni/qt-peer/mainthreadinterface.h
native/jni/qt-peer/slotcallbacks.h
native/jni/qt-peer/qtfiledialogpeer.cpp,
native/jni/qt-peer/eventmethods.cpp,
native/jni/qt-peer/qtimage.h,
native/jni/qt-peer/qtstrings.cpp,
native/jni/qt-peer/nativewrapper.h
native/jni/qt-peer/qtaudioclip.cpp,
native/jni/qt-peer/qtfont.h,
native/jni/qt-peer/qtscrollbarpeer.cpp,
native/jni/qt-peer/containers.h,
native/jni/qt-peer/qtcheckboxpeer.cpp,
native/jni/qt-peer/mainthreadinterface.cpp,
native/jni/qt-peer/componentevent.cpp,
native/jni/qt-peer/qttextareapeer.cpp,
native/jni/qt-peer/qtcomponent.cpp,
native/jni/qt-peer/qtmenupeer.cpp,
native/jni/qt-peer/qtlabelpeer.cpp,
native/jni/qt-peer/slotcallbacks.moc
native/jni/qt-peer/qtcanvaspeer.cpp,
native/jni/qt-peer/qtgraphics.h,
* include/gnu_java_awt_peer_qt_QtCheckboxPeer.h,
include/gnu_java_awt_peer_qt_QtToolkit.h,
include/gnu_java_awt_peer_qt_QtAudioClip.h,
include/gnu_java_awt_peer_qt_QtScreenDevice.h,
include/gnu_java_awt_peer_qt_QtTextFieldPeer.h,
include/gnu_java_awt_peer_qt_QtMenuItemPeer.h,
include/gnu_java_awt_peer_qt_QtButtonPeer.h,
include/gnu_java_awt_peer_qt_QtWindowPeer.h,
include/gnu_java_awt_peer_qt_QtDialogPeer.h,
include/gnu_java_awt_peer_qt_QtImage.h,
include/gnu_java_awt_peer_qt_QtMenuBarPeer.h,
include/gnu_java_awt_peer_qt_QtVolatileImage.h,
include/gnu_java_awt_peer_qt_QtFontPeer.h,
include/gnu_java_awt_peer_qt_QtChoicePeer.h,
include/gnu_java_awt_peer_qt_QtGraphics.h,
include/gnu_java_awt_peer_qt_QtComponentPeer.h,
include/gnu_java_awt_peer_qt_QtMenuPeer.h,
include/gnu_java_awt_peer_qt_QtTextAreaPeer.h,
include/gnu_java_awt_peer_qt_QPen.h,
include/gnu_java_awt_peer_qt_QtPanelPeer.h,
include/gnu_java_awt_peer_qt_QPainterPath.h,
include/gnu_java_awt_peer_qt_QtFontMetrics.h,
include/gnu_java_awt_peer_qt_QtScrollPanePeer.h,
include/gnu_java_awt_peer_qt_QtGraphicsEnvironment.h,
include/gnu_java_awt_peer_qt_QMatrix.h,
include/gnu_java_awt_peer_qt_QtLabelPeer.h,
include/gnu_java_awt_peer_qt_QtPopupMenuPeer.h,
include/gnu_java_awt_peer_qt_QtFramePeer.h,
include/gnu_java_awt_peer_qt_QtListPeer.h,
include/gnu_java_awt_peer_qt_QtScrollbarPeer.h,
include/gnu_java_awt_peer_qt_QtCanvasPeer.h,
include/gnu_java_awt_peer_qt_QtMenuComponentPeer.h,
include/gnu_java_awt_peer_qt_MainQtThread.h,
include/gnu_java_awt_peer_qt_QtFileDialogPeer.h,
include/gnu_java_awt_peer_qt_QtContainerPeer.h:
New files.
Diffstat (limited to 'native/jni/qt-peer/qttoolkit.cpp')
-rw-r--r-- | native/jni/qt-peer/qttoolkit.cpp | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/native/jni/qt-peer/qttoolkit.cpp b/native/jni/qt-peer/qttoolkit.cpp new file mode 100644 index 000000000..222b32344 --- /dev/null +++ b/native/jni/qt-peer/qttoolkit.cpp @@ -0,0 +1,156 @@ +/* qttoolkit.cpp -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +#include <QApplication> +#include <QDesktopWidget> +#include <QString> +#include <QStringList> +#include <QFontDatabase> +#include <gnu_java_awt_peer_qt_QtToolkit.h> +#include "qtcomponent.h" +#include "mainthreadinterface.h" +#include "qtstrings.h" + +extern QApplication *qApplication; + +/** + * Calls syncX(); + */ +class AWTSyncEvent : public AWTEvent { + + private: + QApplication *application; + + public: + AWTSyncEvent(QApplication *app) : AWTEvent() + { + application = app; + } + + void runEvent() + { + application->syncX(); + } +}; + +/* + * Causes your machine to beep. Wow. + */ +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_beep +(JNIEnv *env, jobject obj) +{ + qApplication->beep(); +} + +/** + * Returns the # of the default screen. + */ +JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_defaultScreen +(JNIEnv *env, jobject obj) +{ + return (jint) qApplication->desktop()->primaryScreen(); +} + +/** + * Returns the # of screens. + */ +JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_numScreens +(JNIEnv *env, jobject obj) +{ + return (jint) qApplication->desktop()->numScreens(); +} + +/* + * Returns the screen size. + */ +JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenSize +(JNIEnv *env, jobject obj) +{ + QDesktopWidget *d = QApplication::desktop(); + QSize s = d->size(); + return makeDimension( env, &s ); +} + +/* + * Returns the available fonts + */ +JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_nativeFontFamilies +(JNIEnv *env, jobject obj) +{ + jobjectArray result_array; + jobject *result_array_ptr; + QFontDatabase db; + QStringList fonts = db.families(); + + result_array = env->NewObjectArray(fonts.size(), + env->FindClass("java/lang/String"), + env->NewStringUTF("")); + for (int i = 0; i < fonts.size(); i++) + { + QString qstr = fonts.at(i); + jstring jstr = getJavaString(env, &qstr); + env->SetObjectArrayElement( result_array, i, jstr ); + } + return result_array; +} + + +/* + * Returns the screen resolution + */ +JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenResolution +(JNIEnv *env, jobject obj) +{ + QDesktopWidget *d = qApplication->desktop(); + + // Java assumes square pixels. Qt, more intelligently, does not. + // What to do? Well.. Average them? + // FIXME: Weird values? + int dpi = (d->logicalDpiX() + d->logicalDpiY()) >> 1; + + return (jint)dpi; +} + +/* + */ +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_sync +(JNIEnv *env, jobject obj) +{ + // SyncX needs to be called from the main thread. + mainThread->postEventToMain( new AWTSyncEvent( qApplication ) ); +} + |