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() |
73 IDR_MENU_DROPARROW).ToImageSkia()), | 73 .GetImageNamed(IDR_MENU_DROPARROW) |
| 74 .ToImageSkia()), |
74 destroyed_flag_(NULL), | 75 destroyed_flag_(NULL), |
75 pressed_lock_count_(0), | 76 pressed_lock_count_(0), |
76 should_disable_after_press_(false), | 77 should_disable_after_press_(false), |
77 weak_factory_(this) { | 78 weak_factory_(this) { |
78 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 79 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 80 |
| 81 // TODO(tapted): Remove this. MenuButton has subclasses and Init() may call |
| 82 // virtual methods. |
| 83 InitAsTextbutton(text); |
79 } | 84 } |
80 | 85 |
81 MenuButton::~MenuButton() { | 86 MenuButton::~MenuButton() { |
82 if (destroyed_flag_) | 87 if (destroyed_flag_) |
83 *destroyed_flag_ = true; | 88 *destroyed_flag_ = true; |
84 } | 89 } |
85 | 90 |
86 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
87 // | 92 // |
88 // MenuButton - Public APIs | 93 // MenuButton - Public APIs |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 if (!GetWidget()) { | 355 if (!GetWidget()) { |
351 NOTREACHED(); | 356 NOTREACHED(); |
352 return 0; | 357 return 0; |
353 } | 358 } |
354 | 359 |
355 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); | 360 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); |
356 return monitor_bounds.right() - 1; | 361 return monitor_bounds.right() - 1; |
357 } | 362 } |
358 | 363 |
359 } // namespace views | 364 } // namespace views |
OLD | NEW |