#include <fstream>
#include <vector>
#include "application.h"

using namespace std;
using namespace genv;

struct kocsi
{
    string nev;
    int ar;
    string szin;
};

struct ugyfelek
{
    string nev;
    kocsi kolcsonzottKocsi;
    int ido;
};

listBox* ugyfelek;
listBox* kocsik;

label* ujUgyfelMezo;
textBox* ujUgyfelNev;
button* ujUgyfelButton;

label* ujKocsiMezo;
textBox* ujKocsiNev;
textBox* ujKocsiAr;
textBox* ujKocsiSzin;
button* ujKocsiButton;

button* eltelIdoButton;
button* kolcsonoz;
button* visszahoz;
label* fizet;

void buttonAdd_Click (int x, int y, char button, widget* me) // (x, y) relatív koordináták!!
{

}

void textBox1_KeyPress (int keyCode, widget* me) // Minden widget rendelkezik KeyPress eseménnyel
{

}

void buttonRemove_Click (int x, int y, char button, widget* me) // Minden widget rendelkezik Click eseménnyel
{

}

void scrollBar1_Changed(int newValue, widget* me) // Csak azok a widgetek rendelkeznek Changed eseménnyel, ahol értelmezhető
{

}

void listBox1_SelectionChanged(int newIndex, widget* me)
{

}

void radioTest (widget *me)
{

}

void groupTestChanged (int index)
{

}

void groupTestClick (int x, int y, char button, int index)
{

}

bool hotKeys (int keyCode, bool Control, bool Alt) // Esc és Tab automatikus; Control és Alt értelemszerűen a billenytűkre utal
{
    switch ( keyCode )
    {
    case key_f5 :
        /*{ofstream f("data.txt");
        f << scrollBar1->getValue() << endl;
        for (int i = 0; i < listBox1->getCount(); i++)
            f << listBox1->getItem(i) << endl;
        f.close();
        return true;}*/

    default:
        return false;
    }
}

/// ---- Main ------------------------
int main ()
{
    application App(600, 600, hotKeys);

button* eltelIdoButton;
button* kolcsonoz;
button* visszahoz;
label* fizet;

    const int margin = 20;

    App.add( ugyfelek = new listBox( margin, margin, 200, 300, { } ) );
    App.add( kocsik = new listBox( 0, margin, 200, 300, { } ) );
    kocsik->alignX(ugyfelek, margin);

    App.add( ujUgyfelMezo = new label( margin, 0, 200, 120, "" ) );
    ujUgyfelMezo->alignY(ugyfelek, margin);
    ujUgyfelMezo->background = true;
    ujUgyfelMezo->backgroundColor = "#ddd9dd";
    App.add( ujUgyfelNev = new textBox( margin*2, ujUgyfelMezo->y + margin, 160, 30, "Uj ugyfel" ) );
    App.add( ujUgyfelButton = new button( margin*2, 0, 160, 30, "Hozzaad" ));
    ujUgyfelButton->alignY(ujUgyfelNev, margin);

    App.add( ujKocsiMezo = new label( kocsik->x, 0, 200, 160, "" ) );
    ujKocsiMezo->alignY(kocsik, margin);
    ujKocsiMezo->background = true;
    ujKocsiMezo->backgroundColor = "#ddd9dd";
    App.add( ujKocsiNev = new textBox( ujKocsiMezo->x + margin, ujKocsiMezo->y + margin, 160, 30, "Uj auto" ) );
    App.add( ujKocsiAr = new textBox( ujKocsiNev->x, 0, 60, 30, "Ar" ) );
    ujKocsiAr->alignY(ujKocsiNev, margin);
    App.add( ujKocsiSzin = new textBox( ujKocsiNev->x, 0, 60, 30, "Szin" ));
    ujKocsiSzin->alignY(ujKocsiAr, margin);
    App.add( ujKocsiButton = new button( 0 , ujKocsiAr->y + margin , 80, 30, "Hozzaad" ));
    ujKocsiButton->alignX(ujKocsiAr, margin);

    App.run();

    return 0;
}

