implement file filtering (matching file name patterns and file types)
Modified: trunk/reactos/subsys/system/winefile/Sv.rc
Modified: trunk/reactos/subsys/system/winefile/cs.rc
Modified: trunk/reactos/subsys/system/winefile/de.rc
Modified: trunk/reactos/subsys/system/winefile/en.rc
Modified: trunk/reactos/subsys/system/winefile/es.rc
Modified: trunk/reactos/subsys/system/winefile/fr.rc
Modified: trunk/reactos/subsys/system/winefile/hu.rc
Modified: trunk/reactos/subsys/system/winefile/it.rc
Modified: trunk/reactos/subsys/system/winefile/nl.rc
Modified: trunk/reactos/subsys/system/winefile/pl.rc
Modified: trunk/reactos/subsys/system/winefile/pt.rc
Modified: trunk/reactos/subsys/system/winefile/resource.h
Modified: trunk/reactos/subsys/system/winefile/ru.rc
Modified: trunk/reactos/subsys/system/winefile/si.rc
Modified: trunk/reactos/subsys/system/winefile/winefile.c
Modified: trunk/reactos/subsys/system/winefile/zh.rc

Modified: trunk/reactos/subsys/system/winefile/Sv.rc
--- trunk/reactos/subsys/system/winefile/Sv.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/Sv.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -98,7 +98,7 @@
 	MENUITEM "Sortera efter st&orlek",	ID_VIEW_SORT_SIZE
 	MENUITEM "Sortera efter &datum",	ID_VIEW_SORT_DATE
         MENUITEM SEPARATOR
