Class: CGRect
- Defined in:
- lib/accessibility/bridge/mri.rb,
lib/accessibility/bridge/mri.rb,
lib/accessibility/bridge/common.rb,
lib/accessibility/extras/common.rb
Overview
Complete definition of a rectangle in a 2D coordinate system
Instance Attribute Summary collapse
-
#origin ⇒ CGPoint, #to_point
The
origin
point. -
#size ⇒ CGSize, #to_size
The
size
of the rectangle.
Class Method Summary collapse
-
.ax_value ⇒ Number
Returns the number that AXAPI uses in order to know how to wrap a struct.
Instance Method Summary collapse
-
#flip! ⇒ CGRect
Treats the rect as belonging to one co-ordinate system and then converts it to the other system.
-
#initialize(origin = CGPoint.new, size = CGSize.new) ⇒ CGRect
constructor
A new instance of CGRect.
-
#inspect ⇒ String
Return a nice string representation of the rectangle.
-
#to_rect ⇒ CGRect
Returns the receiver, since the receiver is already a CGRect.
Constructor Details
Instance Attribute Details
#origin ⇒ CGPoint, #to_point
The origin
point
67 68 69 |
# File 'lib/accessibility/bridge/mri.rb', line 67 def origin @origin end |
#size ⇒ CGSize, #to_size
The size
of the rectangle
67 68 69 |
# File 'lib/accessibility/bridge/mri.rb', line 67 def size @size end |
Class Method Details
.ax_value ⇒ Number
Returns the number that AXAPI uses in order to know how to wrap a struct.
125 |
# File 'lib/accessibility/bridge/macruby.rb', line 125 def ax_value; KAXValueCGRectType end |
Instance Method Details
#flip! ⇒ CGRect
Treats the rect as belonging to one co-ordinate system and then converts it to the other system
This is useful because accessibility API's expect to work with the flipped co-ordinate system (origin in top left), but AppKit prefers to use the cartesian co-ordinate system (origin in bottom left).
12 13 14 15 16 17 18 |
# File 'lib/accessibility/extras/common.rb', line 12 def flip! frame = ::NSScreen.screens.first.frame screen_height = frame.origin.y + frame.size.height self_max_y = self.origin.y + self.size.height origin.y = screen_height - self_max_y self end |
#inspect ⇒ String
Return a nice string representation of the rectangle
Overrides Object#inspect
to more closely mimic MacRuby Boxed#inspect
.
90 91 92 |
# File 'lib/accessibility/bridge/mri.rb', line 90 def inspect "#<CGRect origin=#{self.origin.inspect} size=#{self.size.inspect}>" end |