Better check for click on table column border.

Allow table column identifier to be nil.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26482 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2008-05-01 19:48:28 +00:00
parent a92da16be5
commit 676eb09e4f
4 changed files with 78 additions and 40 deletions

View file

@ -1,3 +1,19 @@
2008-05-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableColumn.m (-initWithIdentifier:, -initWithCoder:):
Check for self becoming nil.
* Source/NSTableView.m (-columnWithIdentifier:): Allow the column
identifier to be nil.
2008-04-28 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableHeaderView.m (-mouseDown:): Use new variable
mouse_sensitivity (value 4) to determine whether the click is on a
column border.
Patch by Andreas Höschler <ahoesch@smartsoft.de>.
* Source/NSTableHeaderView.m (-initWithFrame:, -initWithCoder:):
Check for nil return from super call.
2008-04-27 18:42-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSWindow.m: Change to correct issue with NSWindow placement

View file

@ -99,6 +99,9 @@
- (id)initWithIdentifier: (id)anObject
{
self = [super init];
if (!self)
return nil;
_width = 100;
_min_width = 10;
_max_width = 100000;
@ -406,6 +409,9 @@
id identifier = [aDecoder decodeObjectForKey: @"NSIdentifier"];
self = [self initWithIdentifier: identifier];
if (!self)
return nil;
if ([aDecoder containsValueForKey: @"NSDataCell"])
{
[self setDataCell: [aDecoder decodeObjectForKey: @"NSDataCell"]];
@ -437,6 +443,9 @@
@"NSTableColumn"];
self = [super init];
if (!self)
return nil;
if (version == 2)
{
_identifier = RETAIN([aDecoder decodeObject]);

View file

@ -43,6 +43,12 @@
#include "AppKit/NSScrollView.h"
#include "AppKit/NSGraphics.h"
/*
* Number of pixels in either direction that will be counted as a hit
* on the column border and trigger a column resize.
*/
#define mouse_sensitivity 4
@interface NSTableView (GNUstepPrivate)
- (void) _userResizedTableColumn: (int)index
width: (float)width;
@ -78,6 +84,9 @@
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame: frameRect];
if (self == nil)
return nil;
_tableView = nil;
_resizedColumn = -1;
return self;
@ -308,19 +317,18 @@
if ([_tableView allowsColumnResizing])
{
/* Start resizing if the mouse is down on the bounds of a column. */
if (location.x >= NSMaxX (rect) - 1)
if (location.x >= NSMaxX(rect) - mouse_sensitivity)
{
if (columnIndex != ([_tableView numberOfColumns]))
if (columnIndex < [_tableView numberOfColumns])
{
_resizedColumn = columnIndex;
}
else
{
NSLog(@"ohoh");
NSLog(@"Bug: Trying to resize column past the end of the table.");
}
}
else if (location.x <= NSMinX (rect) + 2)
else if (location.x <= NSMinX(rect) + mouse_sensitivity)
{
if (columnIndex > 0)
{
@ -887,6 +895,9 @@
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if (self == nil)
return nil;
_tableView = nil;
_resizedColumn = -1;

View file

@ -2231,7 +2231,9 @@ static void computeNewSelection
while ((tb = [enumerator nextObject]) != nil)
{
if ([[tb identifier] isEqual: identifier])
// Also handle a nil identifier.
if ((identifier == [tb identifier]) ||
[[tb identifier] isEqual: identifier])
return return_value;
else
return_value++;