diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 13:41:03 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 13:41:03 +0000 |
commit | d8c664d2a1a9301d8bdc7ab68959f51791ebbdc3 (patch) | |
tree | 4fdb16fee4fd55fe3f827e918df802872cf9189c /views | |
parent | a48548184b405b38c3549b7c17dd38c8147833d8 (diff) | |
download | chromium_src-d8c664d2a1a9301d8bdc7ab68959f51791ebbdc3.zip chromium_src-d8c664d2a1a9301d8bdc7ab68959f51791ebbdc3.tar.gz chromium_src-d8c664d2a1a9301d8bdc7ab68959f51791ebbdc3.tar.bz2 |
views: Move the overridden methods of ProgressBar to private section.
R=sky@chromium.org
Review URL: http://codereview.chromium.org/8429014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/progress_bar.cc | 75 | ||||
-rw-r--r-- | views/controls/progress_bar.h | 41 |
2 files changed, 50 insertions, 66 deletions
diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc index 587e6dc..41c69ec 100644 --- a/views/controls/progress_bar.cc +++ b/views/controls/progress_bar.cc @@ -21,9 +21,6 @@ #include "views/border.h" #include "views/painter.h" -using std::max; -using std::min; - namespace { // Corner radius for the progress bar's border. @@ -143,12 +140,34 @@ ProgressBar::ProgressBar() ProgressBar::~ProgressBar() { } -gfx::Size ProgressBar::GetPreferredSize() { - return gfx::Size(100, 16); +void ProgressBar::SetDisplayRange(double min_display_value, + double max_display_value) { + if (min_display_value != min_display_value_ || + max_display_value != max_display_value_) { + DCHECK(min_display_value < max_display_value); + min_display_value_ = min_display_value; + max_display_value_ = max_display_value; + SchedulePaint(); + } } -std::string ProgressBar::GetClassName() const { - return kViewClassName; +void ProgressBar::SetValue(double value) { + if (value != current_value_) { + current_value_ = value; + SchedulePaint(); + } +} + +void ProgressBar::SetTooltipText(const string16& tooltip_text) { + tooltip_text_ = tooltip_text; +} + +bool ProgressBar::GetTooltipText(const gfx::Point& p, string16* tooltip) const { + DCHECK(tooltip); + if (tooltip == NULL) + return false; + tooltip->assign(tooltip_text_); + return !tooltip_text_.empty(); } void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) { @@ -156,9 +175,17 @@ void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) { state->state = ui::AccessibilityTypes::STATE_READONLY; } +gfx::Size ProgressBar::GetPreferredSize() { + return gfx::Size(100, 16); +} + +std::string ProgressBar::GetClassName() const { + return kViewClassName; +} + void ProgressBar::OnPaint(gfx::Canvas* canvas) { - const double capped_value = - min(max(current_value_, min_display_value_), max_display_value_); + const double capped_value = std::min( + std::max(current_value_, min_display_value_), max_display_value_); const double capped_fraction = (capped_value - min_display_value_) / (max_display_value_ - min_display_value_); @@ -289,34 +316,4 @@ void ProgressBar::OnPaint(gfx::Canvas* canvas) { #endif } -bool ProgressBar::GetTooltipText(const gfx::Point& p, string16* tooltip) const { - DCHECK(tooltip); - if (tooltip == NULL) - return false; - tooltip->assign(tooltip_text_); - return !tooltip_text_.empty(); -} - -void ProgressBar::SetDisplayRange(double min_display_value, - double max_display_value) { - if (min_display_value != min_display_value_ || - max_display_value != max_display_value_) { - DCHECK(min_display_value < max_display_value); - min_display_value_ = min_display_value; - max_display_value_ = max_display_value; - SchedulePaint(); - } -} - -void ProgressBar::SetValue(double value) { - if (value != current_value_) { - current_value_ = value; - SchedulePaint(); - } -} - -void ProgressBar::SetTooltipText(const string16& tooltip_text) { - tooltip_text_ = tooltip_text; -} - } // namespace views diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h index 65247b0..aaaee03 100644 --- a/views/controls/progress_bar.h +++ b/views/controls/progress_bar.h @@ -6,26 +6,13 @@ #define VIEWS_CONTROLS_PROGRESS_BAR_H_ #pragma once -#include <string> - +#include "base/basictypes.h" +#include "base/compiler_specific.h" #include "views/view.h" -namespace gfx { -class Canvas; -class Point; -class Size; -} - namespace views { -///////////////////////////////////////////////////////////////////////////// -// -// ProgressBar class -// -// A progress bar is a control that indicates progress visually. -// -///////////////////////////////////////////////////////////////////////////// - +// Progress bar is a control that indicates progress visually. class VIEWS_EXPORT ProgressBar : public View { public: // The value range defaults to [0.0, 1.0]. @@ -34,32 +21,32 @@ class VIEWS_EXPORT ProgressBar : public View { double current_value() const { return current_value_; } - // View implementation. - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual bool GetTooltipText(const gfx::Point& p, - string16* tooltip) const OVERRIDE; - // Sets the inclusive range of values to be displayed. Values outside of the // range will be capped when displayed. - virtual void SetDisplayRange(double min_display_value, - double max_display_value); + void SetDisplayRange(double min_display_value, double max_display_value); // Sets the current value. Values outside of the range [min_display_value_, // max_display_value_] will be stored unmodified and capped for display. - virtual void SetValue(double value); + void SetValue(double value); // Sets the tooltip text. Default behavior for a progress bar is to show no // tooltip on mouse hover. Calling this lets you set a custom tooltip. To // revert to default behavior, call this with an empty string. void SetTooltipText(const string16& tooltip_text); + // Overridden from View: + virtual bool GetTooltipText(const gfx::Point& p, + string16* tooltip) const OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; private: static const char kViewClassName[]; + // Overridden from View: + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual std::string GetClassName() const OVERRIDE; + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + // Inclusive range used when displaying values. double min_display_value_; double max_display_value_; |