Skip to content

Commit 951e754

Browse files
committed
Merge branch 'master' of github.com:glebd/bwtoolkit
2 parents 6768932 + 70b044c commit 951e754

11 files changed

+76
-118
lines changed

BWAnchoredButtonBar.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
#import <Cocoa/Cocoa.h>
1010

11-
@interface BWAnchoredButtonBar : NSView
11+
@interface BWAnchoredButtonBar : NSView <NSSplitViewDelegate>
1212
{
1313
BOOL isResizable, isAtBottom, handleIsRightAligned;
1414
int selectedIndex;
15-
id splitViewDelegate;
1615
}
1716

18-
@property BOOL isResizable, isAtBottom, handleIsRightAligned;
19-
@property int selectedIndex;
17+
@property (nonatomic) BOOL isResizable, isAtBottom, handleIsRightAligned;
18+
@property (nonatomic) int selectedIndex;
2019

2120
// The mode of this bar with a resize handle makes use of some NSSplitView delegate methods. Use the splitViewDelegate for any custom delegate implementations
2221
// you'd like to provide.

BWAnchoredButtonBar.m

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ @implementation BWAnchoredButtonBar
3434

3535
+ (void)initialize;
3636
{
37-
topLineColor = [[NSColor colorWithCalibratedWhite:(202.0f / 255.0f) alpha:1] retain];
38-
bottomLineColor = [[NSColor colorWithCalibratedWhite:(170.0f / 255.0f) alpha:1] retain];
39-
topColor = [[NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1] retain];
40-
middleTopColor = [[NSColor colorWithCalibratedWhite:(242.0f / 255.0f) alpha:1] retain];
41-
middleBottomColor = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain];
42-
bottomColor = [[NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1] retain];
43-
sideInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.5] retain];
44-
borderedTopLineColor = [[NSColor colorWithCalibratedWhite:(190.0f / 255.0f) alpha:1] retain];
37+
topLineColor = [NSColor colorWithCalibratedWhite:(202.0f / 255.0f) alpha:1];
38+
bottomLineColor = [NSColor colorWithCalibratedWhite:(170.0f / 255.0f) alpha:1];
39+
topColor = [NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1];
40+
middleTopColor = [NSColor colorWithCalibratedWhite:(242.0f / 255.0f) alpha:1];
41+
middleBottomColor = [NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1];
42+
bottomColor = [NSColor colorWithCalibratedWhite:(230.0f / 255.0f) alpha:1];
43+
sideInsetColor = [NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.5];
44+
borderedTopLineColor = [NSColor colorWithCalibratedWhite:(190.0f / 255.0f) alpha:1];
4545

4646
gradient = [[NSGradient alloc] initWithColorsAndLocations:
4747
topColor, (CGFloat)0.0,
@@ -50,8 +50,8 @@ + (void)initialize;
5050
bottomColor, (CGFloat)1.0,
5151
nil];
5252

53-
resizeHandleColor = [[NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.598] retain];
54-
resizeInsetColor = [[NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.55] retain];
53+
resizeHandleColor = [NSColor colorWithCalibratedWhite:(0.0f / 255.0f) alpha:0.598];
54+
resizeInsetColor = [NSColor colorWithCalibratedWhite:(255.0f / 255.0f) alpha:0.55];
5555
}
5656

5757
- (id)initWithFrame:(NSRect)frame
@@ -98,7 +98,7 @@ - (void)awakeFromNib
9898
if (splitView != nil && [splitView isVertical] && [self isResizable])
9999
{
100100
if ([splitView delegate] != nil && ([[splitView delegate] isKindOfClass:[BWAnchoredButtonBar class]] ||
101-
[splitView isKindOfClass:[BWSplitView class]] && [[(BWSplitView *)splitView secondaryDelegate] isKindOfClass:[BWAnchoredButtonBar class]]))
101+
([splitView isKindOfClass:[BWSplitView class]] && [[(BWSplitView *)splitView secondaryDelegate] isKindOfClass:[BWAnchoredButtonBar class]])))
102102
{
103103
// There's already an Anchored Button Bar set as the delegate so we need to set ourself as the split view delegate on
104104
// the button bar. But since there can be multiple button bars, we need to set ourself as the delegate on the last
@@ -307,7 +307,6 @@ - (void)dealloc
307307
if ([splitView delegate] == self)
308308
[splitView setDelegate:nil];
309309

310-
[super dealloc];
311310
}
312311

313312
#pragma mark NSSplitView Delegate Methods

BWGradientBox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
BOOL hasTopBorder, hasBottomBorder, hasGradient, hasFillColor;
1818
}
1919

