Revision: 18319
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18319&view=rev
Author:   hofman
Date:     2011-12-15 12:56:56 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
convenience functions to divide a rect returning only one part

Modified Paths:
--------------
    trunk/bibdesk/BDSKAddressTextFieldCell.m
    trunk/bibdesk/BDSKComplexStringEditor.m
    trunk/bibdesk/BDSKEditorTextFieldCell.m
    trunk/bibdesk/BDSKGroupCell.m
    trunk/bibdesk/BDSKGroupOutlineView.m
    trunk/bibdesk/BDSKMainTableView.m
    trunk/bibdesk/BDSKNotesOutlineView.m
    trunk/bibdesk/BDSKPreferenceIconCell.m
    trunk/bibdesk/BDSKReadMeController.m
    trunk/bibdesk/BDSKStatusBar.m
    trunk/bibdesk/BDSKTextWithIconCell.m
    trunk/bibdesk/BibDocument_DataSource.m
    trunk/bibdesk/NSGeometry_BDSKExtensions.h

Modified: trunk/bibdesk/BDSKAddressTextFieldCell.m
===================================================================
--- trunk/bibdesk/BDSKAddressTextFieldCell.m    2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKAddressTextFieldCell.m    2011-12-15 12:56:56 UTC (rev 
18319)
@@ -37,6 +37,7 @@
  */
 
 #import "BDSKAddressTextFieldCell.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 
 @implementation BDSKAddressTextFieldCell
@@ -50,24 +51,20 @@
 }
 
 - (NSRect)textRectForBounds:(NSRect)aRect {
-    NSRect ignored, rect = [super textRectForBounds:aRect];
-    NSDivideRect(rect, &ignored, &rect, 17.0, NSMaxXEdge);
-    return rect;
+    return BDSKShrinkRect([super textRectForBounds:aRect], 17.0, NSMaxXEdge);
 }
 
 - (NSRect)adjustedFrame:(NSRect)aRect inView:(NSView *)controlView {
-       NSRect ignored;
-    NSDivideRect(aRect, &ignored, &aRect, 1.0, [controlView isFlipped] ? 
NSMaxYEdge : NSMinYEdge);
-    return aRect;
+    return BDSKShrinkRect(aRect, 1.0, [controlView isFlipped] ? NSMaxYEdge : 
NSMinYEdge);
 }
 
 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
        NSRect outlineRect = [self adjustedFrame:cellFrame inView:controlView];
-    NSRect outerShadowRect, innerShadowRect, ignored;
+    NSRect outerShadowRect, innerShadowRect;
        NSGradient *gradient = nil;
     
-    NSDivideRect(cellFrame, &outerShadowRect, &ignored, 10.0, [controlView 
isFlipped] ? NSMaxYEdge : NSMinYEdge);
-    NSDivideRect(NSInsetRect(cellFrame, 1.0, 1.0), &innerShadowRect, &ignored, 
10.0, [controlView isFlipped] ? NSMinYEdge : NSMaxYEdge);
+    outerShadowRect = BDSKSliceRect(cellFrame, 10.0, [controlView isFlipped] ? 
NSMaxYEdge : NSMinYEdge);
+    innerShadowRect = BDSKSliceRect(NSInsetRect(cellFrame, 1.0, 1.0), 10.0, 
[controlView isFlipped] ? NSMinYEdge : NSMaxYEdge);
     
        [[NSColor colorWithCalibratedWhite:1.0 alpha:0.394] set];
        [[NSBezierPath bezierPathWithRoundedRect:outerShadowRect xRadius:3.6 
yRadius:3.6] fill];

Modified: trunk/bibdesk/BDSKComplexStringEditor.m
===================================================================
--- trunk/bibdesk/BDSKComplexStringEditor.m     2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKComplexStringEditor.m     2011-12-15 12:56:56 UTC (rev 
18319)
@@ -39,6 +39,7 @@
 #import "BDSKMacroResolver.h"
 #import "BDSKBackgroundView.h"
 #import "NSWindowController_BDSKExtensions.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 @interface BDSKComplexStringEditor (Private)
 
