Mercurial > dwindows
comparison mac/dw.m @ 1914:3872ab37297b
Fix numerous deprecation warnings building with SDK 10.12 Sierra.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 28 Sep 2016 18:36:53 +0000 |
parents | 7e23f3dccb6b |
children | a2a8145f3148 |
comparison
equal
deleted
inserted
replaced
1913:5d32be499016 | 1914:3872ab37297b |
---|---|
1 /* | 1 /* |
2 * Dynamic Windows: | 2 * Dynamic Windows: |
3 * A GTK like implementation of the MacOS GUI using Cocoa | 3 * A GTK like implementation of the MacOS GUI using Cocoa |
4 * | 4 * |
5 * (C) 2011-2015 Brian Smith <brian@dbsoft.org> | 5 * (C) 2011-2016 Brian Smith <brian@dbsoft.org> |
6 * (C) 2011 Mark Hessling <mark@rexx.org> | 6 * (C) 2011 Mark Hessling <mark@rexx.org> |
7 * | 7 * |
8 * Requires 10.5 or later. | 8 * Requires 10.5 or later. |
9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit | 9 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit |
10 */ | 10 */ |
308 id view = [[[event window] contentView] superview]; | 308 id view = [[[event window] contentView] superview]; |
309 NSEventType type = [event type]; | 309 NSEventType type = [event type]; |
310 | 310 |
311 p = [view convertPoint:[event locationInWindow] toView:object]; | 311 p = [view convertPoint:[event locationInWindow] toView:object]; |
312 | 312 |
313 #ifdef MAC_OS_X_VERSION_10_12 | |
314 if(type == NSEventTypeRightMouseDown || type == NSEventTypeRightMouseUp) | |
315 #else | |
313 if(type == NSRightMouseDown || type == NSRightMouseUp) | 316 if(type == NSRightMouseDown || type == NSRightMouseUp) |
317 #endif | |
314 { | 318 { |
315 button = 2; | 319 button = 2; |
316 } | 320 } |
321 #ifdef MAC_OS_X_VERSION_10_12 | |
322 else if(type == NSEventTypeOtherMouseDown || type == NSEventTypeOtherMouseDown) | |
323 #else | |
317 else if(type == NSOtherMouseDown || type == NSOtherMouseUp) | 324 else if(type == NSOtherMouseDown || type == NSOtherMouseUp) |
325 #endif | |
318 { | 326 { |
319 button = 3; | 327 button = 3; |
320 } | 328 } |
329 #ifdef MAC_OS_X_VERSION_10_12 | |
330 else if([event modifierFlags] & NSEventModifierFlagControl) | |
331 #else | |
321 else if([event modifierFlags] & NSControlKeyMask) | 332 else if([event modifierFlags] & NSControlKeyMask) |
333 #endif | |
322 { | 334 { |
323 button = 2; | 335 button = 2; |
324 } | 336 } |
325 } | 337 } |
326 | 338 |
514 DWTID _dw_mutex_locked = (DWTID)-1; | 526 DWTID _dw_mutex_locked = (DWTID)-1; |
515 | 527 |
516 /* Send fake event to make sure the loop isn't stuck */ | 528 /* Send fake event to make sure the loop isn't stuck */ |
517 void _dw_wakeup_app() | 529 void _dw_wakeup_app() |
518 { | 530 { |
531 #ifdef MAC_OS_X_VERSION_10_12 | |
532 [DWApp postEvent:[NSEvent otherEventWithType:NSEventTypeApplicationDefined | |
533 #else | |
519 [DWApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined | 534 [DWApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined |
535 #endif | |
520 location:NSMakePoint(0, 0) | 536 location:NSMakePoint(0, 0) |
521 modifierFlags:0 | 537 modifierFlags:0 |
522 timestamp:0 | 538 timestamp:0 |
523 windowNumber:0 | 539 windowNumber:0 |
524 context:NULL | 540 context:NULL |
608 if([bltsrc isMemberOfClass:[NSBitmapImageRep class]]) | 624 if([bltsrc isMemberOfClass:[NSBitmapImageRep class]]) |
609 { | 625 { |
610 NSBitmapImageRep *rep = bltsrc; | 626 NSBitmapImageRep *rep = bltsrc; |
611 NSImage *image = [NSImage alloc]; | 627 NSImage *image = [NSImage alloc]; |
612 SEL siwc = NSSelectorFromString(@"initWithCGImage"); | 628 SEL siwc = NSSelectorFromString(@"initWithCGImage"); |
629 #ifdef MAC_OS_X_VERSION_10_12 | |
630 NSCompositingOperation op = NSCompositingOperationSourceOver; | |
631 #else | |
632 NSCompositingOperation op = NSCompositeSourceOver; | |
633 #endif | |
613 | 634 |
614 if([image respondsToSelector:siwc]) | 635 if([image respondsToSelector:siwc]) |
615 { | 636 { |
616 IMP iiwc = [image methodForSelector:siwc]; | 637 IMP iiwc = [image methodForSelector:siwc]; |
617 image = iiwc(image, siwc, [rep CGImage], NSZeroSize); | 638 image = iiwc(image, siwc, [rep CGImage], NSZeroSize); |
623 } | 644 } |
624 if(bltinfo->srcwidth != -1) | 645 if(bltinfo->srcwidth != -1) |
625 { | 646 { |
626 [image drawInRect:NSMakeRect(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height) | 647 [image drawInRect:NSMakeRect(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height) |
627 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->srcwidth, bltinfo->srcheight) | 648 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->srcwidth, bltinfo->srcheight) |
628 operation:NSCompositeSourceOver fraction:1.0]; | 649 operation:op fraction:1.0]; |
629 } | 650 } |
630 else | 651 else |
631 { | 652 { |
632 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) | 653 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) |
633 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) | 654 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) |
634 operation:NSCompositeSourceOver fraction:1.0]; | 655 operation:op fraction:1.0]; |
635 } | 656 } |
636 [bltsrc release]; | 657 [bltsrc release]; |
637 [image release]; | 658 [image release]; |
638 } | 659 } |
639 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) | 660 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) |
821 | 842 |
822 @implementation DWWindow | 843 @implementation DWWindow |
823 -(void)sendEvent:(NSEvent *)theEvent | 844 -(void)sendEvent:(NSEvent *)theEvent |
824 { | 845 { |
825 int rcode = -1; | 846 int rcode = -1; |
847 #ifdef MAC_OS_X_VERSION_10_12 | |
848 if([theEvent type] == NSEventTypeKeyDown) | |
849 #else | |
826 if([theEvent type] == NSKeyDown) | 850 if([theEvent type] == NSKeyDown) |
851 #endif | |
827 { | 852 { |
828 rcode = _event_handler(self, theEvent, 2); | 853 rcode = _event_handler(self, theEvent, 2); |
829 } | 854 } |
830 if ( rcode != TRUE ) | 855 if ( rcode != TRUE ) |
831 [super sendEvent:theEvent]; | 856 [super sendEvent:theEvent]; |
870 -(NSFont *)font { return font; } | 895 -(NSFont *)font { return font; } |
871 -(void)setSize:(NSSize)input { size = input; } | 896 -(void)setSize:(NSSize)input { size = input; } |
872 -(NSSize)size { return size; } | 897 -(NSSize)size { return size; } |
873 -(void)mouseDown:(NSEvent *)theEvent | 898 -(void)mouseDown:(NSEvent *)theEvent |
874 { | 899 { |
900 #ifdef MAC_OS_X_VERSION_10_12 | |
901 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & NSEventModifierFlagControl)) | |
902 #else | |
875 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & NSControlKeyMask)) | 903 if(![theEvent isMemberOfClass:[NSEvent class]] || !([theEvent modifierFlags] & NSControlKeyMask)) |
904 #endif | |
876 _event_handler(self, theEvent, 3); | 905 _event_handler(self, theEvent, 3); |
877 } | 906 } |
878 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } | 907 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } |
879 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); return nil; } | 908 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); return nil; } |
880 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } | 909 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } |
1254 [super keyUp:theEvent]; | 1283 [super keyUp:theEvent]; |
1255 } | 1284 } |
1256 } | 1285 } |
1257 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent | 1286 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent |
1258 { | 1287 { |
1288 #ifdef MAC_OS_X_VERSION_10_12 | |
1289 if(([theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask) == NSEventModifierFlagCommand) | |
1290 #else | |
1259 if(([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask) | 1291 if(([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask) |
1292 #endif | |
1260 { | 1293 { |
1261 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"]) | 1294 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"]) |
1262 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self]; | 1295 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self]; |
1263 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"c"]) | 1296 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"c"]) |
1264 return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self]; | 1297 return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self]; |
1318 [super keyUp:theEvent]; | 1351 [super keyUp:theEvent]; |
1319 } | 1352 } |
1320 } | 1353 } |
1321 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent | 1354 -(BOOL)performKeyEquivalent:(NSEvent *)theEvent |
1322 { | 1355 { |
1356 #ifdef MAC_OS_X_VERSION_10_12 | |
1357 if(([theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask) == NSEventModifierFlagControl) | |
1358 #else | |
1323 if(([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask) | 1359 if(([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask) |
1360 #endif | |
1324 { | 1361 { |
1325 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"]) | 1362 if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"x"]) |
1326 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self]; | 1363 return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self]; |
1327 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"c"]) | 1364 else if ([[theEvent charactersIgnoringModifiers] isEqualToString:@"c"]) |
1328 return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self]; | 1365 return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self]; |
1720 if(image != nil) | 1757 if(image != nil) |
1721 { | 1758 { |
1722 NSSize imageSize; | 1759 NSSize imageSize; |
1723 NSRect imageFrame; | 1760 NSRect imageFrame; |
1724 SEL sdir = NSSelectorFromString(@"drawInRect:fromRect:operation:fraction:respectFlipped:hints:"); | 1761 SEL sdir = NSSelectorFromString(@"drawInRect:fromRect:operation:fraction:respectFlipped:hints:"); |
1762 #ifdef MAC_OS_X_VERSION_10_12 | |
1763 NSCompositingOperation op = NSCompositingOperationSourceOver; | |
1764 #else | |
1765 NSCompositingOperation op = NSCompositeSourceOver; | |
1766 #endif | |
1725 | 1767 |
1726 imageSize = [image size]; | 1768 imageSize = [image size]; |
1727 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge); | 1769 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge); |
1728 if ([self drawsBackground]) | 1770 if ([self drawsBackground]) |
1729 { | 1771 { |
1738 { | 1780 { |
1739 IMP idir = [image methodForSelector:sdir]; | 1781 IMP idir = [image methodForSelector:sdir]; |
1740 | 1782 |
1741 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2); | 1783 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2); |
1742 | 1784 |
1743 idir(image, sdir, imageFrame, NSZeroRect, NSCompositeSourceOver, 1.0, YES, nil); | 1785 idir(image, sdir, imageFrame, NSZeroRect, op, 1.0, YES, nil); |
1744 } | 1786 } |
1745 else | 1787 else |
1746 { | 1788 { |
1747 /* Old method for 10.5 */ | 1789 /* Old method for 10.5 */ |
1748 SEL sctp = NSSelectorFromString(@"compositeToPoint:operation:"); | 1790 SEL sctp = NSSelectorFromString(@"compositeToPoint:operation:"); |
1754 | 1796 |
1755 if([image respondsToSelector:sctp]) | 1797 if([image respondsToSelector:sctp]) |
1756 { | 1798 { |
1757 IMP ictp = [image methodForSelector:sctp]; | 1799 IMP ictp = [image methodForSelector:sctp]; |
1758 | 1800 |
1759 ictp(image, sctp, imageFrame.origin, NSCompositeSourceOver); | 1801 ictp(image, sctp, imageFrame.origin, op); |
1760 } | 1802 } |
1761 } | 1803 } |
1762 } | 1804 } |
1763 [super drawWithFrame:cellFrame inView:controlView]; | 1805 [super drawWithFrame:cellFrame inView:controlView]; |
1764 } | 1806 } |
2592 -(void)setParent:(id)input { parent = input; } | 2634 -(void)setParent:(id)input { parent = input; } |
2593 -(id)parent { return parent; } | 2635 -(id)parent { return parent; } |
2594 -(void)mouseDown:(NSEvent *)event | 2636 -(void)mouseDown:(NSEvent *)event |
2595 { | 2637 { |
2596 [super mouseDown:event]; | 2638 [super mouseDown:event]; |
2639 #ifdef MAC_OS_X_VERSION_10_12 | |
2640 if([[NSApp currentEvent] type] == NSEventTypeLeftMouseUp) | |
2641 #else | |
2597 if([[NSApp currentEvent] type] == NSLeftMouseUp) | 2642 if([[NSApp currentEvent] type] == NSLeftMouseUp) |
2643 #endif | |
2598 [self mouseUp:event]; | 2644 [self mouseUp:event]; |
2599 } | 2645 } |
2600 -(void)mouseUp:(NSEvent *)event | 2646 -(void)mouseUp:(NSEvent *)event |
2601 { | 2647 { |
2602 [textfield takeIntValueFrom:self]; | 2648 [textfield takeIntValueFrom:self]; |
3169 [item setTarget:DWApp]; | 3215 [item setTarget:DWApp]; |
3170 | 3216 |
3171 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) | 3217 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) |
3172 action:@selector(hideOtherApplications:) | 3218 action:@selector(hideOtherApplications:) |
3173 keyEquivalent:@"h"]; | 3219 keyEquivalent:@"h"]; |
3220 #ifdef MAC_OS_X_VERSION_10_12 | |
3221 [item setKeyEquivalentModifierMask:NSEventModifierFlagCommand | NSEventModifierFlagOption]; | |
3222 #else | |
3174 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; | 3223 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; |
3224 #endif | |
3175 [item setTarget:DWApp]; | 3225 [item setTarget:DWApp]; |
3176 | 3226 |
3177 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) | 3227 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) |
3178 action:@selector(unhideAllApplications:) | 3228 action:@selector(unhideAllApplications:) |
3179 keyEquivalent:@""]; | 3229 keyEquivalent:@""]; |
3251 } | 3301 } |
3252 | 3302 |
3253 /* Internal version that doesn't lock the run mutex */ | 3303 /* Internal version that doesn't lock the run mutex */ |
3254 int _dw_main_iteration(NSDate *date) | 3304 int _dw_main_iteration(NSDate *date) |
3255 { | 3305 { |
3306 #ifdef MAC_OS_X_VERSION_10_12 | |
3307 NSEvent *event = [DWApp nextEventMatchingMask:NSEventMaskAny | |
3308 #else | |
3256 NSEvent *event = [DWApp nextEventMatchingMask:NSAnyEventMask | 3309 NSEvent *event = [DWApp nextEventMatchingMask:NSAnyEventMask |
3310 #endif | |
3257 untilDate:date | 3311 untilDate:date |
3258 inMode:NSDefaultRunLoopMode | 3312 inMode:NSDefaultRunLoopMode |
3259 dequeue:YES]; | 3313 dequeue:YES]; |
3260 if(event) | 3314 if(event) |
3261 { | 3315 { |
3410 [alert addButtonWithTitle:button2]; | 3464 [alert addButtonWithTitle:button2]; |
3411 if(button3) | 3465 if(button3) |
3412 [alert addButtonWithTitle:button3]; | 3466 [alert addButtonWithTitle:button3]; |
3413 va_end(args); | 3467 va_end(args); |
3414 | 3468 |
3469 #ifdef MAC_OS_X_VERSION_10_12 | |
3470 if(flags & DW_MB_ERROR) | |
3471 [alert setAlertStyle:NSAlertStyleCritical]; | |
3472 else if(flags & DW_MB_INFORMATION) | |
3473 [alert setAlertStyle:NSAlertStyleInformational]; | |
3474 else | |
3475 [alert setAlertStyle:NSAlertStyleWarning]; | |
3476 #else | |
3415 if(flags & DW_MB_ERROR) | 3477 if(flags & DW_MB_ERROR) |
3416 [alert setAlertStyle:NSCriticalAlertStyle]; | 3478 [alert setAlertStyle:NSCriticalAlertStyle]; |
3417 else if(flags & DW_MB_INFORMATION) | 3479 else if(flags & DW_MB_INFORMATION) |
3418 [alert setAlertStyle:NSInformationalAlertStyle]; | 3480 [alert setAlertStyle:NSInformationalAlertStyle]; |
3419 else | 3481 else |
3420 [alert setAlertStyle:NSWarningAlertStyle]; | 3482 [alert setAlertStyle:NSWarningAlertStyle]; |
3421 | 3483 #endif |
3422 iResponse = [alert runModal]; | 3484 iResponse = [alert runModal]; |
3423 [alert release]; | 3485 [alert release]; |
3424 | 3486 |
3425 switch(iResponse) | 3487 switch(iResponse) |
3426 { | 3488 { |
4429 } | 4491 } |
4430 [button setTarget:button]; | 4492 [button setTarget:button]; |
4431 [button setAction:@selector(buttonClicked:)]; | 4493 [button setAction:@selector(buttonClicked:)]; |
4432 [button setTag:cid]; | 4494 [button setTag:cid]; |
4433 [button setButtonType:NSMomentaryPushInButton]; | 4495 [button setButtonType:NSMomentaryPushInButton]; |
4496 #ifdef MAC_OS_X_VERSION_10_12 | |
4497 [button setBezelStyle:NSBezelStyleRegularSquare]; | |
4498 #else | |
4434 [button setBezelStyle:NSThickerSquareBezelStyle]; | 4499 [button setBezelStyle:NSThickerSquareBezelStyle]; |
4500 #endif | |
4435 /* TODO: Reenable scaling in the future if it is possible on other platforms. | 4501 /* TODO: Reenable scaling in the future if it is possible on other platforms. |
4436 [[button cell] setImageScaling:NSImageScaleProportionallyDown]; */ | 4502 [[button cell] setImageScaling:NSImageScaleProportionallyDown]; */ |
4437 if(DWDefaultFont) | 4503 if(DWDefaultFont) |
4438 { | 4504 { |
4439 [[button cell] setFont:DWDefaultFont]; | 4505 [[button cell] setFont:DWDefaultFont]; |
4451 { | 4517 { |
4452 DWButton *button = _button_new(text, cid); | 4518 DWButton *button = _button_new(text, cid); |
4453 [button setButtonType:NSMomentaryPushInButton]; | 4519 [button setButtonType:NSMomentaryPushInButton]; |
4454 [button setBezelStyle:NSRoundedBezelStyle]; | 4520 [button setBezelStyle:NSRoundedBezelStyle]; |
4455 [button setImagePosition:NSNoImage]; | 4521 [button setImagePosition:NSNoImage]; |
4522 #ifdef MAC_OS_X_VERSION_10_12 | |
4523 [button setAlignment:NSTextAlignmentCenter]; | |
4524 #else | |
4456 [button setAlignment:NSCenterTextAlignment]; | 4525 [button setAlignment:NSCenterTextAlignment]; |
4526 #endif | |
4457 [[button cell] setControlTint:NSBlueControlTint]; | 4527 [[button cell] setControlTint:NSBlueControlTint]; |
4458 return button; | 4528 return button; |
4459 } | 4529 } |
4460 | 4530 |
4461 /* | 4531 /* |
6524 DWImageAndTextCell *browsercell = [[DWImageAndTextCell alloc] init]; | 6594 DWImageAndTextCell *browsercell = [[DWImageAndTextCell alloc] init]; |
6525 [column setDataCell:browsercell]; | 6595 [column setDataCell:browsercell]; |
6526 [browsercell release]; | 6596 [browsercell release]; |
6527 } | 6597 } |
6528 /* Defaults to left justified so just handle right and center */ | 6598 /* Defaults to left justified so just handle right and center */ |
6599 #ifdef MAC_OS_X_VERSION_10_12 | |
6600 if(flags[z] & DW_CFA_RIGHT) | |
6601 { | |
6602 [(NSCell *)[column dataCell] setAlignment:NSTextAlignmentRight]; | |
6603 [(NSCell *)[column headerCell] setAlignment:NSTextAlignmentRight]; | |
6604 } | |
6605 else if(flags[z] & DW_CFA_CENTER) | |
6606 { | |
6607 [(NSCell *)[column dataCell] setAlignment:NSTextAlignmentCenter]; | |
6608 [(NSCell *)[column headerCell] setAlignment:NSTextAlignmentCenter]; | |
6609 } | |
6610 #else | |
6529 if(flags[z] & DW_CFA_RIGHT) | 6611 if(flags[z] & DW_CFA_RIGHT) |
6530 { | 6612 { |
6531 [(NSCell *)[column dataCell] setAlignment:NSRightTextAlignment]; | 6613 [(NSCell *)[column dataCell] setAlignment:NSRightTextAlignment]; |
6532 [(NSCell *)[column headerCell] setAlignment:NSRightTextAlignment]; | 6614 [(NSCell *)[column headerCell] setAlignment:NSRightTextAlignment]; |
6533 } | 6615 } |
6534 else if(flags[z] & DW_CFA_CENTER) | 6616 else if(flags[z] & DW_CFA_CENTER) |
6535 { | 6617 { |
6536 [(NSCell *)[column dataCell] setAlignment:NSCenterTextAlignment]; | 6618 [(NSCell *)[column dataCell] setAlignment:NSCenterTextAlignment]; |
6537 [(NSCell *)[column headerCell] setAlignment:NSCenterTextAlignment]; | 6619 [(NSCell *)[column headerCell] setAlignment:NSCenterTextAlignment]; |
6538 } | 6620 } |
6621 #endif | |
6539 [column setEditable:NO]; | 6622 [column setEditable:NO]; |
6540 [cont addTableColumn:column]; | 6623 [cont addTableColumn:column]; |
6541 [cont addColumn:column andType:(int)flags[z]]; | 6624 [cont addColumn:column andType:(int)flags[z]]; |
6542 [column release]; | 6625 [column release]; |
6543 } | 6626 } |
7262 if(bubbletext) | 7345 if(bubbletext) |
7263 [item setToolTip:[NSString stringWithUTF8String:bubbletext]]; | 7346 [item setToolTip:[NSString stringWithUTF8String:bubbletext]]; |
7264 [item setTarget:handle]; | 7347 [item setTarget:handle]; |
7265 [item setEnabled:YES]; | 7348 [item setEnabled:YES]; |
7266 [item setHighlightMode:YES]; | 7349 [item setHighlightMode:YES]; |
7350 #ifdef MAC_OS_X_VERSION_10_12 | |
7351 [item sendActionOn:(NSEventMaskLeftMouseUp|NSEventMaskLeftMouseDown|NSEventMaskRightMouseUp|NSEventMaskRightMouseDown)]; | |
7352 #else | |
7267 [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)]; | 7353 [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)]; |
7354 #endif | |
7268 [item setAction:@selector(mouseDown:)]; | 7355 [item setAction:@selector(mouseDown:)]; |
7269 dw_window_set_data(handle, "_dw_taskbar", item); | 7356 dw_window_set_data(handle, "_dw_taskbar", item); |
7270 } | 7357 } |
7271 | 7358 |
7272 /* | 7359 /* |
7567 } | 7654 } |
7568 | 7655 |
7569 /* Function takes an NSImage and copies it into a flipped NSBitmapImageRep */ | 7656 /* Function takes an NSImage and copies it into a flipped NSBitmapImageRep */ |
7570 void _flip_image(NSImage *tmpimage, NSBitmapImageRep *image, NSSize size) | 7657 void _flip_image(NSImage *tmpimage, NSBitmapImageRep *image, NSSize size) |
7571 { | 7658 { |
7659 #ifdef MAC_OS_X_VERSION_10_12 | |
7660 NSCompositingOperation op =NSCompositingOperationSourceOver; | |
7661 #else | |
7662 NSCompositingOperation op =NSCompositeSourceOver; | |
7663 #endif | |
7572 [NSGraphicsContext saveGraphicsState]; | 7664 [NSGraphicsContext saveGraphicsState]; |
7573 [NSGraphicsContext setCurrentContext:[NSGraphicsContext | 7665 [NSGraphicsContext setCurrentContext:[NSGraphicsContext |
7574 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] | 7666 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] |
7575 flipped:YES]]; | 7667 flipped:YES]]; |
7576 [[[NSDictionary alloc] initWithObjectsAndKeys:image, NSGraphicsContextDestinationAttributeName, nil] autorelease]; | 7668 [[[NSDictionary alloc] initWithObjectsAndKeys:image, NSGraphicsContextDestinationAttributeName, nil] autorelease]; |
7584 [t translateXBy:0.0 yBy:-size.height]; | 7676 [t translateXBy:0.0 yBy:-size.height]; |
7585 | 7677 |
7586 /* Apply the transform */ | 7678 /* Apply the transform */ |
7587 [t concat]; | 7679 [t concat]; |
7588 [tmpimage drawAtPoint:NSMakePoint(0, 0) fromRect:NSMakeRect(0, 0, size.width, size.height) | 7680 [tmpimage drawAtPoint:NSMakePoint(0, 0) fromRect:NSMakeRect(0, 0, size.width, size.height) |
7589 operation:NSCompositeSourceOver fraction:1.0]; | 7681 operation:op fraction:1.0]; |
7590 [NSGraphicsContext restoreGraphicsState]; | 7682 [NSGraphicsContext restoreGraphicsState]; |
7591 } | 7683 } |
7592 | 7684 |
7593 /* | 7685 /* |
7594 * Creates a pixmap from a file. | 7686 * Creates a pixmap from a file. |
8155 NSEvent *event = [DWApp currentEvent]; | 8247 NSEvent *event = [DWApp currentEvent]; |
8156 if(!window) | 8248 if(!window) |
8157 window = [event window]; | 8249 window = [event window]; |
8158 [thismenu autorelease]; | 8250 [thismenu autorelease]; |
8159 NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); | 8251 NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); |
8252 #ifdef MAC_OS_X_VERSION_10_12 | |
8253 NSEvent* fake = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown | |
8254 #else | |
8160 NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown | 8255 NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown |
8256 #endif | |
8161 location:_windowPointFromScreen(window, p) | 8257 location:_windowPointFromScreen(window, p) |
8162 modifierFlags:0 | 8258 modifierFlags:0 |
8163 timestamp:[event timestamp] | 8259 timestamp:[event timestamp] |
8164 windowNumber:[window windowNumber] | 8260 windowNumber:[window windowNumber] |
8165 context:[NSGraphicsContext currentContext] | 8261 context:[NSGraphicsContext currentContext] |
8646 [window setShown:YES]; | 8742 [window setShown:YES]; |
8647 } | 8743 } |
8648 [[window contentView] showWindow]; | 8744 [[window contentView] showWindow]; |
8649 [window makeKeyAndOrderFront:nil]; | 8745 [window makeKeyAndOrderFront:nil]; |
8650 | 8746 |
8747 #ifdef MAC_OS_X_VERSION_10_12 | |
8748 if(!([window styleMask] & NSWindowStyleMaskResizable)) | |
8749 #else | |
8651 if(!([window styleMask] & NSResizableWindowMask)) | 8750 if(!([window styleMask] & NSResizableWindowMask)) |
8751 #endif | |
8652 { | 8752 { |
8653 /* Fix incorrect repeat in displaying textured windows */ | 8753 /* Fix incorrect repeat in displaying textured windows */ |
8654 [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; | 8754 [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; |
8655 [window setContentBorderThickness:0.0 forEdge:NSMinYEdge]; | 8755 [window setContentBorderThickness:0.0 forEdge:NSMinYEdge]; |
8656 } | 8756 } |