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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after 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() OVERRIDE; | 96 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
97 virtual const char* GetClassName() const OVERRIDE; | 97 virtual const char* GetClassName() const OVERRIDE; |
98 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; | 98 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; |
99 virtual bool OnKeyPressed(const ui::KeyEvent& e) OVERRIDE; | 99 virtual bool OnKeyPressed(const ui::KeyEvent& e) OVERRIDE; |
100 virtual bool OnKeyReleased(const ui::KeyEvent& e) OVERRIDE; | 100 virtual bool OnKeyReleased(const ui::KeyEvent& e) OVERRIDE; |
101 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 101 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
102 virtual void OnFocus() OVERRIDE; | 102 virtual void OnFocus() OVERRIDE; |
103 virtual void OnBlur() OVERRIDE; | 103 virtual void OnBlur() OVERRIDE; |
104 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 104 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
105 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; | 105 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; |
106 virtual void Layout() OVERRIDE; | 106 virtual void Layout() OVERRIDE; |
107 | 107 |
108 // Overridden from MenuDelegate: | 108 // Overridden from MenuDelegate: |
109 virtual bool IsItemChecked(int id) const OVERRIDE; | 109 virtual bool IsItemChecked(int id) const OVERRIDE; |
110 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 110 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
111 virtual void ExecuteCommand(int id) OVERRIDE; | 111 virtual void ExecuteCommand(int id) OVERRIDE; |
112 virtual bool GetAccelerator(int id, ui::Accelerator* accelerator) OVERRIDE; | 112 virtual bool GetAccelerator(int id, |
| 113 ui::Accelerator* accelerator) const OVERRIDE; |
113 | 114 |
114 // Overridden from PrefixDelegate: | 115 // Overridden from PrefixDelegate: |
115 virtual int GetRowCount() OVERRIDE; | 116 virtual int GetRowCount() OVERRIDE; |
116 virtual int GetSelectedRow() OVERRIDE; | 117 virtual int GetSelectedRow() OVERRIDE; |
117 virtual void SetSelectedRow(int row) OVERRIDE; | 118 virtual void SetSelectedRow(int row) OVERRIDE; |
118 virtual base::string16 GetTextForRow(int row) OVERRIDE; | 119 virtual base::string16 GetTextForRow(int row) OVERRIDE; |
119 | 120 |
120 // Overriden from ComboboxModelObserver: | 121 // Overriden from ComboboxModelObserver: |
121 virtual void OnComboboxModelChanged(ui::ComboboxModel* model) OVERRIDE; | 122 virtual void OnComboboxModelChanged(ui::ComboboxModel* model) OVERRIDE; |
122 | 123 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 194 |
194 // Like MenuButton, we use a time object in order to keep track of when the | 195 // Like MenuButton, we use a time object in order to keep track of when the |
195 // combobox was closed. The time is used for simulating menu behavior; that | 196 // combobox was closed. The time is used for simulating menu behavior; that |
196 // is, if the menu is shown and the button is pressed, we need to close the | 197 // is, if the menu is shown and the button is pressed, we need to close the |
197 // menu. There is no clean way to get the second click event because the | 198 // menu. There is no clean way to get the second click event because the |
198 // menu is displayed using a modal loop and, unlike regular menus in Windows, | 199 // menu is displayed using a modal loop and, unlike regular menus in Windows, |
199 // the button is not part of the displayed menu. | 200 // the button is not part of the displayed menu. |
200 base::Time closed_time_; | 201 base::Time closed_time_; |
201 | 202 |
202 // The maximum dimensions of the content in the dropdown | 203 // The maximum dimensions of the content in the dropdown |
203 gfx::Size content_size_; | 204 mutable gfx::Size content_size_; |
204 | 205 |
205 // The painters or images that are used when |style_| is STYLE_BUTTONS. The | 206 // The painters or images that are used when |style_| is STYLE_BUTTONS. The |
206 // first index means the state of unfocused or focused. | 207 // first index means the state of unfocused or focused. |
207 // The images are owned by ResourceBundle. | 208 // The images are owned by ResourceBundle. |
208 scoped_ptr<Painter> body_button_painters_[2][Button::STATE_COUNT]; | 209 scoped_ptr<Painter> body_button_painters_[2][Button::STATE_COUNT]; |
209 std::vector<const gfx::ImageSkia*> | 210 std::vector<const gfx::ImageSkia*> |
210 menu_button_images_[2][Button::STATE_COUNT]; | 211 menu_button_images_[2][Button::STATE_COUNT]; |
211 | 212 |
212 // The transparent buttons to handle events and render buttons. These are | 213 // The transparent buttons to handle events and render buttons. These are |
213 // placed on top of this combobox as child views, accept event and manage the | 214 // placed on top of this combobox as child views, accept event and manage the |
214 // button states. These are not rendered but when |style_| is | 215 // button states. These are not rendered but when |style_| is |
215 // STYLE_NOTIFY_ON_CLICK, a Combobox renders the button images according to | 216 // STYLE_NOTIFY_ON_CLICK, a Combobox renders the button images according to |
216 // these button states. | 217 // these button states. |
217 // The base View takes the ownerships of these as child views. | 218 // The base View takes the ownerships of these as child views. |
218 CustomButton* text_button_; | 219 CustomButton* text_button_; |
219 CustomButton* arrow_button_; | 220 CustomButton* arrow_button_; |
220 | 221 |
221 // Used for making calbacks. | 222 // Used for making calbacks. |
222 base::WeakPtrFactory<Combobox> weak_ptr_factory_; | 223 base::WeakPtrFactory<Combobox> weak_ptr_factory_; |
223 | 224 |
224 DISALLOW_COPY_AND_ASSIGN(Combobox); | 225 DISALLOW_COPY_AND_ASSIGN(Combobox); |
225 }; | 226 }; |
226 | 227 |
227 } // namespace views | 228 } // namespace views |
228 | 229 |
229 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 230 #endif // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ |
OLD | NEW |