Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: ui/base/cocoa/controls/hyperlink_text_view.mm

Issue 887823002: Finished swap out of old API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed formatting issues, changed code to perform string operations in C++ rather than ObjC Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/base/cocoa/controls/hyperlink_text_view.h ('k') | ui/base/cocoa/controls/hyperlink_text_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698