| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/first_run_bubble.h" | 5 #include "chrome/browser/views/first_run_bubble.h" |
| 6 | 6 |
| 7 #include "app/gfx/font_util.h" |
| 7 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/win_util.h" |
| 9 #include "base/win_util.h" | 11 #include "base/win_util.h" |
| 10 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 11 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
| 12 #include "chrome/browser/browser_window.h" | 14 #include "chrome/browser/browser_window.h" |
| 13 #include "chrome/browser/options_window.h" | 15 #include "chrome/browser/options_window.h" |
| 14 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/search_engines/template_url_model.h" | 17 #include "chrome/browser/search_engines/template_url_model.h" |
| 16 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 18 #include "grit/locale_settings.h" | 20 #include "grit/locale_settings.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 int next_v_space = | 329 int next_v_space = |
| 328 label1_->y() + pref_size.height() + kRelatedControlSmallVerticalSpacing; | 330 label1_->y() + pref_size.height() + kRelatedControlSmallVerticalSpacing; |
| 329 | 331 |
| 330 pref_size = label3_->GetPreferredSize(); | 332 pref_size = label3_->GetPreferredSize(); |
| 331 label3_->SetBounds(kOEMBubblePadding, next_v_space, | 333 label3_->SetBounds(kOEMBubblePadding, next_v_space, |
| 332 canvas.width() - kOEMBubblePadding * 2, | 334 canvas.width() - kOEMBubblePadding * 2, |
| 333 pref_size.height()); | 335 pref_size.height()); |
| 334 } | 336 } |
| 335 | 337 |
| 336 gfx::Size FirstRunOEMBubbleView::GetPreferredSize() { | 338 gfx::Size FirstRunOEMBubbleView::GetPreferredSize() { |
| 337 return gfx::Size(views::Window::GetLocalizedContentsSize( | 339 // Calculate width based on font and text. |
| 338 IDS_FIRSTRUNOEMBUBBLE_DIALOG_WIDTH_CHARS, | 340 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 339 IDS_FIRSTRUNOEMBUBBLE_DIALOG_HEIGHT_LINES)); | 341 const gfx::Font& font = rb.GetFont( |
| 342 ResourceBundle::MediumFont).DeriveFont(3, gfx::Font::BOLD); |
| 343 gfx::Size size = gfx::Size( |
| 344 gfx::GetLocalizedContentsWidthForFont( |
| 345 IDS_FIRSTRUNOEMBUBBLE_DIALOG_WIDTH_CHARS, font), |
| 346 gfx::GetLocalizedContentsHeightForFont( |
| 347 IDS_FIRSTRUNOEMBUBBLE_DIALOG_HEIGHT_LINES, font)); |
| 348 |
| 349 // WARNING: HACK. Vista and XP calculate font size differently; this means |
| 350 // that a dialog box correctly proportioned for XP will appear too large in |
| 351 // Vista. The correct thing to do is to change font size calculations in |
| 352 // XP or Vista so that the length of a string is calculated properly. For |
| 353 // now, we force Vista to show a correctly-sized box by taking account of |
| 354 // the difference in font size calculation. The coefficient should not be |
| 355 // stored in a variable because it's a hack and should go away. |
| 356 if (win_util::ShouldUseVistaFrame()) { |
| 357 size.set_width(static_cast<int>(size.width() * 0.85)); |
| 358 size.set_height(static_cast<int>(size.height() * 0.85)); |
| 359 } |
| 360 return size; |
| 340 } | 361 } |
| 341 | 362 |
| 342 void FirstRunOEMBubbleView::FocusWillChange(View* focused_before, | 363 void FirstRunOEMBubbleView::FocusWillChange(View* focused_before, |
| 343 View* focused_now) { | 364 View* focused_now) { |
| 344 // No buttons in oem_bubble to register focus changes. | 365 // No buttons in oem_bubble to register focus changes. |
| 345 } | 366 } |
| 346 | 367 |
| 347 // FirstRunBubble ------------------------------------------------------------- | 368 // FirstRunBubble ------------------------------------------------------------- |
| 348 | 369 |
| 349 // static | 370 // static |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 429 } |
| 409 | 430 |
| 410 void FirstRunBubble::InfoBubbleClosing(InfoBubble* info_bubble, | 431 void FirstRunBubble::InfoBubbleClosing(InfoBubble* info_bubble, |
| 411 bool closed_by_escape) { | 432 bool closed_by_escape) { |
| 412 // Make sure our parent window is re-enabled. | 433 // Make sure our parent window is re-enabled. |
| 413 if (!IsWindowEnabled(GetParent())) | 434 if (!IsWindowEnabled(GetParent())) |
| 414 ::EnableWindow(GetParent(), true); | 435 ::EnableWindow(GetParent(), true); |
| 415 enable_window_method_factory_.RevokeAll(); | 436 enable_window_method_factory_.RevokeAll(); |
| 416 GetFocusManager()->RemoveFocusChangeListener(view_); | 437 GetFocusManager()->RemoveFocusChangeListener(view_); |
| 417 } | 438 } |
| OLD | NEW |