| 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 "chrome/views/button_dropdown.h" | 5 #include "chrome/views/button_dropdown.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "chrome/browser/back_forward_menu_model.h" | 8 #include "chrome/browser/back_forward_menu_model.h" |
| 9 #include "chrome/common/l10n_util.h" | 9 #include "chrome/common/l10n_util.h" |
| 10 #include "chrome/views/view_menu_delegate.h" | 10 #include "chrome/views/view_menu_delegate.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // | 105 // |
| 106 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
| 107 | 107 |
| 108 void ButtonDropDown::ShowDropDownMenu(HWND window) { | 108 void ButtonDropDown::ShowDropDownMenu(HWND window) { |
| 109 if (menu_delegate_) { | 109 if (menu_delegate_) { |
| 110 CRect lb; | 110 CRect lb; |
| 111 GetLocalBounds(&lb, true); | 111 GetLocalBounds(&lb, true); |
| 112 | 112 |
| 113 // Both the menu position and the menu anchor type change if the UI layout | 113 // Both the menu position and the menu anchor type change if the UI layout |
| 114 // is right-to-left. | 114 // is right-to-left. |
| 115 CPoint menu_position = CPoint(lb.TopLeft()); | 115 gfx::Point menu_position(lb.TopLeft()); |
| 116 menu_position.Offset(0, lb.Height() - 1); | 116 menu_position.Offset(0, lb.Height() - 1); |
| 117 if (UILayoutIsRightToLeft()) | 117 if (UILayoutIsRightToLeft()) |
| 118 menu_position.Offset(lb.Width() - 1, 0); | 118 menu_position.Offset(lb.Width() - 1, 0); |
| 119 | 119 |
| 120 Menu::AnchorPoint anchor = Menu::TOPLEFT; | 120 Menu::AnchorPoint anchor = Menu::TOPLEFT; |
| 121 if (UILayoutIsRightToLeft()) | 121 if (UILayoutIsRightToLeft()) |
| 122 anchor = Menu::TOPRIGHT; | 122 anchor = Menu::TOPRIGHT; |
| 123 | 123 |
| 124 View::ConvertPointToScreen(this, &menu_position); | 124 View::ConvertPointToScreen(this, &menu_position); |
| 125 Menu menu(menu_delegate_, anchor, window); | 125 Menu menu(menu_delegate_, anchor, window); |
| 126 | 126 |
| 127 // ID's for AppendMenu is 1-based because RunMenu will ignore the user | 127 // ID's for AppendMenu is 1-based because RunMenu will ignore the user |
| 128 // selection if id=0 is selected (0 = NO-OP) so we add 1 here and subtract 1 | 128 // selection if id=0 is selected (0 = NO-OP) so we add 1 here and subtract 1 |
| 129 // in the handlers above to get the actual index | 129 // in the handlers above to get the actual index |
| 130 int item_count = menu_delegate_->GetItemCount(); | 130 int item_count = menu_delegate_->GetItemCount(); |
| 131 for (int i = 0; i < item_count; i++) { | 131 for (int i = 0; i < item_count; i++) { |
| 132 if (menu_delegate_->IsItemSeparator(i + 1)) { | 132 if (menu_delegate_->IsItemSeparator(i + 1)) { |
| 133 menu.AppendSeparator(); | 133 menu.AppendSeparator(); |
| 134 } else { | 134 } else { |
| 135 if (menu_delegate_->HasIcon(i + 1)) | 135 if (menu_delegate_->HasIcon(i + 1)) |
| 136 menu.AppendMenuItemWithIcon(i + 1, L"", SkBitmap()); | 136 menu.AppendMenuItemWithIcon(i + 1, L"", SkBitmap()); |
| 137 else | 137 else |
| 138 menu.AppendMenuItem(i+1, L"", Menu::NORMAL); | 138 menu.AppendMenuItem(i+1, L"", Menu::NORMAL); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 menu.RunMenuAt(menu_position.x, menu_position.y); | 142 menu.RunMenuAt(menu_position.x(), menu_position.y()); |
| 143 | 143 |
| 144 // Need to explicitly clear mouse handler so that events get sent | 144 // Need to explicitly clear mouse handler so that events get sent |
| 145 // properly after the menu finishes running. If we don't do this, then | 145 // properly after the menu finishes running. If we don't do this, then |
| 146 // the first click to other parts of the UI is eaten. | 146 // the first click to other parts of the UI is eaten. |
| 147 SetMouseHandler(NULL); | 147 SetMouseHandler(NULL); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////////// |
| 152 // | 152 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 171 | 171 |
| 172 bool ButtonDropDown::GetAccessibleState(VARIANT* state) { | 172 bool ButtonDropDown::GetAccessibleState(VARIANT* state) { |
| 173 DCHECK(state); | 173 DCHECK(state); |
| 174 | 174 |
| 175 state->lVal |= STATE_SYSTEM_HASPOPUP; | 175 state->lVal |= STATE_SYSTEM_HASPOPUP; |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace ChromeViews | 179 } // namespace ChromeViews |
| 180 | 180 |
| OLD | NEW |