@@ -200,13 +201,13 @@
 
 - (void)cellFrameDidChange:(NSNotification *)notification {
        NSRectEdge lowerEdge = [tableView isFlipped] ? NSMaxYEdge : NSMinYEdge;
-       NSRect lowerEdgeRect, ignored;
+       NSRect lowerEdgeRect;
        NSRect winFrame = [[self window] frame];
        CGFloat margin = 4.0; // for the shadow and focus ring
        CGFloat minWidth = 16.0; // minimal width of the window without 
margins, so subviews won't get shifted
        NSView *contentView = (NSView *)[[tableView enclosingScrollView] 
contentView] ?: (NSView *)tableView;
        
-       NSDivideRect([tableView frameOfCellAtColumn:column row:row], 
&lowerEdgeRect, &ignored, 1.0, lowerEdge);
+       lowerEdgeRect = BDSKSliceRect([tableView frameOfCellAtColumn:column 
row:row], 1.0, lowerEdge);
        lowerEdgeRect = NSIntersectionRect(lowerEdgeRect, [contentView 
visibleRect]);
        // see if the cell's lower edge is scrolled out of sight
        if (NSIsEmptyRect(lowerEdgeRect)) {

Modified: trunk/bibdesk/BDSKEditorTextFieldCell.m
===================================================================
--- trunk/bibdesk/BDSKEditorTextFieldCell.m     2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKEditorTextFieldCell.m     2011-12-15 12:56:56 UTC (rev 
18319)
@@ -38,6 +38,7 @@
 
 #import "BDSKEditorTextFieldCell.h"
 #import "NSImage_BDSKExtensions.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 #define BUTTON_MARGIN 2.0
 #define BUTTON_SIZE NSMakeSize(12.0, 12.0)
@@ -193,11 +194,8 @@
 }
 
 - (NSRect)drawingRectForBounds:(NSRect)theRect {
-       if ([self hasButton] || [self URL]) {
-        NSRect ignored;
-        NSSize size = BUTTON_SIZE;
-        NSDivideRect(theRect, &ignored, &theRect, size.width + BUTTON_MARGIN, 
NSMaxXEdge);
-    }
+       if ([self hasButton] || [self URL])
+        theRect = BDSKShrinkRect(theRect, BUTTON_SIZE.width + BUTTON_MARGIN, 
NSMaxXEdge);
     return [super drawingRectForBounds:theRect];
 }
 

Modified: trunk/bibdesk/BDSKGroupCell.m
===================================================================
--- trunk/bibdesk/BDSKGroupCell.m       2011-12-15 12:19:46 UTC (rev 18318)
+++ trunk/bibdesk/BDSKGroupCell.m       2011-12-15 12:56:56 UTC (rev 18319)
@@ -221,10 +221,7 @@
 
 - (NSRect)iconRectForBounds:(NSRect)aRect {
     NSSize imageSize = [self iconSizeForBounds:aRect];
-    NSRect imageRect, ignored;
-    NSDivideRect(aRect, &ignored, &imageRect, BORDER_BETWEEN_EDGE_AND_IMAGE, 
NSMinXEdge);
-    NSDivideRect(imageRect, &imageRect, &ignored, imageSize.width, NSMinXEdge);
-    return imageRect;
+    return BDSKSliceRect(BDSKShrinkRect(aRect, BORDER_BETWEEN_EDGE_AND_IMAGE, 
NSMinXEdge), imageSize.width, NSMinXEdge);
 }
 
 - (NSRect)countRectForBounds:(NSRect)aRect {
@@ -239,15 +236,12 @@
         countSize = [countString boundingRectWithSize:aRect.size 
options:0].size;
         countSize.width += [self countPaddingForSize:countSize]; // add oval 
pading around count
     }
-    NSRect countRect, ignored;
-    if (countSize.width > 0.0) {
-        NSDivideRect(aRect, &ignored, &countRect, 
BORDER_BETWEEN_EDGE_AND_COUNT, NSMaxXEdge);
-        NSDivideRect(countRect, &countRect, &ignored, countSize.width, 
NSMaxXEdge);
+    NSRect countRect;
+    if (countSize.width > 0.0)
         // now set the size of it to the string size
-        countRect = BDSKCenterRect(countRect, countSize, YES);
-    } else {
-        NSDivideRect(aRect, &countRect, &ignored, 0.0, NSMaxXEdge);
-    }
+        countRect = BDSKCenterRect(BDSKSliceRect(BDSKShrinkRect(aRect, 
BORDER_BETWEEN_EDGE_AND_COUNT, NSMaxXEdge), countSize.width, NSMaxXEdge), 
countSize, YES);
+    else
+        countRect = BDSKSliceRect(aRect, 0.0, NSMaxXEdge);
     return countRect;
 }    
 
