diff options
author | Dennis Syrovatsky <dennis@tightvnc.com> | 2005-12-15 14:20:03 +0000 |
---|---|---|
committer | Dennis Syrovatsky <dennis@tightvnc.com> | 2005-12-15 14:20:03 +0000 |
commit | 1a3a5532a6c6924258040d24bd47fc4132c17a0f (patch) | |
tree | 560cc32ed71fbc5d630de0bd1e662b85c02a5f6c /vncviewer/FTBrowseDlg.cxx | |
parent | b0b7247602f2c18015f321d7c2b7642a04e03987 (diff) | |
download | tigervnc-1a3a5532a6c6924258040d24bd47fc4132c17a0f.tar.gz tigervnc-1a3a5532a6c6924258040d24bd47fc4132c17a0f.zip |
Added browse folders possibility on both sides (local and remote).
Code improvements.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@457 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/FTBrowseDlg.cxx')
-rw-r--r-- | vncviewer/FTBrowseDlg.cxx | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/vncviewer/FTBrowseDlg.cxx b/vncviewer/FTBrowseDlg.cxx index 81cd882e..7c88ff6a 100644 --- a/vncviewer/FTBrowseDlg.cxx +++ b/vncviewer/FTBrowseDlg.cxx @@ -30,6 +30,8 @@ FTBrowseDlg::FTBrowseDlg(FTDialog *pFTDlg) { m_pFTDlg = pFTDlg; m_hwndDlg = NULL; + m_hwndTree = NULL; + m_hParentItem = NULL; } FTBrowseDlg::~FTBrowseDlg() @@ -46,6 +48,8 @@ FTBrowseDlg::create() if (m_hwndDlg == NULL) return false; + m_hwndTree = GetDlgItem(m_hwndDlg, IDC_FTBROWSETREE); + ShowWindow(m_hwndDlg, SW_SHOW); UpdateWindow(m_hwndDlg); @@ -64,17 +68,70 @@ FTBrowseDlg::addItems(FileInfo *pFI) TVITEM tvi; TVINSERTSTRUCT tvins; + while (TreeView_GetChild(m_hwndTree, m_hParentItem) != NULL) { + TreeView_DeleteItem(m_hwndTree, TreeView_GetChild(m_hwndTree, m_hParentItem)); + } + for (unsigned int i = 0; i < pFI->getNumEntries(); i++) { tvi.mask = TVIF_TEXT; tvi.pszText = pFI->getNameAt(i);; - tvins.hParent = NULL; + tvins.hParent = m_hParentItem; tvins.item = tvi; - tvins.hParent = TreeView_InsertItem(GetDlgItem(m_hwndDlg, IDC_FTBROWSETREE), &tvins); - TreeView_InsertItem(GetDlgItem(m_hwndDlg, IDC_FTBROWSETREE), &tvins); + tvins.hParent = TreeView_InsertItem(m_hwndTree, &tvins); + TreeView_InsertItem(m_hwndTree, &tvins); } } +char * +FTBrowseDlg::getTVPath(HTREEITEM hTItem) +{ + char path[FT_FILENAME_SIZE]; + char szText[FT_FILENAME_SIZE]; + + TVITEM tvi; + path[0] = '\0'; + + do { + tvi.mask = TVIF_TEXT | TVIF_HANDLE; + tvi.hItem = hTItem; + tvi.pszText = szText; + tvi.cchTextMax = FT_FILENAME_SIZE; + TreeView_GetItem(m_hwndTree, &tvi); + sprintf(path, "%s\\%s", path, tvi.pszText); + hTItem = TreeView_GetParent(m_hwndTree, hTItem); + } while(hTItem != NULL); + + return pathInvert(path); +} + +char * +FTBrowseDlg::pathInvert(char *pPath) +{ + int len = strlen(pPath); + m_szPath[0] = '\0'; + char *pos = NULL; + + while ((pos = strrchr(pPath, '\\')) != NULL) { + if (strlen(m_szPath) == 0) { + strcpy(m_szPath, (pos + 1)); + } else { + sprintf(m_szPath, "%s\\%s", m_szPath, (pos + 1)); + } + *pos = '\0'; + } + + m_szPath[len] = '\0'; + return m_szPath; +} + +char * +FTBrowseDlg::getPath() +{ + GetDlgItemText(m_hwndDlg, IDC_FTBROWSEPATH, m_szPath, FT_FILENAME_SIZE); + return m_szPath; +} + BOOL CALLBACK FTBrowseDlg::FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -92,8 +149,10 @@ FTBrowseDlg::FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDOK: + _this->m_pFTDlg->onEndBrowseDlg(true); return FALSE; case IDCANCEL: + _this->m_pFTDlg->onEndBrowseDlg(false); return FALSE; } } @@ -105,16 +164,23 @@ FTBrowseDlg::FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) switch (((LPNMHDR) lParam)->code) { case TVN_SELCHANGED: + SetDlgItemText(hwnd, IDC_FTBROWSEPATH, _this->getTVPath(((NMTREEVIEW *) lParam)->itemNew.hItem)); return FALSE; case TVN_ITEMEXPANDING: + { + NMTREEVIEW *nmCode = (NMTREEVIEW *) lParam; + if (nmCode->action == 2) { + _this->m_hParentItem = nmCode->itemNew.hItem; + _this->m_pFTDlg->getBrowseItems(_this->getTVPath(_this->m_hParentItem)); + } + } return FALSE; } - break; - } break; case WM_CLOSE: - case WM_DESTROY: + _this->m_pFTDlg->onEndBrowseDlg(false); return FALSE; } + } return 0; } |