/*
 * ************************************************************************************************************
 * Author: Marcin Załęczny
 * Copyright (C)2010 Marcin Załęczny <mzaleczny@hotmail.com>
 * License: The GNU Lesser General Public License, version 3.0 (LGPLv3)
 * Library Name: mzstdgraphics
 * Version: 1.05
 * First release date:   2010-11-08
 * Current release date: 2011-03-04
 *
 *
 * This file is part of mzstdgraphics library
 * 
 * mzstdgraphics library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * mzstdgraphics library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************************************************
 */

#ifndef __MZSTDGRAPHICS_ANIMATED_BITMAP_H__
#define __MZSTDGRAPHICS_ANIMATED_BITMAP_H__

#include "mzstdgraphicsCommon.h"
#include "mzBitmap.h"
#include "mzString.h"

class DECLSPEC_MZSTDGRAPHICS CAnimatedBitmap : public CBitmap {
public:
    WINAPI CAnimatedBitmap(HINSTANCE hInst, CString base_fname);
    virtual WINAPI ~CAnimatedBitmap() {}
    inline LONG WINAPI getCurrentFrame() { return this->_currentFrame; }
    inline VOID WINAPI setCurrentFrame(LONG currentFrame) { this->_currentFrame = currentFrame; }
    VOID WINAPI forward();
    VOID WINAPI backward();
    virtual inline LONG WINAPI width() { return this->_frameWidth; }
    inline LONG WINAPI fullWidth() { return this->_width; }
    VOID WINAPI play(BOOL forward = TRUE);
    inline BOOL WINAPI isPlaying() { return this->_step != 0; }
    inline VOID WINAPI stop() { this->_step = 0; }
    inline VOID WINAPI loop() { this->_looping = TRUE; }
    inline BOOL WINAPI isLooping() { return this->_looping; }
    inline VOID WINAPI setRewind(BOOL v) { this->_rewind = v; }
    inline BOOL WINAPI isRewind() { return this->_rewind; }
    VOID WINAPI update();
    inline LONG WINAPI getFramesCount() { return this->_framesCount; }

private:
    LONG _currentFrame;
    LONG _framesCount;
    LONG _frameWidth;
    // Flaga sygnalizująca co ile jest zmieniana klatka animacji.
    // Jeśli ma wartość niezerową, to znaczy że odgrywana jest
    // animacja.
    LONG _step;
    // Flaga sygnalizująca czy po odtworzeniu całej animacji ma się
    // ona zacząć od początku.
    BOOL _looping;
    // Flaga sygnalizująca czy po zakończeniu i zatrzymaniu animacji ma nastąpić
    // powrót do pierwszej klatki.
    BOOL _rewind;
};

typedef CAnimatedBitmap* PAnimatedBitmap;

#endif
