Adding theme method for NSBrowser drawing.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31658 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2010-11-26 19:49:04 +00:00
parent 538432c72f
commit eac1ad07ad
4 changed files with 99 additions and 68 deletions

View file

@ -1,6 +1,14 @@
2010-11-26 Gregory John Casamento <greg.casamento@gmail.com>
* Source/GSThemeDrawing.m: Added method to scroller view.
* Source/GSThemeDrawing.m: Added method to draw NSBrowser view.
* Source/NSBrowser.m: Added call in drawRect: to new drawing method
in GSTheme.
* Headers/Additions/GNUstepGUI/GSTheme.h:
Added declaration for new method.
2010-11-26 Gregory John Casamento <greg.casamento@gmail.com>
* Source/GSThemeDrawing.m: Added method to draw NSScroller view.
* Source/NSScroller.m: Added call in drawRect: to new drawing method
in GSTheme.
* Headers/Additions/GNUstepGUI/GSTheme.h:

View file

@ -944,6 +944,11 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
inView: (NSView *)view
hitPart: (NSScrollerPart)hitPart
isHorizontal: (BOOL)isHorizontal;
- (void) drawBrowserRect: (NSRect)rect
inView: (NSView *)view
withScrollerRect: (NSRect)scrollerRect
columnSize: (NSSize)columnSize;
@end
/**

View file

@ -31,6 +31,7 @@
#import "AppKit/NSAttributedString.h"
#import "AppKit/NSBezierPath.h"
#import "AppKit/NSButtonCell.h"
#import "AppKit/NSBrowser.h"
#import "AppKit/NSCell.h"
#import "AppKit/NSColor.h"
#import "AppKit/NSColorList.h"
@ -1821,4 +1822,84 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
}
}
- (void) drawBrowserRect: (NSRect)rect
inView: (NSView *)view
withScrollerRect: (NSRect)scrollerRect
columnSize: (NSSize)columnSize
{
NSBrowser *browser = (NSBrowser *)view;
NSRect bounds = [view bounds];
// Load the first column if not already done
if (![browser isLoaded])
{
[browser loadColumnZero];
}
// Draws titles
if ([browser isTitled])
{
int i;
for (i = [browser firstVisibleColumn];
i <= [browser lastVisibleColumn];
++i)
{
NSRect titleRect = [browser titleFrameOfColumn: i];
if (NSIntersectsRect (titleRect, rect) == YES)
{
[browser drawTitleOfColumn: i
inRect: titleRect];
}
}
}
// Draws scroller border
if ([browser hasHorizontalScroller] &&
[browser separatesColumns])
{
NSRect scrollerBorderRect = scrollerRect;
NSSize bs = [self sizeForBorderType: NSBezelBorder];
scrollerBorderRect.origin.x = 0;
scrollerBorderRect.origin.y = 0;
scrollerBorderRect.size.width += 2 * bs.width;
scrollerBorderRect.size.height += (2 * bs.height) - 1;
if ((NSIntersectsRect (scrollerBorderRect, rect) == YES) && [view window])
{
[self drawGrayBezel: scrollerBorderRect withClip: rect];
}
}
if (![browser separatesColumns])
{
NSPoint p1,p2;
int i, visibleColumns;
float hScrollerWidth = [browser hasHorizontalScroller] ?
[NSScroller scrollerWidth] : 0;
// Columns borders
[self drawGrayBezel: bounds withClip: rect];
[[NSColor blackColor] set];
visibleColumns = [browser numberOfVisibleColumns];
for (i = 1; i < visibleColumns; i++)
{
p1 = NSMakePoint((columnSize.width * i) + 2 + (i-1),
columnSize.height + hScrollerWidth + 2);
p2 = NSMakePoint((columnSize.width * i) + 2 + (i-1),
hScrollerWidth + 2);
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
}
// Horizontal scroller border
if ([browser hasHorizontalScroller])
{
p1 = NSMakePoint(2, hScrollerWidth + 2);
p2 = NSMakePoint(rect.size.width - 2, hScrollerWidth + 2);
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
}
}
}
@end

View file

@ -2324,73 +2324,10 @@ static NSTextFieldCell *titleCell;
- (void) drawRect: (NSRect)rect
{
// Load the first column if not already done
if (!_isLoaded)
{
[self loadColumnZero];
}
// Draws titles
if (_isTitled)
{
int i;
for (i = _firstVisibleColumn; i <= _lastVisibleColumn; ++i)
{
NSRect titleRect = [self titleFrameOfColumn: i];
if (NSIntersectsRect (titleRect, rect) == YES)
{
[self drawTitleOfColumn: i
inRect: titleRect];
}
}
}
// Draws scroller border
if (_hasHorizontalScroller && _separatesColumns)
{
NSRect scrollerBorderRect = _scrollerRect;
NSSize bs = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
scrollerBorderRect.origin.x = 0;
scrollerBorderRect.origin.y = 0;
scrollerBorderRect.size.width += 2 * bs.width;
scrollerBorderRect.size.height += (2 * bs.height) - 1;
if ((NSIntersectsRect (scrollerBorderRect, rect) == YES) && _window)
{
[[GSTheme theme] drawGrayBezel: scrollerBorderRect withClip: rect];
}
}
if (!_separatesColumns)
{
NSPoint p1,p2;
int i, visibleColumns;
float hScrollerWidth = _hasHorizontalScroller ? scrollerWidth : 0;
// Columns borders
[[GSTheme theme] drawGrayBezel: _bounds withClip: rect];
[[NSColor blackColor] set];
visibleColumns = [self numberOfVisibleColumns];
for (i = 1; i < visibleColumns; i++)
{
p1 = NSMakePoint((_columnSize.width * i) + 2 + (i-1),
_columnSize.height + hScrollerWidth + 2);
p2 = NSMakePoint((_columnSize.width * i) + 2 + (i-1),
hScrollerWidth + 2);
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
}
// Horizontal scroller border
if (_hasHorizontalScroller)
{
p1 = NSMakePoint(2, hScrollerWidth + 2);
p2 = NSMakePoint(rect.size.width - 2, hScrollerWidth + 2);
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
}
}
[[GSTheme theme] drawBrowserRect: rect
inView: self
withScrollerRect: _scrollerRect
columnSize: _columnSize];
}
/* Informs the receivers's subviews that the receiver's bounds