#ifndef EX_H
#define EX_H

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>

#ifdef E
#undef E
#endif

#ifdef EX
#define E extern
#else
#define E
#endif

/* fonts */
#define FN10 "lucidasans-10"
#define BT14 "lucidasanstypewriter-bold-14"
#define BN24 "-adobe-helvetica-bold-r-normal--24-180-100-100-p-138-iso8859-1"
#define BN34 "-adobe-helvetica-medium-r-normal--34-240-100-100-p-182-iso8859-1"

#define FONTS 4
#define FNT10 0
#define FNT14 1
#define FNT24 2
#define FNT34 3

typedef struct {
  Window win;
  Pixmap pix;
  int offset_x,offset_y;
  int width,height;
  int bo;
  char title[128];
} WINATTR;

E Display *disp;
E Window root,mwin;
E GC gc,or_gc,and_gc;
E Colormap cmap;
E XColor col[COLORS],rgb;
E Pixmap background,mwintmp,chara,mask,scr,scrm;
E Pixmap tmp;
E XEvent event;
E WINATTR w1attr,w2attr,nextattr,sgwattr;
E WINATTR scrwattr,csmwattr,linwattr,levwattr;
E int minx,miny,maxx,maxy;
E XFontStruct fonts[FONTS];

/* keyboard ¤Î¾õÂÖ */
E KeySym key;
E int pushedkey;
E KeySym qp_f;

/* macro(s) */
#define set_col(c) XSetForeground(disp,gc,col[c].pixel)
#define set_font(id) XSetFont(disp,gc,fonts[id].fid);

/* Functions */
E void x_create_window(Window pwin,WINATTR *win);
E void create_GC();
E void color_init();
E void load_font(XFontStruct *fp,char *fontname);
E void set_win_values();
E void x_init();
E void x_end();
E void x_flush();
E void keyrepeaton();
E void keyrepeatoff();
E void manage_expose(XExposeEvent *exevent);
E void keypress(XKeyEvent *kevent);
E void keyrelease(XKeyEvent *kevent);
E int  get_event(int f);
E void mk_sgw();
E void mk_mwin();
E void mk_nextwin();
E void mk_scr_etc();
E void mk_game_window();
E int x_get_word_width(int id,char *word);

#endif