20-
@property (nonatomic, retain) NSColor *fillStartingColor, *fillEndingColor, *fillColor, *topBorderColor, *bottomBorderColor;
20+
@property (nonatomic, strong) NSColor *fillStartingColor, *fillEndingColor, *fillColor, *topBorderColor, *bottomBorderColor;
2121
@property float topInsetAlpha, bottomInsetAlpha;
2222
@property BOOL hasTopBorder, hasBottomBorder, hasGradient, hasFillColor;
2323

BWGradientBox.m

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ - (void)drawRect:(NSRect)rect
7676
{
7777
NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:fillStartingColor endingColor:fillEndingColor];
7878
[gradient drawInRect:self.bounds angle:90];
79-
[gradient release];
8079
}
8180
else
8281
{
@@ -119,8 +118,7 @@ - (void)setFillColor:(NSColor *)color
119118
{
120119
if (fillColor != color)
121120
{
122-
[fillColor release];
123-
fillColor = [color retain];
121+
fillColor = color;
124122

125123
[self setNeedsDisplay:YES];
126124
}
@@ -130,8 +128,7 @@ - (void)setFillStartingColor:(NSColor *)color
130128
{
131129
if (fillStartingColor != color)
132130
{
133-
[fillStartingColor release];
134-
fillStartingColor = [color retain];
131+
fillStartingColor = color;
135132

136133
[self setNeedsDisplay:YES];
137134
}
@@ -141,8 +138,7 @@ - (void)setFillEndingColor:(NSColor *)color
141138
{
142139
if (fillEndingColor != color)
143140
{
144-
[fillEndingColor release];
145-
fillEndingColor = [color retain];
141+
fillEndingColor = color;
146142

147143
[self setNeedsDisplay:YES];
148144
}
@@ -152,8 +148,7 @@ - (void)setTopBorderColor:(NSColor *)color
152148
{
153149
if (topBorderColor != color)
154150
{
155-
[topBorderColor release];
156-
topBorderColor = [color retain];
151+
topBorderColor = color;
157152

158153
[self setNeedsDisplay:YES];
159154
}
@@ -163,22 +158,11 @@ - (void)setBottomBorderColor:(NSColor *)color
163158
{
164159
if (bottomBorderColor != color)
165160
{
166-
[bottomBorderColor release];
167-
bottomBorderColor = [color retain];
161+
bottomBorderColor = color;
168162

169163
[self setNeedsDisplay:YES];
170164
}
171165
}
172166

173-
- (void)dealloc
174-
{
175-
[fillColor release];
176-
[fillStartingColor release];
177-
[fillEndingColor release];
178-
[topBorderColor release];
179-
[bottomBorderColor release];
180-
181-
[super dealloc];
182-
}
183167

184168
@end

BWSplitView.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
#import <Cocoa/Cocoa.h>
1010

11-
@interface BWSplitView : NSSplitView
11+
@interface BWSplitView : NSSplitView <NSSplitViewDelegate>
1212
{
1313
NSColor *color;
1414
BOOL colorIsEnabled, checkboxIsEnabled, dividerCanCollapse, collapsibleSubviewCollapsed;
15-
id secondaryDelegate;
1615
NSMutableDictionary *minValues, *maxValues, *minUnits, *maxUnits;
1716
NSMutableDictionary *resizableSubviewPreferredProportion, *nonresizableSubviewPreferredSize;
1817
NSArray *stateForLastPreferredCalculations;
@@ -24,20 +23,20 @@
2423
BOOL isAnimating;
2524
}
2625

27-
@property (retain) NSMutableDictionary *minValues, *maxValues, *minUnits, *maxUnits;
28-
@property (retain) NSMutableDictionary *resizableSubviewPreferredProportion, *nonresizableSubviewPreferredSize;
29-
@property (retain) NSArray *stateForLastPreferredCalculations;
30-
@property (retain) NSButton *toggleCollapseButton;
26+
@property (nonatomic, strong) NSMutableDictionary *minValues, *maxValues, *minUnits, *maxUnits;
27+
@property (strong) NSMutableDictionary *resizableSubviewPreferredProportion, *nonresizableSubviewPreferredSize;
28+
@property (strong) NSArray *stateForLastPreferredCalculations;
29+
@property (strong) NSButton *toggleCollapseButton;
3130
@property (assign) id secondaryDelegate;
32-
@property BOOL collapsibleSubviewCollapsed;
31+
@property (nonatomic) BOOL collapsibleSubviewCollapsed;
3332
@property int collapsiblePopupSelection;
3433
@property BOOL dividerCanCollapse;
3534

3635
// The split view divider color
3736
@property (copy) NSColor *color;
3837

3938
// Flag for whether a custom divider color is enabled. If not, the standard divider color is used.
40-
@property BOOL colorIsEnabled;
39+
@property (nonatomic) BOOL colorIsEnabled;
4140

4241
// Call this method to collapse or expand a subview configured as collapsible in the IB inspector.
4342
- (IBAction)toggleCollapse:(id)sender;

BWSplitView.m

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ - (void)resizeAndAdjustSubviews;
4747
@end
4848

4949
@interface BWSplitView ()
50-
@property BOOL checkboxIsEnabled;
50+
@property (nonatomic) BOOL checkboxIsEnabled;
5151
@end
5252

5353
@implementation BWSplitView
@@ -58,9 +58,9 @@ @implementation BWSplitView
5858

5959
+ (void)initialize;
6060
{
61-
borderColor = [[NSColor colorWithCalibratedWhite:(165.0f / 255.0f) alpha:1] retain];
62-
gradientStartColor = [[NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1] retain];
63-
gradientEndColor = [[NSColor colorWithCalibratedWhite:(222.0f / 255.0f) alpha:1] retain];
61+
borderColor = [NSColor colorWithCalibratedWhite:(165.0f / 255.0f) alpha:1];
62+
gradientStartColor = [NSColor colorWithCalibratedWhite:(253.0f / 255.0f) alpha:1];
63+
gradientEndColor = [NSColor colorWithCalibratedWhite:(222.0f / 255.0f) alpha:1];
6464

6565
gradient = [[NSGradient alloc] initWithStartingColor:gradientStartColor endingColor:gradientEndColor];
6666

@@ -312,7 +312,7 @@ - (void)setMinSizeForCollapsibleSubview:(NSNumber *)minSize
312312
{
313313
if ([self hasCollapsibleSubview])
314314
{
315-
NSMutableDictionary *tempMinValues = [[[self minValues] mutableCopy] autorelease];
315+
NSMutableDictionary *tempMinValues = [[self minValues] mutableCopy];
316316
[tempMinValues setObject:minSize forKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]];
317317
[self setMinValues:tempMinValues];
318318
}
@@ -322,7 +322,7 @@ - (void)removeMinSizeForCollapsibleSubview
322322
{
323323
if ([self hasCollapsibleSubview])
324324
{
325-
NSMutableDictionary *tempMinValues = [[[self minValues] mutableCopy] autorelease];
325+
NSMutableDictionary *tempMinValues = [[self minValues] mutableCopy];
326326
[tempMinValues removeObjectForKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]];
327327
[self setMinValues:tempMinValues];
328328
}
@@ -349,7 +349,7 @@ - (IBAction)toggleCollapse:(id)sender
349349
// We'll later remove the min size temporarily while animating and then restore it.
350350
BOOL hasMinSize = NO;
351351
NSNumber *minSize = [minValues objectForKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]];
352-
minSize = [[minSize copy] autorelease];
352+
minSize = [minSize copy];
353353

354354
if (minSize != nil || [minSize intValue] != 0)
355355
hasMinSize = YES;
@@ -715,6 +715,13 @@ - (void)splitViewWillResizeSubviews:(NSNotification *)aNotification
715715
[secondaryDelegate splitViewWillResizeSubviews:aNotification];
716716
}
717717

718+
- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view
719+
{
720+
if ([secondaryDelegate respondsToSelector:@selector(splitView:shouldAdjustSizeOfSubview:)])
721+
return [secondaryDelegate splitView:splitView shouldAdjustSizeOfSubview:view];
722+
return YES;
723+
}
724+
718725
#pragma mark - Resize Subviews Delegate Method and Helper Methods
719726

720727
- (int)resizableSubviews
@@ -907,8 +914,8 @@ - (void)correctCollapsiblePreferredProportionOrSize;
907914
if (![self hasCollapsibleSubview])
908915
return;
909916

910-
NSMutableDictionary *preferredProportions = [[[self resizableSubviewPreferredProportion] mutableCopy] autorelease];
911-
NSMutableDictionary *preferredSizes = [[[self nonresizableSubviewPreferredSize] mutableCopy] autorelease];
917+
NSMutableDictionary *preferredProportions = [[self resizableSubviewPreferredProportion] mutableCopy];
918+
NSMutableDictionary *preferredSizes = [[self nonresizableSubviewPreferredSize] mutableCopy];
912919

913920
NSNumber *key = [NSNumber numberWithInt:[self collapsibleSubviewIndex]];
914921
NSView *subview = [self collapsibleSubview];
@@ -1070,8 +1077,8 @@ - (void)resizeAndAdjustSubviews;
10701077
// TODO: Could add a special case for resizableSubviewsTotalAvailableSize <= 0 : just set all resizable subviews to minimum size
10711078

10721079
// Make array of all the resizable subviews indexes
1073-
NSMutableArray *resizableSubviewIndexes = [[[resizableSubviewPreferredProportion allKeys] mutableCopy] autorelease];
1074-
[resizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES] autorelease]]];
1080+
NSMutableArray *resizableSubviewIndexes = [[resizableSubviewPreferredProportion allKeys] mutableCopy];
1081+
[resizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES]]];
10751082

