| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/menu/submenu_view.h" | 5 #include "views/controls/menu/submenu_view.h" |
| 6 | 6 |
| 7 #include "gfx/canvas.h" | 7 #include "gfx/canvas.h" |
| 8 #include "views/controls/menu/menu_config.h" | 8 #include "views/controls/menu/menu_config.h" |
| 9 #include "views/controls/menu/menu_controller.h" | 9 #include "views/controls/menu/menu_controller.h" |
| 10 #include "views/controls/menu/menu_host.h" | 10 #include "views/controls/menu/menu_host.h" |
| 11 #include "views/controls/menu/menu_scroll_view_container.h" | 11 #include "views/controls/menu/menu_scroll_view_container.h" |
| 12 #include "views/widget/root_view.h" | 12 #include "views/widget/root_view.h" |
| 13 | 13 |
| 14 // Height of the drop indicator. This should be an even number. | 14 // Height of the drop indicator. This should be an even number. |
| 15 static const int kDropIndicatorHeight = 2; | 15 static const int kDropIndicatorHeight = 2; |
| 16 | 16 |
| 17 // Color of the drop indicator. | 17 // Color of the drop indicator. |
| 18 static const SkColor kDropIndicatorColor = SK_ColorBLACK; | 18 static const SkColor kDropIndicatorColor = SK_ColorBLACK; |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 const int SubmenuView::kSubmenuBorderSize = 3; | 23 const int SubmenuView::kSubmenuBorderSize = 3; |
| 24 | 24 |
| 25 // static |
| 26 const char SubmenuView::kViewClassName[] = "views/SubmenuView"; |
| 27 |
| 25 SubmenuView::SubmenuView(MenuItemView* parent) | 28 SubmenuView::SubmenuView(MenuItemView* parent) |
| 26 : parent_menu_item_(parent), | 29 : parent_menu_item_(parent), |
| 27 host_(NULL), | 30 host_(NULL), |
| 28 drop_item_(NULL), | 31 drop_item_(NULL), |
| 29 drop_position_(MenuDelegate::DROP_NONE), | 32 drop_position_(MenuDelegate::DROP_NONE), |
| 30 scroll_view_container_(NULL), | 33 scroll_view_container_(NULL), |
| 31 max_accelerator_width_(0) { | 34 max_accelerator_width_(0) { |
| 32 DCHECK(parent); | 35 DCHECK(parent); |
| 33 // We'll delete ourselves, otherwise the ScrollView would delete us on close. | 36 // We'll delete ourselves, otherwise the ScrollView would delete us on close. |
| 34 set_parent_owned(false); | 37 set_parent_owned(false); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 294 |
| 292 gfx::NativeWindow SubmenuView::native_window() const { | 295 gfx::NativeWindow SubmenuView::native_window() const { |
| 293 return host_ ? host_->GetMenuHostWindow() : NULL; | 296 return host_ ? host_->GetMenuHostWindow() : NULL; |
| 294 } | 297 } |
| 295 | 298 |
| 296 void SubmenuView::MenuHostDestroyed() { | 299 void SubmenuView::MenuHostDestroyed() { |
| 297 host_ = NULL; | 300 host_ = NULL; |
| 298 GetMenuItem()->GetMenuController()->Cancel(MenuController::EXIT_DESTROYED); | 301 GetMenuItem()->GetMenuController()->Cancel(MenuController::EXIT_DESTROYED); |
| 299 } | 302 } |
| 300 | 303 |
| 304 std::string SubmenuView::GetClassName() const { |
| 305 return kViewClassName; |
| 306 } |
| 307 |
| 301 void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas, | 308 void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas, |
| 302 MenuItemView* item, | 309 MenuItemView* item, |
| 303 MenuDelegate::DropPosition position) { | 310 MenuDelegate::DropPosition position) { |
| 304 if (position == MenuDelegate::DROP_NONE) | 311 if (position == MenuDelegate::DROP_NONE) |
| 305 return; | 312 return; |
| 306 | 313 |
| 307 gfx::Rect bounds = CalculateDropIndicatorBounds(item, position); | 314 gfx::Rect bounds = CalculateDropIndicatorBounds(item, position); |
| 308 canvas->FillRectInt(kDropIndicatorColor, bounds.x(), bounds.y(), | 315 canvas->FillRectInt(kDropIndicatorColor, bounds.x(), bounds.y(), |
| 309 bounds.width(), bounds.height()); | 316 bounds.width(), bounds.height()); |
| 310 } | 317 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 338 item_bounds.set_height(kDropIndicatorHeight); | 345 item_bounds.set_height(kDropIndicatorHeight); |
| 339 return item_bounds; | 346 return item_bounds; |
| 340 | 347 |
| 341 default: | 348 default: |
| 342 // Don't render anything for on. | 349 // Don't render anything for on. |
| 343 return gfx::Rect(); | 350 return gfx::Rect(); |
| 344 } | 351 } |
| 345 } | 352 } |
| 346 | 353 |
| 347 } // namespace views | 354 } // namespace views |
| OLD | NEW |