| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/menu_button.h" | 5 #include "views/controls/button/menu_button.h" |
| 6 | 6 |
| 7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
| 8 #include "app/gfx/chrome_canvas.h" | 8 #include "app/gfx/chrome_canvas.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 int MenuButton::GetMaximumScreenXCoordinate() { | 104 int MenuButton::GetMaximumScreenXCoordinate() { |
| 105 Widget* widget = GetWidget(); | 105 Widget* widget = GetWidget(); |
| 106 | 106 |
| 107 if (!widget) { | 107 if (!widget) { |
| 108 NOTREACHED(); | 108 NOTREACHED(); |
| 109 return 0; | 109 return 0; |
| 110 } | 110 } |
| 111 | 111 |
| 112 HWND hwnd = widget->GetNativeView(); | 112 HWND hwnd = widget->GetNativeView(); |
| 113 CRect t; | 113 RECT t; |
| 114 ::GetWindowRect(hwnd, &t); | 114 ::GetWindowRect(hwnd, &t); |
| 115 | 115 |
| 116 gfx::Rect r(t); | 116 gfx::Rect r(t); |
| 117 gfx::Rect monitor_rect = win_util::GetMonitorBoundsForRect(r); | 117 gfx::Rect monitor_rect = win_util::GetMonitorBoundsForRect(r); |
| 118 return monitor_rect.x() + monitor_rect.width() - 1; | 118 return monitor_rect.x() + monitor_rect.width() - 1; |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool MenuButton::Activate() { | 121 bool MenuButton::Activate() { |
| 122 SetState(BS_PUSHED); | 122 SetState(BS_PUSHED); |
| 123 // We need to synchronously paint here because subsequently we enter a | 123 // We need to synchronously paint here because subsequently we enter a |
| (...skipping 23 matching lines...) Expand all Loading... |
| 147 // We're about to show the menu from a mouse press. By showing from the | 147 // We're about to show the menu from a mouse press. By showing from the |
| 148 // mouse press event we block RootView in mouse dispatching. This also | 148 // mouse press event we block RootView in mouse dispatching. This also |
| 149 // appears to cause RootView to get a mouse pressed BEFORE the mouse | 149 // appears to cause RootView to get a mouse pressed BEFORE the mouse |
| 150 // release is seen, which means RootView sends us another mouse press no | 150 // release is seen, which means RootView sends us another mouse press no |
| 151 // matter where the user pressed. To force RootView to recalculate the | 151 // matter where the user pressed. To force RootView to recalculate the |
| 152 // mouse target during the mouse press we explicitly set the mouse handler | 152 // mouse target during the mouse press we explicitly set the mouse handler |
| 153 // to NULL. | 153 // to NULL. |
| 154 GetRootView()->SetMouseHandler(NULL); | 154 GetRootView()->SetMouseHandler(NULL); |
| 155 | 155 |
| 156 menu_visible_ = true; | 156 menu_visible_ = true; |
| 157 menu_delegate_->RunMenu(this, menu_position.ToPOINT(), | 157 menu_delegate_->RunMenu(this, menu_position, GetWidget()->GetNativeView()); |
| 158 GetWidget()->GetNativeView()); | |
| 159 menu_visible_ = false; | 158 menu_visible_ = false; |
| 160 menu_closed_time_ = Time::Now(); | 159 menu_closed_time_ = Time::Now(); |
| 161 | 160 |
| 162 // Now that the menu has closed, we need to manually reset state to | 161 // Now that the menu has closed, we need to manually reset state to |
| 163 // "normal" since the menu modal loop will have prevented normal | 162 // "normal" since the menu modal loop will have prevented normal |
| 164 // mouse move messages from getting to this View. We set "normal" | 163 // mouse move messages from getting to this View. We set "normal" |
| 165 // and not "hot" because the likelihood is that the mouse is now | 164 // and not "hot" because the likelihood is that the mouse is now |
| 166 // somewhere else (user clicked elsewhere on screen to close the menu | 165 // somewhere else (user clicked elsewhere on screen to close the menu |
| 167 // or selected an item) and we will inevitably refresh the hot state | 166 // or selected an item) and we will inevitably refresh the hot state |
| 168 // in the event the mouse _is_ over the view. | 167 // in the event the mouse _is_ over the view. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 243 } |
| 245 | 244 |
| 246 bool MenuButton::GetAccessibleState(AccessibilityTypes::State* state) { | 245 bool MenuButton::GetAccessibleState(AccessibilityTypes::State* state) { |
| 247 DCHECK(state); | 246 DCHECK(state); |
| 248 | 247 |
| 249 *state = AccessibilityTypes::STATE_HASPOPUP; | 248 *state = AccessibilityTypes::STATE_HASPOPUP; |
| 250 return true; | 249 return true; |
| 251 } | 250 } |
| 252 | 251 |
| 253 } // namespace views | 252 } // namespace views |
| OLD | NEW |