76 #include <private/qcore_mac_p.h> 83 #include <private/qevent_p.h> 84 #include <private/qt_cocoa_helpers_mac_p.h> 85 #include <private/qt_mac_p.h> 86 #include <private/qapplication_p.h> 87 #include <private/qcocoaapplication_mac_p.h> 88 #include <private/qcocoawindow_mac_p.h> 89 #include <private/qcocoaview_mac_p.h> 90 #include <private/qkeymapper_p.h> 91 #include <private/qwidget_p.h> 92 #include <private/qcocoawindow_mac_p.h> 96 #ifdef QT_MAC_USE_COCOA 99 static bool qt_leftButtonIsRightButton =
false;
111 return macwindowFader();
122 const int widgetCount = myWidgetsToFade.
count();
125 [NSAnimationContext beginGrouping];
126 [[NSAnimationContext currentContext] setDuration:NSTimeInterval(
m_duration)];
129 for (
int i = 0; i < widgetCount; ++i) {
133 [[window animator] setAlphaValue:0.0];
136 TransitionWindowOptions options = {0,
m_duration, 0, 0};
137 TransitionWindowWithOptions(window, kWindowFadeTransitionEffect, kWindowHideTransitionAction,
142 [NSAnimationContext endGrouping];
157 #ifdef QT_MAC_USE_COCOA 170 if (GetWindowProperty(static_cast<WindowRef>(window), kWidgetCreatorQt,
kWidgetPropertyQWidget,
sizeof(widget), 0, &widget) != noErr)
187 #if defined(QT_MAC_USE_COCOA) && defined(__OBJC__) 200 for (
int i=0; dnd_enums[i].
qt_code; i++) {
201 if (dnd_enums[i].Qt2Mac && (action & dnd_enums[i].qt_code)) {
205 return NSDragOperationNone;
208 NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions)
210 NSDragOperation nsActions = NSDragOperationNone;
211 for (
int i=0; dnd_enums[i].
qt_code; i++) {
212 if (dnd_enums[i].Qt2Mac && (actions & dnd_enums[i].qt_code))
218 Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions)
221 for (
int i=0; dnd_enums[i].
mac_code; i++) {
222 if (nsActions & dnd_enums[i].mac_code)
228 Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions)
231 for (
int i=0; dnd_enums[i].
mac_code; i++) {
232 if (nsActions & dnd_enums[i].mac_code)
233 actions |= dnd_enums[i].
qt_code;
239 DnDParams *macCurrentDnDParameters()
241 return currentDnDParameters();
249 return ( [wnd styleMask] & NSTexturedBackgroundWindowMask ) ? true :
false;
251 WindowAttributes currentAttributes;
252 GetWindowAttributes(wnd, ¤tAttributes);
253 return (currentAttributes & kWindowMetalAttribute) ? true :
false;
263 if (show != [toolbar isVisible]) {
264 [toolbar setVisible:show];
272 ShowHideWindowToolbar(wnd, show,
false);
281 [wnd setToolbar:
static_cast<NSToolbar *
>(toolbarRef)];
283 SetWindowToolbar(wnd, static_cast<HIToolbarRef>(toolbarRef));
292 return [toolbar isVisible];
295 return IsWindowToolbarVisible(wnd);
303 [wnd setHasShadow:BOOL(hasShadow)];
306 ChangeWindowAttributes(wnd, 0, kWindowNoShadowAttribute);
308 ChangeWindowAttributes(wnd, kWindowNoShadowAttribute, 0);
316 [wnd flushWindowIfNeeded];
326 NSImage *newImage = 0;
327 NSRect imageRect = NSMakeRect(0.0, 0.0, CGImageGetWidth(image), CGImageGetHeight(image));
328 newImage = [[NSImage alloc] initWithSize:imageRect.size];
329 [newImage lockFocus];
332 CGContextDrawImage(imageContext, *(
CGRect*)&imageRect, image);
334 [newImage unlockFocus];
342 #ifdef QT_MAC_USE_COCOA 354 require_action(inContext != NULL, InvalidContext, err = paramErr);
355 require_action(inBounds != NULL, InvalidBounds, err = paramErr);
356 require_action(inImage != NULL, InvalidImage, err = paramErr);
358 CGContextSaveGState( inContext );
359 CGContextTranslateCTM (inContext, 0, inBounds->origin.y + CGRectGetMaxY(*inBounds));
360 CGContextScaleCTM(inContext, 1, -1);
362 CGContextDrawImage(inContext, *inBounds, inImage);
364 CGContextRestoreGState(inContext);
373 #ifndef QT_MAC_USE_COCOA 375 HIViewFindByID(HIViewGetRoot(HIViewGetWindow(
HIViewRef(widget->
winId()))), kHIViewWindowGrowBoxID, &nativeSizeGrip);
376 return (nativeSizeGrip != 0);
385 #if defined(DEBUG_MOUSE_MAPS) 386 # define QT_MAC_MAP_ENUM(x) x, #x 389 # define QT_MAC_MAP_ENUM(x) x 404 #ifdef DEBUG_MOUSE_MAPS 405 qDebug(
"Qt: internal: **Mapping buttons: %d (0x%04x)", buttons, buttons);
408 for(
int i = 0; qt_mac_mouse_symbols[i].
qt_code; i++) {
409 if (buttons & (0x01<<(qt_mac_mouse_symbols[i].mac_code-1))) {
410 #ifdef DEBUG_MOUSE_MAPS 411 qDebug(
"Qt: internal: got button: %s", qt_mac_mouse_symbols[i].desc);
413 ret |= Qt::MouseButtons(qt_mac_mouse_symbols[i].qt_code);
420 #ifdef DEBUG_MOUSE_MAPS 421 qDebug(
"Qt: internal: **Mapping button: %d (0x%04x)", button, button);
423 Qt::MouseButtons ret = 0;
424 for(
int i = 0; qt_mac_mouse_symbols[i].
qt_code; i++) {
425 if (button == qt_mac_mouse_symbols[i].mac_code) {
426 #ifdef DEBUG_MOUSE_MAPS 427 qDebug(
"Qt: internal: got button: %s", qt_mac_mouse_symbols[i].desc);
444 return tablet_hash();
447 #ifdef QT_MAC_USE_COCOA 453 if (cocoaView && [cocoaView respondsToSelector:
@selector(qt_qwidget)]) {
454 [cocoaView qt_clearQWidget];
460 NSEvent *proximityEvent =
static_cast<NSEvent *
>(tabletEvent);
462 TabletProximityRec carbonProximityRec = { [proximityEvent vendorID],
463 [proximityEvent tabletID],
464 [proximityEvent pointingDeviceID],
465 [proximityEvent deviceID],
466 [proximityEvent systemTabletID],
467 [proximityEvent vendorPointingDeviceType],
468 [proximityEvent pointingDeviceSerialNumber],
469 [proximityEvent uniqueID],
470 [proximityEvent capabilityMask],
471 [proximityEvent pointingDeviceType],
472 [proximityEvent isEnteringProximity] };
475 #endif // QT_MAC_USE_COCOA 480 proximityDevice.tabletUniqueID = proxRec.uniqueID;
481 proximityDevice.capabilityMask = proxRec.capabilityMask;
483 switch (proxRec.pointerType) {
484 case NSUnknownPointingDevice:
488 case NSPenPointingDevice:
491 case NSCursorPointingDevice:
494 case NSEraserPointingDevice:
498 uint bits = proxRec.vendorPointerType;
499 if (bits == 0 && proximityDevice.tabletUniqueID != 0) {
503 bits = proximityDevice.tabletUniqueID >> 32;
507 if (((bits & 0x0006) == 0x0002) && ((bits & 0x0F06) != 0x0902)) {
510 switch (bits & 0x0F06) {
532 bool entering = proxRec.enterProximity;
542 proximityDevice.tabletPointerType, 0., 0, 0, 0., 0., 0, 0,
543 proximityDevice.tabletUniqueID);
573 return key < entry.
qtKey;
592 { NSCarriageReturnCharacter, Qt::Key_Return },
599 { NSDeleteCharacter, Qt::Key_Backspace },
659 static bool mustInit =
true;
663 rev_entries[i] = entries[i];
668 if (i == rev_entries.
end())
673 #ifdef QT_MAC_USE_COCOA 685 if (modifierFlags & NSShiftKeyMask)
687 if (modifierFlags & NSControlKeyMask)
689 if (modifierFlags & NSAlternateKeyMask)
691 if (modifierFlags & NSCommandKeyMask)
693 if (modifierFlags & NSNumericPadKeyMask)
698 NSString *qt_mac_removePrivateUnicode(NSString*
string)
700 int len = [
string length];
703 bool changed =
false;
704 for (
int i = 0; i<len; i++) {
705 characters[i] = [
string characterAtIndex:i];
708 if (characters[i] == NSDeleteFunctionKey) {
709 characters[i] = NSDeleteCharacter;
714 return [NSString stringWithCharacters:characters.
data() length:len];
722 if (dragOperations & NSDragOperationLink)
724 if (dragOperations & NSDragOperationGeneric)
726 if (dragOperations & NSDragOperationCopy)
731 static inline QEvent::Type cocoaEvent2QtEvent(NSUInteger eventType)
739 case NSLeftMouseDown:
740 case NSRightMouseDown:
741 case NSOtherMouseDown:
748 case NSLeftMouseDragged:
749 case NSRightMouseDragged:
750 case NSOtherMouseDragged:
758 static bool mustUseCocoaKeyEvent()
761 return TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData) == 0;
764 bool qt_dispatchKeyEventWithCocoa(
void *
keyEvent,
QWidget *widgetToGetEvent)
766 NSEvent *
event =
static_cast<NSEvent *
>(
keyEvent);
767 NSString *keyChars = [
event charactersIgnoringModifiers];
768 int keyLength = [keyChars length];
771 bool ignoreText =
false;
773 if (keyLength == 1) {
774 QChar ch([keyChars characterAtIndex:0]);
777 qtKey = cocoaKey2QtKey(ch);
790 UInt32 macScanCode = 1;
791 QKeyEventEx ke(cocoaEvent2QtEvent([event
type]), qtKey, keyMods, text, [event isARepeat],
qMax(1, keyLength),
792 macScanCode, [event keyCode], [event modifierFlags]);
814 #ifndef QT_MAC_USE_COCOA 819 NSEvent *
event =
static_cast<NSEvent *
>(
keyEvent);
820 EventRef key_event =
static_cast<EventRef>(
const_cast<void *
>([
event eventRef]));
822 unsigned int info = 0;
824 if ([event
type] == NSKeyDown) {
825 NSString *characters = [
event characters];
826 if ([characters length]) {
827 unichar value = [characters characterAtIndex:0];
836 if (mustUseCocoaKeyEvent())
837 return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent);
840 return consumed && (info != 0);
846 #ifndef QT_MAC_USE_COCOA 850 UInt32 modifiers = 0;
852 NSEvent *
event =
static_cast<NSEvent *
>(flagsChangedEvent);
853 EventRef key_event =
static_cast<EventRef>(
const_cast<void *
>([
event eventRef]));
855 GetEventParameter(key_event, kEventParamKeyModifiers, typeUInt32, 0,
856 sizeof(modifiers), 0, &modifiers);
877 #if QT_MAC_USE_COCOA && __OBJC__ 879 void qt_mac_handleNonClientAreaMouseEvent(NSWindow *
window, NSEvent *event)
882 if (widgetToGetEvent == 0)
885 NSEventType evtType = [
event type];
888 bool processThisEvent =
false;
889 bool fakeNCEvents =
false;
890 bool fakeMouseEvents =
false;
893 if (evtType == NSLeftMouseDown || evtType == NSLeftMouseUp
894 || evtType == NSRightMouseDown || evtType == NSRightMouseUp
895 || evtType == NSOtherMouseDown || evtType == NSOtherMouseUp
896 || evtType == NSMouseMoved || evtType == NSLeftMouseDragged
897 || evtType == NSRightMouseDragged || evtType == NSOtherMouseDragged) {
899 if (mac_mouse_grabber && mac_mouse_grabber != widgetToGetEvent) {
900 NSWindow *grabWindow =
static_cast<NSWindow *
>(
qt_mac_window_for(mac_mouse_grabber));
901 if (
window != grabWindow) {
908 if(evtType != NSLeftMouseDragged || fakeNCEvents) {
909 NSPoint windowPoint = [
event locationInWindow];
910 NSPoint globalPoint = [[
event window] convertBaseToScreen:windowPoint];
911 NSRect frameRect = [
window frame];
912 if (fakeNCEvents || NSMouseInRect(globalPoint, frameRect, NO)) {
913 NSRect contentRect = [
window contentRectForFrameRect:frameRect];
918 if (fakeNCEvents || (!NSMouseInRect(globalPoint, contentRect, NO) && !w)) {
921 processThisEvent =
true;
927 if (!processThisEvent)
932 if (mac_mouse_grabber || qt_button_down ||
934 fakeMouseEvents =
true;
940 case NSLeftMouseDown:
950 case NSRightMouseDown:
960 case NSOtherMouseDown:
975 case NSLeftMouseDragged:
980 case NSRightMouseDragged:
985 case NSOtherMouseDragged:
991 qWarning(
"not handled! Non client area mouse message");
997 NSInteger clickCount = [
event clickCount];
998 if (clickCount % 2 == 0)
1003 qt_leftButtonIsRightButton =
true;
1008 qt_leftButtonIsRightButton =
false;
1015 if (GetEventParameter((
EventRef)[event eventRef], kEventParamMouseChord, typeUInt32, 0,
1016 sizeof(mac_buttons), 0, &mac_buttons) == noErr)
1020 QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods);
1030 QWidget *qt_mac_getTargetForKeyEvent(
QWidget *widgetThatReceivedEvent)
1034 return focusInPopup ? focusInPopup : popup;
1038 if (!widgetToGetKey)
1039 widgetToGetKey = widgetThatReceivedEvent;
1041 return widgetToGetKey;
1053 QPoint &returnLocalPoint,
1054 QPoint &returnGlobalPoint,
1056 QWidget **returnWidgetUnderMouse)
1059 NSPoint nsglobalpoint =
event ? [[
event window] convertBaseToScreen:[
event locationInWindow]] : [NSEvent mouseLocation];
1062 returnGlobalPoint =
QPoint(globalPointF.
x(), globalPointF.
y());
1068 QWidget *widgetUnderMouse = 0;
1069 if (popup || qt_button_down || !nativeWidget || !nativeWidget->
isVisible()) {
1078 if (!widgetUnderMouse && nativeWidget) {
1082 widgetUnderMouse = nativeWidget->
childAt(p);
1083 if (!widgetUnderMouse && nativeWidget->
rect().
contains(p))
1084 widgetUnderMouse = nativeWidget;
1087 if (widgetUnderMouse) {
1090 if (widgetUnderMouse == qt_button_down) {
1092 if (buttonDownNotBlockedByModal ==
false)
1093 widgetUnderMouse = 0;
1095 widgetUnderMouse = 0;
1098 if (widgetUnderMouse && widgetUnderMouse->
isWindow()) {
1102 widgetUnderMouse = 0;
1105 if (returnWidgetUnderMouse)
1106 *returnWidgetUnderMouse = widgetUnderMouse;
1110 if (popup && !mouseGrabber) {
1121 }
else if (popup == candidate) {
1127 returnLocalPoint = candidate->
mapFromGlobal(returnGlobalPoint);
1132 QWidget *target = mouseGrabber;
1133 if (!target && buttonDownNotBlockedByModal)
1136 target = widgetUnderMouse;
1140 returnLocalPoint = target->
mapFromGlobal(returnGlobalPoint);
1146 static inline void qt_mac_checkEnterLeaveForNativeWidgets(
QWidget *maybeEnterWidget)
1157 if ((maybeEnterWidget == qt_last_native_mouse_receiver) && qt_last_native_mouse_receiver)
1159 if (maybeEnterWidget) {
1160 if (!qt_last_native_mouse_receiver) {
1170 if (qt_last_native_mouse_receiver) {
1173 qt_last_mouse_receiver = 0;
1174 qt_last_native_mouse_receiver = 0;
1182 NSInputManager *currentIManager = [NSInputManager currentInputManager];
1183 if (currentIManager && [currentIManager wantsToHandleMouseEvents]) {
1184 [currentIManager handleMouseEvent:
event];
1189 QWidget *widgetUnderMouse = 0;
1190 QPoint localPoint, globalPoint;
1192 if (!widgetToGetMouse)
1199 if (widgetUnderMouse)
1211 EventRef carbonEvent =
static_cast<EventRef>(
const_cast<void *
>([
event eventRef]));
1220 NSInteger clickCount = [
event clickCount];
1224 if (GetEventParameter(carbonEvent, kEventParamMouseChord, typeUInt32, 0,
1225 sizeof(mac_buttons), 0, &mac_buttons) == noErr)
1227 if (fakeEvent && buttons == 0)
1232 qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse);
1234 switch (eventType) {
1236 qWarning(
"not handled! %d", eventType);
1243 qt_button_down = widgetUnderMouse;
1244 if (clickCount % 2 == 0 && (previousButton ==
Qt::NoButton || previousButton == button))
1248 qt_leftButtonIsRightButton =
true;
1254 qt_leftButtonIsRightButton =
false;
1262 DnDParams *dndParams = currentDnDParameters();
1263 dndParams->view = view;
1264 dndParams->theEvent =
event;
1265 dndParams->globalPoint = globalPoint;
1268 QMouseEvent qme(eventType, localPoint, globalPoint, button, buttons, keyMods);
1270 widgetToGetMouse, &qme, widgetUnderMouse, nativeWidget,
1271 &qt_button_down, qt_last_mouse_receiver,
true);
1284 qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse);
1287 previousButton = button;
1294 #ifndef QT_MAC_USE_COCOA 1300 NSView *theNSView =
static_cast<NSView *
>(view);
1301 NSEvent *theTabletEvent =
static_cast<NSEvent *
>(tabletEvent);
1303 NSEventType eventType = [theTabletEvent
type];
1304 if (eventType != NSTabletPoint && [theTabletEvent subtype] != NSTabletPointEventSubtype)
1307 NSPoint windowPoint = [theTabletEvent locationInWindow];
1308 NSPoint globalPoint = [[theTabletEvent
window] convertBaseToScreen:windowPoint];
1310 QWidget *qwidget = [theView qt_qwidget];
1311 QWidget *widgetToGetMouse = qwidget;
1313 if (popup && popup != qwidget->
window())
1314 widgetToGetMouse = popup;
1317 static_cast<EventRef>(const_cast<void *>([theTabletEvent eventRef]))))
1319 if (widgetToGetMouse != qwidget) {
1321 windowPoint = [[theNSView
window] convertScreenToBase:globalPoint];
1323 NSPoint localPoint = [theNSView convertPoint:windowPoint fromView:nil];
1330 if (!tabletHash->
contains([theTabletEvent deviceID])) {
1331 qWarning(
"QCocoaView handleTabletEvent: This tablet device is unknown" 1332 " (received no proximity event for it). Discarding event.");
1339 switch (eventType) {
1340 case NSLeftMouseDown:
1341 case NSRightMouseDown:
1345 case NSRightMouseUp:
1350 case NSLeftMouseDragged:
1351 case NSRightMouseDragged:
1358 if (eventType != NSMouseMoved) {
1359 pressure = [theTabletEvent pressure];
1364 NSPoint tilt = [theTabletEvent tilt];
1365 int xTilt =
qRound(tilt.x * 60.0);
1366 int yTilt =
qRound(tilt.y * -60.0);
1367 qreal tangentialPressure = 0;
1370 if (deviceData.capabilityMask & 0x0200)
1371 z = [theTabletEvent absoluteZ];
1373 if (deviceData.capabilityMask & 0x0800)
1374 tangentialPressure = [theTabletEvent tangentialPressure];
1376 rotation = [theTabletEvent rotation];
1380 deviceData.tabletDeviceType, deviceData.tabletPointerType,
1381 pressure, xTilt, yTilt, tangentialPressure, rotation, z,
1383 deviceData.tabletUniqueID);
1386 return qtabletEvent.isAccepted();
1393 #if !defined(QT_MAC_USE_COCOA) 1394 # if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 1396 ::HIWindowSetContentBorderThickness(theWindow, &metrics);
1403 if ([theWindow styleMask] & NSTexturedBackgroundWindowMask)
1404 [theWindow setContentBorderThickness:metrics.top forEdge:NSMaxYEdge];
1405 [theWindow setContentBorderThickness:metrics.bottom forEdge:NSMinYEdge];
1409 #if QT_MAC_USE_COCOA 1416 id theClass = [[[theWindow contentView] superview]
class];
1424 if(!widget->drawRectOriginalAdded) {
1425 Method m2 = class_getInstanceMethod(theClass,
@selector(drawRect:));
1430 class_addMethod(theClass,
@selector(drawRectOriginal:), method_getImplementation(m2), method_getTypeEncoding(m2));
1431 widget->drawRectOriginalAdded =
true;
1433 if(widget->originalDrawMethod) {
1434 Method m0 = class_getInstanceMethod([theWindow
class],
@selector(
drawRectSpecial:));
1439 Method m1 = class_getInstanceMethod(theClass,
@selector(drawRect:));
1445 method_exchangeImplementations(m1, m0);
1446 widget->originalDrawMethod =
false;
1455 id theClass = [[[theWindow contentView] superview]
class];
1458 Method m0 = class_getInstanceMethod([theWindow
class],
@selector(
drawRectSpecial:));
1463 Method m1 = class_getInstanceMethod(theClass,
@selector(drawRect:));
1468 method_exchangeImplementations(m1, m0);
1469 widget->originalDrawMethod =
true;
1472 #endif // QT_MAC_USE_COCOA 1474 #if QT_MAC_USE_COCOA 1481 NSToolbar *macToolbar = [theWindow
toolbar];
1482 [macToolbar setShowsBaselineSeparator:show];
1484 #endif // QT_MAC_USE_COCOA 1489 NSArray *array =
static_cast<NSArray *
>(nsarray);
1490 for (NSUInteger i=0; i<[array count]; ++i)
1491 result << qt_mac_NSStringToQString([array objectAtIndex:i]);
1497 NSMutableArray *result = [NSMutableArray arrayWithCapacity:list.
size()];
1498 for (
int i=0; i<list.
size(); ++i){
1504 #if QT_MAC_USE_COCOA 1507 if (!widgetForWindow)
1510 Qt::WindowFlags flags = widgetForWindow->
windowFlags();
1513 NSButton *btn = [
window standardWindowButton:NSWindowZoomButton];
1516 [btn setEnabled:go];
1518 btn = [
window standardWindowButton:NSWindowMiniaturizeButton];
1520 [btn setEnabled:go];
1522 btn = [
window standardWindowButton:NSWindowCloseButton];
1525 [btn setEnabled:go];
1529 #endif // QT_MAC_USE_COCOA 1537 #ifndef QT_MAC_USE_COCOA 1540 QDBeginCGContext(port, &context);
1551 #ifndef QT_MAC_USE_COCOA 1560 #ifndef QT_MAC_USE_COCOA 1561 return HIGetScaleFactor();
1564 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) 1565 NSScreen *mainScreen = [NSScreen mainScreen];
1566 if ([mainScreen respondsToSelector:
@selector(backingScaleFactor)])
1567 return [mainScreen backingScaleFactor];
1575 NSPasteboard *pb = nil;
1577 if (PasteboardCopyName(paste, &pbname) == noErr) {
1578 pb = [NSPasteboard pasteboardWithName:
const_cast<NSString *
>(
reinterpret_cast<const NSString *
>(pbname))];
1581 pb = [NSPasteboard generalPasteboard];
1584 NSString *
text = [pb stringForType:NSStringPboardType];
1586 return qt_mac_NSStringToQString(text);
1596 CGRect rect = CGRectMake(0, 0, width, height);
1599 CGAffineTransform old_xform = CGContextGetCTM(ctx);
1600 CGContextConcatCTM(ctx, CGAffineTransformInvert(old_xform));
1601 CGContextConcatCTM(ctx, CGAffineTransformIdentity);
1604 b.blue = b.green = b.red = 255*255;
1605 PlotIconRefInContext(ctx, &rect, kAlignNone, kTransformNone, &b, kPlotIconRefNormalFlags, icon);
1606 CGContextRelease(ctx);
1613 while (size <= 128) {
1625 int littleSize = size / 2;
1628 painter.
drawPixmap(size - littleSize, size - littleSize, overlayPix);
1636 #ifdef QT_MAC_USE_COCOA 1637 void qt_mac_menu_collapseSeparators(
void * theMenu,
bool collapse)
1642 bool previousIsSeparator =
true;
1645 NSArray *itemArray = [menu itemArray];
1646 for (
unsigned int i = 0; i < [itemArray count]; ++i) {
1648 if ([item isSeparatorItem]) {
1649 [item setHidden:previousIsSeparator];
1652 if (![item isHidden]) {
1653 previousItem = item;
1654 previousIsSeparator = ([previousItem isSeparatorItem]);
1659 if (previousItem && previousIsSeparator)
1660 [previousItem setHidden:YES];
1662 NSArray *itemArray = [menu itemArray];
1663 for (
unsigned int i = 0; i < [itemArray count]; ++i) {
1665 if (
QAction *action = reinterpret_cast<QAction *>([item tag]))
1666 [item setHidden:!action->isVisible()];
1671 class CocoaPostMessageAfterEventLoopExitHelp :
public QObject 1679 CocoaPostMessageAfterEventLoopExitHelp(
id target,
SEL selector,
int argCount,
id arg1,
id arg2)
1680 : target(target), selector(selector), argCount(argCount), arg1(arg1), arg2(arg2){
1684 ~CocoaPostMessageAfterEventLoopExitHelp()
1686 qt_cocoaPostMessage(target, selector, argCount, arg1, arg2);
1690 void qt_cocoaPostMessage(
id target,
SEL selector,
int argCount,
id arg1,
id arg2)
1694 QCocoaPostMessageArgs *args =
new QCocoaPostMessageArgs(target, selector, argCount, arg1, arg2);
1697 NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined
1698 location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0
1700 [NSApp postEvent:e atStart:NO];
1703 void qt_cocoaPostMessageAfterEventLoopExit(
id target,
SEL selector,
int argCount,
id arg1,
id arg2)
1706 qt_cocoaPostMessage(target, selector, argCount, arg1, arg2);
1708 new CocoaPostMessageAfterEventLoopExitHelp(target, selector, argCount, arg1, arg2);
1715 #ifndef QT_MAC_USE_COCOA 1716 NSApplicationLoad();
1718 pool = (
void*)[[NSAutoreleasePool alloc]
init];
1723 [(NSAutoreleasePool*)pool release];
1728 #ifdef QT_MAC_USE_COCOA 1730 qt_cocoaPostMessage([NSApp
QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)],
@selector(qtTranslateApplicationMenu));
1740 #ifdef QT_MAC_USE_COCOA 1744 void macDrawRectOnTop(
void *
window)
1747 NSView *contentView = [theWindow contentView];
1751 NSRect contentRect = [contentView frame];
1754 if([theWindow isKeyWindow] || [theWindow isMainWindow]) {
1755 [[NSColor colorWithCalibratedRed:1.0
green:1.0
blue:1.0 alpha:1.0]
set];
1757 [[NSColor colorWithCalibratedRed:1.0
green:1.0
blue:1.0 alpha:1.0]
set];
1759 NSPoint origin = NSMakePoint(0, contentRect.size.height);
1760 NSPoint end = NSMakePoint(contentRect.size.width, contentRect.size.height);
1761 [NSBezierPath strokeLineFromPoint:origin toPoint:
end];
1770 void macSyncDrawingOnFirstInvocation(
void *
window)
1773 NSApplication *application = [NSApplication sharedApplication];
1775 if([application isActive]) {
1777 [toolbar setShowsBaselineSeparator:NO];
1780 [toolbar setVisible:
false];
1781 [toolbar setShowsBaselineSeparator:NO];
1782 [toolbar setVisible:
true];
1787 void qt_cocoaStackChildWindowOnTopOfOtherChildren(
QWidget *childWidget)
1793 if (childWidget->
isWindow() && parent) {
1796 d->setSubWindowStacking(
false);
1797 d->setSubWindowStacking(
true);
1802 void qt_mac_display(
QWidget *widget)
1808 void qt_mac_setNeedsDisplay(
QWidget *widget)
1811 [theNSView setNeedsDisplay:YES];
1814 void qt_mac_setNeedsDisplayInRect(
QWidget *widget,
QRegion region)
1818 [theNSView setNeedsDisplay:YES];
1823 for (
int i = 0; i < rects.
count(); ++i) {
1824 const QRect &rect = rects.
at(i);
1825 NSRect nsrect = NSMakeRect(rect.
x(), rect.
y(), rect.
width(), rect.
height());
1826 [theNSView setNeedsDisplayInRect:nsrect];
1831 #endif // QT_MAC_USE_COCOA static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
const struct __CFString * CFStringRef
void qt_mac_post_retranslateAppMenu()
QIntegerForSizeof< void * >::Unsigned quintptr
static mach_timebase_info_data_t info
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
int remove(const Key &key)
Removes all the items that have the key from the hash.
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
Qt::MouseButton qt_mac_get_button(EventMouseButton button)
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int flipYCoordinate(int y)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
PasteboardRef OSPasteboardRef
bool operator<(const KeyPair &entry, QChar qchar)
QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height)
CGFloat qt_mac_get_scalefactor()
The QPointF class defines a point in the plane using floating point precision.
static Qt::MouseButtons buttons
void macWindowFlush(void *window)
static CFStringRef toCFStringRef(const QString &str)
static QString toQString(CFStringRef cfstr)
QString qt_mac_get_pasteboardString(OSPasteboardRef paste)
int width() const
Returns the width of the rectangle.
OSViewRef qt_mac_effectiveview_for(const QWidget *w)
struct CGImage * CGImageRef
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
static QApplicationPrivate * instance()
void * qt_mac_create_nsimage(const QPixmap &pm)
void qt_mac_update_mouseTracking(QWidget *widget)
void qt_mac_dispatchPendingUpdateRequests(QWidget *widget)
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
int count(const T &t) const
Returns the number of occurrences of value in the list.
static qt_mac_enum_mapper qt_mac_mouse_symbols[]
int height() const
Returns the height of the rectangle.
QPointF flipPoint(const NSPoint &p)
The QString class provides a Unicode character string.
QPointer< QWidget > qt_last_mouse_receiver
Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader)
The QHash class is a template class that provides a hash-table-based dictionary.
void updateKeyMap(const MSG &msg)
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
void macWindowToolbarSet(void *window, void *toolbarRef)
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
The QChar class provides a 16-bit Unicode character.
bool macWindowToolbarIsVisible(void *window)
const T value(const Key &key) const
Returns the value associated with the key.
QMacTabletHash * qt_mac_tablet_hash()
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
StandardPixmap
This enum describes the available standard pixmaps.
Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags)
static QPixmap * find(const QString &key)
bool isLower() const
Returns true if the character is a lowercase letter, i.
qreal x() const
Returns the x-coordinate of this point.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
OSWindowRef qt_mac_window_for(const QWidget *)
void macSendToolbarChangeEvent(QWidget *widget)
static const KeyPair entries[NumEntries]
static bool qtKey2CocoaKeySortLessThan(const KeyPair &entry1, const KeyPair &entry2)
Q_CORE_EXPORT void qDebug(const char *,...)
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
void qt_dispatchModifiersChanged(void *flagsChangedEvent, QWidget *widgetToGetEvent)
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QMacWindowFader * currentFader()
void macWindowSetHasShadow(void *window, bool hasShadow)
Q_GUI_EXPORT EGLDisplay display()
void qt_mac_replaceDrawRectOriginal(void *window, QWidgetPrivate *widget)
void * qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
Returns the CoreGraphics CGContextRef of the paint device.
#define QT_MAC_MAP_ENUM(x)
void setFadeDuration(float durationInSecs)
const T & at(int i) const
Returns the item at index position i in the list.
struct OpaqueControlRef * HIViewRef
The QStringList class provides a list of strings.
QWidget * mac_mouse_grabber
Q_CORE_EXPORT void qWarning(const char *,...)
bool macWindowIsTextured(void *window)
bool qt_mac_handleTabletEvent(void *view, void *tabletEvent)
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
QMacCocoaAutoReleasePool()
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
The QRegion class specifies a clip region for a painter.
bool operator==(const KeyPair &entry, QChar qchar)
void clear()
Removes all items from the list.
bool qt_dispatchKeyEvent(void *keyEvent, QWidget *widgetToGetEvent)
QWidgetList m_windowsToFade
void registerWindowToFade(QWidget *window)
void qSort(RandomAccessIterator start, RandomAccessIterator end)
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
struct OpaqueEventRef * EventRef
The QTabletEvent class contains parameters that describe a Tablet event.
const T & at(int i) const
Returns the item at index position i in the vector.
QApplication * qAppInstance()
Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations)
The QMouseEvent class contains parameters that describe a mouse event.
void qt_mac_replaceDrawRect(void *window, QWidgetPrivate *widget)
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
~QMacCocoaAutoReleasePool()
static QWidget * activePopupWidget()
Returns the active popup widget.
static const int NumEntries
Type
This enum type defines the valid event types in Qt.
static bool isBlockedByModal(QWidget *widget)
Returns true if widget is blocked by a modal window.
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
int y() const
Returns the y-coordinate of the rectangle's top edge.
void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse)
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
#define QT_MANGLE_NAMESPACE(name)
int x() const
Returns the x-coordinate of the rectangle's left edge.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
static QTestResult::TestLocation location
The QPoint class defines a point in the plane using integer precision.
bool singleShot
This static function calls a slot after a given time interval.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Qt::MouseButtons qt_mac_get_buttons(int buttons)
const UInt32 kEventClassQt
int size() const
Returns the number of items in the list.
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
void macWindowToolbarShow(const QWidget *widget, bool show)
The QRect class defines a rectangle in the plane using integer precision.
void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon)
OSViewRef qt_mac_nativeview_for(const QWidget *)
QChar qtKey2CocoaKey(Qt::Key key)
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
int y() const
Returns the y coordinate of this point.
qreal y() const
Returns the y-coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
void qt_mac_showBaseLineSeparator(void *window, bool show)
void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
QKeyMapperPrivate * qt_keymapper_private()
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
void qt_mac_send_modifiers_changed(quint32, QObject *)
int x() const
Returns the x coordinate of this point.
struct CGContext * CGContextRef
static QString qtKey(CFStringRef cfkey)
CGImageRef toMacCGImageRef() const
Creates a CGImageRef equivalent to the QPixmap.
static const KeyPair *const end
bool qt_mac_checkForNativeSizeGrip(const QWidget *widget)
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true)
The QEvent class is the base class of all event classes.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QStringList qt_mac_NSArrayToQStringList(void *nsarray)
Q_DECL_CONSTEXPR int qRound(qreal d)
The QAction class provides an abstract user interface action that can be inserted into widgets...
qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch)
void qt_mac_updateContentBorderMetricts(void *window, const ::HIContentBorderMetrics &metrics)
struct OpaqueIconRef * IconRef
The QList class is a template class that provides lists.
void macWindowFade(void *window, float durationSeconds)
The QIcon class provides scalable icons in different modes and states.