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/qcocoawindow_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****************************************************************************/
     
    5451
    5552QT_FORWARD_DECLARE_CLASS(QWidget);
    56 QT_BEGIN_NAMESPACE
    57 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
    58 QT_END_NAMESPACE
    5953QT_USE_NAMESPACE
    6054
     
    8377@implementation QT_MANGLE_NAMESPACE(QCocoaWindow)
    8478
    85 - (BOOL)canBecomeKeyWindow
    86 {
    87     return YES;
    88 }
    89 
    9079/***********************************************************************
    91   BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
     80  Copy and Paste between QCocoaWindow and QCocoaPanel
    9281  This is a bit unfortunate, but thanks to the dynamic dispatch we
    9382  have to duplicate this code or resort to really silly forwarding methods
    9483**************************************************************************/
    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"
    20385
    20486@end
    205 
    20687#endif
Note: See TracChangeset for help on using the changeset viewer.