Revision: 18303
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18303&view=rev
Author: hofman
Date: 2011-12-09 12:55:42 +0000 (Fri, 09 Dec 2011)
Log Message:
-----------
take into account frame adjustment in address text field for drag image
Modified Paths:
--------------
trunk/bibdesk/BDSKAddressTextField.m
trunk/bibdesk/BDSKAddressTextFieldCell.h
trunk/bibdesk/BDSKAddressTextFieldCell.m
Modified: trunk/bibdesk/BDSKAddressTextField.m
===================================================================
--- trunk/bibdesk/BDSKAddressTextField.m 2011-12-08 22:50:19 UTC (rev
18302)
+++ trunk/bibdesk/BDSKAddressTextField.m 2011-12-09 12:55:42 UTC (rev
18303)
@@ -146,7 +146,7 @@
- (void)mouseDown:(NSEvent *)theEvent {
if ([[self delegate]
respondsToSelector:@selector(addressTextField:writeDataToPasteboard:)]) {
- NSRect iconRect = [[self cell] iconRectForBounds:[self bounds]];
+ NSRect iconRect = [[self cell] iconRectForBounds:[[self cell]
layoutRectForBounds:[self bounds] inView:self]];
NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
if (NSMouseInRect(mouseLoc, iconRect, [self isFlipped])) {
NSEvent *nextEvent = [[self window] nextEventMatchingMask:
NSLeftMouseUpMask | NSLeftMouseDraggedMask];
@@ -157,21 +157,20 @@
if ([[self delegate] addressTextField:self
writeDataToPasteboard:pboard]) {
NSImage *dragImage = nil;
- NSSize imageSize = NSZeroSize;
NSImage *image = nil;
NSRect drawRect = [self bounds];
- NSRect rect = [[self cell] iconRectForBounds:drawRect];
- NSPoint dragPoint = rect.origin;
- if ([self isFlipped])
- dragPoint.y += NSHeight(rect);
- drawRect.origin.x -= NSMinX(rect);
- drawRect.origin.y -= NSMinY(rect);
- image = [[NSImage alloc] initWithSize:rect.size];
+ NSPoint dragPoint = iconRect.origin;
+ if ([self isFlipped]) {
+ dragPoint.y += NSHeight(iconRect);
+ iconRect.origin.y = NSMaxY(drawRect) -
NSMaxY(iconRect);
+ }
+ drawRect.origin.x -= NSMinX(iconRect);
+ drawRect.origin.y -= NSMinY(iconRect);
+ image = [[NSImage alloc] initWithSize:iconRect.size];
[image lockFocus];
[[self cell] drawInteriorWithFrame:drawRect inView:nil];
[image unlockFocus];
- imageSize = [image size];
- dragImage = [[[NSImage alloc] initWithSize:imageSize]
autorelease];
+ dragImage = [[[NSImage alloc] initWithSize:iconRect.size]
autorelease];
[dragImage lockFocus];
[image drawAtPoint:NSZeroPoint fromRect:NSZeroRect
operation:NSCompositeCopy fraction:0.7];
[dragImage unlockFocus];
Modified: trunk/bibdesk/BDSKAddressTextFieldCell.h
===================================================================
--- trunk/bibdesk/BDSKAddressTextFieldCell.h 2011-12-08 22:50:19 UTC (rev
18302)
+++ trunk/bibdesk/BDSKAddressTextFieldCell.h 2011-12-09 12:55:42 UTC (rev
18303)
@@ -41,4 +41,5 @@
@interface BDSKAddressTextFieldCell : BDSKTextWithIconCell
+- (NSRect)layoutRectForBounds:(NSRect)aRect inView:(NSView *)controlView;
@end
Modified: trunk/bibdesk/BDSKAddressTextFieldCell.m
===================================================================
--- trunk/bibdesk/BDSKAddressTextFieldCell.m 2011-12-08 22:50:19 UTC (rev
18302)
+++ trunk/bibdesk/BDSKAddressTextFieldCell.m 2011-12-09 12:55:42 UTC (rev
18303)
@@ -58,7 +58,7 @@
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
- NSRect outlineRect = adjustedFrame(cellFrame, controlView);
+ NSRect outlineRect = [self layoutRectForBounds:cellFrame
inView:controlView];
NSRect outerShadowRect, innerShadowRect, ignored;
NSGradient *gradient = nil;
@@ -97,16 +97,22 @@
return rect;
}
+- (NSRect)layoutRectForBounds:(NSRect)aRect inView:(NSView *)controlView {
+ NSRect ignored;
+ NSDivideRect(aRect, &ignored, &aRect, 1.0, [controlView isFlipped] ?
NSMaxYEdge : NSMinYEdge);
+ return aRect;
+}
+
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
- [super drawInteriorWithFrame:adjustedFrame(cellFrame, controlView)
inView:controlView];
+ [super drawInteriorWithFrame:[self layoutRectForBounds:cellFrame
inView:controlView] inView:controlView];
}
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent {
- [super editWithFrame:adjustedFrame(aRect, controlView) inView:controlView
editor:textObj delegate:anObject event:theEvent];
+ [super editWithFrame:[self layoutRectForBounds:aRect inView:controlView]
inView:controlView editor:textObj delegate:anObject event:theEvent];
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart
length:(NSInteger)selLength {
- [super selectWithFrame:adjustedFrame(aRect, controlView)
inView:controlView editor:textObj delegate:anObject start:selStart
length:selLength];
+ [super selectWithFrame:[self layoutRectForBounds:aRect inView:controlView]
inView:controlView editor:textObj delegate:anObject start:selStart
length:selLength];
}
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit