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
|
# File 'lib/opine/widgets/window_dark_osx.rb', line 4
def drawRect rect
width = frame[:size][:width]
height = frame[:size][:height]
NSColor.clearColor.set
NSRectFill(NSMakeRect(0, height-1, 4, 1))
NSRectFill(NSMakeRect(0, height-2, 2, 1))
NSRectFill(NSMakeRect(0, height-4, 1, 2))
NSRectFill(NSMakeRect(width-4, height-1, 4, 1))
NSRectFill(NSMakeRect(width-2, height-2, 2, 1))
NSRectFill(NSMakeRect(width-1, height-4, 1, 2))
context = NSGraphicsContext.currentContext.graphicsPort
Cocoa::CGContextTranslateCTM(context, 0.0, rect[:size][:height])
Cocoa::CGContextScaleCTM(context, 1.0, -1.0)
Cairo::QuartzSurface.new(context, rect[:size][:width], rect[:size][:height]) do |surface|
cr = Cairo::Context.new(surface)
cr.push_group
cr.move_to(0, height)
cr.line_to(0, 5)
cr.curve_to(0, 2, 2, 0, 5, 0)
cr.line_to(width-5, 0)
cr.curve_to(width-2, 0, width, 2, width, 5)
cr.line_to(width, height)
cr.clip
cr.new_path
pat = Cairo::LinearPattern.new(0.0, 0.0, 0.0, height/2.0)
pat.add_color_stop(0, 0.0, 0.0, 0.0)
pat.add_color_stop(1, 0.2, 0.2, 0.2)
cr.rectangle(0, 0, width, (height/2.0))
cr.set_source(pat)
cr.fill
pat = Cairo::LinearPattern.new(0.0, 0.0, 0.0, height/2.0)
pat.add_color_stop(0, :black)
pat.add_color_stop(1, :black)
cr.rectangle(0, height/2.0-1, width, height/2.0)
cr.set_source(pat)
cr.fill
cr.set_source_color([0.4,0.4,0.4])
cr.set_line_width(3)
cr.move_to(0, 5)
cr.curve_to(0, 2, 2, 0, 5, 0)
cr.line_to(width-5, 0)
cr.curve_to(width-2, 0, width, 2, width, 5)
cr.stroke
cr.set_source_color(:black)
cr.set_line_width(2)
cr.move_to(0, height-1)
cr.line_to(0, 5)
cr.curve_to(0, 2, 2, 0, 5, 0)
cr.line_to(width-5, 0)
cr.curve_to(width-2, 0, width, 2, width, 5)
cr.line_to(width, height-1)
cr.stroke
cr.pop_group_to_source
cr.paint
end
end
|