| 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_NATIVE_COMBOBOX_VIEWS_H_ | 5 #ifndef UI_VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_VIEWS_H_ |
| 6 #define UI_VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_VIEWS_H_ | 6 #define UI_VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_VIEWS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ui/views/controls/combobox/native_combobox_wrapper.h" | 9 #include "ui/views/controls/combobox/native_combobox_wrapper.h" |
| 10 #include "ui/views/controls/menu/menu_delegate.h" | 10 #include "ui/views/controls/menu/menu_delegate.h" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class Canvas; | 14 class CanvasSkia; |
| 15 class Font; | 15 class Font; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 class KeyEvent; | 20 class KeyEvent; |
| 21 class FocusableBorder; | 21 class FocusableBorder; |
| 22 class MenuRunner; | 22 class MenuRunner; |
| 23 | 23 |
| 24 // A views/skia only implementation of NativeComboboxWrapper. | 24 // A views/skia only implementation of NativeComboboxWrapper. |
| 25 // No platform specific code is used. | 25 // No platform specific code is used. |
| 26 class NativeComboboxViews : public views::View, | 26 class NativeComboboxViews : public views::View, |
| 27 public NativeComboboxWrapper, | 27 public NativeComboboxWrapper, |
| 28 public views::MenuDelegate { | 28 public views::MenuDelegate { |
| 29 public: | 29 public: |
| 30 explicit NativeComboboxViews(Combobox* parent); | 30 explicit NativeComboboxViews(Combobox* parent); |
| 31 virtual ~NativeComboboxViews(); | 31 virtual ~NativeComboboxViews(); |
| 32 | 32 |
| 33 // views::View overrides: | 33 // views::View overrides: |
| 34 virtual bool OnMousePressed(const views::MouseEvent& mouse_event) OVERRIDE; | 34 virtual bool OnMousePressed(const views::MouseEvent& mouse_event) OVERRIDE; |
| 35 virtual bool OnMouseDragged(const views::MouseEvent& mouse_event) OVERRIDE; | 35 virtual bool OnMouseDragged(const views::MouseEvent& mouse_event) OVERRIDE; |
| 36 virtual bool OnKeyPressed(const views::KeyEvent& key_event) OVERRIDE; | 36 virtual bool OnKeyPressed(const views::KeyEvent& key_event) OVERRIDE; |
| 37 virtual bool OnKeyReleased(const views::KeyEvent& key_event) OVERRIDE; | 37 virtual bool OnKeyReleased(const views::KeyEvent& key_event) OVERRIDE; |
| 38 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 38 virtual void OnPaint(gfx::CanvasSkia* canvas) OVERRIDE; |
| 39 virtual void OnFocus() OVERRIDE; | 39 virtual void OnFocus() OVERRIDE; |
| 40 virtual void OnBlur() OVERRIDE; | 40 virtual void OnBlur() OVERRIDE; |
| 41 | 41 |
| 42 // NativeComboboxWrapper overrides: | 42 // NativeComboboxWrapper overrides: |
| 43 virtual void UpdateFromModel() OVERRIDE; | 43 virtual void UpdateFromModel() OVERRIDE; |
| 44 virtual void UpdateSelectedItem() OVERRIDE; | 44 virtual void UpdateSelectedItem() OVERRIDE; |
| 45 virtual void UpdateEnabled() OVERRIDE; | 45 virtual void UpdateEnabled() OVERRIDE; |
| 46 virtual int GetSelectedItem() const OVERRIDE; | 46 virtual int GetSelectedItem() const OVERRIDE; |
| 47 virtual bool IsDropdownOpen() const OVERRIDE; | 47 virtual bool IsDropdownOpen() const OVERRIDE; |
| 48 virtual gfx::Size GetPreferredSize() OVERRIDE; | 48 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // Returns the Combobox's font. | 67 // Returns the Combobox's font. |
| 68 const gfx::Font& GetFont() const; | 68 const gfx::Font& GetFont() const; |
| 69 | 69 |
| 70 // Given bounds within our View, this helper routine mirrors the bounds if | 70 // Given bounds within our View, this helper routine mirrors the bounds if |
| 71 // necessary. | 71 // necessary. |
| 72 void AdjustBoundsForRTLUI(gfx::Rect* rect) const; | 72 void AdjustBoundsForRTLUI(gfx::Rect* rect) const; |
| 73 | 73 |
| 74 // Draw the selected value of the drop down list | 74 // Draw the selected value of the drop down list |
| 75 void PaintText(gfx::Canvas* canvas); | 75 void PaintText(gfx::CanvasSkia* canvas); |
| 76 | 76 |
| 77 // Show the drop down list | 77 // Show the drop down list |
| 78 void ShowDropDownMenu(); | 78 void ShowDropDownMenu(); |
| 79 | 79 |
| 80 // The parent combobox, the owner of this object. | 80 // The parent combobox, the owner of this object. |
| 81 Combobox* combobox_; | 81 Combobox* combobox_; |
| 82 | 82 |
| 83 // The reference to the border class. The object is owned by View::border_. | 83 // The reference to the border class. The object is owned by View::border_. |
| 84 FocusableBorder* text_border_; | 84 FocusableBorder* text_border_; |
| 85 | 85 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 98 // The maximum dimensions of the content in the dropdown | 98 // The maximum dimensions of the content in the dropdown |
| 99 int content_width_; | 99 int content_width_; |
| 100 int content_height_; | 100 int content_height_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(NativeComboboxViews); | 102 DISALLOW_COPY_AND_ASSIGN(NativeComboboxViews); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace views | 105 } // namespace views |
| 106 | 106 |
| 107 #endif // UI_VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_VIEWS_H_ | 107 #endif // UI_VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_VIEWS_H_ |
| OLD | NEW |