OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 5 #ifndef UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
6 #define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 6 #define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 enum Style { | 54 enum Style { |
55 STYLE_NORMAL, | 55 STYLE_NORMAL, |
56 STYLE_ACTION, | 56 STYLE_ACTION, |
57 }; | 57 }; |
58 | 58 |
59 // The combobox's class name. | 59 // The combobox's class name. |
60 static const char kViewClassName[]; | 60 static const char kViewClassName[]; |
61 | 61 |
62 // |model| is not owned by the combobox. | 62 // |model| is not owned by the combobox. |
63 explicit Combobox(ui::ComboboxModel* model); | 63 explicit Combobox(ui::ComboboxModel* model); |
64 virtual ~Combobox(); | 64 ~Combobox() override; |
65 | 65 |
66 static const gfx::FontList& GetFontList(); | 66 static const gfx::FontList& GetFontList(); |
67 | 67 |
68 // Sets the listener which will be called when a selection has been made. | 68 // Sets the listener which will be called when a selection has been made. |
69 void set_listener(ComboboxListener* listener) { listener_ = listener; } | 69 void set_listener(ComboboxListener* listener) { listener_ = listener; } |
70 | 70 |
71 void SetStyle(Style style); | 71 void SetStyle(Style style); |
72 | 72 |
73 // Informs the combobox that its model changed. | 73 // Informs the combobox that its model changed. |
74 void ModelChanged(); | 74 void ModelChanged(); |
(...skipping 11 matching lines...) Expand all Loading... |
86 // Set the accessible name of the combobox. | 86 // Set the accessible name of the combobox. |
87 void SetAccessibleName(const base::string16& name); | 87 void SetAccessibleName(const base::string16& name); |
88 | 88 |
89 // Visually marks the combobox as having an invalid value selected. | 89 // Visually marks the combobox as having an invalid value selected. |
90 // When invalid, it paints with white text on a red background. | 90 // When invalid, it paints with white text on a red background. |
91 // Callers are responsible for restoring validity with selection changes. | 91 // Callers are responsible for restoring validity with selection changes. |
92 void SetInvalid(bool invalid); | 92 void SetInvalid(bool invalid); |
93 bool invalid() const { return invalid_; } | 93 bool invalid() const { return invalid_; } |
94 | 94 |
95 // Overridden from View: | 95 // Overridden from View: |
96 virtual gfx::Size GetPreferredSize() const override; | 96 gfx::Size GetPreferredSize() const override; |
97 virtual const char* GetClassName() const override; | 97 const char* GetClassName() const override; |
98 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) override; | 98 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) override; |
99 virtual bool OnKeyPressed(const ui::KeyEvent& e) override; | 99 bool OnKeyPressed(const ui::KeyEvent& e) override; |
100 virtual bool OnKeyReleased(const ui::KeyEvent& e) override; | 100 bool OnKeyReleased(const ui::KeyEvent& e) override; |
101 virtual void OnPaint(gfx::Canvas* canvas) override; | 101 void OnPaint(gfx::Canvas* canvas) override; |
102 virtual void OnFocus() override; | 102 void OnFocus() override; |
103 virtual void OnBlur() override; | 103 void OnBlur() override; |
104 virtual void GetAccessibleState(ui::AXViewState* state) override; | 104 void GetAccessibleState(ui::AXViewState* state) override; |
105 virtual ui::TextInputClient* GetTextInputClient() override; | 105 ui::TextInputClient* GetTextInputClient() override; |
106 virtual void Layout() override; | 106 void Layout() override; |
107 | 107 |
108 // Overridden from MenuDelegate: | 108 // Overridden from MenuDelegate: |
109 virtual bool IsItemChecked(int id) const override; | 109 bool IsItemChecked(int id) const override; |
110 virtual bool IsCommandEnabled(int id) const override; | 110 bool IsCommandEnabled(int id) const override; |
111 virtual void ExecuteCommand(int id) override; | 111 void ExecuteCommand(int id) override; |
112 virtual bool GetAccelerator(int id, | 112 bool GetAccelerator(int id, ui::Accelerator* accelerator) const override; |
113 ui::Accelerator* accelerator) const override; | |
114 | 113 |
115 // Overridden from PrefixDelegate: | 114 // Overridden from PrefixDelegate: |
116 virtual int GetRowCount() override; | 115 int GetRowCount() override; |
117 virtual int GetSelectedRow() override; | 116 int GetSelectedRow() override; |
118 virtual void SetSelectedRow(int row) override; | 117 void SetSelectedRow(int row) override; |
119 virtual base::string16 GetTextForRow(int row) override; | 118 base::string16 GetTextForRow(int row) override; |
120 | 119 |
121 // Overriden from ComboboxModelObserver: | 120 // Overriden from ComboboxModelObserver: |
122 virtual void OnComboboxModelChanged(ui::ComboboxModel* model) override; | 121 void OnComboboxModelChanged(ui::ComboboxModel* model) override; |
123 | 122 |
124 // Overriden from ButtonListener: | 123 // Overriden from ButtonListener: |
125 virtual void ButtonPressed(Button* sender, const ui::Event& event) override; | 124 void ButtonPressed(Button* sender, const ui::Event& event) override; |
126 | 125 |
127 private: | 126 private: |
128 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, Click); | 127 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, Click); |
129 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, ClickButDisabled); | 128 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, ClickButDisabled); |
130 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, NotifyOnClickWithMouse); | 129 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, NotifyOnClickWithMouse); |
131 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, ContentWidth); | 130 FRIEND_TEST_ALL_PREFIXES(ComboboxTest, ContentWidth); |
132 | 131 |
133 // Updates the combobox's content from its model. | 132 // Updates the combobox's content from its model. |
134 void UpdateFromModel(); | 133 void UpdateFromModel(); |
135 | 134 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 223 |
225 // Used for making calbacks. | 224 // Used for making calbacks. |
226 base::WeakPtrFactory<Combobox> weak_ptr_factory_; | 225 base::WeakPtrFactory<Combobox> weak_ptr_factory_; |
227 | 226 |
228 DISALLOW_COPY_AND_ASSIGN(Combobox); | 227 DISALLOW_COPY_AND_ASSIGN(Combobox); |
229 }; | 228 }; |
230 | 229 |
231 } // namespace views | 230 } // namespace views |
232 | 231 |
233 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 232 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
OLD | NEW |