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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 initWithFrame:[exitLabelPlaceholder_ frame]]); | 207 initWithFrame:[exitLabelPlaceholder_ frame]]); |
208 [exitLabel_.get() | 208 [exitLabel_.get() |
209 setAutoresizingMask:[exitLabelPlaceholder_ autoresizingMask]]; | 209 setAutoresizingMask:[exitLabelPlaceholder_ autoresizingMask]]; |
210 [exitLabel_.get() setHidden:[exitLabelPlaceholder_ isHidden]]; | 210 [exitLabel_.get() setHidden:[exitLabelPlaceholder_ isHidden]]; |
211 [[exitLabelPlaceholder_ superview] replaceSubview:exitLabelPlaceholder_ | 211 [[exitLabelPlaceholder_ superview] replaceSubview:exitLabelPlaceholder_ |
212 with:exitLabel_.get()]; | 212 with:exitLabel_.get()]; |
213 exitLabelPlaceholder_ = nil; // Now released. | 213 exitLabelPlaceholder_ = nil; // Now released. |
214 [exitLabel_.get() setDelegate:self]; | 214 [exitLabel_.get() setDelegate:self]; |
215 | 215 |
216 NSString* exitLinkText; | 216 NSString* exitLinkText; |
217 NSString* exitUnlinkedText; | 217 NSString* exitLinkedText; |
218 if (bubbleType_ == | 218 if (bubbleType_ == |
219 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION || | 219 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION || |
220 bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) { | 220 bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) { |
221 exitLinkText = @""; | 221 exitLinkText = @""; |
222 exitUnlinkedText = | 222 exitLinkedText = |
223 [@" " stringByAppendingString:l10n_util::GetNSStringF( | 223 [@" " stringByAppendingString:l10n_util::GetNSStringF( |
224 IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, | 224 IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, |
225 l10n_util::GetStringUTF16( | 225 l10n_util::GetStringUTF16( |
226 IDS_APP_ESC_KEY))]; | 226 IDS_APP_ESC_KEY))]; |
227 } else { | 227 } else { |
228 exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE); | 228 exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE); |
229 exitUnlinkedText = | 229 NSString* messageText = l10n_util::GetNSStringF( |
230 [@" " stringByAppendingString:l10n_util::GetNSStringF( | 230 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, |
231 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, | 231 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); |
232 l10n_util::GetStringUTF16( | 232 exitLinkedText = |
233 IDS_APP_ESC_KEY))]; | 233 [NSString stringWithFormat:@"%@ %@", exitLinkText, messageText]; |
234 } | 234 } |
235 | 235 |
236 NSFont* font = [NSFont | 236 NSFont* font = [NSFont |
237 systemFontOfSize:[NSFont | 237 systemFontOfSize:[NSFont |
238 systemFontSizeForControlSize:NSRegularControlSize]]; | 238 systemFontSizeForControlSize:NSRegularControlSize]]; |
239 [(HyperlinkTextView*)exitLabel_.get() setMessageAndLink:exitUnlinkedText | 239 [exitLabel_.get() setMessage:exitLinkedText |
240 withLink:exitLinkText | 240 withFont:font |
241 atOffset:0 | 241 messageColor:[NSColor blackColor]]; |
242 font:font | 242 if ([exitLinkText length] != 0) { |
243 messageColor:[NSColor blackColor] | 243 [exitLabel_.get() addLinkRange:NSMakeRange(0, [exitLinkText length]) |
244 linkColor:[NSColor blueColor]]; | 244 withName:@"" |
| 245 linkColor:[NSColor blueColor]]; |
| 246 } |
245 [exitLabel_.get() setAlignment:NSRightTextAlignment]; | 247 [exitLabel_.get() setAlignment:NSRightTextAlignment]; |
246 | 248 |
247 NSRect labelFrame = [exitLabel_ frame]; | 249 NSRect labelFrame = [exitLabel_ frame]; |
248 | 250 |
249 // NSTextView's sizeToFit: method seems to enjoy wrapping lines. Temporarily | 251 // NSTextView's sizeToFit: method seems to enjoy wrapping lines. Temporarily |
250 // set the size large to force it not to. | 252 // set the size large to force it not to. |
251 NSRect windowFrame = [[self window] frame]; | 253 NSRect windowFrame = [[self window] frame]; |
252 [exitLabel_ setFrameSize:windowFrame.size]; | 254 [exitLabel_ setFrameSize:windowFrame.size]; |
253 NSLayoutManager* layoutManager = [exitLabel_ layoutManager]; | 255 NSLayoutManager* layoutManager = [exitLabel_ layoutManager]; |
254 NSTextContainer* textContainer = [exitLabel_ textContainer]; | 256 NSTextContainer* textContainer = [exitLabel_ textContainer]; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 - (void)hideSoon { | 337 - (void)hideSoon { |
336 hideTimer_.reset( | 338 hideTimer_.reset( |
337 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay | 339 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay |
338 target:self | 340 target:self |
339 selector:@selector(hideTimerFired:) | 341 selector:@selector(hideTimerFired:) |
340 userInfo:nil | 342 userInfo:nil |
341 repeats:NO] retain]); | 343 repeats:NO] retain]); |
342 } | 344 } |
343 | 345 |
344 @end | 346 @end |
OLD | NEW |