| 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/chrome_menu.h" | 5 #include "chrome/views/chrome_menu.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <uxtheme.h> | 8 #include <uxtheme.h> |
| 9 #include <Vssym32.h> | 9 #include <Vssym32.h> |
| 10 | 10 |
| 11 #include "base/base_drag_source.h" | 11 #include "base/base_drag_source.h" |
| 12 #include "base/gfx/native_theme.h" | 12 #include "base/gfx/native_theme.h" |
| 13 #include "base/gfx/skia_utils.h" | 13 #include "base/gfx/skia_utils.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/task.h" | 15 #include "base/task.h" |
| 16 #include "base/timer.h" | 16 #include "base/timer.h" |
| 17 #include "base/win_util.h" | 17 #include "base/win_util.h" |
| 18 #include "chrome/browser/drag_utils.h" | 18 #include "chrome/browser/drag_utils.h" |
| 19 #include "chrome/common/gfx/chrome_canvas.h" | 19 #include "chrome/common/gfx/chrome_canvas.h" |
| 20 #include "chrome/common/gfx/color_utils.h" | 20 #include "chrome/common/gfx/color_utils.h" |
| 21 #include "chrome/common/l10n_util.h" | 21 #include "chrome/common/l10n_util.h" |
| 22 #include "chrome/common/os_exchange_data.h" | 22 #include "chrome/common/os_exchange_data.h" |
| 23 #include "chrome/views/border.h" | 23 #include "chrome/views/border.h" |
| 24 #include "chrome/views/container_win.h" | 24 #include "chrome/views/container_win.h" |
| 25 #include "chrome/views/root_view.h" | 25 #include "chrome/views/root_view.h" |
| 26 #include "chrome/views/view_constants.h" |
| 26 #include "generated_resources.h" | 27 #include "generated_resources.h" |
| 27 | 28 |
| 28 #undef min | 29 #undef min |
| 29 #undef max | 30 #undef max |
| 30 | 31 |
| 31 using base::Time; | 32 using base::Time; |
| 32 using base::TimeDelta; | 33 using base::TimeDelta; |
| 33 | 34 |
| 34 // Margins between the top of the item and the label. | 35 // Margins between the top of the item and the label. |
| 35 static const int kItemTopMargin = 3; | 36 static const int kItemTopMargin = 3; |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 // Don't render anything for on. | 1029 // Don't render anything for on. |
| 1029 return gfx::Rect(); | 1030 return gfx::Rect(); |
| 1030 } | 1031 } |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 // MenuItemView --------------------------------------------------------------- | 1034 // MenuItemView --------------------------------------------------------------- |
| 1034 | 1035 |
| 1035 // static | 1036 // static |
| 1036 const int MenuItemView::kMenuItemViewID = 1001; | 1037 const int MenuItemView::kMenuItemViewID = 1001; |
| 1037 | 1038 |
| 1038 // static | |
| 1039 const int MenuItemView::kDropBetweenPixels = 5; | |
| 1040 | |
| 1041 // static | 1039 // static |
| 1042 bool MenuItemView::allow_task_nesting_during_run_ = false; | 1040 bool MenuItemView::allow_task_nesting_during_run_ = false; |
| 1043 | 1041 |
| 1044 MenuItemView::MenuItemView(MenuDelegate* delegate) { | 1042 MenuItemView::MenuItemView(MenuDelegate* delegate) { |
| 1045 DCHECK(delegate_); | 1043 DCHECK(delegate_); |
| 1046 Init(NULL, 0, SUBMENU, delegate); | 1044 Init(NULL, 0, SUBMENU, delegate); |
| 1047 } | 1045 } |
| 1048 | 1046 |
| 1049 MenuItemView::~MenuItemView() { | 1047 MenuItemView::~MenuItemView() { |
| 1050 if (controller_) { | 1048 if (controller_) { |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 } | 1882 } |
| 1885 MenuDelegate::DropPosition drop_position = MenuDelegate::DROP_NONE; | 1883 MenuDelegate::DropPosition drop_position = MenuDelegate::DROP_NONE; |
| 1886 int drop_operation = DragDropTypes::DRAG_NONE; | 1884 int drop_operation = DragDropTypes::DRAG_NONE; |
| 1887 if (menu_item) { | 1885 if (menu_item) { |
| 1888 gfx::Point menu_item_loc(event.location()); | 1886 gfx::Point menu_item_loc(event.location()); |
| 1889 View::ConvertPointToView(source, menu_item, &menu_item_loc); | 1887 View::ConvertPointToView(source, menu_item, &menu_item_loc); |
| 1890 MenuItemView* query_menu_item; | 1888 MenuItemView* query_menu_item; |
| 1891 if (!over_empty_menu) { | 1889 if (!over_empty_menu) { |
| 1892 int menu_item_height = menu_item->height(); | 1890 int menu_item_height = menu_item->height(); |
| 1893 if (menu_item->HasSubmenu() && | 1891 if (menu_item->HasSubmenu() && |
| 1894 (menu_item_loc.y() > MenuItemView::kDropBetweenPixels && | 1892 (menu_item_loc.y() > kDropBetweenPixels && |
| 1895 menu_item_loc.y() < (menu_item_height - | 1893 menu_item_loc.y() < (menu_item_height - kDropBetweenPixels))) { |
| 1896 MenuItemView::kDropBetweenPixels))) { | |
| 1897 drop_position = MenuDelegate::DROP_ON; | 1894 drop_position = MenuDelegate::DROP_ON; |
| 1898 } else if (menu_item_loc.y() < menu_item_height / 2) { | 1895 } else if (menu_item_loc.y() < menu_item_height / 2) { |
| 1899 drop_position = MenuDelegate::DROP_BEFORE; | 1896 drop_position = MenuDelegate::DROP_BEFORE; |
| 1900 } else { | 1897 } else { |
| 1901 drop_position = MenuDelegate::DROP_AFTER; | 1898 drop_position = MenuDelegate::DROP_AFTER; |
| 1902 } | 1899 } |
| 1903 query_menu_item = menu_item; | 1900 query_menu_item = menu_item; |
| 1904 } else { | 1901 } else { |
| 1905 query_menu_item = menu_item->GetParentMenuItem(); | 1902 query_menu_item = menu_item->GetParentMenuItem(); |
| 1906 drop_position = MenuDelegate::DROP_ON; | 1903 drop_position = MenuDelegate::DROP_ON; |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 if (!scroll_task_.get()) | 2713 if (!scroll_task_.get()) |
| 2717 scroll_task_.reset(new MenuScrollTask()); | 2714 scroll_task_.reset(new MenuScrollTask()); |
| 2718 scroll_task_->Update(part); | 2715 scroll_task_->Update(part); |
| 2719 } | 2716 } |
| 2720 | 2717 |
| 2721 void MenuController::StopScrolling() { | 2718 void MenuController::StopScrolling() { |
| 2722 scroll_task_.reset(NULL); | 2719 scroll_task_.reset(NULL); |
| 2723 } | 2720 } |
| 2724 | 2721 |
| 2725 } // namespace views | 2722 } // namespace views |
| OLD | NEW |