+- (void)dealloc
+{
+ [m_image release];
+ [super dealloc];
+}
+- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
+{
+ NSSize labelSize = [super sizeOfLabel:shouldTruncateLabel];
+ if(!m_image)
+ return labelSize;
+ NSSize imageSize = [m_image size];
+ // scale image size
+ if(imageSize.height > labelSize.height)
+ {
+ imageSize.width *= labelSize.height/imageSize.height;
+ imageSize.height *= labelSize.height/imageSize.height;
+ [m_image setScalesWhenResized:YES];
+ [m_image setSize: imageSize];
+ }
+ labelSize.width += imageSize.width;
+ return labelSize;
+}
+- (void)drawLabel:(BOOL)shouldTruncateLabel inRect:(NSRect)tabRect
+{
+ if(m_image)
+ {
+ NSSize imageSize = [m_image size];
+ [m_image compositeToPoint:NSMakePoint(tabRect.origin.x,
+ tabRect.origin.y+imageSize.height)
+ operation:NSCompositeSourceOver];
+ tabRect.size.width -= imageSize.width;
+ tabRect.origin.x += imageSize.width;
+ }
+ [super drawLabel:shouldTruncateLabel inRect:tabRect];
+}
+- (NSImage*)image
+{
+ return m_image;
+}
+- (void)setImage:(NSImage*)image
+{
+ [image retain];
+ [m_image release];
+ m_image = image;
+ if(!m_image)
+ return;
+ [[NSPasteboard generalPasteboard]
+ declareTypes:[NSArray arrayWithObject:NSTIFFPboardType]
+ owner:nil];
+ [[NSPasteboard generalPasteboard]
+ setData:[m_image TIFFRepresentation]
+ forType:NSTIFFPboardType];
+}
+@end // implementation WXCTabViewImageItem : NSTabViewItem