@@ -381,8 +375,7 @@
     }
     
     if ([self label]) {
-        NSRect ignored;
-        NSDivideRect(textRect, &textRect, &ignored, [self labelHeight], 
[controlView isFlipped] ? NSMaxYEdge : NSMinYEdge);
+        textRect = BDSKSliceRect(textRect, [self labelHeight], [controlView 
isFlipped] ? NSMaxYEdge : NSMinYEdge);
         [labelCell drawInteriorWithFrame:textRect inView:controlView];
     }
     

Modified: trunk/bibdesk/BDSKGroupOutlineView.m
===================================================================
--- trunk/bibdesk/BDSKGroupOutlineView.m        2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKGroupOutlineView.m        2011-12-15 12:56:56 UTC (rev 
18319)
@@ -47,6 +47,7 @@
 #import "BDSKGroupCell.h"
 #import "NSFont_BDSKExtensions.h"
 #import "NSColor_BDSKExtensions.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 
 @interface BDSKParentGroupCell : NSTextFieldCell
@@ -245,9 +246,7 @@
 @implementation BDSKParentGroupCell
 
 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
-    NSRect ignored;
-    NSDivideRect(cellFrame, &ignored, &cellFrame, 3.0, NSMinYEdge);
-    [super drawInteriorWithFrame:cellFrame inView:controlView];
+    [super drawInteriorWithFrame:BDSKShrinkRect(cellFrame, 3.0, NSMinYEdge) 
inView:controlView];
 }
 
 @end

Modified: trunk/bibdesk/BDSKMainTableView.m
===================================================================
--- trunk/bibdesk/BDSKMainTableView.m   2011-12-15 12:19:46 UTC (rev 18318)
+++ trunk/bibdesk/BDSKMainTableView.m   2011-12-15 12:56:56 UTC (rev 18319)
@@ -54,6 +54,7 @@
 #import "NSMenu_BDSKExtensions.h"
 #import "NSArray_BDSKExtensions.h"
 #import "NSWindowController_BDSKExtensions.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 enum {
     BDSKColumnTypeText,
@@ -238,12 +239,12 @@
         NSRange visibleRows = [self rowsInRect:clipRect];
         NSUInteger row;
         NSColor *color;
