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

Side by Side Diff: ui/gfx/canvas_mac.mm

Issue 14322007: Add line height setting to views::Label & use it for notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 33
34 } // namespace 34 } // namespace
35 35
36 namespace gfx { 36 namespace gfx {
37 37
38 // static 38 // static
39 void Canvas::SizeStringInt(const string16& text, 39 void Canvas::SizeStringInt(const string16& text,
40 const gfx::Font& font, 40 const gfx::Font& font,
41 int* width, 41 int* width,
42 int* height, 42 int* height,
43 int line_height, // Ignored for now.
dharcourt 2013/04/17 17:52:21 Since multi-line isn't implemented for canvas_mac,
43 int flags) { 44 int flags) {
44 NSFont* native_font = font.GetNativeFont(); 45 NSFont* native_font = font.GetNativeFont();
45 NSString* ns_string = base::SysUTF16ToNSString(text); 46 NSString* ns_string = base::SysUTF16ToNSString(text);
46 NSDictionary* attributes = 47 NSDictionary* attributes =
47 [NSDictionary dictionaryWithObject:native_font 48 [NSDictionary dictionaryWithObject:native_font
48 forKey:NSFontAttributeName]; 49 forKey:NSFontAttributeName];
49 NSSize string_size = [ns_string sizeWithAttributes:attributes]; 50 NSSize string_size = [ns_string sizeWithAttributes:attributes];
50 *width = string_size.width; 51 *width = string_size.width;
51 *height = font.GetHeight(); 52 *height = font.GetHeight();
52 } 53 }
53 54
54 void Canvas::DrawStringWithShadows(const string16& text, 55 void Canvas::DrawStringWithShadows(const string16& text,
55 const gfx::Font& font, 56 const gfx::Font& font,
56 SkColor color, 57 SkColor color,
57 const gfx::Rect& text_bounds, 58 const gfx::Rect& text_bounds,
59 int line_height, // Ignored for now.
58 int flags, 60 int flags,
59 const ShadowValues& shadows) { 61 const ShadowValues& shadows) {
60 DLOG_IF(WARNING, !shadows.empty()) << "Text shadow not implemented."; 62 DLOG_IF(WARNING, !shadows.empty()) << "Text shadow not implemented.";
61 63
62 skia::RefPtr<SkTypeface> typeface = skia::AdoptRef( 64 skia::RefPtr<SkTypeface> typeface = skia::AdoptRef(
63 SkTypeface::CreateFromName( 65 SkTypeface::CreateFromName(
64 font.GetFontName().c_str(), FontTypefaceStyle(font))); 66 font.GetFontName().c_str(), FontTypefaceStyle(font)));
65 SkPaint paint; 67 SkPaint paint;
66 paint.setTypeface(typeface.get()); 68 paint.setTypeface(typeface.get());
67 paint.setColor(color); 69 paint.setColor(color);
68 canvas_->drawText(text.c_str(), 70 canvas_->drawText(text.c_str(),
69 text.size() * sizeof(string16::value_type), 71 text.size() * sizeof(string16::value_type),
70 text_bounds.x(), 72 text_bounds.x(),
71 text_bounds.bottom(), 73 text_bounds.bottom(),
72 paint); 74 paint);
73 } 75 }
74 76
75 void Canvas::DrawStringWithHalo(const string16& text, 77 void Canvas::DrawStringWithHalo(const string16& text,
76 const gfx::Font& font, 78 const gfx::Font& font,
77 SkColor text_color, 79 SkColor text_color,
78 SkColor halo_color, 80 SkColor halo_color,
79 int x, int y, int w, int h, 81 int x, int y, int w, int h,
80 int flags) { 82 int flags) {
81 } 83 }
82 84
83 } // namespace gfx 85 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas_android.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | ui/gfx/canvas_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698