code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
// // BWToolbarItemIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWToolbarItem.h" #import "BWToolbarItemInspector.h" @implementation BWToolbarItem ( BWToolbarItemIntegration ) - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { [super ibPopulateKeyPaths:keyPaths]; [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:@"identifierString", nil]]; } - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { [super ibPopulateAttributeInspectorClasses:classes]; [classes addObject:[BWToolbarItemInspector class]]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolbarItemIntegration.m
Objective-C
bsd
758
// // BWToolbarItem.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWToolbarItem.h" #import "NSString+BWAdditions.h" @interface BWToolbarItem () @property (copy) NSString *identifierString; @end @interface NSToolbarItem (BWTIPrivate) - (void)_setItemIdentifier:(id)fp8; - (id)initWithCoder:(NSCoder *)coder; - (void)encodeWithCoder:(NSCoder*)coder; @end @implementation BWToolbarItem @synthesize identifierString; - (id)initWithCoder:(NSCoder *)coder { if ((self = [super initWithCoder:coder]) != nil) { [self setIdentifierString:[coder decodeObjectForKey:@"BWTIIdentifierString"]]; } return self; } - (void)encodeWithCoder:(NSCoder*)coder { [super encodeWithCoder:coder]; [coder encodeObject:[self identifierString] forKey:@"BWTIIdentifierString"]; } - (void)setIdentifierString:(NSString *)aString { if (identifierString != aString) { [identifierString release]; identifierString = [aString copy]; } if (identifierString == nil || [identifierString isEqualToString:@""]) [self _setItemIdentifier:[NSString randomUUID]]; else [self _setItemIdentifier:identifierString]; } - (void)dealloc { [identifierString release]; [super dealloc]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolbarItem.m
Objective-C
bsd
1,274
// // BWToolbarShowFontsItem.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWToolbarShowFontsItem : NSToolbarItem { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolbarShowFontsItem.h
Objective-C
bsd
247
// // BWAnchoredPopUpButtonIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWAnchoredPopUpButton.h" @implementation BWAnchoredPopUpButton ( BWAnchoredPopUpButtonIntegration ) - (NSSize)ibMinimumSize { return NSMakeSize(0,24); } - (NSSize)ibMaximumSize { return NSMakeSize(100000,24); } - (IBInset)ibLayoutInset { IBInset inset; inset.bottom = 0; inset.right = 0; inset.top = topAndLeftInset.x; inset.left = topAndLeftInset.y; return inset; } - (int)ibBaselineCount { return 1; } - (float)ibBaselineAtIndex:(int)index { return 16; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAnchoredPopUpButtonIntegration.m
Objective-C
bsd
711
// // BWTransparentTableViewCell.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentTableViewCell.h" @implementation BWTransparentTableViewCell - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { if (![[self title] isEqualToString:@""]) { NSColor *textColor; if (!self.isHighlighted) textColor = [NSColor colorWithCalibratedWhite:(198.0f / 255.0f) alpha:1]; else textColor = [NSColor whiteColor]; NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; [attributes addEntriesFromDictionary:[[self attributedStringValue] attributesAtIndex:0 effectiveRange:NULL]]; [attributes setObject:textColor forKey:NSForegroundColorAttributeName]; [attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName]; NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:[self title] attributes:attributes] autorelease]; [self setAttributedStringValue:string]; } cellFrame.size.width -= 1; cellFrame.origin.x += 1; [super drawInteriorWithFrame:cellFrame inView:controlView]; } #pragma mark RSVerticallyCenteredTextFieldCell // RSVerticallyCenteredTextFieldCell courtesy of Daniel Jalkut // http://www.red-sweater.com/blog/148/what-a-difference-a-cell-makes - (NSRect)drawingRectForBounds:(NSRect)theRect { // Get the parent's idea of where we should draw NSRect newRect = [super drawingRectForBounds:theRect]; // When the text field is being // edited or selected, we have to turn off the magic because it screws up // the configuration of the field editor. We sneak around this by // intercepting selectWithFrame and editWithFrame and sneaking a // reduced, centered rect in at the last minute. if (mIsEditingOrSelecting == NO) { // Get our ideal size for current text NSSize textSize = [self cellSizeForBounds:theRect]; // Center that in the proposed rect float heightDelta = newRect.size.height - textSize.height; if (heightDelta > 0) { newRect.size.height -= heightDelta; newRect.origin.y += (heightDelta / 2); } } return newRect; } - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength { aRect = [self drawingRectForBounds:aRect]; mIsEditingOrSelecting = YES; [super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; mIsEditingOrSelecting = NO; } - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent { aRect = [self drawingRectForBounds:aRect]; mIsEditingOrSelecting = YES; [super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent]; mIsEditingOrSelecting = NO; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentTableViewCell.m
Objective-C
bsd
2,956
// // BWTransparentSliderIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWTransparentSlider.h" @implementation BWTransparentSlider ( BWTransparentSliderIntegration ) - (IBInset)ibLayoutInset { IBInset inset; inset.left = 2; inset.top = 2; inset.bottom = 3; if ([self numberOfTickMarks] == 0) { inset.right = 3; } else { inset.right = 2; } return inset; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentSliderIntegration.m
Objective-C
bsd
543
// // NSString+BWAdditions.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "NSString+BWAdditions.h" @implementation NSString (BWAdditions) + (NSString *)randomUUID { CFUUIDRef uuidObj = CFUUIDCreate(nil); NSString *newUUID = (NSString*)CFUUIDCreateString(nil, uuidObj); CFRelease(uuidObj); return [newUUID autorelease]; } @end
08iteng-ipad
TestMerge/bwtoolkit/NSString+BWAdditions.m
Objective-C
bsd
426
// // BWSheetControllerIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWSheetController.h" @implementation BWSheetController ( BWSheetControllerIntegration ) - (NSImage *)ibDefaultImage { NSBundle *bundle = [NSBundle bundleForClass:[BWSheetController class]]; NSImage *image = [[[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Library-SheetController.tif"]] autorelease]; return image; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSheetControllerIntegration.m
Objective-C
bsd
581
// // BWTransparentCheckBoxIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWTransparentCheckbox.h" @implementation BWTransparentCheckbox ( BWTransparentCheckboxIntegration ) - (NSSize)ibMinimumSize { return NSMakeSize(0,18); } - (NSSize)ibMaximumSize { return NSMakeSize(100000,18); } - (IBInset)ibLayoutInset { IBInset inset; inset.top = 3; inset.bottom = 3; inset.left = 2; inset.right = 0; return inset; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentCheckboxIntegration.m
Objective-C
bsd
585
// // BWRemoveBottomBarIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWRemoveBottomBar.h" #import "BWAddSmallBottomBar.h" #import "BWAddRegularBottomBar.h" #import "BWAddMiniBottomBar.h" #import "BWAddSheetBottomBar.h" #import "NSWindow+BWAdditions.h" @interface NSWindow (BWBBPrivate) - (void)setBottomCornerRounded:(BOOL)flag; @end @implementation BWRemoveBottomBar (BWRemoveBottomBarIntegration) - (void)ibDidAddToDesignableDocument:(IBDocument *)document { [super ibDidAddToDesignableDocument:document]; // Remove the window's bottom bar [self performSelector:@selector(removeBottomBar) withObject:nil afterDelay:0]; // Clean up [self performSelector:@selector(removeOtherBottomBarViewsInDocument:) withObject:document afterDelay:0]; [self performSelector:@selector(removeSelfInDocument:) withObject:document afterDelay:0]; } - (void)removeBottomBar { if ([[self window] isTextured] == NO) { [[self window] setContentBorderThickness:0 forEdge:NSMinYEdge]; // Private method if ([[self window] respondsToSelector:@selector(setBottomCornerRounded:)]) [[self window] setBottomCornerRounded:NO]; } } - (void)removeOtherBottomBarViewsInDocument:(IBDocument *)document { NSArray *subviews = [[[self window] contentView] subviews]; int i; for (i = 0; i < [subviews count]; i++) { NSView *view = [subviews objectAtIndex:i]; if (view != self && ([view isKindOfClass:[BWAddRegularBottomBar class]] || [view isKindOfClass:[BWAddSmallBottomBar class]] || [view isKindOfClass:[BWAddMiniBottomBar class]] || [view isKindOfClass:[BWAddSheetBottomBar class]])) { [document removeObject:view]; [view removeFromSuperview]; } } } - (void)removeSelfInDocument:(IBDocument *)document { [document removeObject:self]; [self removeFromSuperview]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWRemoveBottomBarIntegration.m
Objective-C
bsd
1,947
// // BWTexturedSliderCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTexturedSliderCell : NSSliderCell { BOOL isPressed; int trackHeight; } @property int trackHeight; @end
08iteng-ipad
TestMerge/bwtoolkit/BWTexturedSliderCell.h
Objective-C
bsd
303
// // BWTransparentTextFieldCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTransparentTextFieldCell : NSTextFieldCell { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentTextFieldCell.h
Objective-C
bsd
256
// // BWTransparentCheckboxCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> #import "BWTransparentCheckbox.h" @interface BWTransparentCheckboxCell : NSButtonCell { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentCheckboxCell.h
Objective-C
bsd
285
// // BWAddSmallBottomBar.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAddSmallBottomBar.h" #import "NSWindow-NSTimeMachineSupport.h" @implementation BWAddSmallBottomBar - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super initWithCoder:decoder]) != nil) { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)]) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; } return self; } - (void)awakeFromNib { [[self window] setContentBorderThickness:24 forEdge:NSMinYEdge]; } - (void)drawRect:(NSRect)aRect { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] && [[self window] contentBorderThicknessForEdge:NSMinYEdge] == 0) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; if ([[self window] isSheet] && [[self window] respondsToSelector:@selector(setMovable:)]) [[self window] setMovable:NO]; } - (NSRect)bounds { return NSMakeRect(-10000,-10000,0,0); } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddSmallBottomBar.m
Objective-C
bsd
1,081
// // BWSplitViewInspector.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWSplitViewInspector.h" #import "NSView+BWAdditions.h" @interface BWSplitViewInspector (BWSVIPrivate) - (void)updateControls; - (BOOL)toggleDividerCheckboxVisibilityWithAnimation:(BOOL)shouldAnimate; - (void)updateSizeLabels; @end @implementation BWSplitViewInspector @synthesize subviewPopupSelection, subviewPopupContent, collapsiblePopupSelection, collapsiblePopupContent, minUnitPopupSelection, maxUnitPopupSelection, splitView, dividerCheckboxCollapsed; - (NSString *)viewNibName { return @"BWSplitViewInspector"; } - (void)awakeFromNib { [minField setDelegate:self]; [maxField setDelegate:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dividerThicknessChanged:) name:@"BWSplitViewDividerThicknessChanged" object:splitView]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"BWSplitViewOrientationChanged" object:splitView]; } - (void)dividerThicknessChanged:(NSNotification *)notification { [self toggleDividerCheckboxVisibilityWithAnimation:YES]; } - (void)updateSizeLabels { if ([splitView isVertical]) { [maxLabel setStringValue:@"Max Width"]; [minLabel setStringValue:@"Min Width"]; } else { [maxLabel setStringValue:@"Max Height"]; [minLabel setStringValue:@"Min Height"]; } } - (void)orientationChanged:(NSNotification *)notification { [self updateSizeLabels]; [self toggleDividerCheckboxVisibilityWithAnimation:YES]; } - (void)setCollapsiblePopupSelection:(int)index { collapsiblePopupSelection = index; [splitView setCollapsiblePopupSelection:index]; [self toggleDividerCheckboxVisibilityWithAnimation:YES]; } - (void)setSplitView:(BWSplitView *)aSplitView { if (splitView != aSplitView) { [splitView release]; splitView = [aSplitView retain]; [self toggleDividerCheckboxVisibilityWithAnimation:NO]; } } - (void)setDividerCheckboxWantsLayer:(NSString *)flag { if ([flag isEqualToString:@"YES"]) [dividerCheckbox setWantsLayer:YES]; else [dividerCheckbox setWantsLayer:NO]; } - (BOOL)toggleDividerCheckboxVisibilityWithAnimation:(BOOL)shouldAnimate { // Conditions that must be met for a visibility switch to take place. If any of them fail, we return early. if (dividerCheckboxCollapsed && [splitView dividerThickness] > 1.01 && [splitView collapsiblePopupSelection] != 0) { } else if (!dividerCheckboxCollapsed && ([splitView dividerThickness] < 1.01 || [splitView collapsiblePopupSelection] == 0)) { } else return NO; float duration = 0.1, alpha; NSRect targetFrame = NSZeroRect; if (dividerCheckboxCollapsed) { targetFrame = NSMakeRect([[self view] frame].origin.x, [[self view] frame].origin.y, [[self view] frame].size.width, [[self view] frame].size.height + 20); alpha = 1.0; } else { targetFrame = NSMakeRect([[self view] frame].origin.x, [[self view] frame].origin.y, [[self view] frame].size.width, [[self view] frame].size.height - 20); alpha = 0.0; } [self performSelector:@selector(setDividerCheckboxWantsLayer:) withObject:@"YES" afterDelay:0]; if (shouldAnimate) { [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:duration]; [[dividerCheckbox animator] setAlphaValue:alpha]; [[[self view] animator] setFrame:targetFrame]; [NSAnimationContext endGrouping]; if (dividerCheckboxCollapsed) [self performSelector:@selector(setDividerCheckboxWantsLayer:) withObject:@"NO" afterDelay:duration]; } else { [dividerCheckbox setAlphaValue:alpha]; [[self view] setFrame:targetFrame]; if (dividerCheckboxCollapsed) [self performSelector:@selector(setDividerCheckboxWantsLayer:) withObject:@"NO" afterDelay:0]; } dividerCheckboxCollapsed = !dividerCheckboxCollapsed; return YES; } - (void)refresh { [super refresh]; if ([[self inspectedObjects] count] > 0) { [self setSplitView:[[self inspectedObjects] objectAtIndex:0]]; // Populate the subview popup button NSMutableArray *content = [[NSMutableArray alloc] init]; for (NSView *subview in [splitView subviews]) { int index = [[splitView subviews] indexOfObject:subview]; NSString *label = [NSString stringWithFormat:@"Subview %d",index]; if (![[subview className] isEqualToString:@"NSView"]) label = [label stringByAppendingString:[NSString stringWithFormat:@" - %@",[subview className]]]; [content addObject:label]; } [self setSubviewPopupContent:content]; // Populate the collapsible popup button if ([splitView isVertical]) [self setCollapsiblePopupContent:[NSMutableArray arrayWithObjects:@"None", @"Left Pane", @"Right Pane",nil]]; else [self setCollapsiblePopupContent:[NSMutableArray arrayWithObjects:@"None", @"Top Pane", @"Bottom Pane",nil]]; } // Refresh autosizing view [autosizingView setSplitView:splitView]; [autosizingView layoutButtons]; [self updateSizeLabels]; [self updateControls]; } + (BOOL)supportsMultipleObjectInspection { return NO; } - (void)setMinUnitPopupSelection:(int)index { minUnitPopupSelection = index; NSNumber *minUnit = [NSNumber numberWithInt:index]; NSMutableDictionary *tempMinUnits = [[splitView minUnits] mutableCopy]; [tempMinUnits setObject:minUnit forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]; [splitView setMinUnits:tempMinUnits]; } - (void)setMaxUnitPopupSelection:(int)index { maxUnitPopupSelection = index; NSNumber *maxUnit = [NSNumber numberWithInt:index]; NSMutableDictionary *tempMaxUnits = [[splitView maxUnits] mutableCopy]; [tempMaxUnits setObject:maxUnit forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]; [splitView setMaxUnits:tempMaxUnits]; } - (void)controlTextDidChange:(NSNotification *)aNotification { if ([aNotification object] == minField) { if ([minField stringValue] != nil && [[minField stringValue] isEqualToString:@""] == NO && [[minField stringValue] isEqualToString:@" "] == NO) { NSNumber *minValue = [NSNumber numberWithInt:[minField intValue]]; NSMutableDictionary *tempMinValues = [[splitView minValues] mutableCopy]; [tempMinValues setObject:minValue forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]; [splitView setMinValues:tempMinValues]; } else { NSMutableDictionary *tempMinValues = [[splitView minValues] mutableCopy]; [tempMinValues removeObjectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]; [splitView setMinValues:tempMinValues]; } } else if ([aNotification object] == maxField) { if ([maxField stringValue] != nil && [[maxField stringValue] isEqualToString:@""] == NO && [[maxField stringValue] isEqualToString:@" "] == NO) { NSNumber *maxValue = [NSNumber numberWithInt:[maxField intValue]]; NSMutableDictionary *tempMaxValues = [[splitView maxValues] mutableCopy]; [tempMaxValues setObject:maxValue forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]; [splitView setMaxValues:tempMaxValues]; } else { NSMutableDictionary *tempMaxValues = [[splitView maxValues] mutableCopy]; [tempMaxValues removeObjectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]; [splitView setMaxValues:tempMaxValues]; } } } - (int)collapsiblePopupSelection { return [splitView collapsiblePopupSelection]; } - (void)setSubviewPopupSelection:(int)index { subviewPopupSelection = index; [self updateControls]; } - (void)updateControls { [minField setObjectValue:[[splitView minValues] objectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]]; [maxField setObjectValue:[[splitView maxValues] objectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]]]; [self setMinUnitPopupSelection:[[[splitView minUnits] objectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]] intValue]]; [self setMaxUnitPopupSelection:[[[splitView maxUnits] objectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]] intValue]]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitViewInspector.m
Objective-C
bsd
8,169
// // BWToolkit.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWToolkit.h" @implementation BWToolkit - (NSArray *)libraryNibNames { return [NSArray arrayWithObjects:@"BWSplitViewLibrary",@"BWControllersLibrary",@"BWToolbarItemsLibrary",@"BWBottomBarLibrary",@"BWToolkitLibrary",@"BWTransparentControlsLibrary",@"BWButtonBarLibrary",nil]; } - (NSArray *)requiredFrameworks { return [NSArray arrayWithObjects:[NSBundle bundleWithIdentifier:@"com.brandonwalkin.BWToolkitFramework"], nil]; } - (NSString *)label { return @"BWToolkit"; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolkit.m
Objective-C
bsd
644
// // BWTransparentCheckbox.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> #import "BWTransparentCheckboxCell.h" @interface BWTransparentCheckbox : NSButton { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentCheckbox.h
Objective-C
bsd
277
// // BWGradientSplitViewSubviewIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWCustomView.h" #import "IBColor.h" @implementation BWCustomView ( BWCustomViewIntegration ) - (NSView *)ibDesignableContentView { return self; } - (NSColor *)containerCustomViewBackgroundColor { return [IBColor containerCustomViewBackgroundColor]; } - (NSColor *)childlessCustomViewBackgroundColor { return [IBColor childlessCustomViewBackgroundColor]; } - (NSColor *)customViewDarkTexturedBorderColor { return [IBColor customViewDarkTexturedBorderColor]; } - (NSColor *)customViewDarkBorderColor { return [IBColor customViewDarkBorderColor]; } - (NSColor *)customViewLightBorderColor { return [IBColor customViewLightBorderColor]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWCustomViewIntegration.m
Objective-C
bsd
889
// // BWUnanchoredButtonContainer.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // // See the integration class #import "BWUnanchoredButtonContainer.h" @implementation BWUnanchoredButtonContainer @end
08iteng-ipad
TestMerge/bwtoolkit/BWUnanchoredButtonContainer.m
Objective-C
bsd
285
// // BWTransparentSliderCell.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentSliderCell.h" @implementation BWTransparentSliderCell static NSImage *trackLeftImage, *trackFillImage, *trackRightImage, *thumbPImage, *thumbNImage, *triangleThumbNImage, *triangleThumbPImage; + (void)initialize { if([BWTransparentSliderCell class] == [self class]) { NSBundle *bundle = [NSBundle bundleForClass:[BWTransparentSliderCell class]]; trackLeftImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTrackLeft.tiff"]]; trackFillImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTrackFill.tiff"]]; trackRightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTrackRight.tiff"]]; thumbPImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderThumbP.tiff"]]; thumbNImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderThumbN.tiff"]]; triangleThumbNImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTriangleThumbN.tiff"]]; triangleThumbPImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"TransparentSliderTriangleThumbP.tiff"]]; } } - (id)initWithCoder:(NSCoder *)decoder; { self = [super initWithCoder:decoder]; [self setControlSize:NSSmallControlSize]; isPressed = NO; [super setTickMarkPosition:NSTickMarkBelow]; return self; } - (void)drawBarInside:(NSRect)cellFrame flipped:(BOOL)flipped { NSRect slideRect = cellFrame; slideRect.size.height = [trackFillImage size].height; if(cellFrame.size.height > slideRect.size.height) slideRect.origin.y += roundf((cellFrame.size.height - slideRect.size.height) * 0.5f); slideRect.size.width -= 5; slideRect.origin.x += 2; if ([self numberOfTickMarks] > 0) { slideRect.origin.y--; slideRect.size.width++; } CGFloat alpha = 1.0; if (![self isEnabled]) alpha = 0.6; NSDrawThreePartImage(slideRect, trackLeftImage, trackFillImage, trackRightImage, NO, NSCompositeSourceOver, alpha, flipped); // Draw solid white on top of all of the ticks if ([self numberOfTickMarks] > 0) { int i; for (i=0; i < [self numberOfTickMarks]; i++) { NSRect tickRect = [self rectOfTickMarkAtIndex:i]; [[NSColor whiteColor] set]; NSRectFill(tickRect); } } } - (void)drawKnob:(NSRect)rect { NSImage *drawImage; if ([self numberOfTickMarks] == 0) { if (isPressed) drawImage = thumbPImage; else drawImage = thumbNImage; } else { if (isPressed) drawImage = triangleThumbPImage; else drawImage = triangleThumbNImage; } NSPoint drawPoint; drawPoint.x = rect.origin.x + roundf((rect.size.width - drawImage.size.width) / 2) - 1; drawPoint.y = NSMaxY(rect) - roundf((rect.size.height - drawImage.size.height) / 2) + 2; if ([self numberOfTickMarks] > 0) { drawPoint.y -= 2; drawPoint.x++; } [drawImage compositeToPoint:drawPoint operation:NSCompositeSourceOver]; } - (BOOL)_usesCustomTrackImage { return YES; } -(NSRect)knobRectFlipped:(BOOL)flipped { NSRect rect = [super knobRectFlipped:flipped]; if([self numberOfTickMarks] > 0){ rect.size.height+=2; return NSOffsetRect(rect, 0, flipped ? 2 : -2); } return rect; } - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView { isPressed = YES; return [super startTrackingAt:startPoint inView:controlView]; } - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { isPressed = NO; [super stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag]; } - (void)setTickMarkPosition:(NSTickMarkPosition)position { } - (NSControlSize)controlSize { return NSSmallControlSize; } - (void)setControlSize:(NSControlSize)size { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentSliderCell.m
Objective-C
bsd
4,040
// // BWGradientSplitViewSubview.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWCustomView.h" #import "NSColor+BWAdditions.h" #import "NSWindow+BWAdditions.h" #import "IBColor.h" @interface BWCustomView (BWCVPrivate) - (void)drawTextInRect:(NSRect)rect; - (NSColor *)containerCustomViewBackgroundColor; - (NSColor *)childlessCustomViewBackgroundColor; - (NSColor *)customViewDarkTexturedBorderColor; - (NSColor *)customViewDarkBorderColor; - (NSColor *)customViewLightBorderColor; @end @implementation BWCustomView - (void)drawRect:(NSRect)rect { rect = self.bounds; NSColor *insetColor = [self customViewLightBorderColor]; NSColor *borderColor; if ([[self window] isTextured]) borderColor = [self customViewDarkTexturedBorderColor]; else borderColor = [self customViewDarkBorderColor]; // Note: these two colors are reversed in IBColor if (self.subviews.count == 0) { [[self containerCustomViewBackgroundColor] set]; NSRectFillUsingOperation(rect,NSCompositeSourceOver); } else { [[self childlessCustomViewBackgroundColor] set]; NSRectFillUsingOperation(rect,NSCompositeSourceOver); } if ([[self superview] isKindOfClass:NSClassFromString(@"BWSplitView")] && [[self superview] subviews].count > 1) { isOnItsOwn = NO; NSArray *subviews = [[self superview] subviews]; if ([subviews objectAtIndex:0] == self) { [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; if ([(NSSplitView *)[self superview] isVertical]) { [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; } else { [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; } [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; } else if ([subviews lastObject] == self) { [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; if ([(NSSplitView *)[self superview] isVertical]) { [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; } else { [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; } [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; } else { if ([(NSSplitView *)[self superview] isVertical]) { [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; } else { [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [insetColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; } } } else { isOnItsOwn = YES; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:NO flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; } if (rect.size.height > 16) [self drawTextInRect:rect]; } - (void)drawTextInRect:(NSRect)rect { NSString *text; if (isOnItsOwn) text = [NSString stringWithFormat:@"%d x %d pt",(int)rect.size.width,(int)rect.size.height]; else if ([(NSSplitView *)[self superview] isVertical]) text = [NSString stringWithFormat:@"%d pt",(int)rect.size.width]; else text = [NSString stringWithFormat:@"%d pt",(int)rect.size.height]; if (![self.className isEqualToString:@"NSView"]) text = self.className; NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; [attributes setObject:[NSColor whiteColor] forKey:NSForegroundColorAttributeName]; [attributes setObject:[NSFont boldSystemFontOfSize:12] forKey:NSFontAttributeName]; NSShadow *shadow = [[[NSShadow alloc] init] autorelease]; [shadow setShadowOffset:NSMakeSize(0,-1)]; [shadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:0.4]]; [attributes setObject:shadow forKey:NSShadowAttributeName]; NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:text attributes:attributes] autorelease]; NSRect boundingRect = [string boundingRectWithSize:rect.size options:0]; NSPoint rectCenter; rectCenter.x = rect.size.width / 2; rectCenter.y = rect.size.height / 2; NSPoint drawPoint = rectCenter; drawPoint.x -= boundingRect.size.width / 2; drawPoint.y -= boundingRect.size.height / 2; drawPoint.x = roundf(drawPoint.x); drawPoint.y = roundf(drawPoint.y); [string drawAtPoint:drawPoint]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWCustomView.m
Objective-C
bsd
7,814
// // BWSelectableToolbar.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @class BWSelectableToolbarHelper; // Notification that gets sent when a toolbar item has been clicked. You can get the button that was clicked by getting the object // for the key @"BWClickedItem" in the supplied userInfo dictionary. extern NSString * const BWSelectableToolbarItemClickedNotification; @interface BWSelectableToolbar : NSToolbar { BWSelectableToolbarHelper *helper; NSMutableArray *itemIdentifiers; NSMutableDictionary *itemsByIdentifier, *enabledByIdentifier; BOOL inIB; // For the IB inspector int selectedIndex; BOOL isPreferencesToolbar; } // Call one of these methods to set the active tab. - (void)setSelectedItemIdentifier:(NSString *)itemIdentifier; // Use if you want an action in the tabbed window to change the tab. - (void)setSelectedItemIdentifierWithoutAnimation:(NSString *)itemIdentifier; // Use if you want to show the window with a certain item selected. // Programmatically disable or enable a toolbar item. - (void)setEnabled:(BOOL)flag forIdentifier:(NSString *)itemIdentifier; @end
08iteng-ipad
TestMerge/bwtoolkit/BWSelectableToolbar.h
Objective-C
bsd
1,218
// // BWTransparentPopUpIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWTransparentPopUpButton.h" @implementation BWTransparentPopUpButton ( BWTransparentPopUpButtonIntegration ) - (IBInset)ibLayoutInset { IBInset inset; inset.top = 4; inset.bottom = 0; inset.left = 1; inset.right = 1; return inset; } - (int)ibBaselineCount { return 1; } - (float)ibBaselineAtIndex:(int)index { return 13; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentPopUpButtonIntegration.m
Objective-C
bsd
570
// // BWInsetTextField.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWInsetTextField.h" @implementation BWInsetTextField - (id)initWithCoder:(NSCoder *)decoder; { self = [super initWithCoder:decoder]; if (self) { [[self cell] setBackgroundStyle:NSBackgroundStyleRaised]; } return self; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWInsetTextField.m
Objective-C
bsd
401
// // BWAddMiniBottomBar.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAddMiniBottomBar.h" #import "NSWindow-NSTimeMachineSupport.h" @interface NSWindow (BWBBPrivate) - (void)setBottomCornerRounded:(BOOL)flag; @end @implementation BWAddMiniBottomBar - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super initWithCoder:decoder]) != nil) { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)]) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; } return self; } - (void)awakeFromNib { [[self window] setContentBorderThickness:16 forEdge:NSMinYEdge]; // Private method if ([[self window] respondsToSelector:@selector(setBottomCornerRounded:)]) [[self window] setBottomCornerRounded:NO]; } - (void)drawRect:(NSRect)aRect { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] && [[self window] contentBorderThicknessForEdge:NSMinYEdge] == 0) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; if ([[self window] isSheet] && [[self window] respondsToSelector:@selector(setMovable:)]) [[self window] setMovable:NO]; } - (NSRect)bounds { return NSMakeRect(-10000,-10000,0,0); } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddMiniBottomBar.m
Objective-C
bsd
1,303
// // BWSheetController.m // BWToolkit // // Created by Brandon Walkin on 03/07/08. // Copyright 2008 __MyCompanyName__. All rights reserved. // #import "BWSheetController.h" #import "NSWindow-NSTimeMachineSupport.h" @implementation BWSheetController - (void)awakeFromNib { // Hack so the sheet doesn't appear at launch in Cocoa Simulator (or in the actual app if "Visible at Launch" is checked) [sheet setAlphaValue:0]; [sheet performSelector:@selector(orderOut:) withObject:nil afterDelay:0]; // If the sheet has a toolbar or a bottom bar, make sure those elements can't move the window (private API) if ([sheet respondsToSelector:@selector(setMovable:)]) [sheet setMovable:NO]; } - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super init]) != nil) { NSWindowController *tempSheetController = [decoder decodeObjectForKey:@"BWSCSheet"]; NSWindowController *tempParentWindowController = [decoder decodeObjectForKey:@"BWSCParentWindow"]; sheet = [tempSheetController window]; parentWindow = [tempParentWindowController window]; } return self; } - (void)encodeWithCoder:(NSCoder*)coder { NSWindowController *tempSheetController = [[[NSWindowController alloc] initWithWindow:sheet] autorelease]; NSWindowController *tempParentWindowController = [[[NSWindowController alloc] initWithWindow:parentWindow] autorelease]; [coder encodeObject:tempSheetController forKey:@"BWSCSheet"]; [coder encodeObject:tempParentWindowController forKey:@"BWSCParentWindow"]; } - (IBAction)openSheet:(id)sender { [sheet setAlphaValue:1]; [NSApp beginSheet:sheet modalForWindow:parentWindow modalDelegate:nil didEndSelector:nil contextInfo:nil]; } - (IBAction)closeSheet:(id)sender { [sheet orderOut:nil]; [NSApp endSheet:sheet]; } - (IBAction)messageDelegateAndCloseSheet:(id)sender { if (delegate != nil && [delegate respondsToSelector:@selector(shouldCloseSheet:)]) { if ([delegate performSelector:@selector(shouldCloseSheet:) withObject:sender]) [self closeSheet:self]; } else { [self closeSheet:self]; } } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSheetController.m
Objective-C
bsd
2,066
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430 {\fonttbl\f0\fnil\fcharset0 Verdana;} {\colortbl;\red255\green255\blue255;\red73\green73\blue73;} {\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid1}} {\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}} \deftab720 \pard\pardeftab720\sl400\sa280\ql\qnatural \f0\fs24 \cf2 Copyright (c) 2009, Brandon Walkin\uc0\u8232 All rights reserved.\ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ \pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa20\ql\qnatural \ls1\ilvl0\cf2 {\listtext \'95 }Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ {\listtext \'95 }Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ {\listtext \'95 }Neither the name of the Brandon Walkin nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\ \pard\pardeftab720\sl400\sa280\ql\qnatural \cf2 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.}
08iteng-ipad
TestMerge/bwtoolkit/License.rtf
Rich Text Format
bsd
2,213
// // BWTransparentButtonIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWTransparentButton.h" @implementation BWTransparentButton ( BWTransparentButtonIntegration ) - (IBInset)ibLayoutInset { IBInset inset; inset.top = 10; inset.bottom = 0; inset.left = 1; inset.right = 1; return inset; } - (int)ibBaselineCount { return 1; } - (float)ibBaselineAtIndex:(int)index { return 13; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentButtonIntegration.m
Objective-C
bsd
557
// // BWTransparentScroller.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTransparentScroller : NSScroller { BOOL isVertical; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentScroller.h
Objective-C
bsd
258
// // BWSplitView.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) and Fraser Kuyvenhoven. // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWSplitView : NSSplitView { NSColor *color; BOOL colorIsEnabled, checkboxIsEnabled, dividerCanCollapse, collapsibleSubviewCollapsed; id secondaryDelegate; NSMutableDictionary *minValues, *maxValues, *minUnits, *maxUnits; NSMutableDictionary *resizableSubviewPreferredProportion, *nonresizableSubviewPreferredSize; NSArray *stateForLastPreferredCalculations; int collapsiblePopupSelection; float uncollapsedSize; // Collapse button NSButton *toggleCollapseButton; BOOL isAnimating; } @property (retain) NSMutableDictionary *minValues, *maxValues, *minUnits, *maxUnits; @property (retain) NSMutableDictionary *resizableSubviewPreferredProportion, *nonresizableSubviewPreferredSize; @property (retain) NSArray *stateForLastPreferredCalculations; @property (retain) NSButton *toggleCollapseButton; @property BOOL collapsibleSubviewCollapsed; @property int collapsiblePopupSelection; @property BOOL dividerCanCollapse; // The split view divider color @property (copy) NSColor *color; // Flag for whether a custom divider color is enabled. If not, the standard divider color is used. @property BOOL colorIsEnabled; // Call this method to collapse or expand a subview configured as collapsible in the IB inspector. - (IBAction)toggleCollapse:(id)sender; @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitView.h
Objective-C
bsd
1,479
// // BWSheetController.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWSheetController : NSObject { IBOutlet NSWindow *sheet; IBOutlet NSWindow *parentWindow; IBOutlet id delegate; } - (IBAction)openSheet:(id)sender; - (IBAction)closeSheet:(id)sender; - (IBAction)messageDelegateAndCloseSheet:(id)sender; // The optional delegate should implement the method: // - (BOOL)shouldCloseSheet:(id)sender // Return YES if you want the sheet to close after the button click, NO if it shouldn't close. The sender // object is the button that requested the close. This is helpful because in the event that there are multiple buttons // hooked up to the messageDelegateAndCloseSheet: method, you can distinguish which button called the method. @end
08iteng-ipad
TestMerge/bwtoolkit/BWSheetController.h
Objective-C
bsd
866
// // BWTransparentSlider.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentSlider.h" #import "BWTransparentSliderCell.h" @implementation BWTransparentSlider + (Class)cellClass { return [BWTransparentSliderCell class]; } - (id)initWithCoder:(NSCoder *)decoder { // Fail gracefully on non-keyed coders if (![decoder isKindOfClass:[NSKeyedUnarchiver class]]) return [super initWithCoder:decoder]; NSKeyedUnarchiver *coder = (NSKeyedUnarchiver *)decoder; Class oldClass = [[self superclass] cellClass]; Class newClass = [[self class] cellClass]; [coder setClass:newClass forClassName:NSStringFromClass(oldClass)]; self = [super initWithCoder:coder]; [coder setClass:oldClass forClassName:NSStringFromClass(oldClass)]; return self; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentSlider.m
Objective-C
bsd
859
// // BWSplitViewIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWSplitView.h" #import "BWSplitViewInspector.h" @implementation BWSplitView ( BWSplitViewIntegration ) - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { [super ibPopulateKeyPaths:keyPaths]; [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:@"color",@"colorIsEnabled",@"dividerCanCollapse",nil]]; } - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { [super ibPopulateAttributeInspectorClasses:classes]; [classes addObject:[BWSplitViewInspector class]]; } - (void)ibDidAddToDesignableDocument:(IBDocument *)document { [super ibDidAddToDesignableDocument:document]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitViewIntegration.m
Objective-C
bsd
888
// // BWAnchoredPopUpButtonCell.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAnchoredPopUpButtonCell.h" #import "BWAnchoredPopUpButton.h" #import "BWAnchoredButtonBar.h" #import "NSColor+BWAdditions.h" #import "NSImage+BWAdditions.h" #define IMAGE_INSET 8; #define ARROW_INSET 11; static NSColor *fillStop1, *fillStop2, *fillStop3, *fillStop4; static NSColor *topBorderColor, *bottomBorderColor, *sideBorderColor, *sideInsetColor, *pressedColor; static NSColor *textColor, *textShadowColor, *imageColor, *imageShadowColor; static NSColor *borderedSideBorderColor, *borderedTopBorderColor; static NSGradient *fillGradient; static NSImage *pullDownArrow; static float scaleFactor = 1.0f; @interface BWAnchoredPopUpButtonCell (BWAPUBCPrivate) - (void)drawTitleInFrame:(NSRect)cellFrame; - (void)drawImageInFrame:(NSRect)cellFrame; - (void)drawArrowInFrame:(NSRect)cellFrame; @end @implementation BWAnchoredPopUpButtonCell + (void)initialize; { fillStop1 = [[NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1] retain]; fillStop2 = [[NSColor colorWithCalibratedWhite:(242.0f / 255.0f) alpha:1] retain]; fillStop3 = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain]; fillStop4 = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain]; fillGradient = [[NSGradient alloc] initWithColorsAndLocations: fillStop1, (CGFloat)0.0, fillStop2, (CGFloat)0.45454, fillStop3, (CGFloat)0.45454, fillStop4, (CGFloat)1.0, nil]; topBorderColor = [[NSColor colorWithCalibratedWhite:(202.0f / 255.0f) alpha:1] retain]; bottomBorderColor = [[NSColor colorWithCalibratedWhite:(170.0f / 255.0f) alpha:1] retain]; sideBorderColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.2] retain]; sideInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.5] retain]; pressedColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.35] retain]; textColor = [[NSColor colorWithCalibratedWhite:(10.0f / 255.0f) alpha:1] retain]; textShadowColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.75] retain]; imageColor = [[NSColor colorWithCalibratedWhite:(70.0f / 255.0f) alpha:1] retain]; imageShadowColor = [[NSColor colorWithCalibratedWhite:(240.0f / 255.0f) alpha:1] retain]; borderedSideBorderColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.25] retain]; borderedTopBorderColor = [[NSColor colorWithCalibratedWhite:(190.0f / 255.0f) alpha:1] retain]; if([BWAnchoredPopUpButtonCell class] == [self class]) { NSBundle *bundle = [NSBundle bundleForClass:[BWAnchoredPopUpButtonCell class]]; pullDownArrow = [[[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"ButtonBarPullDownArrow.pdf"]] retain]; } } - (void)awakeFromNib { scaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor]; } - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { BOOL inBorderedBar = YES; if ([[[self controlView] superview] respondsToSelector:@selector(isAtBottom)]) { if ([(BWAnchoredButtonBar *)[[self controlView] superview] isAtBottom]) inBorderedBar = NO; } [fillGradient drawInRect:cellFrame angle:90]; [bottomBorderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:YES]; [sideInsetColor drawPixelThickLineAtPosition:1 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; [sideInsetColor drawPixelThickLineAtPosition:1 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; if (inBorderedBar) { [borderedTopBorderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:NO]; [borderedSideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; [borderedSideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; } else { [topBorderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:NO]; [sideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; [sideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; } if (inBorderedBar && [[self controlView] respondsToSelector:@selector(isAtLeftEdgeOfBar)]) { if ([(BWAnchoredPopUpButton *)[self controlView] isAtLeftEdgeOfBar]) [bottomBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; if ([(BWAnchoredPopUpButton *)[self controlView] isAtRightEdgeOfBar]) [bottomBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; } if ([self image] == nil) [self drawTitleInFrame:cellFrame]; else [self drawImageInFrame:cellFrame]; [self drawArrowInFrame:cellFrame]; if ([self isHighlighted]) { [pressedColor set]; NSRectFillUsingOperation(cellFrame, NSCompositeSourceOver); } } - (void)drawTitleInFrame:(NSRect)cellFrame { if (![[self title] isEqualToString:@""]) { NSColor *localTextColor = textColor; if (![self isEnabled]) { localTextColor = [textColor colorWithAlphaComponent:0.6]; } NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; [attributes addEntriesFromDictionary:[[self attributedTitle] attributesAtIndex:0 effectiveRange:NULL]]; [attributes setObject:localTextColor forKey:NSForegroundColorAttributeName]; [attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName]; NSShadow *shadow = [[[NSShadow alloc] init] autorelease]; [shadow setShadowOffset:NSMakeSize(0,-1)]; [shadow setShadowColor:textShadowColor]; [attributes setObject:shadow forKey:NSShadowAttributeName]; NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:[self title] attributes:attributes] autorelease]; // Draw title NSRect boundingRect = [string boundingRectWithSize:cellFrame.size options:0]; NSPoint cellCenter; cellCenter.y = cellFrame.size.height / 2; NSPoint drawPoint = cellCenter; drawPoint.y -= boundingRect.size.height / 2; drawPoint.y = roundf(drawPoint.y); drawPoint.x = IMAGE_INSET; [string drawAtPoint:drawPoint]; } } - (void)drawImageInFrame:(NSRect)cellFrame { NSImage *image = [self image]; if (image != nil) { [image setScalesWhenResized:NO]; NSRect sourceRect = NSZeroRect; if ([[image name] isEqualToString:@"NSActionTemplate"]) [image setSize:NSMakeSize(10,10)]; sourceRect.size = [image size]; NSPoint backgroundCenter; backgroundCenter.y = cellFrame.size.height / 2; NSPoint drawPoint = backgroundCenter; drawPoint.y -= sourceRect.size.height / 2 ;//+ 0.5; drawPoint.y = roundf(drawPoint.y); drawPoint.x = IMAGE_INSET; if ([image isTemplate]) { NSImage *glyphImage = [image tintedImageWithColor:imageColor]; NSImage *shadowImage = [image tintedImageWithColor:imageShadowColor]; NSPoint shadowPoint = drawPoint; shadowPoint.y--; NSAffineTransform* transform = [NSAffineTransform transform]; [transform translateXBy:0.0 yBy:cellFrame.size.height]; [transform scaleXBy:1.0 yBy:-1.0]; [transform concat]; [shadowImage drawAtPoint:shadowPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:1]; if ([self isEnabled]) [glyphImage drawAtPoint:drawPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:1]; else [glyphImage drawAtPoint:drawPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:0.5]; [transform invert]; [transform concat]; } else { if ([self isEnabled]) [image drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; else [image drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.5]; } } } - (void)drawArrowInFrame:(NSRect)cellFrame { if ([self pullsDown]) { NSPoint drawPoint; drawPoint.x = NSMaxX(cellFrame) - ARROW_INSET; drawPoint.y = roundf(cellFrame.size.height / 2) - 2; NSImage *glyphImage = [pullDownArrow tintedImageWithColor:imageColor]; NSImage *shadowImage = [pullDownArrow tintedImageWithColor:imageShadowColor]; NSPoint shadowPoint = drawPoint; shadowPoint.y--; NSAffineTransform* transform = [NSAffineTransform transform]; [transform translateXBy:0.0 yBy:cellFrame.size.height]; [transform scaleXBy:1.0 yBy:-1.0]; [transform concat]; [shadowImage drawAtPoint:shadowPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; if ([self isEnabled]) [glyphImage drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; else [glyphImage drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.5]; [transform invert]; [transform concat]; } else { // Doesn't support pop-up style yet } } - (NSControlSize)controlSize { return NSSmallControlSize; } - (void)setControlSize:(NSControlSize)size { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAnchoredPopUpButtonCell.m
Objective-C
bsd
9,450
// // BWAddMiniBottomBar.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWAddMiniBottomBar : NSView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddMiniBottomBar.h
Objective-C
bsd
231
// // BWTransparentButton.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentButton.h" @implementation BWTransparentButton + (Class)cellClass { return [BWTransparentButtonCell class]; } - (id)initWithCoder:(NSCoder *)decoder { // Fail gracefully on non-keyed coders if (![decoder isKindOfClass:[NSKeyedUnarchiver class]]) return [super initWithCoder:decoder]; NSKeyedUnarchiver *coder = (NSKeyedUnarchiver *)decoder; Class oldClass = [[self superclass] cellClass]; Class newClass = [[self class] cellClass]; [coder setClass:newClass forClassName:NSStringFromClass(oldClass)]; self = [super initWithCoder:coder]; [coder setClass:oldClass forClassName:NSStringFromClass(oldClass)]; return self; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentButton.m
Objective-C
bsd
823
// // BWToolbarItem.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWToolbarItem : NSToolbarItem { NSString *identifierString; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolbarItem.h
Objective-C
bsd
256
// // BWRemoveBottomBar.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWRemoveBottomBar : NSView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWRemoveBottomBar.h
Objective-C
bsd
229
// // BWSplitViewInspectorAutosizingView.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWSplitViewInspectorAutosizingView.h" #import "BWSplitViewInspectorAutosizingButtonCell.h" @implementation BWSplitViewInspectorAutosizingView @synthesize splitView; - (id)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { buttons = [[NSMutableArray alloc] init]; } return self; } - (void)drawRect:(NSRect)aRect { aRect = self.bounds; if ([[self subviews] count] > 0) { [[NSColor windowBackgroundColor] set]; NSRectFill(aRect); } } - (BOOL)isFlipped { return YES; } - (BOOL)isVertical { return [splitView isVertical]; } - (void)layoutButtons { // Remove existing buttons [buttons removeAllObjects]; while ([[self subviews] count] > 0) { [[[self subviews] objectAtIndex:0] removeFromSuperview]; } // Create new buttons and draw them float x, y; int numberOfSubviews = [[splitView subviews] count]; for (int i = 0; i < numberOfSubviews; i++) { NSRect buttonRect = NSZeroRect; if ([splitView isVertical]) { if (i != numberOfSubviews - 1) buttonRect = NSMakeRect(x, 0, floorf((self.bounds.size.width + numberOfSubviews) / numberOfSubviews), self.bounds.size.height); else buttonRect = NSMakeRect(x, 0, self.bounds.size.width - x, self.bounds.size.height); } if ([splitView isVertical] == NO) { if (i != numberOfSubviews - 1) buttonRect = NSMakeRect(0, y, self.bounds.size.width, floorf((self.bounds.size.height + numberOfSubviews) / numberOfSubviews)); else buttonRect = NSMakeRect(0, y, self.bounds.size.width, self.bounds.size.height - y); } NSButton *subviewButton = [[NSButton alloc] initWithFrame:buttonRect]; [subviewButton setCell:[[BWSplitViewInspectorAutosizingButtonCell alloc] initTextCell:@""]]; [subviewButton setTarget:self]; [subviewButton setAction:@selector(updateValues:)]; [subviewButton setTag:i]; // Make the new buttons represent whether the subviews are set to resize or not if ([splitView isVertical]) { if ([[[splitView subviews] objectAtIndex:i] autoresizingMask] & NSViewWidthSizable) [subviewButton setIntValue:1]; } else { if ([[[splitView subviews] objectAtIndex:i] autoresizingMask] & NSViewHeightSizable) [subviewButton setIntValue:1]; } if ([splitView isVertical] && numberOfSubviews < 6 || ![splitView isVertical] && numberOfSubviews < 4) [self addSubview:subviewButton]; [buttons addObject:subviewButton]; x += buttonRect.size.width - 1; y += buttonRect.size.height - 1; } // At least 1 subview must be resizable, so if none of the subviews are set to resize, then we'll set all subviews to resize (which will make it the default state) BOOL resizableViewExists = NO; for (NSButton *button in buttons) { if ([button intValue] == 1) resizableViewExists = YES; } if (resizableViewExists == NO) { for (NSButton *button in buttons) { [button setIntValue:1]; NSView *subviewForButton = [[splitView subviews] objectAtIndex:[button tag]]; int mask = [subviewForButton autoresizingMask]; if ([splitView isVertical]) [subviewForButton setAutoresizingMask:(mask | NSViewWidthSizable)]; else [subviewForButton setAutoresizingMask:(mask | NSViewHeightSizable)]; } } } - (void)updateValues:(id)sender { // Make sure there is always at least one resizable view NSView *subviewForSender = [[splitView subviews] objectAtIndex:[sender tag]]; BOOL resizableViewExists = NO; for (NSButton *button in buttons) { if ([button intValue] == 1) resizableViewExists = YES; } if (resizableViewExists == NO) [sender setIntValue:1]; // Set the autorezising mask on the subview according to the button state int mask = [subviewForSender autoresizingMask]; if ([splitView isVertical]) { if ([sender intValue] == 1) [subviewForSender setAutoresizingMask:(mask | NSViewWidthSizable)]; else [subviewForSender setAutoresizingMask:(mask & ~NSViewWidthSizable)]; } else { if ([sender intValue] == 1) [subviewForSender setAutoresizingMask:(mask | NSViewHeightSizable)]; else [subviewForSender setAutoresizingMask:(mask & ~NSViewHeightSizable)]; } } - (void)dealloc { [buttons release]; [super dealloc]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitViewInspectorAutosizingView.m
Objective-C
bsd
4,376
// // BWTokenField.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTokenField : NSTokenField { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTokenField.h
Objective-C
bsd
225
// // BWTransparentButton.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> #import "BWTransparentButtonCell.h" @interface BWTransparentButton : NSButton { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentButton.h
Objective-C
bsd
271
// // BWTransparentTableViewIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWTransparentTableView.h" @implementation BWTransparentTableView ( BWTransparentTableViewIntegration ) - (void)addObject:(id)object toParent:(id)parent { IBDocument *document = [IBDocument documentForObject:parent]; [document addObject:object toParent:parent]; } - (void)removeObject:(id)object { IBDocument *document = [IBDocument documentForObject:object]; [document removeObject:object]; } - (void)ibTester { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentTableViewIntegration.m
Objective-C
bsd
663
// // BWUnanchoredButtonContainer.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWUnanchoredButtonContainer : NSView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWUnanchoredButtonContainer.h
Objective-C
bsd
249
// // BWTransparentTextFieldCell.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentTextFieldCell.h" static NSShadow *textShadow; @interface NSCell (BWTTFCPrivate) - (NSDictionary *)_textAttributes; @end @implementation BWTransparentTextFieldCell + (void)initialize { textShadow = [[NSShadow alloc] init]; [textShadow setShadowOffset:NSMakeSize(0,-1)]; } - (NSDictionary *)_textAttributes { NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; [attributes addEntriesFromDictionary:[super _textAttributes]]; [attributes setObject:[NSColor whiteColor] forKey:NSForegroundColorAttributeName]; [attributes setObject:[NSFont boldSystemFontOfSize:11] forKey:NSFontAttributeName]; [attributes setObject:textShadow forKey:NSShadowAttributeName]; return attributes; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentTextFieldCell.m
Objective-C
bsd
913
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430 {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;} {\colortbl;\red255\green255\blue255;\red100\green56\blue32;\red196\green26\blue22;} {\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid1} {\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid2} {\list\listtemplateid3\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid3} {\list\listtemplateid4\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1\'02\'05.;}{\levelnumbers\'01;}}{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid2\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid4} {\list\listtemplateid5\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid5} {\list\listtemplateid6\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid6} {\list\listtemplateid7\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid7} {\list\listtemplateid8\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid8} {\list\listtemplateid9\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid9} {\list\listtemplateid10\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid10} {\list\listtemplateid11\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid11} {\list\listtemplateid12\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid12} {\list\listtemplateid13\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid13} {\list\listtemplateid14\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid14} {\list\listtemplateid15\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid15} {\list\listtemplateid16\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid16} {\list\listtemplateid17\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid17} {\list\listtemplateid18\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid18}} {\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}{\listoverride\listid5\listoverridecount0\ls5}{\listoverride\listid6\listoverridecount0\ls6}{\listoverride\listid7\listoverridecount0\ls7}{\listoverride\listid8\listoverridecount0\ls8}{\listoverride\listid9\listoverridecount0\ls9}{\listoverride\listid10\listoverridecount0\ls10}{\listoverride\listid11\listoverridecount0\ls11}{\listoverride\listid12\listoverridecount0\ls12}{\listoverride\listid13\listoverridecount0\ls13}{\listoverride\listid14\listoverridecount0\ls14}{\listoverride\listid15\listoverridecount0\ls15}{\listoverride\listid16\listoverridecount0\ls16}{\listoverride\listid17\listoverridecount0\ls17}{\listoverride\listid18\listoverridecount0\ls18}} \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \f0\b\fs54 \cf0 BWToolkit \fs36 \ \b0 Plugin for Interface Builder 3\ \b \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs30 \cf0 Version 1.1\ February 24, 2009\ Brandon Walkin\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs32 \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 Installation \b0\fs28 \ \ Step 1. Double click the BWToolkit.ibplugin file to load the plugin into Interface Builder\ \ Note: Interface Builder will reference this file rather than copy it to another location. Keep the .ibplugin file in a location where it won't be deleted.\ \ Step 2. In the Xcode project you want to use the plugin in:\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls1\ilvl0\cf0 {\listtext \'95 }Right click the Linked Frameworks folder and click Add -> Existing Frameworks. Select the BWToolkitFramework.framework directory.\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls2\ilvl0\cf0 {\listtext \'95 }Right click your target and click Add -> New Build Phase -> New Copy Files Build Phase. For destination, select Frameworks, leave the path field blank, and close the window.\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls3\ilvl0\cf0 {\listtext \'95 }Drag the BWToolkit framework from Linked Frameworks to the Copy Files build phase you just added.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ Note: You'll have to repeat step 2 for each project you want to use BWToolkit in.\ \ If you need to reference BWToolkit objects in your classes, you can import the main header like so:\ \ \pard\tx560\pardeftab560\ql\qnatural\pardirnatural \f1\fs24 \cf2 \CocoaLigature0 #import \cf3 <BWToolkitFramework/BWToolkitFramework.h> \f0\fs28 \cf0 \CocoaLigature1 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs32 \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 License\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs28 \cf0 \ All source code is provided under the three clause BSD license. Attribution is appreciated but by no means required.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs32 \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 Contributing\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs28 \cf0 \ Please email any patches to me at bwalkin@gmail.com. \b\fs36 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs32 \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 Compatibility\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs28 \cf0 \ BWToolkit has been tested to work in IB 3.1.1 (672), IB 3.1.2 (677), and IB 3.2 (708). \b\fs36 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs32 \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 History\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs28 \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 1.1 - Feb 23, 2009\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls4\ilvl0 \b0 \cf0 {\listtext \'95 }New BWSplitView with:\ \pard\tx940\tx1440\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li1440\fi-1440\ql\qnatural\pardirnatural \ls4\ilvl1\cf0 {\listtext \uc0\u8259 }Customizable min and max sizes for subviews\ {\listtext \uc0\u8259 }Ability to specify which subviews should and shouldn't resize through a control in the inspector (which just sets the subview's autoresizing mask)\ {\listtext \uc0\u8259 }Collapsing functionality\ \pard\tx1660\tx2160\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li2160\fi-2160\ql\qnatural\pardirnatural \ls4\ilvl2\cf0 {\listtext - }Double click divider to collapse\ {\listtext - }Drag a divider past half of the subview's minimum width to collapse\ {\listtext - }Animated collapse: hook a Toggle button up to the split view's toggleCollapse: action to collapse the subview configured as collapsible. The split view will synchronise its state with the button.\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls4\ilvl0\cf0 {\listtext \'95 }Removed all split view size constraint functionality from the anchored button bar since BWSplitView handles that now\ {\listtext \'95 }Replaced the old colors and fonts icons with the new ones from iWork '09\ {\listtext \'95 }Textured slider: fixed bug where certain areas on the slider weren't clickable, zoom buttons now send an action, and fine tuned mouse scrolling behavior (courtesy of Chris Liscio)\ {\listtext \'95 }Selectable toolbar: fixed issue where a focus ring would stay visible on a tab change (courtesy of Duncan Wilcox)\ {\listtext \'95 }Can now customize the font on BWTokenField in IB\ {\listtext \'95 }Fixed various memory leaks\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 1.0.4 - Jan 20, 2009\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls5\ilvl0 \b0 \cf0 {\listtext \'95 }Added ability to programmatically disable toolbar items in the selectable toolbar\ {\listtext \'95 }Added a notification to the selectable toolbar that gets sent whenever a toolbar item has been clicked (see header for details)\ {\listtext \'95 }Added main header file for easy importing\ {\listtext \'95 }Fixed issue where the BWToolbarItem inspector wouldn't be updated with the item identifier \b \ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls6\ilvl0 \b0 \cf0 {\listtext \'95 }There's been an API change in BWSheetController. The delegate method now gets passed the button that initiated the sheet close. This is helpful because in the event that there are multiple buttons hooked up to the messageDelegateAndCloseSheet: method, you can distinguish which button called the method and behave accordingly.\ {\listtext \'95 }Fixed disabled appearance for BWAnchoredPopUpButton\ {\listtext \'95 }Fixed a bug where a sheet not using BWSheetController could be moved around by its bottom bar\ {\listtext \'95 }Fixed toolbar item memory leaks \b \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ 1.0.3 - Dec 18, 2008\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls7\ilvl0 \b0 \cf0 {\listtext \'95 }64-bit support (courtesy of Rob Rix)\ {\listtext \'95 }Added disabled appearance and scroll wheel support to BWTexturedSlider\ {\listtext \'95 }The selectable toolbar panes are now keyboard accessible\ {\listtext \'95 }Anchored button bar now lets you provide your own delegate implementations for the split view (see the header for details)\ {\listtext \'95 }Nearly all the headers have been made public\ {\listtext \'95 }Fixed memory leaks\ {\listtext \'95 }Minor bug fixes\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 \ 1.0.2 - Nov 19, 2008 \b0 \ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls8\ilvl0\cf0 {\listtext \'95 }Added a toolbar item with a customizable item identifier\ {\listtext \'95 }New methods in the BWSelectableToolbar header for programmatically setting the selected toolbar item\ {\listtext \'95 }Reduced the file size of the framework by 40%\ {\listtext \'95 }Made the headers for BWSelectableToolbar and BWSplitView public\ {\listtext \'95 }Fixed a serious bug where IB would crash whenever a window that contained a selectable toolbar had certain properties modified (like whether it had a unified toolbar or could resize)\ {\listtext \'95 }Fixed bug where if a window in IB with a bottom bar was closed and then opened, its bottom bar would disappear\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 \ 1.0.1 - Nov 14, 2008 \b0 \ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls9\ilvl0\cf0 {\listtext \'95 }Added Garbage Collection compatibility. Will now compile in GC supported and GC required apps.\ {\listtext \'95 }Minor bug fix\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 \ 1.0 - Nov 13, 2008 \b0 \ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls10\ilvl0\cf0 {\listtext \'95 \fs32 } \fs28 Initial Release \fs32 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 Known Issues\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs28 \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 General\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls11\ilvl0 \b0 \cf0 {\listtext \'95 }When you build your project, you may get a warning that says "Could not find object file...". It's harmless and you can ignore it. A fix is being worked on for a future release.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 Selectable Toolbar\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls12\ilvl0 \b0 \cf0 {\listtext \'95 }If your IB version is greater than 3.1.1 (672): Simulating is not supported for any document that has a selectable toolbar in it. The toolbar will not be able to save correctly and will be unusable. You will have to quit Interface Builder and restore to a previous version of the nib. Version control is highly recommended. You \b must \b0 back up your document on a consistent basis if you want to use this toolbar.\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls13\ilvl0\cf0 {\listtext \'95 }Interface Builder currently has a bug where a toolbar won't remember any changes to its configuration since an item was added to it. If you take a standard toolbar, rearrange some items in it or remove a few items, it will not remember that configuration when you save the document. To work around this problem, remove an item from the toolbar and add it back before you save the document.\ {\listtext \'95 }Undo is not yet supported for active tab switching.\ {\listtext \'95 }If you want your window with a selectable toolbar to have a bottom bar, drag the bottom bar item to the window like you would normally, but repeat this for each tab in the window.\ {\listtext \'95 }When you re-order the items in the toolbar you'll have to reselect the toolbar for the "Active Tab" pop-up menu to reflect the new order.\ {\listtext \'95 }Make sure, in the outline view, not to double click an item in one of the views in the window that is not nested in the window's current content view. Doing so will cause IB to crash. Instead, switch to the tab with the item, then double click it.\ {\listtext \'95 }Use no more than one selectable toolbar per NIB/XIB. And no more than one document with a selectable toolbar should be open in IB at any particular time.\ {\listtext \'95 }Removing the separator, space, or flexible space from the toolbar's allowed items will remove all items from the toolbar.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 Split View\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls14\ilvl0 \b0 \cf0 {\listtext \'95 }Split view attributes are not yet saved through the autosave name.\ {\listtext \'95 }The toggle action can't uncollapse a subview that's been collapsed manually by dragging the divider.\ {\listtext \'95 }For collapsing using the toggle action, there should only be 1 resizable subview in the split view other than the collapsible view (which can be either resizable or non-resizable).\ {\listtext \'95 }Undo isn't fully supported.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 Bottom Bars\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls15\ilvl0 \b0 \cf0 {\listtext \'95 }When using the drag handles to resize certain controls positioned on a bottom bar, the window will take the click and will move while the control stays stationary. As a workaround, try holding the Control key while resizing the control. If that fails, resize it in the inspector.\ {\listtext \'95 }Bottom bars must be added to the window's content view rather than any subview.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 Anchored Button Bar\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls16\ilvl0 \b0 \cf0 {\listtext \'95 }The inspector doesn't update when an undo action is called on a mode change. Just select the mode you want to use in the inspector.\ {\listtext \'95 }The bar should have a slightly shorter height in the third mode.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 Anchored Pop Up Button\ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls17\ilvl0 \b0 \cf0 {\listtext \'95 }Only the Pull Down type is available at the moment.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b \cf0 Transparent Scroll View \b0 \ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls18\ilvl0\cf0 {\listtext \'95 }Horizontal scrolling is not yet supported.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs32 \cf0 \ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b\fs36 \cf0 Acknowledgements\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \b0\fs28 \cf0 \ Thanks to Fraser Kuyvenhoven, Ali Lalani, Brent Gulanowski, and Jonathan Hess for giving me some assistance with this project.\ }
08iteng-ipad
TestMerge/bwtoolkit/Release Notes.rtf
Rich Text Format
bsd
23,572
// // BWAddSheetBottomBar.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAddSheetBottomBar.h" #import "NSWindow-NSTimeMachineSupport.h" @interface NSWindow (BWPrivate) - (void)setBottomCornerRounded:(BOOL)flag; @end @implementation BWAddSheetBottomBar - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super initWithCoder:decoder]) != nil) { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)]) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; } return self; } - (void)awakeFromNib { [[self window] setContentBorderThickness:40 forEdge:NSMinYEdge]; // Private method if ([[self window] respondsToSelector:@selector(setBottomCornerRounded:)]) [[self window] setBottomCornerRounded:NO]; } - (void)drawRect:(NSRect)aRect { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] && [[self window] contentBorderThicknessForEdge:NSMinYEdge] == 0) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; if ([[self window] isSheet] && [[self window] respondsToSelector:@selector(setMovable:)]) [[self window] setMovable:NO]; } - (NSRect)bounds { return NSMakeRect(-10000,-10000,0,0); } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddSheetBottomBar.m
Objective-C
bsd
1,304
// // BWAnchoredButtonCell.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAnchoredButtonCell.h" #import "BWAnchoredButtonBar.h" #import "BWAnchoredButton.h" #import "NSColor+BWAdditions.h" #import "NSImage+BWAdditions.h" static NSColor *fillStop1, *fillStop2, *fillStop3, *fillStop4; static NSColor *topBorderColor, *bottomBorderColor, *sideBorderColor, *sideInsetColor, *pressedColor; static NSColor *textColor, *textShadowColor, *imageColor, *imageShadowColor; static NSColor *borderedSideBorderColor, *borderedTopBorderColor; static NSGradient *fillGradient; static float scaleFactor = 1.0f; @interface BWAnchoredButtonCell (BWABCPrivate) - (void)drawTitleInFrame:(NSRect)cellFrame; - (void)drawImageInFrame:(NSRect)cellFrame; @end @implementation BWAnchoredButtonCell + (void)initialize; { fillStop1 = [[NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1] retain]; fillStop2 = [[NSColor colorWithCalibratedWhite:(242.0f / 255.0f) alpha:1] retain]; fillStop3 = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain]; fillStop4 = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain]; fillGradient = [[NSGradient alloc] initWithColorsAndLocations: fillStop1, (CGFloat)0.0, fillStop2, (CGFloat)0.45454, fillStop3, (CGFloat)0.45454, fillStop4, (CGFloat)1.0, nil]; topBorderColor = [[NSColor colorWithCalibratedWhite:(202.0f / 255.0f) alpha:1] retain]; bottomBorderColor = [[NSColor colorWithCalibratedWhite:(170.0f / 255.0f) alpha:1] retain]; sideBorderColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.2] retain]; sideInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.5] retain]; pressedColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.35] retain]; textColor = [[NSColor colorWithCalibratedWhite:(10.0f / 255.0f) alpha:1] retain]; textShadowColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.75] retain]; imageColor = [[NSColor colorWithCalibratedWhite:(72.0f / 255.0f) alpha:1] retain]; imageShadowColor = [[NSColor colorWithCalibratedWhite:(240.0f / 255.0f) alpha:1] retain]; borderedSideBorderColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.25] retain]; borderedTopBorderColor = [[NSColor colorWithCalibratedWhite:(190.0f / 255.0f) alpha:1] retain]; } - (void)awakeFromNib { scaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor]; } - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { BOOL inBorderedBar = YES; if ([[[self controlView] superview] respondsToSelector:@selector(isAtBottom)]) { if ([(BWAnchoredButtonBar *)[[self controlView] superview] isAtBottom]) inBorderedBar = NO; } [fillGradient drawInRect:cellFrame angle:90]; [bottomBorderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:YES]; [sideInsetColor drawPixelThickLineAtPosition:1 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; [sideInsetColor drawPixelThickLineAtPosition:1 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; if (inBorderedBar) { [borderedTopBorderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:NO]; [borderedSideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; [borderedSideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; } else { [topBorderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:cellFrame inView:[self controlView] horizontal:YES flip:NO]; [sideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; [sideBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; } if (inBorderedBar && [[self controlView] respondsToSelector:@selector(isAtLeftEdgeOfBar)]) { if ([(BWAnchoredButton *)[self controlView] isAtLeftEdgeOfBar]) [bottomBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:NO]; if ([(BWAnchoredButton *)[self controlView] isAtRightEdgeOfBar]) [bottomBorderColor drawPixelThickLineAtPosition:0 withInset:1 inRect:cellFrame inView:[self controlView] horizontal:NO flip:YES]; } if ([self image] == nil) [self drawTitleInFrame:cellFrame]; else [self drawImageInFrame:cellFrame]; if ([self isHighlighted]) { [pressedColor set]; NSRectFillUsingOperation(cellFrame, NSCompositeSourceOver); } } - (void)drawTitleInFrame:(NSRect)cellFrame { if (![[self title] isEqualToString:@""]) { NSColor *localTextColor = textColor; if (![self isEnabled]) { localTextColor = [textColor colorWithAlphaComponent:0.6]; } NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; [attributes addEntriesFromDictionary:[[self attributedTitle] attributesAtIndex:0 effectiveRange:NULL]]; [attributes setObject:localTextColor forKey:NSForegroundColorAttributeName]; [attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName]; NSShadow *shadow = [[[NSShadow alloc] init] autorelease]; [shadow setShadowOffset:NSMakeSize(0,-1)]; [shadow setShadowColor:textShadowColor]; [attributes setObject:shadow forKey:NSShadowAttributeName]; NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:[self title] attributes:attributes] autorelease]; [self setAttributedTitle:string]; // Draw title NSRect boundingRect = [[self attributedTitle] boundingRectWithSize:cellFrame.size options:0]; NSPoint cellCenter; cellCenter.x = cellFrame.size.width / 2; cellCenter.y = cellFrame.size.height / 2; NSPoint drawPoint = cellCenter; drawPoint.x -= boundingRect.size.width / 2; drawPoint.y -= boundingRect.size.height / 2; drawPoint.x = roundf(drawPoint.x); drawPoint.y = roundf(drawPoint.y); if (drawPoint.x < 4) drawPoint.x = 4; [[self attributedTitle] drawAtPoint:drawPoint]; } } - (void)drawImageInFrame:(NSRect)cellFrame { NSImage *image = [self image]; if (image != nil) { [image setScalesWhenResized:NO]; NSRect sourceRect = NSZeroRect; if ([[image name] isEqualToString:@"NSActionTemplate"]) [image setSize:NSMakeSize(10,10)]; sourceRect.size = [image size]; NSPoint backgroundCenter; backgroundCenter.x = cellFrame.size.width / 2; backgroundCenter.y = cellFrame.size.height / 2; NSPoint drawPoint = backgroundCenter; drawPoint.x -= sourceRect.size.width / 2; drawPoint.y -= sourceRect.size.height / 2 ; drawPoint.x = roundf(drawPoint.x); drawPoint.y = roundf(drawPoint.y); if ([image isTemplate]) { NSImage *glyphImage = [image tintedImageWithColor:imageColor]; NSImage *shadowImage = [image tintedImageWithColor:imageShadowColor]; NSPoint shadowPoint = drawPoint; shadowPoint.y--; NSAffineTransform* xform = [NSAffineTransform transform]; [xform translateXBy:0.0 yBy:cellFrame.size.height]; [xform scaleXBy:1.0 yBy:-1.0]; [xform concat]; [shadowImage drawAtPoint:shadowPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:1]; if ([self isEnabled]) [glyphImage drawAtPoint:drawPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:1]; else [glyphImage drawAtPoint:drawPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:0.5]; } else { if ([self isEnabled]) [image drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; else [image drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.5]; } } } - (NSControlSize)controlSize { return NSSmallControlSize; } - (void)setControlSize:(NSControlSize)size { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAnchoredButtonCell.m
Objective-C
bsd
8,159
// // BWTransparentTableView.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTransparentTableView : NSTableView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentTableView.h
Objective-C
bsd
244
// // BWTokenFieldCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTokenFieldCell : NSTokenFieldCell { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTokenFieldCell.h
Objective-C
bsd
237
// // BWUnanchoredButtonIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWUnanchoredButton.h" @implementation BWUnanchoredButton ( BWUnanchoredButtonIntegration ) - (NSSize)ibMinimumSize { return NSMakeSize(0,22); } - (NSSize)ibMaximumSize { return NSMakeSize(100000,22); } - (IBInset)ibLayoutInset { IBInset inset; inset.bottom = 1; inset.right = 0; inset.top = 1; inset.left = 0; return inset; } - (int)ibBaselineCount { return 1; } - (float)ibBaselineAtIndex:(int)index { return 15; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWUnanchoredButtonIntegration.m
Objective-C
bsd
667
// // BWAddRegularBottomBar.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWAddRegularBottomBar : NSView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddRegularBottomBar.h
Objective-C
bsd
236
// // NSImage+BWAdditions.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface NSImage (BWAdditions) // Draw a solid color over an image - taking into account alpha. Useful for coloring template images. - (NSImage *)tintedImageWithColor:(NSColor *)tint; // Rotate an image 90 degrees clockwise or counterclockwise - (NSImage *)rotateImage90DegreesClockwise:(BOOL)clockwise; @end
08iteng-ipad
TestMerge/bwtoolkit/NSImage+BWAdditions.h
Objective-C
bsd
495
// // BWTransparentTableView.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentTableView.h" #import "BWTransparentTableViewCell.h" #import "BWTransparentCheckboxCell.h" static NSColor *rowColor, *altRowColor, *highlightColor; @interface BWTransparentTableView (BWTTVPrivate) - (void)addObject:(id)object toParent:(id)parent; - (void)removeObject:(id)object; @end @implementation BWTransparentTableView + (void)initialize; { rowColor = [[NSColor colorWithCalibratedWhite:0.13 alpha:0.855] retain]; altRowColor = [[NSColor colorWithCalibratedWhite:0.16 alpha:0.855] retain]; highlightColor = [[NSColor colorWithCalibratedWhite:(75.0 / 255.0) alpha:0.855] retain]; } - (void)addTableColumn:(NSTableColumn *)aColumn { [super addTableColumn:aColumn]; if ([[[aColumn dataCell] className] isEqualToString:@"NSTextFieldCell"]) { BWTransparentTableViewCell *cell = [[BWTransparentTableViewCell alloc] init]; [self removeObject:[aColumn dataCell]]; [aColumn setDataCell:cell]; [self addObject:cell toParent:aColumn]; } } + (Class)cellClass { return [BWTransparentTableViewCell class]; } // We make this a no-op when there are no alt rows so that the background color is not drawn on top of the window - (void)drawBackgroundInClipRect:(NSRect)clipRect { if ([self usesAlternatingRowBackgroundColors]) [super drawBackgroundInClipRect:clipRect]; } // Color shown when a cell is edited - (NSColor *)backgroundColor { return rowColor; } - (NSArray *)_alternatingRowBackgroundColors { NSArray *colors = [NSArray arrayWithObjects:rowColor,altRowColor,nil]; return colors; } - (NSColor *)_highlightColorForCell:(NSCell *)cell { return nil; } - (void)highlightSelectionInClipRect:(NSRect)theClipRect { NSRange aVisibleRowIndexes = [self rowsInRect:theClipRect]; NSIndexSet * aSelectedRowIndexes = [self selectedRowIndexes]; int aRow = aVisibleRowIndexes.location; int anEndRow = aRow + aVisibleRowIndexes.length; for (aRow; aRow < anEndRow; aRow++) { if([aSelectedRowIndexes containsIndex:aRow]) { NSRect aRowRect = [self rectOfRow:aRow]; aRowRect.size.height--; [NSGraphicsContext saveGraphicsState]; [[NSGraphicsContext currentContext] setCompositingOperation:NSCompositeCopy]; NSColor *startColor = [NSColor colorWithCalibratedWhite:(85.0 / 255.0) alpha:0.855]; NSColor *endColor = [NSColor colorWithCalibratedWhite:(70.0 / 255.0) alpha:0.855]; NSGradient *gradient = [[[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor] autorelease]; [gradient drawInRect:aRowRect angle:90]; [NSGraphicsContext restoreGraphicsState]; } } } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentTableView.m
Objective-C
bsd
2,765
// // NSWindow+BWAdditions.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "NSWindow+BWAdditions.h" @implementation NSWindow (BWAdditions) - (void)resizeToSize:(NSSize)newSize animate:(BOOL)animateFlag { NSRect windowFrame; windowFrame.origin.x = [self frame].origin.x; if ([self isSheet]) { float oldWidth = [self frame].size.width; float newWidth = newSize.width; float difference = oldWidth - newWidth; windowFrame.origin.x += difference / 2; } windowFrame.origin.y = [self frame].origin.y + [self frame].size.height - newSize.height; windowFrame.size.width = newSize.width; windowFrame.size.height = newSize.height; if (!NSIsEmptyRect(windowFrame)) [self setFrame:windowFrame display:YES animate:animateFlag]; } - (BOOL)isTextured { return (([self styleMask] & NSTexturedBackgroundWindowMask) != 0); } @end
08iteng-ipad
TestMerge/bwtoolkit/NSWindow+BWAdditions.m
Objective-C
bsd
935
// // BWUnanchoredButtonCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> #import "BWAnchoredButtonCell.h" @interface BWUnanchoredButtonCell : BWAnchoredButtonCell { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWUnanchoredButtonCell.h
Objective-C
bsd
286
// // BWUnanchoredButton.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWUnanchoredButton.h" #import "BWAnchoredButtonBar.h" #import "NSView+BWAdditions.h" @implementation BWUnanchoredButton + (Class)cellClass { return [BWUnanchoredButtonCell class]; } - (id)initWithCoder:(NSCoder *)decoder { // Fail gracefully on non-keyed coders if (![decoder isKindOfClass:[NSKeyedUnarchiver class]]) return [super initWithCoder:decoder]; NSKeyedUnarchiver *coder = (NSKeyedUnarchiver *)decoder; Class oldClass = [[self superclass] cellClass]; Class newClass = [[self class] cellClass]; [coder setClass:newClass forClassName:NSStringFromClass(oldClass)]; self = [super initWithCoder:coder]; if ([BWAnchoredButtonBar wasBorderedBar]) topAndLeftInset = NSMakePoint(0, 0); else topAndLeftInset = NSMakePoint(1, 1); [coder setClass:oldClass forClassName:NSStringFromClass(oldClass)]; return self; } - (void)mouseDown:(NSEvent *)theEvent { [self bringToFront]; [super mouseDown:theEvent]; } - (NSRect)frame { NSRect frame = [super frame]; frame.size.height = 22; return frame; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWUnanchoredButton.m
Objective-C
bsd
1,199
// // NSEvent+BWAdditions.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "NSEvent+BWAdditions.h" @implementation NSEvent (BWAdditions) + (BOOL)shiftKeyIsDown { if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) return YES; return NO; } + (BOOL)commandKeyIsDown { if ([[NSApp currentEvent] modifierFlags] & NSCommandKeyMask) return YES; return NO; } + (BOOL)optionKeyIsDown { if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) return YES; return NO; } + (BOOL)controlKeyIsDown { if ([[NSApp currentEvent] modifierFlags] & NSControlKeyMask) return YES; return NO; } + (BOOL)capsLockKeyIsDown { if ([[NSApp currentEvent] modifierFlags] & NSAlphaShiftKeyMask) return YES; return NO; } @end
08iteng-ipad
TestMerge/bwtoolkit/NSEvent+BWAdditions.m
Objective-C
bsd
834
// // BWTransparentCheckbox.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWTransparentCheckbox.h" @implementation BWTransparentCheckbox + (Class)cellClass { return [BWTransparentCheckboxCell class]; } - (id)initWithCoder:(NSCoder *)decoder { // Fail gracefully on non-keyed coders if (![decoder isKindOfClass:[NSKeyedUnarchiver class]]) return [super initWithCoder:decoder]; NSKeyedUnarchiver *coder = (NSKeyedUnarchiver *)decoder; Class oldClass = [[self superclass] cellClass]; Class newClass = [[self class] cellClass]; [coder setClass:newClass forClassName:NSStringFromClass(oldClass)]; self = [super initWithCoder:coder]; [coder setClass:oldClass forClassName:NSStringFromClass(oldClass)]; return self; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentCheckbox.m
Objective-C
bsd
831
// // BWAnchoredPopUpButtonCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWAnchoredPopUpButtonCell : NSPopUpButtonCell { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAnchoredPopUpButtonCell.h
Objective-C
bsd
256
// // BWSplitViewInspectorAutosizingButtonCell.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWSplitViewInspectorAutosizingButtonCell.h" #import "BWSplitViewInspectorAutosizingView.h" #import "NSColor+BWAdditions.h" #import "NSImage+BWAdditions.h" #import "IBColor.h" static NSColor *insetColor, *borderColor, *viewColor, *lineColor, *insetLineColor; static NSImage *blueArrowStart, *blueArrowEnd, *redArrowStart, *redArrowEnd, *redArrowFill; static float interiorInset = 7.0; @implementation BWSplitViewInspectorAutosizingButtonCell + (void)initialize { insetColor = [IBColor customViewLightBorderColor]; borderColor = [IBColor customViewDarkBorderColor]; viewColor = [IBColor containerCustomViewBackgroundColor]; lineColor = [[NSColor colorWithCalibratedRed:124.0/255.0 green:139.0/255.0 blue:159.0/255.0 alpha:1.0] retain]; insetLineColor = [[[NSColor whiteColor] colorWithAlphaComponent:0.19] retain]; NSBundle *bundle = [NSBundle bundleForClass:[BWSplitViewInspectorAutosizingButtonCell class]]; blueArrowStart = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Inspector-SplitViewArrowBlueLeft.tif"]]; blueArrowEnd = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Inspector-SplitViewArrowBlueRight.tif"]]; redArrowStart = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Inspector-SplitViewArrowRedLeft.tif"]]; redArrowFill = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Inspector-SplitViewArrowRedFill.tif"]]; redArrowEnd = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Inspector-SplitViewArrowRedRight.tif"]]; } - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView { [viewColor set]; NSRectFillUsingOperation(frame,NSCompositeSourceOver); [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:frame inView:controlView horizontal:NO flip:NO]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:frame inView:controlView horizontal:NO flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:frame inView:controlView horizontal:YES flip:YES]; [insetColor drawPixelThickLineAtPosition:1 withInset:0 inRect:frame inView:controlView horizontal:YES flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:frame inView:controlView horizontal:NO flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:frame inView:controlView horizontal:NO flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:frame inView:controlView horizontal:YES flip:YES]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:frame inView:controlView horizontal:YES flip:NO]; } - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { BOOL isVertical = [(BWSplitViewInspectorAutosizingView *)[controlView superview] isVertical]; NSImage *blueArrowStartCap, *blueArrowEndCap, *redArrowStartCap, *redArrowFillSlice, *redArrowEndCap; if (isVertical) { blueArrowStartCap = blueArrowStart; blueArrowEndCap = blueArrowEnd; redArrowStartCap = redArrowStart; redArrowFillSlice = redArrowFill; redArrowEndCap = redArrowEnd; [blueArrowStartCap setFlipped:YES]; [blueArrowEndCap setFlipped:YES]; } else { blueArrowStartCap = [blueArrowStart rotateImage90DegreesClockwise:NO]; blueArrowEndCap = [blueArrowEnd rotateImage90DegreesClockwise:NO]; redArrowStartCap = [redArrowEnd rotateImage90DegreesClockwise:NO]; redArrowFillSlice = [redArrowFill rotateImage90DegreesClockwise:NO]; redArrowEndCap = [redArrowStart rotateImage90DegreesClockwise:NO]; } float arrowHeight = [blueArrowStartCap size].height; float arrowWidth = [blueArrowStartCap size].width; NSRect arrowRect = NSZeroRect; if (isVertical) arrowRect = NSMakeRect(interiorInset, roundf(cellFrame.size.height / 2 - 0.5 * arrowHeight), roundf(cellFrame.size.width - interiorInset * 2), arrowHeight); else arrowRect = NSMakeRect(roundf(cellFrame.size.width / 2 - 0.5 * arrowWidth), interiorInset - 1, arrowWidth, roundf(cellFrame.size.height - (interiorInset - 1) * 2)); if ([self intValue] == 0) { NSPoint startArrowOrigin = arrowRect.origin; NSPoint endArrowOrigin; if (isVertical) endArrowOrigin = NSMakePoint(NSMaxX(arrowRect) - arrowWidth, arrowRect.origin.y); else endArrowOrigin = NSMakePoint(arrowRect.origin.x,NSMaxY(arrowRect) - arrowHeight); [blueArrowStartCap drawAtPoint:startArrowOrigin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; [blueArrowEndCap drawAtPoint:endArrowOrigin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; NSPoint startPoint, endPoint; if (isVertical) { startPoint = NSMakePoint(arrowRect.origin.x + arrowWidth, arrowRect.origin.y + floorf(arrowHeight / 2) + 0.5); endPoint = NSMakePoint(arrowRect.origin.x + arrowRect.size.width - arrowWidth, arrowRect.origin.y + floorf(arrowHeight / 2) + 0.5); } else { startPoint = NSMakePoint(arrowRect.origin.x + floorf(arrowWidth / 2) + 0.5, arrowRect.origin.y + arrowHeight); endPoint = NSMakePoint(arrowRect.origin.x + floorf(arrowWidth / 2) + 0.5, NSMaxY(arrowRect) - arrowHeight); } float array[2] = {3.0, 1.0}; // Draw dashed line NSBezierPath *dashedLine = [NSBezierPath bezierPath]; [dashedLine setLineWidth:1.0]; [dashedLine setLineDash:array count:2 phase:3.0]; [dashedLine moveToPoint:startPoint]; [dashedLine lineToPoint:endPoint]; [lineColor set]; [dashedLine stroke]; // Draw white dashed inset line NSBezierPath *dashedInsetLine = [NSBezierPath bezierPath]; [dashedInsetLine setLineWidth:1.0]; [dashedInsetLine setLineDash:array count:2 phase:3.0]; if (isVertical) { [dashedInsetLine moveToPoint:NSMakePoint(startPoint.x, startPoint.y + 1)]; [dashedInsetLine lineToPoint:NSMakePoint(endPoint.x, endPoint.y + 1)]; } else { [dashedInsetLine moveToPoint:NSMakePoint(startPoint.x + 1, startPoint.y)]; [dashedInsetLine lineToPoint:NSMakePoint(endPoint.x + 1, endPoint.y)]; } [insetLineColor set]; [dashedInsetLine stroke]; } else { if (isVertical) NSDrawThreePartImage(arrowRect, redArrowStartCap, redArrowFillSlice, redArrowEndCap, NO, NSCompositeSourceOver, 1, YES); else NSDrawThreePartImage(arrowRect, redArrowStartCap, redArrowFillSlice, redArrowEndCap, YES, NSCompositeSourceOver, 1, YES); } } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitViewInspectorAutosizingButtonCell.m
Objective-C
bsd
6,514
// // NSWindow+BWAdditions.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface NSWindow (BWAdditions) - (void)resizeToSize:(NSSize)newSize animate:(BOOL)animateFlag; - (BOOL)isTextured; @end
08iteng-ipad
TestMerge/bwtoolkit/NSWindow+BWAdditions.h
Objective-C
bsd
307
// // BWSplitViewInspectorAutosizingButtonCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWSplitViewInspectorAutosizingButtonCell : NSButtonCell { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitViewInspectorAutosizingButtonCell.h
Objective-C
bsd
280
// // BWToolbarShowColorsItem.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWToolbarShowColorsItem.h" @implementation BWToolbarShowColorsItem - (NSImage *)image { NSBundle *bundle = [NSBundle bundleForClass:[BWToolbarShowColorsItem class]]; NSImage *image = [[[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"ToolbarItemColors.tiff"]] autorelease]; return image; } - (NSString *)itemIdentifier { return @"BWToolbarShowColorsItem"; } - (NSString *)label { return @"Colors"; } - (NSString *)paletteLabel { return @"Colors"; } - (id)target { return [NSApplication sharedApplication]; } - (SEL)action { return @selector(orderFrontColorPanel:); } - (NSString *)toolTip { return @"Show Color Panel"; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolbarShowColorsItem.m
Objective-C
bsd
836
// // BWTransparentSliderCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTransparentSliderCell : NSSliderCell { BOOL isPressed; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentSliderCell.h
Objective-C
bsd
263
// // BWControlsView.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWTexturedSlider.h" #import "BWTexturedSliderInspector.h" @implementation BWTexturedSlider ( BWTexturedSliderIntegration ) - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { [super ibPopulateKeyPaths:keyPaths]; [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:@"trackHeight",@"indicatorIndex",nil]]; } - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { [super ibPopulateAttributeInspectorClasses:classes]; [classes addObject:[BWTexturedSliderInspector class]]; } - (IBInset)ibLayoutInset { IBInset inset; if ([self trackHeight] == 0) { inset.top = 4; inset.bottom = 5; } else { inset.top = 5; inset.bottom = 4; } if ([self indicatorIndex] == 0) { inset.right = 4; inset.left = 5; } else if ([self indicatorIndex] == 2) { inset.bottom = 3; inset.right = 5; inset.left = 13; } else if ([self indicatorIndex] == 3) { inset.right = 12; inset.left = 18; } else { inset.right = 0; inset.left = 0; } return inset; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTexturedSliderIntegration.m
Objective-C
bsd
1,273
// // BWSelectableToolbarIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWSelectableToolbar.h" #import "BWSelectableToolbarInspector.h" #import "BWSelectableToolbarHelper.h" @interface NSToolbar (BWSTIntPrivate) - (void)ibDocument:(id)fp8 willStartSimulatorWithContext:(id)fp12; @end @interface BWSelectableToolbar (BWSTIntPrivate) - (id)parentOfObject:(id)anObj; - (void)setDocumentToolbar:(BWSelectableToolbar *)obj; @end @interface IBDocument (BWSTIntPrivate) + (id)currentIBFrameworkVersion; @end @implementation BWSelectableToolbar ( BWSelectableToolbarIntegration ) - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { [super ibPopulateKeyPaths:keyPaths]; [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:@"isPreferencesToolbar",nil]]; } - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { [super ibPopulateAttributeInspectorClasses:classes]; [classes addObject:[BWSelectableToolbarInspector class]]; } // Display a modal warning just before the simulator is launched - this incompatibility will hopefully be fixed in a future version of this plugin - (void)ibDocument:(id)fp8 willStartSimulatorWithContext:(id)fp12 { [super ibDocument:fp8 willStartSimulatorWithContext:fp12]; // Simulating seems to work fine in IB 3.1.1 (672) so we won't show the alert if the user is running that version if ([[IBDocument currentIBFrameworkVersion] intValue] != 672) { NSAlert *alert = [NSAlert alertWithMessageText:@"Toolbar not compatible with simulator" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"The selectable toolbar is not yet compatible with the IB simulator. Quit the simulator and revert to the last saved document. Sorry for the inconvenience."]; [alert runModal]; } } - (void)ibDidAddToDesignableDocument:(IBDocument *)document { [super ibDidAddToDesignableDocument:document]; [self setDocumentToolbar:self]; helper = [[BWSelectableToolbarHelper alloc] init]; [document addObject:helper toParent:[self parentOfObject:self]]; } - (void)addObject:(id)object toParent:(id)parent { IBDocument *document = [IBDocument documentForObject:parent]; [document addObject:object toParent:parent]; } - (void)moveObject:(id)object toParent:(id)parent { IBDocument *document = [IBDocument documentForObject:object]; [document moveObject:object toParent:parent]; } - (void)removeObject:(id)object { IBDocument *document = [IBDocument documentForObject:object]; [document removeObject:object]; } - (NSArray *)objectsforDocumentObject:(id)anObj { IBDocument *document = [IBDocument documentForObject:anObj]; return [[document objects] retain]; } - (id)parentOfObject:(id)anObj { IBDocument *document = [IBDocument documentForObject:anObj]; return [[document parentOfObject:anObj] retain]; } - (NSArray *)childrenOfObject:(id)object { IBDocument *document = [IBDocument documentForObject:object]; return [document childrenOfObject:object]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSelectableToolbarIntegration.m
Objective-C
bsd
3,174
// // BWAddRegularBottomBarIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWAddSmallBottomBar.h" #import "BWAddRegularBottomBar.h" #import "BWAddMiniBottomBar.h" #import "BWAddSheetBottomBar.h" #import "NSWindow+BWAdditions.h" @interface NSWindow (BWBBPrivate) - (void)setBottomCornerRounded:(BOOL)flag; @end @implementation BWAddRegularBottomBar ( BWAddRegularBottomBarIntegration ) - (void)ibDidAddToDesignableDocument:(IBDocument *)document { [super ibDidAddToDesignableDocument:document]; [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; [self performSelector:@selector(removeOtherBottomBarViewsInDocument:) withObject:document afterDelay:0]; } - (void)addBottomBar { if ([[self window] isTextured] == NO) { [[self window] setContentBorderThickness:34 forEdge:NSMinYEdge]; // Private method if ([[self window] respondsToSelector:@selector(setBottomCornerRounded:)]) [[self window] setBottomCornerRounded:YES]; } } - (void)removeOtherBottomBarViewsInDocument:(IBDocument *)document { NSArray *subviews = [[[self window] contentView] subviews]; int i; for (i = 0; i < [subviews count]; i++) { NSView *view = [subviews objectAtIndex:i]; if (view != self && ([view isKindOfClass:[BWAddRegularBottomBar class]] || [view isKindOfClass:[BWAddSmallBottomBar class]] || [view isKindOfClass:[BWAddMiniBottomBar class]] || [view isKindOfClass:[BWAddSheetBottomBar class]])) { [document removeObject:view]; [view removeFromSuperview]; } } } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddRegularBottomBarIntegration.m
Objective-C
bsd
1,670
// // BWAddRegularBottomBar.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAddRegularBottomBar.h" #import "NSWindow-NSTimeMachineSupport.h" @implementation BWAddRegularBottomBar - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super initWithCoder:decoder]) != nil) { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)]) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; } return self; } - (void)awakeFromNib { [[self window] setContentBorderThickness:34 forEdge:NSMinYEdge]; } - (void)drawRect:(NSRect)aRect { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] && [[self window] contentBorderThicknessForEdge:NSMinYEdge] == 0) [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; if ([[self window] isSheet] && [[self window] respondsToSelector:@selector(setMovable:)]) [[self window] setMovable:NO]; } - (NSRect)bounds { return NSMakeRect(-10000,-10000,0,0); } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddRegularBottomBar.m
Objective-C
bsd
1,087
// // BWAddMiniBottomBarIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWAddSmallBottomBar.h" #import "BWAddRegularBottomBar.h" #import "BWAddMiniBottomBar.h" #import "BWAddSheetBottomBar.h" #import "NSWindow+BWAdditions.h" @interface NSWindow (BWBBPrivate) - (void)setBottomCornerRounded:(BOOL)flag; @end @implementation BWAddMiniBottomBar ( BWAddMiniBottomBarIntegration ) - (void)ibDidAddToDesignableDocument:(IBDocument *)document { [super ibDidAddToDesignableDocument:document]; [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; [self performSelector:@selector(removeOtherBottomBarViewsInDocument:) withObject:document afterDelay:0]; } - (void)addBottomBar { if ([[self window] isTextured] == NO) { [[self window] setContentBorderThickness:16 forEdge:NSMinYEdge]; // Private method if ([[self window] respondsToSelector:@selector(setBottomCornerRounded:)]) [[self window] setBottomCornerRounded:NO]; } } - (void)removeOtherBottomBarViewsInDocument:(IBDocument *)document { NSArray *subviews = [[[self window] contentView] subviews]; int i; for (i = 0; i < [subviews count]; i++) { NSView *view = [subviews objectAtIndex:i]; if (view != self && ([view isKindOfClass:[BWAddRegularBottomBar class]] || [view isKindOfClass:[BWAddSmallBottomBar class]] || [view isKindOfClass:[BWAddMiniBottomBar class]] || [view isKindOfClass:[BWAddSheetBottomBar class]])) { [document removeObject:view]; [view removeFromSuperview]; } } } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddMiniBottomBarIntegration.m
Objective-C
bsd
1,660
// // BWTransparentPopUpButtonCell.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWTransparentPopUpButtonCell : NSPopUpButtonCell { NSColor *interiorColor; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWTransparentPopUpButtonCell.h
Objective-C
bsd
286
// // BWAddSmallBottomBar.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWAddSmallBottomBar : NSView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddSmallBottomBar.h
Objective-C
bsd
232
// // BWSplitView.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) and Fraser Kuyvenhoven. // All code is provided under the New BSD license. // #import "BWSplitView.h" #import "NSColor+BWAdditions.h" #import "NSEvent+BWAdditions.h" static NSGradient *gradient; static NSImage *dimpleImageBitmap, *dimpleImageVector; static NSColor *borderColor, *gradientStartColor, *gradientEndColor; static float scaleFactor = 1.0f; #define dimpleDimension 4.0f #define RESIZE_DEBUG_LOGS 0 @interface BWSplitView (BWSVPrivate) - (void)drawDimpleInRect:(NSRect)aRect; - (void)drawGradientDividerInRect:(NSRect)aRect; - (int)resizableSubviews; - (BOOL)subviewIsResizable:(NSView *)subview; - (BOOL)subviewIsCollapsible:(NSView *)subview; - (BOOL)subviewIsCollapsed:(NSView *)subview; - (int)collapsibleSubviewIndex; - (NSView *)collapsibleSubview; - (BOOL)hasCollapsibleSubview; - (BOOL)collapsibleSubviewIsCollapsed; - (CGFloat)subviewMinimumSize:(int)subviewIndex; - (CGFloat)subviewMaximumSize:(int)subviewIndex; - (void)recalculatePreferredProportionsAndSizes; - (BOOL)validatePreferredProportionsAndSizes; - (void)validateAndCalculatePreferredProportionsAndSizes; - (void)clearPreferredProportionsAndSizes; - (void)resizeAndAdjustSubviews; @end @interface BWSplitView () @property BOOL checkboxIsEnabled; @end @implementation BWSplitView @synthesize color, colorIsEnabled, checkboxIsEnabled, minValues, maxValues, minUnits, maxUnits, collapsiblePopupSelection, dividerCanCollapse, collapsibleSubviewCollapsed; @synthesize resizableSubviewPreferredProportion, nonresizableSubviewPreferredSize, stateForLastPreferredCalculations; @synthesize toggleCollapseButton; + (void)initialize; { borderColor = [[NSColor colorWithCalibratedWhite:(165.0f / 255.0f) alpha:1] retain]; gradientStartColor = [[NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1] retain]; gradientEndColor = [[NSColor colorWithCalibratedWhite:(222.0f / 255.0f) alpha:1] retain]; gradient = [[NSGradient alloc] initWithStartingColor:gradientStartColor endingColor:gradientEndColor]; NSBundle *bundle = [NSBundle bundleForClass:[BWSplitView class]]; dimpleImageBitmap = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"GradientSplitViewDimpleBitmap.tif"]]; dimpleImageVector = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"GradientSplitViewDimpleVector.pdf"]]; [dimpleImageBitmap setFlipped:YES]; [dimpleImageVector setFlipped:YES]; } - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super initWithCoder:decoder]) != nil) { [self setColor:[decoder decodeObjectForKey:@"BWSVColor"]]; [self setColorIsEnabled:[decoder decodeBoolForKey:@"BWSVColorIsEnabled"]]; [self setMinValues:[decoder decodeObjectForKey:@"BWSVMinValues"]]; [self setMaxValues:[decoder decodeObjectForKey:@"BWSVMaxValues"]]; [self setMinUnits:[decoder decodeObjectForKey:@"BWSVMinUnits"]]; [self setMaxUnits:[decoder decodeObjectForKey:@"BWSVMaxUnits"]]; [self setCollapsiblePopupSelection:[decoder decodeIntForKey:@"BWSVCollapsiblePopupSelection"]]; [self setDividerCanCollapse:[decoder decodeBoolForKey:@"BWSVDividerCanCollapse"]]; // Delegate set in nib has been decoded, but we want that to be the secondary delegate [self setDelegate:[super delegate]]; [super setDelegate:self]; } return self; } - (void)encodeWithCoder:(NSCoder*)coder { // Temporarily change delegate [super setDelegate:secondaryDelegate]; [super encodeWithCoder:coder]; [coder encodeObject:[self color] forKey:@"BWSVColor"]; [coder encodeBool:[self colorIsEnabled] forKey:@"BWSVColorIsEnabled"]; [coder encodeObject:[self minValues] forKey:@"BWSVMinValues"]; [coder encodeObject:[self maxValues] forKey:@"BWSVMaxValues"]; [coder encodeObject:[self minUnits] forKey:@"BWSVMinUnits"]; [coder encodeObject:[self maxUnits] forKey:@"BWSVMaxUnits"]; [coder encodeInt:[self collapsiblePopupSelection] forKey:@"BWSVCollapsiblePopupSelection"]; [coder encodeBool:[self dividerCanCollapse] forKey:@"BWSVDividerCanCollapse"]; // Set delegate back [self setDelegate:[super delegate]]; [super setDelegate:self]; } - (void)awakeFromNib { scaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor]; } - (void)drawDividerInRect:(NSRect)aRect { if ([self isVertical]) { aRect.size.width = [self dividerThickness]; if (colorIsEnabled && color != nil) [color drawSwatchInRect:aRect]; else [super drawDividerInRect:aRect]; } else { aRect.size.height = [self dividerThickness]; if ([self dividerThickness] <= 1.01) { if (colorIsEnabled && color != nil) [color drawSwatchInRect:aRect]; else [super drawDividerInRect:aRect]; } else { [self drawGradientDividerInRect:aRect]; } } } - (void)drawGradientDividerInRect:(NSRect)aRect { aRect = [self centerScanRect:aRect]; // Draw gradient NSRect gradRect = NSMakeRect(aRect.origin.x,aRect.origin.y + 1 / scaleFactor,aRect.size.width,aRect.size.height - 1 / scaleFactor); [gradient drawInRect:gradRect angle:90]; // Draw top and bottom borders [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:aRect inView:self horizontal:YES flip:NO]; [borderColor drawPixelThickLineAtPosition:0 withInset:0 inRect:aRect inView:self horizontal:YES flip:YES]; [self drawDimpleInRect:aRect]; } - (void)drawDimpleInRect:(NSRect)aRect { float startY = aRect.origin.y + roundf((aRect.size.height / 2) - (dimpleDimension / 2)); float startX = aRect.origin.x + roundf((aRect.size.width / 2) - (dimpleDimension / 2)); NSRect destRect = NSMakeRect(startX,startY,dimpleDimension,dimpleDimension); // Draw at pixel bounds destRect = [self convertRectToBase:destRect]; destRect.origin.x = floor(destRect.origin.x); double param, fractPart, intPart; param = destRect.origin.y; fractPart = modf(param, &intPart); if (fractPart < 0.99) destRect.origin.y = floor(destRect.origin.y); destRect = [self convertRectFromBase:destRect]; if (scaleFactor == 1) { NSRect dimpleRect = NSMakeRect(0,0,dimpleDimension,dimpleDimension); [dimpleImageBitmap drawInRect:destRect fromRect:dimpleRect operation:NSCompositeSourceOver fraction:1]; } else { NSRect dimpleRect = NSMakeRect(0,0,[dimpleImageVector size].width,[dimpleImageVector size].height); [dimpleImageVector drawInRect:destRect fromRect:dimpleRect operation:NSCompositeSourceOver fraction:1]; } } - (CGFloat)dividerThickness { float thickness; if ([self isVertical]) { thickness = 1; } else { if ([super dividerThickness] < 1.01) thickness = 1; else thickness = 10; } return thickness; } - (void)setDelegate:(id)anObj { if (secondaryDelegate != self) secondaryDelegate = anObj; else secondaryDelegate = nil; } - (BOOL)subviewIsCollapsible:(NSView *)subview; { // check if this is the collapsible subview int subviewIndex = [[self subviews] indexOfObject:subview]; BOOL isCollapsibleSubview = (([self collapsiblePopupSelection] == 1 && subviewIndex == 0) || ([self collapsiblePopupSelection] == 2 && subviewIndex == [[self subviews] count] - 1)); return isCollapsibleSubview; } - (BOOL)subviewIsCollapsed:(NSView *)subview; { BOOL isCollapsibleSubview = [self subviewIsCollapsible:subview]; return [super isSubviewCollapsed:subview] || (isCollapsibleSubview && collapsibleSubviewCollapsed); } - (BOOL)collapsibleSubviewIsCollapsed; { return [self subviewIsCollapsed:[self collapsibleSubview]]; } - (int)collapsibleSubviewIndex; { switch ([self collapsiblePopupSelection]) { case 1: return 0; break; case 2: return [[self subviews] count] - 1; break; default: return -1; break; } } - (NSView *)collapsibleSubview; { int index = [self collapsibleSubviewIndex]; if (index >= 0) return [[self subviews] objectAtIndex:index]; else return nil; } - (BOOL)hasCollapsibleSubview; { return [self collapsiblePopupSelection] != 0; } // This is done to support the use of Core Animation to collapse subviews - (void)adjustSubviews { [super adjustSubviews]; [[self window] invalidateCursorRectsForView:self]; } - (void)setCollapsibleSubviewCollapsedHelper:(NSNumber *)flag { [self setCollapsibleSubviewCollapsed:[flag boolValue]]; } - (void)animationEnded { isAnimating = NO; } - (float)animationDuration { if ([NSEvent shiftKeyIsDown]) return 2.0; return 0.25; } - (BOOL)hasCollapsibleDivider { if ([self hasCollapsibleSubview] && (dividerCanCollapse || [self dividerThickness] < 1.01)) return YES; return NO; } - (int)collapsibleDividerIndex { if ([self hasCollapsibleDivider]) { if ([self collapsiblePopupSelection] == 1) return 0; else if ([self collapsiblePopupSelection] == 2) return [self subviews].count - 2; } return -1; } - (void)setCollapsibleSubviewCollapsed:(BOOL)flag { collapsibleSubviewCollapsed = flag; if (flag) [[self toggleCollapseButton] setState:0]; else [[self toggleCollapseButton] setState:1]; } - (void)setMinSizeForCollapsibleSubview:(NSNumber *)minSize { if ([self hasCollapsibleSubview]) { NSMutableDictionary *tempMinValues = [[self minValues] mutableCopy]; [tempMinValues setObject:minSize forKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]]; [self setMinValues:tempMinValues]; } } - (void)removeMinSizeForCollapsibleSubview { if ([self hasCollapsibleSubview]) { NSMutableDictionary *tempMinValues = [[self minValues] mutableCopy]; [tempMinValues removeObjectForKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]]; [self setMinValues:tempMinValues]; } } - (IBAction)toggleCollapse:(id)sender { if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)]) return; if ([self hasCollapsibleSubview] == NO || [self collapsibleSubview] == nil) return; if (isAnimating) return; // Check to see if the collapsible subview has a minimum width/height and record it. // We'll later remove the min size temporarily while animating and then restore it. BOOL hasMinSize = NO; NSNumber *minSize = [minValues objectForKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]]; minSize = [[minSize copy] autorelease]; if (minSize != nil || [minSize intValue] != 0) hasMinSize = YES; // Get a reference to the button and modify its behavior if ([self toggleCollapseButton] == nil) { [self setToggleCollapseButton:sender]; [[toggleCollapseButton cell] setHighlightsBy:NSPushInCellMask]; [[toggleCollapseButton cell] setShowsStateBy:NSContentsCellMask]; } // Temporary: For simplicty, there should only be 1 subview other than the collapsible subview that's resizable for the collapse to happen NSView *resizableSubview = nil; for (NSView *subview in [self subviews]) { if ([self subviewIsResizable:subview] && subview != [self collapsibleSubview]) { resizableSubview = subview; } } if (resizableSubview == nil) return; // Get the thickness of the collapsible divider. If the divider cannot collapse, we set it to 0 so it doesn't affect our calculations. float collapsibleDividerThickness = [self dividerThickness]; if ([self hasCollapsibleDivider] == NO) collapsibleDividerThickness = 0; if ([self isVertical]) { float constantHeight = [self collapsibleSubview].frame.size.height; if ([self collapsibleSubviewCollapsed] == NO) { uncollapsedSize = [self collapsibleSubview].frame.size.width; if (hasMinSize) [self removeMinSizeForCollapsibleSubview]; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:([self animationDuration])]; [[[self collapsibleSubview] animator] setFrameSize:NSMakeSize(0.0, constantHeight)]; [[resizableSubview animator] setFrameSize:NSMakeSize(resizableSubview.frame.size.width + uncollapsedSize + collapsibleDividerThickness, constantHeight)]; [NSAnimationContext endGrouping]; if (hasMinSize) [self performSelector:@selector(setMinSizeForCollapsibleSubview:) withObject:minSize afterDelay:[self animationDuration]]; [self performSelector:@selector(setCollapsibleSubviewCollapsedHelper:) withObject:[NSNumber numberWithBool:YES] afterDelay:[self animationDuration]]; } else { if (hasMinSize) [self removeMinSizeForCollapsibleSubview]; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:([self animationDuration])]; [[[self collapsibleSubview] animator] setFrameSize:NSMakeSize(uncollapsedSize, constantHeight)]; [[resizableSubview animator] setFrameSize:NSMakeSize(resizableSubview.frame.size.width - uncollapsedSize - collapsibleDividerThickness, constantHeight)]; [NSAnimationContext endGrouping]; if (hasMinSize) [self performSelector:@selector(setMinSizeForCollapsibleSubview:) withObject:minSize afterDelay:[self animationDuration]]; [self setCollapsibleSubviewCollapsed:NO]; } } else { float constantWidth = [self collapsibleSubview].frame.size.width; if ([self collapsibleSubviewCollapsed] == NO) { uncollapsedSize = [self collapsibleSubview].frame.size.height; if (hasMinSize) [self removeMinSizeForCollapsibleSubview]; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:([self animationDuration])]; [[[self collapsibleSubview] animator] setFrameSize:NSMakeSize(constantWidth, 0.0)]; [[resizableSubview animator] setFrameSize:NSMakeSize(constantWidth, resizableSubview.frame.size.height + uncollapsedSize + collapsibleDividerThickness)]; [NSAnimationContext endGrouping]; if (hasMinSize) [self performSelector:@selector(setMinSizeForCollapsibleSubview:) withObject:minSize afterDelay:[self animationDuration]]; [self performSelector:@selector(setCollapsibleSubviewCollapsedHelper:) withObject:[NSNumber numberWithBool:YES] afterDelay:[self animationDuration]]; } else { if (hasMinSize) [self removeMinSizeForCollapsibleSubview]; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:([self animationDuration])]; [[[self collapsibleSubview] animator] setFrameSize:NSMakeSize(constantWidth, uncollapsedSize)]; [[resizableSubview animator] setFrameSize:NSMakeSize(constantWidth, resizableSubview.frame.size.height - uncollapsedSize - collapsibleDividerThickness)]; [NSAnimationContext endGrouping]; if (hasMinSize) [self performSelector:@selector(setMinSizeForCollapsibleSubview:) withObject:minSize afterDelay:[self animationDuration]]; [self setCollapsibleSubviewCollapsed:NO]; } } isAnimating = YES; [self performSelector:@selector(animationEnded) withObject:nil afterDelay:[self animationDuration]]; [self performSelector:@selector(resizeAndAdjustSubviews) withObject:nil afterDelay:[self animationDuration]]; } #pragma mark NSSplitView Delegate Methods - (BOOL)splitView:(NSSplitView *)splitView shouldHideDividerAtIndex:(NSInteger)dividerIndex { if ([secondaryDelegate respondsToSelector:@selector(splitView:shouldHideDividerAtIndex:)]) return [secondaryDelegate splitView:splitView shouldHideDividerAtIndex:dividerIndex]; if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] == NO) { if ([self hasCollapsibleDivider] && [self collapsibleDividerIndex] == dividerIndex) { [self setDividerCanCollapse:YES]; return YES; } } return NO; } - (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(NSInteger)dividerIndex { if ([secondaryDelegate respondsToSelector:@selector(splitView:additionalEffectiveRectOfDividerAtIndex:)]) return [secondaryDelegate splitView:splitView additionalEffectiveRectOfDividerAtIndex:dividerIndex]; return NSZeroRect; } - (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview { if ([secondaryDelegate respondsToSelector:@selector(splitView:canCollapseSubview:)]) return [secondaryDelegate splitView:sender canCollapseSubview:subview]; int subviewIndex = [[self subviews] indexOfObject:subview]; if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] == NO) { if ([self collapsiblePopupSelection] == 1 && subviewIndex == 0) return YES; else if ([self collapsiblePopupSelection] == 2 && subviewIndex == [[self subviews] count] - 1) return YES; } return NO; } - (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex { if ([secondaryDelegate respondsToSelector:@selector(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:)]) return [secondaryDelegate splitView:splitView shouldCollapseSubview:subview forDoubleClickOnDividerAtIndex:dividerIndex]; int subviewIndex = [[self subviews] indexOfObject:subview]; if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)] == NO) { if (([self collapsiblePopupSelection] == 1 && subviewIndex == 0 && dividerIndex == 0) || ([self collapsiblePopupSelection] == 2 && subviewIndex == [[self subviews] count] - 1 && dividerIndex == [[splitView subviews] count] - 2)) { [self setCollapsibleSubviewCollapsed:YES]; // Cause the collapse ourselves by calling the resize method [self resizeAndAdjustSubviews]; [self setNeedsDisplay:YES]; // Since we manually did the resize above, we pretend that we don't want to collapse return NO; } } return NO; } - (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset { if ([secondaryDelegate respondsToSelector:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)]) return [secondaryDelegate splitView:sender constrainMaxCoordinate:proposedMax ofSubviewAt:offset]; // Max coordinate depends on max of subview offset, and the min of subview offset + 1 CGFloat newMaxFromThisSubview = proposedMax; CGFloat newMaxFromNextSubview = proposedMax; // Max from this subview CGFloat maxValue = [self subviewMaximumSize:offset]; if (maxValue != FLT_MAX) { NSView *subview = [[self subviews] objectAtIndex:offset]; CGFloat originCoord = [self isVertical] ? [subview frame].origin.x : [subview frame].origin.y; newMaxFromThisSubview = originCoord + maxValue; } // Max from the next subview int nextOffset = offset + 1; if ([[self subviews] count] > nextOffset) { CGFloat minValue = [self subviewMinimumSize:nextOffset]; if (minValue != 0) { NSView *subview = [[self subviews] objectAtIndex:nextOffset]; CGFloat endCoord = [self isVertical] ? [subview frame].origin.x + [subview frame].size.width : [subview frame].origin.y + [subview frame].size.height; newMaxFromNextSubview = endCoord - minValue - [self dividerThickness]; // This could cause trouble when over constrained (TODO) } } CGFloat newMax = fminf(newMaxFromThisSubview, newMaxFromNextSubview); if (newMax < proposedMax) return newMax; return proposedMax; } - (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset { if ([secondaryDelegate respondsToSelector:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)]) return [secondaryDelegate splitView:sender constrainMinCoordinate:proposedMin ofSubviewAt:offset]; // Min coordinate depends on min of subview offset and the max of subview offset + 1 CGFloat newMinFromThisSubview = proposedMin; CGFloat newMaxFromNextSubview = proposedMin; // Min from this subview CGFloat minValue = [self subviewMinimumSize:offset]; if (minValue != 0) { NSView *subview = [[self subviews] objectAtIndex:offset]; CGFloat originCoord = [self isVertical] ? [subview frame].origin.x : [subview frame].origin.y; newMinFromThisSubview = originCoord + minValue; } // Min from the next subview int nextOffset = offset + 1; if ([[self subviews] count] > nextOffset) { CGFloat maxValue = [self subviewMaximumSize:nextOffset]; if (maxValue != FLT_MAX) { NSView *subview = [[self subviews] objectAtIndex:nextOffset]; CGFloat endCoord = [self isVertical] ? [subview frame].origin.x + [subview frame].size.width : [subview frame].origin.y + [subview frame].size.height; newMaxFromNextSubview = endCoord - maxValue - [self dividerThickness]; // This could cause trouble when over constrained (TODO) } } CGFloat newMin = fmaxf(newMinFromThisSubview, newMaxFromNextSubview); if (newMin > proposedMin) return newMin; return proposedMin; } - (CGFloat)splitView:(NSSplitView *)sender constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)offset { [self clearPreferredProportionsAndSizes]; if ([self respondsToSelector:@selector(ibDidAddToDesignableDocument:)]) return proposedPosition; if ([secondaryDelegate respondsToSelector:@selector(splitView:constrainSplitPosition:ofSubviewAt:)]) return [secondaryDelegate splitView:sender constrainSplitPosition:proposedPosition ofSubviewAt:offset]; return proposedPosition; } - (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex { if ([secondaryDelegate respondsToSelector:@selector(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:)]) return [secondaryDelegate splitView:splitView effectiveRect:proposedEffectiveRect forDrawnRect:drawnRect ofDividerAtIndex:dividerIndex]; return proposedEffectiveRect; } - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification { if (collapsibleSubviewCollapsed && ([self isVertical] ? [[self collapsibleSubview] frame].size.width > 0 : [[self collapsibleSubview] frame].size.height > 0)) { [self setCollapsibleSubviewCollapsed:NO]; [self resizeAndAdjustSubviews]; } else if (!collapsibleSubviewCollapsed && ([self isVertical] ? [[self collapsibleSubview] frame].size.width < 0.1 : [[self collapsibleSubview] frame].size.height < 0.1)) { [self setCollapsibleSubviewCollapsed:YES]; [self resizeAndAdjustSubviews]; } else if ([self collapsibleSubviewIsCollapsed]) { [self resizeAndAdjustSubviews]; } [self setNeedsDisplay:YES]; } #pragma mark - Resize Subviews Delegate Method and Helper Methods - (int)resizableSubviews { int resizableSubviews = 0; for (NSView *subview in [self subviews]) { if ([self subviewIsResizable:subview]) resizableSubviews++; } return resizableSubviews; } - (BOOL)subviewIsResizable:(NSView *)subview { if ([self isVertical] && [subview autoresizingMask] & NSViewWidthSizable) return YES; if (![self isVertical] && [subview autoresizingMask] & NSViewHeightSizable) return YES; return NO; } - (CGFloat)subviewMinimumSize:(int)subviewIndex; { NSNumber *minNum = [minValues objectForKey:[NSNumber numberWithInt:subviewIndex]]; if (!minNum) return 0; int units = 0; NSNumber *unitsNum = [minUnits objectForKey:[NSNumber numberWithInt:subviewIndex]]; if (unitsNum) units = [unitsNum intValue]; CGFloat min = [minNum floatValue]; switch (units) { case 1: { // Percent CGFloat dividerThicknessTotal = [self dividerThickness] * ([[self subviews] count] - 1); CGFloat totalSize = [self isVertical] ? [self frame].size.width : [self frame].size.height; totalSize -= dividerThicknessTotal; return roundf((min / 100.0) * totalSize); break; } case 0: default: { // Points return min; break; } } } - (CGFloat)subviewMaximumSize:(int)subviewIndex; { NSNumber *maxNum = [maxValues objectForKey:[NSNumber numberWithInt:subviewIndex]]; if (!maxNum) return FLT_MAX; int units = 0; NSNumber *unitsNum = [maxUnits objectForKey:[NSNumber numberWithInt:subviewIndex]]; if (unitsNum) units = [unitsNum intValue]; CGFloat max = [maxNum floatValue]; switch (units) { case 1: { // Percent CGFloat dividerThicknessTotal = [self dividerThickness] * ([[self subviews] count] - 1); CGFloat totalSize = [self isVertical] ? [self frame].size.width : [self frame].size.height; totalSize -= dividerThicknessTotal; return roundf((max / 100.0) * totalSize); break; } case 0: default: { // Points return max; break; } } } // PREFERRED PROPORTIONS AND SIZES // // Preferred proportions (for resizable) // Need to store resizable subviews preferred proportions for calculating new sizes // // Preferred sizes (for non-resizable) // If a non-resizable subview is ever forced larger or smaller than it prefers, we need to know it's preferred size // // Need to recalculate both of the above whenever a divider is moved, or a subview is added/removed or changed between resizable/non-resizable - (void)recalculatePreferredProportionsAndSizes; { NSMutableArray *stateArray = [NSMutableArray arrayWithCapacity:[[self subviews] count]]; NSMutableDictionary *preferredProportions = [NSMutableDictionary dictionary]; NSMutableDictionary *preferredSizes = [NSMutableDictionary dictionary]; // Total is only the sum of resizable subviews CGFloat resizableTotal = 0; // Calculate resizable total for (NSView *subview in [self subviews]) { if ([self subviewIsResizable:subview]) resizableTotal += [self isVertical] ? [subview frame].size.width : [subview frame].size.height; } // Calculate resizable preferred propotions and set non-resizable preferred sizes for (NSView *subview in [self subviews]) { int index = [[self subviews] indexOfObject:subview]; if ([self subviewIsResizable:subview]) { CGFloat size = [self isVertical] ? [subview frame].size.width : [subview frame].size.height; CGFloat proportion = (resizableTotal > 0) ? (size / resizableTotal) : 0; [preferredProportions setObject:[NSNumber numberWithFloat:proportion] forKey:[NSNumber numberWithInt:index]]; [stateArray addObject:[NSNumber numberWithBool:YES]]; } else { CGFloat size = [self isVertical] ? [subview frame].size.width : [subview frame].size.height; [preferredSizes setObject:[NSNumber numberWithFloat:size] forKey:[NSNumber numberWithInt:index]]; [stateArray addObject:[NSNumber numberWithBool:NO]]; } } [self setResizableSubviewPreferredProportion:preferredProportions]; [self setNonresizableSubviewPreferredSize:preferredSizes]; if (RESIZE_DEBUG_LOGS) NSLog(@"resizableSubviewPreferredProportion: %@", resizableSubviewPreferredProportion); if (RESIZE_DEBUG_LOGS) NSLog(@"nonresizableSubviewPreferredSize: %@", nonresizableSubviewPreferredSize); // Remember state to know when to recalculate [self setStateForLastPreferredCalculations:stateArray]; if (RESIZE_DEBUG_LOGS) NSLog(@"stateForLastPreferredCalculations: %@", stateForLastPreferredCalculations); } // Checks if the number or type of subviews has changed since we last recalculated - (BOOL)validatePreferredProportionsAndSizes; { if (RESIZE_DEBUG_LOGS) NSLog(@"validating preferred proportions and sizes"); // Check if we even have saved proportions and sizes if (![self resizableSubviewPreferredProportion] || ![self nonresizableSubviewPreferredSize]) return NO; // Check if number of items has changed if ([[self subviews] count] != [[self stateForLastPreferredCalculations] count]) return NO; // Check if any of the subviews have changed between resizable and non-resizable for (NSView *subview in [self subviews]) { int index = [[self subviews] indexOfObject:subview]; if ([self subviewIsResizable:subview] != [[[self stateForLastPreferredCalculations] objectAtIndex:index] boolValue]) return NO; } return YES; } - (void)correctCollapsiblePreferredProportionOrSize; { // TODO: Assuming that the collapsible subview does not change between resizable and non-resizable while collapsed if (![self hasCollapsibleSubview]) return; NSMutableDictionary *preferredProportions = [[self resizableSubviewPreferredProportion] mutableCopy]; NSMutableDictionary *preferredSizes = [[self nonresizableSubviewPreferredSize] mutableCopy]; NSNumber *key = [NSNumber numberWithInt:[self collapsibleSubviewIndex]]; NSView *subview = [self collapsibleSubview]; // If the collapsible subview is collapsed, we put aside its preferred propotion/size if ([self subviewIsCollapsed:subview]) { BOOL resizable = [self subviewIsResizable:subview]; if (!resizable) { NSNumber *sizeNum = [preferredSizes objectForKey:key]; if (sizeNum) { if (RESIZE_DEBUG_LOGS) NSLog(@"removing collapsible view from preferred sizes"); // TODO: Save the size for later // Remove from preferred sizes [preferredSizes removeObjectForKey:key]; } } else { NSNumber *proportionNum = [preferredProportions objectForKey:key]; if (proportionNum) { if (RESIZE_DEBUG_LOGS) NSLog(@"removing collapsible view from preferred proportions"); CGFloat proportion = [proportionNum floatValue]; // TODO: Save the proportion for later // Remove from preferred proportions [preferredProportions removeObjectForKey:key]; // Recalculate other proportions CGFloat proportionTotal = 1.0 - proportion; if (proportionTotal > 0) { for (NSNumber *pkey in [preferredProportions allKeys]) { CGFloat oldProportion = [[preferredProportions objectForKey:pkey] floatValue]; CGFloat newPropotion = oldProportion / proportionTotal; [preferredProportions setObject:[NSNumber numberWithFloat:newPropotion] forKey:pkey]; } } } } [self setResizableSubviewPreferredProportion:preferredProportions]; [self setNonresizableSubviewPreferredSize:preferredSizes]; } else // Otherwise, we reintegrate its preferred proportion/size { [self clearPreferredProportionsAndSizes]; [self recalculatePreferredProportionsAndSizes]; } } - (void)validateAndCalculatePreferredProportionsAndSizes; { if (![self validatePreferredProportionsAndSizes]) [self recalculatePreferredProportionsAndSizes]; // Need to make sure the collapsed subviews preferred size/proportion is in the right place [self correctCollapsiblePreferredProportionOrSize]; } - (void)clearPreferredProportionsAndSizes; { if (RESIZE_DEBUG_LOGS) NSLog(@"clearing preferred proportions and sizes"); [self setResizableSubviewPreferredProportion:nil]; [self setNonresizableSubviewPreferredSize:nil]; } // RESIZING ALGORITHM // non-resizable subviews are given preferred size // overall remaining size is calculated // resizable subviews are calculated based on remaining size and preferred proportions // resizable subviews are checked for min/max constraint violations // if violating constraint, set to valid size and remove from resizable subviews // recalculate other resizable subviews and repeat // if all resizable subviews reached constraints without meeting target size, need to resize non-resizable views // non-resizable subviews are adjusted proportionally to meet target size // non-resizable subviews are checked for min/max constraint violations // if violating constraint, set to valid size and remove from non-resizable subviews // recalculate other non-resizable subviews and repeat // if all subviews reached constraints without meeting target size, need to adjust all views to fit // proportionally resize all subviews to fit in target size, ignoring min/max constraints - (void)resizeAndAdjustSubviews; { // Temporary: for now, we will just remember the proportions the first time subviews are resized // we should be remember them in the user defaults so they save across quits (TODO) [self validateAndCalculatePreferredProportionsAndSizes]; if (RESIZE_DEBUG_LOGS) NSLog(@"resizeSubviews begins -----------------------------------------------------"); NSMutableDictionary *newSubviewSizes = [NSMutableDictionary dictionaryWithCapacity:[[self subviews] count]]; // Get new total size CGFloat totalAvailableSize = [self isVertical] ? [self frame].size.width : [self frame].size.height; if (RESIZE_DEBUG_LOGS) NSLog(@"totalAvailableSize: %f", totalAvailableSize); // Calculate non-resizable subviews total CGFloat nonresizableSubviewsTotalPreferredSize = 0; for (NSNumber *size in [nonresizableSubviewPreferredSize allValues]) nonresizableSubviewsTotalPreferredSize += [size floatValue]; if (RESIZE_DEBUG_LOGS) NSLog(@"nonresizableSubviewsTotalPreferredSize: %f", nonresizableSubviewsTotalPreferredSize); // Calculate divider thickness total int dividerCount = [[self subviews] count] - 1; if ([self collapsibleSubviewIsCollapsed] && dividerCanCollapse) dividerCount--; CGFloat dividerThicknessTotal = [self dividerThickness] * dividerCount; if (RESIZE_DEBUG_LOGS) NSLog(@"dividerThicknessTotal: %f", dividerThicknessTotal); // Calculate overall remaining size (could be negative) CGFloat resizableSubviewsTotalAvailableSize = totalAvailableSize - nonresizableSubviewsTotalPreferredSize - dividerThicknessTotal; if (RESIZE_DEBUG_LOGS) NSLog(@"resizableSubviewsTotalAvailableSize: %f", resizableSubviewsTotalAvailableSize); // Special case for the collapsible subview if ([self collapsibleSubviewIsCollapsed]) { [newSubviewSizes setObject:[NSNumber numberWithFloat:0.0] forKey:[NSNumber numberWithInt:[self collapsibleSubviewIndex]]]; } // Set non-resizable subviews to preferred size [newSubviewSizes addEntriesFromDictionary:nonresizableSubviewPreferredSize]; // Set sizes of resizable views based on proportions (could be negative) CGFloat resizableSubviewAvailableSizeUsed = 0; int resizableSubviewCounter = 0; int resizableSubviewCount = [resizableSubviewPreferredProportion count]; for (NSNumber *key in [resizableSubviewPreferredProportion allKeys]) { resizableSubviewCounter++; CGFloat proportion = [[resizableSubviewPreferredProportion objectForKey:key] floatValue]; CGFloat size = roundf(proportion * resizableSubviewsTotalAvailableSize); resizableSubviewAvailableSizeUsed += size; if (resizableSubviewCounter == resizableSubviewCount) { // Make adjustment if necessary size += (resizableSubviewsTotalAvailableSize - resizableSubviewAvailableSizeUsed); } [newSubviewSizes setObject:[NSNumber numberWithFloat:size] forKey:key]; } if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after resizable proportional resizing: %@", newSubviewSizes); // TODO: Could add a special case for resizableSubviewsTotalAvailableSize <= 0 : just set all resizable subviews to minimum size // Make array of all the resizable subviews indexes NSMutableArray *resizableSubviewIndexes = [[resizableSubviewPreferredProportion allKeys] mutableCopy]; [resizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES] autorelease]]]; // Loop until none of the resizable subviews' constraints are violated CGFloat proportionTotal = 1; CGFloat resizableSubviewsRemainingAvailableSize = resizableSubviewsTotalAvailableSize; int i; for (i = 0; i < [resizableSubviewIndexes count]; i++) { NSNumber *key = [resizableSubviewIndexes objectAtIndex:i]; CGFloat size = [[newSubviewSizes objectForKey:key] floatValue]; CGFloat minSize = [self subviewMinimumSize:[key intValue]]; CGFloat maxSize = [self subviewMaximumSize:[key intValue]]; BOOL overMax = size > maxSize; BOOL underMin = size < minSize; // Check if current item in array violates constraints if (underMin || overMax) { CGFloat constrainedSize = underMin ? minSize : maxSize; if (RESIZE_DEBUG_LOGS) NSLog(@"resizable subview %@ was %@, set to %f", key, (underMin ? @"under min" : @"over max"), constrainedSize); // Give subview constrained size and remove from array [newSubviewSizes setObject:[NSNumber numberWithFloat:constrainedSize] forKey:key]; [resizableSubviewIndexes removeObject:key]; // Adjust total proportion and remaining available size proportionTotal -= [[resizableSubviewPreferredProportion objectForKey:key] floatValue]; resizableSubviewsRemainingAvailableSize -= underMin ? minSize : maxSize; // Recalculate remaining subview sizes CGFloat resizableSubviewRemainingSizeUsed = 0; int j; for (j = 0; j < [resizableSubviewIndexes count]; j++) { NSNumber *jKey = [resizableSubviewIndexes objectAtIndex:j]; CGFloat proportion = 0; if (proportionTotal > 0) proportion = [[resizableSubviewPreferredProportion objectForKey:jKey] floatValue] / proportionTotal; else proportion = 1.0 / [resizableSubviewIndexes count]; CGFloat size = roundf(proportion * resizableSubviewsRemainingAvailableSize); resizableSubviewRemainingSizeUsed += size; if (j == [resizableSubviewIndexes count] - 1) { // Make adjustment if necessary size += (resizableSubviewsRemainingAvailableSize - resizableSubviewRemainingSizeUsed); } [newSubviewSizes setObject:[NSNumber numberWithFloat:size] forKey:jKey]; // Reset outer loop to start from beginning i = -1; } } } if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after resizable constraint fulfilling: %@", newSubviewSizes); if ([resizableSubviewIndexes count] == 0 && resizableSubviewsRemainingAvailableSize != 0) { if (RESIZE_DEBUG_LOGS) NSLog(@"entering nonresizable adjustment stage"); // All resizable subviews have reached constraints without reaching the target size // First try to adjust non-resizable subviews, with resizableSubviewsRemainingAvailableSize being the amount of adjustment needed // Make array of non-resizable preferred proportions (normally go by preferred sizes) NSMutableDictionary *nonresizableSubviewPreferredProportion = [NSMutableDictionary dictionary]; for (NSNumber *key in [nonresizableSubviewPreferredSize allKeys]) { CGFloat proportion = [[nonresizableSubviewPreferredSize objectForKey:key] floatValue] / nonresizableSubviewsTotalPreferredSize; [nonresizableSubviewPreferredProportion setObject:[NSNumber numberWithFloat:proportion] forKey:key]; } // ResizableSubviewsRemainingAvailableSize is the amount of adjustment needed CGFloat nonresizableSubviewsRemainingAvailableSize = nonresizableSubviewsTotalPreferredSize + resizableSubviewsRemainingAvailableSize; // Set sizes of nonresizable views based on proportions (could be negative) CGFloat nonresizableSubviewAvailableSizeUsed = 0; int nonresizableSubviewCounter = 0; int nonresizableSubviewCount = [nonresizableSubviewPreferredProportion count]; for (NSNumber *key in [nonresizableSubviewPreferredProportion allKeys]) { nonresizableSubviewCounter++; CGFloat proportion = [[nonresizableSubviewPreferredProportion objectForKey:key] floatValue]; CGFloat size = roundf(proportion * nonresizableSubviewsRemainingAvailableSize); nonresizableSubviewAvailableSizeUsed += size; if (nonresizableSubviewCounter == nonresizableSubviewCount) { // Make adjustment if necessary size += (nonresizableSubviewsRemainingAvailableSize - nonresizableSubviewAvailableSizeUsed); } [newSubviewSizes setObject:[NSNumber numberWithFloat:size] forKey:key]; } if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after nonresizable proportional resizing: %@", newSubviewSizes); // Make array of all the non-resizable subviews indexes NSMutableArray *nonresizableSubviewIndexes = [[nonresizableSubviewPreferredSize allKeys] mutableCopy]; [nonresizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES] autorelease]]]; // Loop until none of the non-resizable subviews' constraints are violated CGFloat proportionTotal = 1; int i; for (i = 0; i < [nonresizableSubviewIndexes count]; i++) { NSNumber *key = [nonresizableSubviewIndexes objectAtIndex:i]; CGFloat size = [[newSubviewSizes objectForKey:key] floatValue]; CGFloat minSize = [self subviewMinimumSize:[key intValue]]; CGFloat maxSize = [self subviewMaximumSize:[key intValue]]; BOOL overMax = size > maxSize; BOOL underMin = size < minSize; // Check if current item in array violates constraints if (underMin || overMax) { CGFloat constrainedSize = underMin ? minSize : maxSize; if (RESIZE_DEBUG_LOGS) NSLog(@"nonresizable subview %@ was %@, set to %f", key, (underMin ? @"under min" : @"over max"), constrainedSize); // Give subview constrained size and remove from array [newSubviewSizes setObject:[NSNumber numberWithFloat:constrainedSize] forKey:key]; [nonresizableSubviewIndexes removeObject:key]; // Adjust total proportion and remaining available size proportionTotal -= [[nonresizableSubviewPreferredProportion objectForKey:key] floatValue]; nonresizableSubviewsRemainingAvailableSize -= underMin ? minSize : maxSize; // Recalculate remaining subview sizes CGFloat nonresizableSubviewRemainingSizeUsed = 0; int j; for (j = 0; j < [nonresizableSubviewIndexes count]; j++) { NSNumber *jKey = [nonresizableSubviewIndexes objectAtIndex:j]; CGFloat proportion = 0; if (proportionTotal > 0) proportion = [[nonresizableSubviewPreferredProportion objectForKey:jKey] floatValue] / proportionTotal; else proportion = 1.0 / [nonresizableSubviewIndexes count]; CGFloat size = roundf(proportion * nonresizableSubviewsRemainingAvailableSize); nonresizableSubviewRemainingSizeUsed += size; if (j == [nonresizableSubviewIndexes count] - 1) { // Make adjustment if necessary size += (nonresizableSubviewsRemainingAvailableSize - nonresizableSubviewRemainingSizeUsed); } [newSubviewSizes setObject:[NSNumber numberWithFloat:size] forKey:jKey]; // Reset outer loop to start from beginning i = -1; } } } if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after nonresizable constraint fulfilling: %@", newSubviewSizes); // If there is still overall violation, resize everything proportionally to make up the difference if ([resizableSubviewIndexes count] == 0 && nonresizableSubviewsRemainingAvailableSize != 0) { if (RESIZE_DEBUG_LOGS) NSLog(@"entering all subviews forced adjustment stage"); // Calculate current proportions and use to calculate new size CGFloat allSubviewTotalCurrentSize = 0; for (NSNumber *size in [newSubviewSizes allValues]) allSubviewTotalCurrentSize += [size floatValue]; CGFloat allSubviewRemainingSizeUsed = 0; CGFloat allSubviewTotalSize = totalAvailableSize - dividerThicknessTotal; // TODO: What to do if even the dividers don't fit? int k; for (k = 0; k < [newSubviewSizes count]; k++) { NSNumber *key = [NSNumber numberWithInt:k]; CGFloat currentSize = [[newSubviewSizes objectForKey:key] floatValue]; CGFloat proportion = currentSize / allSubviewTotalCurrentSize; CGFloat size = roundf(proportion * allSubviewTotalSize); allSubviewRemainingSizeUsed += size; if (k == [newSubviewSizes count] - 1) { // Make adjustment if necessary size += allSubviewTotalSize - allSubviewRemainingSizeUsed; } [newSubviewSizes setObject:[NSNumber numberWithFloat:size] forKey:key]; } if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after all subviews forced adjustment: %@", newSubviewSizes); } // Otherwise there is still flexibiliy in the non-resizable views, so we are done } // Otherwise there is still flexibility in the resizable views, so we are done // Set subview frames CGFloat position = 0; for (i = 0; i < [[self subviews] count]; i++) { NSView *subview = [[self subviews] objectAtIndex:i]; CGFloat size = [[newSubviewSizes objectForKey:[NSNumber numberWithInt:i]] floatValue]; NSRect subviewFrame = NSZeroRect; if ([self isVertical]) { subviewFrame.size.height = [self frame].size.height; subviewFrame.size.width = size; subviewFrame.origin.y = [subview frame].origin.y; subviewFrame.origin.x = position; } else { subviewFrame.size.height = size; subviewFrame.size.width = [self frame].size.width; subviewFrame.origin.y = position; subviewFrame.origin.x = [subview frame].origin.x; } [subview setFrame:subviewFrame]; position += size; if (dividerCanCollapse && [self subviewIsCollapsed:subview]) { // Do nothing } else { position += [self dividerThickness]; } } } - (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize { if ([secondaryDelegate isKindOfClass:NSClassFromString(@"BWAnchoredButtonBar")]) { [self resizeAndAdjustSubviews]; } else if ([secondaryDelegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)]) { [secondaryDelegate splitView:sender resizeSubviewsWithOldSize:oldSize]; } else if (sender == self) { [self resizeAndAdjustSubviews]; } else { [sender adjustSubviews]; } } #pragma mark Force Vertical Splitters to Thin Appearance // This class doesn't have an appearance for wide vertical splitters, so we force all vertical splitters to thin. // We also post notifications that are used by the inspector to show & hide controls. - (void)setDividerStyle:(NSSplitViewDividerStyle)aStyle { BOOL styleChanged = NO; if (aStyle != [self dividerStyle]) styleChanged = YES; if ([self isVertical]) [super setDividerStyle:NSSplitViewDividerStyleThin]; else [super setDividerStyle:aStyle]; // There can be sizing issues during design-time if we don't call this [self adjustSubviews]; if (styleChanged) [[NSNotificationCenter defaultCenter] postNotificationName:@"BWSplitViewDividerThicknessChanged" object:self]; } - (void)setVertical:(BOOL)flag { BOOL orientationChanged = NO; if (flag != [self isVertical]) orientationChanged = YES; if (flag) [super setDividerStyle:NSSplitViewDividerStyleThin]; [super setVertical:flag]; if (orientationChanged) [[NSNotificationCenter defaultCenter] postNotificationName:@"BWSplitViewOrientationChanged" object:self]; } #pragma mark IB Inspector Support Methods - (BOOL)checkboxIsEnabled { if (![self isVertical] && [super dividerThickness] > 1.01) return NO; return YES; } - (void)setColorIsEnabled:(BOOL)flag { colorIsEnabled = flag; [self setNeedsDisplay:YES]; } - (void)setColor:(NSColor *)aColor { if (color != aColor) { [color release]; color = [aColor copy]; } [self setNeedsDisplay:YES]; } - (NSColor *)color { if (color == nil) color = [[NSColor blackColor] retain]; return [[color retain] autorelease]; } - (NSMutableDictionary *)minValues { if (minValues == nil) minValues = [NSMutableDictionary new]; return [[minValues retain] autorelease]; } - (NSMutableDictionary *)maxValues { if (maxValues == nil) maxValues = [NSMutableDictionary new]; return [[maxValues retain] autorelease]; } - (NSMutableDictionary *)minUnits { if (minUnits == nil) minUnits = [NSMutableDictionary new]; return [[minUnits retain] autorelease]; } - (NSMutableDictionary *)maxUnits { if (maxUnits == nil) maxUnits = [NSMutableDictionary new]; return [[maxUnits retain] autorelease]; } - (void)dealloc { [color release]; [minValues release]; [maxValues release]; [minUnits release]; [maxUnits release]; [resizableSubviewPreferredProportion release]; [nonresizableSubviewPreferredSize release]; [toggleCollapseButton release]; [stateForLastPreferredCalculations release]; [super dealloc]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSplitView.m
Objective-C
bsd
47,612
// // BWAddSmallBottomBarIntegration.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> #import "BWAddSmallBottomBar.h" #import "BWAddRegularBottomBar.h" #import "BWAddMiniBottomBar.h" #import "BWAddSheetBottomBar.h" #import "NSWindow+BWAdditions.h" @interface NSWindow (BWBBPrivate) - (void)setBottomCornerRounded:(BOOL)flag; @end @implementation BWAddSmallBottomBar ( BWAddSmallBottomBarIntegration ) - (void)ibDidAddToDesignableDocument:(IBDocument *)document { [super ibDidAddToDesignableDocument:document]; [self performSelector:@selector(addBottomBar) withObject:nil afterDelay:0]; [self performSelector:@selector(removeOtherBottomBarViewsInDocument:) withObject:document afterDelay:0]; } - (void)addBottomBar { if ([[self window] isTextured] == NO) { [[self window] setContentBorderThickness:24 forEdge:NSMinYEdge]; // Private method if ([[self window] respondsToSelector:@selector(setBottomCornerRounded:)]) [[self window] setBottomCornerRounded:YES]; } } - (void)removeOtherBottomBarViewsInDocument:(IBDocument *)document { NSArray *subviews = [[[self window] contentView] subviews]; int i; for (i = 0; i < [subviews count]; i++) { NSView *view = [subviews objectAtIndex:i]; if (view != self && ([view isKindOfClass:[BWAddRegularBottomBar class]] || [view isKindOfClass:[BWAddSmallBottomBar class]] || [view isKindOfClass:[BWAddMiniBottomBar class]] || [view isKindOfClass:[BWAddSheetBottomBar class]])) { [document removeObject:view]; [view removeFromSuperview]; } } } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddSmallBottomBarIntegration.m
Objective-C
bsd
1,664
// // NSString+BWAdditions.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface NSString (BWAdditions) + (NSString *)randomUUID; @end
08iteng-ipad
TestMerge/bwtoolkit/NSString+BWAdditions.h
Objective-C
bsd
249
// // BWSelectableToolbarInspector.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> @interface BWSelectableToolbarInspector : IBInspector { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSelectableToolbarInspector.h
Objective-C
bsd
282
// // BWAnchoredButtonBar.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWAnchoredButtonBar.h" #import "NSColor+BWAdditions.h" #import "NSView+BWAdditions.h" #import "BWAnchoredButton.h" static NSColor *topLineColor, *bottomLineColor; static NSColor *topColor, *middleTopColor, *middleBottomColor, *bottomColor; static NSColor *sideInsetColor, *borderedTopLineColor; static NSColor *resizeHandleColor, *resizeInsetColor; static NSGradient *gradient; static BOOL wasBorderedBar; static float scaleFactor = 0.0f; @interface BWAnchoredButtonBar (BWABBPrivate) - (void)drawResizeHandleInRect:(NSRect)handleRect withColor:(NSColor *)color; - (void)drawLastButtonInsetInRect:(NSRect)rect; @end @implementation BWAnchoredButtonBar @synthesize selectedIndex, isAtBottom, isResizable, splitViewDelegate; + (void)initialize; { topLineColor = [[NSColor colorWithCalibratedWhite:(202.0f / 255.0f) alpha:1] retain]; bottomLineColor = [[NSColor colorWithCalibratedWhite:(170.0f / 255.0f) alpha:1] retain]; topColor = [[NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1] retain]; middleTopColor = [[NSColor colorWithCalibratedWhite:(242.0f / 255.0f) alpha:1] retain]; middleBottomColor = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain]; bottomColor = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain]; sideInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.5] retain]; borderedTopLineColor = [[NSColor colorWithCalibratedWhite:(190.0f / 255.0f) alpha:1] retain]; gradient = [[NSGradient alloc] initWithColorsAndLocations: topColor, (CGFloat)0.0, middleTopColor, (CGFloat)0.45454, middleBottomColor, (CGFloat)0.45454, bottomColor, (CGFloat)1.0, nil]; resizeHandleColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.598] retain]; resizeInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.55] retain]; } - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { scaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor]; [self setIsResizable:YES]; [self setIsAtBottom:YES]; } return self; } - (id)initWithCoder:(NSCoder *)decoder; { if ((self = [super initWithCoder:decoder]) != nil) { [self setIsResizable:[decoder decodeBoolForKey:@"BWABBIsResizable"]]; [self setIsAtBottom:[decoder decodeBoolForKey:@"BWABBIsAtBottom"]]; [self setSelectedIndex:[decoder decodeIntForKey:@"BWABBSelectedIndex"]]; } return self; } - (void)encodeWithCoder:(NSCoder*)coder { [super encodeWithCoder:coder]; [coder encodeBool:[self isResizable] forKey:@"BWABBIsResizable"]; [coder encodeBool:[self isAtBottom] forKey:@"BWABBIsAtBottom"]; [coder encodeInt:[self selectedIndex] forKey:@"BWABBSelectedIndex"]; } - (void)awakeFromNib { scaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor]; // Iterate through superviews, see if we're in a split view, and set its delegate NSSplitView *splitView = nil; id currentView = self; while (![currentView isKindOfClass:[NSSplitView class]] && currentView != nil) { currentView = [currentView superview]; if ([currentView isKindOfClass:[NSSplitView class]]) splitView = currentView; } if (splitView != nil && [splitView isVertical] && [self isResizable]) [splitView setDelegate:self]; [self bringToFront]; } - (void)drawRect:(NSRect)rect { rect = self.bounds; // Draw gradient NSRect gradientRect; if (isAtBottom) gradientRect = NSMakeRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height - 1); else gradientRect = NSInsetRect(rect, 0, 1); [gradient drawInRect:gradientRect angle:270]; // Draw top line if (isAtBottom) [topLineColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; else [borderedTopLineColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:YES]; // Draw resize handle if (isResizable) { NSRect handleRect = NSMakeRect(NSMaxX(rect)-11,6,6,10); [self drawResizeHandleInRect:handleRect withColor:resizeHandleColor]; NSRect insetRect = NSOffsetRect(handleRect,1,-1); [self drawResizeHandleInRect:insetRect withColor:resizeInsetColor]; } [self drawLastButtonInsetInRect:rect]; // Draw bottom line and sides if it's in non-bottom mode if (!isAtBottom) { [bottomLineColor drawPixelThickLineAtPosition:0 withInset:0 inRect:rect inView:self horizontal:YES flip:NO]; [bottomLineColor drawPixelThickLineAtPosition:0 withInset:1 inRect:rect inView:self horizontal:NO flip:NO]; [bottomLineColor drawPixelThickLineAtPosition:0 withInset:1 inRect:rect inView:self horizontal:NO flip:YES]; } } - (void)drawResizeHandleInRect:(NSRect)handleRect withColor:(NSColor *)color { [color drawPixelThickLineAtPosition:0 withInset:0 inRect:handleRect inView:self horizontal:NO flip:NO]; [color drawPixelThickLineAtPosition:3 withInset:0 inRect:handleRect inView:self horizontal:NO flip:NO]; [color drawPixelThickLineAtPosition:6 withInset:0 inRect:handleRect inView:self horizontal:NO flip:NO]; } - (void)drawLastButtonInsetInRect:(NSRect)rect { NSView *rightMostView = nil; if ([[self subviews] count] > 0) { rightMostView = [[self subviews] objectAtIndex:0]; NSView *currentSubview = nil; for (currentSubview in [self subviews]) { if ([[currentSubview className] isEqualToString:@"BWAnchoredButton"] || [[currentSubview className] isEqualToString:@"BWAnchoredPopUpButton"]) { if (NSMaxX([currentSubview frame]) > NSMaxX([rightMostView frame])) rightMostView = currentSubview; if ([currentSubview frame].origin.x == 0) [(BWAnchoredButton *)currentSubview setIsAtLeftEdgeOfBar:YES]; else [(BWAnchoredButton *)currentSubview setIsAtLeftEdgeOfBar:NO]; if (NSMaxX([currentSubview frame]) == NSMaxX([self bounds])) [(BWAnchoredButton *)currentSubview setIsAtRightEdgeOfBar:YES]; else [(BWAnchoredButton *)currentSubview setIsAtRightEdgeOfBar:NO]; } } } if (rightMostView != nil && ([[rightMostView className] isEqualToString:@"BWAnchoredButton"] || [[rightMostView className] isEqualToString:@"BWAnchoredPopUpButton"])) { NSRect newRect = NSOffsetRect(rect,0,-1); [sideInsetColor drawPixelThickLineAtPosition:NSMaxX([rightMostView frame]) withInset:0 inRect:newRect inView:self horizontal:NO flip:NO]; } } - (void)setIsAtBottom:(BOOL)flag { isAtBottom = flag; if (flag) { [self setFrameSize:NSMakeSize(self.frame.size.width,23)]; wasBorderedBar = NO; } else { [self setFrameSize:NSMakeSize(self.frame.size.width,24)]; wasBorderedBar = YES; } [self setNeedsDisplay:YES]; } - (void)setSelectedIndex:(int)anIndex { if (anIndex == 0) { [self setIsAtBottom:YES]; [self setIsResizable:YES]; } else if (anIndex == 1) { [self setIsAtBottom:YES]; [self setIsResizable:NO]; } else if (anIndex == 2) { [self setIsAtBottom:NO]; [self setIsResizable:NO]; } selectedIndex = anIndex; [self setNeedsDisplay:YES]; } + (BOOL)wasBorderedBar { return wasBorderedBar; } #pragma mark NSSplitView Delegate Methods // Add the resize handle rect to the split view hot zone - (NSRect)splitView:(NSSplitView *)aSplitView additionalEffectiveRectOfDividerAtIndex:(NSInteger)dividerIndex { if ([splitViewDelegate respondsToSelector:@selector(splitView:additionalEffectiveRectOfDividerAtIndex:)]) return [splitViewDelegate splitView:aSplitView additionalEffectiveRectOfDividerAtIndex:dividerIndex]; NSRect paddedHandleRect; paddedHandleRect.origin.y = [aSplitView frame].size.height - [self frame].origin.y - [self bounds].size.height; paddedHandleRect.origin.x = NSMaxX([self bounds]) - 15; paddedHandleRect.size.width = 15; paddedHandleRect.size.height = [self bounds].size.height; return paddedHandleRect; } // Remaining delegate methods. They test for an implementation by the splitViewDelegate (otherwise perform default behavior) - (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset { if ([splitViewDelegate respondsToSelector:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)]) return [splitViewDelegate splitView:sender constrainMinCoordinate:proposedMin ofSubviewAt:offset]; return proposedMin; } - (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset { if ([splitViewDelegate respondsToSelector:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)]) return [splitViewDelegate splitView:sender constrainMaxCoordinate:proposedMax ofSubviewAt:offset]; return proposedMax; } - (void)splitView:(NSSplitView*)sender resizeSubviewsWithOldSize:(NSSize)oldSize { if ([splitViewDelegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)]) return [splitViewDelegate splitView:sender resizeSubviewsWithOldSize:oldSize]; [sender adjustSubviews]; } - (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview { if ([splitViewDelegate respondsToSelector:@selector(splitView:canCollapseSubview:)]) return [splitViewDelegate splitView:sender canCollapseSubview:subview]; return NO; } - (CGFloat)splitView:(NSSplitView *)sender constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)offset { if ([splitViewDelegate respondsToSelector:@selector(splitView:constrainSplitPosition:ofSubviewAt:)]) return [splitViewDelegate splitView:sender constrainSplitPosition:proposedPosition ofSubviewAt:offset]; return proposedPosition; } - (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex { if ([splitViewDelegate respondsToSelector:@selector(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:)]) return [splitViewDelegate splitView:splitView effectiveRect:proposedEffectiveRect forDrawnRect:drawnRect ofDividerAtIndex:dividerIndex]; return proposedEffectiveRect; } - (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex { if ([splitViewDelegate respondsToSelector:@selector(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:)]) return [splitViewDelegate splitView:splitView shouldCollapseSubview:subview forDoubleClickOnDividerAtIndex:dividerIndex]; return NO; } - (BOOL)splitView:(NSSplitView *)splitView shouldHideDividerAtIndex:(NSInteger)dividerIndex { if ([splitViewDelegate respondsToSelector:@selector(splitView:shouldHideDividerAtIndex:)]) return [splitViewDelegate splitView:splitView shouldHideDividerAtIndex:dividerIndex]; return NO; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAnchoredButtonBar.m
Objective-C
bsd
10,869
// // BWAddSheetBottomBar.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <Cocoa/Cocoa.h> @interface BWAddSheetBottomBar : NSView { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWAddSheetBottomBar.h
Objective-C
bsd
233
// // BWSelectableToolbarInspector.m // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import "BWSelectableToolbarInspector.h" @implementation BWSelectableToolbarInspector - (NSString *)viewNibName { return @"BWSelectableToolbarInspector"; } - (void)refresh { // Synchronize your inspector's content view with the currently selected objects [super refresh]; } @end
08iteng-ipad
TestMerge/bwtoolkit/BWSelectableToolbarInspector.m
Objective-C
bsd
454
// // BWToolbarItemInspector.h // BWToolkit // // Created by Brandon Walkin (www.brandonwalkin.com) // All code is provided under the New BSD license. // #import <InterfaceBuilderKit/InterfaceBuilderKit.h> @interface BWToolbarItemInspector : IBInspector { } @end
08iteng-ipad
TestMerge/bwtoolkit/BWToolbarItemInspector.h
Objective-C
bsd
273
// // TMUTStateCompareController.m // TestMerge // // Created by Barry Wark on 6/4/09. // Copyright 2009 Barry Wark. All rights reserved. // #import "TMUTStateCompareController.h" #import "TMOutputGroup.h" @implementation TMUTStateCompareController @dynamic referenceText; @dynamic outputText; + (NSSet*)keyPathsForValuesAffectingReferenceText { return [NSSet setWithObject:@"representedObject.referencePath"]; } + (NSSet*)keyPathsForValuesAffectingOutputText { return [NSSet setWithObject:@"representedObject.outputPath"]; } - (NSString*)referenceText { NSStringEncoding encoding; return [NSString stringWithContentsOfFile:[(id<TMOutputGroup>)[self representedObject] referencePath] usedEncoding:&encoding error:NULL]; } - (NSString*)outputText { NSStringEncoding encoding; return [NSString stringWithContentsOfFile:[(id<TMOutputGroup>)[self representedObject] outputPath] usedEncoding:&encoding error:NULL]; } @end
08iteng-ipad
TestMerge/TMUTStateCompareController.m
Objective-C
bsd
989
// // TMSelectableViewTest.m // TestMerge // // Created by Barry Wark on 6/5/09. // Copyright 2009 Barry Wark. All rights reserved. // #import "TMSelectableViewTest.h" #import "TMSelectableView.h" #import "GTMNSObject+UnitTesting.h" @implementation TMSelectableViewTest - (void)testRendering { TMSelectableView *view = [[TMSelectableView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; view.selected = NO; view.drawsBackground = YES; GTMAssertObjectImageEqualToImageNamed(view, @"TMSelectableViewTests-testRendering-unselected-background", @""); view.selected = YES; GTMAssertObjectImageEqualToImageNamed(view, @"TMSelectableViewTests-testRendering-selected-background", @""); view.drawsBackground = NO; GTMAssertObjectImageEqualToImageNamed(view, @"TMSelectableViewTests-testRendering-selected-nobackground", @""); view.selected = NO; GTMAssertObjectImageEqualToImageNamed(view, @"TMSelectableViewTests-testRendering-unselected-background", @""); } @end
08iteng-ipad
TestMerge/TMSelectableViewTest.m
Objective-C
bsd
1,031
// // TMUTStateCompareController.h // TestMerge // // Created by Barry Wark on 6/4/09. // Copyright 2009 Barry Wark. All rights reserved. // #import <Cocoa/Cocoa.h> #import "TMCompareController.h" @interface TMUTStateCompareController : TMCompareController { } @property (copy,readonly) NSString *referenceText; @property (copy,readonly) NSString *outputText; @end
08iteng-ipad
TestMerge/TMUTStateCompareController.h
Objective-C
bsd
378
// // TMOutputGroupCDFactory.m // TestMerge // // Created by Barry Wark on 5/18/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMOutputGroupCDFactory.h" #import "GTMDefines.h" NSString * const TMOutputGroupCDFactoryTooManyGroupsException = @"TMOutputGroupCDFactoryTooManyGroupsException"; @implementation TMOutputGroupCDFactory @synthesize context; - (void)dealloc { [context release]; [super dealloc]; } - (id)initWithManagedObjectContext:(NSManagedObjectContext*)moc { if((self = [super init])) { context = [moc retain]; } return self; } - (id<TMOutputGroup>)groupWithName:(NSString*)name extension:(NSString*)extension { NSManagedObject<TMOutputGroup> *result; NSFetchRequest *fetch = [self.context.persistentStoreCoordinator.managedObjectModel fetchRequestFromTemplateWithName:@"namedGroup" substitutionVariables:[NSDictionary dictionaryWithObjectsAndKeys: name, @"NAME", extension, @"EXTENSION", nil]]; NSError *err; NSArray *existingGroups = [[self context] executeFetchRequest:fetch error:&err]; if(existingGroups.count > 1) { [NSException raise:TMOutputGroupCDFactoryTooManyGroupsException format:@"More than one group with name.ext = %@.%@ in managed object context", name, extension]; } if(existingGroups.count > 0) { result = [existingGroups lastObject]; } else { result = [NSEntityDescription insertNewObjectForEntityForName:@"OutputGroup" inManagedObjectContext:[self context]]; result.name = name; result.extension = extension; if(![[self context] save:&err]) { _GTMDevLog(@"Unable to save context in -[TMOutputGroupCDFactory groupWithName:extension:] (%@)", err); [NSApp presentError:err]; } } return result; } @end
08iteng-ipad
TestMerge/TMOutputGroupCDFactory.m
Objective-C
bsd
2,131
// // TMOutputSorter.m // TestMerge // // Created by Barry Wark on 5/18/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMOutputSorter.h" #import "TMOutputGroup.h" #import "TMErrors.h" #import "GTMRegex.h" #import "GTMSystemVersion.h" NSString * const TMGTMUnitTestStateExtension = @"gtmUTState"; NSString * const TMGTMUnitTestImageExtension = @"tiff"; // !!!:barry:20090528 TODO -- get this dynamically as in GTMNSObject+UnitTesting static const NSUInteger GroupNameIndex = 1; @implementation TMOutputSorter @synthesize referencePaths; @synthesize outputPaths; - (id)initWithReferencePaths:(NSArray*)ref outputPaths:(NSArray*)output { if( (self = [super init]) ) { referencePaths = [ref copy]; outputPaths = [output copy]; } return self; } - (void)dealloc { [referencePaths release]; [outputPaths release]; [super dealloc]; } - (NSSet*)sortedOutputWithGroupFactory:(id<TMOutputGroupFactory>)factory error:(NSError**)error { NSMutableSet *groups = [NSMutableSet set]; for(NSString *path in self.referencePaths) { NSArray *comps = [[[path pathComponents] lastObject] componentsSeparatedByString:@"."]; if(comps.count < 2) { if(error != NULL) { *error = [NSError errorWithDomain:TMErrorDomain code:TMPathError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Path does not contain [name].[extension]", @"Path does not contain [name].[extension]") forKey:NSLocalizedFailureReasonErrorKey]]; return nil; } } NSString *name = [comps objectAtIndex:0]; NSString *extension = [comps lastObject]; id<TMOutputGroup> group = [factory groupWithName:name extension:extension]; [group addReferencePathsObject:path]; [groups addObject:group]; } for(NSString *path in self.outputPaths) { NSArray *comps = [[[path pathComponents] lastObject] componentsSeparatedByString:@"."]; if(comps.count < 2) { if(error != NULL) { *error = [NSError errorWithDomain:TMErrorDomain code:TMPathError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Path does not contain [name].[extension]", @"Path does not contain [name].[extension]") forKey:NSLocalizedFailureReasonErrorKey]]; return nil; } } NSString *name = [comps objectAtIndex:0]; NSString *extension = [comps lastObject]; if(name != nil && name.length > 0) { //remove _Failed and _Diff from name GTMRegex *nameRegex = [GTMRegex regexWithPattern:@"^([^_]+)(_Failed)*(_Diff)*$"]; _GTMDevLog(@"%@ => %@", nameRegex, name); _GTMDevAssert([nameRegex matchesString:name], @"Unable to match %@ with regex", name); NSArray *nameGroups = [nameRegex subPatternsOfString:name]; _GTMDevLog(@"name groups for %@: %@", name, nameGroups); _GTMDevLog(@"Finding group with name %@, extension %@", [nameGroups objectAtIndex:GroupNameIndex], extension); id<TMOutputGroup> group = [factory groupWithName:[nameGroups objectAtIndex:GroupNameIndex] extension:extension]; if([nameGroups lastObject] == [NSNull null] || //Failure nameGroups.count == 2 //new image ) { group.outputPath = path; } else { //_Diff _GTMDevAssert([[nameGroups lastObject] isEqualToString:@"_Diff"], @"Unexpected last name group"); group.failureDiffPath = path; } [groups addObject:group]; } } _GTMDevLog(@"Sorted output groups: %@", groups); return groups; } @end
08iteng-ipad
TestMerge/TMOutputSorter.m
Objective-C
bsd
4,343
// // TMOutputSorterTests.m // TestMerge // // Created by Barry Wark on 5/18/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMOutputSorterTests.h" #import "TMOutputSorter.h" #import "GTMNSObject+UnitTesting.h" #import "GTMNSString+FindFolder.h" #import "GTMSystemVersion.h" #import <SenTestingKit/SenTestingKit.h> #import <OCMock/OCMock.h> @interface TMOutputSorter (UnitTesting) - (void)gtm_unitTestEncodeState:(NSCoder*)inCoder; @end @implementation TMOutputSorter (UnitTesting) - (void)gtm_unitTestEncodeState:(NSCoder*)inCoder { [super gtm_unitTestEncodeState:inCoder]; [inCoder encodeObject:self.outputPaths forKey:@"outputPath"]; [inCoder encodeObject:self.referencePaths forKey:@"referencePath"]; } @end typedef enum _OutputType { Success, Failure, Diff } OutputType; @interface TMOutputSorterTests () - (void)failureTestsForExtension:(NSString*)extension; @end @implementation TMOutputSorterTests - (NSString*)outputFileForName:(NSString*)name arch:(NSString*)arch system:(NSString*)systemVersion extension:(NSString*)extension type:(OutputType)outputType { NSString *suffix; switch(outputType) { case Success: suffix = @""; break; case Failure: suffix = @"_Failed"; break; case Diff: suffix = @"_Failed_Diff"; break; } return [NSString stringWithFormat:@"%@%@.%@.%@.%@", name, suffix, arch, systemVersion, extension]; } - (void)testInitialState { NSArray *refPaths = [NSArray arrayWithObject:@"refPath1"]; NSArray *outputPaths = [NSArray arrayWithObjects:@"outputPath1", @"outputPath2", nil]; TMOutputSorter *sorter = [[TMOutputSorter alloc] initWithReferencePaths:refPaths outputPaths:outputPaths]; GTMAssertObjectStateEqualToStateNamed(sorter, @"TMOutputSorterTests-testInitialState", @""); } - (void)testSortedOutputWithGroupFactoryAddsRefPaths { //also tests group creation for successes SInt32 major, minor, bugFix; [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix]; NSString *actualSystem = [NSString stringWithFormat:@"%d.%d.%d", major, minor, bugFix]; NSString *prevSystem = [NSString stringWithFormat:@"%d.%d.%d", major, minor, bugFix-1]; NSString *actualArch = [GTMSystemVersion runtimeArchitecture]; NSString *otherArch = [actualArch isEqualToString:@"ppc"]?@"i386":@"ppc"; NSArray *refPaths = [NSArray arrayWithObjects: [self outputFileForName:@"testSortWithOutputGroupFactoryUsesCorrectSystemVersion" arch:actualArch system:actualSystem extension:@"tiff" type:Success], [self outputFileForName:@"testSortWithOutputGroupFactoryUsesCorrectSystemVersion" arch:otherArch system:actualSystem extension:@"tiff" type:Success], [self outputFileForName:@"testSortWithOutputGroupFactoryUsesCorrectSystemVersion" arch:actualArch system:prevSystem extension:@"tiff" type:Success], [self outputFileForName:@"testSortWithOutputGroupFactoryUsesCorrectSystemVersion" arch:otherArch system:prevSystem extension:@"tiff" type:Success], nil]; NSArray *outputPaths = [NSArray array]; //Mocks id factory = [OCMockObject mockForProtocol:@protocol(TMOutputGroupFactory)]; id group = [OCMockObject mockForProtocol:@protocol(TMOutputGroup)]; //expectation -- one group per output for(NSInteger i=0; i<refPaths.count; i++) { [[[factory expect] andReturn:group] groupWithName:@"testSortWithOutputGroupFactoryUsesCorrectSystemVersion" extension:@"tiff"]; [[group expect] addReferencePathsObject:[refPaths objectAtIndex:i]]; } TMOutputSorter *sorter = [[TMOutputSorter alloc] initWithReferencePaths:refPaths outputPaths:outputPaths]; NSSet *groups = [sorter sortedOutputWithGroupFactory:factory error:NULL]; STAssertNotNil(groups, @""); [factory verify]; [group verify]; } - (void)testSortedOutputWithGroupFactoryBuildsGroupsForImageFailures { [self failureTestsForExtension:@"tiff"]; } - (void)testSortedOutputWithGroupFactoryBuildsGroupsForStateFailures { [self failureTestsForExtension:@"gtmUTState"]; } - (void)failureTestsForExtension:(NSString*)extension { SInt32 major, minor, bugFix; [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix]; NSString *actualSystem = [NSString stringWithFormat:@"%d.%d.%d", major, minor, bugFix]; NSString *actualArch = [GTMSystemVersion runtimeArchitecture]; NSString *expectedRefPath = [self outputFileForName:@"failureTestsForExtension" arch:actualArch system:actualSystem extension:extension type:Success]; NSArray *refPaths = [NSArray arrayWithObjects: expectedRefPath, nil]; NSArray *outputPaths = [NSArray arrayWithObjects: [self outputFileForName:@"failureTestsForExtension" arch:actualArch system:actualSystem extension:extension type:Failure], [self outputFileForName:@"failureTestsForExtension" arch:actualArch system:actualSystem extension:extension type:Diff], nil]; //Mocks id factory = [OCMockObject mockForProtocol:@protocol(TMOutputGroupFactory)]; id group = [OCMockObject mockForProtocol:@protocol(TMOutputGroup)]; //expectation -- combined group [[[factory expect] andReturn:group] groupWithName:@"failureTestsForExtension" extension:extension]; [[group expect] addReferencePathsObject:expectedRefPath]; for(NSInteger i=0; i<outputPaths.count/2; i++) { [[[factory expect] andReturn:group] groupWithName:@"failureTestsForExtension" extension:extension]; [[group expect] setOutputPath:[self outputFileForName:@"failureTestsForExtension" arch:actualArch system:actualSystem extension:extension type:Failure]]; [[[factory expect] andReturn:group] groupWithName:@"failureTestsForExtension" extension:extension]; [[group expect] setFailureDiffPath:[self outputFileForName:@"failureTestsForExtension" arch:actualArch system:actualSystem extension:extension type:Diff]]; } TMOutputSorter *sorter = [[TMOutputSorter alloc] initWithReferencePaths:refPaths outputPaths:outputPaths]; NSSet *groups = [sorter sortedOutputWithGroupFactory:factory error:NULL]; STAssertNotNil(groups, @""); STAssertTrue(groups.count == 1, @"one group"); [factory verify]; [group verify]; } @end
08iteng-ipad
TestMerge/TMOutputSorterTests.m
Objective-C
bsd
8,797
// // TMMergeController.h // TestMerge // // Created by Barry Wark on 5/18/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import <Cocoa/Cocoa.h> #import "TMOutputGroup.h" @class TMCompareController; extern NSString * const TMMergeControllerDidCommitMerge; @interface TMMergeController : NSWindowController { NSString *referencePath; NSString *outputPath; NSSet *outputGroups; NSManagedObjectContext *managedObjectContext; IBOutlet NSArrayController *groupsController; IBOutlet NSBox *mergeViewContainer; NSDictionary *compareControllersByExtension; TMCompareController *currentCompareController; NSIndexSet *groupSelectionIndexes; } @property (copy,readwrite) NSString * referencePath; @property (copy,readwrite) NSString * outputPath; @property (copy,readonly) NSSet *outputGroups; @property (retain,readwrite) NSManagedObjectContext *managedObjectContext; @property (retain,readonly) NSPredicate *groupFilterPredicate; @property (retain,readwrite) IBOutlet NSBox *mergeViewContainer; @property (readonly) NSArray *groupSortDescriptors; @property (retain,readwrite) NSDictionary *compareControllersByExtension; @property (retain,readwrite,nonatomic) NSIndexSet *groupSelectionIndexes; @property (retain,readwrite) IBOutlet NSArrayController *groupsController; - (NSArray*)gtmUnitTestOutputPathsFromPath:(NSString*)path; - (IBAction)commitMerge:(id)sender; - (IBAction)selectReference:(id)sender; - (IBAction)selectOutput:(id)sender; - (IBAction)selectMergeNone:(id)sender; - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem; @end
08iteng-ipad
TestMerge/TMMergeController.h
Objective-C
bsd
1,668
// // TMImageView.m // TestMerge // // Created by Barry Wark on 5/28/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMImageView.h" #import "GTMDefines.h" @interface TMImageView () @end @implementation TMImageView @dynamic overlay; + (void)initialize { if(self == [TMImageView class]) { [self exposeBinding:@"selected"]; } } - (void)mouseDown:(NSEvent*)theEvent { if([[self delegate] conformsToProtocol:@protocol(TMImageViewDelegate)] && [[self delegate] respondsToSelector:@selector(mouseDownInImageView:)]) { [[self delegate] mouseDownInImageView:self]; } [super mouseDown:theEvent]; } - (void)setOverlay:(CALayer*)overlay { [self setOverlay:overlay forType:IKOverlayTypeImage]; } - (CALayer*)overlay { return [self overlayForType:IKOverlayTypeImage]; } @end
08iteng-ipad
TestMerge/TMImageView.m
Objective-C
bsd
862
// // TMImageView.h // TestMerge // // Created by Barry Wark on 5/28/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import <Cocoa/Cocoa.h> #import <Quartz/Quartz.h> @class TMImageView; @protocol TMImageViewDelegate - (void)mouseDownInImageView:(TMImageView*)view; @end @interface TMImageView : IKImageView { } @property (readwrite) CALayer *overlay; @end
08iteng-ipad
TestMerge/TMImageView.h
Objective-C
bsd
392
#import "_OutputGroup.h" #import "TMOutputGroup.h" @interface OutputGroup : _OutputGroup {} // Custom logic goes here. @property (readonly) NSString *referencePath; - (NSString*)mostSpecificGTMUnitTestOutputPathInSet:(NSSet*)paths name:(NSString*)name extension:(NSString*)ext; - (void)addReferencePathsObject:(NSString*)newPath; @end
08iteng-ipad
TestMerge/MOClasses/OutputGroup.h
Objective-C
bsd
339
#import "OutputGroup.h" #import "OutputFile.h" #import "GTMSystemVersion.h" @interface OutputGroup () @end @implementation OutputGroup @dynamic referencePath; + (NSSet*)keysPathsForValuesAffectingReferencePath { return [NSSet setWithObject:@"referenceFiles"]; } - (NSString*)referencePath { return [self mostSpecificGTMUnitTestOutputPathInSet:[[self referenceFilesSet] valueForKeyPath:@"path"] name:self.name extension:self.extension]; } - (NSString*)mostSpecificGTMUnitTestOutputPathInSet:(NSSet*)paths name:(NSString*)name extension:(NSString*)ext { /* Cribbed from GTMNSObject+UnitTesting because we can't include GTMNSObject+UnitTesting.h without SenTesting/SenTesting.h */ // System Version SInt32 major, minor, bugFix; [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix]; NSString *systemVersions[4]; systemVersions[0] = [NSString stringWithFormat:@".%d.%d.%d", major, minor, bugFix]; systemVersions[1] = [NSString stringWithFormat:@".%d.%d", major, minor]; systemVersions[2] = [NSString stringWithFormat:@".%d", major]; systemVersions[3] = @""; // Architectures NSString *extensions[2]; extensions[0] = [NSString stringWithFormat:@".%@", [GTMSystemVersion runtimeArchitecture]]; extensions[1] = @""; size_t i, j; // Note that we are searching for the most exact match first. for (i = 0; i < sizeof(extensions) / sizeof(*extensions); ++i) { for (j = 0; j < sizeof(systemVersions) / sizeof(*systemVersions); j++) { NSString *result = nil; for(NSString *path in paths) { NSString *fileName = [[path pathComponents] lastObject]; NSString *fullName1 = [NSString stringWithFormat:@"%@%@%@.%@", name, extensions[i], systemVersions[j], ext]; NSString *fullName2 = [NSString stringWithFormat:@"%@%@%@", name, systemVersions[j], extensions[i]]; if([fileName isEqualToString:fullName1] || [fileName isEqualToString:fullName2]) { if(result != nil) { //duplicate [NSException raise:NSGenericException format:@"Multiple paths with suffix %@ | %@ in set", fullName1, fullName2]; } result = path; } } if(result != nil) return result; } } return nil; } - (void)addReferencePathsObject:(NSString*)newPath { OutputFile *file = [OutputFile insertInManagedObjectContext:[self managedObjectContext]]; file.path = newPath; [self addReferenceFilesObject:file]; } @end
08iteng-ipad
TestMerge/MOClasses/OutputGroup.m
Objective-C
bsd
2,861
#import "_OutputFile.h" @interface OutputFile : _OutputFile {} // Custom logic goes here. @end
08iteng-ipad
TestMerge/MOClasses/OutputFile.h
Objective-C
bsd
96
// // OutputGroupTests.h // TestMerge // // Created by Barry Wark on 6/5/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "GTMSenTestCase.h" @class OutputGroup; @interface OutputGroupTests : GTMTestCase { OutputGroup *group; NSManagedObjectContext *moc; NSString *systemArch; NSString *systemVersions[4]; } @property (retain) OutputGroup *group; @property (retain) NSManagedObjectContext *moc; @property (copy) NSString *systemArch; @end
08iteng-ipad
TestMerge/MOClasses/OutputGroupTests.h
Objective-C
bsd
497
// // OutputGroupTests.m // TestMerge // // Created by Barry Wark on 6/5/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "OutputGroupTests.h" #import "OutputGroup.h" #import "GTMSystemVersion.h" @implementation OutputGroupTests @synthesize moc; @synthesize group; @synthesize systemArch; - (void)setUp { NSManagedObjectModel *mom = [NSManagedObjectModel mergedModelFromBundles:[NSArray arrayWithObject:[NSBundle bundleForClass:[OutputGroup class]]]]; NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom]; STAssertNotNil([psc addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:NULL], @"Unable to add store"); self.moc = [[NSManagedObjectContext alloc] init]; self.moc.persistentStoreCoordinator = psc; self.group = [OutputGroup insertInManagedObjectContext:self.moc]; // System Version SInt32 major, minor, bugFix; [GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix]; systemVersions[0] = [NSString stringWithFormat:@".%d.%d.%d", major, minor, bugFix]; systemVersions[1] = [NSString stringWithFormat:@".%d.%d", major, minor]; systemVersions[2] = [NSString stringWithFormat:@".%d", major]; systemVersions[3] = @""; // System architecture self.systemArch = [NSString stringWithFormat:@".%@", [GTMSystemVersion runtimeArchitecture]]; } - (void)tearDown { self.moc = nil; self.group = nil; self.systemArch = nil; } - (void)testMostSpecificPathChoosesSystemArchAndVersion { NSMutableSet *paths = [NSMutableSet set]; for(NSInteger i=0; i<4; i++) { [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@%@.tiff", self.systemArch, systemVersions[i]]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@.tiff", systemVersions[i]]]; } [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@.tiff", self.systemArch]]; NSString *expected = [NSString stringWithFormat:@"path/to/NAME%@%@.tiff", self.systemArch, systemVersions[0]]; STAssertEqualObjects([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME" extension:@"tiff"], expected, @""); } - (void)testMostSpecificPathChoosesSystemArchWhenNoVersion { NSMutableSet *paths = [NSMutableSet set]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@%@.tiff", self.systemArch, @"1.2.3"]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@.tiff", self.systemArch]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME.xyz.%@.tiff", @"1.2.3"]]; NSString *expected = [NSString stringWithFormat:@"path/to/NAME%@.tiff", self.systemArch]; STAssertEqualObjects([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME" extension:@"tiff"], expected, @""); } - (void)testRaisesIfMultipleNamedMatches { NSMutableSet *paths = [NSMutableSet set]; [paths addObject:[NSString stringWithFormat:@"path1/to/NAME%@%@.tiff", self.systemArch, systemVersions[0]]]; [paths addObject:[NSString stringWithFormat:@"path2/to/NAME%@%@.tiff", self.systemArch, systemVersions[0]]]; STAssertThrowsSpecific([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME" extension:@"tiff"], NSException, @""); } - (void)testIgnoresOtherNames { NSMutableSet *paths = [NSMutableSet set]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME1%@%@.tiff", self.systemArch, systemVersions[0]]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME2%@%@.tiff", self.systemArch, systemVersions[0]]]; id expected = [NSString stringWithFormat:@"path/to/NAME1%@%@.tiff", self.systemArch, systemVersions[0]]; STAssertEqualObjects([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME1" extension:@"tiff"], expected, @""); } - (void)testMostSpecificPathReturnsNilWhenNoVersionsMatch { NSMutableSet *paths = [NSMutableSet set]; for(NSInteger i=0; i<4; i++) { [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@%@.tiff", self.systemArch, @"1.2.3"]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@.tiff", @"1.2.3"]]; } STAssertNil([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME" extension:@"tiff"], @""); } - (void)testMostSpecificPathChoosesSystemVersionWhenNoArch { NSMutableSet *paths = [NSMutableSet set]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@%@.tiff", @"abc", systemVersions[0]]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@.tiff", systemVersions[0]]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME.xyz.tiff"]]; NSString *expected = [NSString stringWithFormat:@"path/to/NAME%@.tiff", systemVersions[0]]; STAssertEqualObjects([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME" extension:@"tiff"], expected, @""); } - (void)testMostSpecificPathReturnsNilWhenNoArchsMatch { NSMutableSet *paths = [NSMutableSet set]; for(NSInteger i=0; i<4; i++) { [paths addObject:[NSString stringWithFormat:@"path/to/NAME%@%@.tiff", @"abc", systemVersions[0]]]; [paths addObject:[NSString stringWithFormat:@"path/to/NAME.abc.tiff"]]; } STAssertNil([self.group mostSpecificGTMUnitTestOutputPathInSet:paths name:@"NAME" extension:@"tiff"], @""); } @end
08iteng-ipad
TestMerge/MOClasses/OutputGroupTests.m
Objective-C
bsd
5,720
#import "OutputFile.h" @implementation OutputFile // Custom logic goes here. @end
08iteng-ipad
TestMerge/MOClasses/OutputFile.m
Objective-C
bsd
85
// // TMOutputGroupCDFactoryTests.m // TestMerge // // Created by Barry Wark on 6/3/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMOutputGroupCDFactoryTests.h" #import "TMOutputGroup.h" #import "TMOutputGroupCDFactory.h" #import "OutputGroup.h" @implementation TMOutputGroupCDFactoryTests @synthesize moc; - (void)setUp { NSManagedObjectModel *mom = [NSManagedObjectModel mergedModelFromBundles:[NSArray arrayWithObject:[NSBundle bundleForClass:[TMOutputGroupCDFactory class]]]]; NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom]; STAssertNotNil([psc addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:NULL], @"Unable to add in-memory store."); self.moc = [[NSManagedObjectContext alloc] init]; self.moc.persistentStoreCoordinator = psc; } - (void)tearDown { self.moc = nil; } - (void)testGroupWithNameReturnsExistingGroup { id<TMOutputGroup> group1 = [OutputGroup insertInManagedObjectContext:self.moc]; group1.name = @"test_name"; group1.extension = @"test_ext"; id<TMOutputGroup> group2 = [OutputGroup insertInManagedObjectContext:self.moc]; group2.name = @"test_name2"; group2.extension = @"test_ext"; id<TMOutputGroup> group3 = [OutputGroup insertInManagedObjectContext:self.moc]; group3.name = @"test_name"; group3.extension = @"test_ext3"; STAssertTrue([[self moc] save:NULL], @"unable to save"); STAssertEqualObjects([[[TMOutputGroupCDFactory alloc] initWithManagedObjectContext:self.moc] groupWithName:@"test_name" extension:@"test_ext"], group1, @""); } - (void)testGroupWithnameRaisesForMultipleGroups { id<TMOutputGroup> group1 = [OutputGroup insertInManagedObjectContext:self.moc]; group1.name = @"test_name"; group1.extension = @"test_ext"; id<TMOutputGroup> group2 = [OutputGroup insertInManagedObjectContext:self.moc]; group2.name = @"test_name"; group2.extension = @"test_ext"; STAssertTrue([[self moc] save:NULL], @"unable to save"); STAssertThrowsSpecificNamed([[[TMOutputGroupCDFactory alloc] initWithManagedObjectContext:self.moc] groupWithName:@"test_name" extension:@"test_ext"], NSException, TMOutputGroupCDFactoryTooManyGroupsException, @""); } @end
08iteng-ipad
TestMerge/TMOutputGroupCDFactoryTests.m
Objective-C
bsd
2,371
// // TestMerge_AppDelegate.m // TestMerge // // Created by Barry Wark on 5/18/09. // Copyright Barry Wark 2009 . All rights reserved. // #import "AppDelegate.h" #import "TMMergeController.h" #import "TMImageCompareController.h" #import "TMUTStateCompareController.h" #import "TMOutputSorter.h" #import "GTMUnitTestingUtilities.h" #import "GTMLogger.h" #import "GTMLogger+ASL.h" @interface AppDelegate () @property (retain,readwrite) TMMergeController * mergeController; @end @implementation AppDelegate @synthesize mergeController; /** Implementation of dealloc, to release the retained variables. */ - (void) dealloc { [mergeController release]; [managedObjectContext release], managedObjectContext = nil; [persistentStoreCoordinator release], persistentStoreCoordinator = nil; [managedObjectModel release], managedObjectModel = nil; [super dealloc]; } - (void)applicationWillFinishLaunching:(NSNotification *)aNotification { [GTMLogger setSharedLogger:[GTMLogger standardLoggerWithASL]]; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.mergeController = [[TMMergeController alloc] initWithWindowNibName:@"MergeUI"]; self.mergeController.compareControllersByExtension = [NSDictionary dictionaryWithObjectsAndKeys: [[TMImageCompareController alloc] initWithNibName:@"ImageCompareView" bundle:[NSBundle mainBundle]], TMGTMUnitTestImageExtension, [[TMUTStateCompareController alloc] initWithNibName:@"UTStateCompareView" bundle:[NSBundle mainBundle]], TMGTMUnitTestStateExtension, nil]; self.mergeController.referencePath = [[[[NSProcessInfo processInfo] environment] objectForKey:@"TM_REFERENCE_PATH"] stringByExpandingTildeInPath]; self.mergeController.outputPath = [[[[NSProcessInfo processInfo] environment] objectForKey:@"TM_OUTPUT_PATH"] stringByExpandingTildeInPath]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mergeControllerDidCommitMerge:) name:TMMergeControllerDidCommitMerge object:self.mergeController]; [[[self mergeController] window] center]; [[self mergeController] showWindow:self]; } - (void)mergeControllerDidCommitMerge:(NSNotification*)notification { //pass } /** Returns the support folder for the application, used to store the Core Data store file. This co de uses a folder named "TestMerge" for the content, either in the NSApplicationSupportDirectory location or (if the former cannot be found), the system's temporary directory. */ - (NSString *)applicationSupportFolder { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory(); return [basePath stringByAppendingPathComponent:@"TestMerge"]; } /** Implementation of the applicationShouldTerminate: method, used here to commit merge selections. */ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { int reply = NSTerminateNow; // if the user has selected a merge direction for any output groups, prompt to commit the merge NSSet *groups = self.mergeController.outputGroups; if([[[groups allObjects] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"replaceReference=YES || replaceReference=NO"]] count] > 0) { NSInteger result = [[NSAlert alertWithMessageText:NSLocalizedString(@"Commit merge?", @"Commit merge?") defaultButton:NSLocalizedString(@"Commit",@"Commit") alternateButton:NSLocalizedString(@"Don't commit", @"Don't commit") otherButton:NSLocalizedString(@"Cancel", @"Cancel") informativeTextWithFormat:NSLocalizedString(@"Don't forget to update your unit tests target by adding any new images!", @"Don't forget to update your unit tests target by adding any new images!")] runModal]; switch(result) { case NSAlertDefaultReturn: [[self mergeController] commitMerge:self]; result = NSTerminateNow; break; case NSAlertAlternateReturn: result = NSTerminateNow; break; case NSAlertOtherReturn: result = NSTerminateCancel; break; } } return reply; } @end
08iteng-ipad
TestMerge/AppDelegate.m
Objective-C
bsd
4,988
// // TMOutputSorterTests.h // TestMerge // // Created by Barry Wark on 5/18/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "GTMSenTestCase.h" @interface TMOutputSorterTests : GTMTestCase { } @end
08iteng-ipad
TestMerge/TMOutputSorterTests.h
Objective-C
bsd
237
// // TMImageCompareControllerTests.m // TestMerge // // Created by Barry Wark on 5/27/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMImageCompareControllerTests.h" #import "TMImageCompareController.h" #import "GTMNSObject+UnitTesting.h" #import "GTMNSObject+BindingUnitTesting.h" @implementation TMImageCompareControllerTests @synthesize controller; - (void)setUp { self.controller = [[[NSViewController alloc] initWithNibName:@"ImageCompareView" bundle:[NSBundle mainBundle]] autorelease]; } - (void)tearDown { self.controller = nil; } - (void)testBindings { GTMDoExposedBindingsFunctionCorrectly(self.controller, NULL); } @end
08iteng-ipad
TestMerge/TMImageCompareControllerTests.m
Objective-C
bsd
687
// // TMErrors.h // TestMerge // // Created by Barry Wark on 5/27/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import <Cocoa/Cocoa.h> extern NSString * const TMErrorDomain; extern const NSInteger TMPathError; extern const NSInteger TMCoreDataError;
08iteng-ipad
TestMerge/TMErrors.h
Objective-C
bsd
282
// // TMImageViewTests.m // TestMerge // // Created by Barry Wark on 5/28/09. // Copyright 2009 Physion Consulting LLC. All rights reserved. // #import "TMImageViewTests.h" #import "GTMNSObject+UnitTesting.h" #import "GTMNSObject+BindingUnitTesting.h" @implementation TMImageViewTests @synthesize imageView; @synthesize flag; - (void)setUp { self.imageView = [[[TMImageView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)] autorelease]; NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForImageResource:@"TMMergeControllerTests-testWindowUIRendering.tiff"]; STAssertNotNil(imagePath, @"unable to find image"); self.imageView.autoresizes = YES; self.imageView.autohidesScrollers = YES; [self.imageView setImageWithURL:[NSURL fileURLWithPath:imagePath]]; } - (void)tearDown { self.imageView = nil; } - (void)testRenderNilURLImage { [[self imageView] setImageWithURL:nil]; GTMAssertObjectImageEqualToImageNamed(self.imageView.layer, @"TMImageViewTests-testRenderNilURLImage", @""); } - (void)testDelegateCalledForMouseDown { self.imageView.delegate = self; self.flag = NO; [[self imageView] mouseDown:[NSEvent mouseEventWithType:NSLeftMouseUp location:[[self imageView] convertPoint:NSMakePoint(1,1) toView:nil] modifierFlags:0 timestamp:[NSDate timeIntervalSinceReferenceDate] windowNumber:0 context:nil eventNumber:1 clickCount:1 pressure:1.0]]; STAssertTrue(self.flag, @"delegate method not recieved"); } - (void)mouseDownInImageView:(TMImageView*)view { STAssertEquals(view, self.imageView, @""); self.flag = YES; } - (void)testBindings { GTMDoExposedBindingsFunctionCorrectly(self.imageView.layer, NULL); } - (void)testOverlayRendering { CALayer *diffLayer = [CALayer layer]; NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForImageResource:@"TMMergeControllerTests-testWindowUIRendering.tiff"]; //TMMergeControllerTests-testWindowUIRendering_Failed_Diff.i386.10.5.7.tiff CIImage *diffImage = [CIImage imageWithContentsOfURL:[NSURL fileURLWithPath:imagePath]]; NSBitmapImageRep *diffRep = [[NSBitmapImageRep alloc] initWithCIImage:diffImage]; diffLayer.contents = (id)[diffRep CGImage]; self.imageView.overlay = diffLayer; GTMAssertObjectEqualToStateAndImageNamed(self.imageView.layer, @"TMImageViewTests-testOverlayRendering", @""); } @end
08iteng-ipad
TestMerge/TMImageViewTests.m
Objective-C
bsd
2,850