Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
/*******************************************************************************
* file: dm_ui.h *
* version: 0.9.0 *
* author: d-evil [tmd] (mailto:d-evil.tmd@mail.ru) *
* description: not available *
*******************************************************************************/
#ifndef DM_UI_INCLUDED
#define DM_UI_INCLUDED
////////////////////////////////////////////////////////////////////////////////
// headers
#include "resource.h"
#include <afxwin.h>
#include <afxext.h>
#include <afxcview.h>
#include <afxdlgs.h>
#include <afx.h>
#include "dm_core.h"
namespace dm_ui {
using namespace dm_core;
////////////////////////////////////////////////////////////////////////////////
// cdm_ui declaration
class cdm_ui: public CDialog, public cdm_uiproto {
public:
////////////////////////////////////////////////////////////////////////////
// public cdm_ui types
struct sdm_ti_data {
int objt;
void *obj;
};
////////////////////////////////////////////////////////////////////////////
// public cdm_ui constants
static const int OBJT_SERVERS = 32105;
static const int OBJT_SENDERS = 32110;
static const int OBJT_RECVERS = 32115;
static const int OBJT_SERVER = 32150;
static const int OBJT_SENDER = 32155;
static const int OBJT_RECVER = 32160;
static const int CDM_MSG_SERV = WM_USER + 10;
static const int CDM_MSG_RECV = WM_USER + 20;
static const int CDM_MSG_SEND = WM_USER + 30;
cdm_ui();
~cdm_ui();
virtual BOOL OnInitDialog();
virtual void OnOK() {}
virtual void OnCancel() {}
virtual void OnClose();
int set_core(cdm_core *const core);
cdm_core *core() const { return _core; }
HICON get_icon() const { return _hicon; }
void set_icon(const HICON icon) { _hicon = icon; }
int run() { DoModal(); return 0; }
int error_message(const int dm_error, const int os_error);
virtual int on_pure_dm_error(const int dm_error);
virtual int on_error(const int dm_error, const int os_error);
virtual int on_ext_error(void *const error);
virtual int on_frecver_ch(cdm_frecver *const frecver, const int ch_mask);
virtual int on_fsender_ch(cdm_fsender *const fsender, const int ch_mask);
virtual int on_subs_ch(cdm_frecv_subs *const subs, const int ch_mask);
afx_msg LRESULT on_msg_serv(WPARAM hz, LPARAM msk);
afx_msg LRESULT on_msg_send(WPARAM hz, LPARAM msk);
afx_msg LRESULT on_msg_recv(WPARAM hz, LPARAM msk);
virtual int on_frecver_rm(cdm_frecver *const frecver);
virtual int on_fsender_rm(cdm_fsender *const fsender);
virtual int on_subs_rm(cdm_frecv_subs *const subs);
virtual int on_accept(cdm_frecv_subs *const frecv_subs);
virtual int on_quit();
CEdit *edit_host;
CEdit *edit_port;
CEdit *edit_file;
CButton *btn_recv;
CButton *btn_browse;
CButton *btn_send;
CButton *btn_rs;
CButton *btn_pr;
CButton *btn_kill;
CButton *btn_exit;
CTreeCtrl *tree;
CListCtrl *list;
protected:
////////////////////////////////////////////////////////////////////////////
// protected constants
static const int _BTN_RS_NA = -1;
static const int _BTN_RS_R = 0;
static const int _BTN_RS_S = 1;
static const int _BTN_PR_NA = -1;
static const int _BTN_PR_P = 0;
static const int _BTN_PR_R = 1;
static const int _BTN_KILL_NA = -1;
static const int _BTN_KILL_K = 0;
////////////////////////////////////////////////////////////////////////////
// protected event handlers
DECLARE_MESSAGE_MAP();
void _on_btn_exit();
void _on_btn_browse();
void _on_btn_recv();
void _on_btn_send();
void _on_btn_rs();
void _on_btn_pr();
void _on_btn_kill();
void _on_btn_help();
void _on_btn_about();
void _on_check_bugs();
void _on_tree_selch(NMHDR *phdr, LRESULT *pinfo);
void _on_tree_selching(NMHDR *phdr, LRESULT *pinfo);
////////////////////////////////////////////////////////////////////////////
// protected ui helpers
unsigned short _ui_get_port();
void _ui_size_to_str(const unsigned int sz, CString &str);
void _ui_percent_str(const int total, const int done, CString &str);
void _ui_time_str(const time_t t, CString &str);
void _ui_remtime_str(const clock_t up_time, const int total, const int done, CString &str);
int _ui_get_save_file(const CString &name, CString &path);
void _ui_set_btn_rs(const int state);
int _btn_state_rs;
void _ui_set_btn_pr(const int state);
int _btn_state_pr;
void _ui_set_btn_kill(const int state);
int _btn_state_kill;
void _ui_set_server_btns(cdm_frecver *const recver);
void _ui_set_sender_btns(cdm_fsender *const sender);
void _ui_set_recver_btns(cdm_frecv_subs *const subs);
int _ui_list_lock(const int timeout = 0, const int dbg = 0);
int _ui_list_ulock(const int dbg = 0);
int _clear_list();
int _show_blank();
int _show_servs_info(sdm_ti_data *const data);
int _show_serv_info(cdm_frecver *const frecver);
int _updt_serv_info(cdm_frecver *const frecver, const int ch_mask);
int _show_recvers_info(sdm_ti_data *const data);
int _show_recver_info(cdm_frecv_subs *const subs);
int _updt_recver_info(cdm_frecv_subs *const subs, const int ch_mask);
int _show_senders_info(sdm_ti_data *const data);
int _show_sender_info(cdm_fsender *const sender);
int _updt_sender_info(cdm_fsender *const sender, const int ch_mask);
int _tree_add_server(cdm_frecver *const recver);
int _tree_add_recver(cdm_frecv_subs *const subs);
int _tree_add_sender(cdm_fsender *const sender);
int _run_cool_stuff();
int _stop_cool_stuff();
static DWORD _cool_stuff(cdm_ui *mwnd);
static int _load_str(CString &str, const int rid);
static int _get_os_error_str(CString &str, const int ercode);
private:
cdm_core *_core;
HTREEITEM _tr_servers;
HTREEITEM _tr_senders;
HTREEITEM _tr_recvers;
HTREEITEM _ti_active;
HANDLE _list_mtx;
bool _list_changed;
HICON _hicon;
HANDLE _cool_stuff_thread_h;
DWORD _cool_stuff_thread_id;
HANDLE _cool_stuff_mtx;
bool _cool_stuff_stop_flag;
bool _can_quit;
bool _quit_started;
static const int _lst_field_w = 100;
static const int _lst_value_w = 180;
static const int _cool_stuff_timeout = 10000;
};
} // end of namespace "dm_ui"
#endif