Timestamp:
May 5, 2011, 5:36:53 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    5858extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
    5959extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
     60
     61
     62
     63
     64
     65
    6066QT_END_NAMESPACE
    6167
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
    6287- (BOOL)canBecomeKeyWindow
    6388{
    6489    QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)];
     90
     91
    6592
    6693    bool isToolTip = (widget->windowType() == Qt::ToolTip);
     
    6996}
    7097
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
    71121- (void)toggleToolbarShown:(id)sender
    72122{
     
    75125}
    76126
    77 /*
    78     The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
    79     get hit. We automatically say we can be first responder if we are a window.
    80     So, the handling should get handled by the view. This is here more as a
    81     last resort (i.e., this is code that can potentially be removed).
    82  */
    83 - (void)keyDown:(NSEvent *)theEvent
    84 {
    85     bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
    86     if (!keyOK)
    87         [super keyDown:theEvent];
    88 }
    89 
    90 - (void)keyUp:(NSEvent *)theEvent
    91 {
    92     bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
    93     if (!keyOK)
    94         [super keyUp:theEvent];
    95 }
    96 
    97127- (void)flagsChanged:(NSEvent *)theEvent
    98128{
     
    107137}
    108138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
    109156- (void)sendEvent:(NSEvent *)event
    110157{
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
    111169    QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
    112 
    113170    // Cocoa can hold onto the window after we've disavowed its knowledge. So,
    114171    // if we get sent an event afterwards just have it go through the super's
     
    126183    // sometimes need to redirect mouse events to the popup.
    127184    QWidget *popup = qAppInstance()->activePopupWidget();
    128     if (popup) {
     185    if (popup) {
    129186        switch([event type])
    130187        {
     
    134191            handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
    135192            // Don't call super here. This prevents us from getting the mouseUp event,
    136             // which we need to send even if the mouseDown event was not accepted. 
     193            // which we need to send even if the mouseDown event was not accepted.
    137194            // (this is standard Qt behavior.)
    138195            break;
     
    173230}
    174231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
    175245- (BOOL)makeFirstResponder:(NSResponder *)responder
    176246{
     
    189259}
    190260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
    191370- (void)displayIfNeeded
    192371{
     
    205384}
    206385
    207 
     386// This is a hack and it should be removed once we find the real cause for
     387// the painting problems.
     388// We have a static variable that signals if we have been called before or not.
     389static bool firstDrawingInvocation = true;
     390
     391// The method below exists only as a workaround to draw/not draw the baseline
     392// in the title bar. This is to support unifiedToolbar look.
     393
     394// This method is very special. To begin with, it is a
     395// method that will get called only if we enable documentMode.
     396// Furthermore, it won't get called as a normal method, we swap
     397// this method with the normal implementation of drawRect in
     398// _NSThemeFrame. When this method is active, its mission is to
     399// first call the original drawRect implementation so the widget
     400// gets proper painting. After that, it needs to detect if there
     401// is a toolbar or not, in order to decide how to handle the unified
     402// look. The distinction is important since the presence and
     403// visibility of a toolbar change the way we enter into unified mode.
     404// When there is a toolbar and that toolbar is visible, the problem
     405// is as simple as to tell the toolbar not to draw its baseline.
     406// However when there is not toolbar or the toolbar is not visible,
     407// we need to draw a line on top of the baseline, because the baseline
     408// in that case will belong to the title. For this case we need to draw
     409// a line on top of the baseline.
     410// As usual, there is a special case. When we first are called, we might
     411// need to repaint ourselves one more time. We only need that if we
     412// didn't get the activation, i.e. when we are launched via the command
     413// line. And this only if the toolbar is visible from the beginning,
     414// so we have a special flag that signals if we need to repaint or not.
     415- (void)drawRectSpecial:(NSRect)rect
     416{
     417    // Call the original drawing method.
     418    [self drawRectOriginal:rect];
     419    NSWindow *window = [self window];
     420    NSToolbar *toolbar = [window toolbar];
     421    if(!toolbar) {
     422        // There is no toolbar, we have to draw a line on top of the line drawn by Cocoa.
     423        macDrawRectOnTop((void *)window);
     424    } else {
     425        if([toolbar isVisible]) {
     426            // We tell Cocoa to avoid drawing the line at the end.
     427            if(firstDrawingInvocation) {
     428                firstDrawingInvocation = false;
     429                macSyncDrawingOnFirstInvocation((void *)window);
     430            } else
     431                [toolbar setShowsBaselineSeparator:NO];
     432        } else {
     433            // There is a toolbar but it is not visible so
     434            // we have to draw a line on top of the line drawn by Cocoa.
     435            macDrawRectOnTop((void *)window);
     436        }
     437    }
     438}
Note: See TracChangeset for help on using the changeset viewer.