| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/link.h" | 5 #include "views/controls/link.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "app/keyboard_codes.h" | 11 #include "base/keyboard_codes.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "gfx/color_utils.h" | 13 #include "gfx/color_utils.h" |
| 14 #include "gfx/font.h" | 14 #include "gfx/font.h" |
| 15 #include "views/event.h" | 15 #include "views/event.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void GetColors(const SkColor* background_color, // NULL means "use default" | 19 void GetColors(const SkColor* background_color, // NULL means "use default" |
| 20 SkColor* highlighted_color, | 20 SkColor* highlighted_color, |
| 21 SkColor* disabled_color, | 21 SkColor* disabled_color, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 HitTest(e.location())) { | 115 HitTest(e.location())) { |
| 116 // Focus the link on click. | 116 // Focus the link on click. |
| 117 RequestFocus(); | 117 RequestFocus(); |
| 118 | 118 |
| 119 if (controller_) | 119 if (controller_) |
| 120 controller_->LinkActivated(this, e.GetFlags()); | 120 controller_->LinkActivated(this, e.GetFlags()); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool Link::OnKeyPressed(const KeyEvent& e) { | 124 bool Link::OnKeyPressed(const KeyEvent& e) { |
| 125 bool activate = ((e.GetKeyCode() == app::VKEY_SPACE) || | 125 bool activate = ((e.GetKeyCode() == base::VKEY_SPACE) || |
| 126 (e.GetKeyCode() == app::VKEY_RETURN)); | 126 (e.GetKeyCode() == base::VKEY_RETURN)); |
| 127 if (!activate) | 127 if (!activate) |
| 128 return false; | 128 return false; |
| 129 | 129 |
| 130 SetHighlighted(false); | 130 SetHighlighted(false); |
| 131 | 131 |
| 132 // Focus the link on key pressed. | 132 // Focus the link on key pressed. |
| 133 RequestFocus(); | 133 RequestFocus(); |
| 134 | 134 |
| 135 if (controller_) | 135 if (controller_) |
| 136 controller_->LinkActivated(this, e.GetFlags()); | 136 controller_->LinkActivated(this, e.GetFlags()); |
| 137 | 137 |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { | 141 bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { |
| 142 // Make sure we don't process space or enter as accelerators. | 142 // Make sure we don't process space or enter as accelerators. |
| 143 return (e.GetKeyCode() == app::VKEY_SPACE) || | 143 return (e.GetKeyCode() == base::VKEY_SPACE) || |
| 144 (e.GetKeyCode() == app::VKEY_RETURN); | 144 (e.GetKeyCode() == base::VKEY_RETURN); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool Link::GetAccessibleRole(AccessibilityTypes::Role* role) { | 147 bool Link::GetAccessibleRole(AccessibilityTypes::Role* role) { |
| 148 DCHECK(role); | 148 DCHECK(role); |
| 149 | 149 |
| 150 *role = AccessibilityTypes::ROLE_LINK; | 150 *role = AccessibilityTypes::ROLE_LINK; |
| 151 return true; | 151 return true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void Link::SetFont(const gfx::Font& font) { | 154 void Link::SetFont(const gfx::Font& font) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } else { | 219 } else { |
| 220 if (font().GetStyle() & gfx::Font::UNDERLINED) { | 220 if (font().GetStyle() & gfx::Font::UNDERLINED) { |
| 221 Label::SetFont( | 221 Label::SetFont( |
| 222 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); | 222 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); |
| 223 } | 223 } |
| 224 Label::SetColor(disabled_color_); | 224 Label::SetColor(disabled_color_); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace views | 228 } // namespace views |
| OLD | NEW |