| 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 <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 ///////////////////////////////////////////////////////////////////////////// | 21 ///////////////////////////////////////////////////////////////////////////// |
| 22 // | 22 // |
| 23 // ProgressBar class | 23 // ProgressBar class |
| 24 // | 24 // |
| 25 // A progress bar is a control that indicates progress visually. | 25 // A progress bar is a control that indicates progress visually. |
| 26 // | 26 // |
| 27 ///////////////////////////////////////////////////////////////////////////// | 27 ///////////////////////////////////////////////////////////////////////////// |
| 28 | 28 |
| 29 class VIEWS_EXPORT ProgressBar : public View { | 29 class VIEWS_EXPORT ProgressBar : public View { |
| 30 public: | 30 public: |
| 31 // The value range defaults to [0.0, 1.0]. |
| 31 ProgressBar(); | 32 ProgressBar(); |
| 32 virtual ~ProgressBar(); | 33 virtual ~ProgressBar(); |
| 33 | 34 |
| 34 // Overridden to return preferred size of the progress bar. | 35 double current_value() const { return current_value_; } |
| 35 virtual gfx::Size GetPreferredSize(); | |
| 36 | 36 |
| 37 // Returns views/ProgressBar. | 37 // View implementation. |
| 38 virtual std::string GetClassName() const; | 38 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 39 | 39 virtual std::string GetClassName() const OVERRIDE; |
| 40 // Overridden to paint | 40 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 41 virtual void OnPaint(gfx::Canvas* canvas); | 41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 42 | |
| 43 // Set and get the progress bar progress in range [0, kMaxProgress]. | |
| 44 virtual void SetProgress(int progress); | |
| 45 virtual int GetProgress() const; | |
| 46 // Add progress to current. | |
| 47 virtual void AddProgress(int tick); | |
| 48 | |
| 49 // Sets the tooltip text. Default behavior for a progress bar is to show | |
| 50 // no tooltip on mouse hover. Calling this lets you set a custom tooltip. | |
| 51 // To revert to default behavior, call this with an empty string. | |
| 52 virtual void SetTooltipText(const std::wstring& tooltip_text); | |
| 53 | |
| 54 // Gets the tooltip text if has been specified with SetTooltipText(). | |
| 55 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) | 42 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) |
| 56 OVERRIDE; | 43 OVERRIDE; |
| 57 | 44 |
| 58 // Sets the enabled state. | 45 // Sets the inclusive range of values to be displayed. Values outside of the |
| 59 virtual void OnEnabledChanged() OVERRIDE; | 46 // range will be capped when displayed. |
| 47 virtual void SetDisplayRange(double min_display_value, |
| 48 double max_display_value); |
| 60 | 49 |
| 61 // Accessibility accessors, overridden from View. | 50 // Sets the current value. Values outside of the range [min_display_value_, |
| 62 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 51 // max_display_value_] will be stored unmodified and capped for display. |
| 52 virtual void SetValue(double value); |
| 63 | 53 |
| 64 // Maximum value of progress. | 54 // Sets the tooltip text. Default behavior for a progress bar is to show no |
| 65 static const int kMaxProgress; | 55 // tooltip on mouse hover. Calling this lets you set a custom tooltip. To |
| 56 // revert to default behavior, call this with an empty string. |
| 57 virtual void SetTooltipText(const std::wstring& tooltip_text); |
| 58 |
| 66 | 59 |
| 67 private: | 60 private: |
| 68 // Progress in range [0, kMaxProgress]. | 61 static const char kViewClassName[]; |
| 69 int progress_; | 62 |
| 63 // Inclusive range used when displaying values. |
| 64 double min_display_value_; |
| 65 double max_display_value_; |
| 66 |
| 67 // Current value. May be outside of [min_display_value_, max_display_value_]. |
| 68 double current_value_; |
| 70 | 69 |
| 71 // Tooltip text. | 70 // Tooltip text. |
| 72 string16 tooltip_text_; | 71 string16 tooltip_text_; |
| 73 | 72 |
| 74 // The view class name. | |
| 75 static const char kViewClassName[]; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(ProgressBar); | 73 DISALLOW_COPY_AND_ASSIGN(ProgressBar); |
| 78 }; | 74 }; |
| 79 | 75 |
| 80 } // namespace views | 76 } // namespace views |
| 81 | 77 |
| 82 #endif // VIEWS_CONTROLS_PROGRESS_BAR_H_ | 78 #endif // VIEWS_CONTROLS_PROGRESS_BAR_H_ |
| OLD | NEW |