summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 23:40:40 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 23:40:40 +0000
commit1abede9a1dcf4cdbb27c95d247f41733d21ba208 (patch)
tree42ec2f654e839ff7ea954e3d3dc8c2536c95c68b /views
parent959abf3b1fdbf58974eebe7e42490c2c3ff3e504 (diff)
downloadchromium_src-1abede9a1dcf4cdbb27c95d247f41733d21ba208.zip
chromium_src-1abede9a1dcf4cdbb27c95d247f41733d21ba208.tar.gz
chromium_src-1abede9a1dcf4cdbb27c95d247f41733d21ba208.tar.bz2
views: Change MenuButton API to string16.
BUG=68267 R=sky@chromium.org Review URL: http://codereview.chromium.org/8245013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/menu_button.cc4
-rw-r--r--views/controls/button/menu_button.h4
-rw-r--r--views/examples/menu_example.cc14
3 files changed, 11 insertions, 11 deletions
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index b8d0410..4a9e74c 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -46,10 +46,10 @@ const char MenuButton::kViewClassName[] = "views/MenuButton";
////////////////////////////////////////////////////////////////////////////////
MenuButton::MenuButton(ButtonListener* listener,
- const std::wstring& text,
+ const string16& text,
ViewMenuDelegate* menu_delegate,
bool show_menu_marker)
- : TextButton(listener, text),
+ : TextButton(listener, UTF16ToWideHack(text)),
menu_visible_(false),
menu_offset_(kDefaultMenuOffsetX, kDefaultMenuOffsetY),
menu_delegate_(menu_delegate),
diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h
index ce84526..5f202cb 100644
--- a/views/controls/button/menu_button.h
+++ b/views/controls/button/menu_button.h
@@ -8,6 +8,7 @@
#include <string>
+#include "base/string16.h"
#include "base/time.h"
#include "ui/gfx/font.h"
#include "views/background.h"
@@ -28,12 +29,11 @@ class ViewMenuDelegate;
////////////////////////////////////////////////////////////////////////////////
class VIEWS_EXPORT MenuButton : public TextButton {
public:
- // The menu button's class name.
static const char kViewClassName[];
// Create a Button.
MenuButton(ButtonListener* listener,
- const std::wstring& text,
+ const string16& text,
ViewMenuDelegate* menu_delegate,
bool show_menu_marker);
virtual ~MenuButton();
diff --git a/views/examples/menu_example.cc b/views/examples/menu_example.cc
index 04e28b6..ea501eb 100644
--- a/views/examples/menu_example.cc
+++ b/views/examples/menu_example.cc
@@ -9,9 +9,9 @@
#include "base/utf_string_conversions.h"
#include "ui/base/models/simple_menu_model.h"
#include "views/controls/button/menu_button.h"
+#include "views/controls/button/text_button.h"
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/view_menu_delegate.h"
-#include "views/controls/button/text_button.h"
#include "views/layout/fill_layout.h"
#include "views/view.h"
@@ -59,7 +59,7 @@ class ExampleMenuModel : public ui::SimpleMenuModel,
class ExampleMenuButton : public views::MenuButton,
public views::ViewMenuDelegate {
public:
- ExampleMenuButton(const std::wstring& test, bool show_menu_marker);
+ ExampleMenuButton(const string16& test, bool show_menu_marker);
virtual ~ExampleMenuButton();
private:
@@ -176,7 +176,7 @@ void ExampleMenuModel::ExecuteCommand(int command_id) {
// ExampleMenuButton -----------------------------------------------------------
-ExampleMenuButton::ExampleMenuButton(const std::wstring& test,
+ExampleMenuButton::ExampleMenuButton(const string16& test,
bool show_menu_marker)
: ALLOW_THIS_IN_INITIALIZER_LIST(
views::MenuButton(NULL, test, this, show_menu_marker)) {
@@ -186,9 +186,9 @@ ExampleMenuButton::~ExampleMenuButton() {
}
void ExampleMenuButton::RunMenu(views::View* source, const gfx::Point& point) {
- if (menu_model_ == NULL) {
+ if (!menu_model_.get())
menu_model_.reset(new ExampleMenuModel);
- }
+
menu_model_->RunMenuAt(point);
}
@@ -207,8 +207,8 @@ void MenuExample::CreateExampleView(views::View* container) {
// views::Menu2 is not a sub class of View, hence we cannot directly
// add to the continer. Instead, we add a button to open a menu.
const bool show_menu_marker = true;
- ExampleMenuButton* menu_button = new ExampleMenuButton(L"Open a menu",
- show_menu_marker);
+ ExampleMenuButton* menu_button = new ExampleMenuButton(
+ ASCIIToUTF16("Open a menu"), show_menu_marker);
container->SetLayoutManager(new views::FillLayout);
container->AddChildView(menu_button);
}