-        MENUITEM "Sortera efter &...",                409
+        MENUITEM "Sortera efter &...",                ID_VIEW_FILTER
 	}
 
 	POPUP "&Instõllningar"  {

Modified: trunk/reactos/subsys/system/winefile/cs.rc
--- trunk/reactos/subsys/system/winefile/cs.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/cs.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -97,7 +97,7 @@
 		MENUITEM "T°Ýdit podle &velikosti" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "T°Ýdit podle &data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "T°Ýdit podle &..." ,			409
+		MENUITEM "T°Ýdit podle &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&NastavenÝ"  {

Modified: trunk/reactos/subsys/system/winefile/de.rc
--- trunk/reactos/subsys/system/winefile/de.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/de.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -2,7 +2,7 @@
  * Winefile
  * German Language Support
  *
- * Copyright 2000 Martin Fuchs
+ * Copyright 2000, 2005 Martin Fuchs
  * Copyright 2002 Steven Edwards
  * Copyright 2002 Alexandre Julliard
  *
@@ -96,7 +96,7 @@
 		MENUITEM "Nach &Gr÷?e" , 	ID_VIEW_SORT_SIZE
 		MENUITEM "Nach &Datum" , 	ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Angaben ausw&õhlen..." ,			409
+		MENUITEM "Angaben ausw&õhlen..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Optionen"  {
@@ -176,6 +176,29 @@
 	PUSHBUTTON		"&Durchsuchen" , 254, 158, 43, 47, 14
 }
 
+IDD_DIALOG_VIEW_TYPE DIALOG DISCARDABLE 15, 13, 161, 97
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Angaben auswõhlen"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "&Name:",-1,7,8,22,10
+    EDITTEXT        IDC_VIEW_PATTERN,31,7,63,12,ES_AUTOHSCROLL
+    GROUPBOX        "Dateityp",-1,7,23,87,56
+    CONTROL         "&Verzeichnisse",IDC_VIEW_TYPE_DIRECTORIES,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,32,70,10
+    CONTROL         "&Programme",IDC_VIEW_TYPE_PROGRAMS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,43,70,10
+    CONTROL         "&Dokumente",IDC_VIEW_TYPE_DOCUMENTS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,54,70,10
+    CONTROL         "&Andere Dateien",IDC_VIEW_TYPE_OTHERS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,65,70,10
+    CONTROL         "Vers&teckte/Systemdateien anzeigen",IDC_VIEW_TYPE_HIDDEN,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,81,106,9
+    DEFPUSHBUTTON   "OK",IDOK,104,7,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,104,24,50,14
+END
+
+
 STRINGTABLE
 {
 	IDS_FONT_SEL_DLG_NAME	"Anwenden der Schriftarteinstellung"

Modified: trunk/reactos/subsys/system/winefile/en.rc
--- trunk/reactos/subsys/system/winefile/en.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/en.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -99,7 +99,7 @@
 		MENUITEM "Sort by Si&ze" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Sort by &Date" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Filter by &..." ,			409
+		MENUITEM "Filter by &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Options"  {
@@ -179,6 +179,29 @@
 	PUSHBUTTON		"&Browse" , 254, 158, 43, 47, 14
 }
 
+IDD_DIALOG_VIEW_TYPE DIALOG DISCARDABLE 15, 13, 161, 97
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "By File Type"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "&Name:",-1,7,8,22,10
+    EDITTEXT        IDC_VIEW_PATTERN,31,7,63,12,ES_AUTOHSCROLL
+    GROUPBOX        "File Type",-1,7,23,87,56
+    CONTROL         "&Directories",IDC_VIEW_TYPE_DIRECTORIES,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,32,70,10
+    CONTROL         "&Programs",IDC_VIEW_TYPE_PROGRAMS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,43,70,10
+    CONTROL         "Docu&ments",IDC_VIEW_TYPE_DOCUMENTS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,54,70,10
+    CONTROL         "&Other files",IDC_VIEW_TYPE_OTHERS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,65,70,10
+    CONTROL         "Show Hidden/&System Files",IDC_VIEW_TYPE_HIDDEN,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,81,106,9
+    DEFPUSHBUTTON   "OK",IDOK,104,7,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,104,24,50,14
+END
+
+
 STRINGTABLE
 {
 	IDS_FONT_SEL_DLG_NAME	"Applying font settings"

Modified: trunk/reactos/subsys/system/winefile/es.rc
--- trunk/reactos/subsys/system/winefile/es.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/es.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -95,7 +95,7 @@
 		MENUITEM "Ordenar por t&ama±o" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Ordenar por &fecha" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Ordenar por &..." ,			409
+		MENUITEM "Ordenar por &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Opciones"  {

Modified: trunk/reactos/subsys/system/winefile/fr.rc
--- trunk/reactos/subsys/system/winefile/fr.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/fr.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -98,7 +98,7 @@
 		MENUITEM "Trier par Ta&ille" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Trier par Dat&e" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Trier par &..." ,			409
+		MENUITEM "Trier par &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Options"  {

Modified: trunk/reactos/subsys/system/winefile/hu.rc
--- trunk/reactos/subsys/system/winefile/hu.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/hu.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -98,7 +98,7 @@
 		MENUITEM "RendezÚs &mÚret szerint" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "RendezÚs &dßtum szerint" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Egyedi rendezÚs &..." ,			409
+		MENUITEM "Egyedi rendezÚs &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&BeßllÝtßsok"  {

Modified: trunk/reactos/subsys/system/winefile/it.rc
--- trunk/reactos/subsys/system/winefile/it.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/it.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -98,7 +98,7 @@
 		MENUITEM "&Ordina per Dimensione" , 	ID_VIEW_SORT_SIZE
 		MENUITEM "&Ordina per Data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Ordina per &..." ,			409
+		MENUITEM "Ordina per &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Opzioni"  {

Modified: trunk/reactos/subsys/system/winefile/nl.rc
--- trunk/reactos/subsys/system/winefile/nl.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/nl.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -94,7 +94,7 @@
 		MENUITEM "Sorteer op &grootte" , ID_VIEW_SORT_SIZE
 		MENUITEM "Sorteer op &datum" ,   ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Sorteer op &..." ,     409
+		MENUITEM "Sorteer op &..." ,     ID_VIEW_FILTER
 	}
 
 	POPUP "&Opties"  {

Modified: trunk/reactos/subsys/system/winefile/pl.rc
--- trunk/reactos/subsys/system/winefile/pl.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/pl.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -98,7 +98,7 @@
 		MENUITEM "Rozmie£µ &po wielko£ci" , 		406
 		MENUITEM "&Sortuj po dacie" , 		407
 		MENUITEM SEPARATOR
-		MENUITEM "Sortuj po &..." ,			409
+		MENUITEM "Sortuj po &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Opcje"  {

Modified: trunk/reactos/subsys/system/winefile/pt.rc
--- trunk/reactos/subsys/system/winefile/pt.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/pt.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -97,7 +97,7 @@
 		MENUITEM "Cl&assificar por tamanho" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Cla&ssificar por &data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Classificar &por..." ,			409
+		MENUITEM "Classificar &por..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Opþ§es"  {
@@ -225,7 +225,7 @@
 		MENUITEM "Cl&assificar por tamanho" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Cla&ssificar por &data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Classificar &por..." ,			409
+		MENUITEM "Classificar &por..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Opþ§es"  {

Modified: trunk/reactos/subsys/system/winefile/resource.h
--- trunk/reactos/subsys/system/winefile/resource.h	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/resource.h	2005-05-28 17:13:56 UTC (rev 15592)
@@ -35,6 +35,7 @@
 
 #define IDD_EXECUTE						103
 #define IDD_SELECT_DESTINATION			104
+#define IDD_DIALOG_VIEW_TYPE			105
 
 
 /* control ids */
@@ -53,6 +54,7 @@
 #define	ID_VIEW_SORT_TYPE				405
 #define	ID_VIEW_SORT_SIZE				406
 #define	ID_VIEW_SORT_DATE				407
+#define	ID_VIEW_FILTER					409
 #define	ID_VIEW_SPLIT					414
 #define ID_SELECT_FONT					510
 #define ID_VIEW_TOOL_BAR				508
@@ -71,7 +73,14 @@
 #define ID_HELP_USING					0xE144
 #define ID_HELP 						0xE146
 
+#define IDC_VIEW_PATTERN				1000
+#define IDC_VIEW_TYPE_DIRECTORIES		1001
+#define IDC_VIEW_TYPE_PROGRAMS			1002
+#define IDC_VIEW_TYPE_DOCUMENTS 		1003
+#define IDC_VIEW_TYPE_OTHERS			1004
+#define IDC_VIEW_TYPE_HIDDEN			1005
 
+
 /* winefile extensions */
 
 #define ID_ABOUT_WINE					0x8000

Modified: trunk/reactos/subsys/system/winefile/ru.rc
--- trunk/reactos/subsys/system/winefile/ru.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/ru.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -94,7 +94,7 @@
 		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &­ÓþýÕ­¾" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ õ&Ó?Õ" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &..." ,			409
+		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&?Ó±?­¯ÚÛÞ"  {

Modified: trunk/reactos/subsys/system/winefile/si.rc
--- trunk/reactos/subsys/system/winefile/si.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/si.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -95,7 +95,7 @@
 		MENUITEM "Sort by Si&ze" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "Sort by &Date" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Filter by &..." ,			409
+		MENUITEM "Filter by &..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "&Options"  {

Modified: trunk/reactos/subsys/system/winefile/winefile.c
--- trunk/reactos/subsys/system/winefile/winefile.c	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/winefile.c	2005-05-28 17:13:56 UTC (rev 15592)
@@ -141,6 +141,8 @@
 	BOOL	header_wdths_ok;
 
 	TCHAR	path[MAX_PATH];
+	TCHAR	filter_pattern[MAX_PATH];
+	int		filter_flags;
 	Root	root;
 
 	SORT_ORDER sortOrder;
@@ -1375,10 +1377,22 @@
 }
 
 
+/* flags to filter different file types */
+enum TYPE_FILTER {
+	TF_DIRECTORIES	= 0x01,
+	TF_PROGRAMS		= 0x02,
+	TF_DOCUMENTS	= 0x04,
+	TF_OTHERS		= 0x08,
+	TF_HIDDEN		= 0x10,
+	TF_ALL			= 0x1F
+};
+
+
 static ChildWnd* alloc_child_window(LPCTSTR path, LPITEMIDLIST pidl, HWND hwnd)
 {
 	TCHAR drv[_MAX_DRIVE+1], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT];
 	TCHAR b1[BUFFER_LEN];
+	const static TCHAR sAsterics[] = {'*', '\0'};
 
 	ChildWnd* child = (ChildWnd*) malloc(sizeof(ChildWnd));
 	Root* root = &child->root;
@@ -1416,6 +1430,9 @@
 		_tsplitpath(path, drv, dir, name, ext);
 	}
 
+	_tcscpy(child->filter_pattern, sAsterics);
+	child->filter_flags = TF_ALL;
+
 	root->entry.level = 0;
 
 	entry = read_tree(root, path, pidl, drv, child->sortOrder, hwnd);
@@ -1637,7 +1654,6 @@
 	int		cmdshow;
 };
 
-
 static INT_PTR CALLBACK ExecuteDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 {
 	static struct ExecuteDialog* dlg;
@@ -1664,6 +1680,7 @@
 	return 0;
 }
 
+
 static INT_PTR CALLBACK DestinationDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 {
 	TCHAR b1[BUFFER_LEN], b2[BUFFER_LEN];
@@ -1701,6 +1718,53 @@
 }
 
 
+struct FilterDialog {
+	TCHAR	pattern[MAX_PATH];
+	int		flags;
+};
+
+static INT_PTR CALLBACK FilterDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
+{
+	static struct FilterDialog* dlg;
+
+	switch(nmsg) {
+		case WM_INITDIALOG:
+			dlg = (struct FilterDialog*) lparam;
+			SetWindowText(GetDlgItem(hwnd, IDC_VIEW_PATTERN), dlg->pattern);
+			Button_SetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_DIRECTORIES), (dlg->flags&TF_DIRECTORIES? BST_CHECKED: BST_UNCHECKED));
+			Button_SetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_PROGRAMS), dlg->flags&TF_PROGRAMS? BST_CHECKED: BST_UNCHECKED);
+			Button_SetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_DOCUMENTS), dlg->flags&TF_DOCUMENTS? BST_CHECKED: BST_UNCHECKED);
+			Button_SetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_OTHERS), dlg->flags&TF_OTHERS? BST_CHECKED: BST_UNCHECKED);
+			Button_SetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_HIDDEN), dlg->flags&TF_HIDDEN? BST_CHECKED: BST_UNCHECKED);
+			return 1;
+
+		case WM_COMMAND: {
+			int id = (int)wparam;
+
+			if (id == IDOK) {
+				int flags = 0;
+
+				GetWindowText(GetDlgItem(hwnd, IDC_VIEW_PATTERN), dlg->pattern, MAX_PATH);
+
+				flags |= Button_GetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_DIRECTORIES))&BST_CHECKED? TF_DIRECTORIES: 0;
+				flags |= Button_GetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_PROGRAMS))&BST_CHECKED? TF_PROGRAMS: 0;
+				flags |= Button_GetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_DOCUMENTS))&BST_CHECKED? TF_DOCUMENTS: 0;
+				flags |= Button_GetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_OTHERS))&BST_CHECKED? TF_OTHERS: 0;
+				flags |= Button_GetCheck(GetDlgItem(hwnd,IDC_VIEW_TYPE_HIDDEN))&BST_CHECKED? TF_HIDDEN: 0;
+
+				dlg->flags = flags;
+
+				EndDialog(hwnd, id);
+			} else if (id == IDCANCEL)
+				EndDialog(hwnd, id);
+
+			return 1;}
+	}
+
+	return 0;
+}
+
+
 #ifndef _NO_EXTENSIONS
 
 static struct FullScreenParameters {
@@ -2434,9 +2498,46 @@
 }
 
 
