diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-04 20:46:14 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-04 20:46:14 +0000 |
commit | 13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5 (patch) | |
tree | ada8d64cbd2fd12c7248cca648e47ebd63e6462a /views/controls | |
parent | cd4857b64f3e3b10ebfa3f44c38af0dc7376d5bb (diff) | |
download | chromium_src-13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5.zip chromium_src-13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5.tar.gz chromium_src-13658c4b2835a3155efa6eb2c3c6ff8fef2b7fa5.tar.bz2 |
Change Font.GetStringWidth() to take string16 instead of wstring.
do a bunch of string fixes along the way.
BUG=none
TEST=trybots
Review URL: http://codereview.chromium.org/5985007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/label.cc | 9 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_gtk.cc | 5 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_views.cc | 6 | ||||
-rw-r--r-- | views/controls/textfield/textfield_views_model.cc | 5 |
5 files changed, 15 insertions, 12 deletions
diff --git a/views/controls/label.cc b/views/controls/label.cc index b228c78b..cdf2c8a 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -186,7 +186,8 @@ bool Label::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { // Show the full text if the text does not fit. if (!is_multi_line_ && - (font_.GetStringWidth(text_) > GetAvailableRect().width())) { + (font_.GetStringWidth(WideToUTF16Hack(text_)) > + GetAvailableRect().width())) { *tooltip = text_; return true; } @@ -237,8 +238,10 @@ void Label::SizeToFit(int max_width) { int label_width = 0; for (std::vector<std::wstring>::const_iterator iter = lines.begin(); - iter != lines.end(); ++iter) - label_width = std::max(label_width, font_.GetStringWidth(*iter)); + iter != lines.end(); ++iter) { + label_width = std::max(label_width, + font_.GetStringWidth(WideToUTF16Hack(*iter))); + } label_width += GetInsets().width(); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index 17e8ef8..985ecb7 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -429,7 +429,7 @@ void MenuItemView::Layout() { } int MenuItemView::GetAcceleratorTextWidth() { - std::wstring text = GetAcceleratorText(); + string16 text = WideToUTF16Hack(GetAcceleratorText()); return text.empty() ? 0 : MenuConfig::instance().font.GetStringWidth(text); } diff --git a/views/controls/menu/menu_item_view_gtk.cc b/views/controls/menu/menu_item_view_gtk.cc index 73599e2..87fcdca 100644 --- a/views/controls/menu/menu_item_view_gtk.cc +++ b/views/controls/menu/menu_item_view_gtk.cc @@ -5,6 +5,7 @@ #include "views/controls/menu/menu_item_view.h" #include "app/resource_bundle.h" +#include "base/utf_string_conversions.h" #include "gfx/canvas_skia.h" #include "gfx/favicon_size.h" #include "grit/app_resources.h" @@ -30,8 +31,8 @@ gfx::Size MenuItemView::GetPreferredSize() { // kFavIconSize if we're showing icons. int content_height = std::max(kFavIconSize, font.GetHeight()); return gfx::Size( - font.GetStringWidth(title_) + label_start_ + item_right_margin_ + - GetChildPreferredWidth(), + font.GetStringWidth(WideToUTF16Hack(title_)) + label_start_ + + item_right_margin_ + GetChildPreferredWidth(), content_height + GetBottomMargin() + GetTopMargin()); } diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index baef032..5ea8b23 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -328,7 +328,7 @@ void NativeTextfieldViews::UpdateCursorBoundsAndTextOffset() { // TODO(oshima): bidi const gfx::Font& font = GetFont(); - int full_width = font.GetStringWidth(UTF16ToWide(model_->GetVisibleText())); + int full_width = font.GetStringWidth(model_->GetVisibleText()); cursor_bounds_ = model_->GetCursorBounds(font); cursor_bounds_.set_y(cursor_bounds_.y() + insets.top()); @@ -381,7 +381,7 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { string16 text = model_->GetVisibleText((*iter).begin, (*iter).end); // TODO(oshima): This does not give the accurate position due to // kerning. Figure out how webkit does this with skia. - int width = GetFont().GetStringWidth(UTF16ToWide(text)); + int width = GetFont().GetStringWidth(text); if ((*iter).selected) { canvas->FillRectInt(selection_color, x_offset, y, width, text_height); @@ -601,7 +601,7 @@ size_t NativeTextfieldViews::FindCursorPosition(const gfx::Point& point) const { // TODO(oshima): BIDI/i18n support. gfx::Font font = GetFont(); gfx::Insets insets = GetInsets(); - std::wstring text = UTF16ToWide(model_->GetVisibleText()); + string16 text = model_->GetVisibleText(); int left = 0; int left_pos = 0; int right = font.GetStringWidth(text); diff --git a/views/controls/textfield/textfield_views_model.cc b/views/controls/textfield/textfield_views_model.cc index 21783ec..0b88c8a 100644 --- a/views/controls/textfield/textfield_views_model.cc +++ b/views/controls/textfield/textfield_views_model.cc @@ -196,14 +196,13 @@ bool TextfieldViewsModel::MoveCursorTo(size_t pos, bool select) { gfx::Rect TextfieldViewsModel::GetCursorBounds(const gfx::Font& font) const { string16 text = GetVisibleText(); - int x = font.GetStringWidth(UTF16ToWide(text.substr(0U, cursor_pos_))); + int x = font.GetStringWidth(text.substr(0U, cursor_pos_)); int h = font.GetHeight(); DCHECK(x >= 0); if (text.length() == cursor_pos_) { return gfx::Rect(x, 0, 0, h); } else { - int x_end = - font.GetStringWidth(UTF16ToWide(text.substr(0U, cursor_pos_ + 1U))); + int x_end = font.GetStringWidth(text.substr(0U, cursor_pos_ + 1U)); return gfx::Rect(x, 0, x_end - x, h); } } |