
#include <ncurses.h>
#include <stdint.h>

typedef struct _PROGRESSBAR {
    WINDOW* window; // Window to paint on (self created)
    int pos_l;
    int pos_c;
    int width;
    double max; // Maximum value of the Bar
    uint32_t colpair_fill;
    uint32_t colpair_empty;
    int accuracy; // Numbers of digits to display after . 
} PROGRESSBAR;

enum inputfieldtype { field, button };

typedef struct _INPUTFIELD {
    enum inputfieldtype ft;    
    bool pressed;
    WINDOW* window;
    int pos_l;
    int pos_c;
    int width;
    int size;
    char * contents;
    int cursor;
    int dcur;
    int conlen;
    int colpair;
    struct _INPUTFIELD *next;
    struct _INPUTFIELD *prev;
} INPUTFIELD;

PROGRESSBAR* progressbar( int posl, int posc, int w, double mx, uint32_t cf, uint32_t ce, int a );
void delpbar( PROGRESSBAR* pbar );
void updatebar( PROGRESSBAR* bar, double value );

INPUTFIELD* inputfield( WINDOW* win, INPUTFIELD* next, int posl, int posc, int w, int s, int cp, const char *def );
INPUTFIELD* newbutton( WINDOW* win, INPUTFIELD* next, int posl, int posc, int cp, const char * txt );
void delfield( INPUTFIELD* flt );
void handle_input_field( INPUTFIELD* ifield );
const char * getinput( INPUTFIELD* ifield );
bool buttonpressed( INPUTFIELD* button);
