Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: ui/views/controls/link.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 26 matching lines...) Expand all
37 37
38 void Link::OnEnabledChanged() { 38 void Link::OnEnabledChanged() {
39 RecalculateFont(); 39 RecalculateFont();
40 View::OnEnabledChanged(); 40 View::OnEnabledChanged();
41 } 41 }
42 42
43 std::string Link::GetClassName() const { 43 std::string Link::GetClassName() const {
44 return kViewClassName; 44 return kViewClassName;
45 } 45 }
46 46
47 gfx::NativeCursor Link::GetCursor(const MouseEvent& event) { 47 gfx::NativeCursor Link::GetCursor(const ui::MouseEvent& event) {
48 if (!enabled()) 48 if (!enabled())
49 return gfx::kNullCursor; 49 return gfx::kNullCursor;
50 #if defined(USE_AURA) 50 #if defined(USE_AURA)
51 return ui::kCursorHand; 51 return ui::kCursorHand;
52 #elif defined(OS_WIN) 52 #elif defined(OS_WIN)
53 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); 53 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
54 return g_hand_cursor; 54 return g_hand_cursor;
55 #endif 55 #endif
56 } 56 }
57 57
58 bool Link::HitTestRect(const gfx::Rect& rect) const { 58 bool Link::HitTestRect(const gfx::Rect& rect) const {
59 // We need to allow clicks on the link. So we override the implementation in 59 // We need to allow clicks on the link. So we override the implementation in
60 // Label and use the default implementation of View. 60 // Label and use the default implementation of View.
61 return View::HitTestRect(rect); 61 return View::HitTestRect(rect);
62 } 62 }
63 63
64 bool Link::OnMousePressed(const MouseEvent& event) { 64 bool Link::OnMousePressed(const ui::MouseEvent& event) {
65 if (!enabled() || 65 if (!enabled() ||
66 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) 66 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
67 return false; 67 return false;
68 SetPressed(true); 68 SetPressed(true);
69 return true; 69 return true;
70 } 70 }
71 71
72 bool Link::OnMouseDragged(const MouseEvent& event) { 72 bool Link::OnMouseDragged(const ui::MouseEvent& event) {
73 SetPressed(enabled() && 73 SetPressed(enabled() &&
74 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && 74 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
75 HitTestPoint(event.location())); 75 HitTestPoint(event.location()));
76 return true; 76 return true;
77 } 77 }
78 78
79 void Link::OnMouseReleased(const MouseEvent& event) { 79 void Link::OnMouseReleased(const ui::MouseEvent& event) {
80 // Change the highlight first just in case this instance is deleted 80 // Change the highlight first just in case this instance is deleted
81 // while calling the controller 81 // while calling the controller
82 OnMouseCaptureLost(); 82 OnMouseCaptureLost();
83 if (enabled() && 83 if (enabled() &&
84 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && 84 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
85 HitTestPoint(event.location())) { 85 HitTestPoint(event.location())) {
86 // Focus the link on click. 86 // Focus the link on click.
87 RequestFocus(); 87 RequestFocus();
88 88
89 if (listener_) 89 if (listener_)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void Link::RecalculateFont() { 199 void Link::RecalculateFont() {
200 // The font should be underlined iff the link is enabled. 200 // The font should be underlined iff the link is enabled.
201 if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) { 201 if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) {
202 Label::SetFont(font().DeriveFont(0, enabled() ? 202 Label::SetFont(font().DeriveFont(0, enabled() ?
203 (font().GetStyle() | gfx::Font::UNDERLINED) : 203 (font().GetStyle() | gfx::Font::UNDERLINED) :
204 (font().GetStyle() & ~gfx::Font::UNDERLINED))); 204 (font().GetStyle() & ~gfx::Font::UNDERLINED)));
205 } 205 }
206 } 206 }
207 207
208 } // namespace views 208 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698