+static BOOL pattern_match(LPCTSTR str, LPCTSTR pattern)
+{
+	for( ; *str&&*pattern; str++,pattern++) {
+		if (*pattern == '*') {
+			do pattern++;
+			while(*pattern == '*');
+
+			if (!*pattern)
+				return TRUE;
+
+			for(; *str; str++)
+				if (_totupper(*str)==_totupper(*pattern) && pattern_match(str, pattern))
+					return TRUE;
+
+			return FALSE;
+		}
+		else if (_totupper(*str)!=_totupper(*pattern) && *pattern!='?')
+			return FALSE;
+	}
+
+	if (*str || *pattern)
+		if (*pattern!='*' || pattern[1]!='\0')
+			return FALSE;
+
+	return TRUE;
+}
+
+
+enum FILE_TYPE {
+	FT_OTHER		= 0,
+	FT_EXECUTABLE	= 1,
+	FT_DOCUMENT		= 2
+};
+
+static enum FILE_TYPE get_file_type(LPCTSTR filename);
+
+
 /* insert listbox entries after index idx */
 
-static int insert_entries(Pane* pane, Entry* dir, int idx)
+static int insert_entries(Pane* pane, Entry* dir, LPCTSTR pattern, int filter_flags, int idx)
 {
 	Entry* entry = dir;
 
@@ -2451,23 +2552,54 @@
 			continue;
 #endif
 
-		/* don't display entries "." and ".." in the left pane */
-		if (pane->treePane && (entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
-				&& entry->data.cFileName[0]==TEXT('.'))
-			if (
-#ifndef _NO_EXTENSIONS
-				entry->data.cFileName[1]==TEXT('\0') ||
-#endif
-				(entry->data.cFileName[1]==TEXT('.') && entry->data.cFileName[2]==TEXT('\0')))
+		if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+			/* don't display entries "." and ".." in the left pane */
+			if (pane->treePane && entry->data.cFileName[0]==TEXT('.'))
+				if (
+	#ifndef _NO_EXTENSIONS
+					entry->data.cFileName[1]==TEXT('\0') ||
+	#endif
+					(entry->data.cFileName[1]==TEXT('.') && entry->data.cFileName[2]==TEXT('\0')))
+					continue;
+
+			if (pattern)
+				if (!pattern_match(entry->data.cFileName, pattern))
+					continue;
+
+			/* filter directories in right pane */
+			if (!pane->treePane && !(filter_flags&TF_DIRECTORIES))
 				continue;
+		}
 
+		/* filter system and hidden files */
+		if (!(filter_flags&TF_HIDDEN) && (entry->data.dwFileAttributes&(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM)))
+			continue;
+
+		/* filter looking at the file type */
+		if ((filter_flags&(TF_PROGRAMS|TF_DOCUMENTS|TF_OTHERS)) != (TF_PROGRAMS|TF_DOCUMENTS|TF_OTHERS))
+			switch(get_file_type(entry->data.cFileName)) {
+			  case FT_EXECUTABLE:
+			  	if (!(filter_flags & TF_PROGRAMS))
+					continue;
+				break;
+
+			  case FT_DOCUMENT:
+				if (!(filter_flags & TF_DOCUMENTS))
+					continue;
+				break;
+
+			  default: // TF_OTHERS
+				if (!(filter_flags & TF_OTHERS))
+					continue;
+			}
+
 		if (idx != -1)
 			idx++;
 
 		ListBox_InsertItemData(pane->hwnd, idx, entry);
 
 		if (pane->treePane && entry->expanded)
-			idx = insert_entries(pane, entry->down, idx);
+			idx = insert_entries(pane, entry->down, pattern, filter_flags, idx);
 	}
 
 	ShowWindow(pane->hwnd, SW_SHOW);
