diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 00:07:31 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 00:07:31 +0000 |
commit | d0d639af9da992e49cd9a8fbed43953b9ec0916e (patch) | |
tree | c8837d33539c339d0686c62b2f64dc3fa68b4256 /views | |
parent | a337122f70c5681ca03a90067cc2c80423a79a41 (diff) | |
download | chromium_src-d0d639af9da992e49cd9a8fbed43953b9ec0916e.zip chromium_src-d0d639af9da992e49cd9a8fbed43953b9ec0916e.tar.gz chromium_src-d0d639af9da992e49cd9a8fbed43953b9ec0916e.tar.bz2 |
Clean up a few bits of files that I'm about to modify. The only visible change is the removal of some extra spacing Ben erroneously added to the link infobar a while back (clients already do their own spacing as needed, so this just added extra whitespace in mid-sentence).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/223029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/label.cc | 3 | ||||
-rw-r--r-- | views/controls/link.cc | 124 | ||||
-rw-r--r-- | views/controls/link.h | 6 | ||||
-rw-r--r-- | views/controls/textfield/textfield.h | 4 |
4 files changed, 62 insertions, 75 deletions
diff --git a/views/controls/label.cc b/views/controls/label.cc index 3d2304f..8bda393 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,6 +18,7 @@ namespace views { +// static const char Label::kViewClassName[] = "views/Label"; static const SkColor kEnabledColor = SK_ColorBLACK; diff --git a/views/controls/link.cc b/views/controls/link.cc index 34a9e46..c9bd256 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -61,25 +61,6 @@ const LinkController* Link::GetController() { return controller_; } -std::string Link::GetClassName() const { - return kViewClassName; -} - -void Link::SetHighlightedColor(const SkColor& color) { - normal_color_ = color; - ValidateStyle(); -} - -void Link::SetDisabledColor(const SkColor& color) { - disabled_color_ = color; - ValidateStyle(); -} - -void Link::SetNormalColor(const SkColor& color) { - normal_color_ = color; - ValidateStyle(); -} - bool Link::OnMousePressed(const MouseEvent& e) { if (!enabled_ || (!e.IsLeftMouseButton() && !e.IsMiddleMouseButton())) return false; @@ -117,18 +98,18 @@ bool Link::OnKeyPressed(const KeyEvent& e) { bool activate = false; NOTIMPLEMENTED(); #endif - if (activate) { - SetHighlighted(false); + if (!activate) + return false; - // Focus the link on key pressed. - RequestFocus(); + SetHighlighted(false); - if (controller_) - controller_->LinkActivated(this, e.GetFlags()); + // Focus the link on key pressed. + RequestFocus(); - return true; - } - return false; + if (controller_) + controller_->LinkActivated(this, e.GetFlags()); + + return true; } bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { @@ -141,40 +122,6 @@ bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { #endif } -void Link::SetHighlighted(bool f) { - if (f != highlighted_) { - highlighted_ = f; - ValidateStyle(); - SchedulePaint(); - } -} - -void Link::ValidateStyle() { - gfx::Font font = GetFont(); - - if (enabled_) { - if ((font.style() & gfx::Font::UNDERLINED) == 0) { - Label::SetFont(font.DeriveFont(0, font.style() | - gfx::Font::UNDERLINED)); - } - } else { - if ((font.style() & gfx::Font::UNDERLINED) != 0) { - Label::SetFont(font.DeriveFont(0, font.style() & - ~gfx::Font::UNDERLINED)); - } - } - - if (enabled_) { - if (highlighted_) { - Label::SetColor(highlighted_color_); - } else { - Label::SetColor(normal_color_); - } - } else { - Label::SetColor(disabled_color_); - } -} - void Link::SetFont(const gfx::Font& font) { Label::SetFont(font); ValidateStyle(); @@ -190,16 +137,55 @@ void Link::SetEnabled(bool f) { gfx::NativeCursor Link::GetCursorForPoint(Event::EventType event_type, int x, int y) { - if (enabled_) { + if (!enabled_) + return NULL; #if defined(OS_WIN) - if (!g_hand_cursor) - g_hand_cursor = LoadCursor(NULL, IDC_HAND); - return g_hand_cursor; + if (!g_hand_cursor) + g_hand_cursor = LoadCursor(NULL, IDC_HAND); + return g_hand_cursor; #elif defined(OS_LINUX) - return gdk_cursor_new(GDK_HAND2); + return gdk_cursor_new(GDK_HAND2); #endif +} + +std::string Link::GetClassName() const { + return kViewClassName; +} + +void Link::SetHighlightedColor(const SkColor& color) { + normal_color_ = color; + ValidateStyle(); +} + +void Link::SetDisabledColor(const SkColor& color) { + disabled_color_ = color; + ValidateStyle(); +} + +void Link::SetNormalColor(const SkColor& color) { + normal_color_ = color; + ValidateStyle(); +} + +void Link::SetHighlighted(bool f) { + if (f != highlighted_) { + highlighted_ = f; + ValidateStyle(); + SchedulePaint(); + } +} + +void Link::ValidateStyle() { + gfx::Font font = GetFont(); + + if (enabled_) { + if ((font.style() & gfx::Font::UNDERLINED) == 0) + Label::SetFont(font.DeriveFont(0, font.style() | gfx::Font::UNDERLINED)); + Label::SetColor(highlighted_ ? highlighted_color_ : normal_color_); } else { - return NULL; + if ((font.style() & gfx::Font::UNDERLINED) != 0) + Label::SetFont(font.DeriveFont(0, font.style() & ~gfx::Font::UNDERLINED)); + Label::SetColor(disabled_color_); } } diff --git a/views/controls/link.h b/views/controls/link.h index c574b6e..30b2bdb7 100644 --- a/views/controls/link.h +++ b/views/controls/link.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,8 +32,6 @@ class LinkController { //////////////////////////////////////////////////////////////////////////////// class Link : public Label { public: - static const char kViewClassName[]; - Link(); Link(const std::wstring& title); virtual ~Link(); @@ -63,6 +61,8 @@ class Link : public Label { void SetDisabledColor(const SkColor& color); void SetNormalColor(const SkColor& color); + static const char kViewClassName[]; + private: // A highlighted link is clicked. diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index fd01cef..7bc5f68 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -231,8 +231,8 @@ class Textfield : public View { // |use_default_background_color_| is set to false. SkColor background_color_; - // When true, the system colors for Textfields are used when painting this - // Textfield. When false, the value of |background_color_| determines the + // When true, the system background color for Textfields is used when painting + // this Textfield. When false, the value of |background_color_| determines the // Textfield's background color. bool use_default_background_color_; |