Added all the new table column methods and constants up to Mac OS X 10.6.

These new additions remain to be fully implemented and the archiving code to be 
updated.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29107 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Quentin Mathe 2009-12-08 17:01:01 +00:00
parent 8a86e63b77
commit 29d831a62f
3 changed files with 137 additions and 3 deletions

View file

@ -1,4 +1,13 @@
2009-12-08 Quentin Mathe <quentin.mathe@gmail.com>
* Headers/NSTableColumn.h:
* Source/NSTableColumn.m:
Added all new table column methods and constants up to Mac OS X 10.6.
These new additions remain to be fully implemented and the archiving code
to be updated.
2009-12-08 Hans Baier <hansfbaier@googlemail.com>
* Source/NSColorWell.m (-mouseDragged:, -mouseDown:): Applied
patch from Eric Wasylishen to activate it on click inside the
colored rectangle (same behavior as in OS X)

View file

@ -34,9 +34,28 @@
#include <Foundation/NSObject.h>
#include <AppKit/AppKitDefines.h>
@class NSSortDescriptor;
@class NSCell;
@class NSTableView;
// TODO: Finish to implement hidden, header tool tip and resizing mask
// and update the archiving code to support them.
/**
Describe the resizing styles accepted by the column.
The final resizing behavior also depends on -[NSTableView columnAutoresizingStyle].
The table view uses the resizing mask set on each column and its column
autoresizing style to determine how to resize each column. */
enum {
NSTableColumnNoResizing = 0,
/** Disallow any resizing. */
NSTableColumnAutoresizingMask = 1,
/** Allow automatic resizing when the table view is resized. */
NSTableColumnUserResizingMask = 2
/** Allow the user to resize the column manually. */
};
@interface NSTableColumn : NSObject <NSCoding>
{
id _identifier;
@ -44,10 +63,14 @@
float _width;
float _min_width;
float _max_width;
NSUInteger _resizing_mask;
BOOL _is_resizable;
BOOL _is_editable;
BOOL _is_hidden;
NSCell *_headerCell;
NSCell *_dataCell;
NSString *_headerToolTip;
NSSortDescriptor *_sortDescriptorPrototype;
}
/*
* Initializing an NSTableColumn instance
@ -64,7 +87,7 @@
- (void) setTableView: (NSTableView *)aTableView;
- (NSTableView *) tableView;
/*
* Controlling size
* Controlling size & visibility
*/
- (void) setWidth: (float)newWidth;
- (float) width;
@ -73,8 +96,16 @@
- (void) setMaxWidth: (float)maxWidth;
- (float) maxWidth;
- (void) setResizable: (BOOL)flag;
- (BOOL) isResizable;
- (BOOL) isResizable;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (void) setResizingMask: (NSUInteger)resizingMask;
- (NSUInteger) resizingMask;
#endif
- (void) sizeToFit;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (void) setHidden: (BOOL)hidden;
- (BOOL) isHidden;
#endif
/*
* Controlling editability
*/
@ -84,10 +115,21 @@
* Setting component cells
*/
- (void) setHeaderCell: (NSCell *)aCell;
- (NSCell *) headerCell;
- (NSCell *) headerCell;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (void) setHeaderToolTip: (NSString *)aString;
- (NSString *) headerToolTip;
#endif
- (void) setDataCell: (NSCell *)aCell;
- (NSCell *) dataCell;
- (NSCell *) dataCellForRow: (int)row;
/*
* Sorting
*/
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void) setSortDescriptorPrototype: (NSSortDescriptor *)aSortDescriptor;
- (NSSortDescriptor *) sortDescriptorPrototype;
#endif
@end
/* Notifications */

View file

@ -64,6 +64,7 @@
#include <Foundation/NSNotification.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSSortDescriptor.h>
#include "AppKit/NSTableHeaderCell.h"
#include "AppKit/NSTableColumn.h"
#include "AppKit/NSTableView.h"
@ -105,12 +106,15 @@
_width = 100;
_min_width = 10;
_max_width = 100000;
_resizing_mask = NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask;
_is_resizable = YES;
_is_editable = YES;
_is_hidden = NO;
_tableView = nil;
_headerCell = [NSTableHeaderCell new];
_dataCell = [NSTextFieldCell new];
_headerToolTip = nil;
ASSIGN (_identifier, anObject);
return self;
@ -119,6 +123,7 @@
- (void)dealloc
{
RELEASE (_headerCell);
RELEASE (_headerToolTip);
RELEASE (_dataCell);
TEST_RELEASE (_identifier);
[super dealloc];
@ -264,6 +269,15 @@
- (void)setResizable: (BOOL)flag
{
_is_resizable = flag;
// TODO: To match Cocoa behavior, should be replaced by
//if (flag)
// {
// [self setResizingMask: NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)];
// }
//else
// {
// [self setResizingMask: NSTableColumnNoResizing];
// }
}
/**
@ -272,8 +286,25 @@
- (BOOL)isResizable
{
return _is_resizable;
// TODO: To match Cocoa behavior, should be replaced by
//return (BOOL)[self autoresizingMask];
}
/**
Return the resizing mask that describes whether the column is resizable and how
it resizes. */
- (void) setResizingMask: (NSUInteger)resizingMask;
{
_resizing_mask = resizingMask;
}
/**
Set the resizing mask that describes whether the column is resizable and how
it resizes. */
- (NSUInteger) resizingMask;
{
return _resizing_mask;
}
/**
Change the width of the column to be just enough to display its
header; change the minimum width and maximum width to allow the
@ -296,6 +327,23 @@
[self setWidth: new_width];
}
/**
Set whether the column is invisible or not. */
- (void) setHidden: (BOOL)hidden;
{
_is_hidden = hidden;
}
/**
Return whether the column is invisible or not.
When the column is hidden, it remains present in the column array returned
by -[NSTableView tableColumns]. */
- (BOOL) isHidden
{
return _is_hidden;
}
/*
* Controlling editability
*/
@ -340,6 +388,20 @@
return _headerCell;
}
/**
Set the tool tip text displayed when the pointer is in the header area. */
- (void) setHeaderToolTip: (NSString *)aString;
{
ASSIGN(_headerToolTip, aString);
}
/**
Return the toop tip text displayed when the pointer is in the header area. */
- (NSString *) headerToolTip
{
return _headerToolTip;
}
/**
Set the cell used to display data in the column. aCell can't be
nil, otherwise a warning will be generated and the method ignored.
@ -370,6 +432,27 @@
return [self dataCell];
}
/*
* Sorting
*/
/**
Return the sort descriptor bound to the column. */
- (NSSortDescriptor *) sortDescriptorPrototype
{
return _sortDescriptorPrototype;
}
/** Return the sort descriptor bound to the column.
This sort descriptor will be added to -[NSTableView sortDescriptors] when you
bind a column to another object and NSCreateSortDescriptorBindingOption is set
to YES. */
- (void) setSortDescriptorPrototype: (NSSortDescriptor *)aSortDescriptor
{
ASSIGN(_sortDescriptorPrototype, aSortDescriptor);
}
/*
* Encoding/Decoding
*/