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

Side by Side Diff: third_party/apple_sample_code/ImageAndTextCell.m

Issue 10793033: Fix cookie sheet icons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | third_party/apple_sample_code/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 File: ImageAndTextCell.m 2 File: ImageAndTextCell.m
3 Abstract: Subclass of NSTextFieldCell which can display text and an image simul taneously. 3 Abstract: Subclass of NSTextFieldCell which can display text and an image simul taneously.
4 Version: 1.0 4 Version: 1.0
5 5
6 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 6 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7 Inc. ("Apple") in consideration of your agreement to the following 7 Inc. ("Apple") in consideration of your agreement to the following
8 terms, and your use, installation, modification or redistribution of 8 terms, and your use, installation, modification or redistribution of
9 this Apple software constitutes acceptance of these terms. If you do 9 this Apple software constitutes acceptance of these terms. If you do
10 not agree with these terms, please do not use, install, modify or 10 not agree with these terms, please do not use, install, modify or
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { 115 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
116 if (image != nil) { 116 if (image != nil) {
117 NSRect imageFrame; 117 NSRect imageFrame;
118 NSSize imageSize = [image size]; 118 NSSize imageSize = [image size];
119 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinX Edge); 119 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinX Edge);
120 if ([self drawsBackground]) { 120 if ([self drawsBackground]) {
121 [[self backgroundColor] set]; 121 [[self backgroundColor] set];
122 NSRectFill(imageFrame); 122 NSRectFill(imageFrame);
123 } 123 }
124 imageFrame.origin.x += 3; 124 imageFrame.origin.x += 3;
125 imageFrame.origin.y += ceil((cellFrame.size.height - imageSize.height) / 2);
Robert Sesek 2012/07/17 21:41:34 Technically this should be std::ceil, but that'd r
125 imageFrame.size = imageSize; 126 imageFrame.size = imageSize;
126 127
127 if ([controlView isFlipped]) { 128 [image drawInRect:imageFrame
128 imageFrame.origin.y += ceil((cellFrame.size.height + imageFrame.size.heigh t) / 2); 129 fromRect:NSZeroRect
129 } else { 130 operation:NSCompositeSourceOver
130 imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.heigh t) / 2); 131 fraction:1.0
131 } 132 respectFlipped:YES
132 133 hints:nil];
133 [image compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver];
134 } 134 }
135 [super drawWithFrame:cellFrame inView:controlView]; 135 [super drawWithFrame:cellFrame inView:controlView];
136 } 136 }
137 137
138 - (NSSize)cellSize { 138 - (NSSize)cellSize {
139 NSSize cellSize = [super cellSize]; 139 NSSize cellSize = [super cellSize];
140 if (image != nil) { 140 if (image != nil) {
141 cellSize.width += [image size].width; 141 cellSize.width += [image size].width;
142 } 142 }
143 cellSize.width += 3; 143 cellSize.width += 3;
(...skipping 18 matching lines...) Expand all
162 return NSCellHitContentArea; 162 return NSCellHitContentArea;
163 } 163 }
164 } 164 }
165 // At this point, the cellFrame has been modified to exclude the portion for t he image. Let the superclass handle the hit testing at this point. 165 // At this point, the cellFrame has been modified to exclude the portion for t he image. Let the superclass handle the hit testing at this point.
166 return [super hitTestForEvent:event inRect:cellFrame ofView:controlView]; 166 return [super hitTestForEvent:event inRect:cellFrame ofView:controlView];
167 } 167 }
168 168
169 169
170 @end 170 @end
171 171
OLDNEW
« no previous file with comments | « no previous file | third_party/apple_sample_code/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698