-        NSRect ignored, rect;
+        NSRect rect;
         for (row = visibleRows.location; row < NSMaxRange(visibleRows); row++) 
{
             if ((color = [[self delegate] tableView:self 
highlightColorForRow:row])) {
                 [NSGraphicsContext saveGraphicsState];
                 [color set];
-                NSDivideRect([self rectOfRow:row], &ignored, &rect, 1.0, 
NSMaxYEdge);
+                rect = BDSKShrinkRect([self rectOfRow:row], 1.0, NSMaxYEdge);
                 if ([self isRowSelected:row]) {
                     [NSBezierPath setDefaultLineWidth:2.0];
                     [NSBezierPath strokeHorizontalOvalInRect:NSInsetRect(rect, 
2.0, 1.0)];
@@ -790,7 +791,7 @@
     NSColor *color = [self objectValue];
     if ([color respondsToSelector:@selector(drawSwatchInRect:)]) {
         NSRect rect, ignored;
-        NSDivideRect(cellFrame, &ignored, &rect, 1.0, [controlView isFlipped] 
? NSMaxYEdge : NSMinYEdge);
+        rect = BDSKShrinkRect(cellFrame, 1.0, [controlView isFlipped] ? 
NSMaxYEdge : NSMinYEdge);
         [color drawSwatchInRect:rect];
     }
 }

Modified: trunk/bibdesk/BDSKNotesOutlineView.m
===================================================================
--- trunk/bibdesk/BDSKNotesOutlineView.m        2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKNotesOutlineView.m        2011-12-15 12:56:56 UTC (rev 
18319)
@@ -37,6 +37,7 @@
  */
 
 #import "BDSKNotesOutlineView.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 
 @implementation BDSKNotesOutlineView
@@ -80,8 +81,7 @@
         NSInteger row = [self rowAtPoint:mouseLoc];
         
         if (row != -1 && [[self delegate] outlineView:self 
canResizeRowByItem:[self itemAtRow:row]]) {
-            NSRect ignored, rect;
-            NSDivideRect([self rectOfRow:row], &rect, &ignored, 5.0, [self 
isFlipped] ? NSMaxYEdge : NSMinYEdge);
+            NSRect rect = BDSKSliceRect([self rectOfRow:row], 5.0, [self 
isFlipped] ? NSMaxYEdge : NSMinYEdge);
             if (NSMouseInRect(mouseLoc, rect, [self isFlipped]) && 
NSLeftMouseDragged == [[NSApp nextEventMatchingMask:(NSLeftMouseUpMask | 
NSLeftMouseDraggedMask) untilDate:[NSDate distantFuture] 
inMode:NSEventTrackingRunLoopMode dequeue:NO] type]) {
                 [self resizeRow:row withEvent:theEvent];
                 return;
@@ -153,8 +153,7 @@
             id item = [self itemAtRow:row];
             if ([[self delegate] outlineView:self canResizeRowByItem:item] == 
NO)
                 continue;
-            NSRect ignored, rect = [self rectOfRow:row];
-            NSDivideRect(rect, &rect, &ignored, 5.0, [self isFlipped] ? 
NSMaxYEdge : NSMinYEdge);
+            NSRect rect = BDSKSliceRect([self rectOfRow:row], 5.0, [self 
isFlipped] ? NSMaxYEdge : NSMinYEdge);
             [self addCursorRect:rect cursor:[NSCursor resizeUpDownCursor]];
         }
     } else {

Modified: trunk/bibdesk/BDSKPreferenceIconCell.m
===================================================================
--- trunk/bibdesk/BDSKPreferenceIconCell.m      2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKPreferenceIconCell.m      2011-12-15 12:56:56 UTC (rev 
18319)
@@ -37,16 +37,15 @@
  */
 
 #import "BDSKPreferenceIconCell.h"
+#import "NSGeometry_BDSKExtensions.h"
 
 
 @implementation BDSKPreferenceIconCell
 
 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
     NSSize cellSize = [self cellSizeForBounds:cellFrame];
-    if (cellSize.height < NSHeight(cellFrame)) {
-        NSRect ignored;
-        NSDivideRect(cellFrame, &cellFrame, &ignored, cellSize.height, 
[controlView isFlipped] ? NSMaxYEdge : NSMinYEdge);
-    }
+    if (cellSize.height < NSHeight(cellFrame))
+        cellFrame = BDSKSliceRect(cellFrame, cellSize.height, [controlView 
isFlipped] ? NSMaxYEdge : NSMinYEdge);
     [super drawWithFrame:cellFrame inView:controlView];
 }
 

Modified: trunk/bibdesk/BDSKReadMeController.m
===================================================================
--- trunk/bibdesk/BDSKReadMeController.m        2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKReadMeController.m        2011-12-15 12:56:56 UTC (rev 
18319)
@@ -38,6 +38,7 @@
 
 #import "BDSKReadMeController.h"
 #import "NSWorkspace_BDSKExtensions.h"
+#import "NSGeometry_BDSKExtensions.h"
 #include <sys/utsname.h>
 
 #define BDSKReadMeWindowFrameAutosaveName @"BDSKReadMeWindow"
@@ -89,8 +90,8 @@
                                    withRTF:[NSData 
dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"RelNotes" 
ofType:@"rtf"]]];
     } else {
         [[self window] setTitle:NSLocalizedString(@"Latest Release Notes", 
@"Window title")];
-        NSRect ignored, rect = [[textView enclosingScrollView] frame];
-        NSDivideRect(rect, &ignored, &rect, 61.0, NSMinYEdge);
+        NSRect rect = [[textView enclosingScrollView] frame];
+        rect = BDSKShrinkRect(rect, 61.0, NSMinYEdge);
         [[textView enclosingScrollView] setFrame:rect];
         [downloadButton setHidden:NO];
     }
