| 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(TOOLKIT_USES_GTK) |
| 10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "ui/base/accessibility/accessible_view_state.h" | 14 #include "ui/base/accessibility/accessible_view_state.h" |
| 15 #include "ui/base/keycodes/keyboard_codes.h" | 15 #include "ui/base/keycodes/keyboard_codes.h" |
| 16 #include "ui/gfx/color_utils.h" | 16 #include "ui/gfx/color_utils.h" |
| 17 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 18 #include "views/controls/link_listener.h" | 18 #include "views/controls/link_listener.h" |
| 19 #include "views/events/event.h" | 19 #include "views/events/event.h" |
| 20 | 20 |
| 21 #if defined(OS_LINUX) | 21 #if defined(TOOLKIT_USES_GTK) |
| 22 #include "ui/gfx/gtk_util.h" | 22 #include "ui/gfx/gtk_util.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 void GetColors(const SkColor* background_color, // NULL means "use default" | 27 void GetColors(const SkColor* background_color, // NULL means "use default" |
| 28 SkColor* highlighted_color, | 28 SkColor* highlighted_color, |
| 29 SkColor* disabled_color, | 29 SkColor* disabled_color, |
| 30 SkColor* normal_color) { | 30 SkColor* normal_color) { |
| 31 static SkColor kHighlightedColor, kDisabledColor, kNormalColor; | 31 static SkColor kHighlightedColor, kDisabledColor, kNormalColor; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 std::string Link::GetClassName() const { | 96 std::string Link::GetClassName() const { |
| 97 return kViewClassName; | 97 return kViewClassName; |
| 98 } | 98 } |
| 99 | 99 |
| 100 gfx::NativeCursor Link::GetCursor(const MouseEvent& event) { | 100 gfx::NativeCursor Link::GetCursor(const MouseEvent& event) { |
| 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(USE_AURA) | 106 #elif defined(TOOLKIT_USES_GTK) |
| 107 return gfx::GetCursor(GDK_HAND2); |
| 108 #else |
| 107 // TODO(saintlou): | 109 // TODO(saintlou): |
| 108 return NULL; | 110 return NULL; |
| 109 #elif defined(OS_LINUX) | |
| 110 return gfx::GetCursor(GDK_HAND2); | |
| 111 #endif | 111 #endif |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool Link::HitTest(const gfx::Point& l) const { | 114 bool Link::HitTest(const gfx::Point& l) const { |
| 115 // We need to allow clicks on the link. So we override the implementation in | 115 // We need to allow clicks on the link. So we override the implementation in |
| 116 // Label and use the default implementation of View. | 116 // Label and use the default implementation of View. |
| 117 return View::HitTest(l); | 117 return View::HitTest(l); |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool Link::OnMousePressed(const MouseEvent& event) { | 120 bool Link::OnMousePressed(const MouseEvent& event) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } else { | 222 } else { |
| 223 if (font().GetStyle() & gfx::Font::UNDERLINED) { | 223 if (font().GetStyle() & gfx::Font::UNDERLINED) { |
| 224 Label::SetFont( | 224 Label::SetFont( |
| 225 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); | 225 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); |
| 226 } | 226 } |
| 227 Label::SetColor(disabled_color_); | 227 Label::SetColor(disabled_color_); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace views | 231 } // namespace views |
| OLD | NEW |