Class: HotCocoaView

Inherits:
HotCocoa::LayoutView show all
Defined in:
lib/hotcocoa/mvc.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DefaultLayoutOptions =
{ expand: [:width, :height] }

Instance Attribute Summary collapse

Attributes inherited from HotCocoa::LayoutView

#frame_color, #margin, #spacing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HotCocoa::LayoutView

#addSubview, #default_layout, #default_layout=, #drawRect, #horizontal?, #initWithFrame, #mode=, #relayout!, #remove_all_views, #remove_view, #setFrame, #setFrameSize, #vertical?

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



154
155
156
# File 'lib/hotcocoa/mvc.rb', line 154

def controller
  @controller
end

Class Method Details

.inherited(klass) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/hotcocoa/mvc.rb', line 138

def self.inherited klass
  klass.extend(ClassMethods)
  klass.send(:include, HotCocoa::Behaviors)
  class_name = klass.name.underscore

  HotCocoaController.class_eval %{
    def #{class_name}
      unless HotCocoaController.view_instances[:#{class_name}]
        HotCocoaController.view_instances[:#{class_name}] = #{klass.name}.alloc.initWithFrame(CGRectZero)
        HotCocoaController.view_instances[:#{class_name}].setup_view
      end
      HotCocoaController.view_instances[:#{class_name}]
    end
  }, __FILE__, __LINE__
end

Instance Method Details

#setup_viewObject



156
157
158
159
160
161
162
# File 'lib/hotcocoa/mvc.rb', line 156

def setup_view
  unless @controller
    @controller = class_controller
    self.layout = layout_options
    render
  end
end