Module: PurplishFrame::CocoaView

Includes:
View
Included in:
NSScreen, NSView, NSWindow
Defined in:
lib/purplish-frame/ui/osx/cocoa_view.rb

Instance Method Summary collapse

Methods included from View

#center_x, #center_x=, #center_y, #center_y=, #height, #inset!, #left, #left=, #right, #right=, #size_height_to_fit, #size_height_to_fit_align_bottom, #size_height_to_fit_max, #size_height_to_fit_min, #size_width_to_fit, #size_width_to_fit_align_right, #size_width_to_fit_max, #size_width_to_fit_min, #width, #width=

Instance Method Details

#bottomObject



19
20
21
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 19

def bottom
  frame.origin.y
end

#bottom=(bottom) ⇒ Object



23
24
25
26
27
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 23

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

#centerObject



29
30
31
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 29

def center
  NSMakePoint(left+width/2, top-height/2)
end

#center=(pt) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 33

def center=(pt)
  #We need to check because pt might be HIPoint or some Boxed type
  pt = pt.to_point if pt.respond_to? :to_point
  f = frame
  f.origin.x = pt.x-width/2
  f.origin.y = pt.y-height/2
  self.frame = f
end

#height=(height) ⇒ Object



42
43
44
45
46
47
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 42

def height=(height)
  f = frame
  f.origin.y -= height - frame.size.height
  f.size.height = height
  self.frame = f
end

#topObject



9
10
11
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 9

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

#top=(y) ⇒ Object



13
14
15
16
17
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 13

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

#view_frameObject



5
6
7
# File 'lib/purplish-frame/ui/osx/cocoa_view.rb', line 5

def view_frame
  frame
end