| 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 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Change the highlight first just in case this instance is deleted | 114 // Change the highlight first just in case this instance is deleted |
| 115 // while calling the controller | 115 // while calling the controller |
| 116 SetHighlighted(false); | 116 SetHighlighted(false); |
| 117 if (enabled_ && !canceled && | 117 if (enabled_ && !canceled && |
| 118 (e.IsLeftMouseButton() || e.IsMiddleMouseButton()) && | 118 (e.IsLeftMouseButton() || e.IsMiddleMouseButton()) && |
| 119 HitTest(e.location())) { | 119 HitTest(e.location())) { |
| 120 // Focus the link on click. | 120 // Focus the link on click. |
| 121 RequestFocus(); | 121 RequestFocus(); |
| 122 | 122 |
| 123 if (controller_) | 123 if (controller_) |
| 124 controller_->LinkActivated(this, e.GetFlags()); | 124 controller_->LinkActivated(this, e.flags()); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool Link::OnKeyPressed(const KeyEvent& e) { | 128 bool Link::OnKeyPressed(const KeyEvent& e) { |
| 129 bool activate = ((e.GetKeyCode() == ui::VKEY_SPACE) || | 129 bool activate = ((e.key_code() == ui::VKEY_SPACE) || |
| 130 (e.GetKeyCode() == ui::VKEY_RETURN)); | 130 (e.key_code() == ui::VKEY_RETURN)); |
| 131 if (!activate) | 131 if (!activate) |
| 132 return false; | 132 return false; |
| 133 | 133 |
| 134 SetHighlighted(false); | 134 SetHighlighted(false); |
| 135 | 135 |
| 136 // Focus the link on key pressed. | 136 // Focus the link on key pressed. |
| 137 RequestFocus(); | 137 RequestFocus(); |
| 138 | 138 |
| 139 if (controller_) | 139 if (controller_) |
| 140 controller_->LinkActivated(this, e.GetFlags()); | 140 controller_->LinkActivated(this, e.flags()); |
| 141 | 141 |
| 142 return true; | 142 return true; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { | 145 bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { |
| 146 // Make sure we don't process space or enter as accelerators. | 146 // Make sure we don't process space or enter as accelerators. |
| 147 return (e.GetKeyCode() == ui::VKEY_SPACE) || | 147 return (e.key_code() == ui::VKEY_SPACE) || |
| 148 (e.GetKeyCode() == ui::VKEY_RETURN); | 148 (e.key_code() == ui::VKEY_RETURN); |
| 149 } | 149 } |
| 150 | 150 |
| 151 AccessibilityTypes::Role Link::GetAccessibleRole() { | 151 AccessibilityTypes::Role Link::GetAccessibleRole() { |
| 152 return AccessibilityTypes::ROLE_LINK; | 152 return AccessibilityTypes::ROLE_LINK; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void Link::SetFont(const gfx::Font& font) { | 155 void Link::SetFont(const gfx::Font& font) { |
| 156 Label::SetFont(font); | 156 Label::SetFont(font); |
| 157 ValidateStyle(); | 157 ValidateStyle(); |
| 158 } | 158 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } else { | 220 } else { |
| 221 if (font().GetStyle() & gfx::Font::UNDERLINED) { | 221 if (font().GetStyle() & gfx::Font::UNDERLINED) { |
| 222 Label::SetFont( | 222 Label::SetFont( |
| 223 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); | 223 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); |
| 224 } | 224 } |
| 225 Label::SetColor(disabled_color_); | 225 Label::SetColor(disabled_color_); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace views | 229 } // namespace views |
| OLD | NEW |