aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--Source/ImageAndTextCell.m46
-rw-r--r--Source/SPFavoriteTextFieldCell.m20
-rw-r--r--Source/SPPreferenceController.m13
3 files changed, 60 insertions, 19 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;
}
diff --git a/Source/SPFavoriteTextFieldCell.m b/Source/SPFavoriteTextFieldCell.m
index af65d28e..1c1c6f86 100644
--- a/Source/SPFavoriteTextFieldCell.m
+++ b/Source/SPFavoriteTextFieldCell.m
@@ -129,14 +129,14 @@
// Total height of both strings with a 2 pixel separation space
float totalHeight = [mainString size].height + [subString size].height + 1.0;
- cellFrame.origin.y += (cellFrame.size.height - totalHeight) / 2.0;
+ cellFrame.origin.y += (cellFrame.size.height - totalHeight) / 2.0;
cellFrame.origin.x += 10.0; // Indent main string from image
// Position the sub text's frame rect
subFrame.origin.y = [mainString size].height + cellFrame.origin.y + 1.0;
subFrame.origin.x = cellFrame.origin.x;
- cellFrame.size.height = totalHeight;
+ cellFrame.size.height = totalHeight;
int i;
float maxWidth = cellFrame.size.width;
@@ -166,10 +166,20 @@
[subString drawInRect:subFrame];
}
-// Suppress built-in tooltips
-- (NSRect)expansionFrameWithFrame:(NSRect)cellFrame inView:(NSView *)view
+- (NSSize)cellSize
{
- return NSMakeRect(0,0,0,0);
+ NSSize cellSize = [super cellSize];
+ NSAttributedString *mainString = [[self attributedStringForFavoriteName] autorelease];
+ NSAttributedString *subString = [[self constructSubStringAttributedString] autorelease];
+
+ // 15 := indention 10 from image to string plus 5 px padding
+ float theWidth = MAX([mainString size].width, [subString size].width) + (([self image] != nil) ? [[self image] size].width : 0) + 15;
+
+ float totalHeight = [mainString size].height + [subString size].height + 1.0;
+
+ cellSize.width = theWidth;
+ cellSize.height = totalHeight + 13.0;
+ return cellSize;
}
// -------------------------------------------------------------------------------
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index aed79610..36834616 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -29,7 +29,6 @@
#import "SPKeychain.h"
#import "TableDocument.h"
#import "SPConnectionController.h"
-#import "SPTooltip.h"
#define FAVORITES_PB_DRAG_TYPE @"SequelProPreferencesPasteboard"
@@ -669,18 +668,6 @@
favoriteNameFieldWasTouched = YES;
}
-- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPFavoriteTextFieldCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation
-{
- NSRect r = *rect;
- // No tooltip if cellSize < controlSize
- if([aCell cellSize].width < r.size.width-20) return nil;
-
- NSPoint pos = [NSEvent mouseLocation];
- pos.y -= 20;
- [SPTooltip showWithObject:[NSString stringWithFormat:@"<span style='font-size:larger;'>%@</span><br><font color='darkgrey'>%@</font>", [aCell favoriteName], [aCell favoriteHost]] atLocation:pos ofType:@"html"];
- return nil;
-}
-
#pragma mark -
#pragma mark Toolbar delegate methods