| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2010, 2011, 2012 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2010, 2011, 2012 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool pressed = states & PressedControlState; | 122 bool pressed = states & PressedControlState; |
| 123 if (pressed != oldPressed) | 123 if (pressed != oldPressed) |
| 124 [cell setHighlighted:pressed]; | 124 [cell setHighlighted:pressed]; |
| 125 | 125 |
| 126 // Enabled state | 126 // Enabled state |
| 127 bool oldEnabled = [cell isEnabled]; | 127 bool oldEnabled = [cell isEnabled]; |
| 128 bool enabled = states & EnabledControlState; | 128 bool enabled = states & EnabledControlState; |
| 129 if (enabled != oldEnabled) | 129 if (enabled != oldEnabled) |
| 130 [cell setEnabled:enabled]; | 130 [cell setEnabled:enabled]; |
| 131 | 131 |
| 132 if (ThemeMac::drawWithFrameDrawsFocusRing()) { | |
| 133 // Focused state | |
| 134 bool oldFocused = [cell showsFirstResponder]; | |
| 135 bool focused = states & FocusControlState; | |
| 136 if (focused != oldFocused) | |
| 137 [cell setShowsFirstResponder:focused]; | |
| 138 } | |
| 139 | |
| 140 // Checked and Indeterminate | 132 // Checked and Indeterminate |
| 141 bool oldIndeterminate = [cell state] == NSMixedState; | 133 bool oldIndeterminate = [cell state] == NSMixedState; |
| 142 bool indeterminate = (states & IndeterminateControlState); | 134 bool indeterminate = (states & IndeterminateControlState); |
| 143 bool checked = states & CheckedControlState; | 135 bool checked = states & CheckedControlState; |
| 144 bool oldChecked = [cell state] == NSOnState; | 136 bool oldChecked = [cell state] == NSOnState; |
| 145 if (oldIndeterminate != indeterminate || checked != oldChecked) | 137 if (oldIndeterminate != indeterminate || checked != oldChecked) |
| 146 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO
ffState)]; | 138 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO
ffState)]; |
| 147 | 139 |
| 148 // Window inactive state does not need to be checked explicitly, since we pa
int parented to | 140 // Window inactive state does not need to be checked explicitly, since we pa
int parented to |
| 149 // a view in a window whose key state can be detected. | 141 // a view in a window whose key state can be detected. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); | 274 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); |
| 283 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); | 275 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); |
| 284 context.translate(inflatedRect.x(), inflatedRect.y()); | 276 context.translate(inflatedRect.x(), inflatedRect.y()); |
| 285 context.scale(zoomFactor, zoomFactor); | 277 context.scale(zoomFactor, zoomFactor); |
| 286 context.translate(-inflatedRect.x(), -inflatedRect.y()); | 278 context.translate(-inflatedRect.x(), -inflatedRect.y()); |
| 287 } | 279 } |
| 288 | 280 |
| 289 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); | 281 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); |
| 290 NSView* view = ensuredView(scrollableArea); | 282 NSView* view = ensuredView(scrollableArea); |
| 291 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view]; | 283 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view]; |
| 292 if (!ThemeMac::drawWithFrameDrawsFocusRing() && states & FocusControlState) | 284 if (states & FocusControlState) |
| 293 [checkboxCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view
]; | 285 [checkboxCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view
]; |
| 294 [checkboxCell setControlView:nil]; | 286 [checkboxCell setControlView:nil]; |
| 295 | 287 |
| 296 END_BLOCK_OBJC_EXCEPTIONS | 288 END_BLOCK_OBJC_EXCEPTIONS |
| 297 } | 289 } |
| 298 | 290 |
| 299 // Radio Buttons | 291 // Radio Buttons |
| 300 | 292 |
| 301 static const IntSize* radioSizes() | 293 static const IntSize* radioSizes() |
| 302 { | 294 { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); | 355 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); |
| 364 context.translate(inflatedRect.x(), inflatedRect.y()); | 356 context.translate(inflatedRect.x(), inflatedRect.y()); |
| 365 context.scale(zoomFactor, zoomFactor); | 357 context.scale(zoomFactor, zoomFactor); |
| 366 context.translate(-inflatedRect.x(), -inflatedRect.y()); | 358 context.translate(-inflatedRect.x(), -inflatedRect.y()); |
| 367 } | 359 } |
| 368 | 360 |
| 369 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); | 361 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); |
| 370 BEGIN_BLOCK_OBJC_EXCEPTIONS | 362 BEGIN_BLOCK_OBJC_EXCEPTIONS |
| 371 NSView* view = ensuredView(scrollableArea); | 363 NSView* view = ensuredView(scrollableArea); |
| 372 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view]; | 364 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view]; |
| 373 if (!ThemeMac::drawWithFrameDrawsFocusRing() && states & FocusControlState) | 365 if (states & FocusControlState) |
| 374 [radioCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]; | 366 [radioCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]; |
| 375 [radioCell setControlView:nil]; | 367 [radioCell setControlView:nil]; |
| 376 END_BLOCK_OBJC_EXCEPTIONS | 368 END_BLOCK_OBJC_EXCEPTIONS |
| 377 } | 369 } |
| 378 | 370 |
| 379 // Buttons | 371 // Buttons |
| 380 | 372 |
| 381 // Buttons really only constrain height. They respect width. | 373 // Buttons really only constrain height. They respect width. |
| 382 static const IntSize* buttonSizes() | 374 static const IntSize* buttonSizes() |
| 383 { | 375 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 context.translate(inflatedRect.x(), inflatedRect.y()); | 446 context.translate(inflatedRect.x(), inflatedRect.y()); |
| 455 context.scale(zoomFactor, zoomFactor); | 447 context.scale(zoomFactor, zoomFactor); |
| 456 context.translate(-inflatedRect.x(), -inflatedRect.y()); | 448 context.translate(-inflatedRect.x(), -inflatedRect.y()); |
| 457 } | 449 } |
| 458 } | 450 } |
| 459 | 451 |
| 460 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); | 452 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); |
| 461 NSView* view = ensuredView(scrollableArea); | 453 NSView* view = ensuredView(scrollableArea); |
| 462 | 454 |
| 463 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; | 455 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; |
| 464 if (!ThemeMac::drawWithFrameDrawsFocusRing() && states & FocusControlState) | 456 if (states & FocusControlState) |
| 465 [buttonCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]; | 457 [buttonCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]; |
| 466 [buttonCell setControlView:nil]; | 458 [buttonCell setControlView:nil]; |
| 467 | 459 |
| 468 END_BLOCK_OBJC_EXCEPTIONS | 460 END_BLOCK_OBJC_EXCEPTIONS |
| 469 } | 461 } |
| 470 | 462 |
| 471 // Stepper | 463 // Stepper |
| 472 | 464 |
| 473 static const IntSize* stepperSizes() | 465 static const IntSize* stepperSizes() |
| 474 { | 466 { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 paintButton(part, states, context, zoomedRect, zoomFactor, scrollabl
eArea); | 681 paintButton(part, states, context, zoomedRect, zoomFactor, scrollabl
eArea); |
| 690 break; | 682 break; |
| 691 case InnerSpinButtonPart: | 683 case InnerSpinButtonPart: |
| 692 paintStepper(states, context, zoomedRect, zoomFactor, scrollableArea
); | 684 paintStepper(states, context, zoomedRect, zoomFactor, scrollableArea
); |
| 693 break; | 685 break; |
| 694 default: | 686 default: |
| 695 break; | 687 break; |
| 696 } | 688 } |
| 697 } | 689 } |
| 698 | 690 |
| 699 bool ThemeMac::drawWithFrameDrawsFocusRing() | |
| 700 { | |
| 701 #if defined(MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_V
ERSION_10_8 | |
| 702 // If compiling against an OSX 10.8+ SDK, only 10.7 and older OSes will draw a | |
| 703 // focus ring with the frame. | |
| 704 return IsOSLionOrEarlier(); | |
| 705 #else | |
| 706 // If compiling an OSX 10.7 or older SDK, OSes up through 10.9 will draw a focus | |
| 707 // ring with the frame. | |
| 708 return IsOSMavericksOrEarlier(); | |
| 709 #endif | |
| 710 } | 691 } |
| 711 | |
| 712 } | |
| OLD | NEW |