aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.m2
-rw-r--r--Source/SPWindowController.m58
2 files changed, 56 insertions, 4 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 37f79242..a6b965c7 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -302,8 +302,8 @@
// Create a new window controller, and set up a new connection view within it.
SPWindowController *newWindowController = [[SPWindowController alloc] initWithWindowNibName:@"MainWindow"];
+ [newWindowController addNewConnection:self];
NSWindow *newWindow = [newWindowController window];
- [newWindow setReleasedWhenClosed:YES];
// Cascading defaults to on - retrieve the window origin automatically assigned by cascading,
// and convert to a top left point.
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m
index f04712cc..0050ba15 100644
--- a/Source/SPWindowController.m
+++ b/Source/SPWindowController.m
@@ -59,6 +59,7 @@
[tabBar setCellMinWidth:100];
[tabBar setCellMaxWidth:250];
[tabBar setCellOptimumWidth:250];
+ [tabBar setTearOffStyle:PSMTabBarTearOffAlphaWindow];
// hook up add tab button
[[tabBar addTabButton] setTarget:self];
@@ -67,9 +68,6 @@
// Retrieve references to the 'Close Window' and 'Close Tab' menus. These are updated as window focus changes.
closeWindowMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:1003];
closeTabMenuItem = [[[[NSApp mainMenu] itemWithTag:SPMainMenuFile] submenu] itemWithTag:1103];
-
- // Add a new connection to the new window
- [self addNewConnection:self];
}
/**
@@ -78,6 +76,8 @@
- (void) dealloc
{
[managedDatabaseConnections release];
+
+ [super dealloc];
}
#pragma mark -
@@ -285,6 +285,9 @@
[draggedDocument removeObserver:[draggedFromWindow windowController] forKeyPath:@"isProcessing"];
[[[tabBarControl window] windowController] _updateProgressIndicatorForItem:tabViewItem];
}
+
+ // Check the window and move it to front if it's key (eg for new window creation)
+ if ([[tabBarControl window] isKeyWindow]) [[tabBarControl window] orderFront:self];
}
/**
@@ -348,6 +351,55 @@
[[aTabView window] close];
}
+- (BOOL)tabView:(NSTabView*)aTabView shouldDropTabViewItem:(NSTabViewItem *)tabViewItem inTabBar:(PSMTabBarControl *)tabBarControl
+{
+ return YES;
+}
+
+- (PSMTabBarControl *)tabView:(NSTabView *)aTabView newTabBarForDraggedTabViewItem:(NSTabViewItem *)tabViewItem atPoint:(NSPoint)point
+{
+
+ // Create the new window controller, with no tabs
+ SPWindowController *newWindowController = [[SPWindowController alloc] initWithWindowNibName:@"MainWindow"];
+ NSWindow *newWindow = [newWindowController window];
+
+ // Tweak window positioning according to the style and toolbar
+ point.x -= [[tabBar style] leftMarginForTabBarControl];
+ point.y += 21;
+
+ // Set the new window position and size
+ [newWindow setFrame:[[self window] frame] display:NO];
+ [newWindow setFrameTopLeftPoint:point];
+
+ // Set the window controller as the window's delegate
+ [newWindow setDelegate:newWindowController];
+
+ // Return the window's tab bar
+ return [newWindowController valueForKey:@"tabBar"];
+
+}
+
+- (NSImage *)tabView:(NSTabView *)aTabView imageForTabViewItem:(NSTabViewItem *)tabViewItem offset:(NSSize *)offset styleMask:(unsigned int *)styleMask
+{
+ NSImage *viewImage = [[NSImage alloc] init];
+
+ // Capture an image of the entire window
+ [[[self window] contentView] lockFocus];
+ NSBitmapImageRep *viewRep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:[[[self window] contentView] frame]] autorelease];
+ [viewImage addRepresentation:viewRep];
+ [[[self window] contentView] unlockFocus];
+
+ // Draw over the tab bar area
+ [viewImage lockFocus];
+ [[NSColor windowBackgroundColor] set];
+ NSRectFill([tabBar frame]);
+ [viewImage unlockFocus];
+
+ offset->height = 21;
+
+ return [viewImage autorelease];
+}
+
#pragma mark -
#pragma mark Window delegate methods