mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Added NSTableView to the drawing methods for GSTheme.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31678 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
be0954d2ac
commit
529856ef33
5 changed files with 152 additions and 98 deletions
|
@ -1,3 +1,12 @@
|
|||
2010-11-27 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m: Added methods to draw NSTableView
|
||||
header and view.
|
||||
* Source/NSTableView.m: Added call in to drawing methods in
|
||||
GSTheme.
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
Added declaration for new method.
|
||||
|
||||
2010-11-27 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m: Added methods to draw NSTableHeaderView
|
||||
|
|
|
@ -966,7 +966,16 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
|
||||
- (NSRect) tableHeaderCellDrawingRectForBounds: (NSRect)theRect;
|
||||
|
||||
- (void) drawTableHeaderRect: (NSRect)aRect inView: (NSView *)view;
|
||||
- (void) drawTableHeaderRect: (NSRect)aRect
|
||||
inView: (NSView *)view;
|
||||
|
||||
- (void) drawPopUpButtonCellInteriorWithFrame: (NSRect)cellFrame
|
||||
withCell: (NSCell *)cell
|
||||
inView: (NSView *)controlView;
|
||||
|
||||
- (void) drawTableViewBackgroundInClipRect: (NSRect)clipRect
|
||||
inView: (NSView *)view
|
||||
withBackgroundColor: (NSColor *)backgroundColor;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,6 +63,10 @@
|
|||
/* 8.0 gives us the NeXT Look */
|
||||
#define COLOR_WELL_BORDER_WIDTH 8.0
|
||||
|
||||
@interface NSTableView (Private)
|
||||
- (float *)_columnOrigins;
|
||||
@end
|
||||
|
||||
@implementation GSTheme (Drawing)
|
||||
|
||||
- (void) drawButton: (NSRect)frame
|
||||
|
@ -2157,4 +2161,124 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
drawingRect.origin.x += width;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawPopUpButtonCellInteriorWithFrame: (NSRect)cellFrame
|
||||
withCell: (NSCell *)cell
|
||||
inView: (NSView *)controlView
|
||||
{
|
||||
// Default implementation of this method does nothing.
|
||||
}
|
||||
|
||||
- (void) drawTableViewBackgroundInClipRect: (NSRect)clipRect
|
||||
inView: (NSView *)view
|
||||
withBackgroundColor: (NSColor *)backgroundColor
|
||||
{
|
||||
|
||||
[backgroundColor set];
|
||||
NSRectFill (clipRect);
|
||||
}
|
||||
|
||||
- (void) drawTableViewGridInClipRect: (NSRect)aRect
|
||||
inView: (NSView *)view
|
||||
{
|
||||
NSTableView *tableView = (NSTableView *)view;
|
||||
NSRect bounds = [view bounds];
|
||||
float minX = NSMinX (aRect);
|
||||
float maxX = NSMaxX (aRect);
|
||||
float minY = NSMinY (aRect);
|
||||
float maxY = NSMaxY (aRect);
|
||||
int i;
|
||||
float x_pos;
|
||||
int startingColumn;
|
||||
int endingColumn;
|
||||
int numberOfColumns = [tableView numberOfColumns];
|
||||
NSArray *tableColumns = [tableView tableColumns];
|
||||
NSGraphicsContext *ctxt = GSCurrentContext ();
|
||||
float position = 0.0;
|
||||
float *columnOrigins = [tableView _columnOrigins];
|
||||
int startingRow = [tableView rowAtPoint:
|
||||
NSMakePoint (bounds.origin.x, minY)];
|
||||
int endingRow = [tableView rowAtPoint:
|
||||
NSMakePoint (bounds.origin.x, maxY)];
|
||||
NSColor *gridColor = [tableView gridColor];
|
||||
int rowHeight = [tableView rowHeight];
|
||||
int numberOfRows = [tableView numberOfRows];
|
||||
|
||||
/* Using columnAtPoint:, rowAtPoint: here calls them only twice
|
||||
per drawn rect */
|
||||
x_pos = minX;
|
||||
i = 0;
|
||||
while ((i < numberOfColumns) && (x_pos > columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
startingColumn = (i - 1);
|
||||
|
||||
x_pos = maxX;
|
||||
// Nota Bene: we do *not* reset i
|
||||
while ((i < numberOfColumns) && (x_pos > columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
endingColumn = (i - 1);
|
||||
|
||||
if (endingColumn == -1)
|
||||
endingColumn = numberOfColumns - 1;
|
||||
/*
|
||||
int startingColumn = [tableView columnAtPoint:
|
||||
NSMakePoint (minX, bounds.origin.y)];
|
||||
int endingColumn = [tableView columnAtPoint:
|
||||
NSMakePoint (maxX, bounds.origin.y)];
|
||||
*/
|
||||
|
||||
DPSgsave (ctxt);
|
||||
DPSsetlinewidth (ctxt, 1);
|
||||
[gridColor set];
|
||||
|
||||
if (numberOfRows > 0)
|
||||
{
|
||||
/* Draw horizontal lines */
|
||||
if (startingRow == -1)
|
||||
startingRow = 0;
|
||||
if (endingRow == -1)
|
||||
endingRow = numberOfRows - 1;
|
||||
|
||||
position = bounds.origin.y;
|
||||
position += startingRow * rowHeight;
|
||||
for (i = startingRow; i <= endingRow + 1; i++)
|
||||
{
|
||||
DPSmoveto (ctxt, minX, position);
|
||||
DPSlineto (ctxt, maxX, position);
|
||||
DPSstroke (ctxt);
|
||||
position += rowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (numberOfColumns > 0)
|
||||
{
|
||||
int lastRowPosition = position - rowHeight;
|
||||
/* Draw vertical lines */
|
||||
if (startingColumn == -1)
|
||||
startingColumn = 0;
|
||||
if (endingColumn == -1)
|
||||
endingColumn = numberOfColumns - 1;
|
||||
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
{
|
||||
DPSmoveto (ctxt, columnOrigins[i], minY);
|
||||
DPSlineto (ctxt, columnOrigins[i], lastRowPosition);
|
||||
DPSstroke (ctxt);
|
||||
}
|
||||
position = columnOrigins[endingColumn];
|
||||
position += [[tableColumns objectAtIndex: endingColumn] width];
|
||||
/* Last vertical line must moved a pixel to the left */
|
||||
if (endingColumn == (numberOfColumns - 1))
|
||||
position -= 1;
|
||||
DPSmoveto (ctxt, position, minY);
|
||||
DPSlineto (ctxt, position, lastRowPosition);
|
||||
DPSstroke (ctxt);
|
||||
}
|
||||
|
||||
DPSgrestore (ctxt);
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -1063,6 +1063,9 @@ static NSImage *_pbc_image[5];
|
|||
|
||||
/* We need to calc our size to get images placed correctly */
|
||||
[self calcSize];
|
||||
[[GSTheme theme] drawPopUpButtonCellInteriorWithFrame: cellFrame
|
||||
withCell: self
|
||||
inView: controlView];
|
||||
[super drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
|
||||
/* Unset the item to restore balance if a new was created */
|
||||
|
|
|
@ -5023,100 +5023,8 @@ This method is deprecated, use -columnIndexesInRect:. */
|
|||
|
||||
- (void) drawGridInClipRect: (NSRect)aRect
|
||||
{
|
||||
float minX = NSMinX (aRect);
|
||||
float maxX = NSMaxX (aRect);
|
||||
float minY = NSMinY (aRect);
|
||||
float maxY = NSMaxY (aRect);
|
||||
int i;
|
||||
float x_pos;
|
||||
int startingColumn;
|
||||
int endingColumn;
|
||||
|
||||
NSGraphicsContext *ctxt = GSCurrentContext ();
|
||||
float position = 0.0;
|
||||
|
||||
int startingRow = [self rowAtPoint:
|
||||
NSMakePoint (_bounds.origin.x, minY)];
|
||||
int endingRow = [self rowAtPoint:
|
||||
NSMakePoint (_bounds.origin.x, maxY)];
|
||||
|
||||
/* Using columnAtPoint:, rowAtPoint: here calls them only twice
|
||||
|
||||
per drawn rect */
|
||||
x_pos = minX;
|
||||
i = 0;
|
||||
while ((i < _numberOfColumns) && (x_pos > _columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
startingColumn = (i - 1);
|
||||
|
||||
x_pos = maxX;
|
||||
// Nota Bene: we do *not* reset i
|
||||
while ((i < _numberOfColumns) && (x_pos > _columnOrigins[i]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
endingColumn = (i - 1);
|
||||
|
||||
if (endingColumn == -1)
|
||||
endingColumn = _numberOfColumns - 1;
|
||||
/*
|
||||
int startingColumn = [self columnAtPoint:
|
||||
NSMakePoint (minX, _bounds.origin.y)];
|
||||
int endingColumn = [self columnAtPoint:
|
||||
NSMakePoint (maxX, _bounds.origin.y)];
|
||||
*/
|
||||
|
||||
DPSgsave (ctxt);
|
||||
DPSsetlinewidth (ctxt, 1);
|
||||
[_gridColor set];
|
||||
|
||||
if (_numberOfRows > 0)
|
||||
{
|
||||
/* Draw horizontal lines */
|
||||
if (startingRow == -1)
|
||||
startingRow = 0;
|
||||
if (endingRow == -1)
|
||||
endingRow = _numberOfRows - 1;
|
||||
|
||||
position = _bounds.origin.y;
|
||||
position += startingRow * _rowHeight;
|
||||
for (i = startingRow; i <= endingRow + 1; i++)
|
||||
{
|
||||
DPSmoveto (ctxt, minX, position);
|
||||
DPSlineto (ctxt, maxX, position);
|
||||
DPSstroke (ctxt);
|
||||
position += _rowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (_numberOfColumns > 0)
|
||||
{
|
||||
int lastRowPosition = position - _rowHeight;
|
||||
/* Draw vertical lines */
|
||||
if (startingColumn == -1)
|
||||
startingColumn = 0;
|
||||
if (endingColumn == -1)
|
||||
endingColumn = _numberOfColumns - 1;
|
||||
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
{
|
||||
DPSmoveto (ctxt, _columnOrigins[i], minY);
|
||||
DPSlineto (ctxt, _columnOrigins[i], lastRowPosition);
|
||||
DPSstroke (ctxt);
|
||||
}
|
||||
position = _columnOrigins[endingColumn];
|
||||
position += [[_tableColumns objectAtIndex: endingColumn] width];
|
||||
/* Last vertical line must moved a pixel to the left */
|
||||
if (endingColumn == (_numberOfColumns - 1))
|
||||
position -= 1;
|
||||
DPSmoveto (ctxt, position, minY);
|
||||
DPSlineto (ctxt, position, lastRowPosition);
|
||||
DPSstroke (ctxt);
|
||||
}
|
||||
|
||||
DPSgrestore (ctxt);
|
||||
[[GSTheme theme] drawTableViewGridInClipRect: aRect
|
||||
inView: self];
|
||||
}
|
||||
|
||||
- (void) highlightSelectionInClipRect: (NSRect)clipRect
|
||||
|
@ -5198,9 +5106,10 @@ This method is deprecated, use -columnIndexesInRect:. */
|
|||
|
||||
- (void) drawBackgroundInClipRect: (NSRect)clipRect
|
||||
{
|
||||
[_backgroundColor set];
|
||||
NSRectFill (clipRect);
|
||||
}
|
||||
[[GSTheme theme] drawTableViewBackgroundInClipRect: clipRect
|
||||
inView: self
|
||||
withBackgroundColor: _backgroundColor];
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect)aRect
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue