Changeset 846 for trunk/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
- Timestamp:
- May 5, 2011, 5:36:53 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/gui/kernel/qcocoasharedwindowmethods_mac_p.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 58 58 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm 59 59 extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp 60 61 62 63 64 65 60 66 QT_END_NAMESPACE 61 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 62 87 - (BOOL)canBecomeKeyWindow 63 88 { 64 89 QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; 90 91 65 92 66 93 bool isToolTip = (widget->windowType() == Qt::ToolTip); … … 69 96 } 70 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 71 121 - (void)toggleToolbarShown:(id)sender 72 122 { … … 75 125 } 76 126 77 /*78 The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever79 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 a81 last resort (i.e., this is code that can potentially be removed).82 */83 - (void)keyDown:(NSEvent *)theEvent84 {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 *)theEvent91 {92 bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);93 if (!keyOK)94 [super keyUp:theEvent];95 }96 97 127 - (void)flagsChanged:(NSEvent *)theEvent 98 128 { … … 107 137 } 108 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 109 156 - (void)sendEvent:(NSEvent *)event 110 157 { 158 159 160 161 162 163 164 165 166 167 168 111 169 QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; 112 113 170 // Cocoa can hold onto the window after we've disavowed its knowledge. So, 114 171 // if we get sent an event afterwards just have it go through the super's … … 126 183 // sometimes need to redirect mouse events to the popup. 127 184 QWidget *popup = qAppInstance()->activePopupWidget(); 128 if (popup ) {185 if (popup) { 129 186 switch([event type]) 130 187 { … … 134 191 handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton); 135 192 // 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. 137 194 // (this is standard Qt behavior.) 138 195 break; … … 173 230 } 174 231 232 233 234 235 236 237 238 239 240 241 242 243 244 175 245 - (BOOL)makeFirstResponder:(NSResponder *)responder 176 246 { … … 189 259 } 190 260 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 191 370 - (void)displayIfNeeded 192 371 { … … 205 384 } 206 385 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. 389 static 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.
