From abc2cc57795131cd87707b62c455d662e032e70a Mon Sep 17 00:00:00 2001 From: Dennis Syrovatsky Date: Wed, 23 Nov 2005 03:52:07 +0000 Subject: [PATCH] The control of the states of the buttons was added to the FTDialog class. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@412 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- vncviewer/FTDialog.cxx | 130 ++++++++++++++++++++++++++++++++++++++++- vncviewer/FTDialog.h | 6 ++ 2 files changed, 135 insertions(+), 1 deletion(-) diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx index ece35ae0..dacce7bf 100644 --- a/vncviewer/FTDialog.cxx +++ b/vncviewer/FTDialog.cxx @@ -159,20 +159,46 @@ FTDialog::FTDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { + case IDC_FTLOCALPATH: + switch (HIWORD (wParam)) + { + case CBN_SETFOCUS: + _this->refreshState(); + return FALSE; + } + break; + case IDC_FTREMOTEPATH: + switch (HIWORD (wParam)) + { + case CBN_SETFOCUS: + _this->refreshState(); + return FALSE; + } + break; case IDC_FTCLOSE: _this->closeFTDialog(); return FALSE; case IDC_FTLOCALUP: + _this->refreshState(); _this->onLocalOneUpFolder(); return FALSE; case IDC_FTREMOTEUP: + _this->refreshState(); _this->onRemoteOneUpFolder(); return FALSE; case IDC_FTLOCALRELOAD: + _this->refreshState(); _this->onLocalReload(); return FALSE; case IDC_FTREMOTERELOAD: - _this->onRemoteReload(); + _this->refreshState(); + _this->onRemoteReload(); + return FALSE; + case IDC_FTUPLOAD: + _this->onUpload(); + return FALSE; + case IDC_FTDOWNLOAD: + _this->onDownload(); return FALSE; } } @@ -184,23 +210,36 @@ FTDialog::FTDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case IDC_FTLOCALLIST: switch (((LPNMHDR) lParam)->code) { + case NM_CLICK: + case NM_SETFOCUS: + case LVN_ITEMCHANGED: + _this->refreshState(); + return FALSE; case LVN_GETDISPINFO: _this->m_pLocalLV->onGetDispInfo((NMLVDISPINFO *) lParam); return FALSE; case LVN_ITEMACTIVATE: _this->onLocalItemActivate((LPNMITEMACTIVATE) lParam); return FALSE; + case NM_RCLICK: + return FALSE; } break; case IDC_FTREMOTELIST: switch (((LPNMHDR) lParam)->code) { + case NM_CLICK: + case NM_SETFOCUS: + case LVN_ITEMCHANGED: + _this->refreshState(); case LVN_GETDISPINFO: _this->m_pRemoteLV->onGetDispInfo((NMLVDISPINFO *) lParam); return FALSE; case LVN_ITEMACTIVATE: _this->onRemoteItemActivate((LPNMITEMACTIVATE) lParam); return FALSE; + case NM_RCLICK: + return FALSE; } break; } @@ -316,6 +355,18 @@ FTDialog::makeOneUpFolder(char *pPath) return strlen(pPath); } +void +FTDialog::onUpload() +{ + +} + +void +FTDialog::onDownload() +{ + +} + void FTDialog::setIcon(int dest, int idIcon) { @@ -323,3 +374,80 @@ FTDialog::setIcon(int dest, int idIcon) SendMessage(GetDlgItem(m_hwndFTDialog, dest), BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) hIcon); DestroyIcon((HICON) hIcon); } + +void +FTDialog::refreshState() +{ + if (!m_bDlgShown) return; + + int locPathLen = strlen(m_szLocalPath); + int remPathLen = strlen(m_szRemotePath); + + if (GetFocus() == m_pLocalLV->getWndHandle()) { + if (strlen(m_szLocalPath) != 0) { + int nCount = ListView_GetSelectedCount(m_pLocalLV->getWndHandle()); + if (nCount <= 0) { + setButtonsState(0, 0, -1); + } else { + if (remPathLen == 0) { + setButtonsState(0, 0, -1); + } else { + setButtonsState(1, 0, -1); + } + } + } else { + setButtonsState(0, 0, -1); + } + } else { + if (GetFocus() == m_pRemoteLV->getWndHandle()) { + if (strlen(m_szRemotePath) != 0) { + int nCount = ListView_GetSelectedCount(m_pRemoteLV->getWndHandle()); + if (nCount <= 0) { + setButtonsState(0, 0, -1); + } else { + if (locPathLen == 0) { + setButtonsState(0, 0, -1); + } else { + setButtonsState(0, 1, -1); + } + } + } else { + setButtonsState(0, 0, -1); + } + } else { + setButtonsState(0, 0, -1); + } + } +/* + if (m_pFileTransfer->isTransferEnable()) { + setAllButtonsState(-1, -1, -1, -1, 1); + } else { + setAllButtonsState(-1, -1, -1, -1, 0); + } +*/ +} + +void +FTDialog::setButtonsState(int uploadBtnState, int downloadBtnState, int cancelBtnState) +{ + switch (uploadBtnState) + { + case 0: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTUPLOAD), FALSE); break; + case 1: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTUPLOAD), TRUE); break; + default: break; + } + + switch (downloadBtnState) + { + case 0: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTDOWNLOAD), FALSE); break; + case 1: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTDOWNLOAD), TRUE); break; + default: break; + } + + switch (cancelBtnState) + { + case 0: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTCANCEL), FALSE); break; + case 1: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTCANCEL), TRUE); break; + default: break; + } +} \ No newline at end of file diff --git a/vncviewer/FTDialog.h b/vncviewer/FTDialog.h index 961b1a89..88ff9e93 100644 --- a/vncviewer/FTDialog.h +++ b/vncviewer/FTDialog.h @@ -69,12 +69,18 @@ namespace rfb { void onLocalReload(); void onRemoteReload(); + void onUpload(); + void onDownload(); + void setIcon(int dest, int idIcon); bool initFTDialog(); void onLocalOneUpFolder(); void onRemoteOneUpFolder(); int makeOneUpFolder(char *pPath); + + void refreshState(); + void setButtonsState(int uploadBtnState, int downloadBtnState, int cancelBtnState); bool m_bDlgShown; -- 2.39.5