Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
10
Добавлен:
17.04.2013
Размер:
6.63 Кб
Скачать
/*******************************************************************************
* file:         fx_gui.h                                                       *
* version:	    0.0.1                                                          *
* author:       inba (mailto:inba@mail.ru)                                     *
* description:  not available                                                  *
*******************************************************************************/

#ifndef FX_GUI_INCLUDED
#define FX_GUI_INCLUDED

//#define REDRAW_LIST

#ifdef REDRAW_LIST
	//#define USE_SLOW_MODE
	//#define SLOW_MODE_DELAY		100
#endif

////////////////////////////////////////////////////////////////////////////////
// for correct linkage order
#include <afx.h>


////////////////////////////////////////////////////////////////////////////////
// common headers
#include <math.h>


////////////////////////////////////////////////////////////////////////////////
// OS depended headers
#include <afxwin.h>
#include <afxcmn.h>
#include <afxdlgs.h>

////////////////////////////////////////////////////////////////////////////////
// program specific headers
#include "fx_const.h"
#include "fx_core.h"


namespace fx_ns {

/*******************************************************************************
*  declarations                                                                *
*******************************************************************************/

////////////////////////////////////////////////////////////////////////////////
// CfxListCtr (declaration)
class CfxListCtr: public CListCtrl {
private:
	DECLARE_MESSAGE_MAP();
public:
	static const DWORD list_style = LVS_SHOWSELALWAYS|LVS_SINGLESEL|LVS_REPORT|WS_VSCROLL|WS_HSCROLL;
	static const DWORD list_ext_style = WS_TABSTOP|WS_EX_CLIENTEDGE;
};


struct sfx_time_hlp {
	CTime *st_time;
	cfx_if::sfx_clnt_item *item;
	UINT_PTR timer_id;
};


////////////////////////////////////////////////////////////////////////////////
// cfx_gui (declaration)
class cfx_dialog: public CDialog {
public:
	cfx_dialog();
	~cfx_dialog();

	void set_iface(cfx_if *const iface) { _iface = iface; }
	cfx_if *get_iface() const { return _iface; }

	int scp_host() const { return _scp_host; }
	int scp_addr() const { return _scp_addr; }
	int scp_port() const { return _scp_port; }
	int scp_state() const { return _scp_state; }

	int ccp_done() const { return _ccp_done; }
	int ccp_host() const { return _ccp_host; }
	int ccp_addr() const { return _ccp_addr; }
	int ccp_port() const { return _ccp_port; }
	int ccp_state() const { return _ccp_state; }
	int ccp_fname() const { return _ccp_fname; }
	int ccp_fsize() const { return _ccp_fsize; }
	int ccp_time() const { return _ccp_time; }

	void set_sbtns_state(const int state);
	void set_cbtns_state(const int state);

    // controls
	CEdit *edit_addr;
	CEdit *edit_port;
	CEdit *edit_file;
	CButton *btn_stop_serv;
	CButton *btn_kill_serv;
	CButton *btn_pause;
	CButton *btn_kill;
	CListCtrl *list_serv;
	CListCtrl *list_con;

protected:
	////////////////////////////////////////////////////////////////////////////
	// buttons text
	static const int STR_BTN_STOP	= 16010;
	static const int STR_BTN_RUN	= 16015;
	static const int STR_BTN_KILL	= 16020;
	static const int STR_BTN_PAUSE	= 16025;
	static const int STR_BTN_RESUME	= 16030;
	static const int STR_BTN_NA		= 16035;

	////////////////////////////////////////////////////////////////////////////
	// columns name id's
	static const int COLUMN_HOST	= 15010;
	static const int COLUMN_ADDRES	= 15015;
	static const int COLUMN_PORT	= 15020;
	static const int COLUMN_STATE	= 15025;
	static const int COLUMN_DONE	= 15030;
	static const int COLUMN_FNAME	= 15035;
	static const int COLUMN_FSIZE	= 15040;
	static const int COLUMN_TIME	= 15045;

	////////////////////////////////////////////////////////////////////////////
	// columns description
	struct sfx_column {
		unsigned int n_id;
		int width;
	};

	static const sfx_column _s_columns[];
	static const sfx_column _c_columns[];


	////////////////////////////////////////////////////////////////////////////
	// protected functions
	int _scol_num() const;
	int _ccol_num() const;
	int _get_scol_pos(const unsigned int id) const;
	int _get_ccol_pos(const unsigned int id) const;

	DECLARE_MESSAGE_MAP();

	void _on_btn_new_serv();
	void _on_btn_browse();
	void _on_btn_send_file();
	void _on_btn_stop_serv();
	void _on_btn_kill_serv();
	void _on_btn_pause();
	void _on_btn_kill();
	void _on_serv_click(NMHDR *phdr, LRESULT *pinfo);
	void _on_con_click(NMHDR *phdr, LRESULT *pinfo);
	void _on_btn_exit();
	BOOL OnInitDialog();
	void OnTimer(UINT nIDEvent);

	int _get_port();
	void _serv_sel_item(const int id);
	void _con_sel_item(const int id);

private:
	int _sbtns_state;
	static const DWORD _list_style = LVS_SHOWSELALWAYS|LVS_SINGLESEL|
									LVS_REPORT|WS_VSCROLL|WS_HSCROLL|
									WS_CHILD|WS_VISIBLE;
	cfx_if *_iface;

	// columns indexes
	int _scp_host;
	int _scp_addr;
	int _scp_port;
	int _scp_state;

	int _ccp_done;
	int _ccp_host;
	int _ccp_addr;
	int _ccp_port;
	int _ccp_state;
	int _ccp_fname;
	int _ccp_fsize;
	int _ccp_time;
};



////////////////////////////////////////////////////////////////////////////////
// cfx_gui (declaration)
class cfx_gui: public cfx_if {
public:
	cfx_gui();
	~cfx_gui();

	// int attach(cfx_core *core);
	int run();
	// int detach();

	sfx_data exec_cmd(const int cmd, const sfx_data ldata, const sfx_data rdata);

	int error_report(const char *const msg, int int_id = 0, int win_id = 0);

protected:
	BOOL _load_string(CString &str, const UINT id);

	sfx_data _on_error_report(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_us_new(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_us_modify(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_us_kill(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_uc_new(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_uc_modify(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_uc_kill(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_ask_acceptic(const sfx_data ldata, const sfx_data rdata);
	sfx_data _on_ask_filename(const sfx_data ldata, const sfx_data rdata);

private:
	cfx_core *_core;
	cfx_dialog *_dlg;

	int _serv_count;
	int _clnt_count;

	HANDLE _kill_mutex;
};



}	// end of namespace fx_ns



#endif FX_GUI
Соседние файлы в папке fexchange