Camino only - Bug 390576: Add title support to ThumbnailView. Patch by Jeff Dlouhy <Jeff.Dlouhy@gmail.com>. r=murph r=hwaara sr=smorgan

This commit is contained in:
stuart.morgan%alumni.case.edu 2007-08-28 00:34:31 +00:00
Родитель c3a0267055
Коммит 6cec7f3c6a
3 изменённых файлов: 26 добавлений и 6 удалений

Просмотреть файл

@ -110,6 +110,7 @@ CGColorSpaceRef getTheGreyColorSpace(void);
if (curThumbView) {
[curThumbView setThumbnail:thumb];
[curThumbView setRepresentedObject:tabViewItem];
[curThumbView setTitle:[[tabViewItem labelCell] title]];
[curThumbView setDelegate:self];
[self addSubview:curThumbView];
}

Просмотреть файл

@ -48,12 +48,14 @@
@interface ThumbnailView : NSView {
NSImage* mThumbnail;
NSObject* mRepresentedObject;
NSCell* mTitleCell;
id mDelegate;
}
- (void)setThumbnail:(NSImage*)image;
- (void)setRepresentedObject:(id)object;
- (id)representedObject;
- (void)setTitle:(NSString*)title;
- (void)setDelegate:(id)delegate;
- (id)delegate;

Просмотреть файл

@ -38,16 +38,20 @@
#import "ThumbnailView.h"
const int kShadowX = 0;
const int kShadowY = -3;
const int kShadowRadius = 5;
const int kShadowPadding = 5;
static const int kShadowX = 0;
static const int kShadowY = -3;
static const int kShadowRadius = 5;
static const int kShadowPadding = 5;
static const int kThumbnailTitleHeight = 20;
@implementation ThumbnailView
- (id)initWithFrame:(NSRect)frame {
if ((self = [super initWithFrame:frame]))
if ((self = [super initWithFrame:frame])) {
mThumbnail = nil;
mTitleCell = [[NSCell alloc] initTextCell:@""];
[mTitleCell setAlignment:NSCenterTextAlignment];
}
return self;
}
@ -60,6 +64,11 @@ const int kShadowPadding = 5;
}
}
- (void)setTitle:(NSString*)title
{
[mTitleCell setTitle:title];
}
- (void)setRepresentedObject:(id)object
{
if (mRepresentedObject != object) {
@ -90,15 +99,22 @@ const int kShadowPadding = 5;
[shadow setShadowBlurRadius:kShadowRadius];
[shadow set];
NSRect thumbnailImageRect;
NSRect thumbnailTitleRect;
NSDivideRect([self bounds], &thumbnailTitleRect, &thumbnailImageRect, kThumbnailTitleHeight, NSMinYEdge);
if (mThumbnail) {
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
[mThumbnail setScalesWhenResized:YES];
[mThumbnail drawInRect:NSInsetRect([self bounds], kShadowPadding, kShadowPadding)
[mThumbnail drawInRect:NSInsetRect(thumbnailImageRect, kShadowPadding, kShadowPadding)
fromRect:NSZeroRect
operation:NSCompositeSourceOver
fraction:1];
}
if (mTitleCell)
[mTitleCell drawWithFrame:thumbnailTitleRect inView:self];
}
- (void)mouseUp:(NSEvent*)theEvent
@ -110,6 +126,7 @@ const int kShadowPadding = 5;
- (void)dealloc
{
[mThumbnail release];
[mTitleCell release];
[mRepresentedObject release];
[super dealloc];
}