class UIView

Stuff I copied from MOCommon

Public Instance Methods

bottom() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 37
def bottom
  frame.origin.y + frame.size.height
end
bottom=(bottom) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 42
def bottom=(bottom)
  f = self.frame
  f.origin.y = bottom - f.size.height
  self.frame = f
end
center_x() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 49
def center_x
  center.x
end
center_x=(center_x) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 54
def center_x=(center_x)
  self.center = [center_x, self.center.y]
end
center_y() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 59
def center_y
  center.y
end
center_y=(center_y) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 64
def center_y=(center_y)
  self.center = [self.center.x, center_y]
end
height() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 81
def height
   frame.size.height
end
height=(height) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 86
def height=(height)
  f = self.frame
  f.size.height = height
  self.frame = f
end
left() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 3
def left
  frame.origin.x
end
left=(x) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 8
def left=(x)
  f = self.frame
  f.origin.x = x
  self.frame = f
end
move_origin_relative_to_superview(v) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 177
def move_origin_relative_to_superview(v)
    pt = self.origin_relative_to_superview(v)
    self.left = pt.x
    self.top = pt.y
end
origin_relative_to_superview(v) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 160
def origin_relative_to_superview(v)
  sup = self.superview
  offset = CGPointZero

  #if ([sup isKindOfClass:[UIScrollView class]]) {
    #offset = ((UIScrollView*)sup).contentOffset
  #}

  if !sup || v == sup
    return CGPoint.new(left-offset.x, top-offset.y)
  else
    d = sup.origin_relative_to_superview(v)
    return CGPoint.new(left+d.x-offset.x, top+d.y-offset.y)
  end
end
right() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 26
def right
  frame.origin.x + frame.size.width
end
right=(right) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 31
def right=(right)
  f = self.frame
  f.origin.x = right - f.size.width
  self.frame = f
end
size_height_to_fit() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 100
def size_height_to_fit
  w = self.width
  #Otherwise it doesn't expand short UILabel when it's too short to fit longer text
  self.height = 1000
  sizeToFit
  self.width = w
end
size_height_to_fit_align_bottom() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 116
def size_height_to_fit_align_bottom
  y = self.bottom
  size_height_to_fit
  self.bottom = y
end
size_height_to_fit_max(f) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 141
def size_height_to_fit_max(f)
  size_height_to_fit

  if self.height > f
    self.height = f
  end
end
size_height_to_fit_min(f) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 151
def size_height_to_fit_min(f)
  size_height_to_fit

  if self.height < f
    self.height = f
  end
end
size_width_to_fit() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 93
def size_width_to_fit
  h = self.height
  sizeToFit
  self.height = h
end
size_width_to_fit_align_right() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 109
def size_width_to_fit_align_right
  x = self.right
  size_width_to_fit
  self.right = x
end
size_width_to_fit_max(f) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 123
def size_width_to_fit_max(f)
  size_width_to_fit

  if self.width > f
    self.width = f
  end
end
size_width_to_fit_min(f) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 132
def size_width_to_fit_min(f)
  size_width_to_fit

  if self.width < f
    self.width = f
  end
end
top() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 14
def top
  frame.origin.y
end
top=(y) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 19
def top=(y)
  f = self.frame
  f.origin.y = y
  self.frame = f
end
width() click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 69
def width
   frame.size.width
end
width=(width) click to toggle source
# File lib/purplish-red/ui/ui_view.rb, line 74
def width=(width)
  f = self.frame
  f.size.width = width
  self.frame = f
end