| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_MESSAGE_CENTER_BOUNDED_LABEL_H_ | 5 #ifndef UI_MESSAGE_CENTER_BOUNDED_LABEL_H_ |
| 6 #define UI_MESSAGE_CENTER_BOUNDED_LABEL_H_ | 6 #define UI_MESSAGE_CENTER_BOUNDED_LABEL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // BoundedLabels display left aligned text up to a maximum number of lines, with | 28 // BoundedLabels display left aligned text up to a maximum number of lines, with |
| 29 // ellipsis at the end of the last line for any omitted text. BoundedLabel is a | 29 // ellipsis at the end of the last line for any omitted text. BoundedLabel is a |
| 30 // direct subclass of views::Views rather than a subclass of views::Label | 30 // direct subclass of views::Views rather than a subclass of views::Label |
| 31 // to avoid exposing some of views::Label's methods that can't be made to work | 31 // to avoid exposing some of views::Label's methods that can't be made to work |
| 32 // with BoundedLabel. See the description of InnerBoundedLabel in the | 32 // with BoundedLabel. See the description of InnerBoundedLabel in the |
| 33 // bounded_label.cc file for details. | 33 // bounded_label.cc file for details. |
| 34 class MESSAGE_CENTER_EXPORT BoundedLabel : public views::View { | 34 class MESSAGE_CENTER_EXPORT BoundedLabel : public views::View { |
| 35 public: | 35 public: |
| 36 BoundedLabel(const base::string16& text, const gfx::FontList& font_list); | 36 BoundedLabel(const base::string16& text, const gfx::FontList& font_list); |
| 37 BoundedLabel(const base::string16& text); | 37 BoundedLabel(const base::string16& text); |
| 38 virtual ~BoundedLabel(); | 38 ~BoundedLabel() override; |
| 39 | 39 |
| 40 void SetColors(SkColor textColor, SkColor backgroundColor); | 40 void SetColors(SkColor textColor, SkColor backgroundColor); |
| 41 void SetLineHeight(int height); // Pass in 0 for default height. | 41 void SetLineHeight(int height); // Pass in 0 for default height. |
| 42 void SetLineLimit(int lines); // Pass in -1 for no limit. | 42 void SetLineLimit(int lines); // Pass in -1 for no limit. |
| 43 void SetText(const base::string16& text); // Additionally clears caches. | 43 void SetText(const base::string16& text); // Additionally clears caches. |
| 44 | 44 |
| 45 int GetLineHeight() const; | 45 int GetLineHeight() const; |
| 46 int GetLineLimit() const; | 46 int GetLineLimit() const; |
| 47 | 47 |
| 48 // Pass in a -1 width to use the preferred width, a -1 limit to skip limits. | 48 // Pass in a -1 width to use the preferred width, a -1 limit to skip limits. |
| 49 int GetLinesForWidthAndLimit(int width, int limit); | 49 int GetLinesForWidthAndLimit(int width, int limit); |
| 50 gfx::Size GetSizeForWidthAndLines(int width, int lines); | 50 gfx::Size GetSizeForWidthAndLines(int width, int lines); |
| 51 | 51 |
| 52 // views::View: | 52 // views::View: |
| 53 virtual int GetBaseline() const override; | 53 int GetBaseline() const override; |
| 54 virtual gfx::Size GetPreferredSize() const override; | 54 gfx::Size GetPreferredSize() const override; |
| 55 virtual int GetHeightForWidth(int width) const override; | 55 int GetHeightForWidth(int width) const override; |
| 56 virtual void Paint(gfx::Canvas* canvas, | 56 void Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) override; |
| 57 const views::CullSet& cull_set) override; | 57 bool CanProcessEventsWithinSubtree() const override; |
| 58 virtual bool CanProcessEventsWithinSubtree() const override; | 58 void GetAccessibleState(ui::AXViewState* state) override; |
| 59 virtual void GetAccessibleState(ui::AXViewState* state) override; | |
| 60 | 59 |
| 61 protected: | 60 protected: |
| 62 // Overridden from views::View. | 61 // Overridden from views::View. |
| 63 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 62 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 64 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 63 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 65 | 64 |
| 66 private: | 65 private: |
| 67 friend class test::BoundedLabelTest; | 66 friend class test::BoundedLabelTest; |
| 68 | 67 |
| 69 base::string16 GetWrappedTextForTest(int width, int lines); | 68 base::string16 GetWrappedTextForTest(int width, int lines); |
| 70 | 69 |
| 71 scoped_ptr<InnerBoundedLabel> label_; | 70 scoped_ptr<InnerBoundedLabel> label_; |
| 72 int line_limit_; | 71 int line_limit_; |
| 73 | 72 |
| 74 DISALLOW_COPY_AND_ASSIGN(BoundedLabel); | 73 DISALLOW_COPY_AND_ASSIGN(BoundedLabel); |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 } // namespace message_center | 76 } // namespace message_center |
| 78 | 77 |
| 79 #endif // UI_MESSAGE_CENTER_BOUNDED_LABEL_H_ | 78 #endif // UI_MESSAGE_CENTER_BOUNDED_LABEL_H_ |
| OLD | NEW |