mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Merge pull request #265 from gnustep/NSTableRowView_branch
NSTableRowView class implementation
This commit is contained in:
commit
422649ae5b
8 changed files with 913 additions and 594 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2024-06-07 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h: Add new methods
|
||||
for rendering view-based outline/table views.
|
||||
* Headers/AppKit/NSTableRowView.h: Add implementation
|
||||
* Headers/AppKit/NSTableView.h: Add references to
|
||||
NSTableRowView.h
|
||||
* Source/GSThemeDrawing.m: Factor out NSTableView and
|
||||
NSOutlineView rendering so that GSThemeDrawing methods
|
||||
are as minimal as possible.
|
||||
* Source/NSOutlineView.m: Refactor to use new methods
|
||||
to generate NSTableRowView when it is view-based.
|
||||
* Source/NSTableRowView.m: Add implementation of
|
||||
NSTableRowView implementation.
|
||||
* Source/NSTableView.m: Update to use NSTableRowView
|
||||
when it is view-based.
|
||||
|
||||
2024-06-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* ChangeLog: Update for new release
|
||||
|
@ -20,7 +37,7 @@
|
|||
|
||||
2024-05-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* ChangeLog: Update for new release
|
||||
* ChangeLog: Update for new release
|
||||
* ANNOUNCE:
|
||||
* NEWS:
|
||||
* Documentation/news.texi: Update of release notes for 0.31.0.
|
||||
|
|
|
@ -253,6 +253,7 @@
|
|||
@class NSPopUpButtonCell;
|
||||
@class NSMenuView;
|
||||
@class NSProgressIndicator;
|
||||
@class NSTableColumn;
|
||||
@class NSTableHeaderCell;
|
||||
@class NSTableView;
|
||||
@class NSTabViewItem;
|
||||
|
@ -1341,9 +1342,11 @@ APPKIT_EXPORT_CLASS
|
|||
clipRect: (NSRect)clipRect
|
||||
inView: (NSTableView *)view;
|
||||
|
||||
- (void) drawCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSTableView *)v;
|
||||
- (NSRect) drawOutlineCell: (NSTableColumn *)tb
|
||||
outlineView: (NSOutlineView *)outlineView
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex;
|
||||
|
||||
- (void) drawOutlineViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
/* Definition of class NSTableRowView
|
||||
Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
|
||||
|
||||
By: Gregory John Casamento <greg.casamento@gmail.com>
|
||||
Date: 03-09-2022
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
|
@ -25,7 +25,8 @@
|
|||
#ifndef _NSTableRowView_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSTableRowView_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSTableView.h>
|
||||
#import <AppKit/NSCell.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
|
||||
|
||||
|
@ -34,6 +35,78 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
@interface NSTableRowView : NSView
|
||||
{
|
||||
// Display style...
|
||||
BOOL _emphasized;
|
||||
NSBackgroundStyle _interiorBackgroundStyle;
|
||||
BOOL _floating;
|
||||
|
||||
// Row selection...
|
||||
BOOL _selected;
|
||||
NSTableViewSelectionHighlightStyle _selectionHighlightStyle;
|
||||
|
||||
// Drag and Drop...
|
||||
NSTableViewDraggingDestinationFeedbackStyle _draggingDestinationFeedbackStyle;
|
||||
CGFloat _indentationForDropOperation;
|
||||
BOOL _targetForDropOperation;
|
||||
|
||||
// Row grouping...
|
||||
BOOL _groupRowStyle;
|
||||
NSInteger _numberOfColumns;
|
||||
|
||||
// Overriding row view display characteristics...
|
||||
NSColor *_backgroundColor;
|
||||
|
||||
BOOL _nextRowSelected;
|
||||
BOOL _previousRowSelected;
|
||||
}
|
||||
|
||||
- (BOOL) isEmphasized;
|
||||
- (void) setEmphasized: (BOOL)flag;
|
||||
|
||||
- (NSBackgroundStyle) interiorBackgroundStyle;
|
||||
|
||||
- (BOOL) isFloating;
|
||||
- (void) setFloating: (BOOL)flag;
|
||||
|
||||
- (BOOL) isSelected;
|
||||
- (void) setSelected: (BOOL)flag;
|
||||
|
||||
- (NSTableViewSelectionHighlightStyle) selectionHighlightStyle;
|
||||
- (void) setSelectionHighlightStyle: (NSTableViewSelectionHighlightStyle) selectionHighlightStyle;
|
||||
|
||||
- (NSTableViewDraggingDestinationFeedbackStyle) draggingDestinationFeedbackStyle;
|
||||
- (void) setTableViewDraggingDestinationFeedbackStyle: (NSTableViewDraggingDestinationFeedbackStyle) draggingDestinationFeedbackStyle;
|
||||
|
||||
- (CGFloat) indentationForDropOperation;
|
||||
- (void) setIndentationForDropOperation: (CGFloat)indentationForDropOperation;
|
||||
|
||||
- (BOOL) targetForDropOperation;
|
||||
- (void) setTargetForDropOperation: (BOOL)flag;
|
||||
|
||||
- (BOOL) groupRowStyle;
|
||||
- (void) setGroupRowStyle: (BOOL)flag;
|
||||
|
||||
- (NSInteger) numberOfColumns;
|
||||
|
||||
- (NSColor *) backgroundColor;
|
||||
- (void) setBackgroundColor: (NSColor *)color;
|
||||
|
||||
- (void) drawBackgroundInRect: (NSRect)dirtyRect;
|
||||
|
||||
- (void) drawDraggingDestinationFeedbackInRect: (NSRect)dirtyRect;
|
||||
|
||||
- (void) drawSelectionInRect: (NSRect)dirtyRect;
|
||||
|
||||
- (void) drawSeparatorInRect: (NSRect)dirtyRect;
|
||||
|
||||
- (id) viewAtColumn: (NSInteger)column;
|
||||
|
||||
- (BOOL) isNextRowSelected;
|
||||
- (void) setNextRowSelected: (BOOL)flag;
|
||||
|
||||
- (BOOL) isPreviousRowSelected;
|
||||
- (void) setPreviousRowSelected: (BOOL)flag;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -102,6 +102,15 @@ typedef enum _NSTableViewRowSizeStyle
|
|||
} NSTableViewRowSizeStyle;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
typedef enum _NSTableViewDraggingDestinationFeedbackStyle
|
||||
{
|
||||
NSTableViewDraggingDestinationFeedbackStyleNone = 0,
|
||||
NSTableViewDraggingDestinationFeedbackStyleRegular,
|
||||
NSTableViewDraggingDestinationFeedbackStyleSourceList,
|
||||
NSTableViewDraggingDestinationFeedbackStyleGap,
|
||||
} NSTableViewDraggingDestinationFeedbackStyle;
|
||||
#endif
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSTableView : NSControl <NSUserInterfaceValidations>
|
||||
|
@ -195,6 +204,9 @@ APPKIT_EXPORT_CLASS
|
|||
NSMapTable *_pathsToViews;
|
||||
NSMutableDictionary *_registeredNibs;
|
||||
NSMutableDictionary *_registeredViews;
|
||||
|
||||
/* NSTableRowView support */
|
||||
NSMutableDictionary *_rowViews;
|
||||
}
|
||||
|
||||
/* Data Source */
|
||||
|
@ -402,6 +414,8 @@ APPKIT_EXPORT_CLASS
|
|||
- (void) removeRowsAtIndexes: (NSIndexSet*)indexes withAnimation: (NSTableViewAnimationOptions)animationOptions;
|
||||
- (NSInteger) rowForView: (NSView*)view;
|
||||
- (NSView *) makeViewWithIdentifier: (NSUserInterfaceItemIdentifier)identifier owner: (id)owner;
|
||||
- (NSTableRowView *) rowViewAtRow: (NSInteger)row makeIfNecessary: (BOOL)flag;
|
||||
- (NSView *) viewAtColumn: (NSInteger)column row: (NSInteger)row makeIfNecessary: (BOOL)flag;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST)
|
||||
|
|
|
@ -82,12 +82,9 @@
|
|||
row: (NSInteger)index;
|
||||
- (id)_objectValueForTableColumn: (NSTableColumn *)tb
|
||||
row: (NSInteger)index;
|
||||
- (NSView *) _renderedViewForPath: (NSIndexPath *)path;
|
||||
- (void) _setRenderedView: (NSView *)view forPath: (NSIndexPath *)path;
|
||||
@end
|
||||
|
||||
@interface NSTableColumn (Private)
|
||||
- (NSArray *) _prototypeCellViews;
|
||||
- (void) _calculatedStartingColumn: (NSInteger *)startingColumn
|
||||
endingColumn: (NSInteger *)endingColumn
|
||||
inClipRect: (NSRect)clipRect;
|
||||
@end
|
||||
|
||||
@interface NSCell (Private)
|
||||
|
@ -3384,45 +3381,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (void) _calculatedStartingColumn: (NSInteger *)startingColumn
|
||||
endingColumn: (NSInteger *)endingColumn
|
||||
withTableView: (NSTableView *)tableView
|
||||
inClipRect: (NSRect)clipRect
|
||||
|
||||
{
|
||||
CGFloat x_pos = 0.0;
|
||||
NSInteger i = 0;
|
||||
NSInteger numberOfColumns = [tableView numberOfColumns];
|
||||
CGFloat *columnOrigins = [tableView _columnOrigins];
|
||||
|
||||
/* Using columnAtPoint: here would make it called twice per row per drawn
|
||||
rect - so we avoid it and do it natively */
|
||||
|
||||
/* Determine starting column as fast as possible */
|
||||
x_pos = NSMinX (clipRect);
|
||||
i = 0;
|
||||
while ((i < numberOfColumns) && (x_pos > columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
*startingColumn = (i - 1);
|
||||
|
||||
if (*startingColumn == -1)
|
||||
*startingColumn = 0;
|
||||
|
||||
/* Determine ending column as fast as possible */
|
||||
x_pos = NSMaxX (clipRect);
|
||||
// Nota Bene: we do *not* reset i
|
||||
while ((i < numberOfColumns) && (x_pos > columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
*endingColumn = (i - 1);
|
||||
|
||||
if (*endingColumn == -1)
|
||||
*endingColumn = numberOfColumns - 1;
|
||||
}
|
||||
|
||||
- (void) drawTableViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSTableView *)tableView
|
||||
|
@ -3441,10 +3399,9 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSColor *selectedTextColor = [self colorNamed: @"highlightedTableRowTextColor"
|
||||
state: GSThemeNormalState];
|
||||
|
||||
[self _calculatedStartingColumn: &startingColumn
|
||||
endingColumn: &endingColumn
|
||||
withTableView: tableView
|
||||
inClipRect: clipRect];
|
||||
[tableView _calculatedStartingColumn: &startingColumn
|
||||
endingColumn: &endingColumn
|
||||
inClipRect: clipRect];
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
|
@ -3495,11 +3452,11 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (NSRect) _drawOutlineTableColumn: (NSTableColumn *)tb
|
||||
outlineView: (NSOutlineView *)outlineView
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex
|
||||
- (NSRect) drawOutlineCell: (NSTableColumn *)tb
|
||||
outlineView: (NSOutlineView *)outlineView
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex
|
||||
{
|
||||
NSRect drawingRect = inputRect;
|
||||
NSImage *image = nil;
|
||||
|
@ -3519,17 +3476,17 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
{
|
||||
image = [NSImage imageNamed: @"common_ArrowRightH"];
|
||||
}
|
||||
|
||||
|
||||
if (![outlineView isExpandable: item])
|
||||
{
|
||||
image = AUTORELEASE([[NSImage alloc] initWithSize: NSMakeSize(14.0,14.0)]);
|
||||
}
|
||||
|
||||
|
||||
level = [outlineView levelForItem: item];
|
||||
indentationFactor = indentationPerLevel * level;
|
||||
imageCell = [[NSCell alloc] initImageCell: image];
|
||||
imageRect = [outlineView frameOfOutlineCellAtRow: rowIndex];
|
||||
|
||||
|
||||
if ([delegate respondsToSelector: @selector(outlineView:willDisplayOutlineCell:forTableColumn:item:)])
|
||||
{
|
||||
[delegate outlineView: outlineView
|
||||
|
@ -3537,7 +3494,7 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
forTableColumn: tb
|
||||
item: item];
|
||||
}
|
||||
|
||||
|
||||
/* Do not indent if the delegate set the image to nil. */
|
||||
if ([imageCell image])
|
||||
{
|
||||
|
@ -3554,7 +3511,7 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
drawingRect.origin.x += indentationFactor;
|
||||
drawingRect.size.width -= indentationFactor;
|
||||
}
|
||||
|
||||
|
||||
RELEASE(imageCell);
|
||||
|
||||
return drawingRect;
|
||||
|
@ -3574,7 +3531,7 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSInteger i;
|
||||
id dataSource = [outlineView dataSource];
|
||||
NSTableColumn *outlineTableColumn = [outlineView outlineTableColumn];
|
||||
|
||||
|
||||
if (dataSource == nil)
|
||||
{
|
||||
return;
|
||||
|
@ -3588,10 +3545,9 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
return;
|
||||
}
|
||||
|
||||
[self _calculatedStartingColumn: &startingColumn
|
||||
endingColumn: &endingColumn
|
||||
withTableView: outlineView
|
||||
inClipRect: clipRect];
|
||||
[outlineView _calculatedStartingColumn: &startingColumn
|
||||
endingColumn: &endingColumn
|
||||
inClipRect: clipRect];
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
|
@ -3620,13 +3576,13 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
|
||||
if (tb == outlineTableColumn)
|
||||
{
|
||||
drawingRect = [self _drawOutlineTableColumn: tb
|
||||
outlineView: outlineView
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: rowIndex];
|
||||
drawingRect = [self drawOutlineCell: tb
|
||||
outlineView: outlineView
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: rowIndex];
|
||||
}
|
||||
|
||||
|
||||
[cell drawWithFrame: drawingRect inView: outlineView];
|
||||
if (i == editedColumn && rowIndex == editedRow)
|
||||
{
|
||||
|
@ -3636,130 +3592,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (id) _prototypeCellViewFromTableColumn: (NSTableColumn *)tb
|
||||
{
|
||||
NSArray *protoCellViews = [tb _prototypeCellViews];
|
||||
id view = nil;
|
||||
|
||||
// it seems there is always one prototype...
|
||||
if ([protoCellViews count] > 0)
|
||||
{
|
||||
view = [protoCellViews objectAtIndex: 0];
|
||||
view = [view copy]; // instantiate the prototype...
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void) drawCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSTableView *)v
|
||||
{
|
||||
NSArray *tableColumns = [v tableColumns];
|
||||
NSInteger numberOfRows = [v numberOfRows];
|
||||
NSInteger startingColumn;
|
||||
NSInteger endingColumn;
|
||||
NSInteger i;
|
||||
id dataSource = [v dataSource];
|
||||
id delegate = [v delegate];
|
||||
BOOL hasMethod = NO;
|
||||
NSTableColumn *outlineTableColumn = nil;
|
||||
NSOutlineView *ov = nil;
|
||||
|
||||
// If we have no data source, there is nothing to do...
|
||||
if (dataSource == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the rowIndex is greater than the numberOfRows, done...
|
||||
if (rowIndex >= numberOfRows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the delegate method...
|
||||
hasMethod = [delegate respondsToSelector: @selector(outlineView:viewForTableColumn:item:)];
|
||||
if (hasMethod)
|
||||
{
|
||||
ov = (NSOutlineView *)v;
|
||||
outlineTableColumn = [ov outlineTableColumn];
|
||||
}
|
||||
else
|
||||
{
|
||||
hasMethod = [delegate respondsToSelector: @selector(tableView:viewForTableColumn:row:)];
|
||||
}
|
||||
|
||||
[self _calculatedStartingColumn: &startingColumn
|
||||
endingColumn: &endingColumn
|
||||
withTableView: v
|
||||
inClipRect: clipRect];
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
{
|
||||
NSRect drawingRect = [v frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
NSTableColumn *tb = [tableColumns objectAtIndex: i];
|
||||
NSIndexPath *path = [NSIndexPath indexPathForItem: i
|
||||
inSection: rowIndex];
|
||||
NSView *view = [v _renderedViewForPath: path];
|
||||
|
||||
if (ov != nil)
|
||||
{
|
||||
id item = [ov itemAtRow: rowIndex];
|
||||
|
||||
if (tb == outlineTableColumn)
|
||||
{
|
||||
drawingRect = [self _drawOutlineTableColumn: tb
|
||||
outlineView: ov
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: rowIndex];
|
||||
}
|
||||
|
||||
if (view == nil)
|
||||
{
|
||||
if (hasMethod)
|
||||
{
|
||||
view = [delegate outlineView: ov
|
||||
viewForTableColumn: tb
|
||||
item: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
view = [self _prototypeCellViewFromTableColumn: tb];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the view has been stored use it, if not
|
||||
// then grab it.
|
||||
if (view == nil)
|
||||
{
|
||||
if (hasMethod)
|
||||
{
|
||||
view = [delegate tableView: v
|
||||
viewForTableColumn: tb
|
||||
row: rowIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
view = [self _prototypeCellViewFromTableColumn: tb];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store the object...
|
||||
[v _setRenderedView: view forPath: path];
|
||||
[v addSubview: view];
|
||||
|
||||
// Place the view...
|
||||
[view setFrame: drawingRect];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isBoxOpaque: (NSBox *)box
|
||||
{
|
||||
if ([box boxType] == NSBoxCustom)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,21 +1,21 @@
|
|||
/* Implementation of class NSTableRowView
|
||||
Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 03-09-2022
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
|
@ -26,5 +26,145 @@
|
|||
|
||||
@implementation NSTableRowView
|
||||
|
||||
@end
|
||||
- (BOOL) isEmphasized
|
||||
{
|
||||
return _emphasized;
|
||||
}
|
||||
|
||||
- (void) setEmphasized: (BOOL)flag
|
||||
{
|
||||
_emphasized = flag;
|
||||
}
|
||||
|
||||
- (NSBackgroundStyle) interiorBackgroundStyle
|
||||
{
|
||||
return _interiorBackgroundStyle;
|
||||
}
|
||||
|
||||
- (BOOL) isFloating
|
||||
{
|
||||
return _floating;
|
||||
}
|
||||
|
||||
- (void) setFloating: (BOOL)flag
|
||||
{
|
||||
_floating = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isSelected
|
||||
{
|
||||
return _selected;
|
||||
}
|
||||
|
||||
- (void) setSelected: (BOOL)flag
|
||||
{
|
||||
_selected = flag;
|
||||
}
|
||||
|
||||
- (NSTableViewSelectionHighlightStyle) selectionHighlightStyle
|
||||
{
|
||||
return _selectionHighlightStyle;
|
||||
}
|
||||
|
||||
- (void) setSelectionHighlightStyle: (NSTableViewSelectionHighlightStyle) selectionHighlightStyle
|
||||
{
|
||||
_selectionHighlightStyle = selectionHighlightStyle;
|
||||
}
|
||||
|
||||
- (NSTableViewDraggingDestinationFeedbackStyle) draggingDestinationFeedbackStyle
|
||||
{
|
||||
return _draggingDestinationFeedbackStyle;
|
||||
}
|
||||
|
||||
- (void) setTableViewDraggingDestinationFeedbackStyle: (NSTableViewDraggingDestinationFeedbackStyle) draggingDestinationFeedbackStyle
|
||||
{
|
||||
_draggingDestinationFeedbackStyle = draggingDestinationFeedbackStyle;
|
||||
}
|
||||
|
||||
- (CGFloat) indentationForDropOperation
|
||||
{
|
||||
return _indentationForDropOperation;
|
||||
}
|
||||
|
||||
- (void) setIndentationForDropOperation: (CGFloat)indentationForDropOperation
|
||||
{
|
||||
_indentationForDropOperation = indentationForDropOperation;
|
||||
}
|
||||
|
||||
- (BOOL) targetForDropOperation
|
||||
{
|
||||
return _targetForDropOperation;
|
||||
}
|
||||
|
||||
- (void) setTargetForDropOperation: (BOOL)flag
|
||||
{
|
||||
_targetForDropOperation = flag;
|
||||
}
|
||||
|
||||
- (BOOL) groupRowStyle
|
||||
{
|
||||
return _groupRowStyle;
|
||||
}
|
||||
|
||||
- (void) setGroupRowStyle: (BOOL)flag
|
||||
{
|
||||
_groupRowStyle = flag;
|
||||
}
|
||||
|
||||
- (NSInteger) numberOfColumns
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSColor *) backgroundColor
|
||||
{
|
||||
return _backgroundColor;
|
||||
}
|
||||
|
||||
- (void) setBackgroundColor: (NSColor *)color
|
||||
{
|
||||
ASSIGN(_backgroundColor, color);
|
||||
}
|
||||
|
||||
- (void) drawBackgroundInRect: (NSRect)dirtyRect
|
||||
{
|
||||
}
|
||||
|
||||
- (void) drawDraggingDestinationFeedbackInRect: (NSRect)dirtyRect
|
||||
{
|
||||
}
|
||||
|
||||
- (void) drawSelectionInRect: (NSRect)dirtyRect
|
||||
{
|
||||
}
|
||||
|
||||
- (void) drawSeparatorInRect: (NSRect)dirtyRect
|
||||
{
|
||||
}
|
||||
|
||||
- (id) viewAtColumn: (NSInteger)column
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) isNextRowSelected
|
||||
{
|
||||
return _nextRowSelected;
|
||||
}
|
||||
|
||||
- (void) setNextRowSelected: (BOOL)flag
|
||||
{
|
||||
_nextRowSelected = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isPreviousRowSelected
|
||||
{
|
||||
return _previousRowSelected;
|
||||
}
|
||||
|
||||
- (void) setPreviousRowSelected: (BOOL)flag
|
||||
{
|
||||
_previousRowSelected = flag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#import "AppKit/NSScrollView.h"
|
||||
#import "AppKit/NSTableColumn.h"
|
||||
#import "AppKit/NSTableHeaderView.h"
|
||||
#import "AppKit/NSTableRowView.h"
|
||||
#import "AppKit/NSText.h"
|
||||
#import "AppKit/NSTextFieldCell.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
|
@ -179,6 +180,10 @@ typedef struct _tableViewFlags
|
|||
- (BOOL) _startDragOperationWithEvent:(NSEvent *)theEvent;
|
||||
@end
|
||||
|
||||
@interface NSTableColumn (Private)
|
||||
- (NSArray *) _prototypeCellViews;
|
||||
@end
|
||||
|
||||
/*
|
||||
* A specific struct and its associated quick sort function
|
||||
* This is used by the -sizeToFit method
|
||||
|
@ -2052,6 +2057,7 @@ static void computeNewSelection
|
|||
_pathsToViews = RETAIN([NSMapTable weakToStrongObjectsMapTable]);
|
||||
_registeredNibs = [[NSMutableDictionary alloc] init];
|
||||
_registeredViews = [[NSMutableDictionary alloc] init];
|
||||
_rowViews = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
|
@ -2087,6 +2093,7 @@ static void computeNewSelection
|
|||
RELEASE (_pathsToViews);
|
||||
RELEASE (_registeredNibs);
|
||||
RELEASE (_registeredViews);
|
||||
RELEASE (_rowViews);
|
||||
TEST_RELEASE (_headerView);
|
||||
TEST_RELEASE (_cornerView);
|
||||
if (_autosaveTableColumns == YES)
|
||||
|
@ -2371,6 +2378,7 @@ static void computeNewSelection
|
|||
{
|
||||
[_renderedViewPaths removeAllObjects];
|
||||
[_pathsToViews removeAllObjects];
|
||||
[_rowViews removeAllObjects];
|
||||
}
|
||||
|
||||
[self noteNumberOfRowsChanged];
|
||||
|
@ -5052,14 +5060,119 @@ This method is deprecated, use -columnIndexesInRect:. */
|
|||
/*
|
||||
* Drawing
|
||||
*/
|
||||
- (void) _calculatedStartingColumn: (NSInteger *)startingColumn
|
||||
endingColumn: (NSInteger *)endingColumn
|
||||
inClipRect: (NSRect)clipRect
|
||||
|
||||
{
|
||||
CGFloat x_pos = 0.0;
|
||||
NSInteger i = 0;
|
||||
NSInteger numberOfColumns = [self numberOfColumns];
|
||||
CGFloat *columnOrigins = [self _columnOrigins];
|
||||
|
||||
/* Using columnAtPoint: here would make it called twice per row per drawn
|
||||
rect - so we avoid it and do it natively */
|
||||
|
||||
/* Determine starting column as fast as possible */
|
||||
x_pos = NSMinX (clipRect);
|
||||
i = 0;
|
||||
while ((i < numberOfColumns) && (x_pos > columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
*startingColumn = (i - 1);
|
||||
|
||||
if (*startingColumn == -1)
|
||||
*startingColumn = 0;
|
||||
|
||||
/* Determine ending column as fast as possible */
|
||||
x_pos = NSMaxX (clipRect);
|
||||
// Nota Bene: we do *not* reset i
|
||||
while ((i < numberOfColumns) && (x_pos > columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
*endingColumn = (i - 1);
|
||||
|
||||
if (*endingColumn == -1)
|
||||
*endingColumn = numberOfColumns - 1;
|
||||
}
|
||||
|
||||
- (void) _drawCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
{
|
||||
NSInteger numberOfRows = [self numberOfRows];
|
||||
NSInteger startingColumn;
|
||||
NSInteger endingColumn;
|
||||
NSInteger columnIndex;
|
||||
id dataSource = [self dataSource];
|
||||
|
||||
// If we have no data source, there is nothing to do...
|
||||
if (dataSource == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the rowIndex is greater than the numberOfRows, done...
|
||||
if (rowIndex >= numberOfRows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[self _calculatedStartingColumn: &startingColumn
|
||||
endingColumn: &endingColumn
|
||||
inClipRect: clipRect];
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (columnIndex = startingColumn; columnIndex <= endingColumn; columnIndex++)
|
||||
{
|
||||
id rowView = [self rowViewAtRow: rowIndex
|
||||
makeIfNecessary: YES];
|
||||
NSView *view = [self viewAtColumn: columnIndex
|
||||
row: rowIndex
|
||||
makeIfNecessary: YES];
|
||||
|
||||
// If the view is already part of the table, don't re-add it...
|
||||
if (rowView != nil
|
||||
&& [[self subviews] containsObject: rowView] == NO)
|
||||
{
|
||||
NSRect cellFrame = [self frameOfCellAtColumn: 0
|
||||
row: rowIndex];
|
||||
CGFloat x = 0.0;
|
||||
CGFloat y = cellFrame.origin.y;
|
||||
CGFloat w = [self frame].size.width;
|
||||
CGFloat h = [self rowHeight];
|
||||
|
||||
NSRect rvFrame = NSMakeRect(x, y, w, h);
|
||||
NSAutoresizingMaskOptions options = NSViewWidthSizable
|
||||
| NSViewMinYMargin;
|
||||
|
||||
[self addSubview: rowView];
|
||||
[rowView setAutoresizingMask: options];
|
||||
[rowView setFrame: rvFrame];
|
||||
}
|
||||
|
||||
// Create the view if needed...
|
||||
if (view != nil &&
|
||||
[[rowView subviews] containsObject: view] == NO)
|
||||
{
|
||||
// Add the view to the row...
|
||||
[rowView addSubview: view];
|
||||
|
||||
// Place the view...
|
||||
NSRect newRect = [view frame];
|
||||
newRect.origin.y = 0.0;
|
||||
[view setFrame: newRect];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawRow: (NSInteger)rowIndex clipRect: (NSRect)clipRect
|
||||
{
|
||||
if (_viewBased)
|
||||
{
|
||||
[[GSTheme theme] drawCellViewRow: rowIndex
|
||||
clipRect: clipRect
|
||||
inView: self];
|
||||
[self _drawCellViewRow: rowIndex
|
||||
clipRect: clipRect];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6919,13 +7032,13 @@ For a more detailed explanation, -setSortDescriptors:. */
|
|||
if (loaded)
|
||||
{
|
||||
NSEnumerator *en = [tlo objectEnumerator];
|
||||
id o = nil;
|
||||
id v = nil;
|
||||
|
||||
while ((o = [en nextObject]) != nil)
|
||||
while ((v = [en nextObject]) != nil)
|
||||
{
|
||||
if ([o isKindOfClass: [NSView class]])
|
||||
if ([v isKindOfClass: [NSView class]])
|
||||
{
|
||||
view = o;
|
||||
view = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6940,6 +7053,85 @@ For a more detailed explanation, -setSortDescriptors:. */
|
|||
return view;
|
||||
}
|
||||
|
||||
- (id) _prototypeCellViewFromTableColumn: (NSTableColumn *)tb
|
||||
{
|
||||
NSArray *protoCellViews = [tb _prototypeCellViews];
|
||||
id view = nil;
|
||||
|
||||
// it seems there is always one prototype...
|
||||
if ([protoCellViews count] > 0)
|
||||
{
|
||||
view = [protoCellViews objectAtIndex: 0];
|
||||
view = [view copy]; // instantiate the prototype...
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (NSTableRowView *) rowViewAtRow: (NSInteger)row makeIfNecessary: (BOOL)flag
|
||||
{
|
||||
NSTableRowView *rv = nil;
|
||||
|
||||
if (_viewBased == YES)
|
||||
{
|
||||
NSNumber *aRow = [NSNumber numberWithInteger: row];
|
||||
|
||||
rv = [_rowViews objectForKey: aRow];
|
||||
if (rv == nil)
|
||||
{
|
||||
if (flag == YES)
|
||||
{
|
||||
if ([_delegate respondsToSelector: @selector(tableView:rowViewForRow:)])
|
||||
{
|
||||
rv = [_delegate tableView: self rowViewForRow: row];
|
||||
}
|
||||
if (rv == nil)
|
||||
{
|
||||
rv = AUTORELEASE([[NSTableRowView alloc] init]);
|
||||
}
|
||||
}
|
||||
|
||||
[_rowViews setObject: rv
|
||||
forKey: aRow];
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
- (NSView *) viewAtColumn: (NSInteger)column row: (NSInteger)row makeIfNecessary: (BOOL)flag
|
||||
{
|
||||
NSTableColumn *tb = [_tableColumns objectAtIndex: column];
|
||||
NSIndexPath *path = [NSIndexPath indexPathForItem: column
|
||||
inSection: row];
|
||||
NSView *view = [self _renderedViewForPath: path];
|
||||
NSRect drawingRect = [self frameOfCellAtColumn: column
|
||||
row: row];
|
||||
|
||||
// If the view has been stored use it, if not
|
||||
// then grab it.
|
||||
if (view == nil
|
||||
&& flag == YES)
|
||||
{
|
||||
if ([_delegate respondsToSelector: @selector(tableView:viewForTableColumn:row:)])
|
||||
{
|
||||
view = [_delegate tableView: self
|
||||
viewForTableColumn: tb
|
||||
row: row];
|
||||
}
|
||||
else
|
||||
{
|
||||
view = [self _prototypeCellViewFromTableColumn: tb];
|
||||
}
|
||||
|
||||
[self _setRenderedView: view forPath: path];
|
||||
}
|
||||
|
||||
[view setFrame: drawingRect];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void) registerNib: (NSNib *)nib
|
||||
forIdentifier: (NSUserInterfaceItemIdentifier)identifier
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue