/*
		     Options Window Definations
 */

#ifndef OPTWIN_H
#define OPTWIN_H

#include "../include/osw-x.h"
#include "../include/widget.h"

typedef struct _xsw_options_win_struct	xsw_options_win_struct;
#define XSW_OPTIONS_WIN(p)	((xsw_options_win_struct *)(p))


/*
 *	Tabs:
 */
#define OPTWIN_TAB_CODE_GENERAL		0
#define OPTWIN_TAB_CODE_GRAPHICS	1
#define OPTWIN_TAB_CODE_SOUNDS		2
#define OPTWIN_TAB_CODE_NET		3
#define OPTWIN_TAB_CODE_MISC		4


/*
 *	Options Window:
 */
struct _xsw_options_win_struct {

	bool_t		map_state,
			has_focus,
			disabled;
	int		freeze_count,
			busy_count;
	int		x, y;
	unsigned int	width, height;
	visibility_t	visibility_state;

	win_t		toplevel;
	pixmap_t	toplevel_buf;

	/* Buttons */
	push_button_struct	ok_btn,
				cancel_btn,
				apply_btn,
				defaults_btn,
				save_btn;

	int		tab;	/* Which tab is selected */

	bool_t		has_changes;

	/* Tabs */
	win_t		general_tab,
			graphics_tab,
			sounds_tab,
			network_tab,
			misc_tab;
	/* Tabs buffer */
	pixmap_t	tab_win_buf;


	/* General */
	check_button_struct	show_univ_list_win_cb,
				show_eco_win_cb;
	popup_list_struct	cpu_priority_pulist;
	popup_list_struct	controller_pulist;
	radio_struct		throttle_mode_radio;
	check_button_struct	auto_zoom_cb,
				local_updates_cb,
				notify_scanner_contacts_cb;
	label_struct		units_label;
	popup_list_struct	units_pulist;
	push_button_struct	configure_vsmenu_btn;

#if 0
	prompt_struct		ocsn_prompt,
				imgrefs_prompt,
				sndrefs_prompt;
	push_button_struct	ocsn_browse_btn,
				imgrefs_browse_btn,
				sndrefs_browse_btn;
#endif

#ifdef JS_SUPPORT
	push_button_struct	jsmap_btn;
#endif	/* JS_SUPPORT */
	push_button_struct	keymap_btn;

	/* Graphics */
	check_button_struct	show_viewscreen_selected_weapon_cb,
				show_viewscreen_markings_cb,
				show_viewscreen_object_labels_cb,
				show_viewscreen_netstats_cb;
	radio_struct		show_formal_label_radio;
	check_button_struct	show_lens_flares_cb,
				show_nebula_glow_cb,
				show_strobe_glow_cb,
				show_fires_cb,
				show_smoke_trails_cb,
				async_image_loading_cb;
	prompt_struct		max_particles_prompt,
				async_image_pixels_prompt;

	/* Sounds */
	radio_struct		sounds_radio;
	check_button_struct	music_cb;
	radio_struct		server_type_radio;
	prompt_struct		sound_server_prompt;
	prompt_struct		sound_con_arg_prompt;
	push_button_struct	sound_test_btn;
	check_button_struct	flip_stereo_cb;

	/* Network */
	prompt_struct		def_address_prompt;
	prompt_struct		def_port_prompt;
	check_button_struct	show_net_errors_cb;
	check_button_struct	show_server_errors_cb;
	prompt_struct		net_bandwidth_prompt;
	prompt_struct		net_int_prompt;
	prompt_struct		net_timeout_prompt;
	prompt_struct		net_object_outdated_prompt;
	check_button_struct	auto_interval_cb;

	/* Misc */
	prompt_struct		xsw_local_toplevel_path_prompt;
	prompt_struct		xsw_toplevel_path_prompt;
	prompt_struct		xsw_etc_path_prompt;  
	prompt_struct		xsw_images_path_prompt;
	prompt_struct		xsw_sounds_path_prompt;
	prompt_struct           xsw_downloads_path_prompt;

#ifdef JS_SUPPORT
	prompt_struct		js_calib_path_prompt;
	push_button_struct	js_calib_path_browse_btn;
#endif	/* JS_SUPPORT */
	push_button_struct	refresh_memory_btn;

};


/* optwin.cpp */
extern "C" xsw_options_win_struct *OptWinNew(void);
extern "C" void OptWinTabRemap(xsw_options_win_struct *optwin, int tab);
extern "C" void OptWinResize(xsw_options_win_struct *optwin);
extern "C" void OptWinQueueResize(xsw_options_win_struct *optwin);
extern "C" void OptWinDraw(xsw_options_win_struct *optwin);
extern "C" void OptWinQueueDraw(xsw_options_win_struct *optwin);
extern "C" int OptWinManage(xsw_options_win_struct *optwin, event_t *event);
extern "C" void OptWinUpdateWidgets(xsw_options_win_struct *optwin);
extern "C" void OptWinMap(xsw_options_win_struct *optwin, win_t toplevel);
extern "C" void OptWinUnmap(xsw_options_win_struct *optwin);
extern "C" void OptWinDelete(xsw_options_win_struct *optwin);

/* optwinop.cpp */
extern "C" void OptWinFetchValues(xsw_options_win_struct *optwin);
extern "C" void OptWinApplyChanges(xsw_options_win_struct *optwin);
extern "C" void OptWinSetDefaults(xsw_options_win_struct *optwin);
extern "C" int OptWinSaveChanges(xsw_options_win_struct *optwin);

extern "C" void OptWinTestSoundPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinBrowseOCSNsPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinBrowseImgRefsPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinBrowseSndRefsPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinBrowseJSCalPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinKeymapPBCB(push_button_struct *btn, void *data);
#ifdef JS_SUPPORT
extern "C" void OptWinJSMapPBCB(push_button_struct *btn, void *data);
#endif
extern "C" void OptWinConfigureVSMenuPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinRefreshMemoryPBCB(push_button_struct *btn, void *data);

extern "C" void OptWinOKPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinApplyPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinSavePBCB(push_button_struct *btn, void *data);
extern "C" void OptWinDefaultsPBCB(push_button_struct *btn, void *data);
extern "C" void OptWinCancelPBCB(push_button_struct *btn, void *data);


#endif	/* OPTWIN_H */