/****************************************************************************/
/*																																					*/
/* UW_PROTO.H 																															*/
/*																																					*/
/* Prototype file for UltraWin.                                             */
/*																													Kevin Huck			*/
/*																													Boyd Gafford		*/
/*																																					*/
/****************************************************************************/
#ifndef __UW_PROTO_H
#define __UW_PROTO_H

/*------------------------- Prototypes for UW_MGR.C ------------------------*/
void reset_all_masks( void );
void refresh_desktop( void );
void refresh_column( int col );
void refresh_row( int row );
void redisplay_rect( RECT *rectp );
void add_wn_mask( WINDOW *wnp );
void remove_wn_mask( WINDOW *wnp );
void col_wn_mask( int x_pos, int y_min, int y_max, int amount );
void row_wn_mask( int y_pos, int x_min, int x_max, int amount );
void set_window_attr( void );
WINDOW *end_window( WINDOW *wnp );
WINDOW *cr_inwindow( int col, int row );
WINDOW *link_window( WINDOW *wnp );
int unlink_window( WINDOW *wnp );
int remove_window_ll( int destroy_mode, WINDOW *wnp );
void pull_to_top( WINDOW *wnp );
int make_top_window( WINDOW *wnp );
void move_wn_left( int cols, WINDOW *wnp );
void move_wn_right( int cols, WINDOW *wnp );
void move_wn_up( int rows, WINDOW *wnp );
void move_wn_down( int rows, WINDOW *wnp );
void set_rect(RECT *rectp, int x1, int y1, int x2, int y2);
int is_rect_equal( RECT *r1, RECT *r2 );
int rect_enclosed(RECT *r1, RECT *r2);
int rect_overlap(RECT *r1, RECT *r2);
void offset_rect(RECT *rectp, int col, int row);
int col_row_inrect(int col, int row, RECT *rectp);

/*------------------------- Prototypes for UW_FONT.C ------------------------*/
int encode_color(int r, int g, int b);
void decode_color(int color, int *r, int *g, int *b);
void write_palette( int pnum, uchar val );
void write_palette_all( uchar *vals );
int read_palette( int pnum );
void read_palette_all( uchar *vals );
void set_block_ab(int a, int b);
void blink_enable(int state);
void replicate_enable(int state);
int load_font( uchar *font, char *fname );
int save_font( uchar *font, char *fname, int scan_lines );
void rom8x8(int block, int setmode);
void rom8x14(int block, int setmode);
void rom8x16(int block, int setmode);

/*------------------------- Prototypes for UW_ENTRY.C ------------------------*/
void up_first_char( char *wk_str, char *mask, int mode );
void disp_entry( int c, int r, uchar m_att, char *s, char *m,
								 int offset, int disp_width, int arrow_flag, WINDOW *wnp );
void g_insert( char *s, char *m, char *t, int pos );
void g_delete( char *s, char *m, char *t, int pos );
void g_rtl_insert( char *s, char *m, char *t, int pos );
void g_rtl_delete( char *s, char *m, char *t, int pos );
void add_mask( char *s, char *m, char *t );
int rmv_mask( char *s, char *t );
int validate( char *c, char t );
void strip_entry( char *s, char *m );
void strip_end( char *s, char *m );
void strip_start( char *s, char *m );
int strip_len( char *s, char *m );
int wn_gets( char *str, char *mask, char *tplt, uchar m_att,
						 int strip_mode, WINDOW *wnp );
int init_gets_str( char *s, char *m, char *t, char *wk );
void rev_init_gets_str( char *s, char *m, char *t, char *wk );
void reverse_str( char *s );
int wn_gets_ll( char *str, char *mask, char *tplt, uchar m_att,
								int flags, int disp_width, WINDOW *wnp );
void set_validation_func( int (*func_ptr)(char*, char*, char*, 
													int, int, WINDOW*) );
void set_gets_hook( int (*func_ptr)(char*, char*, char*, int, int, 
										int, EVENT*, WINDOW*) );

/*------------------------- Prototypes for UW_MENU.C ------------------------*/
void menu_st( MENU *mnp, int csr, int inx);
int menu_create( int x_min, int y_min, int x_max, int y_max, int direction,
	      				 uchar back_att, uchar bdr_att, uchar csr_att, uchar first_att,
						     int bdr, int type, MENU *mnp );
