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

Unified Diff: views/controls/link.cc

Issue 6976048: views: Add OnEnabledChanged() method to View class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DisableOnHover test? Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/link.h ('k') | views/controls/native_control.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/link.cc
diff --git a/views/controls/link.cc b/views/controls/link.cc
index 3c8bceac650e07cf51334554c89ba9c8ed10ccc9..1ffbf568a2c209e0c456a6f266adeaa869144539 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.cc
@@ -88,12 +88,9 @@ void Link::Init() {
Link::~Link() {
}
-void Link::SetEnabled(bool flag) {
- if (flag != enabled_) {
- enabled_ = flag;
- ValidateStyle();
- SchedulePaint();
- }
+void Link::OnEnabledChanged() {
+ ValidateStyle();
+ View::OnEnabledChanged();
}
std::string Link::GetClassName() const {
@@ -101,7 +98,7 @@ std::string Link::GetClassName() const {
}
gfx::NativeCursor Link::GetCursor(const MouseEvent& event) {
- if (!enabled_)
+ if (!IsEnabled())
return NULL;
#if defined(OS_WIN)
static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
@@ -112,14 +109,15 @@ gfx::NativeCursor Link::GetCursor(const MouseEvent& event) {
}
bool Link::OnMousePressed(const MouseEvent& event) {
- if (!enabled_ || (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
+ if (!IsEnabled() ||
+ (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
return false;
SetHighlighted(true);
return true;
}
bool Link::OnMouseDragged(const MouseEvent& event) {
- SetHighlighted(enabled_ &&
+ SetHighlighted(IsEnabled() &&
(event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
HitTest(event.location()));
return true;
@@ -129,7 +127,8 @@ void Link::OnMouseReleased(const MouseEvent& event) {
// Change the highlight first just in case this instance is deleted
// while calling the controller
OnMouseCaptureLost();
- if (enabled_ && (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
+ if (IsEnabled() &&
+ (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) &&
HitTest(event.location())) {
// Focus the link on click.
RequestFocus();
@@ -205,7 +204,7 @@ void Link::SetHighlighted(bool f) {
}
void Link::ValidateStyle() {
- if (enabled_) {
+ if (IsEnabled()) {
if (!(font().GetStyle() & gfx::Font::UNDERLINED)) {
Label::SetFont(
font().DeriveFont(0, font().GetStyle() | gfx::Font::UNDERLINED));
« no previous file with comments | « views/controls/link.h ('k') | views/controls/native_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698