| 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/time/time.h" | 10 #include "base/time/time.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29 class ComboboxListener; | 29 class ComboboxListener; | 
| 30 class ComboboxMenuRunner; | 30 class ComboboxMenuRunner; | 
| 31 class CustomButton; | 31 class CustomButton; | 
| 32 class FocusableBorder; | 32 class FocusableBorder; | 
| 33 class MenuRunner; | 33 class MenuRunner; | 
| 34 class MenuRunnerHandler; | 34 class MenuRunnerHandler; | 
| 35 class Painter; | 35 class Painter; | 
| 36 class PrefixSelector; | 36 class PrefixSelector; | 
| 37 | 37 | 
| 38 // A non-editable combobox (aka a drop-down list or selector). | 38 // A non-editable combobox (aka a drop-down list or selector). | 
| 39 // Combobox has two distinct parts, the drop down arrow and the text. When the | 39 // Combobox has two distinct parts, the drop down arrow and the text. Combobox | 
| 40 // user clicks on the text the drop down is either shown | 40 // offers two distinct behaviors: | 
| 41 // (STYLE_SHOW_DROP_DOWN_ON_CLICK) or the listener is notified | 41 // * STYLE_NORMAL: typical combobox, clicking on the text and/or button shows | 
| 42 // (STYLE_NOTIFY_ON_CLICK). | 42 // the drop down, arrow keys change selection, selected index can be changed by | 
|  | 43 // the user to something other than the first item. | 
|  | 44 // * STYLE_ACTION: clicking on the text notifies the listener. The menu can be | 
|  | 45 // shown only by clicking on the arrow. The selected index is always reverted to | 
|  | 46 // 0 after the listener is notified. | 
| 43 class VIEWS_EXPORT Combobox : public MenuDelegate, | 47 class VIEWS_EXPORT Combobox : public MenuDelegate, | 
| 44                               public PrefixDelegate, | 48                               public PrefixDelegate, | 
| 45                               public ui::ComboboxModelObserver, | 49                               public ui::ComboboxModelObserver, | 
| 46                               public ButtonListener { | 50                               public ButtonListener { | 
| 47  public: | 51  public: | 
| 48   // The style of the combobox. | 52   // The style of the combobox. | 
| 49   enum Style { | 53   enum Style { | 
| 50     STYLE_SHOW_DROP_DOWN_ON_CLICK, | 54     STYLE_NORMAL, | 
| 51     STYLE_NOTIFY_ON_CLICK, | 55     STYLE_ACTION, | 
| 52   }; | 56   }; | 
| 53 | 57 | 
| 54   // The combobox's class name. | 58   // The combobox's class name. | 
| 55   static const char kViewClassName[]; | 59   static const char kViewClassName[]; | 
| 56 | 60 | 
| 57   // |model| is not owned by the combobox. | 61   // |model| is not owned by the combobox. | 
| 58   explicit Combobox(ui::ComboboxModel* model); | 62   explicit Combobox(ui::ComboboxModel* model); | 
| 59   virtual ~Combobox(); | 63   virtual ~Combobox(); | 
| 60 | 64 | 
| 61   static const gfx::FontList& GetFontList(); | 65   static const gfx::FontList& GetFontList(); | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 114 | 118 | 
| 115   // Overriden from ComboboxModelObserver: | 119   // Overriden from ComboboxModelObserver: | 
| 116   virtual void OnComboboxModelChanged(ui::ComboboxModel* model) OVERRIDE; | 120   virtual void OnComboboxModelChanged(ui::ComboboxModel* model) OVERRIDE; | 
| 117 | 121 | 
| 118   // Overriden from ButtonListener: | 122   // Overriden from ButtonListener: | 
| 119   virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; | 123   virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; | 
| 120 | 124 | 
| 121  private: | 125  private: | 
| 122   FRIEND_TEST_ALL_PREFIXES(ComboboxTest, Click); | 126   FRIEND_TEST_ALL_PREFIXES(ComboboxTest, Click); | 
| 123   FRIEND_TEST_ALL_PREFIXES(ComboboxTest, NotifyOnClickWithMouse); | 127   FRIEND_TEST_ALL_PREFIXES(ComboboxTest, NotifyOnClickWithMouse); | 
|  | 128   FRIEND_TEST_ALL_PREFIXES(ComboboxTest, ContentWidth); | 
| 124 | 129 | 
| 125   // Updates the combobox's content from its model. | 130   // Updates the combobox's content from its model. | 
| 126   void UpdateFromModel(); | 131   void UpdateFromModel(); | 
| 127 | 132 | 
| 128   // Updates the border according to the current state. | 133   // Updates the border according to the current state. | 
| 129   void UpdateBorder(); | 134   void UpdateBorder(); | 
| 130 | 135 | 
| 131   // Given bounds within our View, this helper mirrors the bounds if necessary. | 136   // Given bounds within our View, this helper mirrors the bounds if necessary. | 
| 132   void AdjustBoundsForRTLUI(gfx::Rect* rect) const; | 137   void AdjustBoundsForRTLUI(gfx::Rect* rect) const; | 
| 133 | 138 | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 208   // The base View takes the ownerships of these as child views. | 213   // The base View takes the ownerships of these as child views. | 
| 209   CustomButton* text_button_; | 214   CustomButton* text_button_; | 
| 210   CustomButton* arrow_button_; | 215   CustomButton* arrow_button_; | 
| 211 | 216 | 
| 212   DISALLOW_COPY_AND_ASSIGN(Combobox); | 217   DISALLOW_COPY_AND_ASSIGN(Combobox); | 
| 213 }; | 218 }; | 
| 214 | 219 | 
| 215 }  // namespace views | 220 }  // namespace views | 
| 216 | 221 | 
| 217 #endif  // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 222 #endif  // UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ | 
| OLD | NEW | 
|---|