4 * Copyright 2000, 2003, 2004, 2005 Martin Fuchs
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #define _MAX_FNAME 256
33 #define _MAX_DIR _MAX_FNAME
34 #define _MAX_EXT _MAX_FNAME
38 #ifdef NONAMELESSUNION
39 #define UNION_MEMBER(x) DUMMYUNIONNAME.x
41 #define UNION_MEMBER(x) x
46 #define DEFAULT_SPLIT_POS 300
48 #define DEFAULT_SPLIT_POS 200
60 typedef struct _Entry
{
71 #ifndef _NO_EXTENSIONS
72 BY_HANDLE_FILE_INFORMATION bhfi
;
74 enum ENTRY_TYPE etype
;
86 TCHAR volname
[_MAX_FNAME
];
96 COL_ATTRIBUTES
= 0x08,
99 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
103 COL_ALL
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_DOSNAMES
|COL_INDEX
|COL_LINKS
116 #ifndef _NO_EXTENSIONS
120 #ifndef _NO_EXTENSIONS
126 int positions
[COLUMNS
+1];
138 int focus_pane
; /* 0: left 1: right */
141 BOOL header_wdths_ok
;
143 TCHAR path
[MAX_PATH
];
146 SORT_ORDER sortOrder
;
150 extern void WineLicense(HWND hwnd
);
151 extern void WineWarranty(HWND hwnd
);
156 /* functions in unixcalls.c */
158 extern void call_getcwd(char* buffer
, size_t len
);
159 extern void* call_opendir(const char* path
);
160 extern int call_readdir(void* pdir
, char* name
, unsigned* pinode
);
161 extern void call_closedir(void* pdir
);
163 extern int call_stat(
164 const char* path
, int* pis_dir
,
165 unsigned long* psize_low
, unsigned long* psize_high
,
166 time_t* patime
, time_t* pmtime
,
167 unsigned long* plinks
170 /* call vswprintf() in msvcrt.dll */
171 int swprintf(wchar_t* buffer
, const wchar_t* fmt
, ...)
173 static int (__cdecl
*vswprintf
)(wchar_t*, const wchar_t*, va_list);
179 HMODULE hmod
= LoadLibraryA("msvcrt");
180 vswprintf
= (int(__cdecl
*)(wchar_t*,const wchar_t*,va_list)) GetProcAddress(hmod
, "vswprintf");
184 ret
= vswprintf(buffer
, fmt
, ap
);
193 // ugly hack to use alloca() while keeping Wine's developers happy
194 #define HeapAlloc(h,f,s) alloca(s)
195 #define HeapFree(h,f,p)
200 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
);
201 static void set_curdir(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
);
202 static void refresh_child(ChildWnd
* child
);
203 static void refresh_drives();
204 static void get_path(Entry
* dir
, PTSTR path
);
206 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
207 LRESULT CALLBACK
ChildWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
208 LRESULT CALLBACK
TreeWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
212 WINEFILE_GLOBALS Globals
;
215 /* some common string constants */
216 const static TCHAR sEmpty
[] = {'\0'};
217 const static TCHAR sSpace
[] = {' ', '\0'};
218 const static TCHAR sNumFmt
[] = {'%','d','\0'};
219 const static TCHAR sQMarks
[] = {'?','?','?','\0'};
221 /* window class names */
222 const static TCHAR sWINEFILEFRAME
[] = {'W','F','S','_','F','r','a','m','e','\0'};
223 const static TCHAR sWINEFILETREE
[] = {'W','F','S','_','T','r','e','e','\0'};
226 /* #define LONGLONGARG _T("I64") */
227 const static TCHAR sLongHexFmt
[] = {'%','I','6','4','X','\0'};
228 const static TCHAR sLongNumFmt
[] = {'%','I','6','4','d','\0'};
230 /* #define LONGLONGARG _T("L") */
231 const static TCHAR sLongHexFmt
[] = {'%','L','X','\0'};
232 const static TCHAR sLongNumFmt
[] = {'%','L','d','\0'};
236 /* load resource string */
237 static LPTSTR
load_string(LPTSTR buffer
, UINT id
)
239 LoadString(Globals
.hInstance
, id
, buffer
, BUFFER_LEN
);
244 #define RS(b, i) load_string(b, i)
247 /* display error message for the specified WIN32 error code */
248 static void display_error(HWND hwnd
, DWORD error
)
250 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
253 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
,
254 0, error
, MAKELANGID(LANG_NEUTRAL
,SUBLANG_DEFAULT
), (PTSTR
)&msg
, 0, NULL
))
255 MessageBox(hwnd
, msg
, RS(b2
,IDS_WINEFILE
), MB_OK
);
257 MessageBox(hwnd
, RS(b1
,IDS_ERROR
), RS(b2
,IDS_WINEFILE
), MB_OK
);
263 /* display network error message using WNetGetLastError() */
264 static void display_network_error(HWND hwnd
)
266 TCHAR msg
[BUFFER_LEN
], provider
[BUFFER_LEN
], b2
[BUFFER_LEN
];
269 if (WNetGetLastError(&error
, msg
, BUFFER_LEN
, provider
, BUFFER_LEN
) == NO_ERROR
)
270 MessageBox(hwnd
, msg
, RS(b2
,IDS_WINEFILE
), MB_OK
);
274 /* allocate and initialise a directory entry */
275 static Entry
* alloc_entry()
277 Entry
* entry
= (Entry
*) malloc(sizeof(Entry
));
279 #ifdef _SHELL_FOLDERS
281 entry
->folder
= NULL
;
288 /* free a directory entry */
289 static void free_entry(Entry
* entry
)
291 #ifdef _SHELL_FOLDERS
292 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
293 DestroyIcon(entry
->hicon
);
295 if (entry
->folder
&& entry
->folder
!=Globals
.iDesktop
)
296 (*entry
->folder
->lpVtbl
->Release
)(entry
->folder
);
299 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, entry
->pidl
);
305 /* recursively free all child entries */
306 static void free_entries(Entry
* dir
)
308 Entry
*entry
, *next
=dir
->down
;
324 static void read_directory_win(Entry
* dir
, LPCTSTR path
)
326 Entry
* first_entry
= NULL
;
330 int level
= dir
->level
+ 1;
331 WIN32_FIND_DATA w32fd
;
333 #ifndef _NO_EXTENSIONS
337 TCHAR buffer
[MAX_PATH
], *p
;
338 for(p
=buffer
; *path
; )
345 hFind
= FindFirstFile(buffer
, &w32fd
);
347 if (hFind
!= INVALID_HANDLE_VALUE
) {
349 entry
= alloc_entry();
357 memcpy(&entry
->data
, &w32fd
, sizeof(WIN32_FIND_DATA
));
360 entry
->expanded
= FALSE
;
361 entry
->scanned
= FALSE
;
362 entry
->level
= level
;
364 #ifdef _NO_EXTENSIONS
365 /* hide directory entry "." */
366 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
367 LPCTSTR name
= entry
->data
.cFileName
;
369 if (name
[0]=='.' && name
[1]=='\0')
373 entry
->etype
= ET_WINDOWS
;
374 entry
->bhfi_valid
= FALSE
;
376 lstrcpy(p
, entry
->data
.cFileName
);
378 hFile
= CreateFile(buffer
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
,
379 0, OPEN_EXISTING
, FILE_FLAG_BACKUP_SEMANTICS
, 0);
381 if (hFile
!= INVALID_HANDLE_VALUE
) {
382 if (GetFileInformationByHandle(hFile
, &entry
->bhfi
))
383 entry
->bhfi_valid
= TRUE
;
390 } while(FindNextFile(hFind
, &entry
->data
));
397 dir
->down
= first_entry
;
402 static Entry
* find_entry_win(Entry
* dir
, LPCTSTR name
)
406 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
408 LPCTSTR q
= entry
->data
.cFileName
;
411 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
413 } while(tolower(*p
++) == tolower(*q
++));
416 q
= entry
->data
.cAlternateFileName
;
419 if (!*p
|| *p
==TEXT('\\') || *p
==TEXT('/'))
421 } while(tolower(*p
++) == tolower(*q
++));
428 static Entry
* read_tree_win(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
430 TCHAR buffer
[MAX_PATH
];
431 Entry
* entry
= &root
->entry
;
435 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
437 #ifndef _NO_EXTENSIONS
438 entry
->etype
= ET_WINDOWS
;
442 while(*s
&& *s
!=TEXT('\\') && *s
!=TEXT('/'))
445 while(*s
==TEXT('\\') || *s
==TEXT('/'))
451 read_directory(entry
, buffer
, sortOrder
, hwnd
);
454 entry
->expanded
= TRUE
;
459 entry
= find_entry_win(entry
, s
);
462 SetCursor(old_cursor
);
468 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
470 static BOOL
time_to_filetime(const time_t* t
, FILETIME
* ftime
)
472 struct tm
* tm
= gmtime(t
);
478 stime
.wYear
= tm
->tm_year
+1900;
479 stime
.wMonth
= tm
->tm_mon
+1;
480 /* stime.wDayOfWeek */
481 stime
.wDay
= tm
->tm_mday
;
482 stime
.wHour
= tm
->tm_hour
;
483 stime
.wMinute
= tm
->tm_min
;
484 stime
.wSecond
= tm
->tm_sec
;
486 return SystemTimeToFileTime(&stime
, ftime
);
489 static void read_directory_unix(Entry
* dir
, LPCTSTR path
)
491 Entry
* first_entry
= NULL
;
497 char cpath
[MAX_PATH
];
499 WideCharToMultiByte(CP_UNIXCP
, 0, path
, -1, cpath
, MAX_PATH
, NULL
, NULL
);
501 const char* cpath
= path
;
504 pdir
= call_opendir(cpath
);
506 int level
= dir
->level
+ 1;
509 char buffer
[MAX_PATH
];
516 for(p
=buffer
,s
=cpath
; *s
; )
519 if (p
==buffer
|| p
[-1]!='/')
522 while(call_readdir(pdir
, p
, &inode
)) {
523 entry
= alloc_entry();
531 entry
->etype
= ET_UNIX
;
534 MultiByteToWideChar(CP_UNIXCP
, 0, p
, -1, entry
->data
.cFileName
, MAX_PATH
);
536 lstrcpy(entry
->data
.cFileName
, p
);
539 entry
->data
.dwFileAttributes
= p
[0]=='.'? FILE_ATTRIBUTE_HIDDEN
: 0;
541 if (!call_stat(buffer
, &is_dir
,
542 &entry
->data
.nFileSizeLow
, &entry
->data
.nFileSizeHigh
,
543 &atime
, &mtime
, &entry
->bhfi
.nNumberOfLinks
))
546 entry
->data
.dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
548 memset(&entry
->data
.ftCreationTime
, 0, sizeof(FILETIME
));
549 time_to_filetime(&atime
, &entry
->data
.ftLastAccessTime
);
550 time_to_filetime(&mtime
, &entry
->data
.ftLastWriteTime
);
552 entry
->bhfi
.nFileIndexLow
= inode
;
553 entry
->bhfi
.nFileIndexHigh
= 0;
555 entry
->bhfi_valid
= TRUE
;
557 entry
->data
.nFileSizeLow
= 0;
558 entry
->data
.nFileSizeHigh
= 0;
559 entry
->bhfi_valid
= FALSE
;
564 entry
->expanded
= FALSE
;
565 entry
->scanned
= FALSE
;
566 entry
->level
= level
;
576 dir
->down
= first_entry
;
580 static Entry
* find_entry_unix(Entry
* dir
, LPCTSTR name
)
584 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
586 LPCTSTR q
= entry
->data
.cFileName
;
589 if (!*p
|| *p
==TEXT('/'))
591 } while(*p
++ == *q
++);
597 static Entry
* read_tree_unix(Root
* root
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
599 TCHAR buffer
[MAX_PATH
];
600 Entry
* entry
= &root
->entry
;
604 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
606 entry
->etype
= ET_UNIX
;
609 while(*s
&& *s
!=TEXT('/'))
612 while(*s
== TEXT('/'))
618 read_directory(entry
, buffer
, sortOrder
, hwnd
);
621 entry
->expanded
= TRUE
;
626 entry
= find_entry_unix(entry
, s
);
629 SetCursor(old_cursor
);
634 #endif /* !defined(_NO_EXTENSIONS) && defined(__WINE__) */
637 #ifdef _SHELL_FOLDERS
640 #define tcscpyn strcpyn
641 #define get_strret get_strretW
642 #define path_from_pidl path_from_pidlW
644 #define tcscpyn wcscpyn
645 #define get_strret get_strretA
646 #define path_from_pidl path_from_pidlA
650 static LPSTR
strcpyn(LPSTR dest
, LPCSTR source
, size_t count
)
655 for(s
=source
; count
&&(*d
++=*s
++); )
661 static LPWSTR
wcscpyn(LPWSTR dest
, LPCWSTR source
, size_t count
)
666 for(s
=source
; count
&&(*d
++=*s
++); )
673 static void get_strretA(STRRET
* str
, const SHITEMID
* shiid
, LPSTR buffer
, int len
)
677 WideCharToMultiByte(CP_ACP
, 0, str
->UNION_MEMBER(pOleStr
), -1, buffer
, len
, NULL
, NULL
);
681 strcpyn(buffer
, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), len
);
685 strcpyn(buffer
, str
->UNION_MEMBER(cStr
), len
);
689 static void get_strretW(STRRET
* str
, const SHITEMID
* shiid
, LPWSTR buffer
, int len
)
693 wcscpyn(buffer
, str
->UNION_MEMBER(pOleStr
), len
);
697 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)shiid
+str
->UNION_MEMBER(uOffset
), -1, buffer
, len
);
701 MultiByteToWideChar(CP_ACP
, 0, str
->UNION_MEMBER(cStr
), -1, buffer
, len
);
706 static void free_strret(STRRET
* str
)
708 if (str
->uType
== STRRET_WSTR
)
709 (*Globals
.iMalloc
->lpVtbl
->Free
)(Globals
.iMalloc
, str
->UNION_MEMBER(pOleStr
));
713 HRESULT
name_from_pidl(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPTSTR buffer
, int len
, SHGDNF flags
)
717 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, flags
, &str
);
720 get_strret(&str
, &pidl
->mkid
, buffer
, len
);
729 HRESULT
path_from_pidlA(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPSTR buffer
, int len
)
733 /* SHGDN_FORPARSING: get full path of id list */
734 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
737 get_strretA(&str
, &pidl
->mkid
, buffer
, len
);
745 HRESULT
path_from_pidlW(IShellFolder
* folder
, LPITEMIDLIST pidl
, LPWSTR buffer
, int len
)
749 /* SHGDN_FORPARSING: get full path of id list */
750 HRESULT hr
= (*folder
->lpVtbl
->GetDisplayNameOf
)(folder
, pidl
, SHGDN_FORPARSING
, &str
);
753 get_strretW(&str
, &pidl
->mkid
, buffer
, len
);
762 /* create an item id list from a file system path */
764 static LPITEMIDLIST
get_path_pidl(LPTSTR path
, HWND hwnd
)
771 LPWSTR buffer
= path
;
773 WCHAR buffer
[MAX_PATH
];
774 MultiByteToWideChar(CP_ACP
, 0, path
, -1, buffer
, MAX_PATH
);
777 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
785 /* convert an item id list from relative to absolute (=relative to the desktop) format */
787 static LPITEMIDLIST
get_to_absolute_pidl(Entry
* entry
, HWND hwnd
)
789 if (entry
->up
&& entry
->up
->etype
==ET_SHELL
) {
790 IShellFolder
* folder
= entry
->up
->folder
;
791 WCHAR buffer
[MAX_PATH
];
793 HRESULT hr
= path_from_pidlW(folder
, entry
->pidl
, buffer
, MAX_PATH
);
799 hr
= (*Globals
.iDesktop
->lpVtbl
->ParseDisplayName
)(Globals
.iDesktop
, hwnd
, NULL
, buffer
, &len
, &pidl
, NULL
);
804 } else if (entry
->etype
== ET_WINDOWS
) {
805 TCHAR path
[MAX_PATH
];
807 get_path(entry
, path
);
809 return get_path_pidl(path
, hwnd
);
810 } else if (entry
->pidl
)
811 return ILClone(entry
->pidl
);
817 HICON
extract_icon(IShellFolder
* folder
, LPCITEMIDLIST pidl
)
819 IExtractIcon
* pExtract
;
821 if (SUCCEEDED((*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, (LPCITEMIDLIST
*)&pidl
, &IID_IExtractIcon
, 0, (LPVOID
*)&pExtract
))) {
822 TCHAR path
[_MAX_PATH
];
827 if (SUCCEEDED((*pExtract
->lpVtbl
->GetIconLocation
)(pExtract
, GIL_FORSHELL
, path
, _MAX_PATH
, &idx
, &flags
))) {
828 if (!(flags
& GIL_NOTFILENAME
)) {
830 idx
= 0; /* special case for some control panel applications */
832 if ((int)ExtractIconEx(path
, idx
, 0, &hicon
, 1) > 0)
833 flags
&= ~GIL_DONTCACHE
;
835 HICON hIconLarge
= 0;
837 HRESULT hr
= (*pExtract
->lpVtbl
->Extract
)(pExtract
, path
, idx
, &hIconLarge
, &hicon
, MAKELONG(0/*GetSystemMetrics(SM_CXICON)*/,GetSystemMetrics(SM_CXSMICON
)));
840 DestroyIcon(hIconLarge
);
851 static Entry
* find_entry_shell(Entry
* dir
, LPCITEMIDLIST pidl
)
855 for(entry
=dir
->down
; entry
; entry
=entry
->next
) {
856 if (entry
->pidl
->mkid
.cb
== pidl
->mkid
.cb
&&
857 !memcmp(entry
->pidl
, pidl
, entry
->pidl
->mkid
.cb
))
864 static Entry
* read_tree_shell(Root
* root
, LPITEMIDLIST pidl
, SORT_ORDER sortOrder
, HWND hwnd
)
866 Entry
* entry
= &root
->entry
;
868 LPITEMIDLIST next_pidl
= pidl
;
869 IShellFolder
* folder
;
870 IShellFolder
* child
= NULL
;
873 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
875 #ifndef _NO_EXTENSIONS
876 entry
->etype
= ET_SHELL
;
879 folder
= Globals
.iDesktop
;
882 entry
->pidl
= next_pidl
;
883 entry
->folder
= folder
;
888 /* copy first element of item idlist */
889 next_pidl
= (*Globals
.iMalloc
->lpVtbl
->Alloc
)(Globals
.iMalloc
, pidl
->mkid
.cb
+sizeof(USHORT
));
890 memcpy(next_pidl
, pidl
, pidl
->mkid
.cb
);
891 ((LPITEMIDLIST
)((LPBYTE
)next_pidl
+pidl
->mkid
.cb
))->mkid
.cb
= 0;
893 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, next_pidl
, 0, &IID_IShellFolder
, (void**)&child
);
897 read_directory(entry
, NULL
, sortOrder
, hwnd
);
900 entry
->expanded
= TRUE
;
902 next
= find_entry_shell(entry
, next_pidl
);
909 /* go to next element */
910 pidl
= (LPITEMIDLIST
) ((LPBYTE
)pidl
+pidl
->mkid
.cb
);
913 SetCursor(old_cursor
);
919 static void fill_w32fdata_shell(IShellFolder
* folder
, LPCITEMIDLIST pidl
, SFGAOF attribs
, WIN32_FIND_DATA
* w32fdata
)
921 if (!(attribs
& SFGAO_FILESYSTEM
) ||
922 FAILED(SHGetDataFromIDList(folder
, pidl
, SHGDFIL_FINDDATA
, w32fdata
, sizeof(WIN32_FIND_DATA
)))) {
923 WIN32_FILE_ATTRIBUTE_DATA fad
;
924 IDataObject
* pDataObj
;
926 STGMEDIUM medium
= {0, {0}, 0};
927 FORMATETC fmt
= {Globals
.cfStrFName
, 0, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
929 HRESULT hr
= (*folder
->lpVtbl
->GetUIObjectOf
)(folder
, 0, 1, &pidl
, &IID_IDataObject
, 0, (LPVOID
*)&pDataObj
);
932 hr
= (*pDataObj
->lpVtbl
->GetData
)(pDataObj
, &fmt
, &medium
);
934 (*pDataObj
->lpVtbl
->Release
)(pDataObj
);
937 LPCTSTR path
= (LPCTSTR
)GlobalLock(medium
.UNION_MEMBER(hGlobal
));
938 UINT sem_org
= SetErrorMode(SEM_FAILCRITICALERRORS
);
940 if (GetFileAttributesEx(path
, GetFileExInfoStandard
, &fad
)) {
941 w32fdata
->dwFileAttributes
= fad
.dwFileAttributes
;
942 w32fdata
->ftCreationTime
= fad
.ftCreationTime
;
943 w32fdata
->ftLastAccessTime
= fad
.ftLastAccessTime
;
944 w32fdata
->ftLastWriteTime
= fad
.ftLastWriteTime
;
946 if (!(fad
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
947 w32fdata
->nFileSizeLow
= fad
.nFileSizeLow
;
948 w32fdata
->nFileSizeHigh
= fad
.nFileSizeHigh
;
952 SetErrorMode(sem_org
);
954 GlobalUnlock(medium
.UNION_MEMBER(hGlobal
));
955 GlobalFree(medium
.UNION_MEMBER(hGlobal
));
960 if (attribs
& (SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
))
961 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_DIRECTORY
;
963 if (attribs
& SFGAO_READONLY
)
964 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
966 if (attribs
& SFGAO_COMPRESSED
)
967 w32fdata
->dwFileAttributes
|= FILE_ATTRIBUTE_COMPRESSED
;
971 static void read_directory_shell(Entry
* dir
, HWND hwnd
)
973 IShellFolder
* folder
= dir
->folder
;
974 int level
= dir
->level
+ 1;
980 Entry
* first_entry
= NULL
;
987 hr
= (*folder
->lpVtbl
->EnumObjects
)(folder
, hwnd
, SHCONTF_FOLDERS
|SHCONTF_NONFOLDERS
|SHCONTF_INCLUDEHIDDEN
|SHCONTF_SHAREABLE
|SHCONTF_STORAGE
, &idlist
);
991 #define FETCH_ITEM_COUNT 32
992 LPITEMIDLIST pidls
[FETCH_ITEM_COUNT
];
997 memset(pidls
, 0, sizeof(pidls
));
999 hr
= (*idlist
->lpVtbl
->Next
)(idlist
, FETCH_ITEM_COUNT
, pidls
, &cnt
);
1006 for(n
=0; n
<cnt
; ++n
) {
1007 entry
= alloc_entry();
1010 first_entry
= entry
;
1015 memset(&entry
->data
, 0, sizeof(WIN32_FIND_DATA
));
1016 entry
->bhfi_valid
= FALSE
;
1018 attribs
= ~SFGAO_FILESYSTEM
; /*SFGAO_HASSUBFOLDER|SFGAO_FOLDER; SFGAO_FILESYSTEM sorgt dafür, daß "My Documents" anstatt von "Martin's Documents" angezeigt wird */
1020 hr
= (*folder
->lpVtbl
->GetAttributesOf
)(folder
, 1, (LPCITEMIDLIST
*)&pidls
[n
], &attribs
);
1022 if (SUCCEEDED(hr
)) {
1023 if (attribs
!= (SFGAOF
)~SFGAO_FILESYSTEM
) {
1024 fill_w32fdata_shell(folder
, pidls
[n
], attribs
, &entry
->data
);
1026 entry
->bhfi_valid
= TRUE
;
1032 entry
->pidl
= pidls
[n
];
1034 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1035 hr
= (*folder
->lpVtbl
->BindToObject
)(folder
, pidls
[n
], 0, &IID_IShellFolder
, (void**)&child
);
1038 entry
->folder
= child
;
1040 entry
->folder
= NULL
;
1043 entry
->folder
= NULL
;
1045 if (!entry
->data
.cFileName
[0])
1046 /*hr = */name_from_pidl(folder
, pidls
[n
], entry
->data
.cFileName
, MAX_PATH
, /*SHGDN_INFOLDER*/0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/);
1048 /* get display icons for files and virtual objects */
1049 if (!(entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1050 !(attribs
& SFGAO_FILESYSTEM
)) {
1051 entry
->hicon
= extract_icon(folder
, pidls
[n
]);
1054 entry
->hicon
= (HICON
)-1; /* don't try again later */
1059 entry
->expanded
= FALSE
;
1060 entry
->scanned
= FALSE
;
1061 entry
->level
= level
;
1063 #ifndef _NO_EXTENSIONS
1064 entry
->etype
= ET_SHELL
;
1065 entry
->bhfi_valid
= FALSE
;
1072 (*idlist
->lpVtbl
->Release
)(idlist
);
1078 dir
->down
= first_entry
;
1079 dir
->scanned
= TRUE
;
1082 #endif /* _SHELL_FOLDERS */
1085 /* sort order for different directory/file types */
1094 /* distinguish between ".", ".." and any other directory names */
1095 static int TypeOrderFromDirname(LPCTSTR name
)
1097 if (name
[0] == '.') {
1098 if (name
[1] == '\0')
1099 return TO_DOT
; /* "." */
1101 if (name
[1]=='.' && name
[2]=='\0')
1102 return TO_DOTDOT
; /* ".." */
1105 return TO_OTHER_DIR
; /* anything else */
1108 /* directories first... */
1109 static int compareType(const WIN32_FIND_DATA
* fd1
, const WIN32_FIND_DATA
* fd2
)
1111 int order1
= fd1
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1112 int order2
= fd2
->dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
? TO_DIR
: TO_FILE
;
1114 /* Handle "." and ".." as special case and move them at the very first beginning. */
1115 if (order1
==TO_DIR
&& order2
==TO_DIR
) {
1116 order1
= TypeOrderFromDirname(fd1
->cFileName
);
1117 order2
= TypeOrderFromDirname(fd2
->cFileName
);
1120 return order2
==order1
? 0: order1
<order2
? -1: 1;
1124 static int compareName(const void* arg1
, const void* arg2
)
1126 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1127 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1129 int cmp
= compareType(fd1
, fd2
);
1133 return lstrcmpi(fd1
->cFileName
, fd2
->cFileName
);
1136 static int compareExt(const void* arg1
, const void* arg2
)
1138 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1139 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1140 const TCHAR
*name1
, *name2
, *ext1
, *ext2
;
1142 int cmp
= compareType(fd1
, fd2
);
1146 name1
= fd1
->cFileName
;
1147 name2
= fd2
->cFileName
;
1149 ext1
= _tcsrchr(name1
, TEXT('.'));
1150 ext2
= _tcsrchr(name2
, TEXT('.'));
1162 cmp
= lstrcmpi(ext1
, ext2
);
1166 return lstrcmpi(name1
, name2
);
1169 static int compareSize(const void* arg1
, const void* arg2
)
1171 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1172 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1174 int cmp
= compareType(fd1
, fd2
);
1178 cmp
= fd2
->nFileSizeHigh
- fd1
->nFileSizeHigh
;
1185 cmp
= fd2
->nFileSizeLow
- fd1
->nFileSizeLow
;
1187 return cmp
<0? -1: cmp
>0? 1: 0;
1190 static int compareDate(const void* arg1
, const void* arg2
)
1192 const WIN32_FIND_DATA
* fd1
= &(*(const Entry
* const*)arg1
)->data
;
1193 const WIN32_FIND_DATA
* fd2
= &(*(const Entry
* const*)arg2
)->data
;
1195 int cmp
= compareType(fd1
, fd2
);
1199 return CompareFileTime(&fd2
->ftLastWriteTime
, &fd1
->ftLastWriteTime
);
1203 static int (*sortFunctions
[])(const void* arg1
, const void* arg2
) = {
1204 compareName
, /* SORT_NAME */
1205 compareExt
, /* SORT_EXT */
1206 compareSize
, /* SORT_SIZE */
1207 compareDate
/* SORT_DATE */
1211 static void SortDirectory(Entry
* dir
, SORT_ORDER sortOrder
)
1213 Entry
* entry
= dir
->down
;
1218 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1222 array
= (Entry
**) HeapAlloc(GetProcessHeap(), 0, len
*sizeof(Entry
*));
1225 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1228 /* call qsort with the appropriate compare function */
1229 qsort(array
, len
, sizeof(array
[0]), sortFunctions
[sortOrder
]);
1231 dir
->down
= array
[0];
1233 for(p
=array
; --len
; p
++)
1238 HeapFree(GetProcessHeap(), 0, array
);
1243 static void read_directory(Entry
* dir
, LPCTSTR path
, SORT_ORDER sortOrder
, HWND hwnd
)
1245 TCHAR buffer
[MAX_PATH
];
1250 #ifdef _SHELL_FOLDERS
1251 if (dir
->etype
== ET_SHELL
)
1253 read_directory_shell(dir
, hwnd
);
1255 if (Globals
.prescan_node
) {
1264 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1265 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1266 read_directory_shell(entry
, hwnd
);
1267 SortDirectory(entry
, sortOrder
);
1273 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1274 if (dir
->etype
== ET_UNIX
)
1276 read_directory_unix(dir
, path
);
1278 if (Globals
.prescan_node
) {
1287 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1288 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1289 lstrcpy(d
, entry
->data
.cFileName
);
1290 read_directory_unix(entry
, buffer
);
1291 SortDirectory(entry
, sortOrder
);
1298 read_directory_win(dir
, path
);
1300 if (Globals
.prescan_node
) {
1309 for(entry
=dir
->down
; entry
; entry
=entry
->next
)
1310 if (entry
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1311 lstrcpy(d
, entry
->data
.cFileName
);
1312 read_directory_win(entry
, buffer
);
1313 SortDirectory(entry
, sortOrder
);
1318 SortDirectory(dir
, sortOrder
);
1322 static Entry
* read_tree(Root
* root
, LPCTSTR path
, LPITEMIDLIST pidl
, LPTSTR drv
, SORT_ORDER sortOrder
, HWND hwnd
)
1324 const static TCHAR sBackslash
[] = {'\\', '\0'};
1325 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1326 const static TCHAR sSlash
[] = {'/', '\0'};
1329 #ifdef _SHELL_FOLDERS
1332 /* read shell namespace tree */
1333 root
->drive_type
= DRIVE_UNKNOWN
;
1336 load_string(root
->volname
, IDS_DESKTOP
);
1338 load_string(root
->fs
, IDS_SHELL
);
1340 return read_tree_shell(root
, pidl
, sortOrder
, hwnd
);
1344 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
1347 /* read unix file system tree */
1348 root
->drive_type
= GetDriveType(path
);
1350 lstrcat(drv
, sSlash
);
1351 load_string(root
->volname
, IDS_ROOT_FS
);
1353 load_string(root
->fs
, IDS_UNIXFS
);
1355 lstrcpy(root
->path
, sSlash
);
1357 return read_tree_unix(root
, path
, sortOrder
, hwnd
);
1361 /* read WIN32 file system tree */
1362 root
->drive_type
= GetDriveType(path
);
1364 lstrcat(drv
, sBackslash
);
1365 GetVolumeInformation(drv
, root
->volname
, _MAX_FNAME
, 0, 0, &root
->fs_flags
, root
->fs
, _MAX_DIR
);
1367 lstrcpy(root
->path
, drv
);
1369 return read_tree_win(root
, path
, sortOrder
, hwnd
);
1373 static ChildWnd
* alloc_child_window(LPCTSTR path
, LPITEMIDLIST pidl
, HWND hwnd
)
1375 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
1376 TCHAR b1
[BUFFER_LEN
];
1378 ChildWnd
* child
= (ChildWnd
*) malloc(sizeof(ChildWnd
));
1379 Root
* root
= &child
->root
;
1382 memset(child
, 0, sizeof(ChildWnd
));
1384 child
->left
.treePane
= TRUE
;
1385 child
->left
.visible_cols
= 0;
1387 child
->right
.treePane
= FALSE
;
1388 #ifndef _NO_EXTENSIONS
1389 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
|COL_INDEX
|COL_LINKS
;
1391 child
->right
.visible_cols
= COL_SIZE
|COL_DATE
|COL_TIME
|COL_ATTRIBUTES
;
1394 child
->pos
.length
= sizeof(WINDOWPLACEMENT
);
1395 child
->pos
.flags
= 0;
1396 child
->pos
.showCmd
= SW_SHOWNORMAL
;
1397 child
->pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
1398 child
->pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
1399 child
->pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
1400 child
->pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
1402 child
->focus_pane
= 0;
1403 child
->split_pos
= DEFAULT_SPLIT_POS
;
1404 child
->sortOrder
= SORT_NAME
;
1405 child
->header_wdths_ok
= FALSE
;
1409 lstrcpy(child
->path
, path
);
1411 _tsplitpath(path
, drv
, dir
, name
, ext
);
1414 root
->entry
.level
= 0;
1416 entry
= read_tree(root
, path
, pidl
, drv
, child
->sortOrder
, hwnd
);
1418 #ifdef _SHELL_FOLDERS
1419 if (root
->entry
.etype
== ET_SHELL
)
1420 load_string(root
->entry
.data
.cFileName
, IDS_DESKTOP
);
1423 wsprintf(root
->entry
.data
.cFileName
, RS(b1
,IDS_TITLEFMT
), drv
, root
->fs
);
1425 root
->entry
.data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1427 child
->left
.root
= &root
->entry
;
1428 child
->right
.root
= NULL
;
1430 set_curdir(child
, entry
, 0, hwnd
);
1436 /* free all memory associated with a child window */
1437 static void free_child_window(ChildWnd
* child
)
1439 free_entries(&child
->root
.entry
);
1444 /* get full path of specified directory entry */
1445 static void get_path(Entry
* dir
, PTSTR path
)
1451 #ifdef _SHELL_FOLDERS
1452 if (dir
->etype
== ET_SHELL
)
1457 path
[0] = TEXT('\0');
1462 hr
= (*dir
->folder
->lpVtbl
->GetAttributesOf
)(dir
->folder
, 1, (LPCITEMIDLIST
*)&dir
->pidl
, &attribs
);
1464 if (SUCCEEDED(hr
) && (attribs
&SFGAO_FILESYSTEM
)) {
1465 IShellFolder
* parent
= dir
->up
? dir
->up
->folder
: Globals
.iDesktop
;
1467 hr
= path_from_pidl(parent
, dir
->pidl
, path
, MAX_PATH
);
1473 for(entry
=dir
; entry
; level
++) {
1479 name
= entry
->data
.cFileName
;
1482 for(l
=0; *s
&& *s
!=TEXT('/') && *s
!=TEXT('\\'); s
++)
1488 memmove(path
+l
+1, path
, len
*sizeof(TCHAR
));
1489 memcpy(path
+1, name
, l
*sizeof(TCHAR
));
1492 #ifndef _NO_EXTENSIONS
1493 if (entry
->etype
== ET_UNIX
)
1494 path
[0] = TEXT('/');
1497 path
[0] = TEXT('\\');
1502 memmove(path
+l
, path
, len
*sizeof(TCHAR
));
1503 memcpy(path
, name
, l
*sizeof(TCHAR
));
1510 #ifndef _NO_EXTENSIONS
1511 if (entry
->etype
== ET_UNIX
)
1512 path
[len
++] = TEXT('/');
1515 path
[len
++] = TEXT('\\');
1518 path
[len
] = TEXT('\0');
1523 static void resize_frame_rect(HWND hwnd
, PRECT prect
)
1528 if (IsWindowVisible(Globals
.htoolbar
)) {
1529 SendMessage(Globals
.htoolbar
, WM_SIZE
, 0, 0);
1530 GetClientRect(Globals
.htoolbar
, &rt
);
1531 prect
->top
= rt
.bottom
+3;
1532 prect
->bottom
-= rt
.bottom
+3;
1535 if (IsWindowVisible(Globals
.hdrivebar
)) {
1536 SendMessage(Globals
.hdrivebar
, WM_SIZE
, 0, 0);
1537 GetClientRect(Globals
.hdrivebar
, &rt
);
1538 new_top
= --prect
->top
+ rt
.bottom
+3;
1539 MoveWindow(Globals
.hdrivebar
, 0, prect
->top
, rt
.right
, new_top
, TRUE
);
1540 prect
->top
= new_top
;
1541 prect
->bottom
-= rt
.bottom
+2;
1544 if (IsWindowVisible(Globals
.hstatusbar
)) {
1545 int parts
[] = {300, 500};
1547 SendMessage(Globals
.hstatusbar
, WM_SIZE
, 0, 0);
1548 SendMessage(Globals
.hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1549 GetClientRect(Globals
.hstatusbar
, &rt
);
1550 prect
->bottom
-= rt
.bottom
;
1553 MoveWindow(Globals
.hmdiclient
, prect
->left
-1,prect
->top
-1,prect
->right
+2,prect
->bottom
+1, TRUE
);
1556 static void resize_frame(HWND hwnd
, int cx
, int cy
)
1565 resize_frame_rect(hwnd
, &rect
);
1568 static void resize_frame_client(HWND hwnd
)
1572 GetClientRect(hwnd
, &rect
);
1574 resize_frame_rect(hwnd
, &rect
);
1578 static HHOOK hcbthook
;
1579 static ChildWnd
* newchild
= NULL
;
1581 LRESULT CALLBACK
CBTProc(int code
, WPARAM wparam
, LPARAM lparam
)
1583 if (code
==HCBT_CREATEWND
&& newchild
) {
1584 ChildWnd
* child
= newchild
;
1587 child
->hwnd
= (HWND
) wparam
;
1588 SetWindowLong(child
->hwnd
, GWL_USERDATA
, (LPARAM
)child
);
1591 return CallNextHookEx(hcbthook
, code
, wparam
, lparam
);
1594 static HWND
create_child_window(ChildWnd
* child
)
1596 MDICREATESTRUCT mcs
;
1599 mcs
.szClass
= sWINEFILETREE
;
1600 mcs
.szTitle
= (LPTSTR
)child
->path
;
1601 mcs
.hOwner
= Globals
.hInstance
;
1602 mcs
.x
= child
->pos
.rcNormalPosition
.left
;
1603 mcs
.y
= child
->pos
.rcNormalPosition
.top
;
1604 mcs
.cx
= child
->pos
.rcNormalPosition
.right
-child
->pos
.rcNormalPosition
.left
;
1605 mcs
.cy
= child
->pos
.rcNormalPosition
.bottom
-child
->pos
.rcNormalPosition
.top
;
1609 hcbthook
= SetWindowsHookEx(WH_CBT
, CBTProc
, 0, GetCurrentThreadId());
1612 child
->hwnd
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDICREATE
, 0, (LPARAM
)&mcs
);
1614 UnhookWindowsHookEx(hcbthook
);
1618 UnhookWindowsHookEx(hcbthook
);
1620 ListBox_SetItemHeight(child
->left
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1621 ListBox_SetItemHeight(child
->right
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1623 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, child
->left
.cur
);
1624 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
1630 struct ExecuteDialog
{
1631 TCHAR cmd
[MAX_PATH
];
1636 static INT_PTR CALLBACK
ExecuteDialogDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1638 static struct ExecuteDialog
* dlg
;
1642 dlg
= (struct ExecuteDialog
*) lparam
;
1646 int id
= (int)wparam
;
1649 GetWindowText(GetDlgItem(hwnd
, 201), dlg
->cmd
, MAX_PATH
);
1650 dlg
->cmdshow
= Button_GetState(GetDlgItem(hwnd
,214))&BST_CHECKED
?
1651 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
1652 EndDialog(hwnd
, id
);
1653 } else if (id
== IDCANCEL
)
1654 EndDialog(hwnd
, id
);
1662 static INT_PTR CALLBACK
DestinationDlgProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1664 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
1668 SetWindowLong(hwnd
, GWL_USERDATA
, lparam
);
1669 SetWindowText(GetDlgItem(hwnd
, 201), (LPCTSTR
)lparam
);
1673 int id
= (int)wparam
;
1677 LPTSTR dest
= (LPTSTR
) GetWindowLong(hwnd
, GWL_USERDATA
);
1678 GetWindowText(GetDlgItem(hwnd
, 201), dest
, MAX_PATH
);
1679 EndDialog(hwnd
, id
);
1683 EndDialog(hwnd
, id
);
1687 MessageBox(hwnd
, RS(b1
,IDS_NO_IMPL
), RS(b2
,IDS_WINEFILE
), MB_OK
);
1699 #ifndef _NO_EXTENSIONS
1701 static struct FullScreenParameters
{
1711 void frame_get_clientspace(HWND hwnd
, PRECT prect
)
1715 if (!IsIconic(hwnd
))
1716 GetClientRect(hwnd
, prect
);
1720 GetWindowPlacement(hwnd
, &wp
);
1722 prect
->left
= prect
->top
= 0;
1723 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
1724 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
1725 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
1726 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
1727 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
1730 if (IsWindowVisible(Globals
.htoolbar
)) {
1731 GetClientRect(Globals
.htoolbar
, &rt
);
1732 prect
->top
+= rt
.bottom
+2;
1735 if (IsWindowVisible(Globals
.hdrivebar
)) {
1736 GetClientRect(Globals
.hdrivebar
, &rt
);
1737 prect
->top
+= rt
.bottom
+2;
1740 if (IsWindowVisible(Globals
.hstatusbar
)) {
1741 GetClientRect(Globals
.hstatusbar
, &rt
);
1742 prect
->bottom
-= rt
.bottom
;
1746 static BOOL
toggle_fullscreen(HWND hwnd
)
1750 if ((g_fullscreen
.mode
=!g_fullscreen
.mode
)) {
1751 GetWindowRect(hwnd
, &g_fullscreen
.orgPos
);
1752 g_fullscreen
.wasZoomed
= IsZoomed(hwnd
);
1754 Frame_CalcFrameClient(hwnd
, &rt
);
1755 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1756 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1758 rt
.left
= g_fullscreen
.orgPos
.left
-rt
.left
;
1759 rt
.top
= g_fullscreen
.orgPos
.top
-rt
.top
;
1760 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+g_fullscreen
.orgPos
.right
-rt
.right
;
1761 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+g_fullscreen
.orgPos
.bottom
-rt
.bottom
;
1763 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1765 MoveWindow(hwnd
, g_fullscreen
.orgPos
.left
, g_fullscreen
.orgPos
.top
,
1766 g_fullscreen
.orgPos
.right
-g_fullscreen
.orgPos
.left
,
1767 g_fullscreen
.orgPos
.bottom
-g_fullscreen
.orgPos
.top
, TRUE
);
1769 if (g_fullscreen
.wasZoomed
)
1770 ShowWindow(hwnd
, WS_MAXIMIZE
);
1773 return g_fullscreen
.mode
;
1776 static void fullscreen_move(HWND hwnd
)
1779 GetWindowRect(hwnd
, &pos
);
1781 Frame_CalcFrameClient(hwnd
, &rt
);
1782 ClientToScreen(hwnd
, (LPPOINT
)&rt
.left
);
1783 ClientToScreen(hwnd
, (LPPOINT
)&rt
.right
);
1785 rt
.left
= pos
.left
-rt
.left
;
1786 rt
.top
= pos
.top
-rt
.top
;
1787 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
1788 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
1790 MoveWindow(hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
1796 static void toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
)
1798 BOOL vis
= IsWindowVisible(hchild
);
1800 CheckMenuItem(Globals
.hMenuOptions
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
1802 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
1804 #ifndef _NO_EXTENSIONS
1805 if (g_fullscreen
.mode
)
1806 fullscreen_move(hwnd
);
1809 resize_frame_client(hwnd
);
1812 BOOL
activate_drive_window(LPCTSTR path
)
1814 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1817 _tsplitpath(path
, drv1
, 0, 0, 0);
1819 /* search for a already open window for the same drive */
1820 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1821 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1824 _tsplitpath(child
->root
.path
, drv2
, 0, 0, 0);
1826 if (!lstrcmpi(drv2
, drv1
)) {
1827 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1829 if (IsMinimized(child_wnd
))
1830 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1840 BOOL
activate_fs_window(LPCTSTR filesys
)
1844 /* search for a already open window of the given file system name */
1845 for(child_wnd
=GetNextWindow(Globals
.hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1846 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
1849 if (!lstrcmpi(child
->root
.fs
, filesys
)) {
1850 SendMessage(Globals
.hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1852 if (IsMinimized(child_wnd
))
1853 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1863 LRESULT CALLBACK
FrameWndProc(HWND hwnd
, UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1865 TCHAR b1
[BUFFER_LEN
], b2
[BUFFER_LEN
];
1869 DestroyWindow(hwnd
);
1871 /* clear handle variables */
1872 Globals
.hMenuFrame
= 0;
1873 Globals
.hMenuView
= 0;
1874 Globals
.hMenuOptions
= 0;
1875 Globals
.hMainWnd
= 0;
1876 Globals
.hmdiclient
= 0;
1877 Globals
.hdrivebar
= 0;
1881 /* don't exit desktop when closing file manager window */
1882 if (!Globals
.hwndParent
)
1886 case WM_INITMENUPOPUP
: {
1887 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1889 if (!SendMessage(hwndClient
, WM_INITMENUPOPUP
, wparam
, lparam
))
1894 UINT cmd
= LOWORD(wparam
);
1895 HWND hwndClient
= (HWND
) SendMessage(Globals
.hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1897 if (SendMessage(hwndClient
, WM_DISPATCH_COMMAND
, wparam
, lparam
))
1900 if (cmd
>=ID_DRIVE_FIRST
&& cmd
<=ID_DRIVE_FIRST
+0xFF) {
1901 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1903 LPCTSTR root
= Globals
.drives
;
1906 for(i
=cmd
-ID_DRIVE_FIRST
; i
--; root
++)
1910 if (activate_drive_window(root
))
1913 _tsplitpath(root
, drv
, 0, 0, 0);
1915 if (!SetCurrentDirectory(drv
)) {
1916 display_error(hwnd
, GetLastError());
1920 GetCurrentDirectory(MAX_PATH
, path
); /*TODO: store last directory per drive */
1921 child
= alloc_child_window(path
, NULL
, hwnd
);
1923 if (!create_child_window(child
))
1925 } else switch(cmd
) {
1927 SendMessage(hwnd
, WM_CLOSE
, 0, 0);
1930 case ID_WINDOW_NEW
: {
1931 TCHAR path
[MAX_PATH
];
1934 GetCurrentDirectory(MAX_PATH
, path
);
1935 child
= alloc_child_window(path
, NULL
, hwnd
);
1937 if (!create_child_window(child
))
1945 case ID_WINDOW_CASCADE
:
1946 SendMessage(Globals
.hmdiclient
, WM_MDICASCADE
, 0, 0);
1949 case ID_WINDOW_TILE_HORZ
:
1950 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1953 case ID_WINDOW_TILE_VERT
:
1954 SendMessage(Globals
.hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1957 case ID_WINDOW_ARRANGE
:
1958 SendMessage(Globals
.hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1961 case ID_SELECT_FONT
: {
1962 TCHAR dlg_name
[BUFFER_LEN
], dlg_info
[BUFFER_LEN
];
1966 HDC hdc
= GetDC(hwnd
);
1967 chFont
.lStructSize
= sizeof(CHOOSEFONT
);
1968 chFont
.hwndOwner
= hwnd
;
1970 chFont
.lpLogFont
= &lFont
;
1971 chFont
.Flags
= CF_SCREENFONTS
| CF_FORCEFONTEXIST
| CF_LIMITSIZE
| CF_NOSCRIPTSEL
;
1972 chFont
.rgbColors
= RGB(0,0,0);
1973 chFont
.lCustData
= 0;
1974 chFont
.lpfnHook
= NULL
;
1975 chFont
.lpTemplateName
= NULL
;
1976 chFont
.hInstance
= Globals
.hInstance
;
1977 chFont
.lpszStyle
= NULL
;
1978 chFont
.nFontType
= SIMULATED_FONTTYPE
;
1979 chFont
.nSizeMin
= 0;
1980 chFont
.nSizeMax
= 24;
1982 if (ChooseFont(&chFont
)) {
1985 Globals
.hfont
= CreateFontIndirect(&lFont
);
1986 SelectFont(hdc
, Globals
.hfont
);
1987 GetTextExtentPoint32(hdc
, sSpace
, 1, &Globals
.spaceSize
);
1989 /* change font in all open child windows */
1990 for(childWnd
=GetWindow(Globals
.hmdiclient
,GW_CHILD
); childWnd
; childWnd
=GetNextWindow(childWnd
,GW_HWNDNEXT
)) {
1991 ChildWnd
* child
= (ChildWnd
*) GetWindowLong(childWnd
, GWL_USERDATA
);
1992 SetWindowFont(child
->left
.hwnd
, Globals
.hfont
, TRUE
);
1993 SetWindowFont(child
->right
.hwnd
, Globals
.hfont
, TRUE
);
1994 ListBox_SetItemHeight(child
->left
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1995 ListBox_SetItemHeight(child
->right
.hwnd
, 1, max(Globals
.spaceSize
.cy
,IMAGE_HEIGHT
+3));
1996 InvalidateRect(child
->left
.hwnd
, NULL
, TRUE
);
1997 InvalidateRect(child
->right
.hwnd
, NULL
, TRUE
);
2000 else if (CommDlgExtendedError()) {
2001 LoadString(Globals
.hInstance
, IDS_FONT_SEL_DLG_NAME
, dlg_name
, BUFFER_LEN
);
2002 LoadString(Globals
.hInstance
, IDS_FONT_SEL_ERROR
, dlg_info
, BUFFER_LEN
);
2003 MessageBox(hwnd
, dlg_info
, dlg_name
, MB_OK
);
2006 ReleaseDC(hwnd
, hdc
);
2010 case ID_VIEW_TOOL_BAR
:
2011 toggle_child(hwnd
, cmd
, Globals
.htoolbar
);
2014 case ID_VIEW_DRIVE_BAR
:
2015 toggle_child(hwnd
, cmd
, Globals
.hdrivebar
);
2018 case ID_VIEW_STATUSBAR
:
2019 toggle_child(hwnd
, cmd
, Globals
.hstatusbar
);
2023 struct ExecuteDialog dlg
;
2025 memset(&dlg
, 0, sizeof(struct ExecuteDialog
));
2027 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), hwnd
, ExecuteDialogDlgProc
, (LPARAM
)&dlg
) == IDOK
) {
2028 HINSTANCE hinst
= ShellExecute(hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
2030 if ((int)hinst
<= 32)
2031 display_error(hwnd
, GetLastError());
2035 case ID_CONNECT_NETWORK_DRIVE
: {
2036 DWORD ret
= WNetConnectionDialog(hwnd
, RESOURCETYPE_DISK
);
2037 if (ret
== NO_ERROR
)
2039 else if (ret
!= (DWORD
)-1) {
2040 if (ret
== ERROR_EXTENDED_ERROR
)
2041 display_network_error(hwnd
);
2043 display_error(hwnd
, ret
);
2047 case ID_DISCONNECT_NETWORK_DRIVE
: {
2048 DWORD ret
= WNetDisconnectDialog(hwnd
, RESOURCETYPE_DISK
);
2049 if (ret
== NO_ERROR
)
2051 else if (ret
!= (DWORD
)-1) {
2052 if (ret
== ERROR_EXTENDED_ERROR
)
2053 display_network_error(hwnd
);
2055 display_error(hwnd
, ret
);
2059 #ifndef __MINGW32__ /* SHFormatDrive missing in MinGW (as of 13.5.2005) */
2060 case ID_FORMAT_DISK
: {
2061 UINT sem_org
= SetErrorMode(0); /* Get the current Error Mode settings. */
2062 SetErrorMode(sem_org
& ~SEM_FAILCRITICALERRORS
); /* Force O/S to handle */
2063 SHFormatDrive(hwnd
, 0 /* A: */, SHFMT_ID_DEFAULT
, 0);
2064 SetErrorMode(sem_org
); /* Put it back the way it was. */
2069 WinHelp(hwnd
, RS(b1
,IDS_WINEFILE
), HELP_INDEX
, 0);
2072 #ifndef _NO_EXTENSIONS
2073 case ID_VIEW_FULLSCREEN
:
2074 CheckMenuItem(Globals
.hMenuOptions
, cmd
, toggle_fullscreen(hwnd
)?MF_CHECKED
:0);
2078 case ID_DRIVE_UNIX_FS
: {
2079 TCHAR path
[MAX_PATH
];
2081 char cpath
[MAX_PATH
];
2085 if (activate_fs_window(RS(b1
,IDS_UNIXFS
)))
2090 call_getcwd(cpath
, MAX_PATH
);
2091 MultiByteToWideChar(CP_UNIXCP
, 0, cpath
, -1, path
, MAX_PATH
);
2093 call_getcwd(path
, MAX_PATH
);
2095 child
= alloc_child_window(path
, NULL
, hwnd
);
2097 if (!create_child_window(child
))
2102 #ifdef _SHELL_FOLDERS
2103 case ID_DRIVE_SHELL_NS
: {
2104 TCHAR path
[MAX_PATH
];
2107 if (activate_fs_window(RS(b1
,IDS_SHELL
)))
2110 GetCurrentDirectory(MAX_PATH
, path
);
2111 child
= alloc_child_window(path
, get_path_pidl(path
,hwnd
), hwnd
);
2113 if (!create_child_window(child
))
2119 /*TODO: There are even more menu items! */
2121 #ifndef _NO_EXTENSIONS
2124 WineLicense(Globals
.hMainWnd
);
2127 case ID_NO_WARRANTY
:
2128 WineWarranty(Globals
.hMainWnd
);
2133 ShellAbout(hwnd
, RS(b2
,IDS_WINE
), RS(b1
,IDS_WINEFILE
), 0);
2137 ShellAbout(hwnd
, RS(b1
,IDS_WINEFILE
), NULL
, 0);
2139 #endif /* _NO_EXTENSIONS */
2142 /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
2143 STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
2144 else */if ((cmd
<IDW_FIRST_CHILD
|| cmd
>=IDW_FIRST_CHILD
+0x100) &&
2145 (cmd
<SC_SIZE
|| cmd
>SC_RESTORE
))
2146 MessageBox(hwnd
, RS(b2
,IDS_NO_IMPL
), RS(b1
,IDS_WINEFILE
), MB_OK
);
2148 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
2153 resize_frame(hwnd
, LOWORD(lparam
), HIWORD(lparam
));
2154 break; /* do not pass message to DefFrameProc */
2156 #ifndef _NO_EXTENSIONS
2157 case WM_GETMINMAXINFO
: {
2158 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
2160 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
2161 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
2164 case FRM_CALC_CLIENT
:
2165 frame_get_clientspace(hwnd
, (PRECT
)lparam
);
2167 #endif /* _NO_EXTENSIONS */
2170 return DefFrameProc(hwnd
, Globals
.hmdiclient
, nmsg
, wparam
, lparam
);
2177 static TCHAR g_pos_names
[COLUMNS
][20] = {
2181 static const int g_pos_align
[] = {
2183 HDF_LEFT
, /* Name */
2184 HDF_RIGHT
, /* Size */
2185 HDF_LEFT
, /* CDate */
2186 #ifndef _NO_EXTENSIONS
2187 HDF_LEFT
, /* ADate */
2188 HDF_LEFT
, /* MDate */
2189 HDF_LEFT
, /* Index */
2190 HDF_CENTER
, /* Links */
2192 HDF_CENTER
, /* Attributes */
2193 #ifndef _NO_EXTENSIONS
2194 HDF_LEFT
/* Security */
2198 static void resize_tree(ChildWnd
* child
, int cx
, int cy
)
2200 HDWP hdwp
= BeginDeferWindowPos(4);
2208 cx
= child
->split_pos
+ SPLIT_WIDTH
/2;
2210 #ifndef _NO_EXTENSIONS
2218 Header_Layout(child
->left
.hwndHeader
, &hdl
);
2220 DeferWindowPos(hdwp
, child
->left
.hwndHeader
, wp
.hwndInsertAfter
,
2221 wp
.x
-1, wp
.y
, child
->split_pos
-SPLIT_WIDTH
/2+1, wp
.cy
, wp
.flags
);
2222 DeferWindowPos(hdwp
, child
->right
.hwndHeader
, wp
.hwndInsertAfter
,
2223 rt
.left
+cx
+1, wp
.y
, wp
.cx
-cx
+2, wp
.cy
, wp
.flags
);
2225 #endif /* _NO_EXTENSIONS */
2227 DeferWindowPos(hdwp
, child
->left
.hwnd
, 0, rt
.left
, rt
.top
, child
->split_pos
-SPLIT_WIDTH
/2-rt
.left
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
2228 DeferWindowPos(hdwp
, child
->right
.hwnd
, 0, rt
.left
+cx
+1, rt
.top
, rt
.right
-cx
, rt
.bottom
-rt
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
2230 EndDeferWindowPos(hdwp
);
2234 #ifndef _NO_EXTENSIONS
2236 static HWND
create_header(HWND parent
, Pane
* pane
, int id
)
2241 HWND hwnd
= CreateWindow(WC_HEADER
, 0, WS_CHILD
|WS_VISIBLE
|HDS_HORZ
/*TODO: |HDS_BUTTONS + sort orders*/,
2242 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2246 SetWindowFont(hwnd
, GetStockObject(DEFAULT_GUI_FONT
), FALSE
);
2248 hdi
.mask
= HDI_TEXT
|HDI_WIDTH
|HDI_FORMAT
;
2250 for(idx
=0; idx
<COLUMNS
; idx
++) {
2251 hdi
.pszText
= g_pos_names
[idx
];
2252 hdi
.fmt
= HDF_STRING
| g_pos_align
[idx
];
2253 hdi
.cxy
= pane
->widths
[idx
];
2254 Header_InsertItem(hwnd
, idx
, &hdi
);
2260 #endif /* _NO_EXTENSIONS */
2263 static void init_output(HWND hwnd
)
2265 const static TCHAR s1000
[] = {'1','0','0','0','\0'};
2269 HDC hdc
= GetDC(hwnd
);
2271 if (GetNumberFormat(LOCALE_USER_DEFAULT
, 0, s1000
, 0, b
, 16) > 4)
2272 Globals
.num_sep
= b
[1];
2274 Globals
.num_sep
= TEXT('.');
2276 old_font
= SelectFont(hdc
, Globals
.hfont
);
2277 GetTextExtentPoint32(hdc
, sSpace
, 1, &Globals
.spaceSize
);
2278 SelectFont(hdc
, old_font
);
2279 ReleaseDC(hwnd
, hdc
);
2282 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
);
2285 /* calculate preferred width for all visible columns */
2287 static BOOL
calc_widths(Pane
* pane
, BOOL anyway
)
2289 int col
, x
, cx
, spc
=3*Globals
.spaceSize
.cx
;
2290 int entries
= ListBox_GetCount(pane
->hwnd
);
2291 int orgWidths
[COLUMNS
];
2292 int orgPositions
[COLUMNS
+1];
2298 memcpy(orgWidths
, pane
->widths
, sizeof(orgWidths
));
2299 memcpy(orgPositions
, pane
->positions
, sizeof(orgPositions
));
2302 for(col
=0; col
<COLUMNS
; col
++)
2303 pane
->widths
[col
] = 0;
2305 hdc
= GetDC(pane
->hwnd
);
2306 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2308 for(cnt
=0; cnt
<entries
; cnt
++) {
2309 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2318 dis
.hwndItem
= pane
->hwnd
;
2320 dis
.rcItem
.left
= 0;
2322 dis
.rcItem
.right
= 0;
2323 dis
.rcItem
.bottom
= 0;
2324 /*dis.itemData = 0; */
2326 draw_item(pane
, &dis
, entry
, COLUMNS
);
2329 SelectObject(hdc
, hfontOld
);
2330 ReleaseDC(pane
->hwnd
, hdc
);
2333 for(col
=0; col
<COLUMNS
; col
++) {
2334 pane
->positions
[col
] = x
;
2335 cx
= pane
->widths
[col
];
2340 if (cx
< IMAGE_WIDTH
)
2343 pane
->widths
[col
] = cx
;
2349 pane
->positions
[COLUMNS
] = x
;
2351 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2354 if (!memcmp(orgWidths
, pane
->widths
, sizeof(orgWidths
)))
2357 /* don't move, if only collapsing an entry */
2358 if (!anyway
&& pane
->widths
[0]<orgWidths
[0] &&
2359 !memcmp(orgWidths
+1, pane
->widths
+1, sizeof(orgWidths
)-sizeof(int))) {
2360 pane
->widths
[0] = orgWidths
[0];
2361 memcpy(pane
->positions
, orgPositions
, sizeof(orgPositions
));
2366 InvalidateRect(pane
->hwnd
, 0, TRUE
);
2372 /* calculate one preferred column width */
2374 static void calc_single_width(Pane
* pane
, int col
)
2378 int entries
= ListBox_GetCount(pane
->hwnd
);
2382 pane
->widths
[col
] = 0;
2384 hdc
= GetDC(pane
->hwnd
);
2385 hfontOld
= SelectFont(hdc
, Globals
.hfont
);
2387 for(cnt
=0; cnt
<entries
; cnt
++) {
2388 Entry
* entry
= (Entry
*) ListBox_GetItemData(pane
->hwnd
, cnt
);
2396 dis
.hwndItem
= pane
->hwnd
;
2398 dis
.rcItem
.left
= 0;
2400 dis
.rcItem
.right
= 0;
2401 dis
.rcItem
.bottom
= 0;
2402 /*dis.itemData = 0; */
2404 draw_item(pane
, &dis
, entry
, col
);
2407 SelectObject(hdc
, hfontOld
);
2408 ReleaseDC(pane
->hwnd
, hdc
);
2410 cx
= pane
->widths
[col
];
2413 cx
+= 3*Globals
.spaceSize
.cx
;
2415 if (cx
< IMAGE_WIDTH
)
2419 pane
->widths
[col
] = cx
;
2421 x
= pane
->positions
[col
] + cx
;
2423 for(; col
<COLUMNS
; ) {
2424 pane
->positions
[++col
] = x
;
2425 x
+= pane
->widths
[col
];
2428 ListBox_SetHorizontalExtent(pane
->hwnd
, x
);
2432 /* insert listbox entries after index idx */
2434 static int insert_entries(Pane
* pane
, Entry
* dir
, int idx
)
2441 ShowWindow(pane
->hwnd
, SW_HIDE
);
2443 for(; entry
; entry
=entry
->next
) {
2445 if (pane
->treePane
&& !(entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
2449 /* don't display entries "." and ".." in the left pane */
2450 if (pane
->treePane
&& (entry
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2451 && entry
->data
.cFileName
[0]==TEXT('.'))
2453 #ifndef _NO_EXTENSIONS
2454 entry
->data
.cFileName
[1]==TEXT('\0') ||
2456 (entry
->data
.cFileName
[1]==TEXT('.') && entry
->data
.cFileName
[2]==TEXT('\0')))
2462 ListBox_InsertItemData(pane
->hwnd
, idx
, entry
);
2464 if (pane
->treePane
&& entry
->expanded
)
2465 idx
= insert_entries(pane
, entry
->down
, idx
);
2468 ShowWindow(pane
->hwnd
, SW_SHOW
);
2474 static void format_bytes(LPTSTR buffer
, LONGLONG bytes
)
2476 const static TCHAR sFmtGB
[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'};
2477 const static TCHAR sFmtMB
[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'};
2478 const static TCHAR sFmtkB
[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'};
2480 float fBytes
= (float)bytes
;
2482 if (bytes
>= 1073741824) /* 1 GB */
2483 _stprintf(buffer
, sFmtGB
, fBytes
/1073741824.f
+.5f
);
2484 else if (bytes
>= 1048576) /* 1 MB */
2485 _stprintf(buffer
, sFmtMB
, fBytes
/1048576.f
+.5f
);
2486 else if (bytes
>= 1024) /* 1 kB */
2487 _stprintf(buffer
, sFmtkB
, fBytes
/1024.f
+.5f
);
2489 _stprintf(buffer
, sLongNumFmt
, bytes
);
2492 static void set_space_status()
2494 ULARGE_INTEGER ulFreeBytesToCaller
, ulTotalBytes
, ulFreeBytes
;
2495 TCHAR fmt
[64], b1
[64], b2
[64], buffer
[BUFFER_LEN
];
2497 if (GetDiskFreeSpaceEx(NULL
, &ulFreeBytesToCaller
, &ulTotalBytes
, &ulFreeBytes
)) {
2498 format_bytes(b1
, ulFreeBytesToCaller
.QuadPart
);
2499 format_bytes(b2
, ulTotalBytes
.QuadPart
);
2500 _stprintf(buffer
, RS(fmt
,IDS_FREE_SPACE_FMT
), b1
, b2
);
2502 _tcscpy(buffer
, sQMarks
);
2504 SendMessage(Globals
.hstatusbar
, SB_SETTEXT
, 0, (LPARAM
)buffer
);
2508 static WNDPROC g_orgTreeWndProc
;
2510 static void create_tree_window(HWND parent
, Pane
* pane
, int id
, int id_header
)
2512 const static TCHAR sListBox
[] = {'L','i','s','t','B','o','x','\0'};
2514 static int s_init
= 0;
2515 Entry
* entry
= pane
->root
;
2517 pane
->hwnd
= CreateWindow(sListBox
, sEmpty
, WS_CHILD
|WS_VISIBLE
|WS_HSCROLL
|WS_VSCROLL
|
2518 LBS_DISABLENOSCROLL
|LBS_NOINTEGRALHEIGHT
|LBS_OWNERDRAWFIXED
|LBS_NOTIFY
,
2519 0, 0, 0, 0, parent
, (HMENU
)id
, Globals
.hInstance
, 0);
2521 SetWindowLong(pane
->hwnd
, GWL_USERDATA
, (LPARAM
)pane
);
2522 g_orgTreeWndProc
= SubclassWindow(pane
->hwnd
, TreeWndProc
);
2524 SetWindowFont(pane
->hwnd
, Globals
.hfont
, FALSE
);
2526 /* insert entries into listbox */
2528 insert_entries(pane
, entry
, -1);
2530 /* calculate column widths */
2533 init_output(pane
->hwnd
);
2536 calc_widths(pane
, TRUE
);
2538 #ifndef _NO_EXTENSIONS
2539 pane
->hwndHeader
= create_header(parent
, pane
, id_header
);
2544 static void InitChildWindow(ChildWnd
* child
)
2546 create_tree_window(child
->hwnd
, &child
->left
, IDW_TREE_LEFT
, IDW_HEADER_LEFT
);
2547 create_tree_window(child
->hwnd
, &child
->right
, IDW_TREE_RIGHT
, IDW_HEADER_RIGHT
);
2551 static void format_date(const FILETIME
* ft
, TCHAR
* buffer
, int visible_cols
)
2557 *buffer
= TEXT('\0');
2559 if (!ft
->dwLowDateTime
&& !ft
->dwHighDateTime
)
2562 if (!FileTimeToLocalFileTime(ft
, &lft
))
2563 {err
: _tcscpy(buffer
,sQMarks
); return;}
2565 if (!FileTimeToSystemTime(&lft
, &systime
))
2568 if (visible_cols
& COL_DATE
) {
2569 len
= GetDateFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
, BUFFER_LEN
);
2574 if (visible_cols
& COL_TIME
) {
2576 buffer
[len
-1] = ' ';
2578 buffer
[len
++] = ' ';
2580 if (!GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &systime
, 0, buffer
+len
, BUFFER_LEN
-len
))
2581 buffer
[len
] = TEXT('\0');
2586 static void calc_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2588 RECT rt
= {0, 0, 0, 0};
2590 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2592 if (rt
.right
> pane
->widths
[col
])
2593 pane
->widths
[col
] = rt
.right
;
2596 static void calc_tabbed_width(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2598 RECT rt
= {0, 0, 0, 0};
2600 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2601 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2603 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2604 /*FIXME rt (0,0) ??? */
2606 if (rt
.right
> pane
->widths
[col
])
2607 pane
->widths
[col
] = rt
.right
;
2611 static void output_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
, DWORD flags
)
2613 int x
= dis
->rcItem
.left
;
2616 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2617 rt
.top
= dis
->rcItem
.top
;
2618 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2619 rt
.bottom
= dis
->rcItem
.bottom
;
2621 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_NOPREFIX
|flags
);
2624 static void output_tabbed_text(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2626 int x
= dis
->rcItem
.left
;
2629 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2630 rt
.top
= dis
->rcItem
.top
;
2631 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2632 rt
.bottom
= dis
->rcItem
.bottom
;
2634 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
2635 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
2637 DrawText(dis
->hDC
, (LPTSTR
)str
, -1, &rt
, DT_SINGLELINE
|DT_EXPANDTABS
|DT_TABSTOP
|(2<<8));
2640 static void output_number(Pane
* pane
, LPDRAWITEMSTRUCT dis
, int col
, LPCTSTR str
)
2642 int x
= dis
->rcItem
.left
;
2649 rt
.left
= x
+pane
->positions
[col
]+Globals
.spaceSize
.cx
;
2650 rt
.top
= dis
->rcItem
.top
;
2651 rt
.right
= x
+pane
->positions
[col
+1]-Globals
.spaceSize
.cx
;
2652 rt
.bottom
= dis
->rcItem
.bottom
;
2657 /* insert number separator characters */
2658 pos
= lstrlen(s
) % 3;
2664 *d
++ = Globals
.num_sep
;
2668 DrawText(dis
->hDC
, b
, d
-b
, &rt
, DT_RIGHT
|DT_SINGLELINE
|DT_NOPREFIX
|DT_END_ELLIPSIS
);
2672 static int is_exe_file(LPCTSTR ext
)
2674 static const TCHAR executable_extensions
[][4] = {
2679 #ifndef _NO_EXTENSIONS
2683 #endif /* _NO_EXTENSIONS */
2687 TCHAR ext_buffer
[_MAX_EXT
];
2688 const TCHAR (*p
)[4];
2692 for(s
=ext
+1,d
=ext_buffer
; (*d
=tolower(*s
)); s
++)
2695 for(p
=executable_extensions
; (*p
)[0]; p
++)
2696 if (!_tcscmp(ext_buffer
, *p
))
2702 static int is_registered_type(LPCTSTR ext
)
2710 static void draw_item(Pane
* pane
, LPDRAWITEMSTRUCT dis
, Entry
* entry
, int calcWidthCol
)
2712 TCHAR buffer
[BUFFER_LEN
];
2714 int visible_cols
= pane
->visible_cols
;
2715 COLORREF bkcolor
, textcolor
;
2716 RECT focusRect
= dis
->rcItem
;
2723 attrs
= entry
->data
.dwFileAttributes
;
2725 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) {
2726 if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('.')
2727 && entry
->data
.cFileName
[2]==TEXT('\0'))
2728 img
= IMG_FOLDER_UP
;
2729 #ifndef _NO_EXTENSIONS
2730 else if (entry
->data
.cFileName
[0]==TEXT('.') && entry
->data
.cFileName
[1]==TEXT('\0'))
2731 img
= IMG_FOLDER_CUR
;
2734 #ifdef _NO_EXTENSIONS
2737 (pane
->treePane
&& (dis
->itemState
&ODS_FOCUS
)))
2738 img
= IMG_OPEN_FOLDER
;
2742 LPCTSTR ext
= _tcsrchr(entry
->data
.cFileName
, '.');
2746 if (is_exe_file(ext
))
2747 img
= IMG_EXECUTABLE
;
2748 else if (is_registered_type(ext
))
2758 if (pane
->treePane
) {
2760 img_pos
= dis
->rcItem
.left
+ entry
->level
*(IMAGE_WIDTH
+TREE_LINE_DX
);
2762 if (calcWidthCol
== -1) {
2764 int y
= dis
->rcItem
.top
+ IMAGE_HEIGHT
/2;
2767 HRGN hrgn_org
= CreateRectRgn(0, 0, 0, 0);
2770 rt_clip
.left
= dis
->rcItem
.left
;
2771 rt_clip
.top
= dis
->rcItem
.top
;
2772 rt_clip
.right
= dis
->rcItem
.left
+pane
->widths
[col
];
2773 rt_clip
.bottom
= dis
->rcItem
.bottom
;
2775 hrgn
= CreateRectRgnIndirect(&rt_clip
);
2777 if (!GetClipRgn(dis
->hDC
, hrgn_org
)) {
2778 DeleteObject(hrgn_org
);
2782 /* HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN)); */
2783 ExtSelectClipRgn(dis
->hDC
, hrgn
, RGN_AND
);
2786 if ((up
=entry
->up
) != NULL
) {
2787 MoveToEx(dis
->hDC
, img_pos
-IMAGE_WIDTH
/2, y
, 0);
2788 LineTo(dis
->hDC
, img_pos
-2, y
);
2790 x
= img_pos
- IMAGE_WIDTH
/2;
2793 x
-= IMAGE_WIDTH
+TREE_LINE_DX
;
2797 && (up
->next
->data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
2800 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2801 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2803 } while((up
=up
->up
) != NULL
);
2806 x
= img_pos
- IMAGE_WIDTH
/2;
2808 MoveToEx(dis
->hDC
, x
, dis
->rcItem
.top
, 0);
2809 LineTo(dis
->hDC
, x
, y
);
2813 && (entry
->next
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
)
2816 LineTo(dis
->hDC
, x
, dis
->rcItem
.bottom
);
2818 if (entry->down && entry->expanded) {
2819 x += IMAGE_WIDTH+TREE_LINE_DX;
2820 MoveToEx(dis->hDC, x, dis->rcItem.top+IMAGE_HEIGHT, 0);
2821 LineTo(dis->hDC, x, dis->rcItem.bottom);
2824 SelectClipRgn(dis
->hDC
, hrgn_org
);
2825 if (hrgn_org
) DeleteObject(hrgn_org
);
2826 /* SelectObject(dis->hDC, holdPen); */
2827 } else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
) {
2828 int right
= img_pos
+ IMAGE_WIDTH
- TREE_LINE_DX
;
2830 if (right
> pane
->widths
[col
])
2831 pane
->widths
[col
] = right
;
2834 img_pos
= dis
->rcItem
.left
;
2837 img_pos
= dis
->rcItem
.left
;
2839 if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2840 pane
->widths
[col
] = IMAGE_WIDTH
;
2843 if (calcWidthCol
== -1) {
2844 focusRect
.left
= img_pos
- 2;
2846 #ifdef _NO_EXTENSIONS
2847 if (pane
->treePane
&& entry
) {
2850 DrawText(dis
->hDC
, entry
->data
.cFileName
, -1, &rt
, DT_CALCRECT
|DT_SINGLELINE
|DT_NOPREFIX
);
2852 focusRect
.right
= dis
->rcItem
.left
+pane
->positions
[col
+1]+TREE_LINE_DX
+ rt
.right
+2;
2856 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
)
2857 textcolor
= COLOR_COMPRESSED
;
2859 #endif /* _NO_EXTENSIONS */
2860 textcolor
= RGB(0,0,0);
2862 if (dis
->itemState
& ODS_FOCUS
) {
2863 textcolor
= RGB(255,255,255);
2864 bkcolor
= COLOR_SELECTION
;
2866 bkcolor
= RGB(255,255,255);
2869 hbrush
= CreateSolidBrush(bkcolor
);
2870 FillRect(dis
->hDC
, &focusRect
, hbrush
);
2871 DeleteObject(hbrush
);
2873 SetBkMode(dis
->hDC
, TRANSPARENT
);
2874 SetTextColor(dis
->hDC
, textcolor
);
2876 cx
= pane
->widths
[col
];
2878 if (cx
&& img
!=IMG_NONE
) {
2879 if (cx
> IMAGE_WIDTH
)
2882 #ifdef _SHELL_FOLDERS
2883 if (entry
->hicon
&& entry
->hicon
!=(HICON
)-1)
2884 DrawIconEx(dis
->hDC
, img_pos
, dis
->rcItem
.top
, entry
->hicon
, cx
, GetSystemMetrics(SM_CYSMICON
), 0, 0, DI_NORMAL
);
2887 ImageList_DrawEx(Globals
.himl
, img
, dis
->hDC
,
2888 img_pos
, dis
->rcItem
.top
, cx
,
2889 IMAGE_HEIGHT
, bkcolor
, CLR_DEFAULT
, ILD_NORMAL
);
2896 #ifdef _NO_EXTENSIONS
2897 if (img
>= IMG_FOLDER_UP
)
2903 /* ouput file name */
2904 if (calcWidthCol
== -1)
2905 output_text(pane
, dis
, col
, entry
->data
.cFileName
, 0);
2906 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2907 calc_width(pane
, dis
, col
, entry
->data
.cFileName
);
2911 #ifdef _NO_EXTENSIONS
2912 if (!pane
->treePane
) {
2915 /* display file size */
2916 if (visible_cols
& COL_SIZE
) {
2917 #ifdef _NO_EXTENSIONS
2918 if (!(attrs
&FILE_ATTRIBUTE_DIRECTORY
))
2923 size
= ((ULONGLONG
)entry
->data
.nFileSizeHigh
<< 32) | entry
->data
.nFileSizeLow
;
2925 _stprintf(buffer
, sLongNumFmt
, size
);
2927 if (calcWidthCol
== -1)
2928 output_number(pane
, dis
, col
, buffer
);
2929 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2930 calc_width(pane
, dis
, col
, buffer
);/*TODO: not in every case time enough */
2936 /* display file date */
2937 if (visible_cols
& (COL_DATE
|COL_TIME
)) {
2938 #ifndef _NO_EXTENSIONS
2939 format_date(&entry
->data
.ftCreationTime
, buffer
, visible_cols
);
2940 if (calcWidthCol
== -1)
2941 output_text(pane
, dis
, col
, buffer
, 0);
2942 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2943 calc_width(pane
, dis
, col
, buffer
);
2946 format_date(&entry
->data
.ftLastAccessTime
, buffer
, visible_cols
);
2947 if (calcWidthCol
== -1)
2948 output_text(pane
, dis
, col
, buffer
, 0);
2949 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2950 calc_width(pane
, dis
, col
, buffer
);
2952 #endif /* _NO_EXTENSIONS */
2954 format_date(&entry
->data
.ftLastWriteTime
, buffer
, visible_cols
);
2955 if (calcWidthCol
== -1)
2956 output_text(pane
, dis
, col
, buffer
, 0);
2957 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2958 calc_width(pane
, dis
, col
, buffer
);
2962 #ifndef _NO_EXTENSIONS
2963 if (entry
->bhfi_valid
) {
2964 ULONGLONG index
= ((ULONGLONG
)entry
->bhfi
.nFileIndexHigh
<< 32) | entry
->bhfi
.nFileIndexLow
;
2966 if (visible_cols
& COL_INDEX
) {
2967 _stprintf(buffer
, sLongHexFmt
, index
);
2969 if (calcWidthCol
== -1)
2970 output_text(pane
, dis
, col
, buffer
, DT_RIGHT
);
2971 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2972 calc_width(pane
, dis
, col
, buffer
);
2977 if (visible_cols
& COL_LINKS
) {
2978 wsprintf(buffer
, sNumFmt
, entry
->bhfi
.nNumberOfLinks
);
2980 if (calcWidthCol
== -1)
2981 output_text(pane
, dis
, col
, buffer
, DT_CENTER
);
2982 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
2983 calc_width(pane
, dis
, col
, buffer
);
2989 #endif /* _NO_EXTENSIONS */
2991 /* show file attributes */
2992 if (visible_cols
& COL_ATTRIBUTES
) {
2993 #ifdef _NO_EXTENSIONS
2994 const static TCHAR s4Tabs
[] = {' ','\t',' ','\t',' ','\t',' ','\t',' ','\0'};
2995 _tcscpy(buffer
, s4Tabs
);
2997 const static TCHAR s11Tabs
[] = {' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\t',' ','\0'};
2998 _tcscpy(buffer
, s11Tabs
);
3001 if (attrs
& FILE_ATTRIBUTE_NORMAL
) buffer
[ 0] = 'N';
3003 if (attrs
& FILE_ATTRIBUTE_READONLY
) buffer
[ 2] = 'R';
3004 if (attrs
& FILE_ATTRIBUTE_HIDDEN
) buffer
[ 4] = 'H';
3005 if (attrs
& FILE_ATTRIBUTE_SYSTEM
) buffer
[ 6] = 'S';
3006 if (attrs
& FILE_ATTRIBUTE_ARCHIVE
) buffer
[ 8] = 'A';
3007 if (attrs
& FILE_ATTRIBUTE_COMPRESSED
) buffer
[10] = 'C';
3008 #ifndef _NO_EXTENSIONS
3009 if (attrs
& FILE_ATTRIBUTE_DIRECTORY
) buffer
[12] = 'D';
3010 if (attrs
& FILE_ATTRIBUTE_ENCRYPTED
) buffer
[14] = 'E';
3011 if (attrs
& FILE_ATTRIBUTE_TEMPORARY
) buffer
[16] = 'T';
3012 if (attrs
& FILE_ATTRIBUTE_SPARSE_FILE
) buffer
[18] = 'P';
3013 if (attrs
& FILE_ATTRIBUTE_REPARSE_POINT
) buffer
[20] = 'Q';
3014 if (attrs
& FILE_ATTRIBUTE_OFFLINE
) buffer
[22] = 'O';
3015 if (attrs
& FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
) buffer
[24] = 'X';
3016 #endif /* _NO_EXTENSIONS */
3019 if (calcWidthCol
== -1)
3020 output_tabbed_text(pane
, dis
, col
, buffer
);
3021 else if (calcWidthCol
==col
|| calcWidthCol
==COLUMNS
)
3022 calc_tabbed_width(pane
, dis
, col
, buffer
);
3028 if (flags.security) {
3029 const static TCHAR sSecTabs[] = {
3030 ' ','\t',' ','\t',' ','\t',' ',
3032 ' ','\t',' ','\t',' ','\t',' ',
3034 ' ','\t',' ','\t',' ','\t',' ',
3038 DWORD rights = get_access_mask();
3040 tcscpy(buffer, sSecTabs);
3042 if (rights & FILE_READ_DATA) buffer[ 0] = 'R';
3043 if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W';
3044 if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A';
3045 if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';}
3046 if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';}
3047 if (rights & FILE_EXECUTE) buffer[12] = 'X';
3048 if (rights & FILE_DELETE_CHILD) buffer[14] = 'D';
3049 if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';}
3050 if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';}
3051 if (rights & WRITE_DAC) buffer[22] = 'C';
3052 if (rights & WRITE_OWNER) buffer[24] = 'O';
3053 if (rights & SYNCHRONIZE) buffer[26] = 'S';
3055 output_text(dis, col++, buffer, DT_LEFT, 3, psize);
3058 if (flags.description) {
3059 get_description(buffer);
3060 output_text(dis, col++, buffer, 0, psize);
3064 #ifdef _NO_EXTENSIONS
3067 /* draw focus frame */
3068 if ((dis
->itemState
&ODS_FOCUS
) && calcWidthCol
==-1) {
3069 /* Currently [04/2000] Wine neither behaves exactly the same */
3070 /* way as WIN 95 nor like Windows NT... */
3075 if (!(GetVersion() & 0x80000000)) { /* Windows NT? */
3076 LOGBRUSH lb
= {PS_SOLID
, RGB(255,255,255)};
3077 hpen
= ExtCreatePen(PS_COSMETIC
|PS_ALTERNATE
, 1, &lb
, 0, 0);
3079 hpen
= CreatePen(PS_DOT
, 0, RGB(255,255,255));
3081 lastPen
= SelectPen(dis
->hDC
, hpen
);
3082 lastBrush
= SelectObject(dis
->hDC
, GetStockObject(HOLLOW_BRUSH
));
3083 SetROP2(dis
->hDC
, R2_XORPEN
);
3084 Rectangle(dis
->hDC
, focusRect
.left
, focusRect
.top
, focusRect
.right
, focusRect
.bottom
);
3085 SelectObject(dis
->hDC
, lastBrush
);
3086 SelectObject(dis
->hDC
, lastPen
);
3089 #endif /* _NO_EXTENSIONS */
3093 #ifdef _NO_EXTENSIONS
3095 static void draw_splitbar(HWND hwnd
, int x
)
3098 HDC hdc
= GetDC(hwnd
);
3100 GetClientRect(hwnd
, &rt
);
3102 rt
.left
= x
- SPLIT_WIDTH
/2;
3103 rt
.right
= x
+ SPLIT_WIDTH
/2+1;
3105 InvertRect(hdc
, &rt
);
3107 ReleaseDC(hwnd
, hdc
);
3110 #endif /* _NO_EXTENSIONS */
3113 #ifndef _NO_EXTENSIONS
3115 static void set_header(Pane
* pane
)
3118 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
3121 item
.mask
= HDI_WIDTH
;
3124 for(; x
+pane
->widths
[i
]<scroll_pos
&& i
<COLUMNS
; i
++) {
3125 x
+= pane
->widths
[i
];
3126 Header_SetItem(pane
->hwndHeader
, i
, &item
);
3130 x
+= pane
->widths
[i
];
3131 item
.cxy
= x
- scroll_pos
;
3132 Header_SetItem(pane
->hwndHeader
, i
++, &item
);
3134 for(; i
<COLUMNS
; i
++) {
3135 item
.cxy
= pane
->widths
[i
];
3136 x
+= pane
->widths
[i
];
3137 Header_SetItem(pane
->hwndHeader
, i
, &item
);
3142 static LRESULT
pane_notify(Pane
* pane
, NMHDR
* pnmh
)
3144 switch(pnmh
->code
) {
3146 case HDN_ENDTRACK
: {
3147 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
3148 int idx
= phdn
->iItem
;
3149 int dx
= phdn
->pitem
->cxy
- pane
->widths
[idx
];
3153 GetClientRect(pane
->hwnd
, &clnt
);
3155 /* move immediate to simulate HDS_FULLDRAG (for now [04/2000] not really needed with WINELIB) */
3156 Header_SetItem(pane
->hwndHeader
, idx
, phdn
->pitem
);
3158 pane
->widths
[idx
] += dx
;
3160 for(i
=idx
; ++i
<=COLUMNS
; )
3161 pane
->positions
[i
] += dx
;
3164 int scroll_pos
= GetScrollPos(pane
->hwnd
, SB_HORZ
);
3168 rt_scr
.left
= pane
->positions
[idx
+1]-scroll_pos
;
3170 rt_scr
.right
= clnt
.right
;
3171 rt_scr
.bottom
= clnt
.bottom
;
3173 rt_clip
.left
= pane
->positions
[idx
]-scroll_pos
;
3175 rt_clip
.right
= clnt
.right
;
3176 rt_clip
.bottom
= clnt
.bottom
;
3178 if (rt_scr
.left
< 0) rt_scr
.left
= 0;
3179 if (rt_clip
.left
< 0) rt_clip
.left
= 0;
3181 ScrollWindowEx(pane
->hwnd
, dx
, 0, &rt_scr
, &rt_clip
, 0, 0, SW_INVALIDATE
);
3183 rt_clip
.right
= pane
->positions
[idx
+1];
3184 RedrawWindow(pane
->hwnd
, &rt_clip
, 0, RDW_INVALIDATE
|RDW_UPDATENOW
);
3186 if (pnmh
->code
== HDN_ENDTRACK
) {
3187 ListBox_SetHorizontalExtent(pane
->hwnd
, pane
->positions
[COLUMNS
]);
3189 if (GetScrollPos(pane
->hwnd
, SB_HORZ
) != scroll_pos
)
3197 case HDN_DIVIDERDBLCLICK
: {
3198 HD_NOTIFY
* phdn
= (HD_NOTIFY
*) pnmh
;
3201 calc_single_width(pane
, phdn
->iItem
);
3202 item
.mask
= HDI_WIDTH
;
3203 item
.cxy
= pane
->widths
[phdn
->iItem
];
3205 Header_SetItem(pane
->hwndHeader
, phdn
->iItem
, &item
);
3206 InvalidateRect(pane
->hwnd
, 0, TRUE
);
3213 #endif /* _NO_EXTENSIONS */
3216 static void scan_entry(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
)
3218 TCHAR path
[MAX_PATH
];
3219 HCURSOR old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
3221 /* delete sub entries in left pane */
3223 LRESULT res
= ListBox_GetItemData(child
->left
.hwnd
, idx
+1);
3224 Entry
* sub
= (Entry
*) res
;
3226 if (res
==LB_ERR
|| !sub
|| sub
->level
<=entry
->level
)
3229 ListBox_DeleteString(child
->left
.hwnd
, idx
+1);
3232 /* empty right pane */
3233 ListBox_ResetContent(child
->right
.hwnd
);
3235 /* release memory */
3236 free_entries(entry
);
3238 /* read contents from disk */
3239 #ifdef _SHELL_FOLDERS
3240 if (entry
->etype
== ET_SHELL
)
3242 read_directory(entry
, NULL
, child
->sortOrder
, hwnd
);
3247 get_path(entry
, path
);
3248 read_directory(entry
, path
, child
->sortOrder
, hwnd
);
3251 /* insert found entries in right pane */
3252 insert_entries(&child
->right
, entry
->down
, -1);
3253 calc_widths(&child
->right
, FALSE
);
3254 #ifndef _NO_EXTENSIONS
3255 set_header(&child
->right
);
3258 child
->header_wdths_ok
= FALSE
;
3260 SetCursor(old_cursor
);
3264 /* expand a directory entry */
3266 static BOOL
expand_entry(ChildWnd
* child
, Entry
* dir
)
3271 if (!dir
|| dir
->expanded
|| !dir
->down
)
3276 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='\0' && p
->next
) {
3279 if (p
->data
.cFileName
[0]=='.' && p
->data
.cFileName
[1]=='.' &&
3280 p
->data
.cFileName
[2]=='\0' && p
->next
)
3284 /* no subdirectories ? */
3285 if (!(p
->data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
))
3288 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, dir
);
3290 dir
->expanded
= TRUE
;
3292 /* insert entries in left pane */
3293 insert_entries(&child
->left
, p
, idx
);
3295 if (!child
->header_wdths_ok
) {
3296 if (calc_widths(&child
->left
, FALSE
)) {
3297 #ifndef _NO_EXTENSIONS
3298 set_header(&child
->left
);
3301 child
->header_wdths_ok
= TRUE
;
3309 static void collapse_entry(Pane
* pane
, Entry
* dir
)
3311 int idx
= ListBox_FindItemData(pane
->hwnd
, 0, dir
);
3313 ShowWindow(pane
->hwnd
, SW_HIDE
);
3315 /* hide sub entries */
3317 LRESULT res
= ListBox_GetItemData(pane
->hwnd
, idx
+1);
3318 Entry
* sub
= (Entry
*) res
;
3320 if (res
==LB_ERR
|| !sub
|| sub
->level
<=dir
->level
)
3323 ListBox_DeleteString(pane
->hwnd
, idx
+1);
3326 dir
->expanded
= FALSE
;
3328 ShowWindow(pane
->hwnd
, SW_SHOW
);
3332 static void set_curdir(ChildWnd
* child
, Entry
* entry
, int idx
, HWND hwnd
)
3334 TCHAR path
[MAX_PATH
];
3338 child
->left
.cur
= entry
;
3339 child
->right
.root
= entry
->down
? entry
->down
: entry
;
3340 child
->right
.cur
= entry
;
3342 if (!entry
->scanned
)
3343 scan_entry(child
, entry
, idx
, hwnd
);
3345 ListBox_ResetContent(child
->right
.hwnd
);
3346 insert_entries(&child
->right
, entry
->down
, -1);
3347 calc_widths(&child
->right
, FALSE
);
3348 #ifndef _NO_EXTENSIONS
3349 set_header(&child
->right
);
3353 get_path(entry
, path
);
3354 lstrcpy(child
->path
, path
);
3356 if (child
->hwnd
) /* only change window title, if the window already exists */
3357 SetWindowText(child
->hwnd
, path
);
3360 if (SetCurrentDirectory(path
))
3365 static void refresh_child(ChildWnd
* child
)
3367 TCHAR path
[MAX_PATH
], drv
[_MAX_DRIVE
+1];
3371 get_path(child
->left
.cur
, path
);
3372 _tsplitpath(path
, drv
, NULL
, NULL
, NULL
);
3374 child
->right
.root
= NULL
;
3376 scan_entry(child
, &child
->root
.entry
, 0, child
->hwnd
);
3378 #ifdef _SHELL_FOLDERS
3379 if (child
->root
.entry
.etype
== ET_SHELL
)
3380 entry
= read_tree(&child
->root
, NULL
, get_path_pidl(path
,child
->hwnd
), drv
, child
->sortOrder
, child
->hwnd
);
3383 entry
= read_tree(&child
->root
, path
, NULL
, drv
, child
->sortOrder
, child
->hwnd
);
3386 entry
= &child
->root
.entry
;
3388 insert_entries(&child
->left
, child
->root
.entry
.down
, 0);
3390 set_curdir(child
, entry
, 0, child
->hwnd
);
3392 idx
= ListBox_FindItemData(child
->left
.hwnd
, 0, child
->left
.cur
);
3393 ListBox_SetCurSel(child
->left
.hwnd
, idx
);
3397 static void create_drive_bar()
3399 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0};
3400 TCHAR b1
[BUFFER_LEN
];
3404 GetLogicalDriveStrings(BUFFER_LEN
, Globals
.drives
);
3406 Globals
.hdrivebar
= CreateToolbarEx(Globals
.hMainWnd
, WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
3407 IDW_DRIVEBAR
, 2, Globals
.hInstance
, IDB_DRIVEBAR
, &drivebarBtn
,
3408 1, 16, 13, 16, 13, sizeof(TBBUTTON
));
3410 #ifndef _NO_EXTENSIONS
3412 /* insert unix file system button */
3416 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b1
);
3418 drivebarBtn
.idCommand
= ID_DRIVE_UNIX_FS
;
3419 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3420 drivebarBtn
.iString
++;
3422 #ifdef _SHELL_FOLDERS
3423 /* insert shell namespace button */
3424 load_string(b1
, IDS_SHELL
);
3425 b1
[lstrlen(b1
)+1] = '\0';
3426 SendMessage(Globals
.hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)b1
);
3428 drivebarBtn
.idCommand
= ID_DRIVE_SHELL_NS
;
3429 SendMessage(Globals
.hdrivebar
, TB_INSERTBUTTON
, btn
++, (LPARAM
)&drivebarBtn
);
3430 drivebarBtn
.iString
++;