mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 12:00:45 +00:00
Final changes suggested by @fredkiefer and some small fixes before merge
This commit is contained in:
parent
f9b89c41e6
commit
cf7b9ebd39
4 changed files with 132 additions and 129 deletions
|
@ -1342,10 +1342,6 @@ 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
|
||||
|
|
|
@ -82,6 +82,9 @@
|
|||
row: (NSInteger)index;
|
||||
- (id)_objectValueForTableColumn: (NSTableColumn *)tb
|
||||
row: (NSInteger)index;
|
||||
- (void) _calculatedStartingColumn: (NSInteger *)startingColumn
|
||||
endingColumn: (NSInteger *)endingColumn
|
||||
inClipRect: (NSRect)clipRect;
|
||||
@end
|
||||
|
||||
@interface NSCell (Private)
|
||||
|
@ -3378,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
|
||||
|
@ -3435,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++)
|
||||
|
@ -3567,7 +3530,8 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSRect drawingRect;
|
||||
NSInteger i;
|
||||
id dataSource = [outlineView dataSource];
|
||||
|
||||
NSTableColumn *outlineTableColumn = [outlineView outlineTableColumn];
|
||||
|
||||
if (dataSource == nil)
|
||||
{
|
||||
return;
|
||||
|
@ -3581,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++)
|
||||
|
@ -3611,6 +3574,15 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
drawingRect = [outlineView frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
|
||||
if (tb == outlineTableColumn)
|
||||
{
|
||||
drawingRect = [self drawOutlineCell: tb
|
||||
outlineView: outlineView
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: rowIndex];
|
||||
}
|
||||
|
||||
[cell drawWithFrame: drawingRect inView: outlineView];
|
||||
if (i == editedColumn && rowIndex == editedRow)
|
||||
{
|
||||
|
@ -3620,77 +3592,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (void) drawCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSTableView *)tableView
|
||||
{
|
||||
NSInteger numberOfRows = [tableView numberOfRows];
|
||||
NSInteger startingColumn;
|
||||
NSInteger endingColumn;
|
||||
NSInteger columnIndex;
|
||||
id dataSource = [tableView 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
|
||||
withTableView: tableView
|
||||
inClipRect: clipRect];
|
||||
|
||||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (columnIndex = startingColumn; columnIndex <= endingColumn; columnIndex++)
|
||||
{
|
||||
id rowView = [tableView rowViewAtRow: rowIndex
|
||||
makeIfNecessary: YES];
|
||||
NSView *view = [tableView viewAtColumn: columnIndex
|
||||
row: rowIndex
|
||||
makeIfNecessary: YES];
|
||||
|
||||
// If the view is already part of the table, don't re-add it...
|
||||
if (rowView != nil
|
||||
&& [[tableView subviews] containsObject: rowView] == NO)
|
||||
{
|
||||
NSRect cellFrame = [tableView frameOfCellAtColumn: 0
|
||||
row: rowIndex];
|
||||
CGFloat x = 0.0;
|
||||
CGFloat y = cellFrame.origin.y;
|
||||
CGFloat w = [tableView frame].size.width;
|
||||
CGFloat h = [tableView rowHeight];
|
||||
|
||||
NSRect rvFrame = NSMakeRect(x, y, w, h);
|
||||
NSAutoresizingMaskOptions options = NSViewWidthSizable
|
||||
| NSViewMinYMargin;
|
||||
|
||||
[tableView 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isBoxOpaque: (NSBox *)box
|
||||
{
|
||||
if ([box boxType] == NSBoxCustom)
|
||||
|
|
|
@ -139,6 +139,8 @@ static NSImage *unexpandable = nil;
|
|||
- (NSView *) _renderedViewForPath: (NSIndexPath *)path;
|
||||
- (void) _setRenderedView: (NSView *)view forPath: (NSIndexPath *)path;
|
||||
- (id) _prototypeCellViewFromTableColumn: (NSTableColumn *)tb;
|
||||
- (void) _drawCellViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect;
|
||||
@end
|
||||
|
||||
@implementation NSOutlineView
|
||||
|
@ -956,9 +958,8 @@ static NSImage *unexpandable = nil;
|
|||
{
|
||||
if (_viewBased)
|
||||
{
|
||||
[[GSTheme theme] drawCellViewRow: rowIndex
|
||||
clipRect: aRect
|
||||
inView: self];
|
||||
[self _drawCellViewRow: rowIndex
|
||||
clipRect: aRect];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -5060,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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue