Class: NSView
Class Method Summary
collapse
Instance Method Summary
collapse
#height, #setHeight, #setWidth, #setX, #setY, #width, #x, #y
Class Method Details
.attr_updates(*attrs) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 5
def attr_updates(*attrs)
attr_accessor(*attrs)
attrs.each do |attr|
define_method("#{attr}=") do |value|
if instance_variable_get("@#{attr}") != value
setNeedsDisplay
end
willChangeValueForKey(attr)
instance_variable_set("@#{attr}", value)
didChangeValueForKey(attr)
end
end
end
|
Instance Method Details
superview << view
> superview.addSubview(view)
23
24
25
26
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 23
def <<(view)
self.addSubview(view)
return self
end
|
#convert_frame_from(source) ⇒ Object
47
48
49
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 47
def convert_frame_from(source)
return self.convert_rect(CGRectMake(0, 0, source.frame.size.width, source.frame.size.height), from: source)
end
|
#convert_frame_to(destination) ⇒ Object
43
44
45
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 43
def convert_frame_to(destination)
return self.convert_rect(CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), to: destination)
end
|
#convert_origin_from(source) ⇒ Object
63
64
65
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 63
def convert_origin_from(source)
return self.convert_point([0, 0], from: source)
end
|
#convert_origin_to(destination) ⇒ Object
59
60
61
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 59
def convert_origin_to(destination)
return self.convert_point([0, 0], to: destination)
end
|
#convert_point(point, from: source) ⇒ Object
67
68
69
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 67
def convert_point(point, to: destination)
return self.convertPoint(point, toView: destination)
end
|
#convert_rect(rect, from: source) ⇒ Object
51
52
53
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 51
def convert_rect(rect, to: destination)
return self.convertRect(rect, toView: destination)
end
|
#first_responder ⇒ Object
returns the first responder, or nil if it cannot be found
39
40
41
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 39
def first_responder
self.window && self.window.firstResponder
end
|
#sugarcube_to_s(options = {}) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/osx/sugarcube-to_s/nsview.rb', line 3
def sugarcube_to_s(options={})
if self.respond_to? :stylename and self.stylename
suffix = ' stylename: ' + self.stylename.inspect
else
suffix = ''
end
if options[:inner].is_a? Hash
inner = ''
options[:inner].each do |key, value|
inner += ', ' if inner.length > 0
inner += "#{key}: #{value.inspect}"
end
else
inner = options[:inner]
end
"#{self.class.to_s}(##{self.object_id.to_s(16)}, [[#{frame.origin.x}, #{frame.origin.y}], [#{frame.size.width}, #{frame.size.height}]]" +
(inner ? ', ' + inner : '') +
')' +
(options.fetch(:superview, true) && self.superview ? ", child of #{self.superview.class.to_s}(##{self.superview.object_id.to_s(16)})" : '') +
suffix
end
|
26
27
28
|
# File 'lib/osx/sugarcube-to_s/nsview.rb', line 26
def to_s
sugarcube_to_s
end
|
#unshift(view) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/osx/sugarcube-ui/nsview.rb', line 28
def unshift(view)
first_view = self.subviews.first
if first_view
self.addSubview(view, positioned: NSWindowAbove, relativeTo: first_view)
else
self.addSubview(view)
end
return self
end
|