;+
;Object SetProperty method. OIMAGES is the animation model contents
;+
PRO sesCartoonTimer::SetProperty, $
    CURRENT_IMAGE = currentImage, $
    INCREMENT = inc, $
    OIMAGES = oImages

    IF N_ELEMENTS(currentImage) GT 0 THEN $
        self.currentImage = currentImage

    IF N_ELEMENTS(inc) GT 0 THEN $
        self.inc = inc

    IF N_ELEMENTS(oImages) GT 0 THEN $
        self.oImages = oImages
END
;+
;Object GetProperty method.
;+
PRO sesCartoonTimer::GetProperty, $
    CURRENT_IMAGE = currentImage, $
    INCREMENT = inc, $
    OIMAGES = oImages

    IF ARG_PRESENT(currentImage) THEN $
        currentImage = self.currentImage

    IF ARG_PRESENT(inc) THEN $
        inc = self.inc

END
;+
; OnTimer handles notifications that a timer even has occurred
; in the window. Updates currentImage with the increment amount.
; The nImages variable is based on the number of image frames.
; The ACTIVE_POSITION defines the zero-based index number of the
; model container item to be drawn
;+
PRO sesCartoonTimer::OnTimer, oWin
    nImages = self.oImages->Count()
    self.currentImage += self.inc
    IF self.currentImage GE nImages THEN self.currentImage = 0
    IF self.currentImage LT 0 THEN self.currentImage = nImages-1
    self.oImages->SetProperty, ACTIVE_POSITION=self.currentImage

    ; Draw the model containing proper frame in the window.
    oWin->Draw
END
;+
; Obligatory cleanup.
;+
PRO sesCartoonTimer::CleanUp
	COMPILE_OPT IDL2

END
;+
;Initialize class.
;+
FUNCTION sesCartoonTimer::Init
	COMPILE_OPT IDL2
	self.inc = 1
	Return,1
END
;+
;Define timer_observer instance data.
;+
PRO sesCartoonTimer__Define
	COMPILE_OPT IDL2
	struct = { sesCartoonTimer                              , $
		       currentImage             :     0L            , $
		       inc                      :     0L            , $
		       oImages                  :     Obj_New()     , $
		       wFrameIndicator          :     0L            , $
		       timerImages              :     0L              $
    }

END