aboutsummaryrefslogtreecommitdiffstats
path: root/Source/ImageAndTextCell.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-10-12 15:59:07 +0000
committerBibiko <bibiko@eva.mpg.de>2009-10-12 15:59:07 +0000
commit9fc4f973499e8d3bf327f699cd0e18d7e640a54d (patch)
tree9d190c8667790440b4743c6ac1331f9a9db112fb /Source/ImageAndTextCell.m
parent29c40c62b9afa5eb3c61b8904b5213750bed558a (diff)
downloadsequelpro-9fc4f973499e8d3bf327f699cd0e18d7e640a54d.tar.gz
sequelpro-9fc4f973499e8d3bf327f699cd0e18d7e640a54d.tar.bz2
sequelpro-9fc4f973499e8d3bf327f699cd0e18d7e640a54d.zip
• first steps to improve the general tooltip behaviour of 'ImageAndTextCell' class
• simplified the tooltip of Preference's Favorite List
Diffstat (limited to 'Source/ImageAndTextCell.m')
-rw-r--r--Source/ImageAndTextCell.m46
1 files changed, 45 insertions, 1 deletions
diff --git a/Source/ImageAndTextCell.m b/Source/ImageAndTextCell.m
index 345d4aeb..ad6ec247 100644
--- a/Source/ImageAndTextCell.m
+++ b/Source/ImageAndTextCell.m
@@ -81,6 +81,44 @@
[super selectWithFrame:aRect inView: controlView editor:textObj delegate:anObject start:selStart length:selLength];
}
+- (void)drawWithExpansionFrame:(NSRect)cellFrame inView:(NSView *)view
+{
+ if (_indentationLevel != 0)
+ {
+ NSRect indentationFrame;
+ NSDivideRect(cellFrame, &indentationFrame, &cellFrame, (INDENT_AMOUNT * _indentationLevel), NSMinXEdge);
+ }
+
+ if (image != nil)
+ {
+ NSSize imageSize;
+ NSRect imageFrame;
+
+ imageSize = [image size];
+ NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge);
+ if ([self drawsBackground])
+ {
+ [[self backgroundColor] set];
+ NSRectFill(imageFrame);
+ }
+ imageFrame.origin.x += 3;
+
+ imageFrame.size = imageSize;
+
+ if ([view isFlipped])
+ imageFrame.origin.y += ceil((cellFrame.size.height + imageFrame.size.height) / 2);
+ else
+ imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
+
+ [image compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver];
+ } else
+ if (_indentationLevel == 0)
+ cellFrame.size.height = [view frame].size.height+2;
+
+ [super drawWithExpansionFrame:cellFrame inView:view];
+
+}
+
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if (_indentationLevel != 0)
@@ -111,13 +149,19 @@
[image compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver];
}
+
[super drawWithFrame:cellFrame inView:controlView];
}
- (NSSize)cellSize
{
NSSize cellSize = [super cellSize];
- cellSize.width += (image ? [image size].width : 0) + ((1 - MIN(1,INDENT_AMOUNT)) * 3) + (INDENT_AMOUNT * _indentationLevel);
+ cellSize.width += (image ? [image size].width : 0) + ((1 - MIN(1,INDENT_AMOUNT)) * 3) + (INDENT_AMOUNT * _indentationLevel) + 2;
+ // TODO : this has to be generalized yet
+ if (image != nil)
+ cellSize.height += 2;
+ else
+ cellSize.height += 8;
return cellSize;
}