OLD | NEW |
---|---|
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 "base/logging.h" // for NOTREACHED() | 7 #include "base/logging.h" // for NOTREACHED() |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.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" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 initWithFrame:[exitLabelPlaceholder_ frame]]); | 206 initWithFrame:[exitLabelPlaceholder_ frame]]); |
207 [exitLabel_.get() | 207 [exitLabel_.get() |
208 setAutoresizingMask:[exitLabelPlaceholder_ autoresizingMask]]; | 208 setAutoresizingMask:[exitLabelPlaceholder_ autoresizingMask]]; |
209 [exitLabel_.get() setHidden:[exitLabelPlaceholder_ isHidden]]; | 209 [exitLabel_.get() setHidden:[exitLabelPlaceholder_ isHidden]]; |
210 [[exitLabelPlaceholder_ superview] replaceSubview:exitLabelPlaceholder_ | 210 [[exitLabelPlaceholder_ superview] replaceSubview:exitLabelPlaceholder_ |
211 with:exitLabel_.get()]; | 211 with:exitLabel_.get()]; |
212 exitLabelPlaceholder_ = nil; // Now released. | 212 exitLabelPlaceholder_ = nil; // Now released. |
213 [exitLabel_.get() setDelegate:self]; | 213 [exitLabel_.get() setDelegate:self]; |
214 | 214 |
215 NSString* exitLinkText; | 215 NSString* exitLinkText; |
216 NSString* exitUnlinkedText; | 216 NSString* exitLinkedText; |
217 if (bubbleType_ == | 217 if (bubbleType_ == |
218 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION || | 218 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION || |
219 bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) { | 219 bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) { |
220 exitLinkText = @""; | 220 exitLinkText = @""; |
221 exitUnlinkedText = | 221 exitLinkedText = |
222 [@" " stringByAppendingString:l10n_util::GetNSStringF( | 222 [@" " stringByAppendingString:l10n_util::GetNSStringF( |
223 IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, | 223 IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, |
224 l10n_util::GetStringUTF16( | 224 l10n_util::GetStringUTF16( |
225 IDS_APP_ESC_KEY))]; | 225 IDS_APP_ESC_KEY))]; |
226 } else { | 226 } else { |
227 exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE); | 227 exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE); |
228 exitUnlinkedText = | 228 NSString* messageText = l10n_util::GetNSStringF( |
229 [@" " stringByAppendingString:l10n_util::GetNSStringF( | 229 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, |
230 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, | 230 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); |
231 l10n_util::GetStringUTF16( | 231 exitLinkedText = [NSString stringWithFormat:@"%@ %@", exitLinkText, |
232 IDS_APP_ESC_KEY))]; | 232 messageText]; |
Alexei Svitkine (slow)
2015/01/28 14:55:03
Nit: how about this formatting:
exitLinkedTex
shrike
2015/01/28 17:35:04
Done.
| |
233 } | 233 } |
234 | 234 |
235 NSFont* font = [NSFont | 235 NSFont* font = [NSFont |
236 systemFontOfSize:[NSFont | 236 systemFontOfSize:[NSFont |
237 systemFontSizeForControlSize:NSRegularControlSize]]; | 237 systemFontSizeForControlSize:NSRegularControlSize]]; |
238 [(HyperlinkTextView*)exitLabel_.get() setMessageAndLink:exitUnlinkedText | 238 [exitLabel_.get() setMessage:exitLinkedText |
239 withLink:exitLinkText | 239 withFont:font |
240 atOffset:0 | 240 messageColor:[NSColor blackColor]]; |
241 font:font | 241 if ([exitLinkText length] != 0) { |
242 messageColor:[NSColor blackColor] | 242 [exitLabel_.get() addLinkRange:NSMakeRange(0, [exitLinkText length]) |
243 linkColor:[NSColor blueColor]]; | 243 withName:@"" |
244 linkColor:[NSColor blueColor]]; | |
245 } | |
244 [exitLabel_.get() setAlignment:NSRightTextAlignment]; | 246 [exitLabel_.get() setAlignment:NSRightTextAlignment]; |
245 | 247 |
246 NSRect labelFrame = [exitLabel_ frame]; | 248 NSRect labelFrame = [exitLabel_ frame]; |
247 | 249 |
248 // NSTextView's sizeToFit: method seems to enjoy wrapping lines. Temporarily | 250 // NSTextView's sizeToFit: method seems to enjoy wrapping lines. Temporarily |
249 // set the size large to force it not to. | 251 // set the size large to force it not to. |
250 NSRect windowFrame = [[self window] frame]; | 252 NSRect windowFrame = [[self window] frame]; |
251 [exitLabel_ setFrameSize:windowFrame.size]; | 253 [exitLabel_ setFrameSize:windowFrame.size]; |
252 NSLayoutManager* layoutManager = [exitLabel_ layoutManager]; | 254 NSLayoutManager* layoutManager = [exitLabel_ layoutManager]; |
253 NSTextContainer* textContainer = [exitLabel_ textContainer]; | 255 NSTextContainer* textContainer = [exitLabel_ textContainer]; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 - (void)hideSoon { | 325 - (void)hideSoon { |
324 hideTimer_.reset( | 326 hideTimer_.reset( |
325 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay | 327 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay |
326 target:self | 328 target:self |
327 selector:@selector(hideTimerFired:) | 329 selector:@selector(hideTimerFired:) |
328 userInfo:nil | 330 userInfo:nil |
329 repeats:NO] retain]); | 331 repeats:NO] retain]); |
330 } | 332 } |
331 | 333 |
332 @end | 334 @end |
OLD | NEW |