-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGSTheme+Additions.m
103 lines (97 loc) · 3.97 KB
/
GSTheme+Additions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***********************************************************************************************************************************
*
* GSTheme+Additions.m
*
* This file is an part of Mondo Preferences.
*
* Copyright (C) 2020 Mondo Megagames.
* Author: Jamie Ramone <[email protected]>
* Date: 18-5-20
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
**********************************************************************************************************************************/
#import <AppKit/AppKit.h>
#import <GNUstepGUI/GSTheme.h>
#import "aux.h"
@implementation GSTheme (Additions)
- (void) drawScrollViewRect: (NSRect) rect inView: (NSView *) view
{
register NSColor * color = nil;
register NSScrollView * scrollView = nil;
register NSString * name = nil;
register NSScroller * scroller = nil;
register GSTheme * theme = nil;
register GSDrawTiles * tiles = nil;
register void * target = NULL;
register NSBorderType borderType = NSNoBorder;
register NSRect bounds = NSZeroRect;
NSInterfaceStyle style;
register CGFloat pos = 0.0,
scrollerY = 0.0,
scrollerLength = 0.0,
scrollerWidth = 0.0,
scrollerHeight = 0.0;
register BOOL criteria = NO;
scrollView = (NSScrollView *) view;
theme = [GSTheme theme];
borderType = [scrollView borderType];
bounds = [view bounds];
name = [theme nameForElement: self];
criteria = ( name == nil );
name = Choose ( criteria, @"NSScrollView", name );
color = [theme colorNamed: name state: GSThemeNormalState];
tiles = [theme tilesNamed: name state: GSThemeNormalState];
criteria = ( color == nil );
color = Choose ( criteria, ( [NSColor controlDarkShadowColor] ), color );
criteria = ! [[NSUserDefaults standardUserDefaults] boolForKey: @"GSScrollViewNoInnerBorder"];
target = Choose ( criteria, && in1, && next1 );
goto * target;
in1: scrollerWidth = [NSScroller scrollerWidth];
[color set];
criteria = ( [scrollView hasVerticalScroller] );
target = Choose ( criteria, && inA, && nextA );
goto * target;
inA: scroller = [scrollView verticalScroller];
scrollerHeight = bounds.size.height;
style = NSInterfaceStyleForKey ( @"NSScrollViewInterfaceStyle", nil );
criteria = ( style == NSMacintoshInterfaceStyle || style == NSWindows95InterfaceStyle );
pos = [scroller frame].origin.x;
pos += Choose ( criteria, - 1.0, scrollerWidth );
NSRectFill( NSMakeRect ( pos, [scroller frame].origin.y - 1.0, 1.0, scrollerHeight + 1.0 ));
nextA: criteria = ( [scrollView hasHorizontalScroller] );
target = Choose ( criteria, && inB, && next1 );
goto * target;
inB: scrollerLength = bounds.size.width;
scroller = [scrollView horizontalScroller];
scrollerY = [scroller frame].origin.y;
criteria = ( [scrollView hasVerticalScroller] );
scrollerLength -= Choose ( criteria, [NSScroller scrollerWidth], 0.0 );
criteria = [scrollView isFlipped];
pos = scrollerY;
pos += Choose ( criteria, - 1.0, scrollerWidth + 1.0 );
NSRectFill ( NSMakeRect ( [scroller frame].origin.x - 1.0, pos, scrollerLength + 1.0, 1.0 ));
next1: criteria = ( tiles == nil );
target = Choose ( criteria, && in2, && in3 );
goto * target;
in2: 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];
}
goto out;
in3: [self fillRect: bounds withTiles: tiles];
out: return;
};
@end