#ifndef __XVTILITY_H
#define __XVTILITY_H

#ifndef XVT_INCL
#include <xvt.h>
#endif

#ifndef __KEYS_H
#include <keys.h>
#endif

// User defined events
const long E_DROP_FILES = 883L;

// Viswin EVENTS
// vista la mania degli 883, eccoti un po' di concerti di Mozart
const long E_ADDLINE_ONSCREEN = 467L;
const long E_ADDLINE          = 488L;

PNT xvtil_taskwin_size();
RCT& resize_rect(short x, short y, short dx, short dy, WIN_TYPE wt, WINDOW parent);

// align='L|T','C','R|B' grow= '+','=','-'
RCT& xvtil_align_rect(const RCT& inner, const RCT& outer, char halign, char valign, char grow);

WINDOW xvtil_create_window
(
  WIN_TYPE wt,
  short x, short y, short dx, short dy,
  const char* caption, 
  int menu, WINDOW parent,
  long flags,
  EVENT_HANDLER eh,
  long app_data
);

WINDOW xvtil_create_statbar();
void xvtil_statbar_set(const char* text, bool def = FALSE);
void xvtil_statbar_refresh();
void xvtil_statbar_destroy();
int xvtil_statbar_height();

bool xvtil_popup_message(const char* msg);
bool xvtil_popup_warning(const char* msg);
bool xvtil_popup_error(const char* msg);

void beep(int severity = 0);
void do_events();

void set_xvt_hooks();
void ignore_xvt_errors(bool ie);

void customize_colors();
void customize_controls(bool on);

KEY  e_char_to_key(const EVENT* ep);
void dispatch_event(WINDOW win, const EVENT& e, bool post);
void dispatch_e_menu(WINDOW win, MENU_TAG item);
void dispatch_e_char(WINDOW win, KEY key);
void dispatch_e_scroll(WINDOW win, KEY key);

void begin_wait();
void end_wait();

// One-liner for waiting!
class TWait_cursor
{ 
public:           
  TWait_cursor() { ::begin_wait(); }
  ~TWait_cursor() { ::end_wait(); }
};

void xvtil_set_font(WINDOW win, const char* family, int style, int dim = 0);
bool xvtil_test_menu_tag(MENU_TAG tag);  

COLOR trans_color(char c);
PAT_STYLE trans_brush(char p);
PEN_STYLE trans_pen  (char p);

extern short CHARX, CHARY, ROWY;

#endif