< prev index next >

modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m

Print this page




 457 }
 458 
 459 
 460 @end
 461 
 462 #pragma mark --- Dispatcher
 463 
 464 // TODO: re-implement using Obj-C blocks ?
 465 static jlong _createWindowCommonDo(JNIEnv *env, jobject jWindow, jlong jOwnerPtr, jlong jScreenPtr, jint jStyleMask, jboolean jIsChild)
 466 {
 467     GlassWindow *window = nil;
 468 
 469     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 470     {
 471         NSUInteger styleMask = NSBorderlessWindowMask;
 472         // only titled windows get title
 473         if ((jStyleMask&com_sun_glass_ui_Window_TITLED) != 0)
 474         {
 475             styleMask = styleMask|NSTitledWindowMask;
 476         }




 477         // only nontransparent windows get decorations
 478         if ((jStyleMask&com_sun_glass_ui_Window_TRANSPARENT) == 0)
 479         {
 480             if ((jStyleMask&com_sun_glass_ui_Window_CLOSABLE) != 0)
 481             {
 482                 styleMask = styleMask|NSClosableWindowMask;
 483             }
 484 
 485             if (((jStyleMask&com_sun_glass_ui_Window_MINIMIZABLE) != 0) ||
 486                 ((jStyleMask&com_sun_glass_ui_Window_MAXIMIZABLE) != 0))
 487             {
 488                 // on Mac OS X there is one set for min/max buttons,
 489                 // so if clients requests either one, we turn them both on
 490                 styleMask = styleMask|NSMiniaturizableWindowMask;
 491             }
 492 
 493             if ((jStyleMask&com_sun_glass_ui_Window_UNIFIED) != 0) {
 494                 styleMask = styleMask|NSTexturedBackgroundWindowMask;
 495             }
 496 
 497             if ((jStyleMask&com_sun_glass_ui_Window_UTILITY) != 0)
 498             {
 499                 styleMask = styleMask | NSUtilityWindowMask | NSNonactivatingPanelMask;
 500             }
 501         }
 502 
 503         if ((jStyleMask&com_sun_glass_ui_Window_POPUP) != 0)
 504         {
 505             // can receive keyboard input without activating the owning application
 506             styleMask = styleMask|NSNonactivatingPanelMask;
 507         }
 508 
 509         // initial size must be 0x0 otherwise we don't get resize update if the initial size happens to be the exact same size as the later programatical one!
 510         CGFloat x = 0.0f;
 511         CGFloat y = 0.0f;
 512         CGFloat w = 0.0f;
 513         CGFloat h = 0.0f;
 514 
 515         NSScreen *screen = (NSScreen*)jlong_to_ptr(jScreenPtr);
 516         window = [[GlassWindow alloc] _initWithContentRect:NSMakeRect(x, y, w, h) styleMask:styleMask screen:screen jwindow:jWindow jIsChild:jIsChild];
 517 
 518         if ((jStyleMask & com_sun_glass_ui_Window_UNIFIED) != 0) {
 519             //Prevent the textured effect from disappearing on border thickness recalculation
 520             [window->nsWindow setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
 521         }
 522 
 523         if ((jStyleMask & com_sun_glass_ui_Window_UTILITY) != 0) {
 524             [[window->nsWindow standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
 525             [[window->nsWindow standardWindowButton:NSWindowZoomButton] setHidden:YES];



 526         }
 527 
 528         if (jIsChild == JNI_FALSE)
 529         {
 530             if (jOwnerPtr != 0L)
 531             {
 532                 window->owner = getGlassWindow(env, jOwnerPtr)->nsWindow; // not retained (use weak reference?)
 533             }
 534         }
 535         else
 536         {
 537             if ((jOwnerPtr != 0L) && (jOwnerPtr != BROWSER_PARENT_ID))
 538             {
 539                 GlassEmbeddedWindow *parent = getGlassEmbeddedWindow(env, jOwnerPtr);
 540                 GlassEmbeddedWindow *ewindow = (GlassEmbeddedWindow*)window->nsWindow;
 541                 parent->child = ewindow; // not retained (use weak reference?)
 542 
 543                 ewindow->parent = parent; // not retained (use weak reference?)
 544             }
 545         }
 546         window->isResizable = NO;
 547         window->isDecorated = (jStyleMask&com_sun_glass_ui_Window_TITLED) != 0;
 548         /* 10.7 full screen window support */
 549         if ([NSWindow instancesRespondToSelector:@selector(toggleFullScreen:)]) {
 550             NSWindowCollectionBehavior behavior = [window->nsWindow collectionBehavior];
 551             if ((jStyleMask&com_sun_glass_ui_Window_POPUP) == 0 && !window->owner)
 552             {
 553                 // Only ownerless windows should have the Full Screen Toggle control
 554                 behavior |= (1 << 7) /* NSWindowCollectionBehaviorFullScreenPrimary */;
 555             }
 556             else
 557             {
 558                 // Other windows are only allowed to be shown together with a primary
 559                 // full screen window
 560                 behavior |= (1 << 8) /* NSWindowCollectionBehaviorFullScreenAuxiliary */;
 561             }
 562             [window->nsWindow setCollectionBehavior: behavior];
 563         }
 564 
 565         window->isTransparent = (jStyleMask & com_sun_glass_ui_Window_TRANSPARENT) != 0;
 566         if (window->isTransparent == YES)
 567         {
 568             [window->nsWindow setBackgroundColor:[NSColor clearColor]];
 569             [window->nsWindow setHasShadow:NO];
 570             [window->nsWindow setOpaque:NO];
 571         }




 457 }
 458 
 459 
 460 @end
 461 
 462 #pragma mark --- Dispatcher
 463 
 464 // TODO: re-implement using Obj-C blocks ?
 465 static jlong _createWindowCommonDo(JNIEnv *env, jobject jWindow, jlong jOwnerPtr, jlong jScreenPtr, jint jStyleMask, jboolean jIsChild)
 466 {
 467     GlassWindow *window = nil;
 468 
 469     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 470     {
 471         NSUInteger styleMask = NSBorderlessWindowMask;
 472         // only titled windows get title
 473         if ((jStyleMask&com_sun_glass_ui_Window_TITLED) != 0)
 474         {
 475             styleMask = styleMask|NSTitledWindowMask;
 476         }
 477 
 478         bool isUtility = (jStyleMask & com_sun_glass_ui_Window_UTILITY) != 0;
 479         bool isPopup = (jStyleMask & com_sun_glass_ui_Window_POPUP) != 0;
 480 
 481         // only nontransparent windows get decorations
 482         if ((jStyleMask&com_sun_glass_ui_Window_TRANSPARENT) == 0)
 483         {
 484             if ((jStyleMask&com_sun_glass_ui_Window_CLOSABLE) != 0)
 485             {
 486                 styleMask = styleMask|NSClosableWindowMask;
 487             }
 488 
 489             if (((jStyleMask&com_sun_glass_ui_Window_MINIMIZABLE) != 0) ||
 490                 ((jStyleMask&com_sun_glass_ui_Window_MAXIMIZABLE) != 0))
 491             {
 492                 // on Mac OS X there is one set for min/max buttons,
 493                 // so if clients requests either one, we turn them both on
 494                 styleMask = styleMask|NSMiniaturizableWindowMask;
 495             }
 496 
 497             if ((jStyleMask&com_sun_glass_ui_Window_UNIFIED) != 0) {
 498                 styleMask = styleMask|NSTexturedBackgroundWindowMask;
 499             }
 500 
 501             if (isUtility)
 502             {
 503                 styleMask = styleMask | NSUtilityWindowMask | NSNonactivatingPanelMask;
 504             }
 505         }
 506 
 507         if (isPopup)
 508         {
 509             // can receive keyboard input without activating the owning application
 510             styleMask = styleMask|NSNonactivatingPanelMask;
 511         }
 512 
 513         // initial size must be 0x0 otherwise we don't get resize update if the initial size happens to be the exact same size as the later programatical one!
 514         CGFloat x = 0.0f;
 515         CGFloat y = 0.0f;
 516         CGFloat w = 0.0f;
 517         CGFloat h = 0.0f;
 518 
 519         NSScreen *screen = (NSScreen*)jlong_to_ptr(jScreenPtr);
 520         window = [[GlassWindow alloc] _initWithContentRect:NSMakeRect(x, y, w, h) styleMask:styleMask screen:screen jwindow:jWindow jIsChild:jIsChild];
 521 
 522         if ((jStyleMask & com_sun_glass_ui_Window_UNIFIED) != 0) {
 523             //Prevent the textured effect from disappearing on border thickness recalculation
 524             [window->nsWindow setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
 525         }
 526 
 527         if ((jStyleMask & com_sun_glass_ui_Window_UTILITY) != 0) {
 528             [[window->nsWindow standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
 529             [[window->nsWindow standardWindowButton:NSWindowZoomButton] setHidden:YES];
 530             if (!jOwnerPtr) {
 531                 [window->nsWindow setLevel:NSNormalWindowLevel];
 532             }
 533         }
 534 
 535         if (jIsChild == JNI_FALSE)
 536         {
 537             if (jOwnerPtr != 0L)
 538             {
 539                 window->owner = getGlassWindow(env, jOwnerPtr)->nsWindow; // not retained (use weak reference?)
 540             }
 541         }
 542         else
 543         {
 544             if ((jOwnerPtr != 0L) && (jOwnerPtr != BROWSER_PARENT_ID))
 545             {
 546                 GlassEmbeddedWindow *parent = getGlassEmbeddedWindow(env, jOwnerPtr);
 547                 GlassEmbeddedWindow *ewindow = (GlassEmbeddedWindow*)window->nsWindow;
 548                 parent->child = ewindow; // not retained (use weak reference?)
 549 
 550                 ewindow->parent = parent; // not retained (use weak reference?)
 551             }
 552         }
 553         window->isResizable = NO;
 554         window->isDecorated = (jStyleMask&com_sun_glass_ui_Window_TITLED) != 0;
 555         /* 10.7 full screen window support */
 556         if ([NSWindow instancesRespondToSelector:@selector(toggleFullScreen:)]) {
 557             NSWindowCollectionBehavior behavior = [window->nsWindow collectionBehavior];
 558             if (!isPopup && !isUtility && !window->owner)
 559             {
 560                 // Only ownerless windows should have the Full Screen Toggle control
 561                 behavior |= (1 << 7) /* NSWindowCollectionBehaviorFullScreenPrimary */;
 562             }
 563             else
 564             {
 565                 // Other windows are only allowed to be shown together with a primary
 566                 // full screen window
 567                 behavior |= (1 << 8) /* NSWindowCollectionBehaviorFullScreenAuxiliary */;
 568             }
 569             [window->nsWindow setCollectionBehavior: behavior];
 570         }
 571 
 572         window->isTransparent = (jStyleMask & com_sun_glass_ui_Window_TRANSPARENT) != 0;
 573         if (window->isTransparent == YES)
 574         {
 575             [window->nsWindow setBackgroundColor:[NSColor clearColor]];
 576             [window->nsWindow setHasShadow:NO];
 577             [window->nsWindow setOpaque:NO];
 578         }


< prev index next >