OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/cocoa/controls/hyperlink_text_view.h" | 5 #import "ui/base/cocoa/controls/hyperlink_text_view.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "ui/base/cocoa/nsview_additions.h" | 8 #include "ui/base/cocoa/nsview_additions.h" |
9 | 9 |
10 // The baseline shift for text in the NSTextView. | 10 // The baseline shift for text in the NSTextView. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 refusesFirstResponder_ = NO; | 95 refusesFirstResponder_ = NO; |
96 drawsBackgroundUsingSuperview_ = NO; | 96 drawsBackgroundUsingSuperview_ = NO; |
97 } | 97 } |
98 | 98 |
99 - (void)fixupCursor { | 99 - (void)fixupCursor { |
100 if ([[NSCursor currentCursor] isEqual:[NSCursor IBeamCursor]]) | 100 if ([[NSCursor currentCursor] isEqual:[NSCursor IBeamCursor]]) |
101 [[NSCursor arrowCursor] set]; | 101 [[NSCursor arrowCursor] set]; |
102 } | 102 } |
103 | 103 |
104 - (void)setMessageAndLink:(NSString*)message | |
105 withLink:(NSString*)link | |
106 atOffset:(NSUInteger)linkOffset | |
107 font:(NSFont*)font | |
108 messageColor:(NSColor*)messageColor | |
109 linkColor:(NSColor*)linkColor { | |
110 NSMutableString* finalMessage = [NSMutableString stringWithString:message]; | |
111 [finalMessage insertString:link atIndex:linkOffset]; | |
112 [self setMessage:finalMessage withFont:font messageColor:messageColor]; | |
113 if ([link length] != 0) { | |
114 [self addLinkRange:NSMakeRange(linkOffset, [link length]) | |
115 withName:@"" | |
116 linkColor:linkColor]; | |
117 } | |
118 } | |
119 | |
120 - (void)setMessage:(NSString*)message | 104 - (void)setMessage:(NSString*)message |
121 withFont:(NSFont*)font | 105 withFont:(NSFont*)font |
122 messageColor:(NSColor*)messageColor { | 106 messageColor:(NSColor*)messageColor { |
123 // Create an attributes dictionary for the message and link. | 107 // Create an attributes dictionary for the message and link. |
124 NSDictionary* attributes = @{ | 108 NSDictionary* attributes = @{ |
125 NSForegroundColorAttributeName : messageColor, | 109 NSForegroundColorAttributeName : messageColor, |
126 NSCursorAttributeName : [NSCursor arrowCursor], | 110 NSCursorAttributeName : [NSCursor arrowCursor], |
127 NSFontAttributeName : font, | 111 NSFontAttributeName : font, |
128 NSBaselineOffsetAttributeName : @(kTextBaselineShift) | 112 NSBaselineOffsetAttributeName : @(kTextBaselineShift) |
129 }; | 113 }; |
(...skipping 19 matching lines...) Expand all Loading... |
149 }; | 133 }; |
150 | 134 |
151 [[self textStorage] addAttributes:attributes range:range]; | 135 [[self textStorage] addAttributes:attributes range:range]; |
152 } | 136 } |
153 | 137 |
154 - (void)setRefusesFirstResponder:(BOOL)refusesFirstResponder { | 138 - (void)setRefusesFirstResponder:(BOOL)refusesFirstResponder { |
155 refusesFirstResponder_ = refusesFirstResponder; | 139 refusesFirstResponder_ = refusesFirstResponder; |
156 } | 140 } |
157 | 141 |
158 @end | 142 @end |
OLD | NEW |