< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp

Print this page




2330     TRY;
2331 
2332     HDC hIC = ::CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL);
2333 
2334     int nColor = 256;
2335     switch (::GetDeviceCaps(hIC, BITSPIXEL) * ::GetDeviceCaps(hIC, PLANES)) {
2336         case 1:         nColor = 2;             break;
2337         case 4:         nColor = 16;            break;
2338         case 8:         nColor = 256;           break;
2339         case 16:        nColor = 65536;         break;
2340         case 24:        nColor = 16777216;      break;
2341     }
2342     ::DeleteDC(hIC);
2343     return nColor;
2344 
2345     CATCH_BAD_ALLOC_RET(0);
2346 }
2347 
2348 /*
2349  * Class:     sun_awt_windows_WToolkit
2350  * Method:    getScreenWidth
2351  * Signature: ()I
2352  */
2353 JNIEXPORT jint JNICALL
2354 Java_sun_awt_windows_WToolkit_getScreenWidth(JNIEnv *env, jobject self)
2355 {
2356     TRY;
2357 
2358     int width = ::GetSystemMetrics(SM_CXSCREEN);
2359 
2360     Devices::InstanceAccess devices;
2361     AwtWin32GraphicsDevice *device = devices->GetDevice(
2362                         AwtWin32GraphicsDevice::GetDefaultDeviceIndex());
2363 
2364     return (device == NULL) ? width : device->ScaleDownX(width);
2365     CATCH_BAD_ALLOC_RET(0);
2366 }
2367 
2368 /*
2369  * Class:     sun_awt_windows_WToolkit
2370  * Method:    getScreenHeight
2371  * Signature: ()I
2372  */
2373 JNIEXPORT jint JNICALL
2374 Java_sun_awt_windows_WToolkit_getScreenHeight(JNIEnv *env, jobject self)
2375 {
2376     TRY;
2377 
2378     int height = ::GetSystemMetrics(SM_CYSCREEN);
2379     Devices::InstanceAccess devices;
2380     AwtWin32GraphicsDevice *device = devices->GetDevice(
2381                         AwtWin32GraphicsDevice::GetDefaultDeviceIndex());
2382 
2383     return (device == NULL) ? height : device->ScaleDownY(height);
2384 
2385     CATCH_BAD_ALLOC_RET(0);
2386 }
2387 
2388 /*
2389  * Class:     sun_awt_windows_WToolkit
2390  * Method:    getSreenInsets
2391  * Signature: (I)Ljava/awt/Insets;
2392  */
2393 JNIEXPORT jobject JNICALL
2394 Java_sun_awt_windows_WToolkit_getScreenInsets(JNIEnv *env,
2395                                               jobject self,
2396                                               jint screen)
2397 {
2398     jobject insets = NULL;
2399     RECT rect;
2400 
2401     TRY;
2402 
2403     if (AwtToolkit::GetScreenInsets(screen, &rect)) {
2404         jclass insetsClass = env->FindClass("java/awt/Insets");
2405         DASSERT(insetsClass != NULL);
2406         CHECK_NULL_RETURN(insetsClass, NULL);
2407 
2408         insets = env->NewObject(insetsClass,
2409                 AwtToolkit::insetsMID,




2330     TRY;
2331 
2332     HDC hIC = ::CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL);
2333 
2334     int nColor = 256;
2335     switch (::GetDeviceCaps(hIC, BITSPIXEL) * ::GetDeviceCaps(hIC, PLANES)) {
2336         case 1:         nColor = 2;             break;
2337         case 4:         nColor = 16;            break;
2338         case 8:         nColor = 256;           break;
2339         case 16:        nColor = 65536;         break;
2340         case 24:        nColor = 16777216;      break;
2341     }
2342     ::DeleteDC(hIC);
2343     return nColor;
2344 
2345     CATCH_BAD_ALLOC_RET(0);
2346 }
2347 
2348 /*
2349  * Class:     sun_awt_windows_WToolkit








































2350  * Method:    getSreenInsets
2351  * Signature: (I)Ljava/awt/Insets;
2352  */
2353 JNIEXPORT jobject JNICALL
2354 Java_sun_awt_windows_WToolkit_getScreenInsets(JNIEnv *env,
2355                                               jobject self,
2356                                               jint screen)
2357 {
2358     jobject insets = NULL;
2359     RECT rect;
2360 
2361     TRY;
2362 
2363     if (AwtToolkit::GetScreenInsets(screen, &rect)) {
2364         jclass insetsClass = env->FindClass("java/awt/Insets");
2365         DASSERT(insetsClass != NULL);
2366         CHECK_NULL_RETURN(insetsClass, NULL);
2367 
2368         insets = env->NewObject(insetsClass,
2369                 AwtToolkit::insetsMID,


< prev index next >