Class: Context::View

Inherits:
Object
  • Object
show all
Defined in:
lib/Context/View.rb

Overview

This is the abstract view class

Direct Known Subclasses

PageView

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ View

Returns a new instance of View.



6
7
8
# File 'lib/Context/View.rb', line 6

def initialize(context)
	@context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/Context/View.rb', line 5

def context
  @context
end

Instance Method Details

#addView(view) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/Context/View.rb', line 10

def addView(view)
	myWidget = getWidget()
	if(myWidget != nil)
		newWidget = view.getWidget()
		if !newWidget.nil?
  				myWidget.addToThisWidget(newWidget)
  				newWidget.widgetWasAddedTo(myWidget)
  		    end
	end
          view.viewAddedTo(self)
end

#getWidgetObject

Concrete classes should override this method



45
46
47
# File 'lib/Context/View.rb', line 45

def getWidget
	return nil
end

#removeView(view) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/Context/View.rb', line 27

def removeView(view)
    view.removingViewFrom(self)
    myWidget = getWidget()
    if(myWidget != nil)
        oldWidget = view.getWidget()
        if !oldWidget.nil?
            myWidget.removeFromThisWidget(oldWidget)
            oldWidget.widgetWasRemovedFrom(myWidget)
        end
    end
end

#removingViewFrom(parent) ⇒ Object

Override this method to do something when your view being removed from another view. Most useful for removing subviews



41
42
# File 'lib/Context/View.rb', line 41

def removingViewFrom(parent)
end

#viewAddedTo(parent) ⇒ Object

Override this method to do something when your view has been added to another view. Most useful for adding subviews



24
25
# File 'lib/Context/View.rb', line 24

def viewAddedTo(parent)
end