113 #endif |
108 #endif |
114 |
109 |
115 using namespace Java::eSWT; |
110 using namespace Java::eSWT; |
116 |
111 |
117 #define OS_NATIVE(func) Java_org_eclipse_swt_internal_qt_OS_##func |
112 #define OS_NATIVE(func) Java_org_eclipse_swt_internal_qt_OS_##func |
118 |
|
119 #define POINTER_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QObject*>(pointer)) |
|
120 #define HANDLE_TO_POINTER(type, variable, handle) type variable = qobject_cast<type>(static_cast<type>(reinterpret_cast<QObject*>( handle ))) |
|
121 |
|
122 #define QCOLOR_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QColor*>(pointer)) |
|
123 #define HANDLE_TO_QCOLOR(variable, handle) QColor* variable = static_cast<QColor*>(reinterpret_cast<QColor*>( handle )) |
|
124 |
|
125 #define QTABLEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QTableWidgetItem*>(pointer)) |
|
126 #define HANDLE_TO_QTABLEWIDGETITEM(variable, handle) QTableWidgetItem* variable = static_cast<QTableWidgetItem*>(reinterpret_cast<QTableWidgetItem*>( handle )) |
|
127 #define QTREEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QTreeWidgetItem*>(pointer)) |
|
128 #define HANDLE_TO_QTREEWIDGETITEM(variable, handle) QTreeWidgetItem* variable = static_cast<QTreeWidgetItem*>(reinterpret_cast<QTreeWidgetItem*>( handle )) |
|
129 |
|
130 #define SWT_TRY try |
|
131 #define SWT_CATCH \ |
|
132 catch(std::bad_alloc const&)\ |
|
133 {\ |
|
134 swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNoHandles );\ |
|
135 }\ |
|
136 catch(std::exception const&)\ |
|
137 {\ |
|
138 swtApp->jniUtils().Throw( aJniEnv, ESwtErrorUnspecified );\ |
|
139 } |
|
140 #define SWT_CATCH_1(err) \ |
|
141 catch(std::exception const&)\ |
|
142 {\ |
|
143 swtApp->jniUtils().Throw( aJniEnv, err );\ |
|
144 } |
|
145 |
113 |
146 #ifdef Q_WS_X11 |
114 #ifdef Q_WS_X11 |
147 void extern qt_x11_wait_for_window_manager(QWidget* widget); |
115 void extern qt_x11_wait_for_window_manager(QWidget* widget); |
148 #endif |
116 #endif |
149 |
117 |
10191 } |
10159 } |
10192 SWT_CATCH |
10160 SWT_CATCH |
10193 #endif |
10161 #endif |
10194 return ( result ? JNI_TRUE : JNI_FALSE ); |
10162 return ( result ? JNI_TRUE : JNI_FALSE ); |
10195 } |
10163 } |
10196 |
|
10197 |
|
10198 // |
|
10199 // QWebView |
|
10200 // |
|
10201 JNIEXPORT jint JNICALL OS_NATIVE( QWebView_1new ) |
|
10202 ( JNIEnv* aJniEnv , jclass ) |
|
10203 { |
|
10204 #ifndef QT_NO_WEBKIT |
|
10205 QWebView* browser = NULL; |
|
10206 SWT_TRY |
|
10207 { |
|
10208 SWT_LOG_JNI_CALL(); |
|
10209 browser = new QWebView(); |
|
10210 } |
|
10211 SWT_CATCH |
|
10212 return POINTER_TO_HANDLE( browser ); |
|
10213 #endif |
|
10214 #ifdef QT_NO_WEBKIT |
|
10215 swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNotImplemented ); |
|
10216 return 0; |
|
10217 #endif |
|
10218 } |
|
10219 |
|
10220 JNIEXPORT void JNICALL OS_NATIVE( QWebView_1back ) |
|
10221 ( JNIEnv* aJniEnv , jclass, jint |
|
10222 #ifndef QT_NO_WEBKIT |
|
10223 aHandle |
|
10224 #endif |
|
10225 ) |
|
10226 { |
|
10227 SWT_TRY |
|
10228 { |
|
10229 SWT_LOG_JNI_CALL(); |
|
10230 #ifndef QT_NO_WEBKIT |
|
10231 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10232 browser->back(); |
|
10233 #endif |
|
10234 } |
|
10235 SWT_CATCH |
|
10236 } |
|
10237 |
|
10238 JNIEXPORT void JNICALL OS_NATIVE( QWebView_1forward ) |
|
10239 ( JNIEnv* aJniEnv , jclass, jint |
|
10240 #ifndef QT_NO_WEBKIT |
|
10241 aHandle |
|
10242 #endif |
|
10243 ) |
|
10244 { |
|
10245 SWT_TRY |
|
10246 { |
|
10247 SWT_LOG_JNI_CALL(); |
|
10248 #ifndef QT_NO_WEBKIT |
|
10249 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10250 browser->forward(); |
|
10251 #endif |
|
10252 } |
|
10253 SWT_CATCH |
|
10254 } |
|
10255 |
|
10256 JNIEXPORT void JNICALL OS_NATIVE( QWebView_1reload ) |
|
10257 ( JNIEnv* aJniEnv , jclass, jint |
|
10258 #ifndef QT_NO_WEBKIT |
|
10259 aHandle |
|
10260 #endif |
|
10261 ) |
|
10262 { |
|
10263 SWT_TRY |
|
10264 { |
|
10265 SWT_LOG_JNI_CALL(); |
|
10266 #ifndef QT_NO_WEBKIT |
|
10267 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10268 browser->reload(); |
|
10269 #endif |
|
10270 } |
|
10271 SWT_CATCH |
|
10272 } |
|
10273 |
|
10274 JNIEXPORT void JNICALL OS_NATIVE( QWebView_1setHtml ) |
|
10275 ( JNIEnv* aJniEnv , jclass, jint |
|
10276 #ifndef QT_NO_WEBKIT |
|
10277 aHandle |
|
10278 #endif |
|
10279 , jstring |
|
10280 #ifndef QT_NO_WEBKIT |
|
10281 aText |
|
10282 #endif |
|
10283 ) |
|
10284 { |
|
10285 SWT_TRY |
|
10286 { |
|
10287 SWT_LOG_JNI_CALL(); |
|
10288 #ifndef QT_NO_WEBKIT |
|
10289 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10290 browser->setHtml( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ); |
|
10291 #endif |
|
10292 } |
|
10293 SWT_CATCH |
|
10294 } |
|
10295 |
|
10296 JNIEXPORT void JNICALL OS_NATIVE( QWebView_1setUrl ) |
|
10297 ( JNIEnv* aJniEnv , jclass, jint |
|
10298 #ifndef QT_NO_WEBKIT |
|
10299 aHandle |
|
10300 #endif |
|
10301 , jstring |
|
10302 #ifndef QT_NO_WEBKIT |
|
10303 aText |
|
10304 #endif |
|
10305 ) |
|
10306 { |
|
10307 SWT_TRY |
|
10308 { |
|
10309 SWT_LOG_JNI_CALL(); |
|
10310 #ifndef QT_NO_WEBKIT |
|
10311 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10312 browser->setUrl( QUrl( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ) ); |
|
10313 #endif |
|
10314 } |
|
10315 SWT_CATCH |
|
10316 } |
|
10317 |
|
10318 JNIEXPORT void JNICALL OS_NATIVE( QWebView_1stop ) |
|
10319 ( JNIEnv* aJniEnv , jclass, jint |
|
10320 #ifndef QT_NO_WEBKIT |
|
10321 aHandle |
|
10322 #endif |
|
10323 ) |
|
10324 { |
|
10325 SWT_TRY |
|
10326 { |
|
10327 SWT_LOG_JNI_CALL(); |
|
10328 #ifndef QT_NO_WEBKIT |
|
10329 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10330 browser->stop(); |
|
10331 #endif |
|
10332 } |
|
10333 SWT_CATCH |
|
10334 } |
|
10335 |
|
10336 JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1swt_1backUrl ) |
|
10337 ( JNIEnv* aJniEnv , jclass, jint |
|
10338 #ifndef QT_NO_WEBKIT |
|
10339 aHandle |
|
10340 #endif |
|
10341 ) |
|
10342 { |
|
10343 jstring res = NULL; |
|
10344 SWT_TRY |
|
10345 { |
|
10346 SWT_LOG_JNI_CALL(); |
|
10347 #ifndef QT_NO_WEBKIT |
|
10348 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10349 QWebHistory* history = browser->history(); |
|
10350 if ( history && history->canGoBack() ) |
|
10351 { |
|
10352 res = swtApp->jniUtils().QStringToJavaString( aJniEnv, history->backItem().url().toString() ); |
|
10353 } |
|
10354 #endif |
|
10355 } |
|
10356 SWT_CATCH |
|
10357 return res; |
|
10358 } |
|
10359 |
|
10360 JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1canGoBack ) |
|
10361 ( JNIEnv* aJniEnv , jclass, jint |
|
10362 #ifndef QT_NO_WEBKIT |
|
10363 aHandle |
|
10364 #endif |
|
10365 ) |
|
10366 { |
|
10367 jboolean res = false; |
|
10368 SWT_TRY |
|
10369 { |
|
10370 SWT_LOG_JNI_CALL(); |
|
10371 #ifndef QT_NO_WEBKIT |
|
10372 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10373 QWebHistory* history = browser->history(); |
|
10374 if ( history ) |
|
10375 { |
|
10376 res = history->canGoBack(); |
|
10377 } |
|
10378 #endif |
|
10379 } |
|
10380 SWT_CATCH |
|
10381 return res; |
|
10382 } |
|
10383 |
|
10384 JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1canGoForward ) |
|
10385 ( JNIEnv* aJniEnv , jclass, jint |
|
10386 #ifndef QT_NO_WEBKIT |
|
10387 aHandle |
|
10388 #endif |
|
10389 ) |
|
10390 { |
|
10391 jboolean res = false; |
|
10392 SWT_TRY |
|
10393 { |
|
10394 SWT_LOG_JNI_CALL(); |
|
10395 #ifndef QT_NO_WEBKIT |
|
10396 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10397 QWebHistory* history = browser->history(); |
|
10398 if ( history ) |
|
10399 { |
|
10400 res = history->canGoForward(); |
|
10401 } |
|
10402 #endif |
|
10403 } |
|
10404 SWT_CATCH |
|
10405 return res; |
|
10406 } |
|
10407 |
|
10408 JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1evaluateJavaScript ) |
|
10409 ( JNIEnv* aJniEnv , jclass, jint |
|
10410 #ifndef QT_NO_WEBKIT |
|
10411 aHandle |
|
10412 #endif |
|
10413 , jstring |
|
10414 #ifndef QT_NO_WEBKIT |
|
10415 aText |
|
10416 #endif |
|
10417 ) |
|
10418 { |
|
10419 jboolean res = false; |
|
10420 SWT_TRY |
|
10421 { |
|
10422 SWT_LOG_JNI_CALL(); |
|
10423 #ifndef QT_NO_WEBKIT |
|
10424 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10425 QWebPage* page = browser->page(); |
|
10426 if ( page ) |
|
10427 { |
|
10428 QWebFrame* frame = page->currentFrame(); |
|
10429 if ( !frame ) |
|
10430 { |
|
10431 frame = page->mainFrame(); |
|
10432 } |
|
10433 if ( frame ) |
|
10434 { |
|
10435 res = ( frame->evaluateJavaScript( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ) ).toBool(); |
|
10436 } |
|
10437 } |
|
10438 #endif |
|
10439 } |
|
10440 SWT_CATCH |
|
10441 return res; |
|
10442 } |
|
10443 |
|
10444 JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1swt_1forwardUrl ) |
|
10445 ( JNIEnv* aJniEnv , jclass, jint |
|
10446 #ifndef QT_NO_WEBKIT |
|
10447 aHandle |
|
10448 #endif |
|
10449 ) |
|
10450 { |
|
10451 jstring res = NULL; |
|
10452 SWT_TRY |
|
10453 { |
|
10454 SWT_LOG_JNI_CALL(); |
|
10455 #ifndef QT_NO_WEBKIT |
|
10456 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10457 QWebHistory* history = browser->history(); |
|
10458 if ( history && history->canGoForward() ) |
|
10459 { |
|
10460 res = swtApp->jniUtils().QStringToJavaString( aJniEnv, history->forwardItem().url().toString() ); |
|
10461 } |
|
10462 #endif |
|
10463 } |
|
10464 SWT_CATCH |
|
10465 return res; |
|
10466 } |
|
10467 |
|
10468 JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1url ) |
|
10469 ( JNIEnv* aJniEnv , jclass, jint |
|
10470 #ifndef QT_NO_WEBKIT |
|
10471 aHandle |
|
10472 #endif |
|
10473 ) |
|
10474 { |
|
10475 jstring res = NULL; |
|
10476 SWT_TRY |
|
10477 { |
|
10478 SWT_LOG_JNI_CALL(); |
|
10479 #ifndef QT_NO_WEBKIT |
|
10480 HANDLE_TO_POINTER( QWebView*, browser, aHandle ); |
|
10481 res = swtApp->jniUtils().QStringToJavaString( aJniEnv, browser->url().toString() ); |
|
10482 #endif |
|
10483 } |
|
10484 SWT_CATCH |
|
10485 return res; |
|
10486 } |
|
10487 |
10164 |
10488 // |
10165 // |
10489 // Special purpose global functions exported by Qt |
10166 // Special purpose global functions exported by Qt |
10490 // |
10167 // |
10491 |
10168 |