Class: UIView

Inherits:
Object
  • Object
show all
Defined in:
lib/purplish-red/ui/ui_view.rb

Overview

Stuff I copied from MOCommon

Instance Method Summary collapse

Instance Method Details

#bottomObject



37
38
39
# File 'lib/purplish-red/ui/ui_view.rb', line 37

def bottom
  frame.origin.y + frame.size.height
end

#bottom=(bottom) ⇒ Object



42
43
44
45
46
# 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_xObject



49
50
51
# File 'lib/purplish-red/ui/ui_view.rb', line 49

def center_x
  center.x
end

#center_x=(center_x) ⇒ Object



54
55
56
# File 'lib/purplish-red/ui/ui_view.rb', line 54

def center_x=(center_x)
  self.center = [center_x, self.center.y]
end

#center_yObject



59
60
61
# File 'lib/purplish-red/ui/ui_view.rb', line 59

def center_y
  center.y
end

#center_y=(center_y) ⇒ Object



64
65
66
# File 'lib/purplish-red/ui/ui_view.rb', line 64

def center_y=(center_y)
  self.center = [self.center.x, center_y]
end

#heightObject



81
82
83
# File 'lib/purplish-red/ui/ui_view.rb', line 81

def height
   frame.size.height
end

#height=(height) ⇒ Object



86
87
88
89
90
# File 'lib/purplish-red/ui/ui_view.rb', line 86

def height=(height)
  f = self.frame
  f.size.height = height
  self.frame = f
end

#leftObject



3
4
5
# File 'lib/purplish-red/ui/ui_view.rb', line 3

def left
  frame.origin.x
end

#left=(x) ⇒ Object



8
9
10
11
12
# 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) ⇒ Object



177
178
179
180
181
# 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) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# 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

#rightObject



26
27
28
# File 'lib/purplish-red/ui/ui_view.rb', line 26

def right
  frame.origin.x + frame.size.width
end

#right=(right) ⇒ Object



31
32
33
34
35
# 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_fitObject



100
101
102
103
104
105
106
# 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_bottomObject



116
117
118
119
120
# 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) ⇒ Object



141
142
143
144
145
146
147
# 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) ⇒ Object



151
152
153
154
155
156
157
# 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_fitObject



93
94
95
96
97
# 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_rightObject



109
110
111
112
113
# 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) ⇒ Object



123
124
125
126
127
128
129
# 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) ⇒ Object



132
133
134
135
136
137
138
# 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

#topObject



14
15
16
# File 'lib/purplish-red/ui/ui_view.rb', line 14

def top
  frame.origin.y
end

#top=(y) ⇒ Object



19
20
21
22
23
# File 'lib/purplish-red/ui/ui_view.rb', line 19

def top=(y)
  f = self.frame
  f.origin.y = y
  self.frame = f
end

#widthObject



69
70
71
# File 'lib/purplish-red/ui/ui_view.rb', line 69

def width
   frame.size.width
end

#width=(width) ⇒ Object



74
75
76
77
78
# File 'lib/purplish-red/ui/ui_view.rb', line 74

def width=(width)
  f = self.frame
  f.size.width = width
  self.frame = f
end