mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 10:01:14 +00:00
First implementation of drawing. Just the bare minimum to be able to work
on NSTableView. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5352 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0d4a0994ca
commit
89373df3ee
1 changed files with 139 additions and 20 deletions
|
@ -1,46 +1,165 @@
|
|||
/*
|
||||
NSTableHeaderView.m
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Michael Hanni <mhanni@sprintmail.com>
|
||||
Date: 1999
|
||||
Skeleton.
|
||||
|
||||
Author: Nicola Pero <n.pero@mi.flashnet.it>
|
||||
Date: December 1999
|
||||
First actual coding.
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <AppKit/NSTableHeaderCell.h>
|
||||
#include <AppKit/NSTableHeaderView.h>
|
||||
#include <AppKit/NSTableColumn.h>
|
||||
#include <AppKit/NSTableView.h>
|
||||
|
||||
@implementation NSTableHeaderView
|
||||
- (void)setTableView:(NSTableView *)aTableView
|
||||
{
|
||||
ASSIGN(tbhv_tableview, aTableView);
|
||||
}
|
||||
/*
|
||||
*
|
||||
* Class methods
|
||||
*
|
||||
*/
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSTableColumn class])
|
||||
[self setVersion: 1];
|
||||
}
|
||||
|
||||
- (NSTableView *)tableView
|
||||
{
|
||||
return tbhv_tableview;
|
||||
}
|
||||
/*
|
||||
*
|
||||
* Instance methods
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initializes an instance
|
||||
*/
|
||||
|
||||
// TODO: Remove this method, if not really needed
|
||||
- (NSTableHeaderView*)initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
self = [super initWithFrame: frameRect];
|
||||
_tableView = nil;
|
||||
return self;
|
||||
}
|
||||
/*
|
||||
* Setting the table view
|
||||
*/
|
||||
- (void)setTableView: (NSTableView*)aTableView
|
||||
{
|
||||
// We do not RETAIN aTableView but aTableView is supposed
|
||||
// to RETAIN us.
|
||||
_tableView = aTableView;
|
||||
}
|
||||
- (NSTableView*)tableView
|
||||
{
|
||||
return _tableView;
|
||||
}
|
||||
/*
|
||||
* Checking altered columns
|
||||
*/
|
||||
- (int)draggedColumn
|
||||
{
|
||||
// more thought has to go into this, though the default case is -1.
|
||||
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (float)draggedDistance
|
||||
{
|
||||
// return horizontal distance from last location.
|
||||
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (int)resizedColumn
|
||||
{
|
||||
// index of resized column?
|
||||
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (int)columnAtPoint:(NSPoint)aPoint
|
||||
/*
|
||||
* Utility methods
|
||||
*/
|
||||
- (int)columnAtPoint: (NSPoint)aPoint
|
||||
{
|
||||
// black magic here to deduce the column at point, quite easy.
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
- (NSRect)headerRectOfColumn: (int)columnIndex
|
||||
{
|
||||
NSArray* columns;
|
||||
NSRect rect;
|
||||
int i;
|
||||
|
||||
return -1; // No such column
|
||||
if (_tableView == nil)
|
||||
return NSZeroRect;
|
||||
|
||||
columns = [_tableView tableColumns];
|
||||
|
||||
NSAssert(columnIndex > 0, NSInternalInconsistencyException);
|
||||
NSAssert(columnIndex < [columns count], NSInternalInconsistencyException);
|
||||
|
||||
rect.origin.x = bounds.origin.x;
|
||||
rect.origin.y = bounds.origin.y;
|
||||
rect.size.height = bounds.size.height;
|
||||
|
||||
for (i = 0; i < columnIndex; i++)
|
||||
{
|
||||
rect.origin.x += [[columns objectAtIndex: i] width];
|
||||
}
|
||||
rect.size.width = [[columns objectAtIndex: columnIndex] width];
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSRect)headerRectOfColumn:(int)columnIndex
|
||||
/*
|
||||
* Overidden Methods
|
||||
*/
|
||||
- (void)drawRect: (NSRect)aRect
|
||||
{
|
||||
// bzzt. weird.
|
||||
NSArray* columns;
|
||||
NSRange columnsToDraw;
|
||||
int i;
|
||||
|
||||
if (_tableView == nil)
|
||||
return;
|
||||
|
||||
columnsToDraw = [_tableView columnsInRect: aRect];
|
||||
if (columnsToDraw.length == 0)
|
||||
return;
|
||||
|
||||
columns = [_tableView tableColumns];
|
||||
|
||||
for (i = columnsToDraw.location; i < columnsToDraw.length + 1; i++)
|
||||
{
|
||||
[[[columns objectAtIndex: i] headerCell]
|
||||
drawWithFrame: [self headerRectOfColumn: i]
|
||||
inView: self];
|
||||
}
|
||||
}
|
||||
-(void)mouseDown: (NSEvent*)event
|
||||
{
|
||||
// TODO
|
||||
[super mouseDown: event];
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue