diff options
Diffstat (limited to 'chromium/ui/views/controls/combobox/combobox.h')
-rw-r--r-- | chromium/ui/views/controls/combobox/combobox.h | 65 |
1 files changed, 9 insertions, 56 deletions
diff --git a/chromium/ui/views/controls/combobox/combobox.h b/chromium/ui/views/controls/combobox/combobox.h index d6132543edd..9f86b4619e5 100644 --- a/chromium/ui/views/controls/combobox/combobox.h +++ b/chromium/ui/views/controls/combobox/combobox.h @@ -6,12 +6,9 @@ #define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ #include "base/macros.h" -#include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "base/time/time.h" -#include "ui/base/models/combobox_model.h" #include "ui/views/controls/button/button.h" -#include "ui/views/controls/focus_ring.h" #include "ui/views/controls/prefix_delegate.h" namespace gfx { @@ -19,6 +16,7 @@ class FontList; } namespace ui { +class ComboboxModel; class MenuModel; } @@ -28,40 +26,23 @@ class ComboboxTestApi; } class ComboboxListener; -class Button; +class FocusRing; class MenuRunner; -class Painter; class PrefixSelector; // A non-editable combobox (aka a drop-down list or selector). -// Combobox has two distinct parts, the drop down arrow and the text. Combobox -// offers two distinct behaviors: -// * STYLE_NORMAL: typical combobox, clicking on the text and/or button shows -// the drop down, arrow keys change selection or show the menu depending on -// the platform, selected index can be changed by the user to something other -// than the first item. -// * STYLE_ACTION: clicking on the text notifies the listener. The menu can be -// shown only by clicking on the arrow, except on Mac where it can be shown -// through the keyboard. The selected index is always reverted to 0 after the -// listener is notified. +// Combobox has two distinct parts, the drop down arrow and the text. class VIEWS_EXPORT Combobox : public View, public PrefixDelegate, public ButtonListener { public: - // The style of the combobox. - enum Style { - STYLE_NORMAL, - STYLE_ACTION, - }; - // The combobox's class name. static const char kViewClassName[]; // |model| is owned by the combobox when using this constructor. - explicit Combobox(std::unique_ptr<ui::ComboboxModel> model, - Style style = STYLE_NORMAL); + explicit Combobox(std::unique_ptr<ui::ComboboxModel> model); // |model| is not owned by the combobox when using this constructor. - explicit Combobox(ui::ComboboxModel* model, Style style = STYLE_NORMAL); + explicit Combobox(ui::ComboboxModel* model); ~Combobox() override; static const gfx::FontList& GetFontList(); @@ -99,7 +80,6 @@ class VIEWS_EXPORT Combobox : public View, const char* GetClassName() const override; bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) override; bool OnKeyPressed(const ui::KeyEvent& e) override; - bool OnKeyReleased(const ui::KeyEvent& e) override; void OnPaint(gfx::Canvas* canvas) override; void OnFocus() override; void OnBlur() override; @@ -136,9 +116,6 @@ class VIEWS_EXPORT Combobox : public View, // Draws the selected value of the drop down list void PaintText(gfx::Canvas* canvas); - // Draws the button images. - void PaintButtons(gfx::Canvas* canvas); - // Show the drop down list void ShowDropDownMenu(ui::MenuSourceType source_type); @@ -148,14 +125,10 @@ class VIEWS_EXPORT Combobox : public View, // Called when the selection is changed by the user. void OnPerformAction(); - int GetDisclosureArrowLeftPadding() const; - int GetDisclosureArrowRightPadding() const; - // Returns the size of the disclosure arrow. gfx::Size ArrowSize() const; - // Finds the size of the largest menu label or, for STYLE_ACTION, the size of - // the selected label. + // Finds the size of the largest menu label. gfx::Size GetContentSize() const; // Handles the clicking event. @@ -176,9 +149,6 @@ class VIEWS_EXPORT Combobox : public View, // Reference to our model, which may be owned or not. ui::ComboboxModel* model_; - // The visual style of this combobox. - const Style style_; - // Our listener. Not owned. Notified when the selected index change. ComboboxListener* listener_; @@ -208,29 +178,15 @@ class VIEWS_EXPORT Combobox : public View, // The maximum dimensions of the content in the dropdown. gfx::Size content_size_; - // The painters or images that are used when |style_| is STYLE_BUTTONS. The - // first index means the state of unfocused or focused. - // The images are owned by ResourceBundle. - std::unique_ptr<Painter> body_button_painters_[2][Button::STATE_COUNT]; - std::vector<const gfx::ImageSkia*> - menu_button_images_[2][Button::STATE_COUNT]; - - // The transparent buttons to handle events and render buttons. These are - // placed on top of this combobox as child views, accept event and manage the - // button states. These are not rendered but when |style_| is - // STYLE_NOTIFY_ON_CLICK, a Combobox renders the button images according to - // these button states. - // The base View takes the ownerships of these as child views. - Button* text_button_; + // A transparent button that handles events and holds button state. Placed on + // top of the combobox as a child view. Doesn't paint itself, but serves as a + // host for inkdrops. Button* arrow_button_; // Set while the dropdown is showing. Ensures the menu is closed if |this| is // destroyed. std::unique_ptr<MenuRunner> menu_runner_; - // The image to be drawn for this combobox's arrow. - gfx::ImageSkia arrow_image_; - // When true, the size of contents is defined by the selected label. // Otherwise, it's defined by the widest label in the menu. If this is set to // true, the parent view must relayout in ChildPreferredSizeChanged(). @@ -239,9 +195,6 @@ class VIEWS_EXPORT Combobox : public View, // The focus ring for this Combobox. std::unique_ptr<FocusRing> focus_ring_; - // Used for making calbacks. - base::WeakPtrFactory<Combobox> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(Combobox); }; |