OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/message_center/cocoa/notification_controller.h" | 5 #import "ui/message_center/cocoa/notification_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "skia/ext/skia_utils_mac.h" | 10 #include "skia/ext/skia_utils_mac.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 inView:(NSView*)controlView { | 55 inView:(NSView*)controlView { |
56 CGFloat offsetX = message_center::kButtonHorizontalPadding; | 56 CGFloat offsetX = message_center::kButtonHorizontalPadding; |
57 if ([base::mac::ObjCCastStrict<NSButton>(controlView) image]) { | 57 if ([base::mac::ObjCCastStrict<NSButton>(controlView) image]) { |
58 offsetX += message_center::kNotificationButtonIconSize + | 58 offsetX += message_center::kNotificationButtonIconSize + |
59 message_center::kButtonIconToTitlePadding; | 59 message_center::kButtonIconToTitlePadding; |
60 } | 60 } |
61 frame.origin.x = offsetX; | 61 frame.origin.x = offsetX; |
62 frame.size.width -= offsetX; | 62 frame.size.width -= offsetX; |
63 | 63 |
64 NSDictionary* attributes = @{ | 64 NSDictionary* attributes = @{ |
65 NSFontAttributeName : [title attribute:NSFontAttributeName | 65 NSFontAttributeName : |
66 atIndex:0 | 66 [title attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL], |
67 effectiveRange:NULL], | 67 NSForegroundColorAttributeName : |
| 68 gfx::SkColorToDeviceNSColor(message_center::kRegularTextColor), |
68 }; | 69 }; |
69 [[title string] drawWithRect:frame | 70 [[title string] drawWithRect:frame |
70 options:(NSStringDrawingUsesLineFragmentOrigin | | 71 options:(NSStringDrawingUsesLineFragmentOrigin | |
71 NSStringDrawingTruncatesLastVisibleLine) | 72 NSStringDrawingTruncatesLastVisibleLine) |
72 attributes:attributes]; | 73 attributes:attributes]; |
73 return frame; | 74 return frame; |
74 } | 75 } |
75 | 76 |
76 - (void)mouseEntered:(NSEvent*)event { | 77 - (void)mouseEntered:(NSEvent*)event { |
77 hovered_ = YES; | 78 hovered_ = YES; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 [closeButton_ setAutoresizingMask:NSViewMinYMargin]; | 338 [closeButton_ setAutoresizingMask:NSViewMinYMargin]; |
338 [closeButton_ setTarget:self]; | 339 [closeButton_ setTarget:self]; |
339 [closeButton_ setAction:@selector(close:)]; | 340 [closeButton_ setAction:@selector(close:)]; |
340 } | 341 } |
341 | 342 |
342 - (void)configureTitleInFrame:(NSRect)rootFrame { | 343 - (void)configureTitleInFrame:(NSRect)rootFrame { |
343 NSRect frame = [self currentContentRect]; | 344 NSRect frame = [self currentContentRect]; |
344 frame.size.height = 0; | 345 frame.size.height = 0; |
345 title_.reset([self newLabelWithFrame:frame]); | 346 title_.reset([self newLabelWithFrame:frame]); |
346 [title_ setAutoresizingMask:NSViewMinYMargin]; | 347 [title_ setAutoresizingMask:NSViewMinYMargin]; |
| 348 [title_ setTextColor:gfx::SkColorToCalibratedNSColor( |
| 349 message_center::kRegularTextColor)]; |
347 [title_ setFont:[NSFont messageFontOfSize:message_center::kTitleFontSize]]; | 350 [title_ setFont:[NSFont messageFontOfSize:message_center::kTitleFontSize]]; |
348 } | 351 } |
349 | 352 |
350 - (void)configureBodyInFrame:(NSRect)rootFrame { | 353 - (void)configureBodyInFrame:(NSRect)rootFrame { |
351 NSRect frame = [self currentContentRect]; | 354 NSRect frame = [self currentContentRect]; |
352 frame.size.height = 0; | 355 frame.size.height = 0; |
353 message_.reset([self newLabelWithFrame:frame]); | 356 message_.reset([self newLabelWithFrame:frame]); |
354 [message_ setAutoresizingMask:NSViewMinYMargin]; | 357 [message_ setAutoresizingMask:NSViewMinYMargin]; |
| 358 [message_ setTextColor:gfx::SkColorToCalibratedNSColor( |
| 359 message_center::kDimTextColor)]; |
355 [message_ setFont: | 360 [message_ setFont: |
356 [NSFont messageFontOfSize:message_center::kMessageFontSize]]; | 361 [NSFont messageFontOfSize:message_center::kMessageFontSize]]; |
357 } | 362 } |
358 | 363 |
359 - (NSTextField*)newLabelWithFrame:(NSRect)frame { | 364 - (NSTextField*)newLabelWithFrame:(NSRect)frame { |
360 NSTextField* label = [[NSTextField alloc] initWithFrame:frame]; | 365 NSTextField* label = [[NSTextField alloc] initWithFrame:frame]; |
361 [label setDrawsBackground:NO]; | 366 [label setDrawsBackground:NO]; |
362 [label setBezeled:NO]; | 367 [label setBezeled:NO]; |
363 [label setEditable:NO]; | 368 [label setEditable:NO]; |
364 [label setSelectable:NO]; | 369 [label setSelectable:NO]; |
365 [label setTextColor:gfx::SkColorToCalibratedNSColor( | |
366 message_center::kRegularTextColor)]; | |
367 return label; | 370 return label; |
368 } | 371 } |
369 | 372 |
370 - (NSRect)currentContentRect { | 373 - (NSRect)currentContentRect { |
371 DCHECK(icon_); | 374 DCHECK(icon_); |
372 DCHECK(closeButton_); | 375 DCHECK(closeButton_); |
373 | 376 |
374 NSRect iconFrame, contentFrame; | 377 NSRect iconFrame, contentFrame; |
375 NSDivideRect([[self view] bounds], &iconFrame, &contentFrame, | 378 NSDivideRect([[self view] bounds], &iconFrame, &contentFrame, |
376 NSWidth([icon_ frame]) + message_center::kIconToTextPadding, | 379 NSWidth([icon_ frame]) + message_center::kIconToTextPadding, |
377 NSMinXEdge); | 380 NSMinXEdge); |
378 contentFrame.size.width -= NSWidth([closeButton_ frame]); | 381 contentFrame.size.width -= NSWidth([closeButton_ frame]); |
379 return contentFrame; | 382 return contentFrame; |
380 } | 383 } |
381 | 384 |
382 @end | 385 @end |
OLD | NEW |