summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/checkbox.cc7
-rw-r--r--views/controls/button/text_button.cc11
-rw-r--r--views/controls/button/text_button.h5
-rw-r--r--views/controls/message_box_view.cc2
-rw-r--r--views/examples/button_example.cc24
-rw-r--r--views/window/dialog_client_view.cc2
6 files changed, 26 insertions, 25 deletions
diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc
index 6eb683d..b60e802 100644
--- a/views/controls/button/checkbox.cc
+++ b/views/controls/button/checkbox.cc
@@ -5,23 +5,22 @@
#include "views/controls/button/checkbox.h"
#include "base/logging.h"
-#include "base/utf_string_conversions.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/gfx/canvas.h"
#include "views/controls/label.h"
namespace views {
+const int kCheckboxLabelSpacing = 4;
+
// static
const char Checkbox::kViewClassName[] = "views/Checkbox";
-static const int kCheckboxLabelSpacing = 4;
-
////////////////////////////////////////////////////////////////////////////////
// Checkbox, public:
Checkbox::Checkbox(const string16& label)
- : TextButtonBase(NULL, UTF16ToWideHack(label)),
+ : TextButtonBase(NULL, label),
checked_(false) {
set_border(new TextButtonNativeThemeBorder(this));
set_focusable(true);
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index 58c0030..1d56f1d 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -264,8 +264,7 @@ void TextButtonNativeThemeBorder::GetInsets(gfx::Insets* insets) const {
////////////////////////////////////////////////////////////////////////////////
// TextButtonBase, public:
-TextButtonBase::TextButtonBase(ButtonListener* listener,
- const std::wstring& text)
+TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text)
: CustomButton(listener),
alignment_(ALIGN_LEFT),
font_(ResourceBundle::GetSharedInstance().GetFont(
@@ -304,9 +303,9 @@ void TextButtonBase::SetIsDefault(bool is_default) {
SchedulePaint();
}
-void TextButtonBase::SetText(const std::wstring& text) {
- text_ = WideToUTF16Hack(text);
- SetAccessibleName(WideToUTF16Hack(text));
+void TextButtonBase::SetText(const string16& text) {
+ text_ = text;
+ SetAccessibleName(text);
UpdateTextSize();
}
@@ -653,7 +652,7 @@ gfx::NativeTheme::State TextButtonBase::GetForegroundThemeState(
TextButton::TextButton(ButtonListener* listener,
const std::wstring& text)
- : TextButtonBase(listener, text),
+ : TextButtonBase(listener, WideToUTF16Hack(text)),
icon_placement_(ICON_ON_LEFT),
has_hover_icon_(false),
has_pushed_icon_(false),
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index fedd114..031b59a 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -8,6 +8,7 @@
#include <string>
+#include "base/string16.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font.h"
@@ -139,7 +140,7 @@ class VIEWS_EXPORT TextButtonBase : public CustomButton,
// Call SetText once per string in your set of possible values at button
// creation time, so that it can contain the largest of them and avoid
// resizing the button when the text changes.
- virtual void SetText(const std::wstring& text);
+ virtual void SetText(const string16& text);
const string16& text() const { return text_; }
enum TextAlignment {
@@ -215,7 +216,7 @@ class VIEWS_EXPORT TextButtonBase : public CustomButton,
virtual std::string GetClassName() const OVERRIDE;
protected:
- TextButtonBase(ButtonListener* listener, const std::wstring& text);
+ TextButtonBase(ButtonListener* listener, const string16& text);
// Called when enabled or disabled state changes, or the colors for those
// states change.
diff --git a/views/controls/message_box_view.cc b/views/controls/message_box_view.cc
index b64952f..8216f29 100644
--- a/views/controls/message_box_view.cc
+++ b/views/controls/message_box_view.cc
@@ -73,7 +73,7 @@ void MessageBoxView::SetCheckBoxLabel(const string16& label) {
if (!checkbox_)
checkbox_ = new Checkbox(label);
else
- checkbox_->SetText(UTF16ToWideHack(label));
+ checkbox_->SetText(label);
ResetLayoutManager();
}
diff --git a/views/examples/button_example.cc b/views/examples/button_example.cc
index 6f27449..71f11f6 100644
--- a/views/examples/button_example.cc
+++ b/views/examples/button_example.cc
@@ -4,6 +4,7 @@
#include "views/examples/button_example.h"
+#include "base/utf_string_conversions.h"
#include "grit/ui_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "views/controls/button/checkbox.h"
@@ -34,18 +35,18 @@ void ButtonExample::CreateExampleView(views::View* container) {
void ButtonExample::ButtonPressed(views::Button* sender,
const views::Event& event) {
- PrintStatus("Pressed! count:%d", ++count_);
+ PrintStatus("Pressed! count: %d", ++count_);
if (event.IsControlDown()) {
if (event.IsShiftDown()) {
if (event.IsAltDown()) {
button_->SetMultiLine(!button_->multi_line());
if (button_->multi_line()) {
- button_->SetText(L"Multi-line text\n"
- L"is here to stay all the way!\n"
- L"123");
+ button_->SetText(ASCIIToUTF16("Multi-line text\n") +
+ ASCIIToUTF16("is here to stay all the way!\n") +
+ ASCIIToUTF16("123"));
} else {
- button_->SetText(L"Button");
+ button_->SetText(ASCIIToUTF16("Button"));
}
} else {
switch(button_->icon_placement()) {
@@ -79,13 +80,14 @@ void ButtonExample::ButtonPressed(views::Button* sender,
} else if (event.IsShiftDown()) {
if (event.IsAltDown()) {
if (button_->text().length() < 10) {
- button_->SetText(L"Startof"
- L"ReallyReallyReallyReallyReallyReallyReally"
- L"ReallyReallyReallyReallyReallyReallyReally"
- L"ReallyReallyReallyReallyReallyReallyReally"
- L"LongButtonText");
+ button_->SetText(
+ ASCIIToUTF16("Startof") +
+ ASCIIToUTF16("ReallyReallyReallyReallyReallyReallyReally") +
+ ASCIIToUTF16("ReallyReallyReallyReallyReallyReallyReally") +
+ ASCIIToUTF16("ReallyReallyReallyReallyReallyReallyReally") +
+ ASCIIToUTF16("LongButtonText"));
} else {
- button_->SetText(L"Button");
+ button_->SetText(ASCIIToUTF16("Button"));
}
} else {
use_native_theme_border_ = !use_native_theme_border_;
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 5569df0..4c571c2 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -47,7 +47,7 @@ void UpdateButtonHelper(NativeTextButton* button_view,
MessageBoxFlags::DialogButton button) {
string16 label = delegate->GetDialogButtonLabel(button);
if (!label.empty())
- button_view->SetText(UTF16ToWideHack(label));
+ button_view->SetText(label);
button_view->SetEnabled(delegate->IsDialogButtonEnabled(button));
button_view->SetVisible(delegate->IsDialogButtonVisible(button));
}