OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_EXAMPLES_KEYBOARD_KEYBOARD_VIEW_H_ | 5 #ifndef MOJO_EXAMPLES_KEYBOARD_KEYBOARD_VIEW_H_ |
6 #define MOJO_EXAMPLES_KEYBOARD_KEYBOARD_VIEW_H_ | 6 #define MOJO_EXAMPLES_KEYBOARD_KEYBOARD_VIEW_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/macros.h" |
10 #include "ui/gfx/font_list.h" | 11 #include "ui/gfx/font_list.h" |
11 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 class LabelButton; | 16 class LabelButton; |
16 } | 17 } |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
19 namespace examples { | 20 namespace examples { |
20 | 21 |
21 class KeyboardDelegate; | 22 class KeyboardDelegate; |
22 struct Key; | 23 struct Key; |
23 struct Row; | 24 struct Row; |
24 | 25 |
25 // Shows a keyboard the user can interact with. The delegate is notified any | 26 // Shows a keyboard the user can interact with. The delegate is notified any |
26 // time the user presses a button. | 27 // time the user presses a button. |
27 class KeyboardView : public views::View, public views::ButtonListener { | 28 class KeyboardView : public views::View, public views::ButtonListener { |
28 public: | 29 public: |
29 explicit KeyboardView(KeyboardDelegate* delegate); | 30 explicit KeyboardView(KeyboardDelegate* delegate); |
30 virtual ~KeyboardView(); | 31 virtual ~KeyboardView(); |
31 | 32 |
32 // views::View: | 33 // views::View: |
33 virtual void Layout() OVERRIDE; | 34 virtual void Layout() override; |
34 | 35 |
35 private: | 36 private: |
36 // The type of keys that are shown. | 37 // The type of keys that are shown. |
37 enum KeyboardLayout { | 38 enum KeyboardLayout { |
38 KEYBOARD_LAYOUT_ALPHA, | 39 KEYBOARD_LAYOUT_ALPHA, |
39 | 40 |
40 // Uppercase characters. | 41 // Uppercase characters. |
41 KEYBOARD_LAYOUT_SHIFT, | 42 KEYBOARD_LAYOUT_SHIFT, |
42 | 43 |
43 // Numeric characters. | 44 // Numeric characters. |
(...skipping 28 matching lines...) Expand all Loading... |
72 | 73 |
73 const Key& GetKeyForButton(views::Button* button) const; | 74 const Key& GetKeyForButton(views::Button* button) const; |
74 | 75 |
75 // Reset the fonts of all the buttons. |special_font| is used for the buttons | 76 // Reset the fonts of all the buttons. |special_font| is used for the buttons |
76 // that toggle the layout. | 77 // that toggle the layout. |
77 void ResetFonts(const gfx::FontList& button_font, | 78 void ResetFonts(const gfx::FontList& button_font, |
78 const gfx::FontList& special_font); | 79 const gfx::FontList& special_font); |
79 | 80 |
80 // views::ButtonListener: | 81 // views::ButtonListener: |
81 virtual void ButtonPressed(views::Button* sender, | 82 virtual void ButtonPressed(views::Button* sender, |
82 const ui::Event& event) OVERRIDE; | 83 const ui::Event& event) override; |
83 | 84 |
84 KeyboardDelegate* delegate_; | 85 KeyboardDelegate* delegate_; |
85 | 86 |
86 // Maximium number of keys in a row. Determined from |rows_|. | 87 // Maximium number of keys in a row. Determined from |rows_|. |
87 int max_keys_in_row_; | 88 int max_keys_in_row_; |
88 | 89 |
89 KeyboardLayout keyboard_layout_; | 90 KeyboardLayout keyboard_layout_; |
90 | 91 |
91 std::vector<const Row*> rows_; | 92 std::vector<const Row*> rows_; |
92 | 93 |
93 gfx::Size last_layout_size_; | 94 gfx::Size last_layout_size_; |
94 | 95 |
95 gfx::FontList button_font_; | 96 gfx::FontList button_font_; |
96 | 97 |
97 DISALLOW_COPY_AND_ASSIGN(KeyboardView); | 98 DISALLOW_COPY_AND_ASSIGN(KeyboardView); |
98 }; | 99 }; |
99 | 100 |
100 } // namespace examples | 101 } // namespace examples |
101 } // namespace mojo | 102 } // namespace mojo |
102 | 103 |
103 #endif // MOJO_EXAMPLES_KEYBOARD_KEYBOARD_VIEW_H_ | 104 #endif // MOJO_EXAMPLES_KEYBOARD_KEYBOARD_VIEW_H_ |
OLD | NEW |