winefile.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2000, 2003, 2004, 2005, 2008 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #ifdef __WINE__
00020 #include "config.h"
00021 #include "wine/port.h"
00022 
00023 /* for unix filesystem function calls */
00024 #include <sys/stat.h>
00025 #include <sys/types.h>
00026 #include <dirent.h>
00027 
00028 #define heap_alloc(s) HeapAlloc(GetProcessHeap(),0,s)
00029 #define heap_free(p) HeapFree(GetProcessHeap(),0,p)
00030 #else /* __WINE__ */
00031 #define heap_alloc(s) malloc(s)
00032 #define heap_free(p) free(p)
00033 #endif
00034 
00035 #define COBJMACROS
00036 
00037 #define WIN32_LEAN_AND_MEAN
00038 #define WIN32_EXTRA_LEAN
00039 #define NOSERVICE
00040 #define NOMCX
00041 #define NOIME
00042 #define NOCOMM
00043 #define NOKANJI
00044 #define NORPC
00045 #define NOPROXYSTUB
00046 #define NOIMAGE
00047 #define NOTAPE
00048 
00049 #define NONAMELESSUNION
00050 #include <windows.h>
00051 #include <windowsx.h>
00052 #include <commctrl.h>
00053 #include <commdlg.h>
00054 
00055 #ifdef UNICODE
00056 #define _UNICODE
00057 #endif
00058 
00059 #include <stdlib.h>
00060 #include <stdio.h>
00061 #include <ctype.h>
00062 #include <locale.h>
00063 #include <time.h>
00064 
00065 #include <shellapi.h>   /* for ShellExecute() */
00066 #include <shlobj.h>     /* for SHFormatDrive() */
00067 
00068 #ifndef _NO_EXTENSIONS
00069 #define _SHELL_FOLDERS
00070 #endif /* _NO_EXTENSIONS */
00071 
00072 #ifndef FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
00073 #define FILE_ATTRIBUTE_ENCRYPTED            0x00000040
00074 #define FILE_ATTRIBUTE_SPARSE_FILE          0x00000200
00075 #define FILE_ATTRIBUTE_REPARSE_POINT        0x00000400
00076 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED  0x00002000
00077 #endif
00078 
00079 
00080 #ifdef  _DEBUG
00081 #define ASSERT(x)   {if (!(x)) DebugBreak();}
00082 #else
00083 #define ASSERT(x)   /* nothing */
00084 #endif
00085 
00086 #define BUFFER_LEN  1024
00087 
00088 
00089 enum IMAGE {
00090     IMG_NONE=-1,    IMG_FILE=0,         IMG_DOCUMENT,   IMG_EXECUTABLE,
00091     IMG_FOLDER,     IMG_OPEN_FOLDER,    IMG_FOLDER_PLUS,IMG_OPEN_PLUS,  IMG_OPEN_MINUS,
00092     IMG_FOLDER_UP,  IMG_FOLDER_CUR
00093 };
00094 
00095 #define IMAGE_WIDTH         16
00096 #define IMAGE_HEIGHT        13
00097 #define SPLIT_WIDTH         5
00098 #define TREE_LINE_DX        3
00099 
00100 #define IDW_STATUSBAR       0x100
00101 #define IDW_TOOLBAR         0x101
00102 #define IDW_DRIVEBAR        0x102
00103 #define IDW_FIRST_CHILD     0xC000  /*0x200*/
00104 
00105 #define IDW_TREE_LEFT       3
00106 #define IDW_TREE_RIGHT      6
00107 #define IDW_HEADER_LEFT     2
00108 #define IDW_HEADER_RIGHT    5
00109 
00110 #define WM_DISPATCH_COMMAND 0xBF80
00111 
00112 #define COLOR_COMPRESSED    RGB(0,0,255)
00113 #define COLOR_SELECTION     RGB(0,0,128)
00114 #define COLOR_SELECTION_TXT RGB(255,255,255)
00115 
00116 #ifdef _NO_EXTENSIONS
00117 #define COLOR_SPLITBAR      WHITE_BRUSH
00118 #else
00119 #define COLOR_SPLITBAR      LTGRAY_BRUSH
00120 #endif
00121 
00122 #define FRM_CALC_CLIENT     0xBF83
00123 #define Frame_CalcFrameClient(hwnd, prt) ((BOOL)SNDMSG(hwnd, FRM_CALC_CLIENT, 0, (LPARAM)(PRECT)prt))
00124 
00125 
00126 typedef struct WINDOW_OPTIONS
00127 {
00128     int start_x;
00129     int start_y;
00130     int width;
00131     int height;
00132 };
00133 
00134 typedef struct WINEFILE_GLOBALS
00135 {
00136     HANDLE      hInstance;
00137     HACCEL      haccel;
00138     ATOM        hframeClass;
00139 
00140     HWND        hMainWnd;
00141     HMENU       hMenuFrame;
00142     HMENU       hWindowsMenu;
00143     HMENU       hLanguageMenu;
00144     HMENU       hMenuView;
00145     HMENU       hMenuOptions;
00146     HWND        hmdiclient;
00147     HWND        hstatusbar;
00148     HWND        htoolbar;
00149     HWND        hdrivebar;
00150     HFONT       hfont;
00151 
00152     TCHAR       num_sep;
00153     SIZE        spaceSize;
00154     HIMAGELIST  himl;
00155 
00156     TCHAR       drives[BUFFER_LEN];
00157     BOOL        prescan_node;   /*TODO*/
00158     BOOL        saveSettings;
00159 
00160 #ifdef _SHELL_FOLDERS
00161   IShellFolder* iDesktop;
00162   IMalloc*      iMalloc;
00163   UINT          cfStrFName;
00164 #endif
00165 };
00166 
00167 extern struct WINEFILE_GLOBALS Globals;
00168 
00169 #ifdef __WINE__
00170 
00171 #ifdef UNICODE
00172 extern void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
00173 #define _tsplitpath _wsplitpath
00174 #define _stprintf msvcrt_swprintf
00175 #else
00176 extern void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext);
00177 #define _tsplitpath _splitpath
00178 #define _stprintf sprintf //#error  problems in format_bytes() because of incompatible sprintf() implementation in WINE
00179 #endif
00180 
00181 #else
00182 
00183 #include <tchar.h>  /* for _tsplitpath() */
00184 
00185 #endif
00186 
00187 
00188 #ifdef _NO_EXTENSIONS
00189 #undef _LEFT_FILES
00190 #endif
00191 
00192 #ifndef _MAX_PATH
00193 #define _MAX_DRIVE  3
00194 #define _MAX_FNAME  256
00195 #define _MAX_DIR    _MAX_FNAME
00196 #define _MAX_EXT    _MAX_FNAME
00197 #define _MAX_PATH   260
00198 #endif
00199 
00200 #ifdef NONAMELESSUNION
00201 #define UNION_MEMBER(x) DUMMYUNIONNAME.x
00202 #else
00203 #define UNION_MEMBER(x) x
00204 #endif
00205 
00206 #ifdef _MSC_VER
00207 #define inline __inline
00208 #endif
00209 
00210 
00211 /* resource string tools */
00212 extern LPTSTR load_string(LPTSTR buffer, UINT id);
00213 #define RS(b, i) load_string(b, i)
00214 
00215 
00216 #ifdef _SHELL_FOLDERS
00217 #define DEFAULT_SPLIT_POS   300
00218 #else
00219 #define DEFAULT_SPLIT_POS   200
00220 #endif
00221 
00222 
00223 enum ENTRY_TYPE {
00224     ET_WINDOWS,
00225     ET_UNIX,
00226 #ifdef _SHELL_FOLDERS
00227     ET_SHELL
00228 #endif
00229 };
00230 
00231 typedef struct _Entry {
00232     struct _Entry*  next;
00233     struct _Entry*  down;
00234     struct _Entry*  up;
00235 
00236     BOOL            expanded;
00237     BOOL            scanned;
00238     int             level;
00239 
00240     WIN32_FIND_DATA data;
00241 
00242 #ifndef _NO_EXTENSIONS
00243     BY_HANDLE_FILE_INFORMATION bhfi;
00244     BOOL            bhfi_valid;
00245     enum ENTRY_TYPE etype;
00246 #endif
00247 #ifdef _SHELL_FOLDERS
00248     LPITEMIDLIST    pidl;
00249     IShellFolder*   folder;
00250     HICON           hicon;
00251 #endif
00252 } Entry;
00253 
00254 typedef struct _Root {
00255     Entry   entry;
00256     TCHAR   path[MAX_PATH];
00257     TCHAR   volname[_MAX_FNAME];
00258     TCHAR   fs[_MAX_DIR];
00259     DWORD   drive_type;
00260     DWORD   fs_flags;
00261 } Root;
00262 
00263 enum COLUMN_FLAGS {
00264     COL_SIZE        = 0x01,
00265     COL_DATE        = 0x02,
00266     COL_TIME        = 0x04,
00267     COL_ATTRIBUTES  = 0x08,
00268     COL_DOSNAMES    = 0x10,
00269 #ifdef _NO_EXTENSIONS
00270     COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES
00271 #else
00272     COL_INDEX       = 0x20,
00273     COL_LINKS       = 0x40,
00274     COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES|COL_INDEX|COL_LINKS
00275 #endif
00276 };
00277 
00278 enum SORT_ORDER {
00279     SORT_NAME,
00280     SORT_EXT,
00281     SORT_SIZE,
00282     SORT_DATE
00283 };
00284 
00285 typedef struct _Pane {
00286     HWND    hwnd;
00287 #ifndef _NO_EXTENSIONS
00288     HWND    hwndHeader;
00289 #endif
00290 
00291 #ifndef _NO_EXTENSIONS
00292 #define COLUMNS 10
00293 #else
00294 #define COLUMNS 5
00295 #endif
00296     int     widths[COLUMNS];
00297     int     positions[COLUMNS+1];
00298 
00299     BOOL    treePane;
00300     int     visible_cols;
00301     Entry*  root;
00302     Entry*  cur;
00303 } Pane;
00304 
00305 typedef struct _ChildWnd {
00306     HWND    hwnd;
00307     Pane    left;
00308     Pane    right;
00309     int     focus_pane;     /* 0: left  1: right */
00310     WINDOWPLACEMENT pos;
00311     int     split_pos;
00312     BOOL    header_wdths_ok;
00313 
00314     TCHAR   path[MAX_PATH];
00315     TCHAR   filter_pattern[MAX_PATH];
00316     int     filter_flags;
00317     Root    root;
00318 
00319     enum SORT_ORDER sortOrder;
00320 } ChildWnd;
00321 
00322 
00323 /* flags to filter different file types */
00324 
00325 enum TYPE_FILTER {
00326     TF_DIRECTORIES  = 0x01,
00327     TF_PROGRAMS     = 0x02,
00328     TF_DOCUMENTS    = 0x04,
00329     TF_OTHERS       = 0x08,
00330     TF_HIDDEN       = 0x10,
00331     TF_ALL          = 0x1F
00332 };
00333 
00334 
00335 extern const TCHAR sEmpty[]; /* "" */
00336 extern const TCHAR sSpace[]; /* " " */
00337 extern const TCHAR sNumFmt[]; /* "%d" */
00338 extern const TCHAR sQMarks[]; /* "???" */
00339 extern const TCHAR sLongHexFmt[]; /* "%I64X" */
00340 extern const TCHAR sLongNumFmt[]; /* "%I64d" */
00341 
00342 
00343 /* entries.c */
00344 
00345 extern Entry* alloc_entry(void);
00346 /*extern void free_entry(Entry* entry);*/
00347 extern void free_entries(Entry* dir);
00348 
00349 extern Entry* read_tree(Root* root, LPCTSTR path, LPITEMIDLIST pidl, LPTSTR drv, enum SORT_ORDER sortOrder, HWND hwnd);
00350 extern void get_path(Entry* dir, PTSTR path);
00351 
00352 
00353 extern void format_date(const FILETIME* ft, TCHAR* buffer, int visible_cols);
00354 
00355 extern void read_directory(Entry* dir, LPCTSTR path, enum SORT_ORDER sortOrder, HWND hwnd);
00356 
00357 /* display error message for the specified WIN32 error code */
00358 extern void display_error(HWND hwnd, DWORD error);
00359 
00360 /* display network error message using WNetGetLastError() */
00361 extern void display_network_error(HWND hwnd);
00362 
00363 
00364 /* Windows file system namespace function declarations */
00365 
00366 extern void read_directory_win(Entry* dir, LPCTSTR path);
00367 extern Entry* read_tree_win(Root* root, LPCTSTR path, enum SORT_ORDER sortOrder, HWND hwnd);
00368 
00369 
00370 /* Unix file system namespace function declarations */
00371 
00372 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
00373 extern void read_directory_unix(Entry* dir, LPCTSTR path);
00374 extern Entry* read_tree_unix(Root* root, LPCTSTR path, enum SORT_ORDER sortOrder, HWND hwnd);
00375 #endif
00376 
00377 
00378 /* Shell file system namespace function declarations */
00379 
00380 #ifdef _SHELL_FOLDERS
00381 
00382 extern void read_directory_shell(Entry* dir, HWND hwnd);
00383 extern Entry* read_tree_shell(Root* root, LPITEMIDLIST pidl, enum SORT_ORDER sortOrder, HWND hwnd);
00384 
00385 #ifdef UNICODE
00386 #define get_strret get_strretW
00387 #define path_from_pidl path_from_pidlW
00388 #else
00389 #define get_strret get_strretA
00390 #define path_from_pidl path_from_pidlA
00391 #endif
00392 
00393 extern LPITEMIDLIST get_path_pidl(LPCTSTR path, HWND hwnd);
00394 extern LPITEMIDLIST get_to_absolute_pidl(Entry* entry, HWND hwnd);
00395 
00396 extern HRESULT path_from_pidlA(IShellFolder* folder, LPITEMIDLIST pidl, LPSTR buffer, int len);
00397 extern HRESULT path_from_pidlW(IShellFolder* folder, LPITEMIDLIST pidl, LPWSTR buffer, int len);
00398 
00399 extern BOOL CtxMenu_HandleMenuMsg(UINT nmsg, WPARAM wparam, LPARAM lparam);
00400 extern HRESULT ShellFolderContextMenu(IShellFolder* shell_folder, HWND hwndParent, int cidl, LPCITEMIDLIST* apidl, int x, int y);
00401 
00402 extern IContextMenu3* s_pctxmenu3;
00403 
00404 #endif /* _SHELL_FOLDERS */
00405 
00406 
00407 /* shelltools.c */
00408 
00409 extern void save_registry_settings(void);
00410 extern void load_registry_settings(struct WINDOW_OPTIONS* pOpts);
00411 
00412 
00413 /* dialogs.c */
00414 
00415 struct ExecuteDialog {
00416     TCHAR   cmd[MAX_PATH];
00417     int     cmdshow;
00418 };
00419 extern INT_PTR CALLBACK ExecuteDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
00420 
00421 struct FilterDialog {
00422     TCHAR   pattern[MAX_PATH];
00423     int     flags;
00424 };
00425 extern INT_PTR CALLBACK FilterDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
00426 
00427 extern void choose_font(HWND hwnd);
00428 extern void show_properties_dlg(Entry* entry, HWND hwnd);
00429 extern INT_PTR CALLBACK DestinationDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
00430 
00431 
00432 #include "resource.h"

Winefile Source Code Documentation
generated on 15.09.2008 by doxygen

Winefile Homepage