#pragma once
#include <SDL/SDL.h>
#include "opengl.h"
#include "font.h"

extern int toolkit;

/* Creation. */
unsigned int window_create(char* name, const int x, const int y,
                           const int w, const int h);

void window_addButton(const unsigned int wid, const int x, const int y,
                      const int w, const int h, char* name, char* display,
                      void(*call)(char*));

void window_addText(const unsigned int wid, const int x, const int y,
                    const int w, const int h, const int centered, char* name,
                    glFont* font, glColour* colour, char* string);

void window_addImage(const unsigned int wid, const int x, const int y,
                     char* name, glTexture* image, int border);

void window_addList(const unsigned int wid,
                    const int x, const int y, /* Position. */
                    const int w, const int h, /* Size. */
                    char* name, char** items, int nitems, int defitem,
                    void(*call)(char*));

void window_addRect(const unsigned int wid,
                    const int x, const int y, /* Position. */
                    const int w, const int h, /* size. */
                    char* name, glColour* colour, int border); /* Properties. */

void window_addCust(const unsigned int wid,
                    const int x, const int y, /* Position. */
                    const int w, const int h, /* Size. */
                    char* name, const int border,
                    void(*render) (double x, double y, double w, double h),
                    void(*mouse) (SDL_Event* event, double x, double y));

void window_addInput(const unsigned int wid,
                     const int x, const int y,
                     const int w, const int h,
                     char* name, const int max, const int oneline);

void window_addImageArray(const unsigned int wid,
                          const int x, const int y, /* Position. */
                          const int w, const int h, /* Size. */
                          char* name, const int iw, const int ih, /* Name and images sizes. */
                          glTexture** tex, char** caption, int nelem, /* Elements. */
                          void(*call)(char*));

/* Modification. */
void window_setAccept(const unsigned int wid, void(*fptr)(char*));
void window_setCancel(const unsigned int wid, void(*cancel)(char*));
/* Text. */
void window_modifyText(const unsigned int wid, char* name, char* newstring);
/* Button. */
void window_disableButton(const unsigned int wid, char* name);
void window_enableButton(const unsigned int wid, char* name);
/* Image. */
void window_modifyImage(const unsigned int wid, char* name, glTexture* image);
void window_imgColour(const unsigned int wid, char* name, glColour* colour);

/* Get. */
/* Generic. */
int window_exists(const char* wdwname);
unsigned int window_get(const char* wdwname);
char* window_getInput(const unsigned int wid, char* name);
void window_posWidget(const unsigned int wid,
                      char* name, int* x, int* y);
void window_moveWidget(const unsigned int wid,
                       char* name, int x, int y);
/* Specific. */
char* toolkit_getList(const unsigned int wid, char* name);
int toolkit_getListPos(const unsigned int wid, char* name);
glTexture* window_getImage(const unsigned int wid, char* name);

/* Destroy window. */
void window_destroy(const unsigned int wid);
void window_destroyWidget(unsigned wid, const char* wgtname);

/* Render. */
void toolkit_render(void);

/* Input. */
int toolkit_input(SDL_Event* event);
void toolkit_update(void);

/* Init/Exit. */
int toolkit_init(void);
void toolkit_exit(void);

