mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
* Source/NSBrowser.m:
* Source/GSThemeDrawing.m: * Headers/Additions/GNUstepGUI/GSTheme.h: Add GSBrowserUseBezels user default. Themes can set it to NO to prevent NSBrowser from drawing any bezels, even if separatesColumns is set to YES. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37174 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f0b96e967f
commit
67de37f017
3 changed files with 132 additions and 71 deletions
|
@ -1102,6 +1102,8 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
|
||||
- (CGFloat) browserVerticalPadding;
|
||||
|
||||
- (BOOL) browserUseBezels;
|
||||
|
||||
- (void) drawMenuRect: (NSRect)rect
|
||||
inView: (NSView *)view
|
||||
isHorizontal: (BOOL)horizontal
|
||||
|
|
|
@ -2096,51 +2096,55 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
|
||||
// Draws scroller border
|
||||
if ([browser hasHorizontalScroller] &&
|
||||
[browser separatesColumns])
|
||||
|
||||
if ([self browserUseBezels])
|
||||
{
|
||||
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;
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
// 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),
|
||||
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];
|
||||
}
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2172,6 +2176,20 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL) browserUseBezels
|
||||
{
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
if ([defs objectForKey: @"GSBrowserUseBezels"] != nil)
|
||||
{
|
||||
return [defs boolForKey: @"GSBrowserUseBezels"];
|
||||
}
|
||||
else
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawMenuRect: (NSRect)rect
|
||||
inView: (NSView *)view
|
||||
isHorizontal: (BOOL)horizontal
|
||||
|
|
|
@ -64,7 +64,7 @@ static CGFloat scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
static NSTextFieldCell *titleCell;
|
||||
static CGFloat browserColumnSeparation;
|
||||
static CGFloat browserVerticalPadding;
|
||||
|
||||
static BOOL browserUseBezels;
|
||||
|
||||
#define NSBR_COLUMN_IS_VISIBLE(i) \
|
||||
(((i)>=_firstVisibleColumn)&&((i)<=_lastVisibleColumn))
|
||||
|
@ -235,6 +235,8 @@ static CGFloat browserVerticalPadding;
|
|||
- (void) _performLoadOfColumn: (NSInteger)column;
|
||||
- (void) _remapColumnSubviews: (BOOL)flag;
|
||||
- (void) _setColumnTitlesNeedDisplay;
|
||||
- (NSBorderType) _resolvedBorderType;
|
||||
- (void) _themeDidActivate: (NSNotification*)notification;
|
||||
@end
|
||||
|
||||
//
|
||||
|
@ -774,15 +776,7 @@ static CGFloat browserVerticalPadding;
|
|||
sc = [[NSScrollView alloc] initWithFrame: rect];
|
||||
[sc setHasHorizontalScroller: NO];
|
||||
[sc setHasVerticalScroller: YES];
|
||||
|
||||
if (_separatesColumns)
|
||||
{
|
||||
[sc setBorderType: NSBezelBorder];
|
||||
}
|
||||
else
|
||||
{
|
||||
[sc setBorderType: NSNoBorder];
|
||||
}
|
||||
[sc setBorderType: [self _resolvedBorderType]];
|
||||
|
||||
[bc setColumnScrollView: sc];
|
||||
[self addSubview: sc];
|
||||
|
@ -1244,8 +1238,7 @@ static CGFloat browserVerticalPadding;
|
|||
|
||||
sw = scrollerWidth;
|
||||
// Take the border into account
|
||||
if (_separatesColumns)
|
||||
sw += 2 * ([[GSTheme theme] sizeForBorderType: NSBezelBorder]).width;
|
||||
sw += 2 * ([[GSTheme theme] sizeForBorderType: [self _resolvedBorderType]]).width;
|
||||
|
||||
// Column width cannot be less than scroller and border
|
||||
if (columnWidth < sw)
|
||||
|
@ -1270,7 +1263,7 @@ static CGFloat browserVerticalPadding;
|
|||
*/
|
||||
- (void) setSeparatesColumns: (BOOL)flag
|
||||
{
|
||||
if (_isTitled)
|
||||
if (_separatesColumns == flag || _isTitled)
|
||||
return;
|
||||
|
||||
_separatesColumns = flag;
|
||||
|
@ -1289,8 +1282,7 @@ static CGFloat browserVerticalPadding;
|
|||
}
|
||||
|
||||
// Take the border into account
|
||||
if (_separatesColumns)
|
||||
cw += 2 * ([[GSTheme theme] sizeForBorderType: NSBezelBorder]).width;
|
||||
cw += 2 * ([[GSTheme theme] sizeForBorderType: [self _resolvedBorderType]]).width;
|
||||
|
||||
return cw;
|
||||
}
|
||||
|
@ -1301,8 +1293,7 @@ static CGFloat browserVerticalPadding;
|
|||
|
||||
cw = columnWidth;
|
||||
// Take the border into account
|
||||
if (_separatesColumns)
|
||||
cw -= 2 * ([[GSTheme theme] sizeForBorderType: NSBezelBorder]).width;
|
||||
cw -= 2 * ([[GSTheme theme] sizeForBorderType: [self _resolvedBorderType]]).width;
|
||||
|
||||
return cw;
|
||||
}
|
||||
|
@ -1754,9 +1745,12 @@ static CGFloat browserVerticalPadding;
|
|||
- (NSRect) frameOfColumn: (NSInteger)column
|
||||
{
|
||||
NSRect rect = NSZeroRect;
|
||||
NSSize bezelBorderSize = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
NSSize bezelBorderSize = NSZeroSize;
|
||||
NSInteger n;
|
||||
|
||||
if (browserUseBezels)
|
||||
bezelBorderSize = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
|
||||
// Number of columns over from the first
|
||||
n = column - _firstVisibleColumn;
|
||||
|
||||
|
@ -1768,7 +1762,7 @@ static CGFloat browserVerticalPadding;
|
|||
{
|
||||
rect.origin.x += n * browserColumnSeparation;
|
||||
}
|
||||
else
|
||||
else if (!_separatesColumns && browserUseBezels)
|
||||
{
|
||||
if (column == _firstVisibleColumn)
|
||||
rect.origin.x += 2;
|
||||
|
@ -1777,17 +1771,25 @@ static CGFloat browserVerticalPadding;
|
|||
}
|
||||
|
||||
// Adjust for horizontal scroller
|
||||
if (_hasHorizontalScroller)
|
||||
if (browserUseBezels)
|
||||
{
|
||||
if (_separatesColumns)
|
||||
rect.origin.y = (scrollerWidth - 1) + (2 * bezelBorderSize.height) +
|
||||
browserVerticalPadding;
|
||||
if (_hasHorizontalScroller)
|
||||
{
|
||||
if (_separatesColumns)
|
||||
rect.origin.y = (scrollerWidth - 1) + (2 * bezelBorderSize.height) +
|
||||
browserVerticalPadding;
|
||||
else
|
||||
rect.origin.y = scrollerWidth + bezelBorderSize.width;
|
||||
}
|
||||
else
|
||||
rect.origin.y = scrollerWidth + bezelBorderSize.width;
|
||||
{
|
||||
rect.origin.y += bezelBorderSize.width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.origin.y += bezelBorderSize.width;
|
||||
if (_hasHorizontalScroller)
|
||||
rect.origin.y = (scrollerWidth - 1);
|
||||
}
|
||||
|
||||
// Padding : _columnSize.width is rounded in "tile" method
|
||||
|
@ -1795,7 +1797,7 @@ static CGFloat browserVerticalPadding;
|
|||
{
|
||||
if (_separatesColumns)
|
||||
rect.size.width = _frame.size.width - rect.origin.x;
|
||||
else
|
||||
else
|
||||
rect.size.width = _frame.size.width -
|
||||
(rect.origin.x + bezelBorderSize.width);
|
||||
}
|
||||
|
@ -1847,10 +1849,13 @@ static CGFloat browserVerticalPadding;
|
|||
*/
|
||||
- (void) tile
|
||||
{
|
||||
NSSize bezelBorderSize = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
NSSize bezelBorderSize = NSZeroSize;
|
||||
NSInteger i, num, columnCount, delta;
|
||||
CGFloat frameWidth;
|
||||
|
||||
if (browserUseBezels)
|
||||
bezelBorderSize = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
|
||||
_columnSize.height = _frame.size.height;
|
||||
|
||||
// Titles (there is no real frames to resize)
|
||||
|
@ -1960,6 +1965,7 @@ static CGFloat browserVerticalPadding;
|
|||
[sc setBorderType: bt];
|
||||
}
|
||||
|
||||
[sc setBorderType: [self _resolvedBorderType]];
|
||||
[sc setFrame: [self frameOfColumn: i]];
|
||||
matrix = [bc columnMatrix];
|
||||
|
||||
|
@ -2192,6 +2198,7 @@ static CGFloat browserVerticalPadding;
|
|||
scrollerWidth = [NSScroller scrollerWidth];
|
||||
browserColumnSeparation = [theme browserColumnSeparation];
|
||||
browserVerticalPadding = [theme browserVerticalPadding];
|
||||
browserUseBezels = [theme browserUseBezels];
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
|
@ -2254,7 +2261,10 @@ static CGFloat browserVerticalPadding;
|
|||
_browserDelegate = nil;
|
||||
_passiveDelegate = YES;
|
||||
_doubleAction = NULL;
|
||||
bs = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
// FIXME: Seems a bit wrong to look at the current theme here
|
||||
bs = NSZeroSize;
|
||||
if (browserUseBezels)
|
||||
bs = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
_minColumnWidth = scrollerWidth + (2 * bs.width);
|
||||
if (_minColumnWidth < 100.0)
|
||||
_minColumnWidth = 100.0;
|
||||
|
@ -2280,11 +2290,19 @@ static CGFloat browserVerticalPadding;
|
|||
_maxVisibleColumns = 3;
|
||||
[self _createColumn];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_themeDidActivate:)
|
||||
name: GSThemeDidActivateNotification
|
||||
object: nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
if ([titleCell controlView] == self)
|
||||
{
|
||||
[titleCell setControlView: nil];
|
||||
|
@ -2706,7 +2724,10 @@ static CGFloat browserVerticalPadding;
|
|||
_browserDelegate = nil;
|
||||
_passiveDelegate = YES;
|
||||
_doubleAction = NULL;
|
||||
bs = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
// FIXME: Seems a bit wrong to look at the current theme here
|
||||
bs = NSZeroSize;
|
||||
if (browserUseBezels)
|
||||
bs = [[GSTheme theme] sizeForBorderType: NSBezelBorder];
|
||||
_minColumnWidth = scrollerWidth + (2 * bs.width);
|
||||
if (_minColumnWidth < 100.0)
|
||||
_minColumnWidth = 100.0;
|
||||
|
@ -2845,6 +2866,12 @@ static CGFloat browserVerticalPadding;
|
|||
_isLoaded = NO;
|
||||
[self tile];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_themeDidActivate:)
|
||||
name: GSThemeDidActivateNotification
|
||||
object: nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -3201,4 +3228,18 @@ static CGFloat browserVerticalPadding;
|
|||
[super setNeedsDisplayInRect: invalidRect];
|
||||
}
|
||||
|
||||
- (NSBorderType) _resolvedBorderType
|
||||
{
|
||||
if (browserUseBezels && _separatesColumns)
|
||||
{
|
||||
return NSBezelBorder;
|
||||
}
|
||||
return NSNoBorder;
|
||||
}
|
||||
|
||||
- (void) _themeDidActivate: (NSNotification*)notification
|
||||
{
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue