Class: MotionKit::WindowLayout
- Inherits:
-
TreeLayout
- Object
- BaseLayout
- TreeLayout
- MotionKit::WindowLayout
- Defined in:
- lib/motion-kit-osx/layouts/nswindow_layout.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BaseLayout
Instance Method Summary collapse
- #add_child(subview) ⇒ Object
- #all(element_id) ⇒ Object
-
#default_root ⇒ Object
platform specific default root view.
- #get(element_id) ⇒ Object
- #last(element_id) ⇒ Object
- #nth(element_id, index) ⇒ Object
-
#reapply!(window = nil) ⇒ Object
NSWindow doesn’t have immediate children; restyle its contentView.
- #remove(element_id) ⇒ Object
- #remove_child(subview) ⇒ Object
-
#window ⇒ Object
A more sensible name for the window that is created.
Methods inherited from TreeLayout
#add, #build, #built?, #call_style_method, #create, #create_default_root_context, #first, #initial, #reapply, #root, #view, view
Methods inherited from BaseLayout
#add_deferred_block, #apply, #apply_with_context, #apply_with_target, #context, #deferred, #deferred_blocks, delegate_method_fix, #initialize, #ipad?, #iphone35?, #iphone4?, #iphone?, #method_missing, #orientation?, #retina?, #run_deferred, #set_layout, #target, #v
Methods included from BaseLayoutClassMethods
#layout_for, #memoize, #new_child, #target_klasses, #targets
Constructor Details
This class inherits a constructor from MotionKit::BaseLayout
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MotionKit::BaseLayout
Instance Method Details
#add_child(subview) ⇒ Object
22 23 24 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 22 def add_child(subview) target.contentView.addSubview(subview) end |
#all(element_id) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 55 def all(element_id) found = self.all(element_id, in: self.window.contentView) if self.window.motion_kit_id == element_id found << self.window end return found end |
#default_root ⇒ Object
platform specific default root view
13 14 15 16 17 18 19 20 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 13 def default_root # child WindowLayout classes can return *their* NSView subclass from self.nsview_class view_class = self.class.targets || NSWindow view_class.alloc.initWithContentRect([[0, 0], [0, 0]], styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: NSBackingStoreBuffered, defer: false) end |
#get(element_id) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 37 def get(element_id) if self.window.motion_kit_id == element_id return self.window else self.get(element_id, in: self.window.contentView) end end |
#last(element_id) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 45 def last(element_id) if last = self.last(element_id, in: self.window.contentView) last elsif self.window.motion_kit_id == element_id self.window else nil end end |
#nth(element_id, index) ⇒ Object
63 64 65 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 63 def nth(element_id, index) self.all(element_id, in: self.window.contentView)[index] end |
#reapply!(window = nil) ⇒ Object
NSWindow doesn’t have immediate children; restyle its contentView.
31 32 33 34 35 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 31 def reapply!(window=nil) window ||= self.window call_style_method(window, window.motion_kit_id) if window.motion_kit_id super(window.contentView) end |
#remove(element_id) ⇒ Object
67 68 69 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 67 def remove(element_id) self.remove(element_id, from: self.window.contentView) end |
#remove_child(subview) ⇒ Object
26 27 28 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 26 def remove_child(subview) subview.removeFromSuperview end |
#window ⇒ Object
A more sensible name for the window that is created.
8 9 10 |
# File 'lib/motion-kit-osx/layouts/nswindow_layout.rb', line 8 def window self.view end |