| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_LINUX) | 9 #if defined(OS_LINUX) |
| 10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (!IsEnabled()) | 101 if (!IsEnabled()) |
| 102 return NULL; | 102 return NULL; |
| 103 #if defined(OS_WIN) | 103 #if defined(OS_WIN) |
| 104 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); | 104 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); |
| 105 return g_hand_cursor; | 105 return g_hand_cursor; |
| 106 #elif defined(OS_LINUX) | 106 #elif defined(OS_LINUX) |
| 107 return gfx::GetCursor(GDK_HAND2); | 107 return gfx::GetCursor(GDK_HAND2); |
| 108 #endif | 108 #endif |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool Link::HitTest(const gfx::Point& l) const { |
| 112 // We need to allow clicks on the link. So we override the implementation in |
| 113 // Label and use the default implementation of View. |
| 114 return View::HitTest(l); |
| 115 } |
| 116 |
| 111 bool Link::OnMousePressed(const MouseEvent& event) { | 117 bool Link::OnMousePressed(const MouseEvent& event) { |
| 112 if (!IsEnabled() || | 118 if (!IsEnabled() || |
| 113 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) | 119 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) |
| 114 return false; | 120 return false; |
| 115 SetHighlighted(true); | 121 SetHighlighted(true); |
| 116 return true; | 122 return true; |
| 117 } | 123 } |
| 118 | 124 |
| 119 bool Link::OnMouseDragged(const MouseEvent& event) { | 125 bool Link::OnMouseDragged(const MouseEvent& event) { |
| 120 SetHighlighted(IsEnabled() && | 126 SetHighlighted(IsEnabled() && |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } else { | 219 } else { |
| 214 if (font().GetStyle() & gfx::Font::UNDERLINED) { | 220 if (font().GetStyle() & gfx::Font::UNDERLINED) { |
| 215 Label::SetFont( | 221 Label::SetFont( |
| 216 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); | 222 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); |
| 217 } | 223 } |
| 218 Label::SetColor(disabled_color_); | 224 Label::SetColor(disabled_color_); |
| 219 } | 225 } |
| 220 } | 226 } |
| 221 | 227 |
| 222 } // namespace views | 228 } // namespace views |
| OLD | NEW |