#ifndef _INC_RLOEWGUI
#define _INC_RLOEWGUI

#include <windows.h>

typedef int (* WINSUB)(struct winstr *);

struct winstr {
ATOM wclass;                          //Class from rlclass
HWND hWnd;                            //Main Window Handle
int x0,y0,x,y,opt;                    //Window Position, Size and Extra Options
char *name;                           //Window Name
HFONT font;                           //Font Handle
int status;                           //Status .31=err .30=close .29=init
HANDLE hand;                          //Thread Handle
WINSUB build;                         //Callback to add Child Windows  
WINSUB key;                           //Callback for Keystrokes (Char in .wp)
WINSUB menu;                          //Callback for Menu (ID in .wp LOW)
WINSUB control;                       //Callback for Controls (ID in .lp)
WINSUB scroll;                        //Callback for Scrolling
WINSUB paint;                         //Callback for Painting (in hdc, ps, rt)
WINSUB other;                         //Callback for Other Messages (0=def else loop returns 0)
WINSUB close;                         //Callback for Window Closure
DWORD mess,wp,lp;                     //Message Parameters
HDC hdc;                              //Device Context
PAINTSTRUCT ps;                       //Paint Struct
RECT rt;                              //Rectangle
HANDLE event;                         //Event Handle
int hspage,hsmax,hscur;               //Horizontal Scroll
int vspage,vsmax,vscur;               //Vertical Scroll
BITMAPINFOHEADER *bh;                 //Bitmap Info
BYTE *bmp;                            //Bitmap Data
int cx,cy;                            //Client Area
int arg;                              //Arg for Next Level Subroutine
HWND *child;                          //Child Window Handles Table
int *user;                            //Pointer to User Area
};

ATOM rlclass(char *name); //Create Class
int makewin(struct winstr *ws,int x0,int y0,int x,int y,char *name); //Create Window
int closewin(struct winstr *ws); //Close Window
int movewin(struct winstr *z,int x0,int y0,int x,int y); //Move Window
void paint(struct winstr *x); //Repaint Window

int scroll(struct winstr *x);                            //Scroll (~0 = processed)

HFONT makefont(char *name,int size,int width); //Create Fixed Font
HWND makebutton(struct winstr *ws,char *name,int x0,int y0,int x,int y);
HWND makecombo(struct winstr *z,char *name,int x0,int y0,int x,int y);
HWND makeedit(struct winstr *ws,char *name,int x0,int y0,int x,int y);
HWND makeeditmult(struct winstr *z,char *name,int x0,int y0,int x,int y);
HWND makelistmult(struct winstr *ws,char *name,int x0,int y0,int x,int y);
HWND makelistone(struct winstr *ws,char *name,int x0,int y0,int x,int y);
HWND makestatic(struct winstr *ws,char *name,int x0,int y0,int x,int y);
int getedit(HWND h,int line,char *buff,int max);
void comboclr(HWND h);
int comboadd(HWND h,char *s,int pos);
int combodel(HWND h,int pos);
int getcombosel(HWND h);
int gettext(HWND h,char *b,int len);
int settext(HWND h,char *b);
void listclr(HWND h);
int listadd(HWND h,char *s,int pos);
int listdel(HWND h,int pos);
int setlistsel(HWND h,int pos,int set);   // off=0, on=1, sel=2
int getlistsel(HWND h,int *list,int max);

void econsole(struct winstr *x,HWND h,int lines,WINSUB proc,int *cnts);
int econadd(HWND h,char *str);

BOOL openname(HWND h,char *name,int len);
BOOL savename(HWND h,char *name,int len);

struct winstr *openimage(int winx,int winy,int bitx,int bity,BYTE *bmp,char *name); //Display Scrollable Image

void clearimg(BYTE *bmp,int w,int h,int color);
int getpix(BYTE *bmp,int w,int h,int x,int y);
int setpix(BYTE *bmp,int w,int h,int x,int y,int color);
void drawline(BYTE *bmp,int w,int h,int x1,int y1,int x2,int y2,int color);
void drawthick(BYTE *bmp,int w,int h,int x1,int y1,int x2,int y2,int color);
void fill(unsigned char *bmp,int w,int h,int x,int y,int bcolor,int fcolor,int m);

#endif