@@ -2512,7 +2644,7 @@
 
 static WNDPROC g_orgTreeWndProc;
 
-static void create_tree_window(HWND parent, Pane* pane, int id, int id_header)
+static void create_tree_window(HWND parent, Pane* pane, int id, int id_header, LPCTSTR pattern, int filter_flags)
 {
 	const static TCHAR sListBox[] = {'L','i','s','t','B','o','x','\0'};
 
@@ -2530,7 +2662,7 @@
 
 	/* insert entries into listbox */
 	if (entry)
-		insert_entries(pane, entry, -1);
+		insert_entries(pane, entry, pattern, filter_flags, -1);
 
 	/* calculate column widths */
 	if (!s_init) {
@@ -2548,8 +2680,8 @@
 
 static void InitChildWindow(ChildWnd* child)
 {
-	create_tree_window(child->hwnd, &child->left, IDW_TREE_LEFT, IDW_HEADER_LEFT);
-	create_tree_window(child->hwnd, &child->right, IDW_TREE_RIGHT, IDW_HEADER_RIGHT);
+	create_tree_window(child->hwnd, &child->left, IDW_TREE_LEFT, IDW_HEADER_LEFT, NULL, TF_ALL);
+	create_tree_window(child->hwnd, &child->right, IDW_TREE_RIGHT, IDW_HEADER_RIGHT, child->filter_pattern, child->filter_flags);
 }
 
 
@@ -2674,7 +2806,7 @@
 }
 
 
-static int is_exe_file(LPCTSTR ext)
+static BOOL is_exe_file(LPCTSTR ext)
 {
 	static const TCHAR executable_extensions[][4] = {
 		{'C','O','M','\0'},
@@ -2698,20 +2830,36 @@
 		d++;
 
 	for(p=executable_extensions; (*p)[0]; p++)
-		if (!_tcscmp(ext_buffer, *p))
-			return 1;
+		if (!_tcsicmp(ext_buffer, *p))
+			return TRUE;
 
-	return 0;
+	return FALSE;
 }
 
-static int is_registered_type(LPCTSTR ext)
+static BOOL is_registered_type(LPCTSTR ext)
 {
-        /* TODO */
+	/* check if there exists a classname for this file extension in the registry */
+	if (!RegQueryValue(HKEY_CLASSES_ROOT, ext, NULL, NULL))
+		return TRUE;
 
-	return 1;
+	return FALSE;
 }
 
+static enum FILE_TYPE get_file_type(LPCTSTR filename)
+{
+	LPCTSTR ext = _tcsrchr(filename, '.');
+	if (!ext)
+		ext = sEmpty;
 
+	if (is_exe_file(ext))
+		return FT_EXECUTABLE;
+	else if (is_registered_type(ext))
+		return FT_DOCUMENT;
+	else
+		return FT_OTHER;
+}
+
+
 static void draw_item(Pane* pane, LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol)
 {
 	TCHAR buffer[BUFFER_LEN];
@@ -2744,16 +2892,11 @@
 			else
 				img = IMG_FOLDER;
 		} else {
-			LPCTSTR ext = _tcsrchr(entry->data.cFileName, '.');
-			if (!ext)
-				ext = sEmpty;
-
-			if (is_exe_file(ext))
-				img = IMG_EXECUTABLE;
-			else if (is_registered_type(ext))
-				img = IMG_DOCUMENT;
-			else
-				img = IMG_FILE;
+			switch(get_file_type(entry->data.cFileName)) {
+			  case FT_EXECUTABLE:	img = IMG_EXECUTABLE;	break;
+			  case FT_DOCUMENT:		img = IMG_DOCUMENT;		break;
+			  default:				img = IMG_FILE;
+			}
 		}
 	} else {
 		attrs = 0;
@@ -3254,7 +3397,7 @@
 	}
 
 	/* insert found entries in right pane */
-	insert_entries(&child->right, entry->down, -1);
+	insert_entries(&child->right, entry->down, child->filter_pattern, child->filter_flags, -1);
 	calc_widths(&child->right, FALSE);
 #ifndef _NO_EXTENSIONS
 	set_header(&child->right);
@@ -3295,7 +3438,7 @@
 	dir->expanded = TRUE;
 
 	/* insert entries in left pane */
-	insert_entries(&child->left, p, idx);
+	insert_entries(&child->left, p, NULL, TF_ALL, idx);
 
 	if (!child->header_wdths_ok) {
 		if (calc_widths(&child->left, FALSE)) {
@@ -3334,6 +3477,17 @@
 }
 
 
+static void refresh_right_pane(ChildWnd* child)
+{
+	ListBox_ResetContent(child->right.hwnd);
+	insert_entries(&child->right, child->right.root, child->filter_pattern, child->filter_flags, -1);
+	calc_widths(&child->right, FALSE);
+
+#ifndef _NO_EXTENSIONS
+	set_header(&child->right);
+#endif
+}
+
 static void set_curdir(ChildWnd* child, Entry* entry, int idx, HWND hwnd)
 {
 	TCHAR path[MAX_PATH];
@@ -3341,19 +3495,14 @@
 	path[0] = '\0';
 
 	child->left.cur = entry;
+
 	child->right.root = entry->down? entry->down: entry;
 	child->right.cur = entry;
 
 	if (!entry->scanned)
 		scan_entry(child, entry, idx, hwnd);
-	else {
-		ListBox_ResetContent(child->right.hwnd);
-		insert_entries(&child->right, entry->down, -1);
-		calc_widths(&child->right, FALSE);
-#ifndef _NO_EXTENSIONS
-		set_header(&child->right);
-#endif
-	}
+	else
+		refresh_right_pane(child);
 
 	get_path(entry, path);
 	lstrcpy(child->path, path);
@@ -3390,7 +3539,7 @@
 	if (!entry)
 		entry = &child->root.entry;
 
-	insert_entries(&child->left, child->root.entry.down, 0);
+	insert_entries(&child->left, child->root.entry.down, NULL, TF_ALL, 0);
 
 	set_curdir(child, entry, 0, child->hwnd);
 
@@ -4000,6 +4149,20 @@
 					set_sort_order(child, SORT_DATE);
 					break;
 
+				case ID_VIEW_FILTER: {
+					struct FilterDialog dlg;
+
+					memset(&dlg, 0, sizeof(struct FilterDialog));
+					_tcscpy(dlg.pattern, child->filter_pattern);
+					dlg.flags = child->filter_flags;
+
+					if (DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_DIALOG_VIEW_TYPE), hwnd, FilterDialogDlgProc, (LPARAM)&dlg) == IDOK) {
+						_tcscpy(child->filter_pattern, dlg.pattern);
+						child->filter_flags = dlg.flags;
+						refresh_right_pane(child);
+					}
+					break;}
+
 				case ID_VIEW_SPLIT: {
 					last_split = child->split_pos;
 #ifdef _NO_EXTENSIONS

Modified: trunk/reactos/subsys/system/winefile/zh.rc
--- trunk/reactos/subsys/system/winefile/zh.rc	2005-05-28 16:51:42 UTC (rev 15591)
+++ trunk/reactos/subsys/system/winefile/zh.rc	2005-05-28 17:13:56 UTC (rev 15592)
@@ -95,7 +95,7 @@
 		MENUITEM "???¾ðí??ð?ú¿&Zú®" , 		ID_VIEW_SORT_SIZE
 		MENUITEM "???iã???ð?ú¿&Dú®" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "¿Íã??ð?..." ,			409
+		MENUITEM "¿Íã??ð?..." ,			ID_VIEW_FILTER
 	}
 
 	POPUP "Ðí¤¯ú¿&Oú®"  {