| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/link.h" | 5 #include "ui/views/controls/link.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 SetEnabledColor(GetDefaultEnabledColor()); | 198 SetEnabledColor(GetDefaultEnabledColor()); |
| 199 #if defined(OS_WIN) | 199 #if defined(OS_WIN) |
| 200 SetDisabledColor(color_utils::GetSysSkColor(COLOR_WINDOWTEXT)); | 200 SetDisabledColor(color_utils::GetSysSkColor(COLOR_WINDOWTEXT)); |
| 201 SetPressedColor(SkColorSetRGB(200, 0, 0)); | 201 SetPressedColor(SkColorSetRGB(200, 0, 0)); |
| 202 #else | 202 #else |
| 203 // TODO(beng): source from theme provider. | 203 // TODO(beng): source from theme provider. |
| 204 SetDisabledColor(SK_ColorBLACK); | 204 SetDisabledColor(SK_ColorBLACK); |
| 205 SetPressedColor(SK_ColorRED); | 205 SetPressedColor(SK_ColorRED); |
| 206 #endif | 206 #endif |
| 207 RecalculateFont(); | 207 RecalculateFont(); |
| 208 set_focusable(true); | 208 SetFocusable(true); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void Link::SetPressed(bool pressed) { | 211 void Link::SetPressed(bool pressed) { |
| 212 if (pressed_ != pressed) { | 212 if (pressed_ != pressed) { |
| 213 pressed_ = pressed; | 213 pressed_ = pressed; |
| 214 Label::SetEnabledColor(pressed_ ? | 214 Label::SetEnabledColor(pressed_ ? |
| 215 requested_pressed_color_ : requested_enabled_color_); | 215 requested_pressed_color_ : requested_enabled_color_); |
| 216 RecalculateFont(); | 216 RecalculateFont(); |
| 217 SchedulePaint(); | 217 SchedulePaint(); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 void Link::RecalculateFont() { | 221 void Link::RecalculateFont() { |
| 222 // Underline the link iff it is enabled and |underline_| is true. | 222 // Underline the link iff it is enabled and |underline_| is true. |
| 223 const int style = font().GetStyle(); | 223 const int style = font().GetStyle(); |
| 224 const int intended_style = (enabled() && underline_) ? | 224 const int intended_style = (enabled() && underline_) ? |
| 225 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); | 225 (style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE); |
| 226 if (style != intended_style) | 226 if (style != intended_style) |
| 227 Label::SetFont(font().DeriveFont(0, intended_style)); | 227 Label::SetFont(font().DeriveFont(0, intended_style)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace views | 230 } // namespace views |
| OLD | NEW |