| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/button/button_dropdown.h" | 5 #include "views/controls/button/button_dropdown.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "grit/app_strings.h" | 10 #include "grit/app_strings.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 // Make the button look depressed while the menu is open. | 152 // Make the button look depressed while the menu is open. |
| 153 SetState(BS_PUSHED); | 153 SetState(BS_PUSHED); |
| 154 | 154 |
| 155 // Create and run menu. Display an empty menu if model is NULL. | 155 // Create and run menu. Display an empty menu if model is NULL. |
| 156 if (model_) { | 156 if (model_) { |
| 157 MenuModelAdapter menu_delegate(model_); | 157 MenuModelAdapter menu_delegate(model_); |
| 158 MenuItemView menu(&menu_delegate); | 158 MenuItemView menu(&menu_delegate); |
| 159 menu_delegate.BuildMenu(&menu); | 159 menu_delegate.BuildMenu(&menu); |
| 160 | 160 |
| 161 menu.RunMenuAt(GetWindow()->GetNativeWindow(), NULL, | 161 menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL, |
| 162 gfx::Rect(menu_position, gfx::Size(0, 0)), | 162 gfx::Rect(menu_position, gfx::Size(0, 0)), |
| 163 views::MenuItemView::TOPLEFT, | 163 views::MenuItemView::TOPLEFT, |
| 164 true); | 164 true); |
| 165 } else { | 165 } else { |
| 166 MenuDelegate menu_delegate; | 166 MenuDelegate menu_delegate; |
| 167 MenuItemView menu(&menu_delegate); | 167 MenuItemView menu(&menu_delegate); |
| 168 menu.RunMenuAt(GetWindow()->GetNativeWindow(), NULL, | 168 menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL, |
| 169 gfx::Rect(menu_position, gfx::Size(0, 0)), | 169 gfx::Rect(menu_position, gfx::Size(0, 0)), |
| 170 views::MenuItemView::TOPLEFT, | 170 views::MenuItemView::TOPLEFT, |
| 171 true); | 171 true); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Need to explicitly clear mouse handler so that events get sent | 174 // Need to explicitly clear mouse handler so that events get sent |
| 175 // properly after the menu finishes running. If we don't do this, then | 175 // properly after the menu finishes running. If we don't do this, then |
| 176 // the first click to other parts of the UI is eaten. | 176 // the first click to other parts of the UI is eaten. |
| 177 SetMouseHandler(NULL); | 177 SetMouseHandler(NULL); |
| 178 | 178 |
| 179 // Set the state back to normal after the drop down menu is closed. | 179 // Set the state back to normal after the drop down menu is closed. |
| 180 if (state_ != BS_DISABLED) | 180 if (state_ != BS_DISABLED) |
| 181 SetState(BS_NORMAL); | 181 SetState(BS_NORMAL); |
| 182 } | 182 } |
| 183 | 183 |
| 184 //////////////////////////////////////////////////////////////////////////////// | 184 //////////////////////////////////////////////////////////////////////////////// |
| 185 // | 185 // |
| 186 // ButtonDropDown - Accessibility | 186 // ButtonDropDown - Accessibility |
| 187 // | 187 // |
| 188 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
| 189 | 189 |
| 190 } // namespace views | 190 } // namespace views |
| OLD | NEW |