| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/about_chrome_view.h" | 5 #include "chrome/browser/views/about_chrome_view.h" |
| 6 | 6 |
| 7 #include <commdlg.h> | 7 #include <commdlg.h> |
| 8 | 8 |
| 9 #include "app/gfx/chrome_canvas.h" | 9 #include "app/gfx/chrome_canvas.h" |
| 10 #include "app/gfx/color_utils.h" | 10 #include "app/gfx/color_utils.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 main_label_chunk2_ + open_source_url_->GetText() + | 219 main_label_chunk2_ + open_source_url_->GetText() + |
| 220 main_label_chunk3_; | 220 main_label_chunk3_; |
| 221 | 221 |
| 222 dialog_dimensions_ = views::Window::GetLocalizedContentsSize( | 222 dialog_dimensions_ = views::Window::GetLocalizedContentsSize( |
| 223 IDS_ABOUT_DIALOG_WIDTH_CHARS, | 223 IDS_ABOUT_DIALOG_WIDTH_CHARS, |
| 224 IDS_ABOUT_DIALOG_MINIMUM_HEIGHT_LINES); | 224 IDS_ABOUT_DIALOG_MINIMUM_HEIGHT_LINES); |
| 225 | 225 |
| 226 // Create a label and add the full text so we can query it for the height. | 226 // Create a label and add the full text so we can query it for the height. |
| 227 views::Label dummy_text(full_text); | 227 views::Label dummy_text(full_text); |
| 228 dummy_text.SetMultiLine(true); | 228 dummy_text.SetMultiLine(true); |
| 229 ChromeFont font = | 229 gfx::Font font = |
| 230 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); | 230 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); |
| 231 | 231 |
| 232 // Add up the height of the various elements on the page. | 232 // Add up the height of the various elements on the page. |
| 233 int height = about_background_logo->height() + | 233 int height = about_background_logo->height() + |
| 234 kRelatedControlVerticalSpacing + | 234 kRelatedControlVerticalSpacing + |
| 235 font.height() + // Copyright line. | 235 font.height() + // Copyright line. |
| 236 dummy_text.GetHeightForWidth( // Main label. | 236 dummy_text.GetHeightForWidth( // Main label. |
| 237 dialog_dimensions_.width() - (2 * kPanelHorizMargin)) + | 237 dialog_dimensions_.width() - (2 * kPanelHorizMargin)) + |
| 238 kRelatedControlVerticalSpacing; | 238 kRelatedControlVerticalSpacing; |
| 239 | 239 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 void AboutChromeView::Paint(ChromeCanvas* canvas) { | 354 void AboutChromeView::Paint(ChromeCanvas* canvas) { |
| 355 views::View::Paint(canvas); | 355 views::View::Paint(canvas); |
| 356 | 356 |
| 357 // Draw the background image color (and the separator) across the dialog. | 357 // Draw the background image color (and the separator) across the dialog. |
| 358 // This will become the background for the logo image at the top of the | 358 // This will become the background for the logo image at the top of the |
| 359 // dialog. | 359 // dialog. |
| 360 canvas->TileImageInt(*kBackgroundBmp, 0, 0, | 360 canvas->TileImageInt(*kBackgroundBmp, 0, 0, |
| 361 dialog_dimensions_.width(), kBackgroundBmp->height()); | 361 dialog_dimensions_.width(), kBackgroundBmp->height()); |
| 362 | 362 |
| 363 ChromeFont font = | 363 gfx::Font font = |
| 364 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); | 364 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); |
| 365 | 365 |
| 366 const gfx::Rect label_bounds = main_text_label_->bounds(); | 366 const gfx::Rect label_bounds = main_text_label_->bounds(); |
| 367 | 367 |
| 368 views::Link* link1 = | 368 views::Link* link1 = |
| 369 chromium_url_appears_first_ ? chromium_url_ : open_source_url_; | 369 chromium_url_appears_first_ ? chromium_url_ : open_source_url_; |
| 370 views::Link* link2 = | 370 views::Link* link2 = |
| 371 chromium_url_appears_first_ ? open_source_url_ : chromium_url_; | 371 chromium_url_appears_first_ ? open_source_url_ : chromium_url_; |
| 372 gfx::Rect* rect1 = chromium_url_appears_first_ ? | 372 gfx::Rect* rect1 = chromium_url_appears_first_ ? |
| 373 &chromium_url_rect_ : &open_source_url_rect_; | 373 &chromium_url_rect_ : &open_source_url_rect_; |
| 374 gfx::Rect* rect2 = chromium_url_appears_first_ ? | 374 gfx::Rect* rect2 = chromium_url_appears_first_ ? |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // Save the height so we can set the bounds correctly. | 423 // Save the height so we can set the bounds correctly. |
| 424 main_text_label_height_ = position.height() + font.height(); | 424 main_text_label_height_ = position.height() + font.height(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas, | 427 void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas, |
| 428 const std::wstring& text, | 428 const std::wstring& text, |
| 429 views::Link* link, | 429 views::Link* link, |
| 430 gfx::Rect* rect, | 430 gfx::Rect* rect, |
| 431 gfx::Size* position, | 431 gfx::Size* position, |
| 432 const gfx::Rect& bounds, | 432 const gfx::Rect& bounds, |
| 433 const ChromeFont& font) { | 433 const gfx::Font& font) { |
| 434 DCHECK(canvas && position); | 434 DCHECK(canvas && position); |
| 435 | 435 |
| 436 // What we get passed in as |text| is potentially a mix of LTR and RTL "runs" | 436 // What we get passed in as |text| is potentially a mix of LTR and RTL "runs" |
| 437 // (a run is a sequence of words that share the same directionality). We | 437 // (a run is a sequence of words that share the same directionality). We |
| 438 // initialize a bidirectional ICU line iterator and split the text into runs | 438 // initialize a bidirectional ICU line iterator and split the text into runs |
| 439 // that are either strictly LTR or strictly RTL (and do not contain a mix). | 439 // that are either strictly LTR or strictly RTL (and do not contain a mix). |
| 440 l10n_util::BiDiLineIterator bidi_line; | 440 l10n_util::BiDiLineIterator bidi_line; |
| 441 if (!bidi_line.Open(text.c_str(), true, false)) | 441 if (!bidi_line.Open(text.c_str(), true, false)) |
| 442 return; | 442 return; |
| 443 | 443 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 rect->Offset(bounds.x(), bounds.y()); | 476 rect->Offset(bounds.x(), bounds.y()); |
| 477 // And leave some space to draw the link in. | 477 // And leave some space to draw the link in. |
| 478 position->Enlarge(sz.width(), 0); | 478 position->Enlarge(sz.width(), 0); |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas, | 482 void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas, |
| 483 const std::wstring& text, | 483 const std::wstring& text, |
| 484 gfx::Size* position, | 484 gfx::Size* position, |
| 485 const gfx::Rect& bounds, | 485 const gfx::Rect& bounds, |
| 486 const ChromeFont& font, | 486 const gfx::Font& font, |
| 487 bool ltr_within_rtl) { | 487 bool ltr_within_rtl) { |
| 488 // Iterate through line breaking opportunities (which in English would be | 488 // Iterate through line breaking opportunities (which in English would be |
| 489 // spaces and such. This tells us where to wrap. | 489 // spaces and such. This tells us where to wrap. |
| 490 WordIterator iter(text, WordIterator::BREAK_LINE); | 490 WordIterator iter(text, WordIterator::BREAK_LINE); |
| 491 if (!iter.Init()) | 491 if (!iter.Init()) |
| 492 return; | 492 return; |
| 493 | 493 |
| 494 int flags = (text_direction_is_rtl_ ? | 494 int flags = (text_direction_is_rtl_ ? |
| 495 ChromeCanvas::TEXT_ALIGN_RIGHT : | 495 ChromeCanvas::TEXT_ALIGN_RIGHT : |
| 496 ChromeCanvas::TEXT_ALIGN_LEFT) | | 496 ChromeCanvas::TEXT_ALIGN_LEFT) | |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 819 |
| 820 // We have updated controls on the parent, so we need to update its layout. | 820 // We have updated controls on the parent, so we need to update its layout. |
| 821 View* parent = GetParent(); | 821 View* parent = GetParent(); |
| 822 parent->Layout(); | 822 parent->Layout(); |
| 823 | 823 |
| 824 // Check button may have appeared/disappeared. We cannot call this during | 824 // Check button may have appeared/disappeared. We cannot call this during |
| 825 // ViewHierarchyChanged because the |window()| pointer hasn't been set yet. | 825 // ViewHierarchyChanged because the |window()| pointer hasn't been set yet. |
| 826 if (window()) | 826 if (window()) |
| 827 GetDialogClientView()->UpdateDialogButtons(); | 827 GetDialogClientView()->UpdateDialogButtons(); |
| 828 } | 828 } |
| OLD | NEW |