2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSTableHeaderCell</title>
|
1999-10-25 22:15:18 +00:00
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
Author: Nicola Pero <n.pero@mi.flashnet.it>
|
1999-10-25 22:15:18 +00:00
|
|
|
Date: 1999
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1999-10-25 22:15:18 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
1999-10-25 22:15:18 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
1999-10-25 22:15:18 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1999-10-25 22:15:18 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
1999-10-25 22:15:18 +00:00
|
|
|
*/
|
|
|
|
|
2009-11-09 14:53:59 +00:00
|
|
|
#import "AppKit/NSColor.h"
|
|
|
|
#import "AppKit/NSFont.h"
|
|
|
|
#import "AppKit/NSImage.h"
|
|
|
|
#import "AppKit/NSTableHeaderCell.h"
|
2011-03-04 11:33:22 +00:00
|
|
|
#import "GNUstepGUI/GSTheme.h"
|
1999-10-25 22:15:18 +00:00
|
|
|
|
1999-07-19 19:13:10 +00:00
|
|
|
@implementation NSTableHeaderCell
|
2006-01-20 01:03:01 +00:00
|
|
|
|
1999-10-25 22:15:18 +00:00
|
|
|
// Default appearance of NSTableHeaderCell
|
|
|
|
- (id) initTextCell: (NSString *)aString
|
|
|
|
{
|
2009-11-09 14:53:59 +00:00
|
|
|
self = [super initTextCell: aString];
|
|
|
|
if (!self)
|
|
|
|
return nil;
|
1999-10-25 22:15:18 +00:00
|
|
|
|
2006-01-20 01:03:01 +00:00
|
|
|
[self setAlignment: NSCenterTextAlignment];
|
2015-07-08 22:21:16 +00:00
|
|
|
[self setTextColor: [[GSTheme theme] tableHeaderTextColorForState: GSThemeNormalState]];
|
1999-10-25 22:15:18 +00:00
|
|
|
[self setBackgroundColor: [NSColor controlShadowColor]];
|
2006-01-20 01:03:01 +00:00
|
|
|
[self setDrawsBackground: YES];
|
2000-09-02 17:16:26 +00:00
|
|
|
[self setFont: [NSFont titleBarFontOfSize: 0]];
|
2011-03-09 09:00:46 +00:00
|
|
|
[self setWraps: NO];
|
2006-01-20 01:03:01 +00:00
|
|
|
// This is not exactly true
|
2000-03-18 00:26:41 +00:00
|
|
|
_cell.is_bezeled = YES;
|
2008-02-02 21:01:43 +00:00
|
|
|
_cell.is_bordered = NO;
|
1999-10-25 22:15:18 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
2004-06-07 23:54:25 +00:00
|
|
|
|
2006-01-20 01:03:01 +00:00
|
|
|
- (NSRect) drawingRectForBounds: (NSRect)theRect
|
|
|
|
{
|
2010-11-27 03:51:13 +00:00
|
|
|
return [[GSTheme theme] tableHeaderCellDrawingRectForBounds: theRect];
|
2000-03-18 00:26:41 +00:00
|
|
|
}
|
|
|
|
|
2008-02-02 21:01:43 +00:00
|
|
|
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
|
|
|
inView: (NSView*)controlView
|
2002-02-13 16:34:40 +00:00
|
|
|
{
|
2010-01-28 07:25:04 +00:00
|
|
|
GSThemeControlState state;
|
2006-01-20 01:03:01 +00:00
|
|
|
if (_cell.is_highlighted == YES)
|
2002-02-13 16:34:40 +00:00
|
|
|
{
|
2010-01-28 07:25:04 +00:00
|
|
|
state = GSThemeHighlightedState;
|
2002-02-13 16:34:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-28 07:25:04 +00:00
|
|
|
state = GSThemeNormalState;
|
2002-02-13 16:34:40 +00:00
|
|
|
}
|
2008-12-08 16:28:13 +00:00
|
|
|
|
2010-01-28 07:25:04 +00:00
|
|
|
[[GSTheme theme] drawTableHeaderCell: self
|
|
|
|
withFrame: cellFrame
|
|
|
|
inView: controlView
|
|
|
|
state: state];
|
1999-07-19 19:13:10 +00:00
|
|
|
}
|
2003-01-30 04:26:35 +00:00
|
|
|
|
2009-11-09 14:53:59 +00:00
|
|
|
- (void) drawSortIndicatorWithFrame: (NSRect)cellFrame
|
|
|
|
inView: (NSView *)controlView
|
|
|
|
ascending: (BOOL)ascending
|
|
|
|
priority: (int)priority
|
|
|
|
{
|
|
|
|
NSImage *img;
|
|
|
|
|
|
|
|
cellFrame = [self sortIndicatorRectForBounds: cellFrame];
|
|
|
|
if (ascending)
|
|
|
|
img = [NSImage imageNamed: @"NSAscendingSortIndicator"];
|
|
|
|
else
|
|
|
|
img = [NSImage imageNamed: @"NSDescendingSortIndicator"];
|
|
|
|
|
|
|
|
[img drawAtPoint: cellFrame.origin
|
|
|
|
fromRect: NSZeroRect
|
|
|
|
operation: NSCompositeSourceOver
|
|
|
|
fraction: 1.0];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect) sortIndicatorRectForBounds: (NSRect)theRect
|
|
|
|
{
|
|
|
|
NSImage *img = [NSImage imageNamed: @"NSAscendingSortIndicator"];
|
|
|
|
NSSize size = [img size];
|
|
|
|
|
|
|
|
theRect.origin.x = NSMaxX(theRect) - size.width;
|
|
|
|
theRect.size = size;
|
|
|
|
|
|
|
|
return theRect;
|
|
|
|
}
|
|
|
|
|
2006-01-20 01:03:01 +00:00
|
|
|
- (void) setHighlighted: (BOOL)flag
|
2003-01-30 04:26:35 +00:00
|
|
|
{
|
|
|
|
_cell.is_highlighted = flag;
|
|
|
|
|
|
|
|
if (flag == YES)
|
|
|
|
{
|
2005-01-09 16:12:14 +00:00
|
|
|
[self setBackgroundColor: [NSColor controlHighlightColor]];
|
2015-07-08 22:21:16 +00:00
|
|
|
[self setTextColor: [[GSTheme theme] tableHeaderTextColorForState: GSThemeHighlightedState]];
|
2003-01-30 04:26:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self setBackgroundColor: [NSColor controlShadowColor]];
|
2015-07-08 22:21:16 +00:00
|
|
|
[self setTextColor: [[GSTheme theme] tableHeaderTextColorForState: GSThemeNormalState]];
|
2003-01-30 04:26:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-19 19:13:10 +00:00
|
|
|
@end
|