Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: chrome/browser/views/about_chrome_view.cc

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/canvas.h"
10 #include "app/gfx/color_utils.h" 10 #include "app/gfx/color_utils.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "base/file_version_info.h" 13 #include "base/file_version_info.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/win_util.h" 15 #include "base/win_util.h"
16 #include "base/word_iterator.h" 16 #include "base/word_iterator.h"
17 #include "chrome/browser/browser_list.h" 17 #include "chrome/browser/browser_list.h"
18 #include "chrome/browser/metrics/user_metrics.h" 18 #include "chrome/browser/metrics/user_metrics.h"
19 #include "chrome/browser/views/restart_message_box.h" 19 #include "chrome/browser/views/restart_message_box.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 int update_label_x = throbber_->x() + throbber_->width() + 344 int update_label_x = throbber_->x() + throbber_->width() +
345 kRelatedControlHorizontalSpacing; 345 kRelatedControlHorizontalSpacing;
346 update_label_.SetHorizontalAlignment(views::Label::ALIGN_LEFT); 346 update_label_.SetHorizontalAlignment(views::Label::ALIGN_LEFT);
347 update_label_.SetBounds(update_label_x, 347 update_label_.SetBounds(update_label_x,
348 throbber_topleft_y + 1, 348 throbber_topleft_y + 1,
349 parent_bounds.width() - update_label_x, 349 parent_bounds.width() - update_label_x,
350 sz.height()); 350 sz.height());
351 } 351 }
352 352
353 353
354 void AboutChromeView::Paint(ChromeCanvas* canvas) { 354 void AboutChromeView::Paint(gfx::Canvas* 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 gfx::Font font = 363 gfx::Font font =
364 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); 364 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // Then position the Open Source URL within the main label. 417 // Then position the Open Source URL within the main label.
418 open_source_url_->SetBounds(open_source_url_rect_.x(), 418 open_source_url_->SetBounds(open_source_url_rect_.x(),
419 open_source_url_rect_.y(), 419 open_source_url_rect_.y(),
420 open_source_url_rect_.width(), 420 open_source_url_rect_.width(),
421 open_source_url_rect_.height()); 421 open_source_url_rect_.height());
422 422
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(gfx::Canvas* 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 gfx::Font& 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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 // Go from relative pixel coordinates (within the label we are drawing on) 473 // Go from relative pixel coordinates (within the label we are drawing on)
474 // to absolute pixel coordinates (relative to the top left corner of the 474 // to absolute pixel coordinates (relative to the top left corner of the
475 // dialog content). 475 // dialog content).
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(gfx::Canvas* 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 gfx::Font& 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 gfx::Canvas::TEXT_ALIGN_RIGHT :
496 ChromeCanvas::TEXT_ALIGN_LEFT) | 496 gfx::Canvas::TEXT_ALIGN_LEFT) |
497 ChromeCanvas::MULTI_LINE | 497 gfx::Canvas::MULTI_LINE |
498 ChromeCanvas::HIDE_PREFIX; 498 gfx::Canvas::HIDE_PREFIX;
499 499
500 // Iterate over each word in the text, or put in a more locale-neutral way: 500 // Iterate over each word in the text, or put in a more locale-neutral way:
501 // iterate to the next line breaking opportunity. 501 // iterate to the next line breaking opportunity.
502 while (iter.Advance()) { 502 while (iter.Advance()) {
503 // Get the word and figure out the dimensions. 503 // Get the word and figure out the dimensions.
504 std::wstring word; 504 std::wstring word;
505 if (!ltr_within_rtl) 505 if (!ltr_within_rtl)
506 word = iter.GetWord(); // Get the next word. 506 word = iter.GetWord(); // Get the next word.
507 else 507 else
508 word = text; // Draw the whole text at once. 508 word = text; // Draw the whole text at once.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/views/about_chrome_view.h ('k') | chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698