int item_add( char *entry, int id, int first_pos, MENU *mnp );
void menu_set( MENU *mnp );
void menu_restore( MENU *mnp );
void menu_destroy( MENU *mnp );
void decrement_csr( int *csr, int min, int max);
void increment_csr( int *csr, int min, int max);
int upkey( int key );
int menu_horiz( MENU *mnp, int proc_mode );
int menu_vert( MENU *mnp, int proc_mode );
int do_menu( MENU *mnp, int proc_mode );
int menu_system( MENU *top_mnp, MENU *dropmenu[], int draw_top );
int menu_system_ll( MENU *top_mnp, MENU *dropmenu[], int draw_top,
									  int first_key, int exit_mode );

/*------------------------- Prototypes for UW_PRTF.C ------------------------*/
int wn_printf( WINDOW *wnp, char *fmt, ... );

/*------------------------- Prototypes for UW_RFSH.C ------------------------*/
void move_n_to_f( int *s, int dest_seg, int dest_off, int cnt );
void move_f_to_n( int src_seg, int src_off, int *d, int cnt );
void wn_io( int dir, int area, WINDOW *wnp );
void wn_rfsh_line( int line, WINDOW *wnp );
void wn_rfsh_col( int col, WINDOW *wnp );

/*------------------------- Prototypes for UW_WN.C  ------------------------*/
int wn_create( int x_min, int y_min, int x_max, int y_max, int bdr, int mode, WINDOW *wnp );
void wn_destroy( WINDOW *wnp );
void wn_set( WINDOW *wnp );
void wn_clear( WINDOW *wnp );
void wn_move( int col, int row, WINDOW *wnp );
int wn_size( int x_min, int y_min, int x_max, int y_max, WINDOW *wnp );

/*------------------------- Prototypes for UW_LL.C  ------------------------*/
int _csr_adj( WINDOW *wnp );
void _wn_scroll( int dir, WINDOW *wnp );
uchar far *_calc_scr_addr(WINDOW *wnp);
uchar *_calc_buff_addr(WINDOW *wnp);
uchar *_calc_mask_addr(WINDOW *wnp);
void _calc_all_addr(uchar far **scr, uchar **buff, uchar **mask, WINDOW *wnp);
void _fill_rect( uchar att, int v, RECT *rp );

/*------------------------- Prototypes for UW_BDR.C ------------------------*/
void wn_co( int cnt, uchar c, WINDOW *wnp );
void wn_border( WINDOW *wnp );
void wn_hline(int row, int style, WINDOW *wnp);
void wn_vline(int col, int style, WINDOW *wnp);

/*------------------------- Prototypes for UW_MASK.C ------------------------*/
void adjust_mask_col( int x_pos, int y_min, int y_max, int amount, WINDOW *wnp );
void adjust_mask_row( int y_pos, int x_min, int x_max, int amount, WINDOW *wnp );
void set_mask( int mode, WINDOW *wnp1, WINDOW *wnp2 );
void clear_mask( WINDOW *wnp );

/*------------------------- Prototypes for UW_TERM.C ------------------------*/
void wn_claol( WINDOW *wnp );
void wn_cleol( WINDOW *wnp );
void wn_clbol( WINDOW *wnp );
void wn_cleos( WINDOW *wnp );
void wn_clbos( WINDOW *wnp );
void wn_claos( WINDOW *wnp );
void wn_cln(int qty, WINDOW *wnp);
void wn_clear_tabs( WINDOW *wnp );
void wn_init_tabs( int space, WINDOW *wnp );
void wn_set_tab( WINDOW *wnp );
void wn_reset_tab( WINDOW *wnp );
void wn_tab_right( int cnt, WINDOW *wnp );
void wn_tab_left( int cnt, WINDOW *wnp );
void wn_ins_del_chars(int mode, char c, int cnt, WINDOW *wnp );
void wn_ins_del_lines(int mode, char c, int cnt, WINDOW *wnp );
void wn_csr_dn( int qty, WINDOW *wnp );
void wn_csr_up( int qty, WINDOW *wnp );
void wn_csr_left( int qty, WINDOW *wnp );
void wn_csr_right( int qty, WINDOW *wnp );
void wn_csr_pos( int line, int col, WINDOW *wnp );
void wn_scroll_reg( int line_s, int line_e, WINDOW *wnp );
void wn_bksp( int qty, WINDOW *wnp );

