summaryrefslogtreecommitdiff
path: root/frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m')
-rw-r--r--frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m62
1 files changed, 20 insertions, 42 deletions
diff --git a/frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m b/frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m
index 4542e8d02..1e3e3684e 100644
--- a/frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m
+++ b/frontends/cocoa/PSMTabBarControl/PSMTabDragAssistant.m
@@ -10,6 +10,8 @@
#import "PSMTabBarCell.h"
#import "PSMTabStyle.h"
#import "PSMTabDragWindowController.h"
+#import "PSMOverflowPopUpButton.h"
+#import "PSMRolloverButton.h"
#define PI 3.1417
@@ -53,16 +55,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
return self;
}
-- (void)dealloc {
- [_sourceTabBar release];
- [_destinationTabBar release];
- [_participatingTabBars release];
- [_draggedCell release];
- [_animationTimer release];
- [_sineCurveWidths release];
- [_targetCell release];
- [super dealloc];
-}
#pragma mark -
#pragma mark Accessors
@@ -72,8 +64,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
- (void)setSourceTabBar:(PSMTabBarControl *)tabBar {
- [tabBar retain];
- [_sourceTabBar release];
_sourceTabBar = tabBar;
}
@@ -82,8 +72,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
- (void)setDestinationTabBar:(PSMTabBarControl *)tabBar {
- [tabBar retain];
- [_destinationTabBar release];
_destinationTabBar = tabBar;
}
@@ -92,8 +80,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
- (void)setDraggedCell:(PSMTabBarCell *)cell {
- [cell retain];
- [_draggedCell release];
_draggedCell = cell;
}
@@ -126,8 +112,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
- (void)setTargetCell:(PSMTabBarCell *)cell {
- [cell retain];
- [_targetCell release];
_targetCell = cell;
}
@@ -175,20 +159,18 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:PSMTabDragDidBeginNotification object:nil];
//retain the control in case the drag operation causes the control to be released
- [control retain];
if([control delegate] && [[control delegate] respondsToSelector:@selector(tabView:shouldDropTabViewItem:inTabBar:)] &&
[[control delegate] tabView:[control tabView] shouldDropTabViewItem:[[self draggedCell] representedObject] inTabBar:nil]) {
_currentTearOffStyle = [control tearOffStyle];
- _draggedTab = [[PSMTabDragWindowController alloc] initWithImage:dragImage styleMask:NSBorderlessWindowMask tearOffStyle:_currentTearOffStyle];
+ _draggedTab = [[PSMTabDragWindowController alloc] initWithImage:dragImage styleMask:NSWindowStyleMaskBorderless tearOffStyle:_currentTearOffStyle];
cellFrame.origin.y -= cellFrame.size.height;
- [control dragImage:[[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] autorelease] at:cellFrame.origin offset:offset event:event pasteboard:pboard source:control slideBack:NO];
+ [control dragImage:[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] at:cellFrame.origin offset:offset event:event pasteboard:pboard source:control slideBack:NO];
} else {
[control dragImage:dragImage at:cellFrame.origin offset:offset event:event pasteboard:pboard source:control slideBack:YES];
}
- [control release];
}
- (void)draggingEnteredTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc {
@@ -360,7 +342,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
//temporarily disable the delegate in order to move the tab to a different index
id tempDelegate = [tabView delegate];
[tabView setDelegate:nil];
- [item retain];
[tabView removeTabViewItem:item];
[tabView insertTabViewItem:item atIndex:index];
if(reselect) {
@@ -440,13 +421,11 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
if(_draggedTab) {
[[_draggedTab window] orderOut:nil];
- [_draggedTab release];
_draggedTab = nil;
}
if(_draggedView) {
[[_draggedView window] orderOut:nil];
- [_draggedView release];
_draggedView = nil;
}
@@ -548,7 +527,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
NSImage *viewImage = nil;
if(outMask) {
- *outMask = NSBorderlessWindowMask;
+ *outMask = NSWindowStyleMaskBorderless;
}
if([control delegate] && [[control delegate] respondsToSelector:@selector(tabView:imageForTabViewItem:offset:styleMask:)]) {
@@ -569,19 +548,19 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
drawPoint.x += [control frame].size.width - [tabImage size].width;
}
- [tabImage compositeToPoint:drawPoint operation:NSCompositeSourceOver];
+ [tabImage drawAtPoint:drawPoint fromRect: NSZeroRect operation:NSCompositingOperationSourceOver fraction: 1.0];
[viewImage unlockFocus];
} else {
//the delegate doesn't give a custom image, so use an image of the view
NSView *tabView = [[cell representedObject] view];
- viewImage = [[[NSImage alloc] initWithSize:[tabView frame].size] autorelease];
+ viewImage = [[NSImage alloc] initWithSize:[tabView frame].size] ;
[viewImage lockFocus];
[tabView drawRect:[tabView bounds]];
[viewImage unlockFocus];
}
- if(*outMask | NSBorderlessWindowMask) {
+ if(*outMask | NSWindowStyleMaskBorderless) {
_dragWindowOffset.height += 22;
}
@@ -590,7 +569,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
- (NSImage *)_miniwindowImageOfWindow:(NSWindow *)window {
NSRect rect = [window frame];
- NSImage *image = [[[NSImage alloc] initWithSize:rect.size] autorelease];
+ NSImage *image = [[NSImage alloc] initWithSize:rect.size] ;
[image lockFocus];
rect.origin = NSZeroPoint;
CGContextCopyWindowCaptureContentsToRect([[NSGraphicsContext currentContext] graphicsPort], *(CGRect *)&rect, [NSApp contextID], [window windowNumber], 0);
@@ -637,7 +616,6 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
if(![animation isAnimating]) {
[timer invalidate];
- [animation release];
}
}
@@ -645,7 +623,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
#pragma mark Animation
- (void)animateDrag:(NSTimer *)timer {
- NSEnumerator *e = [[[_participatingTabBars copy] autorelease] objectEnumerator];
+ NSEnumerator *e = [[_participatingTabBars copy] objectEnumerator];
PSMTabBarControl *tabBar;
while((tabBar = [e nextObject])) {
[self calculateDragAnimationForTabBar:tabBar];
@@ -754,7 +732,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
// replace dragged cell with a placeholder, and clean up surrounding cells
NSInteger cellIndex = [cells indexOfObject:cell];
- PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:YES inControlView:control] autorelease];
+ PSMTabBarCell *pc = [[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:YES inControlView:control] ;
[cells replaceObjectAtIndex:cellIndex withObject:pc];
[cells removeObjectAtIndex:(cellIndex + 1)];
[cells removeObjectAtIndex:(cellIndex - 1)];
@@ -768,11 +746,11 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control {
NSUInteger i, numVisibleTabs = [control numberOfVisibleTabs];
for(i = 0; i < numVisibleTabs; i++) {
- PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease];
+ PSMTabBarCell *pc = [[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] ;
[[control cells] insertObject:pc atIndex:(2 * i)];
}
- PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease];
+ PSMTabBarCell *pc = [[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] ;
if([[control cells] count] > (2 * numVisibleTabs)) {
[[control cells] insertObject:pc atIndex:(2 * numVisibleTabs)];
} else {
@@ -815,16 +793,16 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
//self = [super initWithCoder:aDecoder];
//if (self) {
if([aDecoder allowsKeyedCoding]) {
- _sourceTabBar = [[aDecoder decodeObjectForKey:@"sourceTabBar"] retain];
- _destinationTabBar = [[aDecoder decodeObjectForKey:@"destinationTabBar"] retain];
- _participatingTabBars = [[aDecoder decodeObjectForKey:@"participatingTabBars"] retain];
- _draggedCell = [[aDecoder decodeObjectForKey:@"draggedCell"] retain];
+ _sourceTabBar = [aDecoder decodeObjectForKey:@"sourceTabBar"] ;
+ _destinationTabBar = [aDecoder decodeObjectForKey:@"destinationTabBar"] ;
+ _participatingTabBars = [aDecoder decodeObjectForKey:@"participatingTabBars"] ;
+ _draggedCell = [aDecoder decodeObjectForKey:@"draggedCell"] ;
_draggedCellIndex = [aDecoder decodeIntegerForKey:@"draggedCellIndex"];
_isDragging = [aDecoder decodeBoolForKey:@"isDragging"];
- _animationTimer = [[aDecoder decodeObjectForKey:@"animationTimer"] retain];
- _sineCurveWidths = [[aDecoder decodeObjectForKey:@"sineCurveWidths"] retain];
+ _animationTimer = [aDecoder decodeObjectForKey:@"animationTimer"] ;
+ _sineCurveWidths = [aDecoder decodeObjectForKey:@"sineCurveWidths"] ;
_currentMouseLoc = [aDecoder decodePointForKey:@"currentMouseLoc"];
- _targetCell = [[aDecoder decodeObjectForKey:@"targetCell"] retain];
+ _targetCell = [aDecoder decodeObjectForKey:@"targetCell"] ;
}
//}
return self;