@@ -155,8 +156,8 @@
 - (void)windowDidLoad {
     @try {
         [[self window] setTitle:NSLocalizedString(@"Error Log", @"Window 
title")];
-        NSRect ignored, rect = [[textView enclosingScrollView] frame];
-        NSDivideRect(rect, &ignored, &rect, 61.0, NSMinYEdge);
+        NSRect rect = [[textView enclosingScrollView] frame];
+        rect = BDSKShrinkRect(rect, 61.0, NSMinYEdge);
         [[textView enclosingScrollView] setFrame:rect];
         [downloadButton setHidden:NO];
         [downloadButton setTitle:NSLocalizedString(@"Report Error", @"Button 
title")];

Modified: trunk/bibdesk/BDSKStatusBar.m
===================================================================
--- trunk/bibdesk/BDSKStatusBar.m       2011-12-15 12:19:46 UTC (rev 18318)
+++ trunk/bibdesk/BDSKStatusBar.m       2011-12-15 12:56:56 UTC (rev 18319)
@@ -86,13 +86,12 @@
 }
 
 - (void)drawRect:(NSRect)rect {
-       NSRect textRect, ignored;
+       NSRect textRect;
     CGFloat fullRightMargin = rightMargin;
        
     if (progressIndicator)
         fullRightMargin += NSWidth([progressIndicator frame]) + 
MARGIN_BETWEEN_ITEMS;
-    NSDivideRect([self bounds], &ignored, &textRect, leftMargin, NSMinXEdge);
-    NSDivideRect(textRect, &ignored, &textRect, fullRightMargin, NSMaxXEdge);
+    textRect = BDSKShrinkRect(BDSKShrinkRect([self bounds], leftMargin, 
NSMinXEdge), fullRightMargin, NSMaxXEdge);
        
        NSImage *icon;
        NSRect iconRect;    
@@ -102,7 +101,7 @@
                icon = [dict objectForKey:@"icon"];
         size = [self cellSizeForIcon:icon];
         NSDivideRect(textRect, &iconRect, &textRect, size.width, NSMaxXEdge);
-        NSDivideRect(textRect, &ignored, &textRect, MARGIN_BETWEEN_ITEMS, 
NSMaxXEdge);
+        textRect = BDSKShrinkRect(textRect, MARGIN_BETWEEN_ITEMS, NSMaxXEdge);
         iconRect = BDSKCenterRectVertically(iconRect, size.height, NO);
         iconRect.origin.y += VERTICAL_OFFSET;
                [iconCell setImage:icon];
@@ -278,13 +277,13 @@
 }
 
 - (void)rebuildToolTips {
-       NSRect ignored, rect;
+       NSRect rect;
     CGFloat fullRightMargin = rightMargin;
        
        if (progressIndicator != nil) 
                fullRightMargin += NSMinX([progressIndicator frame]) + 
MARGIN_BETWEEN_ITEMS;
        
-    NSDivideRect([self bounds], &ignored, &rect, fullRightMargin, NSMaxXEdge);
+    rect = BDSKShrinkRect([self bounds], fullRightMargin, NSMaxXEdge);
     
        NSRect iconRect;
     NSSize size;
@@ -294,7 +293,7 @@
        for (NSDictionary *dict in icons) {
         size = [self cellSizeForIcon:[dict objectForKey:@"icon"]];
         NSDivideRect(rect, &iconRect, &rect, size.width, NSMaxXEdge);
-        NSDivideRect(rect, &ignored, &rect, MARGIN_BETWEEN_ITEMS, NSMaxXEdge);
+        rect = BDSKShrinkRect(rect, MARGIN_BETWEEN_ITEMS, NSMaxXEdge);
         iconRect = BDSKCenterRectVertically(iconRect, size.height, NO);
         iconRect.origin.y += VERTICAL_OFFSET;
                [self addToolTipRect:iconRect owner:self userData:[dict 
objectForKey:@"identifier"]];
@@ -349,11 +348,9 @@
                [progressIndicator setDisplayedWhenStopped:NO];
                [progressIndicator sizeToFit];
                
-               NSRect rect, ignored;
+               NSRect rect;
                NSSize size = [progressIndicator frame].size;
-        NSDivideRect([self bounds], &ignored, &rect, rightMargin, NSMaxXEdge);
-        NSDivideRect(rect, &rect, &ignored, size.width, NSMaxXEdge);
-        rect = BDSKCenterRect(rect, size, [self isFlipped]);
+        rect = BDSKCenterRect(BDSKSliceRect(BDSKShrinkRect([self bounds], 
rightMargin, NSMaxXEdge), size.width, NSMaxXEdge), size, [self isFlipped]);
         rect.origin.y += VERTICAL_OFFSET;
                [progressIndicator setFrame:rect];
                
@@ -390,15 +387,14 @@
 
 - (id)accessibilityHitTest:(NSPoint)point {
     NSPoint localPoint = [self convertPoint:[[self window] 
convertScreenToBase:point] fromView:nil];
-    NSRect rect, childRect, ignored;
+    NSRect rect, childRect;
     
-    NSDivideRect([self bounds], &ignored, &rect, leftMargin, NSMinXEdge);
-    NSDivideRect(rect, &ignored, &rect, rightMargin, NSMaxXEdge);
+    rect = BDSKShrinkRect(BDSKShrinkRect([self bounds], leftMargin, 
NSMinXEdge), rightMargin, NSMaxXEdge);
     if (progressIndicator) {
         NSDivideRect(rect, &childRect, &rect, NSWidth([progressIndicator 
frame]), NSMaxXEdge);
         if (NSMouseInRect(localPoint, childRect, [self isFlipped]))
             return NSAccessibilityUnignoredAncestor(progressIndicator);
-        NSDivideRect(rect, &ignored, &rect, MARGIN_BETWEEN_ITEMS, NSMaxXEdge);
+        rect = BDSKShrinkRect(rect, MARGIN_BETWEEN_ITEMS, NSMaxXEdge);
        }
     return NSAccessibilityUnignoredAncestor(textCell);
 }

Modified: trunk/bibdesk/BDSKTextWithIconCell.m
===================================================================
--- trunk/bibdesk/BDSKTextWithIconCell.m        2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BDSKTextWithIconCell.m        2011-12-15 12:56:56 UTC (rev 
18319)
@@ -125,7 +125,7 @@
 }
 
 - (NSRect)textRectForBounds:(NSRect)aRect {
-    NSRect ignored, textRect = aRect;
+    NSRect textRect = aRect;
     CGFloat border;
     
     if ([self isBordered])
@@ -135,14 +135,11 @@
     else
         border = NSHeight(aRect) - 1 + 
BORDER_BETWEEN_EDGE_AND_IMAGE_BORDERLESS + 
BORDER_BETWEEN_IMAGE_AND_TEXT_BORDERLESS;
     
-    NSDivideRect(aRect, &ignored, &textRect, border, NSMinXEdge);
-    
-    return textRect;
+    return BDSKShrinkRect(aRect, border, NSMinXEdge);
 }
 
 - (NSRect)iconRectForBounds:(NSRect)aRect {
     CGFloat border, imageWidth;
-    NSRect ignored, imageRect = aRect;
     
     if ([self isBordered]) {
         border = BORDER_BETWEEN_EDGE_AND_IMAGE_BORDERED;
@@ -156,10 +153,7 @@
         imageWidth = NSHeight(aRect) - 1;
     }
     
-    NSDivideRect(aRect, &ignored, &imageRect, border, NSMinXEdge);
-    NSDivideRect(imageRect, &imageRect, &ignored, imageWidth, NSMinXEdge);
-    
-    return imageRect;
+    return BDSKSliceRect(BDSKShrinkRect(aRect, border, NSMinXEdge), 
imageWidth, NSMinXEdge);
 }
 
 - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView {

Modified: trunk/bibdesk/BibDocument_DataSource.m
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.m      2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/BibDocument_DataSource.m      2011-12-15 12:56:56 UTC (rev 
18319)
@@ -1064,11 +1064,9 @@
     
     if (spinner) {
         NSInteger column = [[outlineView tableColumns] 
indexOfObject:tableColumn];
-        NSRect ignored, rect = [outlineView frameOfCellAtColumn:column 
row:[outlineView rowForItem:item]];
+        NSRect rect = [outlineView frameOfCellAtColumn:column row:[outlineView 
rowForItem:item]];
         NSSize size = [spinner frame].size;
-        NSDivideRect(rect, &ignored, &rect, 2.0f, NSMaxXEdge);
-        NSDivideRect(rect, &rect, &ignored, size.width, NSMaxXEdge);
-        rect = BDSKCenterRectVertically(rect, size.height, [outlineView 
isFlipped]);
+        rect = BDSKCenterRectVertically(BDSKSliceRect(BDSKShrinkRect(rect, 
2.0f, NSMaxXEdge), size.width, NSMaxXEdge), size.height, [outlineView 
isFlipped]);
         
         [spinner setFrame:rect];
         if ([spinner isDescendantOf:outlineView] == NO)

Modified: trunk/bibdesk/NSGeometry_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSGeometry_BDSKExtensions.h   2011-12-15 12:19:46 UTC (rev 
18318)
+++ trunk/bibdesk/NSGeometry_BDSKExtensions.h   2011-12-15 12:56:56 UTC (rev 
18319)
@@ -41,3 +41,15 @@
 extern NSRect BDSKCenterRect(NSRect rect, NSSize size, BOOL flipped);
 extern NSRect BDSKCenterRectVertically(NSRect rect, CGFloat height, BOOL 
flipped);
 extern NSRect BDSKCenterRectHorizontally(NSRect rect, CGFloat width);
+
+static inline NSRect BDSKSliceRect(NSRect rect, CGFloat amount, NSRectEdge 
edge) {
+    NSRect ignored;
+    NSDivideRect(rect, &rect, &ignored, amount, edge);
+    return rect;
+}
+
+static inline NSRect BDSKShrinkRect(NSRect rect, CGFloat amount, NSRectEdge 
edge) {
+    NSRect ignored;
+    NSDivideRect(rect, &ignored, &rect, amount, edge);
+    return rect;
+}

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.  
But none more important than the need to reduce IT complexity 
while improving strategic productivity.  Learn More! 
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to