| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 bool pressed = states & PressedControlState; | 134 bool pressed = states & PressedControlState; |
| 135 if (pressed != oldPressed) | 135 if (pressed != oldPressed) |
| 136 [cell setHighlighted:pressed]; | 136 [cell setHighlighted:pressed]; |
| 137 | 137 |
| 138 // Enabled state | 138 // Enabled state |
| 139 bool oldEnabled = [cell isEnabled]; | 139 bool oldEnabled = [cell isEnabled]; |
| 140 bool enabled = states & EnabledControlState; | 140 bool enabled = states & EnabledControlState; |
| 141 if (enabled != oldEnabled) | 141 if (enabled != oldEnabled) |
| 142 [cell setEnabled:enabled]; | 142 [cell setEnabled:enabled]; |
| 143 | 143 |
| 144 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING | |
| 145 // Focused state | 144 // Focused state |
| 146 bool oldFocused = [cell showsFirstResponder]; | 145 bool oldFocused = [cell showsFirstResponder]; |
| 147 bool focused = states & FocusControlState; | 146 bool focused = states & FocusControlState; |
| 148 if (focused != oldFocused) | 147 if (focused != oldFocused) |
| 149 [cell setShowsFirstResponder:focused]; | 148 [cell setShowsFirstResponder:focused]; |
| 150 #endif | |
| 151 | 149 |
| 152 // Checked and Indeterminate | 150 // Checked and Indeterminate |
| 153 bool oldIndeterminate = [cell state] == NSMixedState; | 151 bool oldIndeterminate = [cell state] == NSMixedState; |
| 154 bool indeterminate = (states & IndeterminateControlState); | 152 bool indeterminate = (states & IndeterminateControlState); |
| 155 bool checked = states & CheckedControlState; | 153 bool checked = states & CheckedControlState; |
| 156 bool oldChecked = [cell state] == NSOnState; | 154 bool oldChecked = [cell state] == NSOnState; |
| 157 if (oldIndeterminate != indeterminate || checked != oldChecked) | 155 if (oldIndeterminate != indeterminate || checked != oldChecked) |
| 158 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO
ffState)]; | 156 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO
ffState)]; |
| 159 | 157 |
| 160 // Window inactive state does not need to be checked explicitly, since we pa
int parented to | 158 // Window inactive state does not need to be checked explicitly, since we pa
int parented to |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 205 } |
| 208 | 206 |
| 209 // static | 207 // static |
| 210 IntRect ThemeMac::inflateRectForAA(const IntRect& rect) { | 208 IntRect ThemeMac::inflateRectForAA(const IntRect& rect) { |
| 211 const int margin = 2; | 209 const int margin = 2; |
| 212 return IntRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin
, rect.height() + 2 * margin); | 210 return IntRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin
, rect.height() + 2 * margin); |
| 213 } | 211 } |
| 214 | 212 |
| 215 // static | 213 // static |
| 216 IntRect ThemeMac::inflateRectForFocusRing(const IntRect& rect) { | 214 IntRect ThemeMac::inflateRectForFocusRing(const IntRect& rect) { |
| 217 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING | |
| 218 // Just put a margin of 16 units around the rect. The UI elements that use t
his don't appropriately | 215 // Just put a margin of 16 units around the rect. The UI elements that use t
his don't appropriately |
| 219 // scale their focus rings appropriately (e.g, paint pickers), or switch to
non-native widgets when | 216 // scale their focus rings appropriately (e.g, paint pickers), or switch to
non-native widgets when |
| 220 // scaled (e.g, check boxes and radio buttons). | 217 // scaled (e.g, check boxes and radio buttons). |
| 221 const int margin = 16; | 218 const int margin = 16; |
| 222 IntRect result; | 219 IntRect result; |
| 223 result.setX(rect.x() - margin); | 220 result.setX(rect.x() - margin); |
| 224 result.setY(rect.y() - margin); | 221 result.setY(rect.y() - margin); |
| 225 result.setWidth(rect.width() + 2 * margin); | 222 result.setWidth(rect.width() + 2 * margin); |
| 226 result.setHeight(rect.height() + 2 * margin); | 223 result.setHeight(rect.height() + 2 * margin); |
| 227 return result; | 224 return result; |
| 228 #else | |
| 229 return rect; | |
| 230 #endif | |
| 231 } | 225 } |
| 232 | 226 |
| 233 // Checkboxes | 227 // Checkboxes |
| 234 | 228 |
| 235 static const IntSize* checkboxSizes() | 229 static const IntSize* checkboxSizes() |
| 236 { | 230 { |
| 237 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize(
10, 10) }; | 231 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize(
10, 10) }; |
| 238 return sizes; | 232 return sizes; |
| 239 } | 233 } |
| 240 | 234 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); | 292 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); |
| 299 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); | 293 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); |
| 300 context->translate(inflatedRect.x(), inflatedRect.y()); | 294 context->translate(inflatedRect.x(), inflatedRect.y()); |
| 301 context->scale(zoomFactor, zoomFactor); | 295 context->scale(zoomFactor, zoomFactor); |
| 302 context->translate(-inflatedRect.x(), -inflatedRect.y()); | 296 context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 303 } | 297 } |
| 304 | 298 |
| 305 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); | 299 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); |
| 306 NSView* view = ensuredView(scrollableArea); | 300 NSView* view = ensuredView(scrollableArea); |
| 307 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view]; | 301 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view]; |
| 308 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING | |
| 309 if (states & FocusControlState) | 302 if (states & FocusControlState) |
| 310 [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:vi
ew]; | 303 [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:vi
ew]; |
| 311 #endif | |
| 312 [checkboxCell setControlView:nil]; | 304 [checkboxCell setControlView:nil]; |
| 313 | 305 |
| 314 END_BLOCK_OBJC_EXCEPTIONS | 306 END_BLOCK_OBJC_EXCEPTIONS |
| 315 } | 307 } |
| 316 | 308 |
| 317 // Radio Buttons | 309 // Radio Buttons |
| 318 | 310 |
| 319 static const IntSize* radioSizes() | 311 static const IntSize* radioSizes() |
| 320 { | 312 { |
| 321 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize(
10, 10) }; | 313 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize(
10, 10) }; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); | 373 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); |
| 382 context->translate(inflatedRect.x(), inflatedRect.y()); | 374 context->translate(inflatedRect.x(), inflatedRect.y()); |
| 383 context->scale(zoomFactor, zoomFactor); | 375 context->scale(zoomFactor, zoomFactor); |
| 384 context->translate(-inflatedRect.x(), -inflatedRect.y()); | 376 context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 385 } | 377 } |
| 386 | 378 |
| 387 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); | 379 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); |
| 388 BEGIN_BLOCK_OBJC_EXCEPTIONS | 380 BEGIN_BLOCK_OBJC_EXCEPTIONS |
| 389 NSView* view = ensuredView(scrollableArea); | 381 NSView* view = ensuredView(scrollableArea); |
| 390 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view]; | 382 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view]; |
| 391 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING | |
| 392 if (states & FocusControlState) | 383 if (states & FocusControlState) |
| 393 [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]
; | 384 [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]
; |
| 394 #endif | |
| 395 [radioCell setControlView:nil]; | 385 [radioCell setControlView:nil]; |
| 396 END_BLOCK_OBJC_EXCEPTIONS | 386 END_BLOCK_OBJC_EXCEPTIONS |
| 397 } | 387 } |
| 398 | 388 |
| 399 // Buttons | 389 // Buttons |
| 400 | 390 |
| 401 // Buttons really only constrain height. They respect width. | 391 // Buttons really only constrain height. They respect width. |
| 402 static const IntSize* buttonSizes() | 392 static const IntSize* buttonSizes() |
| 403 { | 393 { |
| 404 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; | 394 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 context->translate(inflatedRect.x(), inflatedRect.y()); | 464 context->translate(inflatedRect.x(), inflatedRect.y()); |
| 475 context->scale(zoomFactor, zoomFactor); | 465 context->scale(zoomFactor, zoomFactor); |
| 476 context->translate(-inflatedRect.x(), -inflatedRect.y()); | 466 context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 477 } | 467 } |
| 478 } | 468 } |
| 479 | 469 |
| 480 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); | 470 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo
cusRing(inflatedRect)); |
| 481 NSView* view = ensuredView(scrollableArea); | 471 NSView* view = ensuredView(scrollableArea); |
| 482 | 472 |
| 483 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; | 473 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; |
| 484 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING | |
| 485 if (states & FocusControlState) | 474 if (states & FocusControlState) |
| 486 [buttonCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view
]; | 475 [buttonCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view
]; |
| 487 #endif | |
| 488 [buttonCell setControlView:nil]; | 476 [buttonCell setControlView:nil]; |
| 489 | 477 |
| 490 END_BLOCK_OBJC_EXCEPTIONS | 478 END_BLOCK_OBJC_EXCEPTIONS |
| 491 } | 479 } |
| 492 | 480 |
| 493 // Stepper | 481 // Stepper |
| 494 | 482 |
| 495 static const IntSize* stepperSizes() | 483 static const IntSize* stepperSizes() |
| 496 { | 484 { |
| 497 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize(
13, 15) }; | 485 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize(
13, 15) }; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 break; | 700 break; |
| 713 case InnerSpinButtonPart: | 701 case InnerSpinButtonPart: |
| 714 paintStepper(states, context, zoomedRect, zoomFactor, scrollableArea
); | 702 paintStepper(states, context, zoomedRect, zoomFactor, scrollableArea
); |
| 715 break; | 703 break; |
| 716 default: | 704 default: |
| 717 break; | 705 break; |
| 718 } | 706 } |
| 719 } | 707 } |
| 720 | 708 |
| 721 } | 709 } |
| OLD | NEW |