#ifndef APPLICATION_H_INCLUDED
#define APPLICATION_H_INCLUDED

#include <functional>
#include "graphics.hpp"
#include <iostream>
#include <vector>

/// ---- Vezérlők --------------------
class application;
#include "widget.h"
#include "group.h"
#include "color.h"

#include "label.h"
#include "checkbox.h"
#include "textbox.h"
#include "scrollBar.h"
#include "listBox.h"
#include "button.h"
#include "radioButton.h"
#include <sstream>

/// ---- Konstansok ------------------
extern int X;
extern int Y;
extern const unsigned int t;

template <typename T>
std::string convertS(T temp)
{
    std::string out;
    std::stringstream ss;
    ss << temp;
    ss >> out;
    return out;
}
int convertI(std::string temp);
float convertF(std::string temp);

/// ---- Application osztály --------------------
class application
{
protected:
    std::vector<widget*> widgets;
    std::vector<group*> groups;
    unsigned int tabIndex;
    std::function<bool(int, bool, bool)> eventHotKeys;
    bool shutdownFlag;
    bool keyControl, keyAlt;

    /// ---- Függvények ----
    void scrClear(); // Ablak törlése
    bool keyEvents(genv::event &ev); // Gyorsbillyentyűk elkapása
    void initApp(int X0, int Y0);

    void next();  // Fókusz továbbadása
    bool setFocus(unsigned int newFocus);  // Fókusz állítása adott elemre

public:
    /// ---- Konstruktor / Destruktor ----
    application(int X0, int Y0);
    application(int X0, int Y0,std::function<bool(int, bool, bool)>f0);
    ~application();

    /// ---- Bővítés -----
    void add(widget *newWidget);
    group* newGroup();

    /// ---- Működés ----
    void run();
    void shutdown();
};

#endif // APPLICATION_H_INCLUDED
