diff --git a/ChangeLog b/ChangeLog index 79e14d32f..9733732ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-09-10 Fred Kiefer + + * Source/NSTableHeaderView.m, + * Source/NSSlider.m, + * Source/NSProgressIndicator.m, + * Source/NSButton.m (-isFlipped): Add fliiping. + * Source/NSTableHeaderView.m (-drawRect:): Adjust for flipping. + * Source/NSTabView.m: Mark as needing an isFlipped method. + 2007-09-09 Fred Kiefer * Source/NSWindow.m (-makeKeyAndOrderFront:): Use diff --git a/Source/NSButton.m b/Source/NSButton.m index a6530a62f..232ed7193 100644 --- a/Source/NSButton.m +++ b/Source/NSButton.m @@ -81,6 +81,11 @@ static id buttonCellClass = nil; return YES; } +- (BOOL) isFlipped +{ + return YES; +} + /**

Sets the NSButtonCell's type to aType and marks self for display.See NSButtonType for more information.

See Also: [NSButtonCell-setButtonType:]

diff --git a/Source/NSProgressIndicator.m b/Source/NSProgressIndicator.m index b7e1e0249..90400e1ad 100644 --- a/Source/NSProgressIndicator.m +++ b/Source/NSProgressIndicator.m @@ -68,6 +68,11 @@ static NSColor *fillColour = nil; [super dealloc]; } +- (BOOL) isFlipped +{ + return YES; +} + - (void)animate:(id)sender { if (!_isIndeterminate) diff --git a/Source/NSSlider.m b/Source/NSSlider.m index c851c0083..83e1dc3cd 100644 --- a/Source/NSSlider.m +++ b/Source/NSSlider.m @@ -97,6 +97,11 @@ static Class cellClass; return self; } +- (BOOL) isFlipped +{ + return YES; +} + /**

Returns the value by which the slider will be incremented if the user holds down the ALT key.

See Also: -setAltIncrementValue:

*/ - (double) altIncrementValue diff --git a/Source/NSTabView.m b/Source/NSTabView.m index 311b63384..2e60687eb 100644 --- a/Source/NSTabView.m +++ b/Source/NSTabView.m @@ -16,7 +16,7 @@ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public @@ -75,6 +75,14 @@ [super dealloc]; } +/* +// FIXME: This should be defined +- (BOOL) isFlipped +{ + return YES; +} +*/ + // tab management. - (void) addTabViewItem: (NSTabViewItem*)tabViewItem @@ -83,7 +91,7 @@ } - (void) insertTabViewItem: (NSTabViewItem*)tabViewItem - atIndex: (int)index + atIndex: (int)index { [tabViewItem _setTabView: self]; [_items insertObject: tabViewItem atIndex: index]; @@ -143,8 +151,8 @@ - (int) indexOfTabViewItemWithIdentifier: (id)identifier { - unsigned howMany = [_items count]; - unsigned i; + unsigned howMany = [_items count]; + unsigned i; for (i = 0; i < howMany; i++) { @@ -214,7 +222,7 @@ @selector(tabView: shouldSelectTabViewItem:)]) { canSelect = [_delegate tabView: self - shouldSelectTabViewItem: tabViewItem]; + shouldSelectTabViewItem: tabViewItem]; } if (canSelect) @@ -225,16 +233,16 @@ { [_selected _setTabState: NSBackgroundTab]; - /* NB: If [_selected view] is nil this does nothing, which + /* NB: If [_selected view] is nil this does nothing, which is fine. */ - [[_selected view] removeFromSuperview]; - } + [[_selected view] removeFromSuperview]; + } if ([_delegate respondsToSelector: - @selector(tabView: willSelectTabViewItem:)]) - { - [_delegate tabView: self willSelectTabViewItem: tabViewItem]; - } + @selector(tabView: willSelectTabViewItem:)]) + { + [_delegate tabView: self willSelectTabViewItem: tabViewItem]; + } _selected = tabViewItem; _selected_item = [_items indexOfObject: _selected]; @@ -243,20 +251,20 @@ selectedView = [_selected view]; if (selectedView != nil) - { - [self addSubview: selectedView]; - [selectedView setFrame: [self contentRect]]; - [_window makeFirstResponder: [_selected initialFirstResponder]]; - } + { + [self addSubview: selectedView]; + [selectedView setFrame: [self contentRect]]; + [_window makeFirstResponder: [_selected initialFirstResponder]]; + } /* Will need to redraw tabs and content area. */ [self setNeedsDisplay: YES]; if ([_delegate respondsToSelector: - @selector(tabView: didSelectTabViewItem:)]) - { - [_delegate tabView: self didSelectTabViewItem: _selected]; - } + @selector(tabView: didSelectTabViewItem:)]) + { + [_delegate tabView: self didSelectTabViewItem: _selected]; + } } } @@ -277,7 +285,7 @@ - (void) takeSelectedTabViewItemFromSender: (id)sender { - int index = -1; + int index = -1; if ([sender respondsToSelector: @selector(indexOfSelectedItem)] == YES) { @@ -285,14 +293,14 @@ } else if ([sender isKindOfClass: [NSMatrix class]] == YES) { - int cols = [sender numberOfColumns]; - int row = [sender selectedRow]; - int col = [sender selectedColumn]; + int cols = [sender numberOfColumns]; + int row = [sender selectedRow]; + int col = [sender selectedColumn]; if (row >= 0 && col >= 0) - { - index = row * cols + col; - } + { + index = row * cols + col; + } } [self selectTabViewItemAtIndex: index]; } @@ -355,20 +363,20 @@ switch (_type) { case NSTopTabsBezelBorder: - return NSMakeSize(2, 19.5); + return NSMakeSize(2, 19.5); case NSNoTabsBezelBorder: - return NSMakeSize(2, 3); + return NSMakeSize(2, 3); case NSNoTabsLineBorder: - return NSMakeSize(2, 3); + return NSMakeSize(2, 3); case NSBottomTabsBezelBorder: - return NSMakeSize(2, 16); + return NSMakeSize(2, 16); case NSLeftTabsBezelBorder: - return NSMakeSize(16, 3); + return NSMakeSize(16, 3); case NSRightTabsBezelBorder: - return NSMakeSize(16, 3); + return NSMakeSize(16, 3); case NSNoTabsNoBorder: default: - return NSZeroSize; + return NSZeroSize; } } @@ -385,37 +393,37 @@ switch (_type) { case NSTopTabsBezelBorder: - cRect.origin.y += 1; - cRect.origin.x += 0.5; - cRect.size.width -= 2; - cRect.size.height -= 18.5; - break; + cRect.origin.y += 1; + cRect.origin.x += 0.5; + cRect.size.width -= 2; + cRect.size.height -= 18.5; + break; case NSNoTabsBezelBorder: - cRect.origin.y += 1; - cRect.origin.x += 0.5; - cRect.size.width -= 2; - cRect.size.height -= 2; - break; + cRect.origin.y += 1; + cRect.origin.x += 0.5; + cRect.size.width -= 2; + cRect.size.height -= 2; + break; case NSNoTabsLineBorder: - cRect.origin.y += 1; - cRect.origin.x += 0.5; - cRect.size.width -= 2; - cRect.size.height -= 2; - break; - case NSBottomTabsBezelBorder: - cRect.size.height -= 8; - cRect.origin.y = 8; - break; + cRect.origin.y += 1; + cRect.origin.x += 0.5; + cRect.size.width -= 2; + cRect.size.height -= 2; + break; + case NSBottomTabsBezelBorder: + cRect.size.height -= 8; + cRect.origin.y = 8; + break; case NSLeftTabsBezelBorder: - cRect.size.width -= 16; - cRect.origin.x += 16; - break; + cRect.size.width -= 16; + cRect.origin.x += 16; + break; case NSRightTabsBezelBorder: - cRect.size.width -= 16; - break; + cRect.size.width -= 16; + break; case NSNoTabsNoBorder: default: - break; + break; } return cRect; @@ -425,12 +433,12 @@ - (void) drawRect: (NSRect)rect { - NSGraphicsContext *ctxt = GSCurrentContext(); - GSTheme *theme = [GSTheme theme]; - int howMany = [_items count]; - int i; - int previousState = 0; - NSRect aRect = _bounds; + NSGraphicsContext *ctxt = GSCurrentContext(); + GSTheme *theme = [GSTheme theme]; + int howMany = [_items count]; + int i; + int previousState = 0; + NSRect aRect = _bounds; NSColor *lineColour = [NSColor highlightColor]; NSColor *backgroundColour = [[self window] backgroundColor]; BOOL truncate = [self allowsTruncatedLabels]; @@ -445,39 +453,39 @@ { default: case NSTopTabsBezelBorder: - aRect.size.height -= 16; - [theme drawButton: aRect withClip: rect]; - break; + aRect.size.height -= 16; + [theme drawButton: aRect withClip: rect]; + break; case NSBottomTabsBezelBorder: - aRect.size.height -= 16; - aRect.origin.y += 16; - [theme drawButton: aRect withClip: rect]; - aRect.origin.y -= 16; - break; + aRect.size.height -= 16; + aRect.origin.y += 16; + [theme drawButton: aRect withClip: rect]; + aRect.origin.y -= 16; + break; case NSLeftTabsBezelBorder: - aRect.size.width -= 18; - aRect.origin.x += 18; - [theme drawButton: aRect withClip: rect]; - break; + aRect.size.width -= 18; + aRect.origin.x += 18; + [theme drawButton: aRect withClip: rect]; + break; case NSRightTabsBezelBorder: - aRect.size.width -= 18; - [theme drawButton: aRect withClip: rect]; - break; + aRect.size.width -= 18; + [theme drawButton: aRect withClip: rect]; + break; case NSNoTabsBezelBorder: - [theme drawButton: aRect withClip: rect]; - break; + [theme drawButton: aRect withClip: rect]; + break; case NSNoTabsLineBorder: - [[NSColor controlDarkShadowColor] set]; - NSFrameRect(aRect); - break; + [[NSColor controlDarkShadowColor] set]; + NSFrameRect(aRect); + break; case NSNoTabsNoBorder: - break; + break; } if (_type == NSBottomTabsBezelBorder) @@ -486,119 +494,119 @@ iP.x = _bounds.origin.x; iP.y = _bounds.origin.y; - + for (i = 0; i < howMany; i++) - { - NSRect r; - NSRect fRect; - NSTabViewItem *anItem = [_items objectAtIndex: i]; - NSTabState itemState = [anItem tabState]; - NSSize s = [anItem sizeOfLabel: truncate]; - - [backgroundColour set]; + { + NSRect r; + NSRect fRect; + NSTabViewItem *anItem = [_items objectAtIndex: i]; + NSTabState itemState = [anItem tabState]; + NSSize s = [anItem sizeOfLabel: truncate]; + + [backgroundColour set]; - if (i == 0) - { - if (itemState == NSSelectedTab) - { - iP.y += 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabDownSelectedLeft"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y -= 1; - } - else if (itemState == NSBackgroundTab) - { - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabDownUnSelectedLeft"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - } - else - NSLog(@"Not finished yet. Luff ya.\n"); - } - else - { - if (itemState == NSSelectedTab) - { - iP.y += 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: - @"common_TabDownUnSelectedToSelectedJunction"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y -= 1; - } - else if (itemState == NSBackgroundTab) - { - if (previousState == NSSelectedTab) - { - iP.y += 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: - @"common_TabDownSelectedToUnSelectedJunction"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y -= 1; - } - else - { - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: - @"common_TabDownUnSelectedJunction"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - } - } - else - NSLog(@"Not finished yet. Luff ya.\n"); - } + if (i == 0) + { + if (itemState == NSSelectedTab) + { + iP.y += 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabDownSelectedLeft"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y -= 1; + } + else if (itemState == NSBackgroundTab) + { + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabDownUnSelectedLeft"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + } + else + NSLog(@"Not finished yet. Luff ya.\n"); + } + else + { + if (itemState == NSSelectedTab) + { + iP.y += 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: + @"common_TabDownUnSelectedToSelectedJunction"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y -= 1; + } + else if (itemState == NSBackgroundTab) + { + if (previousState == NSSelectedTab) + { + iP.y += 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: + @"common_TabDownSelectedToUnSelectedJunction"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y -= 1; + } + else + { + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: + @"common_TabDownUnSelectedJunction"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + } + } + else + NSLog(@"Not finished yet. Luff ya.\n"); + } - r.origin.x = iP.x + 13; - r.origin.y = iP.y + 2; - r.size.width = s.width; - r.size.height = 15; + r.origin.x = iP.x + 13; + r.origin.y = iP.y + 2; + r.size.width = s.width; + r.size.height = 15; - fRect = r; - if (itemState == NSSelectedTab) - { - // Undraw the line that separates the tab from its view. - fRect.origin.y += 1; - fRect.size.height += 1; - } - NSRectFill(fRect); + fRect = r; + if (itemState == NSSelectedTab) + { + // Undraw the line that separates the tab from its view. + fRect.origin.y += 1; + fRect.size.height += 1; + } + NSRectFill(fRect); - // Draw the line at the bottom of the item - [lineColour set]; - DPSsetlinewidth(ctxt, 1); - DPSmoveto(ctxt, r.origin.x, r.origin.y - 1); - DPSrlineto(ctxt, r.size.width, 0); - DPSstroke(ctxt); - - // Label - [anItem drawLabel: truncate inRect: r]; - - iP.x += s.width + 13; - previousState = itemState; + // Draw the line at the bottom of the item + [lineColour set]; + DPSsetlinewidth(ctxt, 1); + DPSmoveto(ctxt, r.origin.x, r.origin.y - 1); + DPSrlineto(ctxt, r.size.width, 0); + DPSstroke(ctxt); + + // Label + [anItem drawLabel: truncate inRect: r]; + + iP.x += s.width + 13; + previousState = itemState; - if (i == howMany - 1) - { - [backgroundColour set]; + if (i == howMany - 1) + { + [backgroundColour set]; - if ([anItem tabState] == NSSelectedTab) - { - iP.y += 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabDownSelectedRight"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y -= 1; - } - else if ([anItem tabState] == NSBackgroundTab) - { - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabDownUnSelectedRight"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - } - else - NSLog(@"Not finished yet. Luff ya.\n"); - } - } + if ([anItem tabState] == NSSelectedTab) + { + iP.y += 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabDownSelectedRight"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y -= 1; + } + else if ([anItem tabState] == NSBackgroundTab) + { + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabDownUnSelectedRight"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + } + else + NSLog(@"Not finished yet. Luff ya.\n"); + } + } } else if (_type == NSTopTabsBezelBorder) { @@ -609,117 +617,117 @@ iP.y = _bounds.size.height - 16; for (i = 0; i < howMany; i++) - { - NSRect r; - NSRect fRect; - NSTabViewItem *anItem = [_items objectAtIndex: i]; - NSTabState itemState = [anItem tabState]; - NSSize s = [anItem sizeOfLabel: truncate]; + { + NSRect r; + NSRect fRect; + NSTabViewItem *anItem = [_items objectAtIndex: i]; + NSTabState itemState = [anItem tabState]; + NSSize s = [anItem sizeOfLabel: truncate]; - [backgroundColour set]; - - if (i == 0) - { - if (itemState == NSSelectedTab) - { - iP.y -= 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabSelectedLeft"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y += 1; - } - else if (itemState == NSBackgroundTab) - { - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabUnSelectedLeft"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - } - else - NSLog(@"Not finished yet. Luff ya.\n"); - } - else - { - if (itemState == NSSelectedTab) - { - iP.y -= 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: - @"common_TabUnSelectToSelectedJunction"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y += 1; - } - else if (itemState == NSBackgroundTab) - { - if (previousState == NSSelectedTab) - { - iP.y -= 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: - @"common_TabSelectedToUnSelectedJunction"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y += 1; - } - else - { - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: - @"common_TabUnSelectedJunction"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - } - } - else - NSLog(@"Not finished yet. Luff ya.\n"); - } + [backgroundColour set]; + + if (i == 0) + { + if (itemState == NSSelectedTab) + { + iP.y -= 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabSelectedLeft"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y += 1; + } + else if (itemState == NSBackgroundTab) + { + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabUnSelectedLeft"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + } + else + NSLog(@"Not finished yet. Luff ya.\n"); + } + else + { + if (itemState == NSSelectedTab) + { + iP.y -= 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: + @"common_TabUnSelectToSelectedJunction"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y += 1; + } + else if (itemState == NSBackgroundTab) + { + if (previousState == NSSelectedTab) + { + iP.y -= 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: + @"common_TabSelectedToUnSelectedJunction"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y += 1; + } + else + { + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: + @"common_TabUnSelectedJunction"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + } + } + else + NSLog(@"Not finished yet. Luff ya.\n"); + } - r.origin.x = iP.x + 13; - r.origin.y = iP.y; - r.size.width = s.width; - r.size.height = 15; - - fRect = r; - if (itemState == NSSelectedTab) - { - // Undraw the line that separates the tab from its view. - fRect.origin.y -= 1; - fRect.size.height += 1; - } - NSRectFill(fRect); + r.origin.x = iP.x + 13; + r.origin.y = iP.y; + r.size.width = s.width; + r.size.height = 15; + + fRect = r; + if (itemState == NSSelectedTab) + { + // Undraw the line that separates the tab from its view. + fRect.origin.y -= 1; + fRect.size.height += 1; + } + NSRectFill(fRect); - // Draw the line at the top of the item - [lineColour set]; - DPSsetlinewidth(ctxt, 1); - DPSmoveto(ctxt, r.origin.x, r.origin.y + 16); - DPSrlineto(ctxt, r.size.width, 0); - DPSstroke(ctxt); - - // Label - [anItem drawLabel: truncate inRect: r]; - - iP.x += s.width + 13; - previousState = itemState; + // Draw the line at the top of the item + [lineColour set]; + DPSsetlinewidth(ctxt, 1); + DPSmoveto(ctxt, r.origin.x, r.origin.y + 16); + DPSrlineto(ctxt, r.size.width, 0); + DPSstroke(ctxt); + + // Label + [anItem drawLabel: truncate inRect: r]; + + iP.x += s.width + 13; + previousState = itemState; - if (i == howMany - 1) - { - [backgroundColour set]; - - if ([anItem tabState] == NSSelectedTab) - { - iP.y -= 1; - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabSelectedRight"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - iP.y += 1; - } - else if ([anItem tabState] == NSBackgroundTab) - { - NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); - [[NSImage imageNamed: @"common_TabUnSelectedRight"] - compositeToPoint: iP operation: NSCompositeSourceOver]; - } - else - NSLog(@"Not finished yet. Luff ya.\n"); - } - } + if (i == howMany - 1) + { + [backgroundColour set]; + + if ([anItem tabState] == NSSelectedTab) + { + iP.y -= 1; + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabSelectedRight"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + iP.y += 1; + } + else if ([anItem tabState] == NSBackgroundTab) + { + NSRectFill(NSMakeRect(iP.x, iP.y, 14, 17)); + [[NSImage imageNamed: @"common_TabUnSelectedRight"] + compositeToPoint: iP operation: NSCompositeSourceOver]; + } + else + NSLog(@"Not finished yet. Luff ya.\n"); + } + } } // FIXME: Missing drawing code for other cases @@ -747,7 +755,7 @@ NSTabViewItem *anItem = [_items objectAtIndex: i]; if (NSPointInRect(point, [anItem _tabRect])) - return anItem; + return anItem; } return nil; @@ -756,7 +764,7 @@ - (void) mouseDown: (NSEvent *)theEvent { NSPoint location = [self convertPoint: [theEvent locationInWindow] - fromView: nil]; + fromView: nil]; NSTabViewItem *anItem = [self tabViewItemAtPoint: location]; if (anItem != nil && ![anItem isEqual: _selected]) @@ -830,35 +838,35 @@ { if ([aDecoder containsValueForKey: @"NSAllowTruncatedLabels"]) { - [self setAllowsTruncatedLabels: [aDecoder decodeBoolForKey: - @"NSAllowTruncatedLabels"]]; - } + [self setAllowsTruncatedLabels: [aDecoder decodeBoolForKey: + @"NSAllowTruncatedLabels"]]; + } if ([aDecoder containsValueForKey: @"NSDrawsBackground"]) { - [self setDrawsBackground: [aDecoder decodeBoolForKey: - @"NSDrawsBackground"]]; - } + [self setDrawsBackground: [aDecoder decodeBoolForKey: + @"NSDrawsBackground"]]; + } if ([aDecoder containsValueForKey: @"NSFont"]) { - [self setFont: [aDecoder decodeObjectForKey: @"NSFont"]]; - } + [self setFont: [aDecoder decodeObjectForKey: @"NSFont"]]; + } if ([aDecoder containsValueForKey: @"NSTabViewItems"]) { - ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSTabViewItems"]); - } + ASSIGN(_items, [aDecoder decodeObjectForKey: @"NSTabViewItems"]); + } if ([aDecoder containsValueForKey: @"NSSelectedTabViewItem"]) { - [self selectTabViewItem: [aDecoder decodeObjectForKey: - @"NSSelectedTabViewItem"]]; - } + [self selectTabViewItem: [aDecoder decodeObjectForKey: + @"NSSelectedTabViewItem"]]; + } if ([aDecoder containsValueForKey: @"NSTvFlags"]) { - int vFlags = [aDecoder decodeIntForKey: @"NSTvFlags"]; + int vFlags = [aDecoder decodeIntForKey: @"NSTvFlags"]; - [self setControlTint: ((vFlags & 0x70000000) >> 28)]; - [self setControlSize: ((vFlags & 0x0c000000) >> 26)]; - [self setTabViewType: (vFlags & 0x00000007)]; - } + [self setControlTint: ((vFlags & 0x70000000) >> 28)]; + [self setControlSize: ((vFlags & 0x0c000000) >> 26)]; + [self setTabViewType: (vFlags & 0x00000007)]; + } } else { @@ -869,33 +877,33 @@ [aDecoder decodeValueOfObjCType: @encode(NSTabViewType) at: &_type]; if (version < 2) { - switch(_type) - { - case 0: - _type = NSTopTabsBezelBorder; - break; - case 5: - _type = NSLeftTabsBezelBorder; - break; - case 1: - _type = NSBottomTabsBezelBorder; - break; - case 6: - _type = NSRightTabsBezelBorder; - break; - case 2: - _type = NSNoTabsBezelBorder; - break; - case 3: - _type = NSNoTabsLineBorder; - break; - case 4: - _type = NSNoTabsNoBorder; - break; - default: - break; - } - } + switch(_type) + { + case 0: + _type = NSTopTabsBezelBorder; + break; + case 5: + _type = NSLeftTabsBezelBorder; + break; + case 1: + _type = NSBottomTabsBezelBorder; + break; + case 6: + _type = NSRightTabsBezelBorder; + break; + case 2: + _type = NSNoTabsBezelBorder; + break; + case 3: + _type = NSNoTabsLineBorder; + break; + case 4: + _type = NSNoTabsNoBorder; + break; + default: + break; + } + } [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_draws_background]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_truncated_label]; _delegate = [aDecoder decodeObject]; diff --git a/Source/NSTableHeaderView.m b/Source/NSTableHeaderView.m index 1e04927d8..23a393316 100644 --- a/Source/NSTableHeaderView.m +++ b/Source/NSTableHeaderView.m @@ -19,7 +19,7 @@ This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public @@ -44,7 +44,7 @@ @interface NSTableView (GNUstepPrivate) - (void) _userResizedTableColumn: (int)index - width: (float)width; + width: (float)width; - (float *) _columnOrigins; - (void) _mouseDownInHeaderOfTableColumn: (NSTableColumn *)tc; - (void) _didClickTableColumn: (NSTableColumn *)tc; @@ -81,6 +81,12 @@ _resizedColumn = -1; return self; } + +- (BOOL) isFlipped +{ + return YES; +} + /* * Setting the table view */ @@ -161,17 +167,20 @@ return; firstColumnToDraw = [self columnAtPoint: NSMakePoint (aRect.origin.x, - aRect.origin.y)]; + aRect.origin.y)]; if (firstColumnToDraw == -1) firstColumnToDraw = 0; lastColumnToDraw = [self columnAtPoint: NSMakePoint (NSMaxX (aRect), - aRect.origin.y)]; + aRect.origin.y)]; if (lastColumnToDraw == -1) lastColumnToDraw = [_tableView numberOfColumns] - 1; drawingRect = [self headerRectOfColumn: firstColumnToDraw]; - drawingRect.origin.y++; + if ([self isFlipped]) + { + drawingRect.origin.y++; + } drawingRect.size.height--; columns = [_tableView tableColumns]; @@ -184,16 +193,16 @@ drawingRect.size.width = width; cell = [column headerCell]; if ((column == highlightedTableColumn) - || [_tableView isColumnSelected: i]) - { - [cell setHighlighted: YES]; - } + || [_tableView isColumnSelected: i]) + { + [cell setHighlighted: YES]; + } else - { - [cell setHighlighted: NO]; - } + { + [cell setHighlighted: NO]; + } [cell drawWithFrame: drawingRect - inView: self]; + inView: self]; drawingRect.origin.x += width; } if (lastColumnToDraw == [_tableView numberOfColumns] - 1) @@ -203,16 +212,16 @@ drawingRect.size.width = width; cell = [column headerCell]; if ((column == highlightedTableColumn) - || [_tableView isColumnSelected: lastColumnToDraw]) - { - [cell setHighlighted: YES]; - } + || [_tableView isColumnSelected: lastColumnToDraw]) + { + [cell setHighlighted: YES]; + } else - { - [cell setHighlighted: NO]; - } + { + [cell setHighlighted: NO]; + } [cell drawWithFrame: drawingRect - inView: self]; + inView: self]; drawingRect.origin.x += width; } else @@ -222,25 +231,32 @@ drawingRect.size.width = width; cell = [column headerCell]; if ((column == highlightedTableColumn) - || [_tableView isColumnSelected: lastColumnToDraw]) - { - [cell setHighlighted: YES]; - } + || [_tableView isColumnSelected: lastColumnToDraw]) + { + [cell setHighlighted: YES]; + } else - { - [cell setHighlighted: NO]; - } + { + [cell setHighlighted: NO]; + } [cell drawWithFrame: drawingRect - inView: self]; + inView: self]; drawingRect.origin.x += width; } - { NSRectEdge up_sides[] = {NSMinYEdge, NSMaxXEdge}; + NSRectEdge dn_sides[] = {NSMaxYEdge, NSMaxXEdge}; float grays[] = {NSBlack, NSBlack}; - NSDrawTiledRects(_bounds, aRect, up_sides, grays, 2); + if ([self isFlipped]) + { + NSDrawTiledRects(_bounds, aRect, up_sides, grays, 2); + } + else + { + NSDrawTiledRects(_bounds, aRect, dn_sides, grays, 2); + } } } @@ -268,7 +284,7 @@ return; } currentColumn = [[_tableView tableColumns] - objectAtIndex: columnIndex]; + objectAtIndex: columnIndex]; if (clickCount == 2) @@ -283,573 +299,573 @@ /* Safety check */ if (_resizedColumn != -1) - { - NSLog (@"Bug: starting resizing of column while already resizing!"); - _resizedColumn = -1; - } + { + NSLog (@"Bug: starting resizing of column while already resizing!"); + _resizedColumn = -1; + } if ([_tableView allowsColumnResizing]) - { - /* Start resizing if the mouse is down on the bounds of a column. */ - - if (location.x >= NSMaxX (rect) - 1) - { - if (columnIndex != ([_tableView numberOfColumns])) - { - _resizedColumn = columnIndex; - } - else - { - NSLog(@"ohoh"); - } - } - else if (location.x <= NSMinX (rect) + 2) - { - if (columnIndex > 0) - { - _resizedColumn = columnIndex - 1; - } - } - } + { + /* Start resizing if the mouse is down on the bounds of a column. */ + + if (location.x >= NSMaxX (rect) - 1) + { + if (columnIndex != ([_tableView numberOfColumns])) + { + _resizedColumn = columnIndex; + } + else + { + NSLog(@"ohoh"); + } + } + else if (location.x <= NSMinX (rect) + 2) + { + if (columnIndex > 0) + { + _resizedColumn = columnIndex - 1; + } + } + } /* Resizing */ if (_resizedColumn != -1) - { - /* Width of the highlighted area. */ - const float divWidth = 4; - /* Dragging limits */ - float minCoord; - float maxCoord; - float minAbsCoord; - float maxAbsCoord; - float minVisCoord; - float maxVisCoord; - NSRect tvRect; - NSPoint unconverted; - NSArray *columns; - /* Column on the left of resizing bound */ - NSTableColumn *column; - NSRect rectLow = [self headerRectOfColumn: _resizedColumn]; - /* Old highlighted rect, used to avoid useless redrawing */ - NSRect oldRect = NSZeroRect; - /* Current highlighted rect */ - NSRect r; - /* Mouse position */ - float p; - float q; - BOOL outside = NO; - /* YES if some highlighting was done and needs to be undone */ - BOOL lit = NO; - /* YES if some dragging was actually done - to avoid - retiling/redrawing the table if no dragging is done */ - BOOL dragged = NO; - NSEvent *e; - NSDate *farAway = [NSDate distantFuture]; - unsigned int eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask - | NSPeriodicMask; + { + /* Width of the highlighted area. */ + const float divWidth = 4; + /* Dragging limits */ + float minCoord; + float maxCoord; + float minAbsCoord; + float maxAbsCoord; + float minVisCoord; + float maxVisCoord; + NSRect tvRect; + NSPoint unconverted; + NSArray *columns; + /* Column on the left of resizing bound */ + NSTableColumn *column; + NSRect rectLow = [self headerRectOfColumn: _resizedColumn]; + /* Old highlighted rect, used to avoid useless redrawing */ + NSRect oldRect = NSZeroRect; + /* Current highlighted rect */ + NSRect r; + /* Mouse position */ + float p; + float q; + BOOL outside = NO; + /* YES if some highlighting was done and needs to be undone */ + BOOL lit = NO; + /* YES if some dragging was actually done - to avoid + retiling/redrawing the table if no dragging is done */ + BOOL dragged = NO; + NSEvent *e; + NSDate *farAway = [NSDate distantFuture]; + unsigned int eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask + | NSPeriodicMask; - /* Determine dragging limits, constrained to visible rect */ - rect = [self visibleRect]; - minVisCoord = MAX (NSMinX (rectLow), NSMinX (rect)) + divWidth; - maxVisCoord = NSMaxX (rect) - divWidth; - - /* Then constrain to minimum and maximum column width if any */ - columns = [_tableView tableColumns]; - /* Column at the left */ - column = [columns objectAtIndex: _resizedColumn]; - if ([column isResizable] == NO) - { - _resizedColumn = -1; - return; - } - /* We use p as a temporary variable for a while */ - minAbsCoord = NSMinX (rectLow) + [column minWidth]; - maxAbsCoord = NSMinX (rectLow) + [column maxWidth]; - minCoord = MAX (minAbsCoord, minVisCoord); - maxCoord = MIN (maxAbsCoord, maxVisCoord); - + /* Determine dragging limits, constrained to visible rect */ + rect = [self visibleRect]; + minVisCoord = MAX (NSMinX (rectLow), NSMinX (rect)) + divWidth; + maxVisCoord = NSMaxX (rect) - divWidth; + + /* Then constrain to minimum and maximum column width if any */ + columns = [_tableView tableColumns]; + /* Column at the left */ + column = [columns objectAtIndex: _resizedColumn]; + if ([column isResizable] == NO) + { + _resizedColumn = -1; + return; + } + /* We use p as a temporary variable for a while */ + minAbsCoord = NSMinX (rectLow) + [column minWidth]; + maxAbsCoord = NSMinX (rectLow) + [column maxWidth]; + minCoord = MAX (minAbsCoord, minVisCoord); + maxCoord = MIN (maxAbsCoord, maxVisCoord); + - /* Do we need to check that we already fit into this area ? - We should */ + /* Do we need to check that we already fit into this area ? + We should */ - [self lockFocus]; - - [[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode]; - - [[NSColor lightGrayColor] set]; - r.size.width = divWidth; - r.size.height = NSHeight (rect); - r.origin.y = NSMinY (rect); - - [NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05]; - e = [NSApp nextEventMatchingMask: eventMask - untilDate: farAway - inMode: NSEventTrackingRunLoopMode - dequeue: YES]; + [self lockFocus]; + + [[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode]; + + [[NSColor lightGrayColor] set]; + r.size.width = divWidth; + r.size.height = NSHeight (rect); + r.origin.y = NSMinY (rect); + + [NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05]; + e = [NSApp nextEventMatchingMask: eventMask + untilDate: farAway + inMode: NSEventTrackingRunLoopMode + dequeue: YES]; - /* Safety assignment to make sure p is never left - unitialized - should make no difference with current code - but anyway */ - p = NSMaxX (rectLow); + /* Safety assignment to make sure p is never left + unitialized - should make no difference with current code + but anyway */ + p = NSMaxX (rectLow); - while ([e type] != NSLeftMouseUp) - { - if ([e type] != NSPeriodic) - { - dragged = YES; - unconverted = [e locationInWindow]; - p = [self convertPoint: unconverted fromView: nil].x; - q = p; - if (p > maxVisCoord || p < minVisCoord) - { - outside = YES; - } - else - { - outside = NO; - } - if (p < minCoord) - { - p = minCoord; - } - else if (p > maxCoord) - { - p = maxCoord; - } - r.origin.x = p - (divWidth / 2.); - - if (!outside && NSEqualRects(r, oldRect) == NO) - { - if (lit == YES) - { - NSHighlightRect (oldRect); - } - NSHighlightRect (r); - [_window flushWindow]; - lit = YES; - oldRect = r; - } - } - else - { - if (outside) - { - q = [self convertPoint: unconverted - fromView: nil].x; - if (lit) - { - NSHighlightRect (oldRect); - [_window flushWindow]; - lit = NO; - } - tvRect = [_tableView visibleRect]; - if (q > maxVisCoord) - { - if (q > maxAbsCoord + 5) - q = maxAbsCoord + 5; - tvRect.origin.x += (q - maxVisCoord)/2; - } - else if (q < minVisCoord) - { - if (q < minAbsCoord - 5) - q = minAbsCoord - 5; - tvRect.origin.x += (q - minVisCoord)/2; - } - else // TODO remove this condition - { - NSLog(@"not outside !"); - } - [_tableView scrollPoint: tvRect.origin]; - rect = [self visibleRect]; - minVisCoord = NSMinX (rect) + divWidth; - maxVisCoord = NSMaxX (rect) - divWidth; - minCoord = MAX (minAbsCoord, minVisCoord); - maxCoord = MIN (maxAbsCoord, maxVisCoord); - } - } - e = [NSApp nextEventMatchingMask: eventMask - untilDate: farAway - inMode: NSEventTrackingRunLoopMode - dequeue: YES]; - } - [NSEvent stopPeriodicEvents]; - if (outside) - { - p = [self convertPoint: [e locationInWindow] fromView: nil].x; - if (p > maxAbsCoord) - p = maxAbsCoord; - else if (p < minAbsCoord) - p = minAbsCoord; - } - if (lit == YES) - { - NSHighlightRect(oldRect); - [_window flushWindow]; - } + while ([e type] != NSLeftMouseUp) + { + if ([e type] != NSPeriodic) + { + dragged = YES; + unconverted = [e locationInWindow]; + p = [self convertPoint: unconverted fromView: nil].x; + q = p; + if (p > maxVisCoord || p < minVisCoord) + { + outside = YES; + } + else + { + outside = NO; + } + if (p < minCoord) + { + p = minCoord; + } + else if (p > maxCoord) + { + p = maxCoord; + } + r.origin.x = p - (divWidth / 2.); + + if (!outside && NSEqualRects(r, oldRect) == NO) + { + if (lit == YES) + { + NSHighlightRect (oldRect); + } + NSHighlightRect (r); + [_window flushWindow]; + lit = YES; + oldRect = r; + } + } + else + { + if (outside) + { + q = [self convertPoint: unconverted + fromView: nil].x; + if (lit) + { + NSHighlightRect (oldRect); + [_window flushWindow]; + lit = NO; + } + tvRect = [_tableView visibleRect]; + if (q > maxVisCoord) + { + if (q > maxAbsCoord + 5) + q = maxAbsCoord + 5; + tvRect.origin.x += (q - maxVisCoord)/2; + } + else if (q < minVisCoord) + { + if (q < minAbsCoord - 5) + q = minAbsCoord - 5; + tvRect.origin.x += (q - minVisCoord)/2; + } + else // TODO remove this condition + { + NSLog(@"not outside !"); + } + [_tableView scrollPoint: tvRect.origin]; + rect = [self visibleRect]; + minVisCoord = NSMinX (rect) + divWidth; + maxVisCoord = NSMaxX (rect) - divWidth; + minCoord = MAX (minAbsCoord, minVisCoord); + maxCoord = MIN (maxAbsCoord, maxVisCoord); + } + } + e = [NSApp nextEventMatchingMask: eventMask + untilDate: farAway + inMode: NSEventTrackingRunLoopMode + dequeue: YES]; + } + [NSEvent stopPeriodicEvents]; + if (outside) + { + p = [self convertPoint: [e locationInWindow] fromView: nil].x; + if (p > maxAbsCoord) + p = maxAbsCoord; + else if (p < minAbsCoord) + p = minAbsCoord; + } + if (lit == YES) + { + NSHighlightRect(oldRect); + [_window flushWindow]; + } - [self unlockFocus]; + [self unlockFocus]; - /* The following tiles the table. We use a private method - which avoids tiling the table twice. */ - if (dragged == YES) - { - [_tableView _userResizedTableColumn: _resizedColumn - width: (p - NSMinX (rectLow))]; - } + /* The following tiles the table. We use a private method + which avoids tiling the table twice. */ + if (dragged == YES) + { + [_tableView _userResizedTableColumn: _resizedColumn + width: (p - NSMinX (rectLow))]; + } - /* Clean up */ - _resizedColumn = -1; - return; - } + /* Clean up */ + _resizedColumn = -1; + return; + } /* We are not resizing - Let's launch a mouseDownInHeaderOfTableColumn message + Let's launch a mouseDownInHeaderOfTableColumn message */ { - NSRect rect = [self headerRectOfColumn: columnIndex]; - [_tableView _mouseDownInHeaderOfTableColumn: - [[_tableView tableColumns] - objectAtIndex: columnIndex]]; - rect.origin.y++; - rect.size.height--; - [[currentColumn headerCell] setHighlighted: YES]; + NSRect rect = [self headerRectOfColumn: columnIndex]; + [_tableView _mouseDownInHeaderOfTableColumn: + [[_tableView tableColumns] + objectAtIndex: columnIndex]]; + rect.origin.y++; + rect.size.height--; + [[currentColumn headerCell] setHighlighted: YES]; - [self lockFocus]; - [[currentColumn headerCell] - highlight: YES - withFrame: rect - inView: self]; - [self unlockFocus]; - [_window flushWindow]; + [self lockFocus]; + [[currentColumn headerCell] + highlight: YES + withFrame: rect + inView: self]; + [self unlockFocus]; + [_window flushWindow]; } /* Dragging */ /* Wait for mouse dragged events. - If mouse is dragged, move the column. - If mouse is not dragged but released, select/deselect the column. */ + If mouse is dragged, move the column. + If mouse is not dragged but released, select/deselect the column. */ if ([_tableView allowsColumnReordering]) - { - int i = columnIndex; - int j = columnIndex; - float minCoord; - float maxCoord; - float minVisCoord; - float maxVisCoord; - float *_cO; - float *_cO_minus1; - int numberOfColumns = [_tableView numberOfColumns]; - unsigned int eventMask = (NSLeftMouseUpMask - | NSLeftMouseDraggedMask - | NSPeriodicMask); - unsigned int modifiers = [event modifierFlags]; - NSEvent *e; - NSDate *distantFuture = [NSDate distantFuture]; - NSRect visibleRect = [self visibleRect]; - NSRect tvRect; - NSRect highlightRect = NSZeroRect, oldRect = NSZeroRect; - BOOL outside = NO; - BOOL lit = NO; - - BOOL mouseDragged = NO; - float p; - NSPoint unconverted; - minVisCoord = NSMinX (visibleRect); - maxVisCoord = NSMaxX (visibleRect); - { - NSRect bounds = [self bounds]; - minCoord = NSMinX(bounds); - maxCoord = NSMaxX(bounds); - } - { - float *_c = [_tableView _columnOrigins]; - _cO_minus1 = malloc((numberOfColumns + 3) * sizeof(float)); - _cO = _cO_minus1 + 1; - memcpy(_cO, _c, numberOfColumns * sizeof(float)); - _cO[numberOfColumns] = maxCoord; - _cO[numberOfColumns + 1] = maxCoord; - _cO[-1] = minCoord; - } + { + int i = columnIndex; + int j = columnIndex; + float minCoord; + float maxCoord; + float minVisCoord; + float maxVisCoord; + float *_cO; + float *_cO_minus1; + int numberOfColumns = [_tableView numberOfColumns]; + unsigned int eventMask = (NSLeftMouseUpMask + | NSLeftMouseDraggedMask + | NSPeriodicMask); + unsigned int modifiers = [event modifierFlags]; + NSEvent *e; + NSDate *distantFuture = [NSDate distantFuture]; + NSRect visibleRect = [self visibleRect]; + NSRect tvRect; + NSRect highlightRect = NSZeroRect, oldRect = NSZeroRect; + BOOL outside = NO; + BOOL lit = NO; + + BOOL mouseDragged = NO; + float p; + NSPoint unconverted; + minVisCoord = NSMinX (visibleRect); + maxVisCoord = NSMaxX (visibleRect); + { + NSRect bounds = [self bounds]; + minCoord = NSMinX(bounds); + maxCoord = NSMaxX(bounds); + } + { + float *_c = [_tableView _columnOrigins]; + _cO_minus1 = malloc((numberOfColumns + 3) * sizeof(float)); + _cO = _cO_minus1 + 1; + memcpy(_cO, _c, numberOfColumns * sizeof(float)); + _cO[numberOfColumns] = maxCoord; + _cO[numberOfColumns + 1] = maxCoord; + _cO[-1] = minCoord; + } - highlightRect.size.height = NSHeight (visibleRect); - highlightRect.origin.y = NSMinY (visibleRect); + highlightRect.size.height = NSHeight (visibleRect); + highlightRect.origin.y = NSMinY (visibleRect); - [self lockFocus]; - [[NSColor lightGrayColor] set]; - [NSEvent startPeriodicEventsAfterDelay: 0.05 - withPeriod: 0.05]; - e = [NSApp nextEventMatchingMask: eventMask - untilDate: distantFuture - inMode: NSEventTrackingRunLoopMode - dequeue: YES]; + [self lockFocus]; + [[NSColor lightGrayColor] set]; + [NSEvent startPeriodicEventsAfterDelay: 0.05 + withPeriod: 0.05]; + e = [NSApp nextEventMatchingMask: eventMask + untilDate: distantFuture + inMode: NSEventTrackingRunLoopMode + dequeue: YES]; - while ([e type] != NSLeftMouseUp) - { - switch ([e type]) - { - case NSLeftMouseDragged: - unconverted = [e locationInWindow]; - p = [self convertPoint: unconverted fromView: nil].x; - if (mouseDragged == NO) - { - NSLog(@"TODO: Deselect the column"); - } - mouseDragged = YES; - if (p < minVisCoord || p > maxVisCoord) - { - outside = YES; - } - else - { - outside = NO; - i = j; - if (p > (_cO[i] + _cO[i+1]) / 2) - { - while (p > (_cO[i] + _cO[i+1]) / 2) - i++; - } - else if (p < (_cO[i] + _cO[i-1]) / 2) - { - while (p < (_cO[i] + _cO[i-1]) / 2) - i--; - } - if (i != columnIndex - && i != columnIndex + 1) - { - j = i; - highlightRect.size.height = NSHeight (visibleRect); - highlightRect.origin.y = NSMinY (visibleRect); - highlightRect.size.width = 7; - if (i == numberOfColumns) - { - highlightRect.origin.x = _cO[i] - 3; - } - else if (i == 0) - { - highlightRect.origin.x = _cO[i] - 3; - } - else - { - highlightRect.origin.x = _cO[i] - 3; - } - if (!NSEqualRects(highlightRect, oldRect)) - { - if (lit) - NSHighlightRect(oldRect); - NSHighlightRect(highlightRect); - [_window flushWindow]; - } - else if (!lit) - { - NSHighlightRect(highlightRect); - [_window flushWindow]; - } - oldRect = highlightRect; - lit = YES; - } - else - { - i = columnIndex; - highlightRect.size.height = NSHeight (visibleRect); - highlightRect.origin.y = NSMinY (visibleRect); - highlightRect.origin.x = _cO[columnIndex]; - highlightRect.size.width = - _cO[columnIndex + 1] - _cO[columnIndex]; - - if (!NSEqualRects(highlightRect, oldRect)) - { - if (lit) - NSHighlightRect(oldRect); - // NSHighlightRect(highlightRect); - [_window flushWindow]; - } - else if (!lit) - { - // NSHighlightRect(highlightRect); - // [_window flushWindow]; - } - // oldRect = highlightRect; - oldRect = NSZeroRect; - lit = NO; //lit = YES; - } - } - break; - case NSPeriodic: - if (outside == YES) - { - if (lit) - { - NSHighlightRect(oldRect); - [_window flushWindow]; - lit = NO; - oldRect = NSZeroRect; - } - p = [self convertPoint: unconverted - fromView: nil].x; - tvRect = [_tableView visibleRect]; - if (p > maxVisCoord) - { - if (p > maxCoord) - tvRect.origin.x += (p - maxVisCoord)/8; - else - tvRect.origin.x += (p - maxVisCoord)/2; - } - else if (p < minVisCoord) - { - if (p < minCoord) - tvRect.origin.x += (p - minVisCoord)/8; - else - tvRect.origin.x += (p - minVisCoord)/2; - } - else // TODO remove this condition - { - NSLog(@"not outside !"); - } - [_tableView scrollPoint: tvRect.origin]; - visibleRect = [self visibleRect]; - minVisCoord = NSMinX (visibleRect); - maxVisCoord = NSMaxX (visibleRect); - } - break; - default: - break; - } - e = [NSApp nextEventMatchingMask: eventMask - untilDate: distantFuture - inMode: NSEventTrackingRunLoopMode - dequeue: YES]; - } - if (lit) - { - NSHighlightRect(highlightRect); - [_window flushWindow]; - lit = NO; - } + while ([e type] != NSLeftMouseUp) + { + switch ([e type]) + { + case NSLeftMouseDragged: + unconverted = [e locationInWindow]; + p = [self convertPoint: unconverted fromView: nil].x; + if (mouseDragged == NO) + { + NSLog(@"TODO: Deselect the column"); + } + mouseDragged = YES; + if (p < minVisCoord || p > maxVisCoord) + { + outside = YES; + } + else + { + outside = NO; + i = j; + if (p > (_cO[i] + _cO[i+1]) / 2) + { + while (p > (_cO[i] + _cO[i+1]) / 2) + i++; + } + else if (p < (_cO[i] + _cO[i-1]) / 2) + { + while (p < (_cO[i] + _cO[i-1]) / 2) + i--; + } + if (i != columnIndex + && i != columnIndex + 1) + { + j = i; + highlightRect.size.height = NSHeight (visibleRect); + highlightRect.origin.y = NSMinY (visibleRect); + highlightRect.size.width = 7; + if (i == numberOfColumns) + { + highlightRect.origin.x = _cO[i] - 3; + } + else if (i == 0) + { + highlightRect.origin.x = _cO[i] - 3; + } + else + { + highlightRect.origin.x = _cO[i] - 3; + } + if (!NSEqualRects(highlightRect, oldRect)) + { + if (lit) + NSHighlightRect(oldRect); + NSHighlightRect(highlightRect); + [_window flushWindow]; + } + else if (!lit) + { + NSHighlightRect(highlightRect); + [_window flushWindow]; + } + oldRect = highlightRect; + lit = YES; + } + else + { + i = columnIndex; + highlightRect.size.height = NSHeight (visibleRect); + highlightRect.origin.y = NSMinY (visibleRect); + highlightRect.origin.x = _cO[columnIndex]; + highlightRect.size.width = + _cO[columnIndex + 1] - _cO[columnIndex]; + + if (!NSEqualRects(highlightRect, oldRect)) + { + if (lit) + NSHighlightRect(oldRect); + // NSHighlightRect(highlightRect); + [_window flushWindow]; + } + else if (!lit) + { + // NSHighlightRect(highlightRect); + // [_window flushWindow]; + } + // oldRect = highlightRect; + oldRect = NSZeroRect; + lit = NO; //lit = YES; + } + } + break; + case NSPeriodic: + if (outside == YES) + { + if (lit) + { + NSHighlightRect(oldRect); + [_window flushWindow]; + lit = NO; + oldRect = NSZeroRect; + } + p = [self convertPoint: unconverted + fromView: nil].x; + tvRect = [_tableView visibleRect]; + if (p > maxVisCoord) + { + if (p > maxCoord) + tvRect.origin.x += (p - maxVisCoord)/8; + else + tvRect.origin.x += (p - maxVisCoord)/2; + } + else if (p < minVisCoord) + { + if (p < minCoord) + tvRect.origin.x += (p - minVisCoord)/8; + else + tvRect.origin.x += (p - minVisCoord)/2; + } + else // TODO remove this condition + { + NSLog(@"not outside !"); + } + [_tableView scrollPoint: tvRect.origin]; + visibleRect = [self visibleRect]; + minVisCoord = NSMinX (visibleRect); + maxVisCoord = NSMaxX (visibleRect); + } + break; + default: + break; + } + e = [NSApp nextEventMatchingMask: eventMask + untilDate: distantFuture + inMode: NSEventTrackingRunLoopMode + dequeue: YES]; + } + if (lit) + { + NSHighlightRect(highlightRect); + [_window flushWindow]; + lit = NO; + } - [NSEvent stopPeriodicEvents]; - [self unlockFocus]; - if (mouseDragged == NO) - { - [_tableView _selectColumn: columnIndex - modifiers: modifiers]; - - [_tableView _didClickTableColumn: - currentColumn]; + [NSEvent stopPeriodicEvents]; + [self unlockFocus]; + if (mouseDragged == NO) + { + [_tableView _selectColumn: columnIndex + modifiers: modifiers]; + + [_tableView _didClickTableColumn: + currentColumn]; - [self setNeedsDisplay: YES];; - } - else // mouseDragged == YES - { - { - NSRect rect = [self headerRectOfColumn: columnIndex]; - [_tableView _mouseDownInHeaderOfTableColumn: - [[_tableView tableColumns] - objectAtIndex: columnIndex]]; - rect.origin.y++; - rect.size.height--; - [[currentColumn headerCell] - setHighlighted: NO]; - - [self lockFocus]; - [[currentColumn headerCell] - highlight: NO - withFrame: rect - inView: self]; - [self unlockFocus]; - [_window flushWindow]; - } - if (i > columnIndex) - i--; - if (i != columnIndex) - { - [_tableView moveColumn: columnIndex - toColumn: i]; - } - } - free(_cO_minus1); - return; - } + [self setNeedsDisplay: YES];; + } + else // mouseDragged == YES + { + { + NSRect rect = [self headerRectOfColumn: columnIndex]; + [_tableView _mouseDownInHeaderOfTableColumn: + [[_tableView tableColumns] + objectAtIndex: columnIndex]]; + rect.origin.y++; + rect.size.height--; + [[currentColumn headerCell] + setHighlighted: NO]; + + [self lockFocus]; + [[currentColumn headerCell] + highlight: NO + withFrame: rect + inView: self]; + [self unlockFocus]; + [_window flushWindow]; + } + if (i > columnIndex) + i--; + if (i != columnIndex) + { + [_tableView moveColumn: columnIndex + toColumn: i]; + } + } + free(_cO_minus1); + return; + } else - { - NSRect cellFrame = [self headerRectOfColumn: columnIndex]; - NSApplication *theApp = [NSApplication sharedApplication]; - unsigned int modifiers = [event modifierFlags]; - NSPoint location = [event locationInWindow]; - NSPoint point = [self convertPoint: location fromView: nil]; + { + NSRect cellFrame = [self headerRectOfColumn: columnIndex]; + NSApplication *theApp = [NSApplication sharedApplication]; + unsigned int modifiers = [event modifierFlags]; + NSPoint location = [event locationInWindow]; + NSPoint point = [self convertPoint: location fromView: nil]; - if (![self mouse: point inRect: cellFrame]) - { - NSLog(@"not in frame, what's happening ?"); - return; - } + if (![self mouse: point inRect: cellFrame]) + { + NSLog(@"not in frame, what's happening ?"); + return; + } - event = [theApp nextEventMatchingMask: NSLeftMouseUpMask - untilDate: nil - inMode: NSEventTrackingRunLoopMode - dequeue: NO]; - + event = [theApp nextEventMatchingMask: NSLeftMouseUpMask + untilDate: nil + inMode: NSEventTrackingRunLoopMode + dequeue: NO]; + - location = [event locationInWindow]; - - point = [self convertPoint: location fromView: nil]; - - if (![self mouse: point inRect: cellFrame]) - { - NSDebugLLog(@"NSCell", - @"tableheaderview point not in cell frame\n"); - { - NSRect rect = [self headerRectOfColumn: columnIndex]; - [_tableView _mouseDownInHeaderOfTableColumn: - [[_tableView tableColumns] - objectAtIndex: columnIndex]]; - rect.origin.y++; - rect.size.height--; - [[currentColumn headerCell] - setHighlighted: NO]; - - [self lockFocus]; - [[currentColumn headerCell] - highlight: NO - withFrame: rect - inView: self]; - [self unlockFocus]; - [_window flushWindow]; - } + location = [event locationInWindow]; + + point = [self convertPoint: location fromView: nil]; + + if (![self mouse: point inRect: cellFrame]) + { + NSDebugLLog(@"NSCell", + @"tableheaderview point not in cell frame\n"); + { + NSRect rect = [self headerRectOfColumn: columnIndex]; + [_tableView _mouseDownInHeaderOfTableColumn: + [[_tableView tableColumns] + objectAtIndex: columnIndex]]; + rect.origin.y++; + rect.size.height--; + [[currentColumn headerCell] + setHighlighted: NO]; + + [self lockFocus]; + [[currentColumn headerCell] + highlight: NO + withFrame: rect + inView: self]; + [self unlockFocus]; + [_window flushWindow]; + } - } - else - { - [_tableView _selectColumn: columnIndex - modifiers: modifiers]; - [_tableView _didClickTableColumn: - currentColumn]; + } + else + { + [_tableView _selectColumn: columnIndex + modifiers: modifiers]; + [_tableView _didClickTableColumn: + currentColumn]; - [self setNeedsDisplay: YES]; - /* - if ([_tableView highlightedTableColumn] != currentColumn) - { - NSRect rect = [self headerRectOfColumn: columnIndex]; - - // [_tableView _mouseDownInHeaderOfTableColumn: - // [[_tableView tableColumns] - // objectAtIndex: columnIndex]]; + [self setNeedsDisplay: YES]; + /* + if ([_tableView highlightedTableColumn] != currentColumn) + { + NSRect rect = [self headerRectOfColumn: columnIndex]; + + // [_tableView _mouseDownInHeaderOfTableColumn: + // [[_tableView tableColumns] + // objectAtIndex: columnIndex]]; - rect.origin.y++; - rect.size.height--; - NSLog(@"highlight"); - [[currentColumn headerCell] setHighlighted: NO]; - - [[currentColumn headerCell] - highlight: NO - withFrame: rect - inView: self]; - [_window flushWindow]; - } - */ - } - } + rect.origin.y++; + rect.size.height--; + NSLog(@"highlight"); + [[currentColumn headerCell] setHighlighted: NO]; + + [[currentColumn headerCell] + highlight: NO + withFrame: rect + inView: self]; + [_window flushWindow]; + } + */ + } + } } }