Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / views / autofill / decorated_textfield.h
blobb16c4ea393c4b6e3f80cfc95b288e75ea9fa75a3
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 CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_
8 #include "base/strings/string16.h"
9 #include "ui/gfx/image/image.h"
10 #include "ui/views/controls/textfield/textfield.h"
12 namespace views {
13 class FocusableBorder;
14 class TextfieldController;
17 namespace autofill {
19 // A class which holds a textfield and draws extra stuff on top, like
20 // invalid content indications.
21 class DecoratedTextfield : public views::Textfield {
22 public:
23 static const char kViewClassName[];
25 DecoratedTextfield(const base::string16& default_value,
26 const base::string16& placeholder,
27 views::TextfieldController* controller);
28 virtual ~DecoratedTextfield();
30 // Sets whether to indicate the textfield has invalid content.
31 void SetInvalid(bool invalid);
32 bool invalid() const { return invalid_; }
34 // Sets the icon to be displayed inside the textfield at the end of the
35 // text.
36 void SetIcon(const gfx::Image& icon);
38 // views::View implementation.
39 virtual const char* GetClassName() const OVERRIDE;
40 virtual gfx::Size GetPreferredSize() OVERRIDE;
41 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
42 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
44 private:
45 FRIEND_TEST_ALL_PREFIXES(DecoratedTextfieldTest, HeightMatchesButton);
47 // This number corresponds to the number of pixels in the images that
48 // are used to draw a views button which are above or below the actual border.
49 // This number is encoded in the button assets themselves, so there's no other
50 // way to get it than to hardcode it here.
51 static const int kMagicInsetNumber;
53 // We draw the border.
54 views::FocusableBorder* border_; // Weak.
56 // The icon that goes at the right side of the textfield.
57 gfx::Image icon_;
59 // Whether the text contents are "invalid" (i.e. should special markers be
60 // shown to indicate invalidness).
61 bool invalid_;
63 DISALLOW_COPY_AND_ASSIGN(DecoratedTextfield);
66 } // namespace autofill
68 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_