3 /*************************************************************************/
5 #pragma mark EVIL HACKERY
6 /*************************************************************************/
8 @interface NSTabViewItem (HACKHACKHACKHACK)
13 @implementation ITTabView
15 - (id)initWithFrame:(NSRect)frame
17 if ( (self = [super initWithFrame:frame]) ) {
24 - (void)setAllowsDragging:(bool)flag
26 _allowsDragging = flag;
29 - (bool)allowsDragging
31 return _allowsDragging;
34 - (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index
36 if ([self indexOfTabViewItem:tab] != index)
39 [self removeTabViewItem:tab];
40 [self insertTabViewItem:tab atIndex:index];
41 [self selectTabViewItem:tab];
45 - (void)mouseDown:(NSEvent *)event
47 if ([self allowsDragging]) {
48 NSPoint clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
49 NSTabViewItem *clickedTab = [self tabViewItemAtPoint:clickedPoint];
50 _draggedTab = clickedTab;
52 [super mouseDown:event];
55 - (void)mouseUp:(NSEvent *)event
57 if ([self allowsDragging]) {
58 NSPoint releasedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
59 NSTabViewItem *releasedTab = [self tabViewItemAtPoint:releasedPoint];
60 if (releasedTab && ![releasedTab isEqualTo:_draggedTab]) {
61 [self moveTab:_draggedTab toIndex:[self indexOfTabViewItem:releasedTab]];
65 [super mouseUp:event];
68 - (void)mouseDragged:(NSEvent *)event
70 if ([self allowsDragging]) {
71 NSPoint currentPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
72 NSTabViewItem *curTab = [self tabViewItemAtPoint:currentPoint];
73 if (curTab && ![curTab isEqualTo:_draggedTab]) {
74 [self moveTab:_draggedTab toIndex:[self indexOfTabViewItem:curTab]];
75 [self selectTabViewItem:_draggedTab];
78 [super mouseDragged:event];