Changeset 561 for trunk/src/gui/kernel/qcocoawindow_mac.mm
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qcocoawindow_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 **40 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE41 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.42 39 ** 43 40 ****************************************************************************/ … … 54 51 55 52 QT_FORWARD_DECLARE_CLASS(QWidget); 56 QT_BEGIN_NAMESPACE57 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm58 QT_END_NAMESPACE59 53 QT_USE_NAMESPACE 60 54 … … 83 77 @implementation QT_MANGLE_NAMESPACE(QCocoaWindow) 84 78 85 - (BOOL)canBecomeKeyWindow86 {87 return YES;88 }89 90 79 /*********************************************************************** 91 BEGINCopy and Paste between QCocoaWindow and QCocoaPanel80 Copy and Paste between QCocoaWindow and QCocoaPanel 92 81 This is a bit unfortunate, but thanks to the dynamic dispatch we 93 82 have to duplicate this code or resort to really silly forwarding methods 94 83 **************************************************************************/ 95 96 /* 97 The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever 98 get hit. We automatically say we can be first responder if we are a window. 99 So, the handling should get handled by the view. This is here more as a 100 last resort (i.e., this is code that can potentially be removed). 101 */ 102 103 - (void)keyDown:(NSEvent *)theEvent 104 { 105 bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]); 106 if (!keyOK) 107 [super keyDown:theEvent]; 108 } 109 110 - (void)keyUp:(NSEvent *)theEvent 111 { 112 bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]); 113 if (!keyOK) 114 [super keyUp:theEvent]; 115 } 116 117 - (void)flagsChanged:(NSEvent *)theEvent 118 { 119 qt_dispatchModifiersChanged(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]); 120 [super flagsChanged:theEvent]; 121 } 122 123 124 - (void)tabletProximity:(NSEvent *)tabletEvent 125 { 126 qt_dispatchTabletProximityEvent(tabletEvent); 127 } 128 129 - (void)sendEvent:(NSEvent *)event 130 { 131 [self retain]; 132 133 QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; 134 QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget)); 135 Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]); 136 137 // sometimes need to redirect mouse events to the popup. 138 QWidget *popup = qAppInstance()->activePopupWidget(); 139 if (popup && popup != widget) { 140 switch([event type]) 141 { 142 case NSLeftMouseDown: 143 qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton); 144 // Don't call super here. This prevents us from getting the mouseUp event, 145 // which we need to send even if the mouseDown event was not accepted. 146 // (this is standard Qt behavior.) 147 break; 148 case NSRightMouseDown: 149 case NSOtherMouseDown: 150 if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton)) 151 [super sendEvent:event]; 152 break; 153 case NSLeftMouseUp: 154 case NSRightMouseUp: 155 case NSOtherMouseUp: 156 if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonRelease, mouseButton)) 157 [super sendEvent:event]; 158 break; 159 case NSMouseMoved: 160 qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, Qt::NoButton); 161 break; 162 case NSLeftMouseDragged: 163 case NSRightMouseDragged: 164 case NSOtherMouseDragged: 165 [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->view = view; 166 [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->theEvent = event; 167 if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, mouseButton)) 168 [super sendEvent:event]; 169 break; 170 default: 171 [super sendEvent:event]; 172 break; 173 } 174 } else { 175 [super sendEvent:event]; 176 } 177 qt_mac_dispatchNCMouseMessage(self, event, [self QT_MANGLE_NAMESPACE(qt_qwidget)], leftButtonIsRightButton); 178 179 180 [self release]; 181 } 182 183 184 - (BOOL)makeFirstResponder:(NSResponder *)responder 185 { 186 // For some reason Cocoa wants to flip the first responder 187 // when Qt doesn't want to, sorry, but "No" :-) 188 if (responder == nil && qApp->focusWidget()) 189 return NO; 190 return [super makeFirstResponder:responder]; 191 } 192 193 /*********************************************************************** 194 END Copy and Paste between QCocoaWindow and QCocoaPanel 195 ***********************************************************************/ 196 197 + (Class)frameViewClassForStyleMask:(NSUInteger)styleMask 198 { 199 if (styleMask & QtMacCustomizeWindow) 200 return [QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame) class]; 201 return [super frameViewClassForStyleMask:styleMask]; 202 } 84 #include "qcocoasharedwindowmethods_mac_p.h" 203 85 204 86 @end 205 206 87 #endif
Note:
See TracChangeset
for help on using the changeset viewer.