gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / ui / message_center / views / bounded_label.h
blob6d97c8850ccc7f3e449369767554b4012213646f
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
3 // found in the LICENSE file.
5 #ifndef UI_MESSAGE_CENTER_BOUNDED_LABEL_H_
6 #define UI_MESSAGE_CENTER_BOUNDED_LABEL_H_
8 #include <list>
9 #include <map>
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/message_center/message_center_export.h"
14 #include "ui/views/view.h"
16 namespace gfx {
17 class Font;
20 namespace message_center {
22 class InnerBoundedLabel;
24 namespace test {
25 class BoundedLabelTest;
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
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
32 // with BoundedLabel. See the description of InnerBoundedLabel in the
33 // bounded_label.cc file for details.
34 class MESSAGE_CENTER_EXPORT BoundedLabel : public views::View {
35 public:
36 BoundedLabel(const string16& text, gfx::Font font);
37 BoundedLabel(const string16& text);
38 virtual ~BoundedLabel();
40 void SetColors(SkColor textColor, SkColor backgroundColor);
41 void SetLineHeight(int height); // Pass in 0 for default height.
42 void SetLineLimit(int lines); // Pass in -1 for no limit.
44 int GetLineHeight() const;
45 int GetLineLimit() const;
47 // Pass in a -1 width to use the preferred width, a -1 limit to skip limits.
48 int GetLinesForWidthAndLimit(int width, int limit);
49 gfx::Size GetSizeForWidthAndLines(int width, int lines);
51 // Overridden from views::View.
52 virtual int GetBaseline() const OVERRIDE;
53 virtual gfx::Size GetPreferredSize() OVERRIDE;
54 virtual int GetHeightForWidth(int width) OVERRIDE;
55 virtual void Paint(gfx::Canvas* canvas) OVERRIDE;
56 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
57 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
59 protected:
60 // Overridden from views::View.
61 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
62 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
64 private:
65 friend class test::BoundedLabelTest;
67 string16 GetWrappedTextForTest(int width, int lines);
69 scoped_ptr<InnerBoundedLabel> label_;
70 int line_limit_;
72 DISALLOW_COPY_AND_ASSIGN(BoundedLabel);
75 } // namespace message_center
77 #endif // UI_MESSAGE_CENTER_BOUNDED_LABEL_H_