Sha256: ec4fffc34ed9f1da93893fa38f3ab836695072a12f54c17e6360aabc5018f8a6

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# encoding: utf-8
module Context

	# This is the abstract view class
	class View
		attr_reader :context
		def initialize(context)
			@context = context
		end
		
		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
        
        # Override this method to do something when your view has been
        # added to another view.  Most useful for adding subviews
        def viewAddedTo(parent)
        end

        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

        # Override this method to do something when your view being
        # removed from another view.  Most useful for removing subviews
        def removingViewFrom(parent)
        end
		
		# Concrete classes should override this method
		def getWidget
			return nil
		end

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.6.0.1 lib/Context/View.rb