Revision: 7573
http://skim-app.svn.sourceforge.net/skim-app/?rev=7573&view=rev
Author: hofman
Date: 2011-12-14 18:15:08 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------
convenience functions for NSDivideRect with ignored section
Modified Paths:
--------------
trunk/NSBezierPath_SKExtensions.m
trunk/NSGeometry_SKExtensions.h
trunk/PDFPage_SKExtensions.m
trunk/SKNoteOutlineView.m
trunk/SKPDFView.m
trunk/SKProgressCell.m
trunk/SKSideWindow.m
trunk/SKSnapshotPageCell.m
trunk/SKStatusBar.m
trunk/SKTextWithIconCell.m
Modified: trunk/NSBezierPath_SKExtensions.m
===================================================================
--- trunk/NSBezierPath_SKExtensions.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/NSBezierPath_SKExtensions.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -37,6 +37,7 @@
*/
#import "NSBezierPath_SKExtensions.h"
+#import "NSGeometry_SKExtensions.h"
@implementation NSBezierPath (SKExtensions)
@@ -50,8 +51,7 @@
if( radius <= 0 )
return [self bezierPathWithRect:rect];
- NSRect ignored, innerRect;
- NSDivideRect(NSInsetRect(rect, 0.0, radius), &ignored, &innerRect, radius,
NSMinXEdge); // Make rect with corners being centers of the corner circles.
+ NSRect innerRect = SKShrinkRect(NSInsetRect(rect, 0.0, radius), radius,
NSMinXEdge); // Make rect with corners being centers of the corner circles.
NSBezierPath *path = [self bezierPath];
// Now draw our rectangle:
@@ -78,8 +78,7 @@
if( radius <= 0 )
return [self bezierPathWithRect:rect];
- NSRect ignored, innerRect;
- NSDivideRect(NSInsetRect(rect, 0.0, radius), &ignored, &innerRect, radius,
NSMaxXEdge); // Make rect with corners being centers of the corner circles.
+ NSRect innerRect = SKShrinkRect(NSInsetRect(rect, 0.0, radius), radius,
NSMaxXEdge); // Make rect with corners being centers of the corner circles.
NSBezierPath *path = [self bezierPath];
// Now draw our rectangle:
Modified: trunk/NSGeometry_SKExtensions.h
===================================================================
--- trunk/NSGeometry_SKExtensions.h 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/NSGeometry_SKExtensions.h 2011-12-14 18:15:08 UTC (rev 7573)
@@ -128,6 +128,18 @@
return rect;
}
+static inline NSRect SKSliceRect(NSRect rect, CGFloat amount, NSRectEdge edge)
{
+ NSRect ignored;
+ NSDivideRect(rect, &rect, &ignored, amount, edge);
+ return rect;
+}
+
+static inline NSRect SKShrinkRect(NSRect rect, CGFloat amount, NSRectEdge
edge) {
+ NSRect ignored;
+ NSDivideRect(rect, &ignored, &rect, amount, edge);
+ return rect;
+}
+
#pragma mark -
extern NSPoint SKConstrainPointInRect(NSPoint point, NSRect boundary);
Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/PDFPage_SKExtensions.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -165,11 +165,8 @@
[self transformContextForBox:box];
[[[NSUserDefaults standardUserDefaults]
colorForKey:SKReadingBarColorKey] setFill];
if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKReadingBarInvertKey]) {
- NSRect outRect, ignored;
- NSDivideRect(bounds, &outRect, &ignored, NSMaxY(bounds) -
NSMaxY(readingBarRect), NSMaxYEdge);
- [NSBezierPath fillRect:outRect];
- NSDivideRect(bounds, &outRect, &ignored, NSMinY(readingBarRect) -
NSMinY(bounds), NSMinYEdge);
- [NSBezierPath fillRect:outRect];
+ [NSBezierPath fillRect:SKSliceRect(bounds, NSMaxY(bounds) -
NSMaxY(readingBarRect), NSMaxYEdge)];
+ [NSBezierPath fillRect:SKSliceRect(bounds, NSMinY(readingBarRect)
- NSMinY(bounds), NSMinYEdge)];
} else {
CGContextSetBlendMode([[NSGraphicsContext currentContext]
graphicsPort], kCGBlendModeMultiply);
[NSBezierPath fillRect:readingBarRect];
Modified: trunk/SKNoteOutlineView.m
===================================================================
--- trunk/SKNoteOutlineView.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKNoteOutlineView.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -40,6 +40,7 @@
#import "SKTypeSelectHelper.h"
#import "NSEvent_SKExtensions.h"
#import "SKColorCell.h"
+#import "NSGeometry_SKExtensions.h"
#define NUMBER_OF_TYPES 9
@@ -81,8 +82,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 = SKSliceRect([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;
@@ -166,9 +166,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);
- [self addCursorRect:rect cursor:[NSCursor resizeUpDownCursor]];
+ [self addCursorRect:SKSliceRect([self rectOfRow:row], 5.0, [self
isFlipped] ? NSMaxYEdge : NSMinYEdge) cursor:[NSCursor resizeUpDownCursor]];
}
} else {
[super resetCursorRects];
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKPDFView.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -388,11 +388,8 @@
if (NSEqualRects(rect, NSZeroRect) || [[readingBar page]
isEqual:pdfPage] == NO) {
[NSBezierPath fillRect:bounds];
} else {
- NSRect outRect, ignored;
- NSDivideRect(bounds, &outRect, &ignored, NSMaxY(bounds) -
NSMaxY(rect), NSMaxYEdge);
- [NSBezierPath fillRect:outRect];
- NSDivideRect(bounds, &outRect, &ignored, NSMinY(rect) -
NSMinY(bounds), NSMinYEdge);
- [NSBezierPath fillRect:outRect];
+ [NSBezierPath fillRect:SKSliceRect(bounds, NSMaxY(bounds) -
NSMaxY(rect), NSMaxYEdge)];
+ [NSBezierPath fillRect:SKSliceRect(bounds, NSMinY(rect) -
NSMinY(bounds), NSMinYEdge)];
}
} else if ([[readingBar page] isEqual:pdfPage]) {
[NSGraphicsContext saveGraphicsState];
@@ -2171,10 +2168,10 @@
}
- (void)scrollPageToVisible:(PDFPage *)page {
- NSRect ignored, rect = [page boundsForBox:[self displayBox]];
+ NSRect rect = [page boundsForBox:[self displayBox]];
if ([[self currentPage] isEqual:page] == NO)
[self goToPage:page];
- NSDivideRect([self convertRect:rect fromPage:page], &rect, &ignored, 1.0,
NSMaxYEdge);
+ rect = SKSliceRect([self convertRect:rect fromPage:page], 1.0, NSMaxYEdge);
[self goToRect:[self convertRect:rect toPage:page] onPage:page];
}
Modified: trunk/SKProgressCell.m
===================================================================
--- trunk/SKProgressCell.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKProgressCell.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -39,6 +39,7 @@
#import "SKProgressCell.h"
#import "SKDownload.h"
#import "NSString_SKExtensions.h"
+#import "NSGeometry_SKExtensions.h"
#define MARGIN_X 8.0
#define MARGIN_Y 2.0
@@ -136,24 +137,19 @@
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSProgressIndicator *progressIndicator = objectValueForKey([self
objectValue], SKDownloadProgressIndicatorKey);
- NSRect rect, ignored, insetRect;
NSRectEdge bottomEdge = [controlView isFlipped] ? NSMaxYEdge : NSMinYEdge;
NSRectEdge topEdge = [controlView isFlipped] ? NSMinYEdge : NSMaxYEdge;
+ NSRect insetRect = SKShrinkRect(NSInsetRect(cellFrame, MARGIN_X, 0.0),
MARGIN_Y, bottomEdge);
- NSDivideRect(NSInsetRect(cellFrame, MARGIN_X, 0.0), &ignored, &insetRect,
MARGIN_Y, bottomEdge);
+ [super drawWithFrame:SKSliceRect(insetRect, [self cellSize].height,
topEdge) inView:controlView];
- NSDivideRect(insetRect, &rect, &ignored, [self cellSize].height, topEdge);
- [super drawWithFrame:rect inView:controlView];
-
if (progressIndicator) {
- NSDivideRect(insetRect, &rect, &ignored, NSHeight([progressIndicator
frame]), bottomEdge);
- [progressIndicator setFrame:rect];
+ [progressIndicator setFrame:SKSliceRect(insetRect,
NSHeight([progressIndicator frame]), bottomEdge)];
if ([progressIndicator isDescendantOf:controlView] == NO)
[controlView addSubview:progressIndicator];
} else {
- NSDivideRect(insetRect, &rect, &ignored, [statusCell cellSize].height,
bottomEdge);
- [statusCell drawWithFrame:rect inView:controlView];
+ [statusCell drawWithFrame:SKSliceRect(insetRect, [statusCell
cellSize].height, bottomEdge) inView:controlView];
}
}
Modified: trunk/SKSideWindow.m
===================================================================
--- trunk/SKSideWindow.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKSideWindow.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -41,6 +41,7 @@
#import "NSBezierPath_SKExtensions.h"
#import "NSEvent_SKExtensions.h"
#import "SKStringConstants.h"
+#import "NSGeometry_SKExtensions.h"
#define DEFAULT_WINDOW_WIDTH 300.0
#define WINDOW_INSET 1.0
@@ -78,9 +79,7 @@
- (id)initWithMainController:(SKMainWindowController *)aController
edge:(NSRectEdge)anEdge {
NSScreen *screen = [[aController window] screen] ?: [NSScreen mainScreen];
- NSRect contentRect, ignored;
- NSDivideRect([screen frame], &contentRect, &ignored, DEFAULT_WINDOW_WIDTH,
anEdge);
- contentRect = NSInsetRect(contentRect, 0.0, WINDOW_INSET);
+ NSRect contentRect = NSInsetRect(SKSliceRect([screen frame],
DEFAULT_WINDOW_WIDTH, anEdge), 0.0, WINDOW_INSET);
self = [super initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
if (self) {
@@ -101,7 +100,7 @@
NSView *contentView = [[[SKSideWindowContentView alloc]
initWithFrame:NSZeroRect edge:edge] autorelease];
[self setContentView:contentView];
- NSDivideRect(NSInsetRect([contentView bounds], 0.0, CONTENT_INSET),
&ignored, &contentRect, CONTENT_INSET, edge == NSMaxXEdge ? NSMinXEdge :
NSMaxXEdge);
+ contentRect = SKShrinkRect(NSInsetRect([contentView bounds], 0.0,
CONTENT_INSET), CONTENT_INSET, edge == NSMaxXEdge ? NSMinXEdge : NSMaxXEdge);
mainContentView = [[[NSView alloc] initWithFrame:contentRect]
autorelease];
[mainContentView setAutoresizingMask:(edge == NSMaxXEdge ?
NSViewMaxXMargin : NSViewMinXMargin) | NSViewHeightSizable];
[contentView addSubview:mainContentView];
@@ -126,8 +125,8 @@
- (BOOL)canBecomeKeyWindow { return YES; }
- (void)attachToWindow:(NSWindow *)window {
- NSRect frame, ignored;
- NSDivideRect([[window screen] frame], &frame, &ignored, WINDOW_OFFSET,
edge);
+ NSRect frame;
+ frame = SKSliceRect([[window screen] frame], WINDOW_OFFSET, edge);
[self setFrame:NSInsetRect(frame, 0.0, WINDOW_INSET) display:NO];
state = NSDrawerClosedState;
if (hideWhenClosed != SKClosedSidePanelCollapse)
@@ -358,18 +357,16 @@
}
- (NSRect)resizeHandleRect {
- NSRect rect, ignored;
- NSDivideRect([self bounds], &rect, &ignored, CONTENT_INSET, edge ==
NSMaxXEdge ? NSMinXEdge : NSMaxXEdge);
- return rect;
+ return SKSliceRect([self bounds], CONTENT_INSET, edge == NSMaxXEdge ?
NSMinXEdge : NSMaxXEdge);
}
- (void)drawRect:(NSRect)aRect {
- NSRect ignored, topRect, bottomRect, rect = [self bounds];
+ NSRect topRect, bottomRect, rect = [self bounds];
NSPoint startPoint, endPoint;
NSShadow *shade = [[[NSShadow alloc] init] autorelease];
- NSDivideRect(rect, &topRect, &ignored, 2.0 * CORNER_RADIUS, NSMaxYEdge);
- NSDivideRect(rect, &bottomRect, &ignored, 2.0 * CORNER_RADIUS, NSMinYEdge);
+ topRect = SKSliceRect(rect, 2.0 * CORNER_RADIUS, NSMaxYEdge);
+ bottomRect = SKSliceRect(rect, 2.0 * CORNER_RADIUS, NSMinYEdge);
[NSGraphicsContext saveGraphicsState];
Modified: trunk/SKSnapshotPageCell.m
===================================================================
--- trunk/SKSnapshotPageCell.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKSnapshotPageCell.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -37,6 +37,7 @@
*/
#import "SKSnapshotPageCell.h"
+#import "NSGeometry_SKExtensions.h"
NSString *SKSnapshotPageCellLabelKey = @"label";
NSString *SKSnapshotPageCellHasWindowKey = @"hasWindow";
@@ -82,7 +83,7 @@
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
- NSRect textRect, imageRect, ignored;
+ NSRect textRect, imageRect;
NSDivideRect(cellFrame, &textRect, &imageRect, 17.0, NSMinYEdge);
[super drawInteriorWithFrame:textRect inView:controlView];
if (hasWindow) {
@@ -112,7 +113,7 @@
}
[aShadow setShadowOffset:NSMakeSize(0.0, -1.0)];
- NSDivideRect(imageRect, &imageRect, &ignored, 10.0, NSMinYEdge);
+ imageRect = SKSliceRect(imageRect, 10.0, NSMinYEdge);
imageRect.origin.x += 4.0;
imageRect.size.width = 10.0;
Modified: trunk/SKStatusBar.m
===================================================================
--- trunk/SKStatusBar.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKStatusBar.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -125,8 +125,7 @@
leftMargin += NSHeight([self bounds]) - ICON_HEIGHT_OFFSET +
SEPARATION;
if (progressIndicator)
rightMargin += NSWidth([progressIndicator frame]) + SEPARATION;
- NSDivideRect(rect, &ignored, &rect, leftMargin, NSMinXEdge);
- NSDivideRect(rect, &ignored, &rect, rightMargin, NSMaxXEdge);
+ rect = SKShrinkRect(SKShrinkRect(rect, leftMargin, NSMinXEdge),
rightMargin, NSMaxXEdge);
if (rightFrame != NULL)
NSDivideRect(rect, rightFrame, &ignored, rightWidth, NSMaxXEdge);
if (leftFrame != NULL)
@@ -135,17 +134,16 @@
- (void)drawRect:(NSRect)rect {
NSRect bounds = [self bounds];
- NSRect textRect, iconRect = NSZeroRect, ignored;
+ NSRect textRect, iconRect = NSZeroRect;
CGFloat rightMargin = RIGHT_MARGIN;
CGFloat iconHeight = NSHeight(bounds) - ICON_HEIGHT_OFFSET;
if (progressIndicator)
rightMargin += NSWidth([progressIndicator frame]) + SEPARATION;
- NSDivideRect(bounds, &ignored, &textRect, LEFT_MARGIN, NSMinXEdge);
- NSDivideRect(textRect, &ignored, &textRect, rightMargin, NSMaxXEdge);
+ textRect = SKShrinkRect(SKShrinkRect(bounds, LEFT_MARGIN, NSMinXEdge),
rightMargin, NSMaxXEdge);
if (iconCell) {
NSDivideRect(textRect, &iconRect, &textRect, iconHeight, NSMinXEdge);
- NSDivideRect(textRect, &ignored, &textRect, SEPARATION, NSMaxXEdge);
+ textRect = SKShrinkRect(textRect, SEPARATION, NSMaxXEdge);
}
if (textRect.size.width < 0.0)
@@ -405,11 +403,10 @@
[progressIndicator setUsesThreadedAnimation:YES];
[progressIndicator sizeToFit];
- NSRect rect, ignored;
+ NSRect rect;
NSSize size = [progressIndicator frame].size;
if (size.width < 0.01) size.width = PROGRESSBAR_WIDTH;
- NSDivideRect([self bounds], &ignored, &rect, RIGHT_MARGIN, NSMaxXEdge);
- NSDivideRect(rect, &rect, &ignored, size.width, NSMaxXEdge);
+ rect = SKSliceRect(SKShrinkRect([self bounds], RIGHT_MARGIN,
NSMaxXEdge), size.width, NSMaxXEdge);
rect.origin.y = floor(NSMidY(rect) - 0.5 * size.height) +
VERTICAL_OFFSET;
rect.size.height = size.height;
[progressIndicator setFrame:rect];
Modified: trunk/SKTextWithIconCell.m
===================================================================
--- trunk/SKTextWithIconCell.m 2011-12-13 22:17:57 UTC (rev 7572)
+++ trunk/SKTextWithIconCell.m 2011-12-14 18:15:08 UTC (rev 7573)
@@ -95,21 +95,11 @@
}
- (NSRect)textRectForBounds:(NSRect)aRect {
- NSRect ignored, textRect = aRect;
-
- NSDivideRect(aRect, &ignored, &textRect, NSHeight(aRect) - 1 +
BORDER_BETWEEN_EDGE_AND_IMAGE + BORDER_BETWEEN_IMAGE_AND_TEXT, NSMinXEdge);
-
- return textRect;
+ return SKShrinkRect(aRect, NSHeight(aRect) - 1 +
BORDER_BETWEEN_EDGE_AND_IMAGE + BORDER_BETWEEN_IMAGE_AND_TEXT, NSMinXEdge);
}
- (NSRect)iconRectForBounds:(NSRect)aRect {
- CGFloat imageWidth = NSHeight(aRect) - 1;
- NSRect ignored, imageRect = aRect;
-
- NSDivideRect(aRect, &ignored, &imageRect, BORDER_BETWEEN_EDGE_AND_IMAGE,
NSMinXEdge);
- NSDivideRect(imageRect, &imageRect, &ignored, imageWidth, NSMinXEdge);
-
- return imageRect;
+ return SKSliceRect(SKShrinkRect(aRect, BORDER_BETWEEN_EDGE_AND_IMAGE,
NSMinXEdge), NSHeight(aRect) - 1, NSMinXEdge);
}
- (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Cloud Computing - Latest Buzzword or a Glimpse of the Future?
This paper surveys cloud computing today: What are the benefits?
Why are businesses embracing it? What are its payoffs and pitfalls?
http://www.accelacomm.com/jaw/sdnl/114/51425149/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit