mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:00:46 +00:00
Reverted changes of previous commit to rollback unintentional reformatting of code in the files NSTableView.m and NSOutlineView.m.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@36044 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
10ad99f43f
commit
fe5d19ee8e
2 changed files with 6704 additions and 6786 deletions
|
@ -29,7 +29,7 @@
|
|||
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.
|
||||
*/
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
|
@ -144,13 +144,13 @@ static NSImage *unexpandable = nil;
|
|||
[self setVersion: current_version];
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
#if 0
|
||||
/* Old Interface Builder style. */
|
||||
/* Old Interface Builder style. */
|
||||
collapsed = [NSImage imageNamed: @"common_outlineCollapsed"];
|
||||
expanded = [NSImage imageNamed: @"common_outlineExpanded"];
|
||||
unexpandable = [NSImage imageNamed: @"common_outlineUnexpandable"];
|
||||
#else
|
||||
/* Current OSX style images. */
|
||||
// FIXME ... better ones?
|
||||
/* Current OSX style images. */
|
||||
// FIXME ... better ones?
|
||||
collapsed = [NSImage imageNamed: @"common_ArrowRightH"];
|
||||
expanded = [NSImage imageNamed: @"common_ArrowDownH"];
|
||||
unexpandable = [[NSImage alloc] initWithSize: [expanded size]];
|
||||
|
@ -672,9 +672,9 @@ static NSImage *unexpandable = nil;
|
|||
- (void) setDataSource: (id)anObject
|
||||
{
|
||||
#define CHECK_REQUIRED_METHOD(selector_name) \
|
||||
if (anObject && ![anObject respondsToSelector: @selector(selector_name)]) \
|
||||
[NSException raise: NSInternalInconsistencyException \
|
||||
format: @"data source does not respond to %@", @#selector_name]
|
||||
if (anObject && ![anObject respondsToSelector: @selector(selector_name)]) \
|
||||
[NSException raise: NSInternalInconsistencyException \
|
||||
format: @"data source does not respond to %@", @#selector_name]
|
||||
|
||||
CHECK_REQUIRED_METHOD(outlineView:child:ofItem:);
|
||||
CHECK_REQUIRED_METHOD(outlineView:isItemExpandable:);
|
||||
|
@ -738,10 +738,10 @@ format: @"data source does not respond to %@", @#selector_name]
|
|||
_delegate = anObject;
|
||||
|
||||
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
||||
if ([_delegate respondsToSelector: @selector(outlineView##notif_name:)]) \
|
||||
[nc addObserver: _delegate \
|
||||
selector: @selector(outlineView##notif_name:) \
|
||||
name: NSOutlineView##notif_name##Notification object: self]
|
||||
if ([_delegate respondsToSelector: @selector(outlineView##notif_name:)]) \
|
||||
[nc addObserver: _delegate \
|
||||
selector: @selector(outlineView##notif_name:) \
|
||||
name: NSOutlineView##notif_name##Notification object: self]
|
||||
|
||||
SET_DELEGATE_NOTIFICATION(ColumnDidMove);
|
||||
SET_DELEGATE_NOTIFICATION(ColumnDidResize);
|
||||
|
@ -1222,7 +1222,7 @@ name: NSOutlineView##notif_name##Notification object: self]
|
|||
}
|
||||
|
||||
/* Returns the row whose item is the parent that owns the child at the given row.
|
||||
Also returns the child index relative to this parent. */
|
||||
Also returns the child index relative to this parent. */
|
||||
- (NSInteger) _parentRowForRow: (NSInteger)row
|
||||
atLevel: (NSInteger)level
|
||||
andReturnChildIndex: (NSInteger *)childIndex
|
||||
|
@ -1517,7 +1517,7 @@ name: NSOutlineView##notif_name##Notification object: self]
|
|||
}
|
||||
|
||||
return [_dataSource outlineView: self
|
||||
namesOfPromisedFilesDroppedAtDestination: dropDestination
|
||||
namesOfPromisedFilesDroppedAtDestination: dropDestination
|
||||
forDraggedItems: itemArray];
|
||||
}
|
||||
else
|
||||
|
@ -1526,7 +1526,6 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Autosave methods...
|
||||
- (void) setAutosaveName: (NSString *)name
|
||||
{
|
||||
|
@ -2266,25 +2265,6 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
|
|||
return cell;
|
||||
}
|
||||
|
||||
// This is used to build the drag image.
|
||||
- (NSString *) _objectStringForTableColum:(NSTableColumn *)column item:(int)row {
|
||||
NSString *draggedItemString = nil;
|
||||
if ([[self dataSource] respondsToSelector:@selector(outlineView:objectValueForTableColumn:byItem:)]) {
|
||||
id item = [self itemAtRow:row];
|
||||
id draggedObject = [[self dataSource] outlineView:self
|
||||
objectValueForTableColumn:column
|
||||
byItem:item];
|
||||
|
||||
// Pad the string to match its indentation level:
|
||||
int level = [self levelForRow:row];
|
||||
NSString *pad = [@"" stringByPaddingToLength:(level*4)
|
||||
withString:@" "
|
||||
startingAtIndex:0];
|
||||
draggedItemString = [pad stringByAppendingString:[draggedObject description]];
|
||||
}
|
||||
return draggedItemString;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSOutlineView (Private)
|
||||
|
@ -2302,5 +2282,4 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
|
|||
}
|
||||
[autoExpanded removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
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.
|
||||
*/
|
||||
*/
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
|
@ -68,8 +68,6 @@
|
|||
#import "AppKit/NSCustomImageRep.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
#import "GSBindingHelpers.h"
|
||||
#import "AppKit/NSAttributedString.h"
|
||||
#import "AppKit/NSStringDrawing.h"
|
||||
|
||||
#include <math.h>
|
||||
static NSNotificationCenter *nc = nil;
|
||||
|
@ -1986,8 +1984,6 @@ static void computeNewSelection
|
|||
- (void) _autoloadTableColumns;
|
||||
- (NSCell *) _dataCellForTableColumn: (NSTableColumn *)tb
|
||||
row: (int) rowIndex;
|
||||
- (NSString *) _objectStringForTableColum:(NSTableColumn *)column item:(int)row;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -3602,21 +3598,21 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
{
|
||||
#define COMPUTE_NEW_SELECTION do { \
|
||||
if (originalRow == -1) \
|
||||
{ \
|
||||
originalRow = currentRow; \
|
||||
} \
|
||||
{ \
|
||||
originalRow = currentRow; \
|
||||
} \
|
||||
if (currentRow >= 0 && currentRow < _numberOfRows) \
|
||||
{ \
|
||||
computeNewSelection(self, \
|
||||
oldSelectedRows, \
|
||||
_selectedRows, \
|
||||
originalRow, \
|
||||
oldRow, \
|
||||
currentRow, \
|
||||
&_selectedRow, \
|
||||
selectionMode); \
|
||||
[self displayIfNeeded]; \
|
||||
} \
|
||||
{ \
|
||||
computeNewSelection(self, \
|
||||
oldSelectedRows, \
|
||||
_selectedRows, \
|
||||
originalRow, \
|
||||
oldRow, \
|
||||
currentRow, \
|
||||
&_selectedRow, \
|
||||
selectionMode); \
|
||||
[self displayIfNeeded]; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
// Selection
|
||||
|
@ -3950,10 +3946,10 @@ selectionMode); \
|
|||
/* helpers for keyboard selection */
|
||||
#define CHECK_CHANGING(x) { \
|
||||
if (!x) \
|
||||
{ \
|
||||
[self _postSelectionIsChangingNotification]; \
|
||||
x = YES; \
|
||||
} \
|
||||
{ \
|
||||
[self _postSelectionIsChangingNotification]; \
|
||||
x = YES; \
|
||||
} \
|
||||
}
|
||||
static BOOL selectContiguousRegion(NSTableView *self,
|
||||
NSIndexSet *_selectedRows,
|
||||
|
@ -4321,9 +4317,9 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
|||
|
||||
/** Returns the indexes of the table columns which intersects the given rect.
|
||||
|
||||
The rect is expressed in the receiver coordinate space.
|
||||
The rect is expressed in the receiver coordinate space.
|
||||
|
||||
Hidden table columns are never tested. */
|
||||
Hidden table columns are never tested. */
|
||||
- (NSIndexSet *) columnIndexesInRect: (NSRect)aRect
|
||||
{
|
||||
NSRange range = [self columnsInRect: aRect];
|
||||
|
@ -4343,11 +4339,11 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
|||
|
||||
/** Returns the index range of the table columns which intersects the given rect.
|
||||
|
||||
The rect is expressed in the receiver coordinate space.
|
||||
The rect is expressed in the receiver coordinate space.
|
||||
|
||||
The returned range can include hidden table column indexes.
|
||||
The returned range can include hidden table column indexes.
|
||||
|
||||
This method is deprecated, use -columnIndexesInRect:. */
|
||||
This method is deprecated, use -columnIndexesInRect:. */
|
||||
- (NSRange) columnsInRect: (NSRect)aRect
|
||||
{
|
||||
NSRange range;
|
||||
|
@ -4752,8 +4748,8 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
|||
[self tile];
|
||||
}
|
||||
/*
|
||||
- (void) sizeToFit
|
||||
{
|
||||
- (void) sizeToFit
|
||||
{
|
||||
NSCell *cell;
|
||||
NSEnumerator *enumerator;
|
||||
NSTableColumn *tb;
|
||||
|
@ -4829,8 +4825,8 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
|||
_tilingDisabled = NO;
|
||||
[self tile];
|
||||
NSLog(@"exiting sizeToFit");
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) noteNumberOfRowsChanged
|
||||
{
|
||||
|
@ -5261,10 +5257,10 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
|||
_delegate = anObject;
|
||||
|
||||
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
||||
if ([_delegate respondsToSelector: @selector(tableView##notif_name:)]) \
|
||||
[nc addObserver: _delegate \
|
||||
selector: @selector(tableView##notif_name:) \
|
||||
name: NSTableView##notif_name##Notification object: self]
|
||||
if ([_delegate respondsToSelector: @selector(tableView##notif_name:)]) \
|
||||
[nc addObserver: _delegate \
|
||||
selector: @selector(tableView##notif_name:) \
|
||||
name: NSTableView##notif_name##Notification object: self]
|
||||
|
||||
SET_DELEGATE_NOTIFICATION(ColumnDidMove);
|
||||
SET_DELEGATE_NOTIFICATION(ColumnDidResize);
|
||||
|
@ -5341,10 +5337,6 @@ name: NSTableView##notif_name##Notification object: self]
|
|||
event: (NSEvent*)event
|
||||
offset: (NSPoint*)offset
|
||||
{
|
||||
if (!cols && ([self tableColumns]) && ([[self tableColumns] count] > 0)) {
|
||||
cols = [NSArray arrayWithObject:[[self tableColumns] objectAtIndex:0]];
|
||||
}
|
||||
if (!rows || [rows count] < 1 || !cols || [cols count] < 1) {
|
||||
// FIXME
|
||||
NSArray *rowArray;
|
||||
|
||||
|
@ -5352,46 +5344,6 @@ name: NSTableView##notif_name##Notification object: self]
|
|||
return [self dragImageForRows: rowArray
|
||||
event: event
|
||||
dragImageOffset: offset];
|
||||
}
|
||||
|
||||
// Build a string of texts, each representing a line from the tableView,
|
||||
// separated by "\n":
|
||||
NSString *descriptionsList = nil;
|
||||
unsigned int index = [rows firstIndex];
|
||||
while (index != NSNotFound) {
|
||||
NSString *draggedItemString = [self _objectStringForTableColum:[cols objectAtIndex:0]
|
||||
item:index];
|
||||
if (!descriptionsList) {
|
||||
descriptionsList = [NSMutableString stringWithString:draggedItemString];
|
||||
}
|
||||
else {
|
||||
descriptionsList = [descriptionsList stringByAppendingFormat:@"\n%@", draggedItemString];
|
||||
}
|
||||
index = [rows indexGreaterThanIndex:index];
|
||||
}
|
||||
|
||||
|
||||
NSAttributedString *attributedString = [[[NSAttributedString alloc] initWithString:descriptionsList] autorelease];
|
||||
|
||||
NSSize boxSize = [attributedString size];
|
||||
NSRect rect = NSMakeRect(0.0, 0.0, boxSize.width, boxSize.height);
|
||||
NSImage *image = [[NSImage alloc] initWithSize:boxSize];
|
||||
NSColor *bg = [NSColor whiteColor];
|
||||
|
||||
|
||||
[image lockFocus];
|
||||
// Filling with white color for now, transparent is showing as blackColor.
|
||||
[bg set];
|
||||
NSRectFill(rect);
|
||||
[attributedString drawInRect:rect];
|
||||
[image unlockFocus];
|
||||
|
||||
// Offset the image so it sits neatly next to the mouse cursor.
|
||||
// Note: Cocoa actually offsets the image to position of the mouse down.
|
||||
offset->x = (boxSize.width / 2) + 5;
|
||||
offset->y = (boxSize.height / -2) + 5;
|
||||
|
||||
return [image autorelease];
|
||||
}
|
||||
|
||||
- (void) setDropRow: (int)row
|
||||
|
@ -5426,7 +5378,7 @@ name: NSTableView##notif_name##Notification object: self]
|
|||
@selector(tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:)])
|
||||
{
|
||||
return [_dataSource tableView: self
|
||||
namesOfPromisedFilesDroppedAtDestination: dropDestination
|
||||
namesOfPromisedFilesDroppedAtDestination: dropDestination
|
||||
forDraggedRowsWithIndexes: _selectedRows];
|
||||
}
|
||||
else
|
||||
|
@ -5815,7 +5767,7 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
|
|||
@selector(tableView:mouseDownInHeaderOfTableColumn:)])
|
||||
{
|
||||
[_delegate tableView: self
|
||||
mouseDownInHeaderOfTableColumn: tc];
|
||||
mouseDownInHeaderOfTableColumn: tc];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5910,7 +5862,7 @@ mouseDownInHeaderOfTableColumn: tc];
|
|||
}
|
||||
}
|
||||
|
||||
// Should we loop around or not?
|
||||
// Should we loop around or not?
|
||||
#if 0
|
||||
// Nothing found? Search in the rows before the current
|
||||
for (i = 0; i < row; i++)
|
||||
|
@ -5978,7 +5930,7 @@ mouseDownInHeaderOfTableColumn: tc];
|
|||
}
|
||||
}
|
||||
|
||||
// Should we loop around or not?
|
||||
// Should we loop around or not?
|
||||
#if 0
|
||||
// Nothing found? Search in the rows after the current
|
||||
for (i = _numberOfRows - 1; i > row; i--)
|
||||
|
@ -6101,19 +6053,6 @@ mouseDownInHeaderOfTableColumn: tc];
|
|||
return cell;
|
||||
}
|
||||
|
||||
- (NSString *) _objectStringForTableColum:(NSTableColumn *)column item:(int)row
|
||||
{
|
||||
NSString *draggedItemString = nil;
|
||||
if ([_dataSource respondsToSelector:@selector(tableView:objectValueForTableColumn:byItem:)]) {
|
||||
id draggedObject = [_dataSource tableView:self
|
||||
objectValueForTableColumn:column
|
||||
row:row];
|
||||
|
||||
draggedItemString = [draggedObject description];
|
||||
}
|
||||
return draggedItemString;
|
||||
}
|
||||
|
||||
- (void) superviewFrameChanged: (NSNotification*)aNotification
|
||||
{
|
||||
if (_autoresizesAllColumnsToFit == YES)
|
||||
|
@ -6449,20 +6388,20 @@ mouseDownInHeaderOfTableColumn: tc];
|
|||
*/
|
||||
|
||||
/** Sets the sort descriptors used to sort the rows and delegates the sorting
|
||||
to -tableView:didChangeSortDescriptors or -outlineView:didChangeSortDescriptors:
|
||||
in NSOutlineView.
|
||||
to -tableView:didChangeSortDescriptors or -outlineView:didChangeSortDescriptors:
|
||||
in NSOutlineView.
|
||||
|
||||
The delegate methods can retrieve the new sort descriptors with
|
||||
-sortDescriptors and override them with -setSortDescriptors:.<br />
|
||||
The first object in the new sort descriptor array is the sort descriptor
|
||||
prototype returned by the table column whose header was the last clicked.
|
||||
See -[NSTableColumn sortDescriptorPrototype].
|
||||
The delegate methods can retrieve the new sort descriptors with
|
||||
-sortDescriptors and override them with -setSortDescriptors:.<br />
|
||||
The first object in the new sort descriptor array is the sort descriptor
|
||||
prototype returned by the table column whose header was the last clicked.
|
||||
See -[NSTableColumn sortDescriptorPrototype].
|
||||
|
||||
This method is called automatically when you click on a table column header,
|
||||
so you shouldn't need to call it usually.
|
||||
This method is called automatically when you click on a table column header,
|
||||
so you shouldn't need to call it usually.
|
||||
|
||||
Take note the sort descriptors are encoded by the keyed archiving (rarely used
|
||||
since neither IB or Gorm support to set these directly). */
|
||||
Take note the sort descriptors are encoded by the keyed archiving (rarely used
|
||||
since neither IB or Gorm support to set these directly). */
|
||||
- (void) setSortDescriptors: (NSArray *)sortDescriptors
|
||||
{
|
||||
NSArray *oldSortDescriptors = [self sortDescriptors];
|
||||
|
@ -6492,11 +6431,11 @@ mouseDownInHeaderOfTableColumn: tc];
|
|||
}
|
||||
|
||||
/** Returns the current sort descriptors, usually updated every time a click
|
||||
happens on a table column header.
|
||||
happens on a table column header.
|
||||
|
||||
By default, returns an empty array.
|
||||
By default, returns an empty array.
|
||||
|
||||
For a more detailed explanation, -setSortDescriptors:. */
|
||||
For a more detailed explanation, -setSortDescriptors:. */
|
||||
- (NSArray *)sortDescriptors
|
||||
{
|
||||
return _sortDescriptors;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue