From 4b57864928380f936b30eb463b7f00b98da6861e Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Fri, 26 Nov 2010 21:27:58 +0000 Subject: [PATCH] Added method to draw scroll view. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31662 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++ Source/GSThemeDrawing.m | 95 ++++++++++++++++++++++++++++++++++++++++- Source/NSScrollView.m | 83 +---------------------------------- 3 files changed, 104 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index dabac2323..a5fe0d9ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-11-26 Gregory John Casamento + + * Source/GSThemeDrawing.m: Added method to draw NSScrollView view. + * Source/NSScrollView.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 * Source/GSThemeDrawing.m: Added method to draw NSBrowser view. diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index b1bfcba8e..b417944e8 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -28,6 +28,7 @@ #import "GSThemePrivate.h" +#import "Foundation/NSUserDefaults.h" #import "AppKit/NSAttributedString.h" #import "AppKit/NSBezierPath.h" #import "AppKit/NSButtonCell.h" @@ -43,6 +44,7 @@ #import "AppKit/NSParagraphStyle.h" #import "AppKit/NSProgressIndicator.h" #import "AppKit/NSScroller.h" +#import "AppKit/NSScrollView.h" #import "AppKit/NSStringDrawing.h" #import "AppKit/NSTableHeaderCell.h" #import "AppKit/NSView.h" @@ -1909,7 +1911,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil}; isHorizontal: (BOOL)horizontal itemCells: (NSArray *)itemCells { - int i = 0; int howMany = [itemCells count]; NSMenuView *menuView = (NSMenuView *)view; @@ -1935,4 +1936,96 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil}; } } +- (void) drawScrollViewRect: (NSRect)rect + inView: (NSView *)view +{ + NSScrollView *scrollView = (NSScrollView *)view; + NSGraphicsContext *ctxt = GSCurrentContext(); + GSTheme *theme = [GSTheme theme]; + NSColor *color; + NSString *name; + NSBorderType borderType = [scrollView borderType]; + NSRect bounds = [view bounds]; + BOOL hasInnerBorder = ![[NSUserDefaults standardUserDefaults] + boolForKey: @"GSScrollViewNoInnerBorder"]; + + name = [theme nameForElement: self]; + if (name == nil) + { + name = @"NSScrollView"; + } + color = [theme colorNamed: name state: GSThemeNormalState]; + if (color == nil) + { + color = [NSColor controlDarkShadowColor]; + } + + switch (borderType) + { + case NSNoBorder: + break; + + case NSLineBorder: + [color set]; + NSFrameRect(bounds); + break; + + case NSBezelBorder: + [theme drawGrayBezel: bounds withClip: rect]; + break; + + case NSGrooveBorder: + [theme drawGroove: bounds withClip: rect]; + break; + } + + if (hasInnerBorder) + { + NSScroller *vertScroller = [scrollView verticalScroller]; + NSScroller *horizScroller = [scrollView horizontalScroller]; + CGFloat scrollerWidth = [NSScroller scrollerWidth]; + + [color set]; + DPSsetlinewidth(ctxt, 1); + + if ([scrollView hasVerticalScroller]) + { + NSInterfaceStyle style; + + style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil); + if (style == NSMacintoshInterfaceStyle + || style == NSWindows95InterfaceStyle) + { + DPSmoveto(ctxt, [vertScroller frame].origin.x - 1, + [vertScroller frame].origin.y - 1); + } + else + { + DPSmoveto(ctxt, [vertScroller frame].origin.x + scrollerWidth, + [vertScroller frame].origin.y - 1); + } + DPSrlineto(ctxt, 0, [vertScroller frame].size.height + 1); + DPSstroke(ctxt); + } + + if ([scrollView hasHorizontalScroller]) + { + float ypos; + float scrollerY = [horizScroller frame].origin.y; + + if ([scrollView isFlipped]) + { + ypos = scrollerY - 1; + } + else + { + ypos = scrollerY + scrollerWidth + 1; + } + + DPSmoveto(ctxt, [horizScroller frame].origin.x - 1, ypos); + DPSrlineto(ctxt, [horizScroller frame].size.width + 1, 0); + DPSstroke(ctxt); + } + } +} @end diff --git a/Source/NSScrollView.m b/Source/NSScrollView.m index e47630810..702b20e5d 100644 --- a/Source/NSScrollView.m +++ b/Source/NSScrollView.m @@ -1216,87 +1216,8 @@ static float scrollerWidth; - (void) drawRect: (NSRect)rect { - NSGraphicsContext *ctxt = GSCurrentContext(); - GSTheme *theme = [GSTheme theme]; - NSColor *color; - NSString *name; - BOOL hasInnerBorder = ![[NSUserDefaults standardUserDefaults] - boolForKey: @"GSScrollViewNoInnerBorder"]; - - name = [theme nameForElement: self]; - if (name == nil) - { - name = @"NSScrollView"; - } - color = [theme colorNamed: name state: GSThemeNormalState]; - if (color == nil) - { - color = [NSColor controlDarkShadowColor]; - } - - switch (_borderType) - { - case NSNoBorder: - break; - - case NSLineBorder: - [color set]; - NSFrameRect(_bounds); - break; - - case NSBezelBorder: - [theme drawGrayBezel: _bounds withClip: rect]; - break; - - case NSGrooveBorder: - [theme drawGroove: _bounds withClip: rect]; - break; - } - - if (hasInnerBorder) - { - [color set]; - DPSsetlinewidth(ctxt, 1); - - if (_hasVertScroller) - { - NSInterfaceStyle style; - - style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil); - if (style == NSMacintoshInterfaceStyle - || style == NSWindows95InterfaceStyle) - { - DPSmoveto(ctxt, [_vertScroller frame].origin.x - 1, - [_vertScroller frame].origin.y - 1); - } - else - { - DPSmoveto(ctxt, [_vertScroller frame].origin.x + scrollerWidth, - [_vertScroller frame].origin.y - 1); - } - DPSrlineto(ctxt, 0, [_vertScroller frame].size.height + 1); - DPSstroke(ctxt); - } - - if (_hasHorizScroller) - { - float ypos; - float scrollerY = [_horizScroller frame].origin.y; - - if ([self isFlipped]) - { - ypos = scrollerY - 1; - } - else - { - ypos = scrollerY + scrollerWidth + 1; - } - - DPSmoveto(ctxt, [_horizScroller frame].origin.x - 1, ypos); - DPSrlineto(ctxt, [_horizScroller frame].size.width + 1, 0); - DPSstroke(ctxt); - } - } + [self drawScrollViewRect: rect + inView: self]; } - (NSRect) documentVisibleRect