mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Add methods to theme and to NSTableView to get the view from the delegate, this is a partial commit to save my place here... will follow up shortly
This commit is contained in:
parent
0be95eba5b
commit
ebdbe0930f
4 changed files with 153 additions and 5 deletions
|
@ -258,6 +258,7 @@
|
|||
@class NSPathComponentCell;
|
||||
@class GSDrawTiles;
|
||||
@class GSTitleView;
|
||||
// @class NSTableCellView;
|
||||
|
||||
APPKIT_EXPORT NSString *GSSwitch;
|
||||
APPKIT_EXPORT NSString *GSRadio;
|
||||
|
@ -1341,6 +1342,14 @@ APPKIT_EXPORT_CLASS
|
|||
|
||||
- (BOOL) isBoxOpaque: (NSBox *)box;
|
||||
|
||||
- (void) drawTableViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSView *)view;
|
||||
|
||||
- (void) drawTableCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSView *)view;
|
||||
|
||||
- (void) drawBoxInClipRect: (NSRect)clipRect
|
||||
boxType: (NSBoxType)boxType
|
||||
borderType: (NSBorderType)borderType
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
@class NSMutableIndexSet;
|
||||
@class NSTableColumn;
|
||||
@class NSTableHeaderView;
|
||||
@class NSTableRowView;
|
||||
@class NSText;
|
||||
@class NSImage;
|
||||
@class NSURL;
|
||||
|
@ -508,6 +509,24 @@ dataCellForTableColumn: (NSTableColumn *)aTableColumn
|
|||
row: (NSInteger)row
|
||||
mouseLocation: (NSPoint)mouse;
|
||||
#endif
|
||||
|
||||
// NSTableCellView based table methods...
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
|
||||
- (NSView *) tableView: (NSTableView *)tableView
|
||||
viewForTableColumn: (NSTableColumn *)aTableColumn
|
||||
row: (NSInteger)rowIndex;
|
||||
|
||||
- (NSTableRowView *) tableView: (NSTableView *)tableView
|
||||
rowViewForRow: (NSInteger)rowIndex;
|
||||
|
||||
- (void) tableView: (NSTableView *)tableView
|
||||
didAddRowView: (NSTableRowView *)rowView
|
||||
forRow: (NSInteger)rowIndex;
|
||||
|
||||
- (void) tableView: (NSTableView *)tableView
|
||||
didRemoveRowView: (NSTableRowView *)rowView
|
||||
forRow: (NSInteger)rowIndex;
|
||||
#endif
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_NSTableView */
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#import "AppKit/NSScrollView.h"
|
||||
#import "AppKit/NSStringDrawing.h"
|
||||
#import "AppKit/NSTableView.h"
|
||||
#import "AppKit/NSTableCellView.h"
|
||||
#import "AppKit/NSTableColumn.h"
|
||||
#import "AppKit/NSTableHeaderCell.h"
|
||||
#import "AppKit/NSTableHeaderView.h"
|
||||
|
@ -3481,9 +3482,119 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
{
|
||||
return ![box isTransparent];
|
||||
}
|
||||
else
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) drawTableCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSView *)view
|
||||
{
|
||||
NSTableView *tableView = (NSTableView *)view;
|
||||
NSInteger numberOfColumns = [tableView numberOfColumns];
|
||||
CGFloat *columnOrigins = [tableView _columnOrigins];
|
||||
NSInteger editedRow = [tableView editedRow];
|
||||
NSInteger editedColumn = [tableView editedColumn];
|
||||
NSArray *tableColumns = [tableView tableColumns];
|
||||
NSInteger startingColumn;
|
||||
NSInteger endingColumn;
|
||||
NSTableColumn *tb;
|
||||
NSRect drawingRect;
|
||||
NSCell *cell;
|
||||
NSInteger i;
|
||||
CGFloat x_pos;
|
||||
const BOOL rowSelected = [[tableView selectedRowIndexes] containsIndex: rowIndex];
|
||||
NSColor *tempColor = nil;
|
||||
NSColor *selectedTextColor = [self colorNamed: @"highlightedTableRowTextColor"
|
||||
state: GSThemeNormalState];
|
||||
id<NSTableViewDelegate> delegate = [tableView delegate];
|
||||
|
||||
NSLog(@"View based NSTableView, in GSTheme...");
|
||||
/* 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]))
|
||||
{
|
||||
return YES;
|
||||
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;
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
{
|
||||
const BOOL columnSelected = [tableView isColumnSelected: i];
|
||||
const BOOL cellSelected = (rowSelected || columnSelected);
|
||||
|
||||
tb = [tableColumns objectAtIndex: i];
|
||||
if ([delegate respondsToSelector: @selector(tableView:viewForTableColumn:row:)])
|
||||
{
|
||||
NSView *view = [delegate tableView: tableView
|
||||
viewForTableColumn: tb
|
||||
row: rowIndex];
|
||||
NSLog(@"View = %@", view);
|
||||
/*
|
||||
cell = [tb dataCellForRow: rowIndex];
|
||||
[tableView _willDisplayCell: cell
|
||||
forTableColumn: tb
|
||||
row: rowIndex];
|
||||
if (i == editedColumn && rowIndex == editedRow)
|
||||
{
|
||||
[cell _setInEditing: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setObjectValue: [tableView _objectValueForTableColumn: tb
|
||||
row: rowIndex]];
|
||||
}
|
||||
drawingRect = [tableView frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
*/
|
||||
}
|
||||
|
||||
// Set the cell text color if the theme provides a custom highlighted
|
||||
// row color.
|
||||
//
|
||||
// FIXME: This could probably be done in a cleaner way. We should
|
||||
// probably do -setHighlighted: YES, and the implementation of
|
||||
// -textColor in NSCell could use that to return a highlighted text color.
|
||||
/*
|
||||
if (cellSelected && (selectedTextColor != nil)
|
||||
&& [cell isKindOfClass: [NSTextFieldCell class]])
|
||||
{
|
||||
tempColor = [cell textColor];
|
||||
[(NSTextFieldCell *)cell setTextColor: selectedTextColor];
|
||||
}
|
||||
|
||||
[cell drawWithFrame: drawingRect inView: tableView];
|
||||
|
||||
if (cellSelected && (selectedTextColor != nil)
|
||||
&& [cell isKindOfClass: [NSTextFieldCell class]])
|
||||
{
|
||||
// Restore the cell's text color if we changed it
|
||||
[(NSTextFieldCell *)cell setTextColor: tempColor];
|
||||
}
|
||||
|
||||
if (i == editedColumn && rowIndex == editedRow)
|
||||
[cell _setInEditing: NO];
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5032,9 +5032,18 @@ This method is deprecated, use -columnIndexesInRect:. */
|
|||
|
||||
- (void) drawRow: (NSInteger)rowIndex clipRect: (NSRect)clipRect
|
||||
{
|
||||
[[GSTheme theme] drawTableViewRow: rowIndex
|
||||
clipRect: clipRect
|
||||
inView: self];
|
||||
if (_viewBased)
|
||||
{
|
||||
[[GSTheme theme] drawTableCellViewRow: rowIndex
|
||||
clipRect: clipRect
|
||||
inView: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[GSTheme theme] drawTableViewRow: rowIndex
|
||||
clipRect: clipRect
|
||||
inView: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) noteHeightOfRowsWithIndexesChanged: (NSIndexSet*)indexes
|
||||
|
|
Loading…
Reference in a new issue