Class: OSX::NSRect

Inherits:
Object show all
Defined in:
src/ruby/osx/objc/oc_types.rb

Overview

NSRect additons.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (OSX::NSRect) new(*args)

Examples:

OSX::NSRect.new
=> #<OSX::NSRect x=0.0, y=0.0, width=0.0, height=0.0>
OSX::NSRect.new([1,2],[3,4])
=> #<OSX::NSRect x=1.0, y=2.0, width=3.0, height=4.0>
OSX::NSRect.new(1,2,3,4)
=> #<OSX::NSRect x=1.0, y=2.0, width=3.0, height=4.0>

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'src/ruby/osx/objc/oc_types.rb', line 26

def new(*args)
  origin, size = case args.size
  when 0
    [[0, 0], [0, 0]]
  when 2
    [args[0], args[1]]
  when 4
    [args[0..1], args[2..3]]
  else
    raise ArgumentError, "wrong number of arguments (#{args.size} for either 0, 2 or 4)"
  end
  origin = OSX::NSPoint.new(*origin) unless origin.is_a?(OSX::NSPoint)
  size = OSX::NSSize.new(*size) unless size.is_a?(OSX::NSSize)
  orig_new(origin, size)
end

+ (Object) orig_new



17
# File 'src/ruby/osx/objc/oc_types.rb', line 17

alias_method :orig_new, :new

Instance Method Details

- (Object) center



52
# File 'src/ruby/osx/objc/oc_types.rb', line 52

def center; OSX::NSPoint.new(OSX::NSMidX(self), OSX::NSMidY(self)); end

- (Boolean) contain?(arg)

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
61
62
# File 'src/ruby/osx/objc/oc_types.rb', line 53

def contain?(arg)
  case arg
  when OSX::NSRect
    OSX::NSContainsRect(self, arg)
  when OSX::NSPoint
    OSX::NSPointInRect(arg, self)
  else
    raise ArgumentError, "argument should be NSRect or NSPoint"
  end
end

- (Boolean) empty?

Returns:

  • (Boolean)


63
# File 'src/ruby/osx/objc/oc_types.rb', line 63

def empty?; OSX::NSIsEmptyRect(self); end

- (Object) height



45
# File 'src/ruby/osx/objc/oc_types.rb', line 45

def height; size.height; end

- (Object) height=(v)



49
# File 'src/ruby/osx/objc/oc_types.rb', line 49

def height=(v); size.height = v; end

- (Object) inflate(dx, dy)



64
# File 'src/ruby/osx/objc/oc_types.rb', line 64

def inflate(dx, dy); inset(-dx, -dy); end

- (Object) inset(dx, dy)



65
# File 'src/ruby/osx/objc/oc_types.rb', line 65

def inset(dx, dy); OSX::NSInsetRect(self, dx, dy); end

- (Object) inspect



71
# File 'src/ruby/osx/objc/oc_types.rb', line 71

def inspect; "#<#{self.class} x=#{x}, y=#{y}, width=#{width}, height=#{height}>"; end

- (Object) integral



66
# File 'src/ruby/osx/objc/oc_types.rb', line 66

def integral; OSX::NSIntegralRect(self); end

- (Boolean) intersect?(rect)

Returns:

  • (Boolean)


67
# File 'src/ruby/osx/objc/oc_types.rb', line 67

def intersect?(rect); OSX::NSIntersectsRect(self, rect); end

- (Object) intersection(rect)



68
# File 'src/ruby/osx/objc/oc_types.rb', line 68

def intersection(rect); OSX::NSIntersectionRect(self, rect); end

- (Object) offset(dx, dy)



69
# File 'src/ruby/osx/objc/oc_types.rb', line 69

def offset(dx, dy); OSX::NSOffsetRect(self, dx, dy); end

- (Object) old_to_a

To remove a warning.



50
# File 'src/ruby/osx/objc/oc_types.rb', line 50

alias_method :old_to_a, :to_a

- (Object) to_a



51
# File 'src/ruby/osx/objc/oc_types.rb', line 51

def to_a; [origin.to_a, size.to_a]; end

- (Object) union(rect)



70
# File 'src/ruby/osx/objc/oc_types.rb', line 70

def union(rect); OSX::NSUnionRect(self, rect); end

- (Object) width



44
# File 'src/ruby/osx/objc/oc_types.rb', line 44

def width; size.width; end

- (Object) width=(v)



48
# File 'src/ruby/osx/objc/oc_types.rb', line 48

def width=(v); size.width = v; end

- (Object) x



42
# File 'src/ruby/osx/objc/oc_types.rb', line 42

def x; origin.x; end

- (Object) x=(v)



46
# File 'src/ruby/osx/objc/oc_types.rb', line 46

def x=(v); origin.x = v; end

- (Object) y



43
# File 'src/ruby/osx/objc/oc_types.rb', line 43

def y; origin.y; end

- (Object) y=(v)



47
# File 'src/ruby/osx/objc/oc_types.rb', line 47

def y=(v); origin.y = v; end