From 358e4745427bb4a8a28545c2c4718978c493c531 Mon Sep 17 00:00:00 2001 From: "mirandac@chromium.org" Date: Fri, 6 Nov 2009 00:42:11 +0000 Subject: Fix first run OEM bubble size issue. BUG= 20267 TEST= Force the first run OEM bubble to appear on a Windows machine with "classic" and "aero" theme. Note that the box is large enough to contain the text in both cases. Review URL: http://codereview.chromium.org/374001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31180 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/first_run_bubble.cc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'chrome/browser/views/first_run_bubble.cc') diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc index a0233be4..4c9c95d 100644 --- a/chrome/browser/views/first_run_bubble.cc +++ b/chrome/browser/views/first_run_bubble.cc @@ -4,8 +4,10 @@ #include "chrome/browser/views/first_run_bubble.h" +#include "app/gfx/font_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "app/win_util.h" #include "base/win_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -334,9 +336,28 @@ void FirstRunOEMBubbleView::Layout() { } gfx::Size FirstRunOEMBubbleView::GetPreferredSize() { - return gfx::Size(views::Window::GetLocalizedContentsSize( - IDS_FIRSTRUNOEMBUBBLE_DIALOG_WIDTH_CHARS, - IDS_FIRSTRUNOEMBUBBLE_DIALOG_HEIGHT_LINES)); + // Calculate width based on font and text. + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + const gfx::Font& font = rb.GetFont( + ResourceBundle::MediumFont).DeriveFont(3, gfx::Font::BOLD); + gfx::Size size = gfx::Size( + gfx::GetLocalizedContentsWidthForFont( + IDS_FIRSTRUNOEMBUBBLE_DIALOG_WIDTH_CHARS, font), + gfx::GetLocalizedContentsHeightForFont( + IDS_FIRSTRUNOEMBUBBLE_DIALOG_HEIGHT_LINES, font)); + + // WARNING: HACK. Vista and XP calculate font size differently; this means + // that a dialog box correctly proportioned for XP will appear too large in + // Vista. The correct thing to do is to change font size calculations in + // XP or Vista so that the length of a string is calculated properly. For + // now, we force Vista to show a correctly-sized box by taking account of + // the difference in font size calculation. The coefficient should not be + // stored in a variable because it's a hack and should go away. + if (win_util::ShouldUseVistaFrame()) { + size.set_width(static_cast(size.width() * 0.85)); + size.set_height(static_cast(size.height() * 0.85)); + } + return size; } void FirstRunOEMBubbleView::FocusWillChange(View* focused_before, -- cgit v1.1