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 | |
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')
-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 | ||||
-rw-r--r-- | views/view_text_utils.cc | 7 | ||||
-rw-r--r-- | views/widget/tooltip_manager.cc | 8 | ||||
-rw-r--r-- | views/window/dialog_client_view.cc | 3 |
8 files changed, 25 insertions, 20 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); } } diff --git a/views/view_text_utils.cc b/views/view_text_utils.cc index df42544..8f13617 100644 --- a/views/view_text_utils.cc +++ b/views/view_text_utils.cc @@ -116,7 +116,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas, else word = text; // Draw the whole text at once. - int w = font.GetStringWidth(word), h = font.GetHeight(); + int w = font.GetStringWidth(WideToUTF16Hack(word)), h = font.GetHeight(); gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(word), font, &w, &h, flags); // If we exceed the boundaries, we need to wrap. @@ -130,8 +130,9 @@ void DrawTextStartingFrom(gfx::Canvas* canvas, // draw the trailing space (if one exists after the LTR text) to the // left of the LTR string. if (ltr_within_rtl && word[word.size() - 1] == L' ') { - int space_w = font.GetStringWidth(L" "), space_h = font.GetHeight(); - gfx::CanvasSkia::SizeStringInt(UTF8ToUTF16(" "), font, &space_w, + int space_w = font.GetStringWidth(ASCIIToUTF16(" ")); + int space_h = font.GetHeight(); + gfx::CanvasSkia::SizeStringInt(ASCIIToUTF16(" "), font, &space_w, &space_h, flags); x += space_w; } diff --git a/views/widget/tooltip_manager.cc b/views/widget/tooltip_manager.cc index 5c400eb9..d71a566 100644 --- a/views/widget/tooltip_manager.cc +++ b/views/widget/tooltip_manager.cc @@ -58,16 +58,16 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text, std::wstring result; for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end(); ++i) { - std::wstring elided_text = UTF16ToWideHack(gfx::ElideText(WideToUTF16Hack( - *i), font, available_width, false)); + string16 elided_text = gfx::ElideText(WideToUTF16Hack(*i), + font, available_width, false); *max_width = std::max(*max_width, font.GetStringWidth(elided_text)); if (i == lines.begin() && i + 1 == lines.end()) { - *text = elided_text; + *text = UTF16ToWideHack(elided_text); return; } if (!result.empty()) result.append(GetLineSeparator()); - result.append(elided_text); + result.append(UTF16ToWideHack(elided_text)); } *text = result; } diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index 8ce2224..ad89187 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -447,7 +447,8 @@ int DialogClientView::GetButtonWidth(int button) const { DialogDelegate* dd = GetDialogDelegate(); std::wstring button_label = dd->GetDialogButtonLabel( static_cast<MessageBoxFlags::DialogButton>(button)); - int string_width = dialog_button_font_->GetStringWidth(button_label); + int string_width = dialog_button_font_->GetStringWidth( + WideToUTF16Hack(button_label)); return std::max(string_width + kDialogButtonLabelSpacing, kDialogMinButtonWidth); } |