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

Side by Side Diff: ui/views/examples/text_example.cc

Issue 9562038: ui/gfx: Make gfx::Canvas inherit from gfx::CanvasSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/examples/text_example.h" 5 #include "ui/views/examples/text_example.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/canvas_skia.h" 10 #include "ui/gfx/canvas_skia.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 fade_(false), 99 fade_(false),
100 fade_mode_(gfx::CanvasSkia::TruncateFadeTail) { 100 fade_mode_(gfx::CanvasSkia::TruncateFadeTail) {
101 } 101 }
102 102
103 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 103 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
104 #if defined(OS_WIN) 104 #if defined(OS_WIN)
105 if (fade_) { 105 if (fade_) {
106 gfx::Rect rect(0, 0, width(), height()); 106 gfx::Rect rect(0, 0, width(), height());
107 size_t characters_to_truncate_from_head = 107 size_t characters_to_truncate_from_head =
108 gfx::CanvasSkia::TruncateFadeHeadAndTail ? 10 : 0; 108 gfx::CanvasSkia::TruncateFadeHeadAndTail ? 10 : 0;
109 canvas->AsCanvasSkia()->DrawFadeTruncatingString(text_, fade_mode_, 109 canvas->DrawFadeTruncatingString(text_, fade_mode_,
110 characters_to_truncate_from_head, font_, SK_ColorDKGRAY, rect); 110 characters_to_truncate_from_head, font_, SK_ColorDKGRAY, rect);
111 return; 111 return;
112 } 112 }
113 #endif 113 #endif
114 114
115 if (halo_) { 115 if (halo_) {
116 canvas->AsCanvasSkia()->DrawStringWithHalo(text_, font_, SK_ColorDKGRAY, 116 canvas->DrawStringWithHalo(text_, font_, SK_ColorDKGRAY,
117 SK_ColorWHITE, 0, 0, width(), height(), text_flags_); 117 SK_ColorWHITE, 0, 0, width(), height(), text_flags_);
118 } else { 118 } else {
119 canvas->DrawStringInt(text_, font_, SK_ColorDKGRAY, 0, 0, width(), 119 canvas->DrawStringInt(text_, font_, SK_ColorDKGRAY, 0, 0, width(),
120 height(), text_flags_); 120 height(), text_flags_);
121 } 121 }
122 } 122 }
123 123
124 int text_flags() const { return text_flags_; } 124 int text_flags() const { return text_flags_; }
125 void set_text_flags(int text_flags) { text_flags_ = text_flags; } 125 void set_text_flags(int text_flags) { text_flags_ = text_flags; }
126 126
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 text_flags |= gfx::Canvas::HIDE_PREFIX; 364 text_flags |= gfx::Canvas::HIDE_PREFIX;
365 break; 365 break;
366 } 366 }
367 } 367 }
368 text_view_->set_text_flags(text_flags); 368 text_view_->set_text_flags(text_flags);
369 text_view_->SchedulePaint(); 369 text_view_->SchedulePaint();
370 } 370 }
371 371
372 } // namespace examples 372 } // namespace examples
373 } // namespace views 373 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698