167
168 @end
169 @implementation AWTWindow_Panel
170 AWT_NS_WINDOW_IMPLEMENTATION
171 @end
172 // END of NSWindow/NSPanel descendants implementation
173 // --------------------------------------------------------------
174
175
176 @implementation AWTWindow
177
178 @synthesize nsWindow;
179 @synthesize javaPlatformWindow;
180 @synthesize javaMenuBar;
181 @synthesize javaMinSize;
182 @synthesize javaMaxSize;
183 @synthesize styleBits;
184 @synthesize isEnabled;
185 @synthesize ownerWindow;
186 @synthesize preFullScreenLevel;
187
188 - (void) updateMinMaxSize:(BOOL)resizable {
189 if (resizable) {
190 [self.nsWindow setMinSize:self.javaMinSize];
191 [self.nsWindow setMaxSize:self.javaMaxSize];
192 } else {
193 NSRect currentFrame = [self.nsWindow frame];
194 [self.nsWindow setMinSize:currentFrame.size];
195 [self.nsWindow setMaxSize:currentFrame.size];
196 }
197 }
198
199 // creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
200 + (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
201 NSUInteger type = 0;
202 if (IS(styleBits, DECORATED)) {
203 type |= NSTitledWindowMask;
204 if (IS(styleBits, CLOSEABLE)) type |= NSClosableWindowMask;
205 if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
206 if (IS(styleBits, RESIZABLE)) type |= NSResizableWindowMask;
492 - (void)windowDidMove:(NSNotification *)notification {
493 AWT_ASSERT_APPKIT_THREAD;
494
495 [self _deliverMoveResizeEvent];
496 }
497
498 - (void)windowDidResize:(NSNotification *)notification {
499 AWT_ASSERT_APPKIT_THREAD;
500
501 [self _deliverMoveResizeEvent];
502 }
503
504 - (void)windowDidExpose:(NSNotification *)notification {
505 AWT_ASSERT_APPKIT_THREAD;
506
507 [AWTToolkit eventCountPlusPlus];
508 // TODO: don't see this callback invoked anytime so we track
509 // window exposing in _setVisible:(BOOL)
510 }
511
512 - (void) _deliverIconify:(BOOL)iconify {
513 AWT_ASSERT_APPKIT_THREAD;
514
515 [AWTToolkit eventCountPlusPlus];
516 JNIEnv *env = [ThreadUtilities getJNIEnv];
517 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
518 if (platformWindow != NULL) {
519 static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
520 JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
521 (*env)->DeleteLocalRef(env, platformWindow);
522 }
523 }
524
525 - (void)windowDidMiniaturize:(NSNotification *)notification {
526 AWT_ASSERT_APPKIT_THREAD;
527
528 [self _deliverIconify:JNI_TRUE];
529 }
530
531 - (void)windowDidDeminiaturize:(NSNotification *)notification {
936 NSRect rect = ConvertNSScreenRect(NULL, jrect);
937 [window constrainSize:&rect.size];
938
939 [nsWindow setFrame:rect display:YES];
940
941 // only start tracking events if pointer is above the toplevel
942 // TODO: should post an Entered event if YES.
943 NSPoint mLocation = [NSEvent mouseLocation];
944 [nsWindow setAcceptsMouseMovedEvents:NSPointInRect(mLocation, rect)];
945
946 // ensure we repaint the whole window after the resize operation
947 // (this will also re-enable screen updates, which were disabled above)
948 // TODO: send PaintEvent
949 }];
950
951 JNF_COCOA_EXIT(env);
952 }
953
954 /*
955 * Class: sun_lwawt_macosx_CPlatformWindow
956 * Method: nativeSetNSWindowMinMax
957 * Signature: (JDDDD)V
958 */
959 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax
960 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH)
961 {
962 JNF_COCOA_ENTER(env);
963
964 if (minW < 1) minW = 1;
965 if (minH < 1) minH = 1;
966 if (maxW < 1) maxW = 1;
967 if (maxH < 1) maxH = 1;
968
969 NSWindow *nsWindow = OBJC(windowPtr);
970 [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
971
972 AWTWindow *window = (AWTWindow*)[nsWindow delegate];
973
974 NSSize min = { minW, minH };
975 NSSize max = { maxW, maxH };
|
167
168 @end
169 @implementation AWTWindow_Panel
170 AWT_NS_WINDOW_IMPLEMENTATION
171 @end
172 // END of NSWindow/NSPanel descendants implementation
173 // --------------------------------------------------------------
174
175
176 @implementation AWTWindow
177
178 @synthesize nsWindow;
179 @synthesize javaPlatformWindow;
180 @synthesize javaMenuBar;
181 @synthesize javaMinSize;
182 @synthesize javaMaxSize;
183 @synthesize styleBits;
184 @synthesize isEnabled;
185 @synthesize ownerWindow;
186 @synthesize preFullScreenLevel;
187 @synthesize standardFrame;
188
189 - (void) updateMinMaxSize:(BOOL)resizable {
190 if (resizable) {
191 [self.nsWindow setMinSize:self.javaMinSize];
192 [self.nsWindow setMaxSize:self.javaMaxSize];
193 } else {
194 NSRect currentFrame = [self.nsWindow frame];
195 [self.nsWindow setMinSize:currentFrame.size];
196 [self.nsWindow setMaxSize:currentFrame.size];
197 }
198 }
199
200 // creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
201 + (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
202 NSUInteger type = 0;
203 if (IS(styleBits, DECORATED)) {
204 type |= NSTitledWindowMask;
205 if (IS(styleBits, CLOSEABLE)) type |= NSClosableWindowMask;
206 if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
207 if (IS(styleBits, RESIZABLE)) type |= NSResizableWindowMask;
493 - (void)windowDidMove:(NSNotification *)notification {
494 AWT_ASSERT_APPKIT_THREAD;
495
496 [self _deliverMoveResizeEvent];
497 }
498
499 - (void)windowDidResize:(NSNotification *)notification {
500 AWT_ASSERT_APPKIT_THREAD;
501
502 [self _deliverMoveResizeEvent];
503 }
504
505 - (void)windowDidExpose:(NSNotification *)notification {
506 AWT_ASSERT_APPKIT_THREAD;
507
508 [AWTToolkit eventCountPlusPlus];
509 // TODO: don't see this callback invoked anytime so we track
510 // window exposing in _setVisible:(BOOL)
511 }
512
513 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window
514 defaultFrame:(NSRect)newFrame {
515
516 return [self standardFrame];
517 }
518
519 - (void) _deliverIconify:(BOOL)iconify {
520 AWT_ASSERT_APPKIT_THREAD;
521
522 [AWTToolkit eventCountPlusPlus];
523 JNIEnv *env = [ThreadUtilities getJNIEnv];
524 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
525 if (platformWindow != NULL) {
526 static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
527 JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
528 (*env)->DeleteLocalRef(env, platformWindow);
529 }
530 }
531
532 - (void)windowDidMiniaturize:(NSNotification *)notification {
533 AWT_ASSERT_APPKIT_THREAD;
534
535 [self _deliverIconify:JNI_TRUE];
536 }
537
538 - (void)windowDidDeminiaturize:(NSNotification *)notification {
943 NSRect rect = ConvertNSScreenRect(NULL, jrect);
944 [window constrainSize:&rect.size];
945
946 [nsWindow setFrame:rect display:YES];
947
948 // only start tracking events if pointer is above the toplevel
949 // TODO: should post an Entered event if YES.
950 NSPoint mLocation = [NSEvent mouseLocation];
951 [nsWindow setAcceptsMouseMovedEvents:NSPointInRect(mLocation, rect)];
952
953 // ensure we repaint the whole window after the resize operation
954 // (this will also re-enable screen updates, which were disabled above)
955 // TODO: send PaintEvent
956 }];
957
958 JNF_COCOA_EXIT(env);
959 }
960
961 /*
962 * Class: sun_lwawt_macosx_CPlatformWindow
963 * Method: nativeSetNSWindowStandardFrame
964 * Signature: (JDDDD)V
965 */
966 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStandardFrame
967 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY,
968 jdouble width, jdouble height)
969 {
970 JNF_COCOA_ENTER(env);
971
972 NSRect jrect = NSMakeRect(originX, originY, width, height);
973
974 NSWindow *nsWindow = OBJC(windowPtr);
975 [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
976
977 NSRect rect = ConvertNSScreenRect(NULL, jrect);
978 AWTWindow *window = (AWTWindow*)[nsWindow delegate];
979 window.standardFrame = rect;
980 }];
981
982 JNF_COCOA_EXIT(env);
983 }
984
985 /*
986 * Class: sun_lwawt_macosx_CPlatformWindow
987 * Method: nativeSetNSWindowMinMax
988 * Signature: (JDDDD)V
989 */
990 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax
991 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH)
992 {
993 JNF_COCOA_ENTER(env);
994
995 if (minW < 1) minW = 1;
996 if (minH < 1) minH = 1;
997 if (maxW < 1) maxW = 1;
998 if (maxH < 1) maxH = 1;
999
1000 NSWindow *nsWindow = OBJC(windowPtr);
1001 [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
1002
1003 AWTWindow *window = (AWTWindow*)[nsWindow delegate];
1004
1005 NSSize min = { minW, minH };
1006 NSSize max = { maxW, maxH };
|