mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Change to GSThemeDrawing to implement drawTableHeaderRect:inView:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31673 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a34d9f2b4a
commit
be0954d2ac
4 changed files with 110 additions and 86 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,12 @@
|
|||
2010-11-27 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m: Added methods to draw NSTableHeaderView
|
||||
drawTableHeaderRect:inView:.
|
||||
* Source/NSTableHeaderView.m: Added call in to drawing methods in
|
||||
GSTheme.
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
Added declaration for new method.
|
||||
|
||||
2010-11-27 Riccardo Mottola
|
||||
|
||||
* Source/GSThemeDrawing.m:
|
||||
|
@ -10,7 +19,7 @@
|
|||
|
||||
2010-11-26 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m: Added methods to draw NSSliderCell view.
|
||||
* Source/GSThemeDrawing.m: Added methods to draw NSTableHeaderCell view.
|
||||
* Source/NSTableHeaderCell.m: Added call in
|
||||
tableHeaderCellDrawingRectForBounds: to drawing methods in GSTheme.
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
|
|
|
@ -965,6 +965,8 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
- (void) drawKnobInCell: (NSCell *)cell;
|
||||
|
||||
- (NSRect) tableHeaderCellDrawingRectForBounds: (NSRect)theRect;
|
||||
|
||||
- (void) drawTableHeaderRect: (NSRect)aRect inView: (NSView *)view;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,10 @@
|
|||
#import "AppKit/NSScroller.h"
|
||||
#import "AppKit/NSScrollView.h"
|
||||
#import "AppKit/NSStringDrawing.h"
|
||||
#import "AppKit/NSTableView.h"
|
||||
#import "AppKit/NSTableColumn.h"
|
||||
#import "AppKit/NSTableHeaderCell.h"
|
||||
#import "AppKit/NSTableHeaderView.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSTabView.h"
|
||||
#import "AppKit/NSTabViewItem.h"
|
||||
|
@ -2062,4 +2065,96 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
|
||||
return NSInsetRect(theRect, borderSize.width, borderSize.height);
|
||||
}
|
||||
|
||||
- (void)drawTableHeaderRect: (NSRect)aRect
|
||||
inView: (NSView *)view
|
||||
{
|
||||
NSTableHeaderView *tableHeaderView = (NSTableHeaderView *)view;
|
||||
NSTableView *tableView = [tableHeaderView tableView];
|
||||
NSArray *columns;
|
||||
int firstColumnToDraw;
|
||||
int lastColumnToDraw;
|
||||
NSRect drawingRect;
|
||||
NSTableColumn *column;
|
||||
NSTableColumn *highlightedTableColumn;
|
||||
float width;
|
||||
int i;
|
||||
NSCell *cell;
|
||||
|
||||
if (tableView == nil)
|
||||
return;
|
||||
|
||||
firstColumnToDraw = [tableHeaderView columnAtPoint: NSMakePoint (aRect.origin.x,
|
||||
aRect.origin.y)];
|
||||
if (firstColumnToDraw == -1)
|
||||
firstColumnToDraw = 0;
|
||||
|
||||
lastColumnToDraw = [tableHeaderView columnAtPoint: NSMakePoint (NSMaxX (aRect),
|
||||
aRect.origin.y)];
|
||||
if (lastColumnToDraw == -1)
|
||||
lastColumnToDraw = [tableView numberOfColumns] - 1;
|
||||
|
||||
drawingRect = [tableHeaderView headerRectOfColumn: firstColumnToDraw];
|
||||
|
||||
columns = [tableView tableColumns];
|
||||
highlightedTableColumn = [tableView highlightedTableColumn];
|
||||
|
||||
for (i = firstColumnToDraw; i < lastColumnToDraw; i++)
|
||||
{
|
||||
column = [columns objectAtIndex: i];
|
||||
width = [column width];
|
||||
drawingRect.size.width = width;
|
||||
cell = [column headerCell];
|
||||
if ((column == highlightedTableColumn)
|
||||
|| [tableView isColumnSelected: i])
|
||||
{
|
||||
[cell setHighlighted: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setHighlighted: NO];
|
||||
}
|
||||
[cell drawWithFrame: drawingRect
|
||||
inView: tableHeaderView];
|
||||
drawingRect.origin.x += width;
|
||||
}
|
||||
if (lastColumnToDraw == [tableView numberOfColumns] - 1)
|
||||
{
|
||||
column = [columns objectAtIndex: lastColumnToDraw];
|
||||
width = [column width] - 1;
|
||||
drawingRect.size.width = width;
|
||||
cell = [column headerCell];
|
||||
if ((column == highlightedTableColumn)
|
||||
|| [tableView isColumnSelected: lastColumnToDraw])
|
||||
{
|
||||
[cell setHighlighted: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setHighlighted: NO];
|
||||
}
|
||||
[cell drawWithFrame: drawingRect
|
||||
inView: tableHeaderView];
|
||||
drawingRect.origin.x += width;
|
||||
}
|
||||
else
|
||||
{
|
||||
column = [columns objectAtIndex: lastColumnToDraw];
|
||||
width = [column width];
|
||||
drawingRect.size.width = width;
|
||||
cell = [column headerCell];
|
||||
if ((column == highlightedTableColumn)
|
||||
|| [tableView isColumnSelected: lastColumnToDraw])
|
||||
{
|
||||
[cell setHighlighted: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setHighlighted: NO];
|
||||
}
|
||||
[cell drawWithFrame: drawingRect
|
||||
inView: tableHeaderView];
|
||||
drawingRect.origin.x += width;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "AppKit/NSScrollView.h"
|
||||
#include "AppKit/NSGraphics.h"
|
||||
#include "GSGuiPrivate.h"
|
||||
#include "GNUstepGUI/GSTheme.h"
|
||||
|
||||
/*
|
||||
* Number of pixels in either direction that will be counted as a hit
|
||||
|
@ -165,91 +166,8 @@
|
|||
*/
|
||||
- (void)drawRect: (NSRect)aRect
|
||||
{
|
||||
NSArray *columns;
|
||||
int firstColumnToDraw;
|
||||
int lastColumnToDraw;
|
||||
NSRect drawingRect;
|
||||
NSTableColumn *column;
|
||||
NSTableColumn *highlightedTableColumn;
|
||||
float width;
|
||||
int i;
|
||||
NSCell *cell;
|
||||
|
||||
if (_tableView == nil)
|
||||
return;
|
||||
|
||||
firstColumnToDraw = [self columnAtPoint: NSMakePoint (aRect.origin.x,
|
||||
aRect.origin.y)];
|
||||
if (firstColumnToDraw == -1)
|
||||
firstColumnToDraw = 0;
|
||||
|
||||
lastColumnToDraw = [self columnAtPoint: NSMakePoint (NSMaxX (aRect),
|
||||
aRect.origin.y)];
|
||||
if (lastColumnToDraw == -1)
|
||||
lastColumnToDraw = [_tableView numberOfColumns] - 1;
|
||||
|
||||
drawingRect = [self headerRectOfColumn: firstColumnToDraw];
|
||||
|
||||
columns = [_tableView tableColumns];
|
||||
highlightedTableColumn = [_tableView highlightedTableColumn];
|
||||
|
||||
for (i = firstColumnToDraw; i < lastColumnToDraw; i++)
|
||||
{
|
||||
column = [columns objectAtIndex: i];
|
||||
width = [column width];
|
||||
drawingRect.size.width = width;
|
||||
cell = [column headerCell];
|
||||
if ((column == highlightedTableColumn)
|
||||
|| [_tableView isColumnSelected: i])
|
||||
{
|
||||
[cell setHighlighted: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setHighlighted: NO];
|
||||
}
|
||||
[cell drawWithFrame: drawingRect
|
||||
inView: self];
|
||||
drawingRect.origin.x += width;
|
||||
}
|
||||
if (lastColumnToDraw == [_tableView numberOfColumns] - 1)
|
||||
{
|
||||
column = [columns objectAtIndex: lastColumnToDraw];
|
||||
width = [column width] - 1;
|
||||
drawingRect.size.width = width;
|
||||
cell = [column headerCell];
|
||||
if ((column == highlightedTableColumn)
|
||||
|| [_tableView isColumnSelected: lastColumnToDraw])
|
||||
{
|
||||
[cell setHighlighted: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setHighlighted: NO];
|
||||
}
|
||||
[cell drawWithFrame: drawingRect
|
||||
inView: self];
|
||||
drawingRect.origin.x += width;
|
||||
}
|
||||
else
|
||||
{
|
||||
column = [columns objectAtIndex: lastColumnToDraw];
|
||||
width = [column width];
|
||||
drawingRect.size.width = width;
|
||||
cell = [column headerCell];
|
||||
if ((column == highlightedTableColumn)
|
||||
|| [_tableView isColumnSelected: lastColumnToDraw])
|
||||
{
|
||||
[cell setHighlighted: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cell setHighlighted: NO];
|
||||
}
|
||||
[cell drawWithFrame: drawingRect
|
||||
inView: self];
|
||||
drawingRect.origin.x += width;
|
||||
}
|
||||
[[GSTheme theme] drawTableHeaderRect: aRect
|
||||
inView: self];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue