| 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 #ifndef VIEWS_CONTROLS_PROGRESS_BAR_H_ | 5 #ifndef VIEWS_CONTROLS_PROGRESS_BAR_H_ |
| 6 #define VIEWS_CONTROLS_PROGRESS_BAR_H_ | 6 #define VIEWS_CONTROLS_PROGRESS_BAR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include "base/basictypes.h" |
| 10 | 10 #include "base/compiler_specific.h" |
| 11 #include "views/view.h" | 11 #include "views/view.h" |
| 12 | 12 |
| 13 namespace gfx { | |
| 14 class Canvas; | |
| 15 class Point; | |
| 16 class Size; | |
| 17 } | |
| 18 | |
| 19 namespace views { | 13 namespace views { |
| 20 | 14 |
| 21 ///////////////////////////////////////////////////////////////////////////// | 15 // Progress bar is a control that indicates progress visually. |
| 22 // | |
| 23 // ProgressBar class | |
| 24 // | |
| 25 // A progress bar is a control that indicates progress visually. | |
| 26 // | |
| 27 ///////////////////////////////////////////////////////////////////////////// | |
| 28 | |
| 29 class VIEWS_EXPORT ProgressBar : public View { | 16 class VIEWS_EXPORT ProgressBar : public View { |
| 30 public: | 17 public: |
| 31 // The value range defaults to [0.0, 1.0]. | 18 // The value range defaults to [0.0, 1.0]. |
| 32 ProgressBar(); | 19 ProgressBar(); |
| 33 virtual ~ProgressBar(); | 20 virtual ~ProgressBar(); |
| 34 | 21 |
| 35 double current_value() const { return current_value_; } | 22 double current_value() const { return current_value_; } |
| 36 | 23 |
| 37 // View implementation. | |
| 38 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 39 virtual std::string GetClassName() const OVERRIDE; | |
| 40 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | |
| 41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
| 42 virtual bool GetTooltipText(const gfx::Point& p, | |
| 43 string16* tooltip) const OVERRIDE; | |
| 44 | |
| 45 // Sets the inclusive range of values to be displayed. Values outside of the | 24 // Sets the inclusive range of values to be displayed. Values outside of the |
| 46 // range will be capped when displayed. | 25 // range will be capped when displayed. |
| 47 virtual void SetDisplayRange(double min_display_value, | 26 void SetDisplayRange(double min_display_value, double max_display_value); |
| 48 double max_display_value); | |
| 49 | 27 |
| 50 // Sets the current value. Values outside of the range [min_display_value_, | 28 // Sets the current value. Values outside of the range [min_display_value_, |
| 51 // max_display_value_] will be stored unmodified and capped for display. | 29 // max_display_value_] will be stored unmodified and capped for display. |
| 52 virtual void SetValue(double value); | 30 void SetValue(double value); |
| 53 | 31 |
| 54 // Sets the tooltip text. Default behavior for a progress bar is to show no | 32 // Sets the tooltip text. Default behavior for a progress bar is to show no |
| 55 // tooltip on mouse hover. Calling this lets you set a custom tooltip. To | 33 // tooltip on mouse hover. Calling this lets you set a custom tooltip. To |
| 56 // revert to default behavior, call this with an empty string. | 34 // revert to default behavior, call this with an empty string. |
| 57 void SetTooltipText(const string16& tooltip_text); | 35 void SetTooltipText(const string16& tooltip_text); |
| 58 | 36 |
| 37 // Overridden from View: |
| 38 virtual bool GetTooltipText(const gfx::Point& p, |
| 39 string16* tooltip) const OVERRIDE; |
| 40 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 59 | 41 |
| 60 private: | 42 private: |
| 61 static const char kViewClassName[]; | 43 static const char kViewClassName[]; |
| 62 | 44 |
| 45 // Overridden from View: |
| 46 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 47 virtual std::string GetClassName() const OVERRIDE; |
| 48 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 49 |
| 63 // Inclusive range used when displaying values. | 50 // Inclusive range used when displaying values. |
| 64 double min_display_value_; | 51 double min_display_value_; |
| 65 double max_display_value_; | 52 double max_display_value_; |
| 66 | 53 |
| 67 // Current value. May be outside of [min_display_value_, max_display_value_]. | 54 // Current value. May be outside of [min_display_value_, max_display_value_]. |
| 68 double current_value_; | 55 double current_value_; |
| 69 | 56 |
| 70 // Tooltip text. | 57 // Tooltip text. |
| 71 string16 tooltip_text_; | 58 string16 tooltip_text_; |
| 72 | 59 |
| 73 DISALLOW_COPY_AND_ASSIGN(ProgressBar); | 60 DISALLOW_COPY_AND_ASSIGN(ProgressBar); |
| 74 }; | 61 }; |
| 75 | 62 |
| 76 } // namespace views | 63 } // namespace views |
| 77 | 64 |
| 78 #endif // VIEWS_CONTROLS_PROGRESS_BAR_H_ | 65 #endif // VIEWS_CONTROLS_PROGRESS_BAR_H_ |
| OLD | NEW |