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 #include "ui/views/controls/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "grit/ui_resources.h" | 11 #include "grit/ui_resources.h" |
12 #include "ui/accessibility/ax_view_state.h" | 12 #include "ui/accessibility/ax_view_state.h" |
13 #include "ui/base/models/combobox_model.h" | 13 #include "ui/base/models/combobox_model.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
16 #include "ui/events/keycodes/keyboard_codes.h" | 16 #include "ui/events/keycodes/keyboard_codes.h" |
17 #include "ui/gfx/animation/throb_animation.h" | 17 #include "ui/gfx/animation/throb_animation.h" |
18 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
20 #include "ui/gfx/scoped_canvas.h" | 20 #include "ui/gfx/scoped_canvas.h" |
21 #include "ui/gfx/text_utils.h" | 21 #include "ui/gfx/text_utils.h" |
22 #include "ui/native_theme/native_theme.h" | 22 #include "ui/native_theme/native_theme.h" |
23 #include "ui/views/background.h" | 23 #include "ui/views/background.h" |
24 #include "ui/views/color_constants.h" | 24 #include "ui/views/color_constants.h" |
25 #include "ui/views/controls/button/custom_button.h" | 25 #include "ui/views/controls/button/custom_button.h" |
26 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/label_button.h" |
27 #include "ui/views/controls/combobox/combobox_listener.h" | 27 #include "ui/views/controls/combobox/combobox_listener.h" |
28 #include "ui/views/controls/focusable_border.h" | 28 #include "ui/views/controls/focusable_border.h" |
| 29 #include "ui/views/controls/menu/menu_item_view.h" |
29 #include "ui/views/controls/menu/menu_runner.h" | 30 #include "ui/views/controls/menu/menu_runner.h" |
30 #include "ui/views/controls/menu/menu_runner_handler.h" | 31 #include "ui/views/controls/menu/menu_runner_handler.h" |
31 #include "ui/views/controls/menu/submenu_view.h" | 32 #include "ui/views/controls/menu/submenu_view.h" |
32 #include "ui/views/controls/prefix_selector.h" | 33 #include "ui/views/controls/prefix_selector.h" |
33 #include "ui/views/ime/input_method.h" | 34 #include "ui/views/ime/input_method.h" |
34 #include "ui/views/mouse_constants.h" | 35 #include "ui/views/mouse_constants.h" |
35 #include "ui/views/painter.h" | 36 #include "ui/views/painter.h" |
36 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
37 | 38 |
38 namespace views { | 39 namespace views { |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 menu_position.set_x(0); | 763 menu_position.set_x(0); |
763 | 764 |
764 gfx::Rect bounds(menu_position, lb.size()); | 765 gfx::Rect bounds(menu_position, lb.size()); |
765 | 766 |
766 Button::ButtonState original_state = Button::STATE_NORMAL; | 767 Button::ButtonState original_state = Button::STATE_NORMAL; |
767 if (arrow_button_) { | 768 if (arrow_button_) { |
768 original_state = arrow_button_->state(); | 769 original_state = arrow_button_->state(); |
769 arrow_button_->SetState(Button::STATE_PRESSED); | 770 arrow_button_->SetState(Button::STATE_PRESSED); |
770 } | 771 } |
771 dropdown_open_ = true; | 772 dropdown_open_ = true; |
772 MenuItemView::AnchorPosition anchor_position = | 773 MenuAnchorPosition anchor_position = |
773 style_ == STYLE_ACTION ? MenuItemView::TOPRIGHT : MenuItemView::TOPLEFT; | 774 style_ == STYLE_ACTION ? MENU_ANCHOR_TOPRIGHT : MENU_ANCHOR_TOPLEFT; |
774 if (dropdown_list_menu_runner_->RunMenuAt(GetWidget(), NULL, bounds, | 775 if (dropdown_list_menu_runner_->RunMenuAt(GetWidget(), NULL, bounds, |
775 anchor_position, source_type, | 776 anchor_position, source_type, |
776 MenuRunner::COMBOBOX) == | 777 MenuRunner::COMBOBOX) == |
777 MenuRunner::MENU_DELETED) { | 778 MenuRunner::MENU_DELETED) { |
778 return; | 779 return; |
779 } | 780 } |
780 dropdown_open_ = false; | 781 dropdown_open_ = false; |
781 if (arrow_button_) | 782 if (arrow_button_) |
782 arrow_button_->SetState(original_state); | 783 arrow_button_->SetState(original_state); |
783 closed_time_ = base::Time::Now(); | 784 closed_time_ = base::Time::Now(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 case STYLE_NORMAL: | 826 case STYLE_NORMAL: |
826 return kDisclosureArrowRightPadding; | 827 return kDisclosureArrowRightPadding; |
827 case STYLE_ACTION: | 828 case STYLE_ACTION: |
828 return kDisclosureArrowButtonRightPadding; | 829 return kDisclosureArrowButtonRightPadding; |
829 } | 830 } |
830 NOTREACHED(); | 831 NOTREACHED(); |
831 return 0; | 832 return 0; |
832 } | 833 } |
833 | 834 |
834 } // namespace views | 835 } // namespace views |
OLD | NEW |