mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 09:22:07 +00:00
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
This commit is contained in:
parent
72963b2f49
commit
4b57864928
3 changed files with 104 additions and 82 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2010-11-26 Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
|
* 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 <greg.casamento@gmail.com>
|
2010-11-26 Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
* Source/GSThemeDrawing.m: Added method to draw NSBrowser view.
|
* Source/GSThemeDrawing.m: Added method to draw NSBrowser view.
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#import "GSThemePrivate.h"
|
#import "GSThemePrivate.h"
|
||||||
|
|
||||||
|
#import "Foundation/NSUserDefaults.h"
|
||||||
#import "AppKit/NSAttributedString.h"
|
#import "AppKit/NSAttributedString.h"
|
||||||
#import "AppKit/NSBezierPath.h"
|
#import "AppKit/NSBezierPath.h"
|
||||||
#import "AppKit/NSButtonCell.h"
|
#import "AppKit/NSButtonCell.h"
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
#import "AppKit/NSParagraphStyle.h"
|
#import "AppKit/NSParagraphStyle.h"
|
||||||
#import "AppKit/NSProgressIndicator.h"
|
#import "AppKit/NSProgressIndicator.h"
|
||||||
#import "AppKit/NSScroller.h"
|
#import "AppKit/NSScroller.h"
|
||||||
|
#import "AppKit/NSScrollView.h"
|
||||||
#import "AppKit/NSStringDrawing.h"
|
#import "AppKit/NSStringDrawing.h"
|
||||||
#import "AppKit/NSTableHeaderCell.h"
|
#import "AppKit/NSTableHeaderCell.h"
|
||||||
#import "AppKit/NSView.h"
|
#import "AppKit/NSView.h"
|
||||||
|
@ -1909,7 +1911,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
||||||
isHorizontal: (BOOL)horizontal
|
isHorizontal: (BOOL)horizontal
|
||||||
itemCells: (NSArray *)itemCells
|
itemCells: (NSArray *)itemCells
|
||||||
{
|
{
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int howMany = [itemCells count];
|
int howMany = [itemCells count];
|
||||||
NSMenuView *menuView = (NSMenuView *)view;
|
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
|
@end
|
||||||
|
|
|
@ -1216,87 +1216,8 @@ static float scrollerWidth;
|
||||||
|
|
||||||
- (void) drawRect: (NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
[self drawScrollViewRect: rect
|
||||||
GSTheme *theme = [GSTheme theme];
|
inView: self];
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) documentVisibleRect
|
- (NSRect) documentVisibleRect
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue