#ifndef FOCUS_H_INCLUDED
#define FOCUS_H_INCLUDED

#include <vector>
#include "widget.h"

struct focus
{
    int tabIndex;
    std::vector<widget*> *widgets;
    focus(std::vector<widget*> *w)
    {
        tabIndex = 0;
        widgets = w;
    }
    void next()  // Fókusz továbbadása
    {
        (*widgets)[tabIndex]->focus = false;
        // Legközelebbi fókuszálható elem keresése
        while(!(*widgets)[(++tabIndex %= (*widgets).size())]->tabStop) if (tabIndex > (*widgets).size() * 2) return;
        (*widgets)[tabIndex]->focus = true;
    }
    bool setFocus(int newFocus)  // Fókusz állítása adott elemre
    {
        if (!(*widgets)[newFocus]->tabStop) return false; // Ha nem állítható az elemre fókusz
        (*widgets)[tabIndex]->focus = false;
        (*widgets)[newFocus]->focus = true;
        tabIndex = newFocus;
    }
};

#endif // FOCUS_H_INCLUDED