10761083
// Loop until none of the resizable subviews' constraints are violated
10771084
CGFloat proportionTotal = 1;
@@ -1176,8 +1183,8 @@ - (void)resizeAndAdjustSubviews;
11761183
if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after nonresizable proportional resizing: %@", newSubviewSizes);
11771184

11781185
// Make array of all the non-resizable subviews indexes
1179-
NSMutableArray *nonresizableSubviewIndexes = [[[nonresizableSubviewPreferredSize allKeys] mutableCopy] autorelease];
1180-
[nonresizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES] autorelease]]];
1186+
NSMutableArray *nonresizableSubviewIndexes = [[nonresizableSubviewPreferredSize allKeys] mutableCopy];
1187+
[nonresizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES]]];
11811188

11821189
// Loop until none of the non-resizable subviews' constraints are violated
11831190
CGFloat proportionTotal = 1;
@@ -1369,7 +1376,6 @@ - (void)setColor:(NSColor *)aColor
13691376
{
13701377
if (color != aColor)
13711378
{
1372-
[color release];
13731379
color = [aColor copy];
13741380
}
13751381

@@ -1379,56 +1385,42 @@ - (void)setColor:(NSColor *)aColor
13791385
- (NSColor *)color
13801386
{
13811387
if (color == nil)
1382-
color = [[NSColor blackColor] retain];
1388+
color = [NSColor blackColor];
13831389

1384-
return [[color retain] autorelease];
1390+
return color;
13851391
}
13861392

13871393
- (NSMutableDictionary *)minValues
13881394
{
13891395
if (minValues == nil)
13901396
minValues = [NSMutableDictionary new];
13911397

1392-
return [[minValues retain] autorelease];
1398+
return minValues;
13931399
}
13941400

13951401
- (NSMutableDictionary *)maxValues
13961402
{
13971403
if (maxValues == nil)
13981404
maxValues = [NSMutableDictionary new];
13991405

1400-
return [[maxValues retain] autorelease];
1406+
return maxValues;
14011407
}
14021408

14031409
- (NSMutableDictionary *)minUnits
14041410
{
14051411
if (minUnits == nil)
14061412
minUnits = [NSMutableDictionary new];
14071413

1408-
return [[minUnits retain] autorelease];
1414+
return minUnits;
14091415
}
14101416

14111417
- (NSMutableDictionary *)maxUnits
14121418
{
14131419
if (maxUnits == nil)
14141420
maxUnits = [NSMutableDictionary new];
14151421

1416-
return [[maxUnits retain] autorelease];
1422+
return maxUnits;
14171423
}
14181424

1419-
- (void)dealloc
1420-
{
1421-
[color release];
1422-
[minValues release];
1423-
[maxValues release];
1424-
[minUnits release];
1425-
[maxUnits release];
1426-
[resizableSubviewPreferredProportion release];
1427-
[nonresizableSubviewPreferredSize release];
1428-
[toggleCollapseButton release];
1429-
[stateForLastPreferredCalculations release];
1430-
1431-
[super dealloc];
1432-
}
14331425

14341426
@end

BWStyledTextField.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ - (void)setShadowIsBelow:(BOOL)flag
3838

3939
- (NSColor *)shadowColor
4040
{
41-
return [[self cell] shadowColor];
41+
return (NSColor *)[[self cell] shadowColor];
4242
}
4343

4444
- (void)setShadowColor:(NSColor *)color
4545
{
46-
[[self cell] setShadowColor:color];
46+
[[self cell] setShadowColor:(__bridge CGColorRef)(color)];
4747

4848
[self setNeedsDisplay:YES];
4949
}

BWStyledTextFieldCell.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
NSMutableDictionary *previousAttributes;
1818
}
1919

20-
@property BOOL shadowIsBelow, hasShadow, hasGradient;
21-
@property (nonatomic, retain) NSColor *shadowColor, *startingColor, *endingColor, *solidColor;
20+
@property (nonatomic) BOOL shadowIsBelow, hasShadow, hasGradient;
21+
@property (nonatomic, strong) NSColor *shadowColor, *startingColor, *endingColor, *solidColor;
2222

2323
@end

0 commit comments

Comments
 (0)