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 #include "chrome/browser/chromeos/login/textfield_with_margin.h" | 5 #include "chrome/browser/chromeos/login/textfield_with_margin.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/login/helper.h" | 7 #include "chrome/browser/chromeos/login/helper.h" |
| 8 #include "ui/base/event.h" |
8 #include "ui/base/keycodes/keyboard_codes.h" | 9 #include "ui/base/keycodes/keyboard_codes.h" |
9 | 10 |
10 namespace { | 11 namespace { |
11 | 12 |
12 // Holds ratio of the margin to the preferred text height. | 13 // Holds ratio of the margin to the preferred text height. |
13 const double kTextMarginRate = 0.33; | 14 const double kTextMarginRate = 0.33; |
14 | 15 |
15 // Size of each vertical margin (top, bottom). | 16 // Size of each vertical margin (top, bottom). |
16 const int kVerticalMargin = 3; | 17 const int kVerticalMargin = 3; |
17 | 18 |
(...skipping 10 matching lines...) Expand all Loading... |
28 CorrectTextfieldFontSize(this); | 29 CorrectTextfieldFontSize(this); |
29 } | 30 } |
30 | 31 |
31 void TextfieldWithMargin::Layout() { | 32 void TextfieldWithMargin::Layout() { |
32 int margin = GetPreferredSize().height() * kTextMarginRate; | 33 int margin = GetPreferredSize().height() * kTextMarginRate; |
33 SetHorizontalMargins(margin, margin); | 34 SetHorizontalMargins(margin, margin); |
34 SetVerticalMargins(kVerticalMargin, kVerticalMargin); | 35 SetVerticalMargins(kVerticalMargin, kVerticalMargin); |
35 views::Textfield::Layout(); | 36 views::Textfield::Layout(); |
36 } | 37 } |
37 | 38 |
38 bool TextfieldWithMargin::OnKeyPressed(const views::KeyEvent& e) { | 39 bool TextfieldWithMargin::OnKeyPressed(const ui::KeyEvent& e) { |
39 if (e.key_code() == ui::VKEY_ESCAPE && !text().empty()) { | 40 if (e.key_code() == ui::VKEY_ESCAPE && !text().empty()) { |
40 SetText(string16()); | 41 SetText(string16()); |
41 return true; | 42 return true; |
42 } | 43 } |
43 return views::Textfield::OnKeyPressed(e); | 44 return views::Textfield::OnKeyPressed(e); |
44 } | 45 } |
45 | 46 |
46 } // namespace chromeos | 47 } // namespace chromeos |
OLD | NEW |