Changeset 561 for trunk/src/gui/kernel/qcocoawindowdelegate_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/qcocoawindowdelegate_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 ****************************************************************************/ … … 133 130 } else { 134 131 QResizeEvent qre(newSize, oldSize); 135 qt_sendSpontaneousEvent(qwidget, &qre); 132 if (qwidget->testAttribute(Qt::WA_PendingResizeEvent)) { 133 qwidget->setAttribute(Qt::WA_PendingResizeEvent, false); 134 QApplication::sendEvent(qwidget, &qre); 135 } else { 136 qt_sendSpontaneousEvent(qwidget, &qre); 137 } 136 138 } 137 139 } … … 195 197 NSWindow *window = [notification object]; 196 198 QWidget *qwidget = m_windowHash->value(window); 197 // Just here to handle the is zoomed method.198 199 QWidgetData *widgetData = qt_qwidget_data(qwidget); 199 200 if (!(qwidget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) && [window isZoomed]) { … … 203 204 qt_sendSpontaneousEvent(qwidget, &e); 204 205 } 205 [self checkForMove:[window frame] forWidget:qwidget];206 206 NSRect rect = [[window contentView] frame]; 207 207 const QSize newSize(rect.size.width, rect.size.height); … … 213 213 } 214 214 215 - (void)checkForMove:(const NSRect &)newRect forWidget:(QWidget *)qwidget 216 { 217 // newRect's origin is bottom left. 215 - (void)windowDidMove:(NSNotification *)notification 216 { 217 // The code underneath needs to translate the window location 218 // from bottom left (which is the origin used by Cocoa) to 219 // upper left (which is the origin used by Qt): 220 NSWindow *window = [notification object]; 221 NSRect newRect = [window frame]; 222 QWidget *qwidget = m_windowHash->value(window); 218 223 QPoint qtPoint = flipPoint(NSMakePoint(newRect.origin.x, 219 224 newRect.origin.y + newRect.size.height)).toPoint(); 220 225 const QRect &oldRect = qwidget->frameGeometry(); 226 221 227 if (qtPoint.x() != oldRect.x() || qtPoint.y() != oldRect.y()) { 222 228 QWidgetData *widgetData = qt_qwidget_data(qwidget); … … 234 240 } 235 241 236 - (void)windowDidMove:(NSNotification *)notification237 {238 [self windowDidResize:notification];239 }240 241 242 -(BOOL)windowShouldClose:(id)windowThatWantsToClose 242 243 { … … 307 308 } 308 309 310 - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame 311 { 312 Q_UNUSED(newFrame); 313 // saving the current window geometry before the window is maximized 314 QWidget *qwidget = m_windowHash->value(window); 315 if (qwidget->isWindow() && !(qwidget->windowState() & Qt::WindowMaximized)) { 316 QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); 317 widgetPrivate->topData()->normalGeometry = qwidget->geometry(); 318 } 319 return YES; 320 } 321 309 322 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame 310 323 { … … 312 325 QWidget *qwidget = m_windowHash->value(window); 313 326 QSizeF size = qwidget->maximumSize(); 314 frameToReturn.size.width = qMin<CGFloat>(frameToReturn.size.width, size.width()); 315 frameToReturn.size.height = qMin<CGFloat>(frameToReturn.size.height, size.height()); 327 NSRect windowFrameRect = [window frame]; 328 NSRect viewFrameRect = [[window contentView] frame]; 329 // consider additional size required for titlebar & frame 330 frameToReturn.size.width = qMin<CGFloat>(frameToReturn.size.width, 331 size.width()+(windowFrameRect.size.width - viewFrameRect.size.width)); 332 frameToReturn.size.height = qMin<CGFloat>(frameToReturn.size.height, 333 size.height()+(windowFrameRect.size.height - viewFrameRect.size.height)); 316 334 return frameToReturn; 317 335 } … … 346 364 } 347 365 366 - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu 367 { 368 Q_UNUSED(menu); 369 QWidget *qwidget = m_windowHash->value(window); 370 if (qwidget && !qwidget->windowFilePath().isEmpty()) { 371 return YES; 372 } 373 return NO; 374 } 375 376 - (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event 377 from:(NSPoint)dragImageLocation 378 withPasteboard:(NSPasteboard *)pasteboard 379 { 380 Q_UNUSED(event); 381 Q_UNUSED(dragImageLocation); 382 Q_UNUSED(pasteboard); 383 QWidget *qwidget = m_windowHash->value(window); 384 if (qwidget && !qwidget->windowFilePath().isEmpty()) { 385 return YES; 386 } 387 return NO; 388 } 348 389 @end 349 390 #endif// QT_MAC_USE_COCOA
Note:
See TracChangeset
for help on using the changeset viewer.