/*------------------------- Prototypes for UW_GRAPH.C ------------------------*/
int init_uw_graphics( int xres, int yres, int font_rows, int font_spacing,
											int seg, int off );
int g_ch( int c, int r, uchar v );
void install_font(uchar *font, int block, int ofs, int cnt,
									int scan_lines, int setmode );
uchar far *get_font_info( int typ, int *scan_lines, int *rows );

/*------------------------- Prototypes for UW_ST.C  ------------------------*/
void wn_st( char *s, WINDOW *wnp );
void wn_st_qty( char *s, int qty, WINDOW *wnp );
void wn_plst( int col, int line, char *s, WINDOW *wnp );
void wn_st_fmt( char *s, WINDOW *wnp );
int get_word( char *s, char *word );

/*------------------------- Prototypes for UW_CSR.C ------------------------*/
void rd_csr( int *col, int *line );
void mv_csr( int col, int line );
void csr_style( int style );
void csr_hide(void);
void csr_show(void);
void pl_csr( WINDOW *wnp );

/*------------------------- Prototypes for UW_CH.C  ------------------------*/
void wn_ch( uchar c, WINDOW *wnp );
void wn_noatt_ch( uchar c, WINDOW *wnp );
uchar wn_och( WINDOW *wnp );
uchar wn_oatt( WINDOW *wnp );
void wn_qch( int cnt, uchar c, WINDOW *wnp );

/*------------------------- Prototypes for UW_PRINT.C ------------------------*/
int  init_printer( char *fname, char *diskbuff, long isize, long msize, PRINT *p );
int  end_printer( PRINT *p );
int  realloc_printer( long new_size, PRINT *p );
void set_prt_xlat( int state, uchar *xlat, PRINT *p );
int  print_char( uchar c, PRINT *p );
int  print_str( uchar *str, PRINT *p );
int  print_printf( PRINT *p, char *fmt, ... );
int  print_data( uchar *data, int cnt, PRINT *p );
int  print_file( char *fname, PRINT *p );
int  print_window( WINDOW *wnp, PRINT *p );
int  print_screen( PRINT *p );
int  print_eol( PRINT *p );
int  print_in_bkgrnd( void );

/*------------------------- Prototypes for UW_EVENT.C ------------------------*/
void m_reset(M_RESET *m);
void m_colrange( int col_min, int col_max );
void m_rowrange( int row_min, int row_max );
void init_mouse(void);
void end_mouse(void);
void m_show(void);
void m_hide(void);
void m_pos( M_LOC *m );
void m_moveto( int col, int row );
void m_pressed( int button, M_LOC *m );
void m_released( int button, M_LOC *m );
void m_textcursor(int curstype, uint arg1, uint arg2);
void m_motion( M_MOVE *m );
void m_lpen_on(void);
void m_lpen_off(void);
void m_ratio( int horiz, int vert );
void wait_ticks( clock_t ticks );
int get_key(void);
int check_key(void);
void set_key_func( int (*func_ptr)(int, int) );
int event_pending(void);
void set_idle_func( int (*func_ptr)(void) );
void wait_event(void);

/*------------------------- Prototypes for UW_VID.C ------------------------*/
void set_25_rows(void);
int get_num_rows(void);
void get_v_mode(void);
void init_video(int cols, int rows);
void set_vid_addr( int segment, int offset );
void force_video(int force_mode, int cols, int rows);
void end_video(void);
uchar swap_nibbles( uchar c );
uchar get_att( uchar att );
void check_desq(void);
void mode43(void);
void mode25(void);
int ega_vga_check(void);
void init_clock(uint speed);
void end_clock(void);
void clock_speed( uint speed );
void tone( uint freq, int dur );
void sound_off(void);
void wait_ticks( clock_t ticks );
#ifdef __ZTC__
void interrupt far *getvect(int vect_no);
void setvect(int vect_no, void interrupt far *fp);
#endif

/*------------------------- Prototypes for UW_KBD.C ------------------------*/
void 	init_ctrlc_hdlr(void);
void  end_ctrlc_hdlr(void);

