00001 /* 00002 * Copyright 2003, 2004, 2005 Martin Fuchs 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 00020 // 00021 // Explorer clone 00022 // 00023 // filechild.cpp 00024 // 00025 // Martin Fuchs, 23.07.2003 00026 // 00027 00028 00029 #include <precomp.h> 00030 00031 #include "ntobjfs.h" 00032 #include "regfs.h" 00033 #include "fatfs.h" 00034 00035 #include "../resource.h" 00036 00037 00038 FileChildWndInfo::FileChildWndInfo(HWND hmdiclient, LPCTSTR path, ENTRY_TYPE etype) 00039 : super(hmdiclient), 00040 _etype(etype) 00041 { 00042 #ifndef _NO_WIN_FS 00043 if (etype == ET_UNKNOWN) 00044 #ifdef __WINE__ 00045 if (*path == '/') 00046 _etype = ET_UNIX; 00047 else 00048 #endif 00049 _etype = ET_WINDOWS; 00050 #endif 00051 00052 _path = path; 00053 00054 _pos.length = sizeof(WINDOWPLACEMENT); 00055 _pos.flags = 0; 00056 _pos.showCmd = SW_SHOWNORMAL; 00057 _pos.rcNormalPosition.left = CW_USEDEFAULT; 00058 _pos.rcNormalPosition.top = CW_USEDEFAULT; 00059 _pos.rcNormalPosition.right = CW_USEDEFAULT; 00060 _pos.rcNormalPosition.bottom = CW_USEDEFAULT; 00061 00062 _open_mode = OWM_EXPLORE|OWM_DETAILS; 00063 } 00064 00065 00066 ShellChildWndInfo::ShellChildWndInfo(HWND hmdiclient, LPCTSTR path, const ShellPath& root_shell_path) 00067 : FileChildWndInfo(hmdiclient, path, ET_SHELL), 00068 _shell_path(path&&*path? path: root_shell_path), 00069 _root_shell_path(root_shell_path) 00070 { 00071 } 00072 00073 00074 NtObjChildWndInfo::NtObjChildWndInfo(HWND hmdiclient, LPCTSTR path) 00075 : FileChildWndInfo(hmdiclient, path, ET_NTOBJS) 00076 { 00077 } 00078 00079 00080 RegistryChildWndInfo::RegistryChildWndInfo(HWND hmdiclient, LPCTSTR path) 00081 : FileChildWndInfo(hmdiclient, path, ET_REGISTRY) 00082 { 00083 } 00084 00085 00086 FATChildWndInfo::FATChildWndInfo(HWND hmdiclient, LPCTSTR path) 00087 : FileChildWndInfo(hmdiclient, path, ET_FAT) 00088 { 00089 } 00090 00091 00092 WebChildWndInfo::WebChildWndInfo(HWND hmdiclient, LPCTSTR url) 00093 : FileChildWndInfo(hmdiclient, url, ET_WEB) 00094 { 00095 } 00096 00097 00098 INT_PTR CALLBACK ExecuteDialog::WndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) 00099 { 00100 static struct ExecuteDialog* dlg; 00101 00102 switch(nmsg) { 00103 case WM_INITDIALOG: 00104 dlg = (struct ExecuteDialog*) lparam; 00105 return 1; 00106 00107 case WM_COMMAND: { 00108 int id = (int)wparam; 00109 00110 if (id == IDOK) { 00111 GetWindowText(GetDlgItem(hwnd, 201), dlg->cmd, COUNTOF(dlg->cmd)); 00112 dlg->cmdshow = Button_GetState(GetDlgItem(hwnd,214))&BST_CHECKED? 00113 SW_SHOWMINIMIZED: SW_SHOWNORMAL; 00114 EndDialog(hwnd, id); 00115 } else if (id == IDCANCEL) 00116 EndDialog(hwnd, id); 00117 00118 return 1;} 00119 } 00120 00121 return 0; 00122 } 00123 00124 00125 // FileChildWindow 00126 00127 FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info) 00128 : super(hwnd, info) 00129 { 00130 CONTEXT("FileChildWindow::FileChildWindow()"); 00131 00132 TCHAR drv[_MAX_DRIVE+1]; 00133 Entry* entry = NULL; 00134 00135 _left = NULL; 00136 _right = NULL; 00137 00138 switch(info._etype) { 00139 #ifdef __WINE__ 00140 case ET_UNIX: 00141 _root._drive_type = GetDriveType(info._path); 00142 _root._sort_order = SORT_NAME; 00143 00144 _tsplitpath(info._path, drv, NULL, NULL, NULL); 00145 lstrcat(drv, TEXT("/")); 00146 lstrcpy(_root._volname, TEXT("root fs")); 00147 _root._fs_flags = 0; 00148 lstrcpy(_root._fs, TEXT("unixfs")); 00149 lstrcpy(_root._path, TEXT("/")); 00150 _root._entry = new UnixDirectory(_root._path); 00151 entry = _root.read_tree(info._path+_tcslen(_root._path)); 00152 break; 00153 #endif 00154 00155 case ET_NTOBJS: 00156 _root._drive_type = DRIVE_UNKNOWN; 00157 _root._sort_order = SORT_NAME; 00158 00159 _tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0); 00160 lstrcat(drv, TEXT("\\")); 00161 lstrcpy(_root._volname, TEXT("NT Object Namespace")); 00162 lstrcpy(_root._fs, TEXT("NTOBJ")); 00163 lstrcpy(_root._path, drv); 00164 _root._entry = new NtObjDirectory(_root._path); 00165 entry = _root.read_tree(info._path+_tcslen(_root._path)); 00166 break; 00167 00168 case ET_REGISTRY: 00169 _root._drive_type = DRIVE_UNKNOWN; 00170 _root._sort_order = SORT_NONE; 00171 00172 _tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0); 00173 lstrcat(drv, TEXT("\\")); 00174 lstrcpy(_root._volname, TEXT("Registry")); 00175 lstrcpy(_root._fs, TEXT("Registry")); 00176 lstrcpy(_root._path, drv); 00177 _root._entry = new RegistryRoot(); 00178 entry = _root.read_tree(info._path+_tcslen(_root._path)); 00179 break; 00180 00181 case ET_FAT: { 00182 _root._drive_type = DRIVE_UNKNOWN; 00183 _root._sort_order = SORT_NONE; 00184 00185 _tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0); 00186 lstrcat(drv, TEXT("\\")); 00187 lstrcpy(_root._volname, TEXT("FAT XXX")); //@@ 00188 lstrcpy(_root._fs, TEXT("FAT")); 00189 lstrcpy(_root._path, drv); 00190 FATDrive* drive = new FATDrive(TEXT("c:/reactos-emu/c.img")); //TEXT("\\\\.\\F:")); //@@ 00191 00192 if (drive->_hDrive != INVALID_HANDLE_VALUE) { 00193 _root._entry = drive; 00194 entry = _root.read_tree(info._path+_tcslen(_root._path)); 00195 } 00196 break;} 00197 00198 #ifndef _NO_WIN_FS 00199 default: // ET_WINDOWS 00200 _root._drive_type = GetDriveType(info._path); 00201 _root._sort_order = SORT_NAME; 00202 00203 _tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0); 00204 lstrcat(drv, TEXT("\\")); 00205 GetVolumeInformation(drv, _root._volname, _MAX_FNAME, 0, 0, &_root._fs_flags, _root._fs, COUNTOF(_root._fs)); 00206 lstrcpy(_root._path, drv); 00207 _root._entry = new WinDirectory(_root._path); 00208 entry = _root.read_tree(info._path+_tcslen(_root._path)); 00209 break; 00210 #else 00211 default: 00212 #endif 00213 00214 case ET_SHELL: { //@@ separate FileChildWindow into ShellChildWindow, WinChildWindow, UnixChildWindow ? 00215 _root._drive_type = DRIVE_UNKNOWN; 00216 _root._sort_order = SORT_NAME; 00217 00218 lstrcpy(drv, TEXT("\\")); 00219 lstrcpy(_root._volname, TEXT("Desktop")); 00220 _root._fs_flags = 0; 00221 lstrcpy(_root._fs, TEXT("Shell")); 00222 00223 _root._entry = new ShellDirectory(GetDesktopFolder(), DesktopFolderPath(), hwnd); 00224 const ShellChildWndInfo& shell_info = static_cast<const ShellChildWndInfo&>(info); 00225 entry = _root.read_tree(&*shell_info._shell_path); 00226 break;} 00227 } 00228 00229 if (_root._entry) { 00230 if (info._etype != ET_SHELL) 00231 wsprintf(_root._entry->_data.cFileName, TEXT("%s - %s"), drv, _root._fs); 00232 /*@@else 00233 lstrcpy(_root._entry->_data.cFileName, TEXT("GetDesktopFolder"));*/ 00234 00235 _root._entry->_data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; 00236 00237 00238 ///@todo use OWM_ROOTED flag 00239 00240 if (info._open_mode & OWM_EXPLORE) ///@todo Is not-explore-mode for FileChildWindow completely implemented? 00241 _left_hwnd = *(_left=new Pane(_hwnd, IDW_TREE_LEFT, IDW_HEADER_LEFT, _root._entry, true, COL_CONTENT)); 00242 00243 _right_hwnd = *(_right=new Pane(_hwnd, IDW_TREE_RIGHT, IDW_HEADER_RIGHT, NULL, false, 00244 COL_TYPE|COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS|COL_CONTENT)); 00245 } 00246 00247 _header_wdths_ok = false; 00248 00249 if (!_left_hwnd && !_right_hwnd) 00250 return; 00251 00252 if (entry) 00253 set_curdir(entry); 00254 else if (_root._entry) 00255 set_curdir(_root._entry); 00256 00257 if (_left_hwnd) { 00258 int idx = ListBox_FindItemData(_left_hwnd, ListBox_GetCurSel(_left_hwnd), _left->_cur); 00259 ListBox_SetCurSel(_left_hwnd, idx); 00260 //SetFocus(_left_hwnd); 00261 } 00262 00263 // store path into history 00264 if (info._path && *info._path) 00265 _url_history.push(info._path); 00266 } 00267 00268 00269 void FileChildWindow::set_curdir(Entry* entry) 00270 { 00271 CONTEXT("FileChildWindow::set_curdir()"); 00272 00273 _path[0] = TEXT('\0'); 00274 00275 _left->_cur = entry; 00276 _right->_root = entry&&entry->_down? entry->_down: entry; 00277 _right->_cur = entry; 00278 00279 if (entry) { 00280 WaitCursor wait; 00281 00282 if (!entry->_scanned) 00283 scan_entry(entry); 00284 else { 00285 HiddenWindow hide(_right_hwnd); 00286 00287 ListBox_ResetContent(_right_hwnd); 00288 _right->insert_entries(entry->_down); 00289 00290 _right->calc_widths(false); ///@todo make configurable (This call takes really _very_ long compared to all other processing!) 00291 00292 _right->set_header(); 00293 } 00294 00295 entry->get_path(_path, COUNTOF(_path)); 00296 } 00297 00298 if (_hwnd) // only change window title if the window already exists 00299 SetWindowText(_hwnd, _path); 00300 00301 if (_path[0]) 00302 { 00303 if (SetCurrentDirectory(_path)) 00304 set_url(_path); //set_url(FmtString(TEXT("file://%s"), _path)); 00305 else 00306 _path[0] = TEXT('\0'); 00307 } 00308 } 00309 00310 00311 // expand a directory entry 00312 00313 bool FileChildWindow::expand_entry(Entry* dir) 00314 { 00315 int idx; 00316 Entry* p; 00317 00318 if (!dir || dir->_expanded || !dir->_down) 00319 return false; 00320 00321 p = dir->_down; 00322 00323 if (p->_data.cFileName[0]=='.' && p->_data.cFileName[1]=='\0' && p->_next) { 00324 p = p->_next; 00325 00326 if (p->_data.cFileName[0]=='.' && p->_data.cFileName[1]=='.' && 00327 p->_data.cFileName[2]=='\0' && p->_next) 00328 p = p->_next; 00329 } 00330 00331 // no subdirectories ? 00332 if (!(p->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && // not a directory? 00333 !p->_down) // not a file with NTFS sub-streams? 00334 return FALSE; 00335 00336 idx = ListBox_FindItemData(_left_hwnd, 0, dir); 00337 00338 dir->_expanded = true; 00339 00340 // insert entries in left pane 00341 HiddenWindow hide(_left_hwnd); 00342 00343 _left->insert_entries(p, idx); 00344 00345 if (!_header_wdths_ok) { 00346 if (_left->calc_widths(false)) { 00347 _left->set_header(); 00348 00349 _header_wdths_ok = true; 00350 } 00351 } 00352 00353 return true; 00354 } 00355 00356 00357 void FileChildWindow::collapse_entry(Pane* pane, Entry* dir) 00358 { 00359 int idx = ListBox_FindItemData(*pane, 0, dir); 00360 00361 SendMessage(*pane, WM_SETREDRAW, FALSE, 0); //ShowWindow(*pane, SW_HIDE); 00362 00363 // hide sub entries 00364 for(;;) { 00365 LRESULT res = ListBox_GetItemData(*pane, idx+1); 00366 Entry* sub = (Entry*) res; 00367 00368 if (res==LB_ERR || !sub || sub->_level<=dir->_level) 00369 break; 00370 00371 ListBox_DeleteString(*pane, idx+1); 00372 } 00373 00374 dir->_expanded = false; 00375 00376 SendMessage(*pane, WM_SETREDRAW, TRUE, 0); //ShowWindow(*pane, SW_SHOW); 00377 } 00378 00379 00380 FileChildWindow* FileChildWindow::create(const FileChildWndInfo& info) 00381 { 00382 CONTEXT("FileChildWindow::create()"); 00383 00384 MDICREATESTRUCT mcs; 00385 00386 mcs.szClass = CLASSNAME_WINEFILETREE; 00387 mcs.szTitle = (LPTSTR)info._path; 00388 mcs.hOwner = g_Globals._hInstance; 00389 mcs.x = info._pos.rcNormalPosition.left; 00390 mcs.y = info._pos.rcNormalPosition.top; 00391 mcs.cx = info._pos.rcNormalPosition.right - info._pos.rcNormalPosition.left; 00392 mcs.cy = info._pos.rcNormalPosition.bottom - info._pos.rcNormalPosition.top; 00393 mcs.style = 0; 00394 mcs.lParam = 0; 00395 00396 FileChildWindow* child = static_cast<FileChildWindow*>( 00397 create_mdi_child(info, mcs, WINDOW_CREATOR_INFO(FileChildWindow,FileChildWndInfo))); 00398 00399 if (!child->_left_hwnd && !child->_right_hwnd) { 00400 SendMessage(info._hmdiclient, WM_MDIDESTROY, (WPARAM)child->_hwnd, 0); 00401 MessageBox(info._hmdiclient, TEXT("Error opening child window"), TEXT("ROS Explorer"), MB_OK); 00402 } 00403 00404 return child; 00405 } 00406 00407 00408 void FileChildWindow::resize_children(int cx, int cy) 00409 { 00410 HDWP hdwp = BeginDeferWindowPos(4); 00411 RECT rt; 00412 00413 rt.left = 0; 00414 rt.top = 0; 00415 rt.right = cx; 00416 rt.bottom = cy; 00417 00418 cx = _split_pos + SPLIT_WIDTH/2; 00419 00420 if (_left && _right) { 00421 WINDOWPOS wp; 00422 HD_LAYOUT hdl; 00423 00424 hdl.prc = &rt; 00425 hdl.pwpos = ℘ 00426 00427 Header_Layout(_left->_hwndHeader, &hdl); 00428 00429 hdwp = DeferWindowPos(hdwp, _left->_hwndHeader, wp.hwndInsertAfter, 00430 wp.x-1, wp.y, _split_pos-SPLIT_WIDTH/2+1, wp.cy, wp.flags); 00431 00432 hdwp = DeferWindowPos(hdwp, _right->_hwndHeader, wp.hwndInsertAfter, 00433 rt.left+cx+1, wp.y, wp.cx-cx+2, wp.cy, wp.flags); 00434 } 00435 00436 if (_left_hwnd) 00437 hdwp = DeferWindowPos(hdwp, _left_hwnd, 0, rt.left, rt.top, _split_pos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); 00438 00439 if (_right_hwnd) 00440 hdwp = DeferWindowPos(hdwp, _right_hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); 00441 00442 EndDeferWindowPos(hdwp); 00443 } 00444 00445 00446 LRESULT FileChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) 00447 { 00448 switch(nmsg) { 00449 case WM_DRAWITEM: { 00450 LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lparam; 00451 Entry* entry = (Entry*) dis->itemData; 00452 00453 if (dis->CtlID == IDW_TREE_LEFT) { 00454 _left->draw_item(dis, entry); 00455 return TRUE; 00456 } else if (dis->CtlID == IDW_TREE_RIGHT) { 00457 _right->draw_item(dis, entry); 00458 return TRUE; 00459 } 00460 00461 goto def;} 00462 00463 case WM_SIZE: 00464 if (wparam != SIZE_MINIMIZED) 00465 resize_children(LOWORD(lparam), HIWORD(lparam)); 00466 return DefMDIChildProc(_hwnd, nmsg, wparam, lparam); 00467 00468 case PM_GET_FILEWND_PTR: 00469 return (LRESULT)this; 00470 00471 case WM_SETFOCUS: { 00472 TCHAR path[MAX_PATH]; 00473 00474 if (_left && _left->_cur) { 00475 _left->_cur->get_path(path, COUNTOF(path)); 00476 SetCurrentDirectory(path); 00477 } 00478 00479 SetFocus(_focus_pane? _right_hwnd: _left_hwnd); 00480 goto def;} 00481 00482 case PM_DISPATCH_COMMAND: { 00483 Pane* pane = GetFocus()==_left_hwnd? _left: _right; 00484 00485 switch(LOWORD(wparam)) { 00486 case ID_WINDOW_NEW: {CONTEXT("FileChildWindow PM_DISPATCH_COMMAND ID_WINDOW_NEW"); 00487 if (_root._entry->_etype == ET_SHELL) 00488 FileChildWindow::create(ShellChildWndInfo(GetParent(_hwnd)/*_hmdiclient*/, _path, DesktopFolderPath())); 00489 else 00490 FileChildWindow::create(FileChildWndInfo(GetParent(_hwnd)/*_hmdiclient*/, _path)); 00491 break;} 00492 00493 case ID_REFRESH: {CONTEXT("ID_REFRESH"); 00494 refresh(); 00495 break;} 00496 00497 case ID_ACTIVATE: {CONTEXT("ID_ACTIVATE"); 00498 activate_entry(pane); 00499 break;} 00500 00501 default: 00502 if (pane->command(LOWORD(wparam))) 00503 return TRUE; 00504 else 00505 return super::WndProc(nmsg, wparam, lparam); 00506 } 00507 00508 return TRUE;} 00509 00510 case WM_CONTEXTMENU: { 00511 // first select the current item in the listbox 00512 HWND hpanel = (HWND) wparam; 00513 POINT pt; 00514 pt.x = LOWORD(lparam); 00515 pt.y = HIWORD(lparam); 00516 POINT pt_screen = pt; 00517 ScreenToClient(hpanel, &pt); 00518 SendMessage(hpanel, WM_LBUTTONDOWN, 0, MAKELONG(pt.x, pt.y)); 00519 SendMessage(hpanel, WM_LBUTTONUP, 0, MAKELONG(pt.x, pt.y)); 00520 00521 // now create the popup menu using shell namespace and IContextMenu 00522 Pane* pane = GetFocus()==_left_hwnd? _left: _right; 00523 int idx = ListBox_GetCurSel(*pane); 00524 if (idx != -1) { 00525 Entry* entry = (Entry*) ListBox_GetItemData(*pane, idx); 00526 00527 HRESULT hr = entry->do_context_menu(_hwnd, pt_screen, _cm_ifs); 00528 00529 if (SUCCEEDED(hr)) 00530 refresh(); 00531 else 00532 CHECKERROR(hr); 00533 } 00534 break;} 00535 00536 default: def: 00537 return super::WndProc(nmsg, wparam, lparam); 00538 } 00539 00540 return 0; 00541 } 00542 00543 00544 void FileChildWindow::refresh() 00545 { 00546 WaitCursor wait; 00547 bool expanded = _left->_cur->_expanded; 00548 00549 scan_entry(_left->_cur); 00550 00551 if (expanded) 00552 expand_entry(_left->_cur); 00553 } 00554 00555 00556 int FileChildWindow::Command(int id, int code) 00557 { 00558 Pane* pane = GetFocus()==_left_hwnd? _left: _right; 00559 00560 switch(code) { 00561 case LBN_SELCHANGE: { 00562 int idx = ListBox_GetCurSel(*pane); 00563 Entry* entry = (Entry*) ListBox_GetItemData(*pane, idx); 00564 00565 if (pane == _left) 00566 set_curdir(entry); 00567 else 00568 pane->_cur = entry; 00569 break;} 00570 00571 case LBN_DBLCLK: 00572 activate_entry(pane); 00573 break; 00574 } 00575 00576 return 0; 00577 } 00578 00579 00580 void FileChildWindow::activate_entry(Pane* pane) ///@todo enable using RETURN key accelerator 00581 { 00582 Entry* entry = pane->_cur; 00583 00584 if (!entry) 00585 return; 00586 00587 WaitCursor wait; 00588 00589 if ((entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || // a directory? 00590 entry->_down) // a file with NTFS sub-streams? 00591 { 00592 int scanned_old = entry->_scanned; 00593 00594 if (!scanned_old) 00595 scan_entry(entry); 00596 00597 if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('\0')) 00598 return; 00599 00600 if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('.') && entry->_data.cFileName[2]==TEXT('\0')) { 00601 entry = _left->_cur->_up; 00602 collapse_entry(_left, entry); 00603 goto focus_entry; 00604 } else if (entry->_expanded) 00605 collapse_entry(pane, _left->_cur); 00606 else { 00607 expand_entry(_left->_cur); 00608 00609 if (!pane->_treePane) focus_entry: { 00610 int idx = ListBox_FindItemData(_left_hwnd, ListBox_GetCurSel(_left_hwnd), entry); 00611 ListBox_SetCurSel(_left_hwnd, idx); 00612 00613 set_curdir(entry); 00614 } 00615 } 00616 00617 if (!scanned_old) { 00618 pane->calc_widths(false); 00619 00620 pane->set_header(); 00621 } 00622 } else { 00623 entry->launch_entry(_hwnd); 00624 } 00625 } 00626 00627 00628 void FileChildWindow::scan_entry(Entry* entry) 00629 { 00630 CONTEXT("FileChildWindow::scan_entry()"); 00631 00632 int idx = ListBox_GetCurSel(_left_hwnd); 00633 00634 // delete sub entries in left pane 00635 for(;;) { 00636 LRESULT res = ListBox_GetItemData(_left_hwnd, idx+1); 00637 Entry* sub = (Entry*) res; 00638 00639 if (res==LB_ERR || !sub || sub->_level<=entry->_level) 00640 break; 00641 00642 ListBox_DeleteString(_left_hwnd, idx+1); 00643 } 00644 00645 // empty right pane 00646 ListBox_ResetContent(_right_hwnd); 00647 00648 // release memory 00649 entry->free_subentries(); 00650 entry->_expanded = false; 00651 00652 // read contents from disk 00653 entry->read_directory_base(_root._sort_order); ///@todo use modifyable sort order instead of fixed file system default 00654 00655 // insert found entries in right pane 00656 HiddenWindow hide(_right_hwnd); 00657 _right->insert_entries(entry->_down); 00658 00659 _right->calc_widths(false); 00660 _right->set_header(); 00661 00662 _header_wdths_ok = false; 00663 } 00664 00665 00666 int FileChildWindow::Notify(int id, NMHDR* pnmh) 00667 { 00668 return (pnmh->idFrom==IDW_HEADER_LEFT? _left: _right)->Notify(id, pnmh); 00669 } 00670 00671 00672 String FileChildWindow::jump_to_int(LPCTSTR url) 00673 { 00674 String dir, fname; 00675 00676 if (SplitFileSysURL(url, dir, fname)) { 00677 Entry* entry = NULL; 00678 00679 // call read_tree() to iterate through the hierarchy and open all folders to reach dir 00680 if (_root._entry) 00681 switch(_root._entry->_etype) { 00682 case ET_SHELL: { //@@ separate into FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow ? 00683 ShellPath shell_path(dir); 00684 entry = _root.read_tree(&*shell_path); 00685 break;} 00686 00687 #ifdef __WINE__ 00688 case ET_UNIX: { 00689 LPCTSTR path = dir; 00690 00691 if (!_tcsicmp(path, _root._path, _tcslen(_root._path))) 00692 path += _tcslen(_root._path); 00693 00694 entry = _root.read_tree(path); 00695 break;} 00696 #endif 00697 00698 default: { // ET_NTOBJS, ET_REGISTRY, ET_FAT, ET_WINDOWS 00699 LPCTSTR path = dir; 00700 00701 if (!_tcsnicmp(path, _root._path, _tcslen(_root._path))) 00702 path += _tcslen(_root._path); 00703 00704 entry = _root.read_tree(path); 00705 break;} 00706 } 00707 00708 if (entry) { 00709 // refresh left pane entries 00710 HiddenWindow hide(_left_hwnd); 00711 00712 ListBox_ResetContent(_left_hwnd); 00713 00714 _left->insert_entries(_root._entry); 00715 00716 if (!_header_wdths_ok) { 00717 if (_left->calc_widths(false)) { 00718 _left->set_header(); 00719 00720 _header_wdths_ok = true; 00721 } 00722 } 00723 00724 set_curdir(entry); 00725 00726 if (_left_hwnd) { 00727 int idx = ListBox_FindItemData(_left_hwnd, -1, entry); 00728 00729 if (idx != -1) { // The item should always be found. 00730 ListBox_SetCurSel(_left_hwnd, idx); 00731 SetFocus(_left_hwnd); 00732 } 00733 } 00734 00735 ///@todo use fname 00736 00737 return dir; //FmtString(TEXT("file://%s"), (LPCTSTR)dir); 00738 } 00739 } 00740 00741 return String(); 00742 }
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |