forked from erkyrath/Inform7-IDE-Mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIFPageBarOverlay.m
82 lines (61 loc) · 1.62 KB
/
IFPageBarOverlay.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
//
// IFPageBarOverlay.m
// Inform-xc2
//
// Created by Andrew Hunter on 01/04/2007.
// Copyright 2007 Andrew Hunter. All rights reserved.
//
#import "IFPageBarOverlay.h"
#import "IFPageBarView.h"
@implementation IFPageBarOverlay
// = Images =
- (NSImage*) normalImage {
static NSImage* image = nil;
if (!image) {
image = [[NSImage imageNamed: @"BarNormal"] retain];
}
return image;
}
// = Initialisation =
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
// = Drawing =
- (BOOL) isOpaque {
return NO;
}
- (void)drawRect:(NSRect)rect {
NSImage* background = [self normalImage];
NSSize backSize = [background size];
float edgeSize = 20;
NSRect bounds = [self bounds];
if (edgeSize*2 > bounds.size.width) {
edgeSize = bounds.size.width/2;
}
// Draw the left
NSRect left = bounds;
left.size.width = edgeSize;
[background drawInRect: left
fromRect: NSMakeRect(0,0, edgeSize, backSize.height)
operation: NSCompositeSourceOver
fraction: 1.0];
// Draw the middle
NSRect middle = NSInsetRect(bounds, edgeSize, 0);
[background drawInRect: middle
fromRect: NSMakeRect(edgeSize,0, backSize.width-edgeSize*2, backSize.height)
operation: NSCompositeSourceOver
fraction: 1.0];
// Draw the right
NSRect right = bounds;
right.origin.x = NSMaxX(bounds)-edgeSize;
right.size.width = edgeSize;
[background drawInRect: right
fromRect: NSMakeRect(backSize.width-edgeSize,0, edgeSize, backSize.height)
operation: NSCompositeSourceOver
fraction: 1.0];
}
@end