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/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "grit/ui_resources.h" | 11 #include "grit/ui_resources.h" |
12 #include "grit/ui_strings.h" | 12 #include "grit/ui_strings.h" |
13 #include "skia/ext/skia_utils_mac.h" | 13 #include "skia/ext/skia_utils_mac.h" |
14 #import "ui/base/cocoa/hover_image_button.h" | 14 #import "ui/base/cocoa/hover_image_button.h" |
15 #include "ui/base/l10n/l10n_util_mac.h" | 15 #include "ui/base/l10n/l10n_util_mac.h" |
16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/base/text/text_elider.h" | 17 #include "ui/gfx/text_elider.h" |
18 #include "ui/message_center/message_center.h" | 18 #include "ui/message_center/message_center.h" |
19 #include "ui/message_center/message_center_style.h" | 19 #include "ui/message_center/message_center_style.h" |
20 #include "ui/message_center/notification.h" | 20 #include "ui/message_center/notification.h" |
21 | 21 |
22 | 22 |
23 @interface MCNotificationProgressBar : NSProgressIndicator | 23 @interface MCNotificationProgressBar : NSProgressIndicator |
24 @end | 24 @end |
25 | 25 |
26 @implementation MCNotificationProgressBar | 26 @implementation MCNotificationProgressBar |
27 - (void)drawRect:(NSRect)dirtyRect { | 27 - (void)drawRect:(NSRect)dirtyRect { |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 } | 690 } |
691 | 691 |
692 - (string16)wrapText:(const string16&)text | 692 - (string16)wrapText:(const string16&)text |
693 forField:(NSTextField*)field | 693 forField:(NSTextField*)field |
694 maxNumberOfLines:(size_t)lines { | 694 maxNumberOfLines:(size_t)lines { |
695 gfx::Font font([field font]); | 695 gfx::Font font([field font]); |
696 int width = NSWidth([self currentContentRect]); | 696 int width = NSWidth([self currentContentRect]); |
697 int height = (lines + 1) * font.GetHeight(); | 697 int height = (lines + 1) * font.GetHeight(); |
698 | 698 |
699 std::vector<string16> wrapped; | 699 std::vector<string16> wrapped; |
700 ui::ElideRectangleText(text, font, width, height, | 700 gfx::ElideRectangleText(text, font, width, height, |
701 ui::WRAP_LONG_WORDS, &wrapped); | 701 gfx::WRAP_LONG_WORDS, &wrapped); |
702 | 702 |
703 if (wrapped.size() > lines) { | 703 if (wrapped.size() > lines) { |
704 // Add an ellipsis to the last line. If this ellipsis makes the last line | 704 // Add an ellipsis to the last line. If this ellipsis makes the last line |
705 // too wide, that line will be further elided by the ui::ElideText below. | 705 // too wide, that line will be further elided by the gfx::ElideText below. |
706 string16 last = wrapped[lines - 1] + UTF8ToUTF16(ui::kEllipsis); | 706 string16 last = wrapped[lines - 1] + UTF8ToUTF16(gfx::kEllipsis); |
707 if (font.GetStringWidth(last) > width) | 707 if (font.GetStringWidth(last) > width) |
708 last = ui::ElideText(last, font, width, ui::ELIDE_AT_END); | 708 last = gfx::ElideText(last, font, width, gfx::ELIDE_AT_END); |
709 wrapped.resize(lines - 1); | 709 wrapped.resize(lines - 1); |
710 wrapped.push_back(last); | 710 wrapped.push_back(last); |
711 } | 711 } |
712 | 712 |
713 return JoinString(wrapped, '\n'); | 713 return JoinString(wrapped, '\n'); |
714 } | 714 } |
715 | 715 |
716 @end | 716 @end |
OLD | NEW |