core/gui: Add an option to turn off the inner border lines in NSScrollView which look bad on any non-NeXT like theme

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30186 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2010-04-18 22:39:18 +00:00
parent a4fb383863
commit 5767b71934
2 changed files with 66 additions and 43 deletions

View file

@ -1,3 +1,12 @@
2010-04-18 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSScrollView.m:
Add a new default, GSScrollViewNoInnerBorder, which can be set to
YES so themes can disable drawing of the inner border lines in
NSScrollView. These only look good with a NeXT style theme,
so most non-NeXT-like themes (WinUX, etc.) will want to set
GSScrollViewNoInnerBorder to YES.
2010-04-16 Riccardo Mottola <rmottola@users.sf.net> 2010-04-16 Riccardo Mottola <rmottola@users.sf.net>
* Source/GSToolbarCustomizationPalette.m * Source/GSToolbarCustomizationPalette.m

View file

@ -33,6 +33,7 @@
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSNotification.h> #include <Foundation/NSNotification.h>
#include <Foundation/NSUserDefaults.h>
#include "AppKit/NSColor.h" #include "AppKit/NSColor.h"
#include "AppKit/NSColorList.h" #include "AppKit/NSColorList.h"
@ -145,6 +146,8 @@ static float scrollerWidth;
{ {
NSSize size = frameSize; NSSize size = frameSize;
NSSize border = [[GSTheme theme] sizeForBorderType: borderType]; NSSize border = [[GSTheme theme] sizeForBorderType: borderType];
float innerBorderWidth = [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSScrollViewNoInnerBorder"] ? 0.0 : 1.0;
/* /*
* Substract 1 from the width and height of * Substract 1 from the width and height of
@ -153,11 +156,11 @@ static float scrollerWidth;
*/ */
if (hFlag) if (hFlag)
{ {
size.height -= scrollerWidth + 1; size.height -= scrollerWidth + innerBorderWidth;
} }
if (vFlag) if (vFlag)
{ {
size.width -= scrollerWidth + 1; size.width -= scrollerWidth + innerBorderWidth;
} }
size.width -= 2 * border.width; size.width -= 2 * border.width;
@ -173,6 +176,8 @@ static float scrollerWidth;
{ {
NSSize size = contentSize; NSSize size = contentSize;
NSSize border = [[GSTheme theme] sizeForBorderType: borderType]; NSSize border = [[GSTheme theme] sizeForBorderType: borderType];
float innerBorderWidth = [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSScrollViewNoInnerBorder"] ? 0.0 : 1.0;
/* /*
* Add 1 to the width and height for the line that separates the * Add 1 to the width and height for the line that separates the
@ -180,11 +185,11 @@ static float scrollerWidth;
*/ */
if (hFlag) if (hFlag)
{ {
size.height += scrollerWidth + 1; size.height += scrollerWidth + innerBorderWidth;
} }
if (vFlag) if (vFlag)
{ {
size.width += scrollerWidth + 1; size.width += scrollerWidth + innerBorderWidth;
} }
size.width += 2 * border.width; size.width += 2 * border.width;
@ -1058,6 +1063,8 @@ static float scrollerWidth;
float headerViewHeight = 0; float headerViewHeight = 0;
NSRectEdge verticalScrollerEdge = NSMinXEdge; NSRectEdge verticalScrollerEdge = NSMinXEdge;
NSInterfaceStyle style; NSInterfaceStyle style;
float innerBorderWidth = [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSScrollViewNoInnerBorder"] ? 0.0 : 1.0;
style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil); style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil);
@ -1127,8 +1134,9 @@ static float scrollerWidth;
[_vertScroller setFrame: vertScrollerRect]; [_vertScroller setFrame: vertScrollerRect];
/* Substract 1 for the line that separates the vertical scroller /* Substract 1 for the line that separates the vertical scroller
* from the clip view (and eventually the horizontal scroller). */ * from the clip view (and eventually the horizontal scroller),
NSDivideRect (contentRect, NULL, &contentRect, 1, verticalScrollerEdge); * unless the GSScrollViewNoInnerBorder default is set. */
NSDivideRect (contentRect, NULL, &contentRect, innerBorderWidth, verticalScrollerEdge);
} }
/* Prepare the horizontal scroller. */ /* Prepare the horizontal scroller. */
@ -1142,8 +1150,9 @@ static float scrollerWidth;
[_horizScroller setFrame: horizScrollerRect]; [_horizScroller setFrame: horizScrollerRect];
/* Substract 1 for the width for the line that separates the /* Substract 1 for the width for the line that separates the
* horizontal scroller from the clip view. */ * horizontal scroller from the clip view,
NSDivideRect (contentRect, NULL, &contentRect, 1, bottomEdge); * unless the GSScrollViewNoInnerBorder default is set. */
NSDivideRect (contentRect, NULL, &contentRect, innerBorderWidth, bottomEdge);
} }
/* Now place and size the header view to be exactly above the /* Now place and size the header view to be exactly above the
@ -1202,6 +1211,8 @@ static float scrollerWidth;
GSTheme *theme = [GSTheme theme]; GSTheme *theme = [GSTheme theme];
NSColor *color; NSColor *color;
NSString *name; NSString *name;
BOOL hasInnerBorder = ![[NSUserDefaults standardUserDefaults]
boolForKey: @"GSScrollViewNoInnerBorder"];
name = [theme nameForElement: self]; name = [theme nameForElement: self];
if (name == nil) if (name == nil)
@ -1233,6 +1244,8 @@ static float scrollerWidth;
break; break;
} }
if (hasInnerBorder)
{
[color set]; [color set];
DPSsetlinewidth(ctxt, 1); DPSsetlinewidth(ctxt, 1);
@ -1274,6 +1287,7 @@ static float scrollerWidth;
DPSrlineto(ctxt, [_horizScroller frame].size.width + 1, 0); DPSrlineto(ctxt, [_horizScroller frame].size.width + 1, 0);
DPSstroke(ctxt); DPSstroke(ctxt);
} }
}
} }
- (NSRect) documentVisibleRect - (NSRect) documentVisibleRect