OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/button/menu_button.h" | 5 #include "ui/views/controls/button/menu_button.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/accessibility/ax_view_state.h" | 8 #include "ui/accessibility/ax_view_state.h" |
9 #include "ui/base/dragdrop/drag_drop_types.h" | 9 #include "ui/base/dragdrop/drag_drop_types.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
59 // | 59 // |
60 // MenuButton - constructors, destructors, initialization | 60 // MenuButton - constructors, destructors, initialization |
61 // | 61 // |
62 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
63 | 63 |
64 MenuButton::MenuButton(ButtonListener* listener, | 64 MenuButton::MenuButton(ButtonListener* listener, |
65 const base::string16& text, | 65 const base::string16& text, |
66 MenuButtonListener* menu_button_listener, | 66 MenuButtonListener* menu_button_listener, |
67 bool show_menu_marker) | 67 bool show_menu_marker) |
68 : LabelButton(listener, text), | 68 : LabelButton(listener), |
69 menu_offset_(kDefaultMenuOffsetX, kDefaultMenuOffsetY), | 69 menu_offset_(kDefaultMenuOffsetX, kDefaultMenuOffsetY), |
70 listener_(menu_button_listener), | 70 listener_(menu_button_listener), |
71 show_menu_marker_(show_menu_marker), | 71 show_menu_marker_(show_menu_marker), |
72 menu_marker_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 72 menu_marker_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
73 IDR_MENU_DROPARROW).ToImageSkia()), | 73 IDR_MENU_DROPARROW).ToImageSkia()), |
74 destroyed_flag_(NULL), | 74 destroyed_flag_(NULL), |
75 pressed_lock_count_(0), | 75 pressed_lock_count_(0), |
76 should_disable_after_press_(false), | 76 should_disable_after_press_(false), |
77 weak_factory_(this) { | 77 weak_factory_(this) { |
78 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 78 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 79 |
| 80 // TODO(tapted): Remove this. MenuButton has subclasses and Init() may call |
| 81 // virtual methods. |
| 82 Init(text); |
79 } | 83 } |
80 | 84 |
81 MenuButton::~MenuButton() { | 85 MenuButton::~MenuButton() { |
82 if (destroyed_flag_) | 86 if (destroyed_flag_) |
83 *destroyed_flag_ = true; | 87 *destroyed_flag_ = true; |
84 } | 88 } |
85 | 89 |
86 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
87 // | 91 // |
88 // MenuButton - Public APIs | 92 // MenuButton - Public APIs |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 if (!GetWidget()) { | 354 if (!GetWidget()) { |
351 NOTREACHED(); | 355 NOTREACHED(); |
352 return 0; | 356 return 0; |
353 } | 357 } |
354 | 358 |
355 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); | 359 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); |
356 return monitor_bounds.right() - 1; | 360 return monitor_bounds.right() - 1; |
357 } | 361 } |
358 | 362 |
359 } // namespace views | 363 } // namespace views |
OLD | NEW |