Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qcocoawindowdelegate_mac.mm

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    39 **
    40 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    41 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    4239**
    4340****************************************************************************/
     
    133130    } else {
    134131        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        }
    136138    }
    137139}
     
    195197    NSWindow *window = [notification object];
    196198    QWidget *qwidget = m_windowHash->value(window);
    197     // Just here to handle the is zoomed method.
    198199    QWidgetData *widgetData = qt_qwidget_data(qwidget);
    199200    if (!(qwidget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) && [window isZoomed]) {
     
    203204        qt_sendSpontaneousEvent(qwidget, &e);
    204205    }
    205     [self checkForMove:[window frame] forWidget:qwidget];
    206206    NSRect rect = [[window contentView] frame];
    207207    const QSize newSize(rect.size.width, rect.size.height);
     
    213213}
    214214
    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);
    218223    QPoint qtPoint = flipPoint(NSMakePoint(newRect.origin.x,
    219224                                           newRect.origin.y + newRect.size.height)).toPoint();
    220225    const QRect &oldRect = qwidget->frameGeometry();
     226
    221227    if (qtPoint.x() != oldRect.x() || qtPoint.y() != oldRect.y()) {
    222228        QWidgetData *widgetData = qt_qwidget_data(qwidget);
     
    234240}
    235241
    236 - (void)windowDidMove:(NSNotification *)notification
    237 {
    238     [self windowDidResize:notification];
    239 }
    240 
    241242-(BOOL)windowShouldClose:(id)windowThatWantsToClose
    242243{
     
    307308}
    308309
     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
    309322- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame
    310323{
     
    312325    QWidget *qwidget = m_windowHash->value(window);
    313326    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));
    316334    return frameToReturn;
    317335}
     
    346364}
    347365
     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}
    348389@end
    349390#endif// QT_MAC_USE_COCOA
Note: See TracChangeset for help on using the changeset viewer.