2011-01-19 23:19:43 +03:00
|
|
|
//
|
|
|
|
// PSMTabDragWindow.m
|
|
|
|
// PSMTabBarControl
|
|
|
|
//
|
|
|
|
// Created by Kent Sutherland on 6/1/06.
|
|
|
|
// Copyright 2006 Kent Sutherland. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "PSMTabDragWindow.h"
|
|
|
|
#import "PSMTabDragView.h"
|
|
|
|
|
|
|
|
@implementation PSMTabDragWindow
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
+ (PSMTabDragWindow *)dragWindowWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask {
|
2011-01-19 23:19:43 +03:00
|
|
|
return [[[PSMTabDragWindow alloc] initWithImage:image styleMask:styleMask] autorelease];
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask {
|
2011-01-19 23:19:43 +03:00
|
|
|
NSSize size = [image size];
|
2011-01-26 13:52:13 +03:00
|
|
|
|
|
|
|
if((self = [super initWithContentRect:NSMakeRect(0, 0, size.width, size.height) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO])) {
|
2011-01-19 23:19:43 +03:00
|
|
|
_dragView = [[[PSMTabDragView alloc] initWithFrame:NSMakeRect(0, 0, size.width, size.height)] autorelease];
|
|
|
|
[self setContentView:_dragView];
|
|
|
|
[self setLevel:NSStatusWindowLevel];
|
|
|
|
[self setIgnoresMouseEvents:YES];
|
|
|
|
[self setOpaque:NO];
|
2011-01-26 13:52:13 +03:00
|
|
|
|
2011-01-19 23:19:43 +03:00
|
|
|
[_dragView setImage:image];
|
2011-01-26 13:52:13 +03:00
|
|
|
|
2011-01-19 23:19:43 +03:00
|
|
|
//Set the size of the window to be the exact size of the drag image
|
|
|
|
NSRect windowFrame = [self frame];
|
|
|
|
windowFrame.origin.y += windowFrame.size.height - size.height;
|
|
|
|
windowFrame.size = size;
|
2011-01-26 13:52:13 +03:00
|
|
|
|
|
|
|
if(styleMask | NSBorderlessWindowMask) {
|
2011-01-19 23:19:43 +03:00
|
|
|
windowFrame.size.height += 22;
|
|
|
|
}
|
2011-01-26 13:52:13 +03:00
|
|
|
|
2011-01-19 23:19:43 +03:00
|
|
|
[self setFrame:windowFrame display:YES];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:52:13 +03:00
|
|
|
- (PSMTabDragView *)dragView {
|
2011-01-19 23:19:43 +03:00
|
|
|
return _dragView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|