/*------------------------- Prototypes for UW_DBG.C ------------------------*/
#if defined(ENQ_DEBUG) || defined(SOURCE_TRACE)
int enq_error( int parm1, int parm2, char *s1, char *s2, void *p );
int wnp_vld( char *s, int mode, WINDOW *wnp );
int prtp_vld( char *s, int mode, PRINT *prtp );
int p_vld( char *s, void *gp );
int menup_vld( char *s, int mode, MENU *menup );
void dbg__log( char *func_name );
void linearize_log(void);
void dbg_push( char *func_name );
void dbg_pop( void );

void wn_att( uchar att, WINDOW *wnp );
void wn_color(int f, int b, WINDOW *wnp);
void wn_bdratt(uchar att, WINDOW *wnp);
void wn_bdr_color(int f, int b, WINDOW *wnp);
void mv_cs(int c, int r, WINDOW *wnp);
int wn_rqty(WINDOW *wnp);
int wn_sqty(WINDOW *wnp);
int wn_cqty(WINDOW *wnp);
void wn_name(char *n, WINDOW *wnp);
void wn_name_loc(int l, WINDOW *wnp);
void wn_save( WINDOW *wnp );
void wn_restore( WINDOW *wnp );
void wn_rfsh( WINDOW *wnp );
void wn_read( WINDOW *wnp );

int wn_get_csr_x(WINDOW *wnp);
int wn_get_csr_y(WINDOW *wnp);
uchar wn_get_att(WINDOW *wnp);
uchar wn_get_bdratt(WINDOW *wnp);
int wn_get_rows(WINDOW *wnp);
int wn_get_cols(WINDOW *wnp);
int wn_get_bdr_style(WINDOW *wnp);
int wn_get_name_loc(WINDOW *wnp);

int wn_is_hidden(WINDOW *wnp);
int wn_is_overlapped(WINDOW *wnp);   
int wn_is_csr_adv(WINDOW *wnp);
int wn_is_inside(WINDOW *wnp);
int wn_is_mask_on(WINDOW *wnp);
int wn_is_popup(WINDOW *wnp);
int wn_is_scroll(WINDOW *wnp);
int wn_is_bs_clear(WINDOW *wnp);
int wn_is_eol_wrap(WINDOW *wnp);
int wn_is_mgr_flag(WINDOW *wnp);
int wn_is_set_flag(WINDOW *wnp);
int wn_is_cr_flag(WINDOW *wnp);
int wn_is_lf_flag(WINDOW *wnp);
int wn_is_cr_lf_flag(WINDOW *wnp);
int wn_is_bk_flag(WINDOW *wnp);
int wn_is_tab_flag(WINDOW *wnp);
int wn_is_bell_flag(WINDOW *wnp);
int wn_is_w_wrap(WINDOW *wnp);
void wn_set_csr_x(int x, WINDOW *wnp);
void wn_set_csr_y(int y, WINDOW *wnp);
void wn_set_bdr_style(int state,WINDOW *wnp);
void wn_set_name_loc(int state,WINDOW *wnp);
void wn_set_hidden(int state,WINDOW *wnp);
void wn_set_overlapped(int state,WINDOW *wnp);
void wn_set_csr_adv(int state,WINDOW *wnp);
void wn_set_inside(int state,WINDOW *wnp);
void wn_set_mask_on(int state,WINDOW *wnp);
void wn_set_popup(int state,WINDOW *wnp);
void wn_set_scroll(int state,WINDOW *wnp);
void wn_set_bs_clear(int state,WINDOW *wnp);
void wn_set_eol_wrap(int state,WINDOW *wnp);
void wn_set_mgr_flag(int state,WINDOW *wnp);
void wn_set_set_flag(int state,WINDOW *wnp);
void wn_set_cr_flag(int state,WINDOW *wnp);
void wn_set_lf_flag(int state,WINDOW *wnp);
void wn_set_cr_lf_flag(int state,WINDOW *wnp);
void wn_set_bk_flag(int state,WINDOW *wnp);
void wn_set_tab_flag(int state,WINDOW *wnp);
void wn_set_bell_flag(int state,WINDOW *wnp);
void wn_set_w_wrap(int state,WINDOW *wnp);
#endif

#endif /* __UW_PROTO_H */

/**** END OF FILE ****/
