#ifndef SCROLLBAR_H_INCLUDED
#define SCROLLBAR_H_INCLUDED

#include "widget.h"

enum scrollAlign { horizontal = 0, vertical = 1 };

class scrollBar : public widget
{
private:
    static int cnt; // Objektumszámláló

    // Lenyomva tartott billentyű vagy egérgomb a folyamatos görgetéshez
    char mouseDown;
    int prevPos;
    int prevVal;
    char keyDown;

    // Hogy ne azonnal kezdjen el görgetni
    bool wait;
    const unsigned int waitInterval = 500;
    unsigned int waitCounter;

    const unsigned int thickness = 20;
    float numRange;
    float graphicRange;
    unsigned int scrollHandleLength;
    unsigned int scrollHandlePosition;

protected:
    int value;
    int maxValue, minValue;
    int valueWidth;
    scrollAlign alignment;

public:
    /// ---- Konstruktor ----
    scrollBar(int x0, int y0, unsigned int length, scrollAlign align, int minV, int maxV);

    /// ---- Események ----
    virtual void onClick(int posX, int posY, char button);
    virtual void onMouseUp(int posX, int posY, char button);
    virtual void onMouseMove(int posX, int posY);
    virtual void onKeyPress(char keyCode);
    virtual void onKeyUp(char keyCode);
    virtual void onTick();

    /// --- Get/Set ----
    void setValue(int newValue);
    int getValue() const;

    void setValueWidth(unsigned int newValue);
    unsigned int getValueWidth() const;

    bool setRange(int minV, int maxV);
    int getMinValue() const;
    int getMaxValue() const;
    unsigned int getNumRange() const;


    /// ---- Kirajzolás ----
    virtual void draw() const;
};

#endif // SCROLLBAR_H_INCLUDED
