From: Robert Dickenson Date: Sat, 6 Jul 2002 02:44:16 +0000 (+0000) Subject: Updated with progress work. X-Git-Tag: ReactOS-0.0.20~132 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=050dbf13f55a6caa772008ba3b475825ce5b957b Updated with progress work. svn path=/trunk/; revision=3182 --- diff --git a/rosapps/winfile/Makefile b/rosapps/winfile/Makefile index cf8506ea019..49b5770a8a6 100644 --- a/rosapps/winfile/Makefile +++ b/rosapps/winfile/Makefile @@ -31,6 +31,15 @@ RCFLAGS = -DGCC -D_WIN32_IE=0x0400 OBJS = about.o \ debug.o \ + draw.o \ + entries.o \ + main.o \ + mdiclient.o \ + run.o \ + settings.o \ + splitpath.o \ + sort.o \ + utils.o \ treeview.o \ listview.o \ $(TARGET).o @@ -46,41 +55,20 @@ $(TARGET).exe: $(OBJS) $(TARGET).coff $(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym -about.o: about.cpp about.h resource.h +about.o: about.c about.h resource.h -affinity.o: affinity.cpp affinity.h +debug.o: debug.c debug.h -applicationpage.o: applicationpage.cpp applicationpage.h processpage.h $(TARGET).h resource.h +font.o: font.c font.h -column.o: column.cpp column.h resource.h +setttings.o: setttings.c setttings.h resource.h -debug.o: debug.cpp debug.h +run.o: run.c run.h -endproc.o: endproc.cpp endproc.h +mdiclient.o: mdiclient.c mdiclient.h resource.h -font.o: font.cpp font.h +$(TARGET).o: $(TARGET).c $(TARGET).h resource.h -graph.o: graph.cpp graph.h resource.h - -graphctrl.o: graphctrl.cpp graphctrl.h resource.h - -optnmenu.o: optnmenu.cpp optnmenu.h resource.h - -perfdata.o: perfdata.cpp perfdata.h - -performancepage.o: performancepage.cpp performancepage.h perfdata.h graphctrl.h graph.h $(TARGET).h resource.h - -priority.o: priority.cpp priority.h - -processpage.o: processpage.cpp processpage.h perfdata.h column.h proclist.h $(TARGET).h resource.h - -proclist.o: proclist.cpp proclist.h - -run.o: run.cpp run.h - -trayicon.o: trayicon.cpp trayicon.h resource.h - -$(TARGET).o: $(TARGET).cpp $(TARGET).h resource.h clean: - $(RM) $(OBJS) diff --git a/rosapps/winfile/about.cpp b/rosapps/winfile/about.c similarity index 93% rename from rosapps/winfile/about.cpp rename to rosapps/winfile/about.c index ac927197391..afc38bc45e6 100644 --- a/rosapps/winfile/about.cpp +++ b/rosapps/winfile/about.c @@ -1,7 +1,7 @@ /* * ReactOS About Dialog Box * - * about.cpp + * about.c * * Copyright (C) 2002 Robert Dickenson * @@ -39,15 +39,7 @@ extern HINSTANCE hInst; -//extern HWND hMainWnd; -LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); - - -void ShowAboutBox(HWND hWnd) -{ - DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)AboutDialogWndProc); -} LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { @@ -69,3 +61,9 @@ LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPAR } return 0; } + +void ShowAboutBox(HWND hWnd) +{ + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)AboutDialogWndProc); +} + diff --git a/rosapps/winfile/about.h b/rosapps/winfile/about.h index fabcfb3d618..4dd6e6dd150 100644 --- a/rosapps/winfile/about.h +++ b/rosapps/winfile/about.h @@ -23,8 +23,16 @@ #ifndef __ABOUT_H__ #define __ABOUT_H__ +#ifdef __cplusplus +extern "C" { +#endif + void ShowAboutBox(HWND hWnd); +#ifdef __cplusplus +}; +#endif + #endif // __ABOUT_H__ diff --git a/rosapps/winfile/debug.cpp b/rosapps/winfile/debug.c similarity index 98% rename from rosapps/winfile/debug.cpp rename to rosapps/winfile/debug.c index bd0b2374711..590160a2de1 100644 --- a/rosapps/winfile/debug.cpp +++ b/rosapps/winfile/debug.c @@ -1,7 +1,7 @@ /* * ReactOS Application Debug Routines * - * debug.cpp + * debug.c * * Copyright (C) 2002 Robert Dickenson * diff --git a/rosapps/winfile/debug.h b/rosapps/winfile/debug.h index f9f96e67238..6ae3506e0f8 100644 --- a/rosapps/winfile/debug.h +++ b/rosapps/winfile/debug.h @@ -23,6 +23,15 @@ #ifndef __DEBUG_H__ #define __DEBUG_H__ +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +}; +#endif + #endif // __DEBUG_H__ \ No newline at end of file diff --git a/rosapps/winfile/listview.cpp b/rosapps/winfile/dialogs.c similarity index 55% rename from rosapps/winfile/listview.cpp rename to rosapps/winfile/dialogs.c index 360dde4f4d4..889d5c132e9 100644 --- a/rosapps/winfile/listview.cpp +++ b/rosapps/winfile/dialogs.c @@ -1,7 +1,7 @@ /* * ReactOS winfile * - * listview.cpp + * dialogs.c * * Copyright (C) 2002 Robert Dickenson * @@ -34,35 +34,52 @@ #include #endif +#include +//#include +#include +#include +#include +#include +#define ASSERT assert + #include "winfile.h" -#include "listview.h" +#include "about.h" +#include "dialogs.h" +#include "utils.h" +#include "debug.h" -// Global Variables: -extern HINSTANCE hInst; -extern HWND hMainWnd; +struct ExecuteDialog { + TCHAR cmd[MAX_PATH]; + int cmdshow; +}; + + +BOOL CALLBACK ExecuteDialogWndProg(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + static struct ExecuteDialog* dlg; + + switch(nmsg) { + case WM_INITDIALOG: + dlg = (struct ExecuteDialog*) lparam; + return 1; + + case WM_COMMAND: { + int id = (int)wparam; + + if (id == IDOK) { + GetWindowText(GetDlgItem(hwnd, 201), dlg->cmd, MAX_PATH); + dlg->cmdshow = Button_GetState(GetDlgItem(hwnd,214))&BST_CHECKED? + SW_SHOWMINIMIZED: SW_SHOWNORMAL; + EndDialog(hwnd, id); + } else if (id == IDCANCEL) + EndDialog(hwnd, id); + + return 1;} + } + + return 0; +} -HWND CreateListView(HWND hwndParent, LPSTR lpszFileName) -{ - RECT rcClient; // dimensions of client area - HWND hwndLV; // handle to list view control - - // Get the dimensions of the parent window's client area, and create the list view control. - GetClientRect(hwndParent, &rcClient); - hwndLV = CreateWindowEx(0, WC_LISTVIEW, "List View", - WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES, - 0, 0, rcClient.right, rcClient.bottom, - hwndParent, (HMENU)LIST_WINDOW, hInst, NULL); - - // Initialize the image list, and add items to the control. -/* - if (!InitListViewImageLists(hwndLV) || - !InitListViewItems(hwndLV, lpszFileName)) { - DestroyWindow(hwndLV); - return FALSE; - } - */ - return hwndLV; -} diff --git a/rosapps/winfile/dialogs.h b/rosapps/winfile/dialogs.h new file mode 100644 index 00000000000..37a5bd28010 --- /dev/null +++ b/rosapps/winfile/dialogs.h @@ -0,0 +1,45 @@ +/* + * ReactOS winfile + * + * dialogs.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __DIALOGS_H__ +#define __DIALOGS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + + +BOOL CALLBACK ExecuteDialogWndProg(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __DIALOGS_H__ diff --git a/rosapps/winfile/draw.c b/rosapps/winfile/draw.c new file mode 100644 index 00000000000..a290ad478ae --- /dev/null +++ b/rosapps/winfile/draw.c @@ -0,0 +1,535 @@ +/* + * ReactOS winfile + * + * draw.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include "winfile.h" +#include "utils.h" +#include "draw.h" + + +#define COLOR_COMPRESSED RGB(0,0,255) +#define COLOR_SELECTION RGB(0,0,128) + + +static void format_date(const FILETIME* ft, TCHAR* buffer, int visible_cols) +{ + SYSTEMTIME systime; + FILETIME lft; + int len = 0; + + *buffer = _T('\0'); + + if (!ft->dwLowDateTime && !ft->dwHighDateTime) + return; + + if (!FileTimeToLocalFileTime(ft, &lft)) + {err: _tcscpy(buffer,_T("???")); return;} + + if (!FileTimeToSystemTime(&lft, &systime)) + goto err; + + if (visible_cols & COL_DATE) { + len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, buffer, BUFFER_LEN); + if (!len) + goto err; + } + + if (visible_cols & COL_TIME) { + if (len) + buffer[len-1] = ' '; + + buffer[len++] = ' '; + + if (!GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, buffer+len, BUFFER_LEN-len)) + buffer[len] = _T('\0'); + } +} + + +static void calc_width(Pane* pane, LPDRAWITEMSTRUCT dis, int col, LPCTSTR str) +{ + RECT rt = {0}; + + DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX); + + if (rt.right > pane->widths[col]) + pane->widths[col] = rt.right; +} + +static void calc_tabbed_width(Pane* pane, LPDRAWITEMSTRUCT dis, int col, LPCTSTR str) +{ + RECT rt = {0}; + +/* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2}; + DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/ + + DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_EXPANDTABS|DT_TABSTOP|(2<<8)); +//@@ rt (0,0) ??? + + if (rt.right > pane->widths[col]) + pane->widths[col] = rt.right; +} + + +static void output_text(Pane* pane, LPDRAWITEMSTRUCT dis, int col, LPCTSTR str, DWORD flags) +{ + int x = dis->rcItem.left; + RECT rt = {x+pane->positions[col]+Globals.spaceSize.cx, dis->rcItem.top, x+pane->positions[col+1]-Globals.spaceSize.cx, dis->rcItem.bottom}; + + DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|flags); +} + +static void output_tabbed_text(Pane* pane, LPDRAWITEMSTRUCT dis, int col, LPCTSTR str) +{ + int x = dis->rcItem.left; + RECT rt = {x+pane->positions[col]+Globals.spaceSize.cx, dis->rcItem.top, x+pane->positions[col+1]-Globals.spaceSize.cx, dis->rcItem.bottom}; + +/* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2}; + DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/ + + DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_EXPANDTABS|DT_TABSTOP|(2<<8)); +} + +static void output_number(Pane* pane, LPDRAWITEMSTRUCT dis, int col, LPCTSTR str) +{ + int x = dis->rcItem.left; + RECT rt = {x+pane->positions[col]+Globals.spaceSize.cx, dis->rcItem.top, x+pane->positions[col+1]-Globals.spaceSize.cx, dis->rcItem.bottom}; + LPCTSTR s = str; + TCHAR b[128]; + LPTSTR d = b; + int pos; + + if (*s) + *d++ = *s++; + + // insert number separator characters + pos = lstrlen(s) % 3; + + while(*s) + if (pos--) + *d++ = *s++; + else { + *d++ = Globals.num_sep; + pos = 3; + } + + DrawText(dis->hDC, b, d-b, &rt, DT_RIGHT|DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS); +} + + +void draw_item(Pane* pane, LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol) +{ +#if 0 + TCHAR buffer[BUFFER_LEN]; + DWORD attrs; + int visible_cols = pane->visible_cols; + COLORREF bkcolor, textcolor; + RECT focusRect = dis->rcItem; + HBRUSH hbrush; + enum IMAGE img; +#ifndef _NO_EXTENSIONS + QWORD index; +#endif + int img_pos, cx; + int col = 0; + + if (entry) { + attrs = entry->data.dwFileAttributes; + + if (attrs & FILE_ATTRIBUTE_DIRECTORY) { + if (entry->data.cFileName[0]==_T('.') && entry->data.cFileName[1]==_T('.') + && entry->data.cFileName[2]==_T('\0')) + img = IMG_FOLDER_UP; +#ifndef _NO_EXTENSIONS + else if (entry->data.cFileName[0]==_T('.') && entry->data.cFileName[1]==_T('\0')) + img = IMG_FOLDER_CUR; +#endif + else if ( +#ifdef _NO_EXTENSIONS + entry->expanded || +#endif + (pane->treePane && (dis->itemState&ODS_FOCUS))) + img = IMG_OPEN_FOLDER; + else + img = IMG_FOLDER; + } else { + LPCTSTR ext = _tcsrchr(entry->data.cFileName, '.'); + if (!ext) + ext = _T(""); + + if (is_exe_file(ext)) + img = IMG_EXECUTABLE; + else if (is_registered_type(ext)) + img = IMG_DOCUMENT; + else + img = IMG_FILE; + } + } else { + attrs = 0; + img = IMG_NONE; + } + + if (pane->treePane) { + if (entry) { + img_pos = dis->rcItem.left + entry->level*(IMAGE_WIDTH+Globals.spaceSize.cx); + + if (calcWidthCol == -1) { + int x; + int y = dis->rcItem.top + IMAGE_HEIGHT/2; + Entry* up; + RECT rt_clip = {dis->rcItem.left, dis->rcItem.top, dis->rcItem.left+pane->widths[col], dis->rcItem.bottom}; + HRGN hrgn_org = CreateRectRgn(0, 0, 0, 0); + HRGN hrgn = CreateRectRgnIndirect(&rt_clip); + + if (!GetClipRgn(dis->hDC, hrgn_org)) { + DeleteObject(hrgn_org); + hrgn_org = 0; + } + +// HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN)); + ExtSelectClipRgn(dis->hDC, hrgn, RGN_AND); + DeleteObject(hrgn); + + if ((up=entry->up) != NULL) { + MoveToEx(dis->hDC, img_pos-IMAGE_WIDTH/2, y, 0); + LineTo(dis->hDC, img_pos-2, y); + + x = img_pos - IMAGE_WIDTH/2; + + do { + x -= IMAGE_WIDTH+Globals.spaceSize.cx; + + if (up->next +#ifndef _LEFT_FILES + && (up->next->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) +#endif + ) { + MoveToEx(dis->hDC, x, dis->rcItem.top, 0); + LineTo(dis->hDC, x, dis->rcItem.bottom); + } + } while((up=up->up) != NULL); + } + + x = img_pos - IMAGE_WIDTH/2; + + MoveToEx(dis->hDC, x, dis->rcItem.top, 0); + LineTo(dis->hDC, x, y); + + if (entry->next +#ifndef _LEFT_FILES + && (entry->next->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) +#endif + ) + LineTo(dis->hDC, x, dis->rcItem.bottom); + + if (entry->down && entry->expanded) { + x += IMAGE_WIDTH+Globals.spaceSize.cx; + MoveToEx(dis->hDC, x, dis->rcItem.top+IMAGE_HEIGHT, 0); + LineTo(dis->hDC, x, dis->rcItem.bottom); + } + + SelectClipRgn(dis->hDC, hrgn_org); + if (hrgn_org) DeleteObject(hrgn_org); +// SelectObject(dis->hDC, holdPen); + } else if (calcWidthCol==col || calcWidthCol==COLUMNS) { + int right = img_pos + IMAGE_WIDTH - Globals.spaceSize.cx; + + if (right > pane->widths[col]) + pane->widths[col] = right; + } + } else { + img_pos = dis->rcItem.left; + } + } else { + img_pos = dis->rcItem.left; + + if (calcWidthCol==col || calcWidthCol==COLUMNS) + pane->widths[col] = IMAGE_WIDTH; + } + + if (calcWidthCol == -1) { + focusRect.left = img_pos -2; + +#ifdef _NO_EXTENSIONS + if (pane->treePane && entry) { + RECT rt = {0}; + + DrawText(dis->hDC, entry->data.cFileName, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX); + + focusRect.right = dis->rcItem.left+pane->positions[col+1]+Globals.spaceSize.cx + rt.right +2; + } +#else + + if (attrs & FILE_ATTRIBUTE_COMPRESSED) + textcolor = COLOR_COMPRESSED; + else +#endif + textcolor = RGB(0,0,0); + + if (dis->itemState & ODS_FOCUS) { + textcolor = RGB(255,255,255); + bkcolor = COLOR_SELECTION; + } else { + bkcolor = RGB(255,255,255); + } + + hbrush = CreateSolidBrush(bkcolor); + FillRect(dis->hDC, &focusRect, hbrush); + DeleteObject(hbrush); + + SetBkMode(dis->hDC, TRANSPARENT); + SetTextColor(dis->hDC, textcolor); + + cx = pane->widths[col]; + + if (cx && img!=IMG_NONE) { + if (cx > IMAGE_WIDTH) + cx = IMAGE_WIDTH; + + ImageList_DrawEx(Globals.himl, img, dis->hDC, + img_pos, dis->rcItem.top, cx, + IMAGE_HEIGHT, bkcolor, CLR_DEFAULT, ILD_NORMAL); + } + } + + if (!entry) + return; + +#ifdef _NO_EXTENSIONS + if (img >= IMG_FOLDER_UP) + return; +#endif + + col++; + + // ouput file name + if (calcWidthCol == -1) + output_text(pane, dis, col, entry->data.cFileName, 0); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, entry->data.cFileName); + + col++; + +#ifdef _NO_EXTENSIONS + if (!pane->treePane) { +#endif + + // display file size + if (visible_cols & COL_SIZE) { +#ifdef _NO_EXTENSIONS + if (!(attrs&FILE_ATTRIBUTE_DIRECTORY)) +#endif + { + QWORD size; + + *(DWORD*)(&size) = entry->data.nFileSizeLow; //TODO: platform spefific + *(((DWORD*)&size)+1) = entry->data.nFileSizeHigh; + + _stprintf(buffer, _T("%") LONGLONGARG _T("d"), size); + + if (calcWidthCol == -1) + output_number(pane, dis, col, buffer); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, buffer);//TODO: not ever time enough + } + + col++; + } + + // display file date + if (visible_cols & (COL_DATE|COL_TIME)) { +#ifndef _NO_EXTENSIONS + format_date(&entry->data.ftCreationTime, buffer, visible_cols); + if (calcWidthCol == -1) + output_text(pane, dis, col, buffer, 0); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, buffer); + col++; + + format_date(&entry->data.ftLastAccessTime, buffer, visible_cols); + if (calcWidthCol == -1) + output_text(pane, dis, col, buffer, 0); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, buffer); + col++; +#endif + + format_date(&entry->data.ftLastWriteTime, buffer, visible_cols); + if (calcWidthCol == -1) + output_text(pane, dis, col, buffer, 0); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, buffer); + col++; + } + +#ifndef _NO_EXTENSIONS + if (entry->bhfi_valid) { + ((DWORD*)&index)[0] = entry->bhfi.nFileIndexLow; //TODO: platform spefific + ((DWORD*)&index)[1] = entry->bhfi.nFileIndexHigh; + + if (visible_cols & COL_INDEX) { + _stprintf(buffer, _T("%") LONGLONGARG _T("X"), index); + if (calcWidthCol == -1) + output_text(pane, dis, col, buffer, DT_RIGHT); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, buffer); + col++; + } + + if (visible_cols & COL_LINKS) { + wsprintf(buffer, _T("%d"), entry->bhfi.nNumberOfLinks); + if (calcWidthCol == -1) + output_text(pane, dis, col, buffer, DT_CENTER); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_width(pane, dis, col, buffer); + col++; + } + } else + col += 2; +#endif + + // show file attributes + if (visible_cols & COL_ATTRIBUTES) { +#ifdef _NO_EXTENSIONS + _tcscpy(buffer, _T(" \t \t \t \t ")); +#else + _tcscpy(buffer, _T(" \t \t \t \t \t \t \t \t \t \t \t ")); +#endif + + if (attrs & FILE_ATTRIBUTE_NORMAL) buffer[ 0] = 'N'; + else { + if (attrs & FILE_ATTRIBUTE_READONLY) buffer[ 2] = 'R'; + if (attrs & FILE_ATTRIBUTE_HIDDEN) buffer[ 4] = 'H'; + if (attrs & FILE_ATTRIBUTE_SYSTEM) buffer[ 6] = 'S'; + if (attrs & FILE_ATTRIBUTE_ARCHIVE) buffer[ 8] = 'A'; + if (attrs & FILE_ATTRIBUTE_COMPRESSED) buffer[10] = 'C'; +#ifndef _NO_EXTENSIONS + if (attrs & FILE_ATTRIBUTE_DIRECTORY) buffer[12] = 'D'; + if (attrs & FILE_ATTRIBUTE_ENCRYPTED) buffer[14] = 'E'; + if (attrs & FILE_ATTRIBUTE_TEMPORARY) buffer[16] = 'T'; + if (attrs & FILE_ATTRIBUTE_SPARSE_FILE) buffer[18] = 'P'; + if (attrs & FILE_ATTRIBUTE_REPARSE_POINT) buffer[20] = 'Q'; + if (attrs & FILE_ATTRIBUTE_OFFLINE) buffer[22] = 'O'; + if (attrs & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) buffer[24] = 'X'; +#endif + } + + if (calcWidthCol == -1) + output_tabbed_text(pane, dis, col, buffer); + else if (calcWidthCol==col || calcWidthCol==COLUMNS) + calc_tabbed_width(pane, dis, col, buffer); + + col++; + } + +/*TODO + if (flags.security) { + DWORD rights = get_access_mask(); + + tcscpy(buffer, _T(" \t \t \t \t \t \t \t \t \t \t \t ")); + + if (rights & FILE_READ_DATA) buffer[ 0] = 'R'; + if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W'; + if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A'; + if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';} + if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';} + if (rights & FILE_EXECUTE) buffer[12] = 'X'; + if (rights & FILE_DELETE_CHILD) buffer[14] = 'D'; + if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';} + if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';} + if (rights & WRITE_DAC) buffer[22] = 'C'; + if (rights & WRITE_OWNER) buffer[24] = 'O'; + if (rights & SYNCHRONIZE) buffer[26] = 'S'; + + output_text(dis, col++, buffer, DT_LEFT, 3, psize); + } + + if (flags.description) { + get_description(buffer); + output_text(dis, col++, buffer, 0, psize); + } +*/ + +#ifdef _NO_EXTENSIONS + } + + // draw focus frame + if ((dis->itemState&ODS_FOCUS) && calcWidthCol==-1) { + // Currently [04/2000] Wine neither behaves exactly the same + // way as WIN 95 nor like Windows NT... +#ifdef WINELIB + DrawFocusRect(dis->hDC, &focusRect); +#else + HGDIOBJ lastBrush; + HPEN lastPen; + HPEN hpen; + + if (!(GetVersion() & 0x80000000)) { // Windows NT? + LOGBRUSH lb = {PS_SOLID, RGB(255,255,255)}; + hpen = ExtCreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &lb, 0, 0); + } else + hpen = CreatePen(PS_DOT, 0, RGB(255,255,255)); + + lastPen = SelectPen(dis->hDC, hpen); + lastBrush = SelectObject(dis->hDC, GetStockObject(HOLLOW_BRUSH)); + SetROP2(dis->hDC, R2_XORPEN); + Rectangle(dis->hDC, focusRect.left, focusRect.top, focusRect.right, focusRect.bottom); + SelectObject(dis->hDC, lastBrush); + SelectObject(dis->hDC, lastPen); + DeleteObject(hpen); +#endif + } +#endif +#endif +} + + + +#ifdef _NO_EXTENSIONS + +void draw_splitbar(HWND hwnd, int x) +{ + RECT rt; + HDC hdc = GetDC(hwnd); + + GetClientRect(hwnd, &rt); + rt.left = x - SPLIT_WIDTH/2; + rt.right = x + SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + ReleaseDC(hwnd, hdc); +} + +#endif + diff --git a/rosapps/winfile/draw.h b/rosapps/winfile/draw.h new file mode 100644 index 00000000000..27087734bfd --- /dev/null +++ b/rosapps/winfile/draw.h @@ -0,0 +1,41 @@ +/* + * ReactOS File Manager + * + * draw.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __DRAW_H__ +#define __DRAW_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +void draw_item(Pane* pane, LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol); +void draw_splitbar(HWND hwnd, int x); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __DRAW_H__ \ No newline at end of file diff --git a/rosapps/winfile/drivebar.bmp b/rosapps/winfile/drivebar.bmp new file mode 100644 index 00000000000..d4fbc511eba Binary files /dev/null and b/rosapps/winfile/drivebar.bmp differ diff --git a/rosapps/winfile/entries.c b/rosapps/winfile/entries.c new file mode 100644 index 00000000000..276c0b6491d --- /dev/null +++ b/rosapps/winfile/entries.c @@ -0,0 +1,374 @@ +/* + * ReactOS winfile + * + * entries.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include + +#include "winfile.h" +#include "entries.h" +#include "utils.h" + + + +Entry* find_entry_win(Entry* parent, LPCTSTR name) +{ + Entry* entry; + + for(entry=parent->down; entry; entry=entry->next) { + LPCTSTR p = name; + LPCTSTR q = entry->data.cFileName; + + do { + if (!*p || *p==_T('\\') || *p==_T('/')) + return entry; + } while(tolower(*p++) == tolower(*q++)); + + p = name; + q = entry->data.cAlternateFileName; + + do { + if (!*p || *p==_T('\\') || *p==_T('/')) + return entry; + } while(tolower(*p++) == tolower(*q++)); + } + + return 0; +} + + +Entry* read_tree_win(Root* root, LPCTSTR path, int sortOrder) +{ + TCHAR buffer[MAX_PATH]; + Entry* entry = &root->entry; + LPCTSTR s = path; + PTSTR d = buffer; + +#ifndef _NO_EXTENSIONS + entry->unix_dir = FALSE; +#endif + + while(entry) { + while(*s && *s!=_T('\\') && *s!=_T('/')) + *d++ = *s++; + + while(*s==_T('\\') || *s==_T('/')) + s++; + + *d++ = _T('\\'); + *d = _T('\0'); + + read_directory(entry, buffer, sortOrder); + + if (entry->down) + entry->expanded = TRUE; + + if (!*s) + break; + + entry = find_entry_win(entry, s); + } + + return entry; +} + + +#if !defined(_NO_EXTENSIONS) && defined(__linux__) + +static Entry* find_entry_unix(Entry* parent, LPCTSTR name) +{ + Entry* entry; + + for(entry=parent->down; entry; entry=entry->next) { + LPCTSTR p = name; + LPCTSTR q = entry->data.cFileName; + + do { + if (!*p || *p==_T('/')) + return entry; + } while(*p++ == *q++); + } + + return 0; +} + +static Entry* read_tree_unix(Root* root, LPCTSTR path, int sortOrder) +{ + TCHAR buffer[MAX_PATH]; + Entry* entry = &root->entry; + LPCTSTR s = path; + PTSTR d = buffer; + + entry->unix_dir = TRUE; + + while(entry) { + while(*s && *s!=_T('/')) + *d++ = *s++; + + while(*s == _T('/')) + s++; + + *d++ = _T('/'); + *d = _T('\0'); + + read_directory(entry, buffer, sortOrder); + + if (entry->down) + entry->expanded = TRUE; + + if (!*s) + break; + + entry = find_entry_unix(entry, s); + } + + return entry; +} + +#endif + + + // recursively free all child entries +void free_entries(Entry* parent) +{ + Entry *entry, *next=parent->down; + + if (next) { + parent->down = 0; + + do { + entry = next; + next = entry->next; + + free_entries(entry); + free(entry); + } while(next); + } +} + + + +// insert listbox entries after index idx +void insert_entries(Pane* pane, Entry* parent, int idx) +{ + Entry* entry = parent; + + if (!entry) + return; + + ShowWindow(pane->hwnd, SW_HIDE); + + for(; entry; entry=entry->next) { +#ifndef _LEFT_FILES + if (pane->treePane && !(entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) + continue; +#endif + + // don't display entries "." and ".." in the left pane + if (pane->treePane && (entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) + && entry->data.cFileName[0]==_T('.')) + if ( +#ifndef _NO_EXTENSIONS + entry->data.cFileName[1]==_T('\0') || +#endif + (entry->data.cFileName[1]==_T('.') && entry->data.cFileName[2]==_T('\0'))) + continue; + + if (idx != -1) + idx++; + + ListBox_InsertItemData(pane->hwnd, idx, entry); + + if (pane->treePane && entry->expanded) + insert_entries(pane, entry->down, idx); + } + + ShowWindow(pane->hwnd, SW_SHOW); +} + + +void scan_entry(ChildWnd* child, Entry* entry) +{ + TCHAR path[MAX_PATH]; + int idx = ListBox_GetCurSel(child->left.hwnd); + HCURSOR crsrOld = SetCursor(LoadCursor(0, IDC_WAIT)); + + // delete sub entries in left pane + for(;;) { + LRESULT res = ListBox_GetItemData(child->left.hwnd, idx+1); + Entry* sub = (Entry*) res; + + if (res==LB_ERR || !sub || sub->level<=entry->level) + break; + + ListBox_DeleteString(child->left.hwnd, idx+1); + } + + // empty right pane + ListBox_ResetContent(child->right.hwnd); + + // release memory + free_entries(entry); + + // read contents from disk + get_path(entry, path); + read_directory(entry, path, child->sortOrder); + + // insert found entries in right pane + insert_entries(&child->right, entry->down, -1); + calc_widths(&child->right, FALSE); +#ifndef _NO_EXTENSIONS + set_header(&child->right); +#endif + + child->header_wdths_ok = FALSE; + + SetCursor(crsrOld); +} + + +// expand a directory entry +BOOL expand_entry(ChildWnd* child, Entry* dir) +{ + int idx; + Entry* p; + + if (!dir || dir->expanded || !dir->down) + return FALSE; + + p = dir->down; + + if (p->data.cFileName[0]=='.' && p->data.cFileName[1]=='\0' && p->next) { + p = p->next; + + if (p->data.cFileName[0]=='.' && p->data.cFileName[1]=='.' && + p->data.cFileName[2]=='\0' && p->next) + p = p->next; + } + + // no subdirectories ? + if (!(p->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) + return FALSE; + + idx = ListBox_FindItemData(child->left.hwnd, 0, dir); + + dir->expanded = TRUE; + + // insert entries in left pane + insert_entries(&child->left, p, idx); + + if (!child->header_wdths_ok) { + if (calc_widths(&child->left, FALSE)) { +#ifndef _NO_EXTENSIONS + set_header(&child->left); +#endif + + child->header_wdths_ok = TRUE; + } + } + + return TRUE; +} + + +void collapse_entry(Pane* pane, Entry* dir) +{ + int idx = ListBox_FindItemData(pane->hwnd, 0, dir); + + ShowWindow(pane->hwnd, SW_HIDE); + + // hide sub entries + for(;;) { + LRESULT res = ListBox_GetItemData(pane->hwnd, idx+1); + Entry* sub = (Entry*) res; + + if (res==LB_ERR || !sub || sub->level<=dir->level) + break; + + ListBox_DeleteString(pane->hwnd, idx+1); + } + + dir->expanded = FALSE; + + ShowWindow(pane->hwnd, SW_SHOW); +} + + +void activate_entry(ChildWnd* child, Pane* pane) +{ + Entry* entry = pane->cur; + + if (!entry) + return; + + if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + int scanned_old = entry->scanned; + + if (!scanned_old) + scan_entry(child, entry); + +#ifndef _NO_EXTENSIONS + if (entry->data.cFileName[0]=='.' && entry->data.cFileName[1]=='\0') + return; +#endif + + if (entry->data.cFileName[0]=='.' && entry->data.cFileName[1]=='.' && entry->data.cFileName[2]=='\0') { + entry = child->left.cur->up; + collapse_entry(&child->left, entry); + goto focus_entry; + } else if (entry->expanded) + collapse_entry(pane, child->left.cur); + else { + expand_entry(child, child->left.cur); + + if (!pane->treePane) focus_entry: { + int idx = ListBox_FindItemData(child->left.hwnd, ListBox_GetCurSel(child->left.hwnd), entry); + ListBox_SetCurSel(child->left.hwnd, idx); + set_curdir(child, entry); + } + } + + if (!scanned_old) { + calc_widths(pane, FALSE); + +#ifndef _NO_EXTENSIONS + set_header(pane); +#endif + } + } else { + + //TODO: start program, open document... + + } +} diff --git a/rosapps/winfile/entries.h b/rosapps/winfile/entries.h new file mode 100644 index 00000000000..4b40a96c90a --- /dev/null +++ b/rosapps/winfile/entries.h @@ -0,0 +1,125 @@ +/* + * ReactOS winfile + * + * entries.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __ENTRIES_H__ +#define __ENTRIES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + + +typedef struct _Entry { + struct _Entry* next; + struct _Entry* down; + struct _Entry* up; + + BOOL expanded; + BOOL scanned; + int level; + + WIN32_FIND_DATA data; + +#ifndef _NO_EXTENSIONS + BY_HANDLE_FILE_INFORMATION bhfi; + BOOL bhfi_valid; + BOOL unix_dir; +#endif +} Entry; + + +typedef enum { + SORT_NAME, + SORT_EXT, + SORT_SIZE, + SORT_DATE +} SORT_ORDER; + +//enum SORT_ORDER { SORT_BY_NAME, SORT_BY_TYPE, SORT_BY_SIZE, SORT_BY_DATE }; + +typedef struct { + Entry entry; + TCHAR path[MAX_PATH]; + TCHAR volname[_MAX_FNAME]; + TCHAR fs[_MAX_DIR]; + DWORD drive_type; + DWORD fs_flags; +} Root; + + +typedef struct { + HWND hwnd; +#ifndef _NO_EXTENSIONS + HWND hwndHeader; +#endif + +#ifndef _NO_EXTENSIONS +#define COLUMNS 10 +#else +#define COLUMNS 5 +#endif + int widths[COLUMNS]; + int positions[COLUMNS+1]; + + BOOL treePane; + int visible_cols; + Entry* root; + Entry* cur; +} Pane; + +typedef struct { + HWND hwnd; + Pane left; + Pane right; + int focus_pane; // 0: left 1: right + WINDOWPLACEMENT pos; + int split_pos; + BOOL header_wdths_ok; + + TCHAR path[MAX_PATH]; + Root root; + + SORT_ORDER sortOrder; +} ChildWnd; + + +void insert_entries(Pane* pane, Entry* parent, int idx); +void scan_entry(ChildWnd* child, Entry* entry); +void activate_entry(ChildWnd* child, Pane* pane); +void collapse_entry(Pane* pane, Entry* dir); +BOOL expand_entry(ChildWnd* child, Entry* dir); +Entry* find_entry_win(Entry* parent, LPCTSTR name); +void free_entries(Entry* parent); +Entry* read_tree_win(Root* root, LPCTSTR path, int sortOrder); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __ENTRIES_H__ diff --git a/rosapps/winfile/format.h b/rosapps/winfile/format.h new file mode 100644 index 00000000000..4539d3b6d65 --- /dev/null +++ b/rosapps/winfile/format.h @@ -0,0 +1,92 @@ +#if !defined(SHFMT_OPT_FULL) + + #if defined (__cplusplus) + extern "C" { + #endif + + /***************************************************************** + The SHFormatDrive API provides access to the Shell's format + dialog box. This allows applications that want to format disks to bring + up the same dialog box that the Shell uses for disk formatting. + + PARAMETERS + hwnd = The window handle of the window that will own the + dialog. NOTE that hwnd == NULL does not cause this + dialog to come up as a "top level application" + window. This parameter should always be non-null, + this dialog box is only designed to be the child of + another window, not a stand-alone application. + + drive = The 0 based (A: == 0) drive number of the drive + to format. + + fmtID = Currently must be set to SHFMT_ID_DEFAULT. + + options = There are currently only two option bits defined. + + SHFMT_OPT_FULL + SHFMT_OPT_SYSONLY + + SHFMT_OPT_FULL specifies that the "Quick Format" + setting should be cleared by default. If the user + leaves the "Quick Format" setting cleared, then a + full format will be applied (this is useful for + users that detect "unformatted" disks and want + to bring up the format dialog box). + + If options is set to zero (0), then the "Quick Format" + setting is set by default. In addition, if the user leaves + it set, a quick format is performed. Under Windows NT 4.0, + this flag is ignored and the "Quick Format" box is always + checked when the dialog box first appears. The user can + still change it. This is by design. + + The SHFMT_OPT_SYSONLY initializes the dialog to + default to just sys the disk. + + All other bits are reserved for future expansion + and must be 0. + + Please note that this is a bit field and not a + value, treat it accordingly. + + RETURN + The return is either one of the SHFMT_* values, or if + the returned DWORD value is not == to one of these + values, then the return is the physical format ID of the + last successful format. The LOWORD of this value can be + passed on subsequent calls as the fmtID parameter to + "format the same type you did last time". + + *****************************************************************/ + DWORD WINAPI SHFormatDrive(HWND hwnd, + UINT drive, + UINT fmtID, + UINT options); + + // + // Special value of fmtID which means "use the defaultformat" + // + + #define SHFMT_ID_DEFAULT 0xFFFF + + // + // Option bits for options parameter + // + + #define SHFMT_OPT_FULL 0x0001 + #define SHFMT_OPT_SYSONLY 0x0002 + + // + // Special return values. PLEASE NOTE that these are DWORD values. + // + + #define SHFMT_ERROR 0xFFFFFFFFL // Error on last format, + // drive may be formatable + #define SHFMT_CANCEL 0xFFFFFFFEL // Last format wascanceled + #define SHFMT_NOFORMAT 0xFFFFFFFDL // Drive is not formatable + + #if defined (__cplusplus) + } + #endif + #endif \ No newline at end of file diff --git a/rosapps/winfile/images.bmp b/rosapps/winfile/images.bmp new file mode 100644 index 00000000000..22e15f48934 Binary files /dev/null and b/rosapps/winfile/images.bmp differ diff --git a/rosapps/winfile/listview.c b/rosapps/winfile/listview.c new file mode 100644 index 00000000000..f437e758a23 --- /dev/null +++ b/rosapps/winfile/listview.c @@ -0,0 +1,250 @@ +/* + * ReactOS winfile + * + * listview.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +//#include +#include +#include +#include +#include +#define ASSERT assert + +#include "winfile.h" +#include "listview.h" +//#include "entries.h" +#include "utils.h" + + +// Global Variables: +extern HINSTANCE hInst; + + +HWND CreateListView(HWND hwndParent, LPSTR lpszFileName) +{ + RECT rcClient; // dimensions of client area + HWND hwndLV; // handle to list view control + + // Get the dimensions of the parent window's client area, and create the list view control. + GetClientRect(hwndParent, &rcClient); + hwndLV = CreateWindowEx(0, WC_LISTVIEW, "List View", + WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES, + 0, 0, rcClient.right, rcClient.bottom, + hwndParent, (HMENU)LIST_WINDOW, hInst, NULL); + + // Initialize the image list, and add items to the control. +/* + if (!InitListViewImageLists(hwndLV) || + !InitListViewItems(hwndLV, lpszFileName)) { + DestroyWindow(hwndLV); + return FALSE; + } + */ + return hwndLV; +} + +const static LPTSTR g_pos_names[COLUMNS] = { + _T(""), // symbol + _T("Name"), + _T("Size"), + _T("CDate"), +#ifndef _NO_EXTENSIONS + _T("ADate"), + _T("MDate"), + _T("Index/Inode"), + _T("Links"), +#endif + _T("Attributes"), +#ifndef _NO_EXTENSIONS + _T("Security") +#endif +}; + +const static int g_pos_align[] = { + 0, + HDF_LEFT, // Name + HDF_RIGHT, // Size + HDF_LEFT, // CDate +#ifndef _NO_EXTENSIONS + HDF_LEFT, // ADate + HDF_LEFT, // MDate + HDF_LEFT, // Index + HDF_CENTER, // Links +#endif + HDF_CENTER, // Attributes +#ifndef _NO_EXTENSIONS + HDF_LEFT // Security +#endif +}; + +void resize_tree(ChildWnd* child, int cx, int cy) +{ + HDWP hdwp = BeginDeferWindowPos(4); + RECT rt = {0, 0, cx, cy}; + + cx = child->split_pos + SPLIT_WIDTH/2; + +#ifndef _NO_EXTENSIONS + { + WINDOWPOS wp; + HD_LAYOUT hdl = {&rt, &wp}; + + Header_Layout(child->left.hwndHeader, &hdl); + + DeferWindowPos(hdwp, child->left.hwndHeader, wp.hwndInsertAfter, + wp.x-1, wp.y, child->split_pos-SPLIT_WIDTH/2+1, wp.cy, wp.flags); + DeferWindowPos(hdwp, child->right.hwndHeader, wp.hwndInsertAfter, + rt.left+cx+1, wp.y, wp.cx-cx+2, wp.cy, wp.flags); + } +#endif + + 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); + DeferWindowPos(hdwp, child->right.hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); + + EndDeferWindowPos(hdwp); +} + + +#ifndef _NO_EXTENSIONS + +HWND create_header(HWND parent, Pane* pane, int id) +{ + HD_ITEM hdi = {HDI_TEXT|HDI_WIDTH|HDI_FORMAT}; + int idx; + + HWND hwnd = CreateWindow(WC_HEADER, 0, WS_CHILD|WS_VISIBLE|HDS_HORZ/*TODO: |HDS_BUTTONS + sort orders*/, + 0, 0, 0, 0, parent, (HMENU)id, Globals.hInstance, 0); + if (!hwnd) + return 0; + + SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), FALSE); + + for(idx=0; idxwidths[idx]; + Header_InsertItem(hwnd, idx, &hdi); + } + + return hwnd; +} + +#endif + + +//////////////////////////////////////////////////////////////////////////////// +static WNDPROC g_orgListWndProc; + +LRESULT CALLBACK ListWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + ChildWnd* child = (ChildWnd*)GetWindowLong(GetParent(hwnd), GWL_USERDATA); + Pane* pane = (Pane*)GetWindowLong(hwnd, GWL_USERDATA); + ASSERT(child); + + switch(nmsg) { +#ifndef _NO_EXTENSIONS + case WM_HSCROLL: + set_header(pane); + break; +#endif + + case WM_SETFOCUS: + child->focus_pane = pane==&child->right? 1: 0; + ListBox_SetSel(hwnd, TRUE, 1); + //TODO: check menu items + break; + + case WM_KEYDOWN: + if (wparam == VK_TAB) { + //TODO: SetFocus(Globals.hDriveBar) + SetFocus(child->focus_pane? child->left.hwnd: child->right.hwnd); + } + } + + return CallWindowProc(g_orgListWndProc, hwnd, nmsg, wparam, lparam); +} + + +static void init_output(HWND hwnd) +{ + TCHAR b[16]; + HFONT old_font; + HDC hdc = GetDC(hwnd); + + if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, _T("1000"), 0, b, 16) > 4) + Globals.num_sep = b[1]; + else + Globals.num_sep = _T('.'); + + old_font = SelectFont(hdc, Globals.hFont); + GetTextExtentPoint32(hdc, _T(" "), 1, &Globals.spaceSize); + SelectFont(hdc, old_font); + ReleaseDC(hwnd, hdc); +} + + +void create_list_window(HWND parent, Pane* pane, int id, int id_header) +{ + static int s_init = 0; + Entry* entry = pane->root; + + pane->hwnd = CreateWindow(_T("ListBox"), _T(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL| + LBS_DISABLENOSCROLL|LBS_NOINTEGRALHEIGHT|LBS_OWNERDRAWFIXED|LBS_NOTIFY, + 0, 0, 0, 0, parent, (HMENU)id, Globals.hInstance, 0); + + SetWindowLong(pane->hwnd, GWL_USERDATA, (LPARAM)pane); + g_orgListWndProc = SubclassWindow(pane->hwnd, ListWndProc); + + SendMessage(pane->hwnd, WM_SETFONT, (WPARAM)Globals.hFont, FALSE); + + // insert entries into listbox + if (entry) + insert_entries(pane, entry, -1); + + // calculate column widths + if (!s_init) { + s_init = 1; + init_output(pane->hwnd); + } + + calc_widths(pane, TRUE); + +#ifndef _NO_EXTENSIONS + pane->hwndHeader = create_header(parent, pane, id_header); +#endif +} + + + diff --git a/rosapps/winfile/listview.h b/rosapps/winfile/listview.h index 9e870786330..467d8506ebe 100644 --- a/rosapps/winfile/listview.h +++ b/rosapps/winfile/listview.h @@ -20,8 +20,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __WINFILE_LISTVIEW_H__ -#define __WINFILE_LISTVIEW_H__ +#ifndef __LISTVIEW_H__ +#define __LISTVIEW_H__ + +#ifdef __cplusplus +extern "C" { +#endif #if _MSC_VER > 1000 #pragma once @@ -30,9 +34,16 @@ #include "resource.h" - HWND CreateListView(HWND hwndParent, LPSTR lpszFileName); +HWND create_header(HWND parent, Pane* pane, int id); +void resize_tree(ChildWnd* child, int cx, int cy); + +void create_list_window(HWND parent, Pane* pane, int id, int id_header); +LRESULT CALLBACK ListWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); +#ifdef __cplusplus +}; +#endif -#endif // __WINFILE_LISTVIEW_H__ +#endif // __LISTVIEW_H__ diff --git a/rosapps/winfile/main.c b/rosapps/winfile/main.c new file mode 100644 index 00000000000..9b7b36ea885 --- /dev/null +++ b/rosapps/winfile/main.c @@ -0,0 +1,343 @@ +/* + * ReactOS winfile + * + * main.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include + +#include "winfile.h" +#include "about.h" +#include "mdiclient.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +WINFILE_GLOBALS Globals; + +HINSTANCE hInst; // current instance + +TCHAR szTitle[MAX_LOADSTRING]; // The title bar text +TCHAR szWindowClass[MAX_LOADSTRING]; +TCHAR szFrameClass[MAX_LOADSTRING]; +//TCHAR szChildClass[MAX_LOADSTRING]; + + +//////////////////////////////////////////////////////////////////////////////// +// +// +// FUNCTION: InitInstance(HANDLE, int) +// +// PURPOSE: Saves instance handle and creates main window +// +// COMMENTS: +// +// In this function, we save the instance handle in a global variable and +// create and display the main program window. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + char path[MAX_PATH]; + int nParts[3]; + ChildWnd* child; + + WNDCLASSEX wcFrame = { + sizeof(WNDCLASSEX), + 0/*style*/, + WndProc, + 0/*cbClsExtra*/, + 0/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINFILE)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szWindowClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_WINFILE), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + }; + ATOM hWndClass = RegisterClassEx(&wcFrame); // register frame window class + + WNDCLASS wcChild = { + CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW, + ChildWndProc, + 0/*cbClsExtra*/, + 0/*cbWndExtra*/, + hInstance, + 0/*hIcon*/, + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szFrameClass + }; + + ATOM hChildClass = RegisterClass(&wcChild); // register child windows class + + HMENU hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_WINFILE)); + HMENU hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2); + + CLIENTCREATESTRUCT ccs = { + hMenuWindow, IDW_FIRST_CHILD + }; + + INITCOMMONCONTROLSEX icc = { + sizeof(INITCOMMONCONTROLSEX), + ICC_BAR_CLASSES + }; + +// TCHAR path[MAX_PATH]; + + HDC hdc = GetDC(0); + +// hMenuFrame = hMenuFrame; + Globals.hMenuView = GetSubMenu(hMenuFrame, 3); + Globals.hMenuOptions = GetSubMenu(hMenuFrame, 4); + Globals.hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINFILE)); + Globals.hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif")); + ReleaseDC(0, hdc); + + Globals.hMainWnd = CreateWindowEx(0, (LPCTSTR)(int)hWndClass, szTitle, + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + 0/*hWndParent*/, hMenuFrame, hInstance, 0/*lpParam*/); + if (!Globals.hMainWnd) { + return FALSE; + } + + Globals.hMDIClient = CreateWindowEx(0, _T("MDICLIENT"), NULL, +// Globals.hMDIClient = CreateWindowEx(0, (LPCTSTR)(int)hChildClass, NULL, + WS_CHILD|WS_CLIPCHILDREN|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE|WS_BORDER, + 0, 0, 0, 0, + Globals.hMainWnd, 0, hInstance, &ccs); + if (!Globals.hMDIClient) { + return FALSE; + } + + InitCommonControlsEx(&icc); + + { + TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP}; + int btn = 1; + PTSTR p; + + Globals.hDriveBar = CreateToolbarEx(Globals.hMainWnd, WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST, + IDW_DRIVEBAR, 2, hInstance, IDB_DRIVEBAR, &drivebarBtn, + 1, 16, 13, 16, 13, sizeof(TBBUTTON)); +// CheckMenuItem(hMenuFrame, ID_OPTIONS_DRIVEBAR, MF_BYCOMMAND|MF_CHECKED); + CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_DRIVEBAR, MF_BYCOMMAND|MF_CHECKED); + GetLogicalDriveStrings(BUFFER_LEN, Globals.drives); + drivebarBtn.fsStyle = TBSTYLE_BUTTON; +#ifndef _NO_EXTENSIONS + // register windows drive root strings + SendMessage(Globals.hDriveBar, TB_ADDSTRING, 0, (LPARAM)Globals.drives); +#endif + drivebarBtn.idCommand = ID_DRIVE_FIRST; + for( p = Globals.drives; *p; ) { +#ifdef _NO_EXTENSIONS + // insert drive letter + TCHAR b[3] = { tolower(*p) }; + SendMessage(Globals.hDriveBar, TB_ADDSTRING, 0, (LPARAM)b); +#endif + switch(GetDriveType(p)) { + case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break; + case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break; + case DRIVE_REMOTE: drivebarBtn.iBitmap = 4; break; + case DRIVE_RAMDISK: drivebarBtn.iBitmap = 5; break; + default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2; + } + SendMessage(Globals.hDriveBar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn); + drivebarBtn.idCommand++; + drivebarBtn.iString++; + while(*p++); + } + } + { + TBBUTTON toolbarBtns[] = { + {0, 0, 0, TBSTYLE_SEP}, + {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON}, + }; + + Globals.hToolBar = CreateToolbarEx(Globals.hMainWnd, WS_CHILD|WS_VISIBLE, + IDW_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns, + sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON)); + CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED); + } + + // Create the status bar + Globals.hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, + "", Globals.hMainWnd, STATUS_WINDOW); + if (!Globals.hStatusBar) + return FALSE; + CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); + + // Create the status bar panes + nParts[0] = 100; + nParts[1] = 210; + nParts[2] = 400; + SendMessage(Globals.hStatusBar, SB_SETPARTS, 3, (long)nParts); + +#if 1 + //Globals.hstatusbar = CreateStatusWindow(WS_CHILD|WS_VISIBLE, 0, Globals.Globals.hMainWnd, IDW_STATUSBAR); + //CheckMenuItem(Globals.Globals.hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); + +/* CreateStatusWindow does not accept WS_BORDER +/* + Globals.hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0, + WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0, + Globals.Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/ + + //TODO: read paths and window placements from registry + + GetCurrentDirectory(MAX_PATH, path); + child = alloc_child_window(path); + + child->pos.showCmd = SW_SHOWMAXIMIZED; + child->pos.rcNormalPosition.left = 0; + child->pos.rcNormalPosition.top = 0; + child->pos.rcNormalPosition.right = 320; + child->pos.rcNormalPosition.bottom = 280; + + if (!create_child_window(child)) + free(child); + + SetWindowPlacement(child->hwnd, &child->pos); + Globals.himl = ImageList_LoadBitmap(Globals.hInstance, MAKEINTRESOURCE(IDB_IMAGES), 16, 0, RGB(0,255,0)); + Globals.prescan_node = FALSE; +#endif + +/* + hSplitWnd = CreateWindow(szFrameClass, "splitter window", WS_VISIBLE|WS_CHILD, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, + Globals.hMainWnd, (HMENU)SPLIT_WINDOW, hInstance, NULL); + if (!hSplitWnd) + return FALSE; + hTreeWnd = CreateTreeView(Globals.hMDIClient, "c:\\foobar.txt"); + if (!hTreeWnd) + return FALSE; + + hListWnd = CreateListView(Globals.hMDIClient, ""); + if (!hListWnd) + return FALSE; + */ + ShowWindow(Globals.hMainWnd, nCmdShow); + UpdateWindow(Globals.hMainWnd); + return TRUE; +} + + + + +#ifdef _NO_EXTENSIONS + +static int g_foundPrevInstance = 0; + +// search for already running win[e]files +static BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lparam) +{ + TCHAR cls[128]; + + GetClassName(hwnd, cls, 128); + if (!lstrcmp(cls, (LPCTSTR)lparam)) { + g_foundPrevInstance++; + return FALSE; + } + return TRUE; +} + +#endif + +void ExitInstance() +{ + if (Globals.himl) + ImageList_Destroy(Globals.himl); +} + + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + MSG msg; + HACCEL hAccel; + + hInst = hInstance; // Store instance handle in our global variable + + // Initialize global strings + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadString(hInstance, IDC_WINFILE, szWindowClass, MAX_LOADSTRING); + LoadString(hInstance, IDC_WINFILE_FRAME, szFrameClass, MAX_LOADSTRING); + +#ifdef _NO_EXTENSIONS + // allow only one running instance + EnumWindows(EnumWndProc, (LPARAM)szWindowClass); + if (g_foundPrevInstance) + return 1; +#endif + + // Perform application initialization: + if (!InitInstance(hInstance, nCmdShow)) { + return FALSE; + } + + hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_WINFILE); + + // Main message loop: +#if 0 + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } +#else + while (GetMessage(&msg, (HWND)NULL, 0, 0)) { + if (!TranslateMDISysAccel(Globals.hMDIClient, &msg) && + !TranslateAccelerator(Globals.hMainWnd/*hwndFrame*/, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } +#endif + ExitInstance(); + return msg.wParam; +} + + diff --git a/rosapps/winfile/mdiclient.c b/rosapps/winfile/mdiclient.c new file mode 100644 index 00000000000..ca0110b4dbc --- /dev/null +++ b/rosapps/winfile/mdiclient.c @@ -0,0 +1,599 @@ +/* + * ReactOS winfile + * + * mdiclient.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +//#include +#include +#include +#include +#include +#define ASSERT assert + +#include "winfile.h" +#include "about.h" +#include "mdiclient.h" +#include "subframe.h" +#include "run.h" +#include "utils.h" +#include "treeview.h" +#include "listview.h" +#include "debug.h" +#include "draw.h" + + +#ifdef _NO_EXTENSIONS +#define COLOR_SPLITBAR WHITE_BRUSH +#else +#define COLOR_SPLITBAR LTGRAY_BRUSH +#endif + + +ChildWnd* alloc_child_window(LPCTSTR path) +{ + TCHAR drv[_MAX_DRIVE+1], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT]; + ChildWnd* child = (ChildWnd*) malloc(sizeof(ChildWnd)); + Root* root = &child->root; + Entry* entry; + + memset(child, 0, sizeof(ChildWnd)); + + child->left.treePane = TRUE; + child->left.visible_cols = 0; + + child->right.treePane = FALSE; +#ifndef _NO_EXTENSIONS + child->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS; +#else + child->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES; +#endif + + child->pos.length = sizeof(WINDOWPLACEMENT); + child->pos.flags = 0; + child->pos.showCmd = SW_SHOWNORMAL; + child->pos.rcNormalPosition.left = CW_USEDEFAULT; + child->pos.rcNormalPosition.top = CW_USEDEFAULT; + child->pos.rcNormalPosition.right = CW_USEDEFAULT; + child->pos.rcNormalPosition.bottom = CW_USEDEFAULT; + + child->focus_pane = 0; + child->split_pos = 200; + child->sortOrder = SORT_NAME; + child->header_wdths_ok = FALSE; + + lstrcpy(child->path, path); + + _tsplitpath(path, drv, dir, name, ext); + +#if !defined(_NO_EXTENSIONS) && defined(__linux__) + if (*path == '/') + { + root->drive_type = GetDriveType(path); + + lstrcat(drv, _T("/")); + lstrcpy(root->volname, _T("root fs")); + root->fs_flags = 0; + lstrcpy(root->fs, _T("unixfs")); + + lstrcpy(root->path, _T("/")); + entry = read_tree_unix(root, path, child->sortOrder); + } + else +#endif + { + root->drive_type = GetDriveType(path); + + lstrcat(drv, _T("\\")); + GetVolumeInformation(drv, root->volname, _MAX_FNAME, 0, 0, &root->fs_flags, root->fs, _MAX_DIR); + + lstrcpy(root->path, drv); + entry = read_tree_win(root, path, child->sortOrder); + } + +//@@lstrcpy(root->entry.data.cFileName, drv); + wsprintf(root->entry.data.cFileName, _T("%s - %s"), drv, root->fs); + + root->entry.data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; + + child->left.root = &root->entry; + + set_curdir(child, entry); + + return child; +} + + +static HHOOK hcbthook; +static ChildWnd* newchild = NULL; + +LRESULT CALLBACK CBTProc(int code, WPARAM wparam, LPARAM lparam) +{ + if (code==HCBT_CREATEWND && newchild) { + ChildWnd* child = newchild; + newchild = NULL; + child->hwnd = (HWND) wparam; + SetWindowLong(child->hwnd, GWL_USERDATA, (LPARAM)child); + } + return CallNextHookEx(hcbthook, code, wparam, lparam); +} + +HWND create_child_window(ChildWnd* child) +{ + MDICREATESTRUCT mcs = { +// WINEFILETREE, (LPTSTR)child->path, Globals.hInstance, + szFrameClass, (LPTSTR)child->path, Globals.hInstance, + child->pos.rcNormalPosition.left, child->pos.rcNormalPosition.top, + child->pos.rcNormalPosition.right-child->pos.rcNormalPosition.left, + child->pos.rcNormalPosition.bottom-child->pos.rcNormalPosition.top, + 0/*style*/, 0/*lParam*/ + }; + int idx; + + hcbthook = SetWindowsHookEx(WH_CBT, CBTProc, 0, GetCurrentThreadId()); + + newchild = child; + child->hwnd = (HWND) SendMessage(Globals.hMDIClient, WM_MDICREATE, 0, (LPARAM)&mcs); + if (!child->hwnd) + return 0; + + UnhookWindowsHookEx(hcbthook); + + idx = ListBox_FindItemData(child->left.hwnd, ListBox_GetCurSel(child->left.hwnd), child->left.cur); + ListBox_SetCurSel(child->left.hwnd, idx); + + return child->hwnd; +} + +// free all memory associated with a child window +static void free_child_window(ChildWnd* child) +{ + free_entries(&child->root.entry); + free(child); +} + +void toggle_child(HWND hwnd, UINT cmd, HWND hchild) +{ + BOOL vis = IsWindowVisible(hchild); + + CheckMenuItem(Globals.hMenuOptions, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED); + ShowWindow(hchild, vis?SW_HIDE:SW_SHOW); +#ifndef _NO_EXTENSIONS + if (g_fullscreen.mode) + fullscreen_move(hwnd); +#endif + resize_frame_client(hwnd); +} + +BOOL activate_drive_window(LPCTSTR path) +{ + TCHAR drv1[_MAX_DRIVE], drv2[_MAX_DRIVE]; + HWND child_wnd; + + _tsplitpath(path, drv1, 0, 0, 0); + + // search for a already open window for the same drive + for (child_wnd = GetNextWindow(Globals.hMDIClient,GW_CHILD); + child_wnd; + child_wnd = GetNextWindow(child_wnd, GW_HWNDNEXT)) { + ChildWnd* child = (ChildWnd*) GetWindowLong(child_wnd, GWL_USERDATA); + if (child) { + _tsplitpath(child->root.path, drv2, 0, 0, 0); + if (!lstrcmpi(drv2, drv1)) { + SendMessage(Globals.hMDIClient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0); + if (IsMinimized(child_wnd)) + ShowWindow(child_wnd, SW_SHOWNORMAL); + return TRUE; + } + } + } + return FALSE; +} + +static void InitChildWindow(ChildWnd* child) +{ + create_tree_window(child->hwnd, &child->left, IDW_TREE_LEFT, IDW_HEADER_LEFT, child->path); + create_list_window(child->hwnd, &child->right, IDW_TREE_RIGHT, IDW_HEADER_RIGHT); +} + + +#ifndef _NO_EXTENSIONS + +void set_header(Pane* pane) +{ + HD_ITEM item; + int scroll_pos = GetScrollPos(pane->hwnd, SB_HORZ); + int i=0, x=0; + + item.mask = HDI_WIDTH; + item.cxy = 0; + + for(; x+pane->widths[i]widths[i]; + Header_SetItem(pane->hwndHeader, i, &item); + } + + if (i < COLUMNS) { + x += pane->widths[i]; + item.cxy = x - scroll_pos; + Header_SetItem(pane->hwndHeader, i++, &item); + + for(; iwidths[i]; + x += pane->widths[i]; + Header_SetItem(pane->hwndHeader, i, &item); + } + } +} + +static LRESULT pane_notify(Pane* pane, NMHDR* pnmh) +{ + switch(pnmh->code) { + case HDN_TRACK: + case HDN_ENDTRACK: + { + HD_NOTIFY* phdn = (HD_NOTIFY*) pnmh; + int idx = phdn->iItem; + int dx = phdn->pitem->cxy - pane->widths[idx]; + int i; + + RECT clnt; + GetClientRect(pane->hwnd, &clnt); + // move immediate to simulate HDS_FULLDRAG (for now [04/2000] not realy needed with WINELIB) + Header_SetItem(pane->hwndHeader, idx, phdn->pitem); + pane->widths[idx] += dx; + for (i = idx; ++i <= COLUMNS; ) + pane->positions[i] += dx; + { + int scroll_pos = GetScrollPos(pane->hwnd, SB_HORZ); + RECT rt_scr = {pane->positions[idx+1]-scroll_pos, 0, clnt.right, clnt.bottom}; + RECT rt_clip = {pane->positions[idx]-scroll_pos, 0, clnt.right, clnt.bottom}; + if (rt_scr.left < 0) rt_scr.left = 0; + if (rt_clip.left < 0) rt_clip.left = 0; + ScrollWindowEx(pane->hwnd, dx, 0, &rt_scr, &rt_clip, 0, 0, SW_INVALIDATE); + rt_clip.right = pane->positions[idx+1]; + RedrawWindow(pane->hwnd, &rt_clip, 0, RDW_INVALIDATE|RDW_UPDATENOW); + if (pnmh->code == HDN_ENDTRACK) { + ListBox_SetHorizontalExtent(pane->hwnd, pane->positions[COLUMNS]); + if (GetScrollPos(pane->hwnd, SB_HORZ) != scroll_pos) + set_header(pane); + } + } + } + return FALSE; + case HDN_DIVIDERDBLCLICK: + { + HD_NOTIFY* phdn = (HD_NOTIFY*) pnmh; + HD_ITEM item; + calc_single_width(pane, phdn->iItem); + item.mask = HDI_WIDTH; + item.cxy = pane->widths[phdn->iItem]; + Header_SetItem(pane->hwndHeader, phdn->iItem, &item); + InvalidateRect(pane->hwnd, 0, TRUE); + break; + } + } + return 0; +} + +#endif + + +static BOOL pane_command(Pane* pane, UINT cmd) +{ + switch(cmd) { + case ID_VIEW_NAME: + if (pane->visible_cols) { + pane->visible_cols = 0; + calc_widths(pane, TRUE); +#ifndef _NO_EXTENSIONS + set_header(pane); +#endif + InvalidateRect(pane->hwnd, 0, TRUE); + CheckMenuItem(Globals.hMenuView, ID_VIEW_NAME, MF_BYCOMMAND|MF_CHECKED); +// CheckMenuItem(Globals.hMenuView, ID_VIEW_ALL_ATTRIBUTES, MF_BYCOMMAND); +// CheckMenuItem(Globals.hMenuView, ID_VIEW_SELECTED_ATTRIBUTES, MF_BYCOMMAND); + } + break; +#if 0 + case ID_VIEW_ALL_ATTRIBUTES: + if (pane->visible_cols != COL_ALL) { + pane->visible_cols = COL_ALL; + calc_widths(pane, TRUE); +#ifndef _NO_EXTENSIONS + set_header(pane); +#endif + InvalidateRect(pane->hwnd, 0, TRUE); + CheckMenuItem(Globals.hMenuView, ID_VIEW_NAME, MF_BYCOMMAND); +// CheckMenuItem(Globals.hMenuView, ID_VIEW_ALL_ATTRIBUTES, MF_BYCOMMAND|MF_CHECKED); +// CheckMenuItem(Globals.hMenuView, ID_VIEW_SELECTED_ATTRIBUTES, MF_BYCOMMAND); + } + break; +#ifndef _NO_EXTENSIONS + case ID_PREFERED_SIZES: { + calc_widths(pane, TRUE); + set_header(pane); + InvalidateRect(pane->hwnd, 0, TRUE); + break;} +#endif +#endif + // TODO: more command ids... + default: + return FALSE; + } + return TRUE; +} + + +LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + static int last_split; + + ChildWnd* child = (ChildWnd*) GetWindowLong(hwnd, GWL_USERDATA); + ASSERT(child); + + switch(nmsg) { + case WM_DRAWITEM: { + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lparam; + Entry* entry = (Entry*) dis->itemData; + + if (dis->CtlID == IDW_TREE_LEFT) + draw_item(&child->left, dis, entry, -1); + else + draw_item(&child->right, dis, entry, -1); + + return TRUE;} + + case WM_CREATE: + InitChildWindow(child); + break; + + case WM_NCDESTROY: + free_child_window(child); + SetWindowLong(hwnd, GWL_USERDATA, 0); + break; + + case WM_PAINT: { + PAINTSTRUCT ps; + HBRUSH lastBrush; + RECT rt; + GetClientRect(hwnd, &rt); + BeginPaint(hwnd, &ps); + rt.left = child->split_pos-SPLIT_WIDTH/2; + rt.right = child->split_pos+SPLIT_WIDTH/2+1; + lastBrush = SelectBrush(ps.hdc, (HBRUSH)GetStockObject(COLOR_SPLITBAR)); + Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1); + SelectObject(ps.hdc, lastBrush); +#ifdef _NO_EXTENSIONS + rt.top = rt.bottom - GetSystemMetrics(SM_CYHSCROLL); + FillRect(ps.hdc, &rt, GetStockObject(BLACK_BRUSH)); +#endif + EndPaint(hwnd, &ps); + break;} + + case WM_SETCURSOR: + if (LOWORD(lparam) == HTCLIENT) { + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hwnd, &pt); + + if (pt.x>=child->split_pos-SPLIT_WIDTH/2 && pt.xsplit_pos+SPLIT_WIDTH/2+1) { + SetCursor(LoadCursor(0, IDC_SIZEWE)); + return TRUE; + } + } + goto def; + + case WM_LBUTTONDOWN: { + RECT rt; + int x = LOWORD(lparam); + + GetClientRect(hwnd, &rt); + + if (x>=child->split_pos-SPLIT_WIDTH/2 && xsplit_pos+SPLIT_WIDTH/2+1) { + last_split = child->split_pos; +#ifdef _NO_EXTENSIONS + draw_splitbar(hwnd, last_split); +#endif + SetCapture(hwnd); + } + + break;} + + case WM_LBUTTONUP: + if (GetCapture() == hwnd) { +#ifdef _NO_EXTENSIONS + RECT rt; + int x = LOWORD(lparam); + draw_splitbar(hwnd, last_split); + last_split = -1; + GetClientRect(hwnd, &rt); + child->split_pos = x; + resize_tree(child, rt.right, rt.bottom); +#endif + ReleaseCapture(); + } + break; + +#ifdef _NO_EXTENSIONS + case WM_CAPTURECHANGED: + if (GetCapture()==hwnd && last_split>=0) + draw_splitbar(hwnd, last_split); + break; +#endif + + case WM_KEYDOWN: + if (wparam == VK_ESCAPE) + if (GetCapture() == hwnd) { + RECT rt; +#ifdef _NO_EXTENSIONS + draw_splitbar(hwnd, last_split); +#else + child->split_pos = last_split; +#endif + GetClientRect(hwnd, &rt); + resize_tree(child, rt.right, rt.bottom); + last_split = -1; + ReleaseCapture(); + SetCursor(LoadCursor(0, IDC_ARROW)); + } + break; + + case WM_MOUSEMOVE: + if (GetCapture() == hwnd) { + RECT rt; + int x = LOWORD(lparam); + +#ifdef _NO_EXTENSIONS + HDC hdc = GetDC(hwnd); + GetClientRect(hwnd, &rt); + + rt.left = last_split-SPLIT_WIDTH/2; + rt.right = last_split+SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + + last_split = x; + rt.left = x-SPLIT_WIDTH/2; + rt.right = x+SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + + ReleaseDC(hwnd, hdc); +#else + GetClientRect(hwnd, &rt); + + if (x>=0 && xsplit_pos = x; + resize_tree(child, rt.right, rt.bottom); + rt.left = x-SPLIT_WIDTH/2; + rt.right = x+SPLIT_WIDTH/2+1; + InvalidateRect(hwnd, &rt, FALSE); + UpdateWindow(child->left.hwnd); + UpdateWindow(hwnd); + UpdateWindow(child->right.hwnd); + } +#endif + } + break; + +#ifndef _NO_EXTENSIONS + case WM_GETMINMAXINFO: + DefMDIChildProc(hwnd, nmsg, wparam, lparam); + + {LPMINMAXINFO lpmmi = (LPMINMAXINFO)lparam; + + lpmmi->ptMaxTrackSize.x <<= 1;//2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN + lpmmi->ptMaxTrackSize.y <<= 1;//2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN + break;} +#endif + + case WM_SETFOCUS: + SetCurrentDirectory(child->path); + SetFocus(child->focus_pane? child->right.hwnd: child->left.hwnd); + break; + + case WM_DISPATCH_COMMAND: { + Pane* pane = GetFocus()==child->left.hwnd? &child->left: &child->right; + + switch(LOWORD(wparam)) { + case ID_WINDOW_NEW_WINDOW: { + ChildWnd* new_child = alloc_child_window(child->path); + + if (!create_child_window(new_child)) + free(new_child); + + break;} +#if 0 + case ID_REFRESH: + scan_entry(child, pane->cur); + break; + case ID_ACTIVATE: + activate_entry(child, pane); + break; +#endif + case ID_WINDOW_CASCADE: + SendMessage(Globals.hMDIClient, WM_MDICASCADE, 0, 0); + break; + case ID_WINDOW_TILE_HORZ: + SendMessage(Globals.hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); + break; + case ID_WINDOW_TILE_VERT: + SendMessage(Globals.hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0); + break; + case ID_WINDOW_ARRANGE_ICONS: + SendMessage(Globals.hMDIClient, WM_MDIICONARRANGE, 0, 0); + break; + default: + return pane_command(pane, LOWORD(wparam)); + } + + return TRUE;} + + case WM_COMMAND: { + Pane* pane = GetFocus()==child->left.hwnd? &child->left: &child->right; + + switch(HIWORD(wparam)) { + case LBN_SELCHANGE: { + int idx = ListBox_GetCurSel(pane->hwnd); + Entry* entry = (Entry*) ListBox_GetItemData(pane->hwnd, idx); + + if (pane == &child->left) + set_curdir(child, entry); + else + pane->cur = entry; + break;} + + case LBN_DBLCLK: + activate_entry(child, pane); + break; + } + break;} + +#ifndef _NO_EXTENSIONS + case WM_NOTIFY: { + NMHDR* pnmh = (NMHDR*) lparam; + return pane_notify(pnmh->idFrom==IDW_HEADER_LEFT? &child->left: &child->right, pnmh);} +#endif + case WM_SIZE: + if (wparam != SIZE_MINIMIZED) + resize_tree(child, LOWORD(lparam), HIWORD(lparam)); + // fall through + default: def: + return DefMDIChildProc(hwnd, nmsg, wparam, lparam); + } + return 0; +} + +/* +RegenerateUserEnvironment + */ \ No newline at end of file diff --git a/rosapps/winfile/mdiclient.h b/rosapps/winfile/mdiclient.h new file mode 100644 index 00000000000..f9575e95861 --- /dev/null +++ b/rosapps/winfile/mdiclient.h @@ -0,0 +1,55 @@ +/* + * ReactOS winfile + * + * mdiclient.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __MDICLIENT_H__ +#define __MDICLIENT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + + + +LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM); + +HWND create_child_window(ChildWnd* child); + +void toggle_child(HWND hwnd, UINT cmd, HWND hchild); +ChildWnd* alloc_child_window(LPCTSTR path); +void set_header(Pane* pane); + +void toggle_child(HWND hwnd, UINT cmd, HWND hchild); +BOOL activate_drive_window(LPCTSTR path); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __MDICLIENT_H__ diff --git a/rosapps/winfile/resource.h b/rosapps/winfile/resource.h index 9913e3ea83d..d6d23febf15 100644 --- a/rosapps/winfile/resource.h +++ b/rosapps/winfile/resource.h @@ -11,21 +11,96 @@ #define ID_WINDOW_MENU 6 #define ID_HELP_MENU 7 -#define IDD_ABOUTBOX 103 -#define IDS_APP_TITLE 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 +#define IDD_ABOUTBOX 104 +#define IDS_APP_TITLE 105 #define IDS_HELLO 106 #define IDI_WINFILE 107 #define IDI_SMALL 108 #define IDC_WINFILE 109 #define IDC_WINFILE_FRAME 110 -#define IDR_WINFILE_MENU 130 +//#define IDR_WINFILE_MENU 130 #define IDD_DIALOG1 131 #define IDB_OPEN_FILE 132 #define IDB_CLOSED_FILE 133 #define IDB_ROOT 134 +#define IDB_TOOLBAR 135 +#define IDB_DRIVEBAR 136 +#define IDB_IMAGES 137 +#define ID_FILE_OPEN 32769 +#define ID_FILE_MOVE 32770 +#define ID_FILE_COPY 32771 +#define ID_FILE_COPY_CLIPBOARD 32772 +#define ID_FILE_DELETE 32773 +#define ID_FILE_RENAME 32774 +#define ID_FILE_PROPERTIES 32775 +#define ID_FILE_COMPRESS 32776 +#define ID_FILE_UNCOMPRESS 32777 +#define ID_FILE_RUN 32778 +#define ID_FILE_PRINT 32779 +#define ID_FILE_ASSOCIATE 32780 +#define ID_FILE_CREATE_DIRECTORY 32781 +#define ID_FILE_SEARCH 32782 +#define ID_FILE_SEARCH_FILES 32783 +#define ID_FILE_EXIT 32784 + +#define ID_DISK_COPY_DISK 32785 +#define ID_DISK_LABEL_DISK 32786 +#define ID_DISK_FORMAT_DISK 32787 +#define ID_DISK_CONNECT_NETWORK_DRIVE 32788 +#define ID_DISK_DISCONNECT_NETWORK_DRIVE 32789 +#define ID_DISK_SHARE_AS 32790 +#define ID_DISK_STOP_SHARING 32791 +#define ID_DISK_SELECT_DRIVE 32792 + +#define ID_TREE_EXPAND_ONE_LEVEL 32793 +#define ID_TREE_EXPAND_BRANCH 32794 +#define ID_TREE_EXPAND_ALL 32795 +#define ID_TREE_INDICATE_EXPANDABLE_BRANCHES 32796 + +#define ID_VIEW_TREE_DIRECTORY 32797 +#define ID_VIEW_TREE_ONLY 32798 +#define ID_VIEW_DIRECTORY_ONLY 32799 +#define ID_VIEW_SPLIT 32800 +#define ID_VIEW_NAME 32801 +#define ID_VIEW_ALL_FILE_DETAILS 32802 +#define ID_VIEW_PARTIAL_DETAILS 32803 +#define ID_VIEW_SORT_BY_NAME 32804 +#define ID_VIEW_SORT_BY_TYPE 32805 +#define ID_VIEW_SORT_BY_SIZE 32806 +#define ID_VIEW_SORT_BY_DATE 32807 +#define ID_VIEW_BY_FILE_TYPE 32808 + +#define ID_OPTIONS_CONFIRMATION 32809 +#define ID_OPTIONS_FONT 32810 +#define ID_OPTIONS_CUSTOMISE_TOOLBAR 32811 +#define ID_OPTIONS_TOOLBAR 32812 +#define ID_OPTIONS_DRIVEBAR 32813 +#define ID_OPTIONS_STATUSBAR 32814 +#define ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT 32815 +#define ID_OPTIONS_MINIMISE_ON_USE 32816 +#define ID_OPTIONS_SAVE_ON_EXIT 32817 + +#define ID_SECURITY_PERMISSIONS 32818 +#define ID_SECURITY_AUDITING 32819 +#define ID_SECURITY_OWNER 32820 + +#define ID_WINDOW_NEW_WINDOW 32821 +#define ID_WINDOW_CASCADE 32822 +#define ID_WINDOW_TILE_HORZ 32823 +#define ID_WINDOW_TILE_VERT 32824 +#define ID_WINDOW_ARRANGE_ICONS 32825 +#define ID_WINDOW_REFRESH 32826 + +#define ID_HELP_CONTENTS 32827 +#define ID_HELP_SEARCH_HELP 32828 +#define ID_HELP_HOW_TO_USE_HELP 32829 +#define ID_HELP_ABOUT 32830 + +#define IDC_LICENSE_EDIT 32831 +#define IDS_LICENSE 32832 + +/* #define ID_HELP_HELPTOPICS 32771 #define ID_VIEW_STATUSBAR 32774 #define ID_VIEW_SPLIT 32775 @@ -58,9 +133,7 @@ #define ID_TREE_EXPANDALL 32816 #define ID_TREE_COLLAPSEBRANCH 32817 #define ID_REGISTRY_OPENLOCAL 32825 - -#define IDC_LICENSE_EDIT 1029 -#define IDS_LICENSE 32835 + */ #define IDC_STATIC -1 @@ -68,8 +141,8 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 132 -#define _APS_NEXT_COMMAND_VALUE 32836 +#define _APS_NEXT_RESOURCE_VALUE 138 +#define _APS_NEXT_COMMAND_VALUE 32832 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 110 #endif diff --git a/rosapps/winfile/run.c b/rosapps/winfile/run.c new file mode 100644 index 00000000000..dbf3b9f7ff9 --- /dev/null +++ b/rosapps/winfile/run.c @@ -0,0 +1,71 @@ +/* + * ReactOS Task Manager + * + * run.c + * + * Copyright (C) 1999 - 2001 Brian Palmer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include "winfile.h" +#include "run.h" + + +void OnFileRun(void) +{ + HMODULE hShell32; + RUNFILEDLG RunFileDlg; + OSVERSIONINFO versionInfo; + WCHAR wTitle[40]; + WCHAR wText[256]; + char szTitle[40] = "Create New Task"; + char szText[256] = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you."; + + hShell32 = LoadLibrary("SHELL32.DLL"); + RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D)); + + // Show "Run..." dialog + if (RunFileDlg) + { + versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&versionInfo); + + if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256); + RunFileDlg(Globals.hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY); + } + else + RunFileDlg(Globals.hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); + } + + FreeLibrary(hShell32); +} diff --git a/rosapps/winfile/run.h b/rosapps/winfile/run.h new file mode 100644 index 00000000000..a090f40fd7f --- /dev/null +++ b/rosapps/winfile/run.h @@ -0,0 +1,63 @@ +/* + * ReactOS File Manager + * + * run.h + * + * Copyright (C) 1999 - 2001 Brian Palmer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +// run.h - definitions necessary to use Microsoft's "Run" dialog +// Undocumented Windows call +// use the type below to declare a function pointer + +// Information taken from http://www.geocities.com/SiliconValley/4942/ +// Copyright © 1998-1999 James Holderness. All Rights Reserved. +// jholderness@geocities.com + +#ifndef __RUN_H__ +#define __RUN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +void OnFileRun(void); + +typedef void (WINAPI *RUNFILEDLG)( + HWND hwndOwner, + HICON hIcon, + LPCSTR lpstrDirectory, + LPCSTR lpstrTitle, + LPCSTR lpstrDescription, + UINT uFlags); + +// +// Flags for RunFileDlg +// + +#define RFF_NOBROWSE 0x01 // Removes the browse button. +#define RFF_NODEFAULT 0x02 // No default item selected. +#define RFF_CALCDIRECTORY 0x04 // Calculates the working directory from the file name. +#define RFF_NOLABEL 0x08 // Removes the edit box label. +#define RFF_NOSEPARATEMEM 0x20 // Removes the Separate Memory Space check box (Windows NT only). + +#ifdef __cplusplus +}; +#endif + +#endif // __RUN_H__ diff --git a/rosapps/winfile/settings.c b/rosapps/winfile/settings.c new file mode 100644 index 00000000000..f1cdb9c405e --- /dev/null +++ b/rosapps/winfile/settings.c @@ -0,0 +1,38 @@ +/* + * ReactOS winfile + * + * settings.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include "winfile.h" + diff --git a/rosapps/winfile/settings.h b/rosapps/winfile/settings.h new file mode 100644 index 00000000000..e05eca6db6e --- /dev/null +++ b/rosapps/winfile/settings.h @@ -0,0 +1,45 @@ +/* + * ReactOS winfile + * + * settings.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __SETTINGS_H__ +#define __SETTINGS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + + + + + + +#ifdef __cplusplus +}; +#endif + +#endif // __SETTINGS_H__ diff --git a/rosapps/winfile/sort.c b/rosapps/winfile/sort.c new file mode 100644 index 00000000000..8a07d26fc39 --- /dev/null +++ b/rosapps/winfile/sort.c @@ -0,0 +1,179 @@ +/* + * ReactOS winfile + * + * sort.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +//#include +#include +#include +#include +#include +#define ASSERT assert + +#include "winfile.h" +#include "sort.h" + + + + // directories first... +static int compareType(const WIN32_FIND_DATA* fd1, const WIN32_FIND_DATA* fd2) +{ + int dir1 = fd1->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; + int dir2 = fd2->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; + + return dir2==dir1? 0: dir2data; + const WIN32_FIND_DATA* fd2 = &(*(Entry**)arg2)->data; + + int cmp = compareType(fd1, fd2); + if (cmp) + return cmp; + + return lstrcmpi(fd1->cFileName, fd2->cFileName); +} + +static int compareExt(const void* arg1, const void* arg2) +{ + const WIN32_FIND_DATA* fd1 = &(*(Entry**)arg1)->data; + const WIN32_FIND_DATA* fd2 = &(*(Entry**)arg2)->data; + const TCHAR *name1, *name2, *ext1, *ext2; + + int cmp = compareType(fd1, fd2); + if (cmp) + return cmp; + + name1 = fd1->cFileName; + name2 = fd2->cFileName; + + ext1 = _tcsrchr(name1, _T('.')); + ext2 = _tcsrchr(name2, _T('.')); + + if (ext1) + ext1++; + else + ext1 = _T(""); + + if (ext2) + ext2++; + else + ext2 = _T(""); + + cmp = lstrcmpi(ext1, ext2); + if (cmp) + return cmp; + + return lstrcmpi(name1, name2); +} + +static int compareSize(const void* arg1, const void* arg2) +{ + WIN32_FIND_DATA* fd1 = &(*(Entry**)arg1)->data; + WIN32_FIND_DATA* fd2 = &(*(Entry**)arg2)->data; + + int cmp = compareType(fd1, fd2); + if (cmp) + return cmp; + + cmp = fd2->nFileSizeHigh - fd1->nFileSizeHigh; + + if (cmp < 0) + return -1; + else if (cmp > 0) + return 1; + + cmp = fd2->nFileSizeLow - fd1->nFileSizeLow; + + return cmp<0? -1: cmp>0? 1: 0; +} + +static int compareDate(const void* arg1, const void* arg2) +{ + WIN32_FIND_DATA* fd1 = &(*(Entry**)arg1)->data; + WIN32_FIND_DATA* fd2 = &(*(Entry**)arg2)->data; + + int cmp = compareType(fd1, fd2); + if (cmp) + return cmp; + + return CompareFileTime(&fd2->ftLastWriteTime, &fd1->ftLastWriteTime); +} + + +static int (*sortFunctions[])(const void* arg1, const void* arg2) = { + compareName, // SORT_NAME + compareExt, // SORT_EXT + compareSize, // SORT_SIZE + compareDate // SORT_DATE +}; + + +void SortDirectory(Entry* parent, SORT_ORDER sortOrder) +{ + Entry* entry = parent->down; + Entry** array, **p; + int len; + + len = 0; + for(entry=parent->down; entry; entry=entry->next) + len++; + + if (len) { +#ifdef _MSC_VER + array = (Entry**) alloca(len*sizeof(Entry*)); +#else + array = (Entry**) malloc(len*sizeof(Entry*)); +#endif + p = array; + for(entry=parent->down; entry; entry=entry->next) + *p++ = entry; + + // call qsort with the appropriate compare function + qsort(array, len, sizeof(array[0]), sortFunctions[sortOrder]); + + parent->down = array[0]; + + for(p=array; --len; p++) + p[0]->next = p[1]; + + (*p)->next = 0; + } +} + + diff --git a/rosapps/winfile/sort.h b/rosapps/winfile/sort.h new file mode 100644 index 00000000000..38fb1ecda65 --- /dev/null +++ b/rosapps/winfile/sort.h @@ -0,0 +1,46 @@ +/* + * ReactOS winfile + * + * sort.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __SORT_H__ +#define __SORT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + + +#include "entries.h" + +void SortDirectory(Entry* parent, SORT_ORDER sortOrder); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __SORT_H__ diff --git a/rosapps/winfile/splitpath.c b/rosapps/winfile/splitpath.c new file mode 100644 index 00000000000..475cc676ed3 --- /dev/null +++ b/rosapps/winfile/splitpath.c @@ -0,0 +1,170 @@ +/* + * ReactOS winfile + * + * winfile.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include "winfile.h" + + +#ifdef UNICODE + +void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext) +{ + const WCHAR* end; // end of processed string + const WCHAR* p; // search pointer + const WCHAR* s; // copy pointer + + // extract drive name + if (path[0] && path[1]==':') { + if (drv) { + *drv++ = *path++; + *drv++ = *path++; + *drv = L'\0'; + } + } else if (drv) + *drv = L'\0'; + + // search for end of string or stream separator + for(end=path; *end && *end!=L':'; ) + end++; + + // search for begin of file extension + for(p=end; p>path && *--p!=L'\\' && *p!=L'/'; ) + if (*p == L'.') { + end = p; + break; + } + + if (ext) + for(s=end; *ext=*s++; ) + ext++; + + // search for end of directory name + for(p=end; p>path; ) + if (*--p=='\\' || *p=='/') { + p++; + break; + } + + if (name) { + for(s=p; spath && *--p!='\\' && *p!='/'; ) + if (*p == '.') { + end = p; + break; + } + + if (ext) + for(s=end; (*ext=*s++); ) + ext++; + + // search for end of directory name + for(p=end; p>path; ) + if (*--p=='\\' || *p=='/') { + p++; + break; + } + + if (name) { + for(s=p; s + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +//#include +//#include +#include +#define ASSERT assert + +#include "winfile.h" +#include "mdiclient.h" +#include "subframe.h" +#include "utils.h" +//#include "treeview.h" +//#include "listview.h" +//#include "debug.h" + + +static void resize_frame_rect(HWND hwnd, PRECT prect) +{ + int new_top; + RECT rt; + + if (IsWindowVisible(Globals.hToolBar)) { + SendMessage(Globals.hToolBar, WM_SIZE, 0, 0); + GetClientRect(Globals.hToolBar, &rt); + prect->top = rt.bottom+3; + prect->bottom -= rt.bottom+3; + } + + if (IsWindowVisible(Globals.hDriveBar)) { + SendMessage(Globals.hDriveBar, WM_SIZE, 0, 0); + GetClientRect(Globals.hDriveBar, &rt); + new_top = --prect->top + rt.bottom+3; + MoveWindow(Globals.hDriveBar, 0, prect->top, rt.right, new_top, TRUE); + prect->top = new_top; + prect->bottom -= rt.bottom+2; + } + + if (IsWindowVisible(Globals.hStatusBar)) { + int parts[] = {300, 500}; + + SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0); + SendMessage(Globals.hStatusBar, SB_SETPARTS, 2, (LPARAM)&parts); + GetClientRect(Globals.hStatusBar, &rt); + prect->bottom -= rt.bottom; + } + + MoveWindow(Globals.hMDIClient, prect->left-1,prect->top-1,prect->right+2,prect->bottom+1, TRUE); +} + +static void resize_frame(HWND hwnd, int cx, int cy) +{ + RECT rect = {0, 0, cx, cy}; + + resize_frame_rect(hwnd, &rect); +} + +void resize_frame_client(HWND hwnd) +{ + RECT rect; + + GetClientRect(hwnd, &rect); + resize_frame_rect(hwnd, &rect); +} + + +LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + if (1) { + switch (nmsg) { + case WM_CLOSE: + DestroyWindow(hwnd); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_COMMAND: + { + UINT cmd = LOWORD(wparam); + HWND hwndClient = (HWND) SendMessage(Globals.hMDIClient, WM_MDIGETACTIVE, 0, 0); + + if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wparam, lparam)) + break; + + if (cmd>=ID_DRIVE_FIRST && cmd<=ID_DRIVE_FIRST+0xFF) { + TCHAR drv[_MAX_DRIVE], path[MAX_PATH]; + ChildWnd* child; + LPCTSTR root = Globals.drives; + int i; + for(i = cmd - ID_DRIVE_FIRST; i--; root++) + while(*root) + root++; + if (activate_drive_window(root)) + return 0; + _tsplitpath(root, drv, 0, 0, 0); + if (!SetCurrentDirectory(drv)) { + display_error(hwnd, GetLastError()); + return 0; + } + GetCurrentDirectory(MAX_PATH, path); //@@ letztes Verzeichnis pro Laufwerk speichern + child = alloc_child_window(path); + if (!create_child_window(child)) + free(child); + } else { + switch (cmd) { + case ID_FILE_EXIT: + PostQuitMessage(0); + break; + case ID_WINDOW_NEW_WINDOW: + { + TCHAR path[MAX_PATH]; + ChildWnd* child; + GetCurrentDirectory(MAX_PATH, path); + child = alloc_child_window(path); + if (!create_child_window(child)) + free(child); + } + break; + case ID_WINDOW_CASCADE: + SendMessage(Globals.hMDIClient, WM_MDICASCADE, 0, 0); + break; + case ID_WINDOW_TILE_HORZ: + SendMessage(Globals.hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); + break; + case ID_WINDOW_TILE_VERT: + SendMessage(Globals.hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0); + break; + case ID_WINDOW_ARRANGE_ICONS: + SendMessage(Globals.hMDIClient, WM_MDIICONARRANGE, 0, 0); + break; + case ID_OPTIONS_TOOLBAR: + toggle_child(hwnd, cmd, Globals.hToolBar); + break; + case ID_OPTIONS_DRIVEBAR: + toggle_child(hwnd, cmd, Globals.hDriveBar); + break; + case ID_OPTIONS_STATUSBAR: + toggle_child(hwnd, cmd, Globals.hStatusBar); + break; +#if 0 + case ID_EXECUTE: + { + struct ExecuteDialog dlg = {{0}}; + if (DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_EXECUTE), hwnd, ExecuteDialogWndProg, (LPARAM)&dlg) == IDOK) + ShellExecute(hwnd, _T("open")/*operation*/, dlg.cmd/*file*/, NULL/*parameters*/, NULL/*dir*/, dlg.cmdshow); + } + break; + case ID_HELP: + WinHelp(hwnd, _T("winfile"), HELP_INDEX, 0); + break; +#endif +#ifndef _NO_EXTENSIONS + case ID_VIEW_FULLSCREEN: + CheckMenuItem(Globals.hMenuOptions, cmd, toggle_fullscreen(hwnd)?MF_CHECKED:0); + break; +#ifdef __linux__ + case ID_DRIVE_UNIX_FS: + { + TCHAR path[MAX_PATH]; + ChildWnd* child; + if (activate_drive_window(_T("/"))) + break; + getcwd(path, MAX_PATH); + child = alloc_child_window(path); + if (!create_child_window(child)) + free(child); + } + break; +#endif +#endif + //TODO: There are even more menu items! + default: + /*@@if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE) + STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE); + else */ + if ((cmd=IDW_FIRST_CHILD+0x100) && + (cmdSC_RESTORE)) { + MessageBox(hwnd, _T("Not yet implemented"), _T("Winefile"), MB_OK); + } + return DefFrameProc(hwnd, Globals.hMDIClient, nmsg, wparam, lparam); + } + } + } + break; + case WM_SIZE: + resize_frame(hwnd, LOWORD(lparam), HIWORD(lparam)); + break; // do not pass message to DefFrameProc +#ifndef _NO_EXTENSIONS + case WM_GETMINMAXINFO: + { + LPMINMAXINFO lpmmi = (LPMINMAXINFO)lparam; + lpmmi->ptMaxTrackSize.x <<= 1;//2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN + lpmmi->ptMaxTrackSize.y <<= 1;//2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN + } + break; + case FRM_CALC_CLIENT: + frame_get_clientspace(hwnd, (PRECT)lparam); + return TRUE; +#endif + default: + return DefFrameProc(hwnd, Globals.hMDIClient, nmsg, wparam, lparam); + } + } + return 0; +} + + diff --git a/rosapps/winfile/subframe.h b/rosapps/winfile/subframe.h new file mode 100644 index 00000000000..4b49059e043 --- /dev/null +++ b/rosapps/winfile/subframe.h @@ -0,0 +1,47 @@ +/* + * ReactOS winfile + * + * subframe.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __SUBFRAME_H__ +#define __SUBFRAME_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + + +LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); + +void resize_frame_client(HWND hwnd); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __SUBFRAME_H__ diff --git a/rosapps/winfile/toolbar.bmp b/rosapps/winfile/toolbar.bmp new file mode 100644 index 00000000000..d4fbc511eba Binary files /dev/null and b/rosapps/winfile/toolbar.bmp differ diff --git a/rosapps/winfile/treeview.cpp b/rosapps/winfile/treeview.c similarity index 71% rename from rosapps/winfile/treeview.cpp rename to rosapps/winfile/treeview.c index c8c82da32cb..3886ec10c73 100644 --- a/rosapps/winfile/treeview.cpp +++ b/rosapps/winfile/treeview.c @@ -1,7 +1,7 @@ /* * ReactOS winfile * - * treeview.cpp + * treeview.c * * Copyright (C) 2002 Robert Dickenson * @@ -33,13 +33,24 @@ #include #include #endif - + +#include +//#include +#include +#include +#include +#include +#define ASSERT assert + #include "winfile.h" #include "treeview.h" +#include "entries.h" +#include "utils.h" + // Global Variables: -extern HINSTANCE hInst; // current instance -extern HWND hMainWnd; // Main Window +extern HINSTANCE hInst; + // Global variables and constants // Image_Open, Image_Closed, and Image_Root - integer variables for @@ -200,12 +211,103 @@ HWND CreateTreeView(HWND hwndParent, LPSTR lpszFileName) WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT, 0, 0, rcClient.right, rcClient.bottom, hwndParent, (HMENU)TREE_WINDOW, hInst, NULL); - +/* + hwndTV = CreateWindow(_T("ListBox"), _T(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL| + LBS_DISABLENOSCROLL|LBS_NOINTEGRALHEIGHT|LBS_OWNERDRAWFIXED|LBS_NOTIFY, + 0, 0, 0, 0, parent, (HMENU)id, Globals.hInstance, 0); + */ // Initialize the image list, and add items to the control. if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, lpszFileName)) { DestroyWindow(hwndTV); - return FALSE; + return NULL; } return hwndTV; } +//////////////////////////////////////////////////////////////////////////////// +static WNDPROC g_orgTreeWndProc; + +LRESULT CALLBACK TreeWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + ChildWnd* child = (ChildWnd*)GetWindowLong(GetParent(hwnd), GWL_USERDATA); + Pane* pane = (Pane*)GetWindowLong(hwnd, GWL_USERDATA); + ASSERT(child); + + switch(nmsg) { +#ifndef _NO_EXTENSIONS + case WM_HSCROLL: + set_header(pane); + break; +#endif + + case WM_SETFOCUS: + child->focus_pane = pane==&child->right? 1: 0; + ListBox_SetSel(hwnd, TRUE, 1); + //TODO: check menu items + break; + + case WM_KEYDOWN: + if (wparam == VK_TAB) { + //TODO: SetFocus(Globals.hDriveBar) + SetFocus(child->focus_pane? child->left.hwnd: child->right.hwnd); + } + } + + return CallWindowProc(g_orgTreeWndProc, hwnd, nmsg, wparam, lparam); +} + + +static void init_output(HWND hwnd) +{ + TCHAR b[16]; + HFONT old_font; + HDC hdc = GetDC(hwnd); + + if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, _T("1000"), 0, b, 16) > 4) + Globals.num_sep = b[1]; + else + Globals.num_sep = _T('.'); + + old_font = SelectFont(hdc, Globals.hFont); + GetTextExtentPoint32(hdc, _T(" "), 1, &Globals.spaceSize); + SelectFont(hdc, old_font); + ReleaseDC(hwnd, hdc); +} + + +void create_tree_window(HWND parent, Pane* pane, int id, int id_header, LPSTR lpszFileName) +{ + static int s_init = 0; + Entry* entry = pane->root; +#if 1 + pane->hwnd = CreateTreeView(parent, lpszFileName); +#else + pane->hwnd = CreateWindow(_T("ListBox"), _T(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL| +// LBS_DISABLENOSCROLL|LBS_NOINTEGRALHEIGHT|LBS_OWNERDRAWFIXED|LBS_NOTIFY, + LBS_DISABLENOSCROLL|LBS_NOINTEGRALHEIGHT|LBS_NOTIFY, + 0, 0, 0, 0, parent, (HMENU)id, Globals.hInstance, 0); +#endif + SetWindowLong(pane->hwnd, GWL_USERDATA, (LPARAM)pane); + g_orgTreeWndProc = SubclassWindow(pane->hwnd, TreeWndProc); + + SendMessage(pane->hwnd, WM_SETFONT, (WPARAM)Globals.hFont, FALSE); + + // insert entries into listbox + if (entry) + insert_entries(pane, entry, -1); + + // calculate column widths + if (!s_init) { + s_init = 1; + init_output(pane->hwnd); + } + + calc_widths(pane, TRUE); + +#ifndef _NO_EXTENSIONS + pane->hwndHeader = create_header(parent, pane, id_header); +#endif +} + + + diff --git a/rosapps/winfile/treeview.h b/rosapps/winfile/treeview.h index acfdec6eb40..63aa4ce6904 100644 --- a/rosapps/winfile/treeview.h +++ b/rosapps/winfile/treeview.h @@ -20,8 +20,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __WINFILE_TREEVIEW_H__ -#define __WINFILE_TREEVIEW_H__ +#ifndef __TREEVIEW_H__ +#define __TREEVIEW_H__ + +#ifdef __cplusplus +extern "C" { +#endif #if _MSC_VER > 1000 #pragma once @@ -33,6 +37,14 @@ HWND CreateTreeView(HWND hwndParent, LPSTR lpszFileName); +void create_tree_window(HWND parent, Pane* pane, int id, int id_header, LPSTR lpszFileName); + +LRESULT CALLBACK TreeWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); + + +#ifdef __cplusplus +}; +#endif -#endif // __WINFILE_TREEVIEW_H__ +#endif // __TREEVIEW_H__ diff --git a/rosapps/winfile/utils.c b/rosapps/winfile/utils.c new file mode 100644 index 00000000000..e48221daa72 --- /dev/null +++ b/rosapps/winfile/utils.c @@ -0,0 +1,522 @@ +/* + * ReactOS winfile + * + * utils.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include + +#include "winfile.h" +#include "utils.h" +#include "sort.h" +#include "draw.h" + +#define FRM_CALC_CLIENT 0xBF83 +#define Frame_CalcFrameClient(hwnd, prt) ((BOOL)SNDMSG(hwnd, FRM_CALC_CLIENT, 0, (LPARAM)(PRECT)prt)) + + +void display_error(HWND hwnd, DWORD error) +{ + PTSTR msg; + + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + 0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PTSTR)&msg, 0, NULL)) + MessageBox(hwnd, msg, _T("Winefile"), MB_OK); + else + MessageBox(hwnd, _T("Error"), _T("Winefile"), MB_OK); + + LocalFree(msg); +} + + +static void read_directory_win(Entry* parent, LPCTSTR path) +{ + Entry* entry = (Entry*) malloc(sizeof(Entry)); + int level = parent->level + 1; + Entry* last = 0; + HANDLE hFind; +#ifndef _NO_EXTENSIONS + HANDLE hFile; +#endif + + TCHAR buffer[MAX_PATH], *p; + for(p=buffer; *path; ) + *p++ = *path++; + + lstrcpy(p, _T("\\*")); + + hFind = FindFirstFile(buffer, &entry->data); + + if (hFind != INVALID_HANDLE_VALUE) { + parent->down = entry; + + do { + entry->down = 0; + entry->up = parent; + entry->expanded = FALSE; + entry->scanned = FALSE; + entry->level = level; + +#ifdef _NO_EXTENSIONS + // hide directory entry "." + if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + LPCTSTR name = entry->data.cFileName; + + if (name[0]=='.' && name[1]=='\0') + continue; + } +#else + entry->unix_dir = FALSE; + entry->bhfi_valid = FALSE; + + lstrcpy(p+1, entry->data.cFileName); + + hFile = CreateFile(buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + + if (hFile != INVALID_HANDLE_VALUE) { + if (GetFileInformationByHandle(hFile, &entry->bhfi)) + entry->bhfi_valid = TRUE; + + CloseHandle(hFile); + } +#endif + + last = entry; + + entry = (Entry*) malloc(sizeof(Entry)); + + if (last) + last->next = entry; + } while(FindNextFile(hFind, &entry->data)); + + last->next = 0; + + FindClose(hFind); + } else + parent->down = 0; + + free(entry); + + parent->scanned = TRUE; +} + + +void read_directory(Entry* parent, LPCTSTR path, int sortOrder) +{ + TCHAR buffer[MAX_PATH]; + Entry* entry; + LPCTSTR s; + PTSTR d; + +#if !defined(_NO_EXTENSIONS) && defined(__linux__) + if (parent->unix_dir) + { + read_directory_unix(parent, path); + + if (Globals.prescan_node) { + s = path; + d = buffer; + + while(*s) + *d++ = *s++; + + *d++ = _T('/'); + + for(entry=parent->down; entry; entry=entry->next) + if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + lstrcpy(d, entry->data.cFileName); + read_directory_unix(entry, buffer); + SortDirectory(entry, sortOrder); + } + } + } + else +#endif + { + read_directory_win(parent, path); + + if (Globals.prescan_node) { + s = path; + d = buffer; + + while(*s) + *d++ = *s++; + + *d++ = _T('\\'); + + for(entry=parent->down; entry; entry=entry->next) + if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + lstrcpy(d, entry->data.cFileName); + read_directory_win(entry, buffer); + SortDirectory(entry, sortOrder); + } + } + } + + SortDirectory(parent, sortOrder); +} + + // get full path of specified directory entry +void get_path(Entry* dir, PTSTR path) +{ + Entry* entry; + int len = 0; + int level = 0; + + for(entry=dir; entry; level++) { + LPCTSTR name = entry->data.cFileName; + LPCTSTR s = name; + int l; + + for(l=0; *s && *s!=_T('/') && *s!=_T('\\'); s++) + l++; + + if (entry->up) { + memmove(path+l+1, path, len*sizeof(TCHAR)); + memcpy(path+1, name, l*sizeof(TCHAR)); + len += l+1; + +#ifndef _NO_EXTENSIONS + if (entry->unix_dir) + path[0] = _T('/'); + else +#endif + path[0] = _T('\\'); + + entry = entry->up; + } else { + memmove(path+l, path, len*sizeof(TCHAR)); + memcpy(path, name, l*sizeof(TCHAR)); + len += l; + break; + } + } + + if (!level) { +#ifndef _NO_EXTENSIONS + if (entry->unix_dir) + path[len++] = _T('/'); + else +#endif + path[len++] = _T('\\'); + } + + path[len] = _T('\0'); +} + + +#ifndef _NO_EXTENSIONS + +void frame_get_clientspace(HWND hwnd, PRECT prect) +{ + RECT rt; + + if (!IsIconic(hwnd)) + GetClientRect(hwnd, prect); + else { + WINDOWPLACEMENT wp; + + GetWindowPlacement(hwnd, &wp); + + prect->left = prect->top = 0; + prect->right = wp.rcNormalPosition.right-wp.rcNormalPosition.left- + 2*(GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(SM_CXEDGE)); + prect->bottom = wp.rcNormalPosition.bottom-wp.rcNormalPosition.top- + 2*(GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(SM_CYEDGE))- + GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYMENUSIZE); + } + + if (IsWindowVisible(Globals.hToolBar)) { + GetClientRect(Globals.hToolBar, &rt); + prect->top += rt.bottom+2; + } + + if (IsWindowVisible(Globals.hDriveBar)) { + GetClientRect(Globals.hDriveBar, &rt); + prect->top += rt.bottom+2; + } + + if (IsWindowVisible(Globals.hStatusBar)) { + GetClientRect(Globals.hStatusBar, &rt); + prect->bottom -= rt.bottom; + } +} + + +#endif + + +int is_exe_file(LPCTSTR ext) +{ + const static LPCTSTR executable_extensions[] = { + _T("COM"), + _T("EXE"), + _T("BAT"), + _T("CMD"), +#ifndef _NO_EXTENSIONS + _T("CMM"), + _T("BTM"), + _T("AWK"), +#endif + 0 + }; + + TCHAR ext_buffer[_MAX_EXT]; + const LPCTSTR* p; + LPCTSTR s; + LPTSTR d; + + for(s=ext+1,d=ext_buffer; (*d=tolower(*s)); s++) + d++; + + for(p=executable_extensions; *p; p++) + if (!_tcscmp(ext_buffer, *p)) + return 1; + + return 0; +} + +int is_registered_type(LPCTSTR ext) +{ + //TODO + + return 1; +} + +void set_curdir(ChildWnd* child, Entry* entry) +{ + TCHAR path[MAX_PATH]; + + child->left.cur = entry; + child->right.root = entry; + child->right.cur = entry; + + if (!entry->scanned) + scan_entry(child, entry); + 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 + } + + get_path(entry, path); + lstrcpy(child->path, path); + SetWindowText(child->hwnd, path); + SetCurrentDirectory(path); +} + + +// calculate prefered width for all visible columns +BOOL calc_widths(Pane* pane, BOOL anyway) +{ + int col, x, cx, spc=3*Globals.spaceSize.cx; + int entries = ListBox_GetCount(pane->hwnd); + int orgWidths[COLUMNS]; + int orgPositions[COLUMNS+1]; + HFONT hfontOld; + HDC hdc; + int cnt; + + if (!anyway) { + memcpy(orgWidths, pane->widths, sizeof(orgWidths)); + memcpy(orgPositions, pane->positions, sizeof(orgPositions)); + } + + for(col=0; colwidths[col] = 0; + + hdc = GetDC(pane->hwnd); + hfontOld = SelectFont(hdc, Globals.hFont); + + for(cnt=0; cnthwnd, cnt); + + DRAWITEMSTRUCT dis = {0/*CtlType*/, 0/*CtlID*/, + 0/*itemID*/, 0/*itemAction*/, 0/*itemState*/, + pane->hwnd/*hwndItem*/, hdc}; + + draw_item(pane, &dis, entry, COLUMNS); + } + + SelectObject(hdc, hfontOld); + ReleaseDC(pane->hwnd, hdc); + + x = 0; + for(col=0; colpositions[col] = x; + cx = pane->widths[col]; + + if (cx) { + cx += spc; + + if (cx < IMAGE_WIDTH) + cx = IMAGE_WIDTH; + + pane->widths[col] = cx; + } + + x += cx; + } + + pane->positions[COLUMNS] = x; + + ListBox_SetHorizontalExtent(pane->hwnd, x); + + // no change? + if (!memcmp(orgWidths, pane->widths, sizeof(orgWidths))) + return FALSE; + + // don't move, if only collapsing an entry + if (!anyway && pane->widths[0]widths+1, sizeof(orgWidths)-sizeof(int))) { + pane->widths[0] = orgWidths[0]; + memcpy(pane->positions, orgPositions, sizeof(orgPositions)); + + return FALSE; + } + + InvalidateRect(pane->hwnd, 0, TRUE); + + return TRUE; +} + + + // calculate one prefered column width + +void calc_single_width(Pane* pane, int col) +{ + HFONT hfontOld; + int x, cx; + int entries = ListBox_GetCount(pane->hwnd); + int cnt; + HDC hdc; + + pane->widths[col] = 0; + + hdc = GetDC(pane->hwnd); + hfontOld = SelectFont(hdc, Globals.hFont); + + for(cnt=0; cnthwnd, cnt); + DRAWITEMSTRUCT dis = {0, 0, 0, 0, 0, pane->hwnd, hdc}; + + draw_item(pane, &dis, entry, col); + } + + SelectObject(hdc, hfontOld); + ReleaseDC(pane->hwnd, hdc); + + cx = pane->widths[col]; + + if (cx) { + cx += 3*Globals.spaceSize.cx; + + if (cx < IMAGE_WIDTH) + cx = IMAGE_WIDTH; + } + + pane->widths[col] = cx; + + x = pane->positions[col] + cx; + + for(; colpositions[++col] = x; + x += pane->widths[col]; + } + + ListBox_SetHorizontalExtent(pane->hwnd, x); +} + + +#ifndef _NO_EXTENSIONS + +static struct FullScreenParameters { + BOOL mode; + RECT orgPos; + BOOL wasZoomed; +} g_fullscreen = { + FALSE // mode +}; + +BOOL toggle_fullscreen(HWND hwnd) +{ + RECT rt; + + if ((g_fullscreen.mode=!g_fullscreen.mode)) { + GetWindowRect(hwnd, &g_fullscreen.orgPos); + g_fullscreen.wasZoomed = IsZoomed(hwnd); + + Frame_CalcFrameClient(hwnd, &rt); + ClientToScreen(hwnd, (LPPOINT)&rt.left); + ClientToScreen(hwnd, (LPPOINT)&rt.right); + + rt.left = g_fullscreen.orgPos.left-rt.left; + rt.top = g_fullscreen.orgPos.top-rt.top; + rt.right = GetSystemMetrics(SM_CXSCREEN)+g_fullscreen.orgPos.right-rt.right; + rt.bottom = GetSystemMetrics(SM_CYSCREEN)+g_fullscreen.orgPos.bottom-rt.bottom; + + MoveWindow(hwnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE); + } else { + MoveWindow(hwnd, g_fullscreen.orgPos.left, g_fullscreen.orgPos.top, + g_fullscreen.orgPos.right-g_fullscreen.orgPos.left, + g_fullscreen.orgPos.bottom-g_fullscreen.orgPos.top, TRUE); + + if (g_fullscreen.wasZoomed) + ShowWindow(hwnd, WS_MAXIMIZE); + } + + return g_fullscreen.mode; +} + +void fullscreen_move(HWND hwnd) +{ + RECT rt, pos; + GetWindowRect(hwnd, &pos); + + Frame_CalcFrameClient(hwnd, &rt); + ClientToScreen(hwnd, (LPPOINT)&rt.left); + ClientToScreen(hwnd, (LPPOINT)&rt.right); + + rt.left = pos.left-rt.left; + rt.top = pos.top-rt.top; + rt.right = GetSystemMetrics(SM_CXSCREEN)+pos.right-rt.right; + rt.bottom = GetSystemMetrics(SM_CYSCREEN)+pos.bottom-rt.bottom; + + MoveWindow(hwnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE); +} + +#endif diff --git a/rosapps/winfile/utils.h b/rosapps/winfile/utils.h new file mode 100644 index 00000000000..e047d24eb1b --- /dev/null +++ b/rosapps/winfile/utils.h @@ -0,0 +1,55 @@ +/* + * ReactOS winfile + * + * utils.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + + +void display_error(HWND hwnd, DWORD error); +void frame_get_clientspace(HWND hwnd, PRECT prect); +BOOL toggle_fullscreen(HWND hwnd); +void fullscreen_move(HWND hwnd); + +BOOL calc_widths(Pane* pane, BOOL anyway); +void calc_single_width(Pane* pane, int col); +void read_directory(Entry* parent, LPCTSTR path, int sortOrder); +int is_registered_type(LPCTSTR ext); +int is_exe_file(LPCTSTR ext); +void set_curdir(ChildWnd* child, Entry* entry); +void get_path(Entry* dir, PTSTR path); + + + +#ifdef __cplusplus +}; +#endif + +#endif // __UTILS_H__ diff --git a/rosapps/winfile/winfile.c b/rosapps/winfile/winfile.c new file mode 100644 index 00000000000..3f9b5199416 --- /dev/null +++ b/rosapps/winfile/winfile.c @@ -0,0 +1,312 @@ +/* + * ReactOS winfile + * + * winfile.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifdef _MSC_VER +#include "stdafx.h" +#else +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +//#include + +#include "winfile.h" +#include "about.h" +#include "run.h" +#include "treeview.h" +#include "listview.h" +#include "mdiclient.h" +#include "subframe.h" +#include "format.h" + + + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +SORT_ORDER SortOrder = SORT_NAME; + +HWND hTreeWnd; // Tree Control Window +HWND hListWnd; // List Control Window +HWND hSplitWnd; // Splitter Bar Control Window + +int nOldWidth; // Holds the previous client area width +int nOldHeight; // Holds the previous client area height + +BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop + + +//////////////////////////////////////////////////////////////////////////////// + +// OnSize() +// This function handles all the sizing events for the application +// It re-sizes every window, and child window that needs re-sizing +void OnSize(UINT nType, int cx, int cy) +{ + if (nType == SIZE_MINIMIZED) + return; +#if 1 + resize_frame_client(Globals.hMainWnd); +#else + int nParts[3]; + int nXDifference; + int nYDifference; + RECT rc; + + nXDifference = cx - nOldWidth; + nYDifference = cy - nOldHeight; + nOldWidth = cx; + nOldHeight = cy; + + // Update the status bar size + GetWindowRect(Globals.hStatusBar, &rc); + SendMessage(Globals.hStatusBar, WM_SIZE, nType, MAKELPARAM(cx, cy + (rc.bottom - rc.top))); + + // Update the status bar pane sizes + nParts[0] = bInMenuLoop ? -1 : 100; + nParts[1] = 210; + nParts[2] = cx; + SendMessage(Globals.hStatusBar, SB_SETPARTS, bInMenuLoop ? 1 : 3, (long)nParts); + + GetWindowRect(Globals.hStatusBar, &rc); + +// MoveWindow(hTreeWnd,0,0,cx/2,cy-(rc.bottom - rc.top),TRUE); +// MoveWindow(hListWnd,cx/2,0,cx,cy-(rc.bottom - rc.top),TRUE); + +// MoveWindow(Globals.hMDIClient,0,0,cx/2,cy-(rc.bottom - rc.top),TRUE); + ShowWindow(Globals.hMDIClient, SW_SHOW); + +// ShowWindow(hTreeWnd, SW_HIDE); +// ShowWindow(hListWnd, SW_HIDE); +#endif +} + +void OnEnterMenuLoop(HWND hWnd) +{ + int nParts; + + // Update the status bar pane sizes + nParts = -1; + SendMessage(Globals.hStatusBar, SB_SETPARTS, 1, (long)&nParts); + bInMenuLoop = TRUE; + SendMessage(Globals.hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T("")); +} + +void OnExitMenuLoop(HWND hWnd) +{ + RECT rc; + int nParts[3]; +// TCHAR text[260]; + + bInMenuLoop = FALSE; + // Update the status bar pane sizes + GetClientRect(hWnd, &rc); + nParts[0] = 100; + nParts[1] = 210; + nParts[2] = rc.right; + SendMessage(Globals.hStatusBar, SB_SETPARTS, 3, (long)nParts); + SendMessage(Globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)_T("")); +// wsprintf(text, _T("CPU Usage: %3d%%"), PerfDataGetProcessorUsage()); +// SendMessage(Globals.hStatusBar, SB_SETTEXT, 1, (LPARAM)text); +// wsprintf(text, _T("Processes: %d"), PerfDataGetProcessCount()); +// SendMessage(Globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)text); +} + +void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) +{ + TCHAR str[100]; + + strcpy(str, TEXT("")); + if (nFlags & MF_POPUP) { + if (hSysMenu != GetMenu(hWnd)) { + if (nItemID == 2) nItemID = 5; + } + } + if (LoadString(Globals.hInstance, nItemID, str, 100)) { + // load appropriate string + LPTSTR lpsz = str; + // first newline terminates actual string + lpsz = _tcschr(lpsz, '\n'); + if (lpsz != NULL) + *lpsz = '\0'; + } + SendMessage(Globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)str); +} + +// +// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) +// +// PURPOSE: Processes messages for the main window. +// +// WM_COMMAND - process the application menu +// WM_PAINT - Paint the main window +// WM_DESTROY - post a quit message and return +// +// + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND hwndClient; + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; + RECT rc; + //TCHAR szHello[MAX_LOADSTRING]; + //LoadString(Globals.hInstance, IDS_HELLO, szHello, MAX_LOADSTRING); + + switch (message) { + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + + hwndClient = (HWND)SendMessage(Globals.hMDIClient, WM_MDIGETACTIVE, 0, 0); + if (hwndClient) + if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wParam, lParam)) + break; + + // Parse the menu selections: + switch (wmId) { + + case ID_FILE_RUN: + OnFileRun(); + break; + + /* + FormatDisk + */ + + case ID_VIEW_SORT_BY_NAME: + SortOrder = SORT_NAME; + break; + case ID_VIEW_SORT_BY_TYPE: + SortOrder = SORT_EXT; + break; + case ID_VIEW_SORT_BY_SIZE: + SortOrder = SORT_SIZE; + break; + case ID_VIEW_SORT_BY_DATE: + SortOrder = SORT_DATE; + break; + + case ID_OPTIONS_TOOLBAR: + toggle_child(hWnd, wmId, Globals.hToolBar); + break; + case ID_OPTIONS_DRIVEBAR: + toggle_child(hWnd, wmId, Globals.hDriveBar); + break; + case ID_OPTIONS_STATUSBAR: + toggle_child(hWnd, wmId, Globals.hStatusBar); + break; +#if 0 + case ID_REGISTRY_OPENLOCAL: + { + HWND hChildWnd; +// hChildWnd = CreateWindow(szChildClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CHILD, +// CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, hWnd, NULL, Globals.hInstance, NULL); + hChildWnd = CreateWindow(szChildClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CHILD, + 0, 0, 150, 170, hWnd, NULL, Globals.hInstance, NULL); + if (hChildWnd) { + ShowWindow(hChildWnd, 1); + UpdateWindow(hChildWnd); + } + } + break; +#endif + case ID_DISK_FORMAT_DISK: +// SHFormatDrive(hWnd, 0 /* A: */, SHFMT_ID_DEFAULT, 0); + { + UINT OldMode = SetErrorMode(0); // Get the current Error Mode settings. + SetErrorMode(OldMode & ~SEM_FAILCRITICALERRORS); // Force O/S to handle + // Call SHFormatDrive here. + SHFormatDrive(hWnd, 0 /* A: */, SHFMT_ID_DEFAULT, 0); + SetErrorMode(OldMode); // Put it back the way it was. + } + break; + + case ID_HELP_ABOUT: +#if 1 + ShowAboutBox(hWnd); +#else + { + HICON hIcon = LoadIcon(Globals.hInstance, (LPCTSTR)IDI_WINFILE); + ShellAbout(hWnd, szTitle, "", hIcon); + //if (hIcon) DestroyIcon(hIcon); // NOT REQUIRED + } +#endif + break; + case ID_FILE_EXIT: + DestroyWindow(hWnd); + break; + default: +#if 0 + if (SendMessage(Globals.hMDIClient, message, wParam, lParam) != 0) { + //return DefWindowProc(hWnd, message, wParam, lParam); + return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam); + } +#else + //return DefWindowProc(hWnd, message, wParam, lParam); + return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam); +#endif + break; + } + break; + case WM_SIZE: + // Handle the window sizing in it's own function + OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); + break; + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + // TODO: Add any drawing code here... + GetClientRect(hWnd, &rc); + //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); + EndPaint(hWnd, &ps); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + case WM_TIMER: + break; + + case WM_ENTERMENULOOP: + OnEnterMenuLoop(hWnd); + break; + case WM_EXITMENULOOP: + OnExitMenuLoop(hWnd); + break; + case WM_MENUSELECT: + OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam); + break; + default: + //return DefWindowProc(hWnd, message, wParam, lParam); + return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam); + } + return 0; +} diff --git a/rosapps/winfile/winfile.cpp b/rosapps/winfile/winfile.cpp deleted file mode 100644 index 641474e8d3e..00000000000 --- a/rosapps/winfile/winfile.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/* - * ReactOS winfile - * - * winfile.cpp - * - * Copyright (C) 2002 Robert Dickenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifdef _MSC_VER -#include "stdafx.h" -#else -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include "winfile.h" -#include "treeview.h" -#include "listview.h" -#include "resource.h" -#include -//#include - - -// Global Variables: -HINSTANCE hInst; // current instance - -HWND hMainWnd; // Main Window -HWND hStatusWnd; // Status Bar Window - -HWND hTreeWnd; // Tree Control Window -HWND hListWnd; // List Control Window -HWND hSplitWnd; // Splitter Bar Control Window - -int nMinimumWidth; // Minimum width of the dialog (OnSize()'s cx) -int nMinimumHeight; // Minimum height of the dialog (OnSize()'s cy) - -int nOldWidth; // Holds the previous client area width -int nOldHeight; // Holds the previous client area height - -BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop - -TCHAR szTitle[MAX_LOADSTRING]; // The title bar text -TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text -TCHAR szFrameClass[MAX_LOADSTRING]; // The title bar text - -// Foward declarations of functions included in this code module: -ATOM MyRegisterClass(HINSTANCE hInstance); -ATOM MyRegisterClass2(HINSTANCE hInstance); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM); - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - MSG msg; - HACCEL hAccelTable; - - // Initialize global strings - LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadString(hInstance, IDC_WINFILE, szWindowClass, MAX_LOADSTRING); - LoadString(hInstance, IDC_WINFILE_FRAME, szFrameClass, MAX_LOADSTRING); - - MyRegisterClass(hInstance); - MyRegisterClass2(hInstance); - - // Perform application initialization: - if (!InitInstance(hInstance, nCmdShow)) { - return FALSE; - } - hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WINFILE); - - // Main message loop: - while (GetMessage(&msg, NULL, 0, 0)) { - if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - return msg.wParam; -} - - - -// -// FUNCTION: MyRegisterClass() -// -// PURPOSE: Registers the window class. -// -// COMMENTS: -// -// This function and its usage is only necessary if you want this code -// to be compatible with Win32 systems prior to the 'RegisterClassEx' -// function that was added to Windows 95. It is important to call this function -// so that the application will get 'well formed' small icons associated -// with it. -// -ATOM MyRegisterClass(HINSTANCE hInstance) -{ - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WINFILE); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)SS_BLACKRECT/*(COLOR_WINDOW+1)*/; -// wcex.lpszMenuName = (LPCSTR)IDC_WINFILE; - wcex.lpszMenuName = (LPCSTR)IDR_WINFILE_MENU; - wcex.lpszClassName = szWindowClass; - wcex.hIconSm = LoadIcon((HINSTANCE)wcex.hInstance, (LPCTSTR)IDI_SMALL); - return RegisterClassEx(&wcex); -} - -ATOM MyRegisterClass2(HINSTANCE hInstance) -{ - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)FrameWndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WINFILE); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = (LPCSTR)IDR_WINFILE_MENU; - wcex.lpszClassName = szFrameClass; - wcex.hIconSm = LoadIcon((HINSTANCE)wcex.hInstance, (LPCTSTR)IDI_SMALL); - return RegisterClassEx(&wcex); -} - -// -// -// FUNCTION: InitInstance(HANDLE, int) -// -// PURPOSE: Saves instance handle and creates main window -// -// COMMENTS: -// -// In this function, we save the instance handle in a global variable and -// create and display the main program window. -// -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - int nParts[3]; - - // Initialize the Windows Common Controls DLL - InitCommonControls(); - - hInst = hInstance; // Store instance handle in our global variable - hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); - if (!hMainWnd) { - return FALSE; - } - - // Get the minimum window sizes -// GetWindowRect(hMainWnd, &rc); -// nMinimumWidth = (rc.right - rc.left); -// nMinimumHeight = (rc.bottom - rc.top); - - // Create the status bar - hStatusWnd = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, - "", hMainWnd, STATUS_WINDOW); - if (!hStatusWnd) - return FALSE; - - // Create the status bar panes - nParts[0] = 100; - nParts[1] = 210; - nParts[2] = 400; - SendMessage(hStatusWnd, SB_SETPARTS, 3, (long)nParts); - -/* - hSplitWnd = CreateWindow(szFrameClass, "splitter window", WS_VISIBLE|WS_CHILD, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, - hMainWnd, (HMENU)SPLIT_WINDOW, hInstance, NULL); - if (!hSplitWnd) - return FALSE; - */ - hTreeWnd = CreateTreeView(hMainWnd, "c:\\foobar.txt"); - if (!hTreeWnd) - return FALSE; - - hListWnd = CreateListView(hMainWnd, ""); - if (!hListWnd) - return FALSE; - - ShowWindow(hMainWnd, nCmdShow); - UpdateWindow(hMainWnd); - return TRUE; -} - - -// OnSize() -// This function handles all the sizing events for the application -// It re-sizes every window, and child window that needs re-sizing -void OnSize(UINT nType, int cx, int cy) -{ - int nParts[3]; - int nXDifference; - int nYDifference; - RECT rc; - - if (nType == SIZE_MINIMIZED) - return; - - nXDifference = cx - nOldWidth; - nYDifference = cy - nOldHeight; - nOldWidth = cx; - nOldHeight = cy; - - // Update the status bar size - GetWindowRect(hStatusWnd, &rc); - SendMessage(hStatusWnd, WM_SIZE, nType, MAKELPARAM(cx, cy + (rc.bottom - rc.top))); - - // Update the status bar pane sizes - nParts[0] = bInMenuLoop ? -1 : 100; - nParts[1] = 210; - nParts[2] = cx; - SendMessage(hStatusWnd, SB_SETPARTS, bInMenuLoop ? 1 : 3, (long)nParts); - - GetWindowRect(hStatusWnd, &rc); - - MoveWindow(hTreeWnd,0,0,cx/2,cy-(rc.bottom - rc.top),TRUE); - MoveWindow(hListWnd,cx/2,0,cx,cy-(rc.bottom - rc.top),TRUE); - -} - -void OnEnterMenuLoop(HWND hWnd) -{ - int nParts; - - // Update the status bar pane sizes - nParts = -1; - SendMessage(hStatusWnd, SB_SETPARTS, 1, (long)&nParts); - bInMenuLoop = TRUE; - SendMessage(hStatusWnd, SB_SETTEXT, (WPARAM)0, (LPARAM)_T("")); -} - -void OnExitMenuLoop(HWND hWnd) -{ - RECT rc; - int nParts[3]; -// TCHAR text[260]; - - bInMenuLoop = FALSE; - // Update the status bar pane sizes - GetClientRect(hWnd, &rc); - nParts[0] = 100; - nParts[1] = 210; - nParts[2] = rc.right; - SendMessage(hStatusWnd, SB_SETPARTS, 3, (long)nParts); - SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)_T("")); -// wsprintf(text, _T("CPU Usage: %3d%%"), PerfDataGetProcessorUsage()); -// SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text); -// wsprintf(text, _T("Processes: %d"), PerfDataGetProcessCount()); -// SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text); -} - -void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) -{ - TCHAR str[100]; - - strcpy(str, TEXT("")); - if (nFlags & MF_POPUP) { - if (hSysMenu != GetMenu(hWnd)) { - if (nItemID == 2) nItemID = 5; - } - } - if (LoadString(hInst, nItemID, str, 100)) { - // load appropriate string - LPTSTR lpsz = str; - // first newline terminates actual string - lpsz = _tcschr(lpsz, '\n'); - if (lpsz != NULL) - *lpsz = '\0'; - } - SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)str); -} - - -LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; - TCHAR szHello[MAX_LOADSTRING]; - LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); - - switch (message) { - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - // Parse the menu selections: - switch (wmId) { - case IDM_ABOUT: -// ShowAboutBox(hWnd); - { - HICON hIcon = LoadIcon(hInst, (LPCTSTR)IDI_WINFILE); - ShellAbout(hWnd, szTitle, "FrameWndProc", hIcon); - //if (hIcon) DestroyIcon(hIcon); // NOT REQUIRED - } - break; - case IDM_EXIT: - DestroyWindow(hWnd); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - // TODO: Add any drawing code here... - RECT rt; - GetClientRect(hWnd, &rt); - DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; -} - - -// -// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) -// -// PURPOSE: Processes messages for the main window. -// -// WM_COMMAND - process the application menu -// WM_PAINT - Paint the main window -// WM_DESTROY - post a quit message and return -// -// -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; - //TCHAR szHello[MAX_LOADSTRING]; - //LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); - - switch (message) { - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - // Parse the menu selections: - switch (wmId) { - case ID_REGISTRY_OPENLOCAL: - { - HWND hChildWnd; -// hChildWnd = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CHILD, -// CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, hWnd, NULL, hInst, NULL); - hChildWnd = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CHILD, - 0, 0, 150, 170, hWnd, NULL, hInst, NULL); - if (hChildWnd) { - ShowWindow(hChildWnd, 1); - UpdateWindow(hChildWnd); - } - } - break; - case IDM_ABOUT: -// ShowAboutBox(hWnd); - { - HICON hIcon = LoadIcon(hInst, (LPCTSTR)IDI_WINFILE); - ShellAbout(hWnd, szTitle, "", hIcon); - //if (hIcon) DestroyIcon(hIcon); // NOT REQUIRED - } - break; - case IDM_EXIT: - DestroyWindow(hWnd); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - case WM_SIZE: - // Handle the window sizing in it's own function - OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); - break; - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - // TODO: Add any drawing code here... - RECT rt; - GetClientRect(hWnd, &rt); - //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - case WM_TIMER: - break; - - case WM_ENTERMENULOOP: - OnEnterMenuLoop(hWnd); - break; - case WM_EXITMENULOOP: - OnExitMenuLoop(hWnd); - break; - case WM_MENUSELECT: - OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; -} diff --git a/rosapps/winfile/winfile.h b/rosapps/winfile/winfile.h index 8ce207b3c2f..a725d3911cc 100644 --- a/rosapps/winfile/winfile.h +++ b/rosapps/winfile/winfile.h @@ -19,23 +19,139 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + * Based on Winefile, Copyright 2000 martin Fuchs + */ -#ifndef __winfile_H__ -#define __winfile_H__ +#ifndef __WINFILE_H__ +#define __WINFILE_H__ + +#ifdef __cplusplus +extern "C" { +#endif #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "resource.h" +#include "entries.h" + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +//////////////////////////////////////////////////////////////////////////////// + #define STATUS_WINDOW 2001 #define TREE_WINDOW 2002 #define LIST_WINDOW 2003 #define SPLIT_WINDOW 2004 #define MAX_LOADSTRING 100 +#define BUFFER_LEN 1024 + +#define WM_DISPATCH_COMMAND 0xBF80 + +//////////////////////////////////////////////////////////////////////////////// + // range for drive bar command ids: 0x9000..0x90FF +#define ID_DRIVE_FIRST 0x9001 + + +#define _NO_EXTENSIONS + +enum IMAGE { + IMG_NONE=-1, IMG_FILE=0, IMG_DOCUMENT, IMG_EXECUTABLE, + IMG_FOLDER, IMG_OPEN_FOLDER, IMG_FOLDER_PLUS,IMG_OPEN_PLUS, IMG_OPEN_MINUS, + IMG_FOLDER_UP, IMG_FOLDER_CUR +}; + +#define IMAGE_WIDTH 16 +#define IMAGE_HEIGHT 13 +#define SPLIT_WIDTH 5 + +#define IDW_STATUSBAR 0x100 +#define IDW_TOOLBAR 0x101 +#define IDW_DRIVEBAR 0x102 +#define IDW_FIRST_CHILD 0xC000 //0x200 + +#define IDW_TREE_LEFT 3 +#define IDW_TREE_RIGHT 6 +#define IDW_HEADER_LEFT 2 +#define IDW_HEADER_RIGHT 5 + + +//////////////////////////////////////////////////////////////////////////////// +void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext); +void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext); + +#ifdef UNICODE +#define _tsplitpath _wsplitpath +#else +#define _tsplitpath _splitpath +#endif + +//////////////////////////////////////////////////////////////////////////////// + +enum COLUMN_FLAGS { + COL_SIZE = 0x01, + COL_DATE = 0x02, + COL_TIME = 0x04, + COL_ATTRIBUTES = 0x08, + COL_DOSNAMES = 0x10, +#ifdef _NO_EXTENSIONS + COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES +#else + COL_INDEX = 0x20, + COL_LINKS = 0x40, + COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES|COL_INDEX|COL_LINKS +#endif +}; + + +typedef struct +{ + HINSTANCE hInstance; + HACCEL hAccel; + HWND hMainWnd; + HMENU hMenuFrame; + HMENU hWindowsMenu; + HMENU hLanguageMenu; + HMENU hMenuView; + HMENU hMenuOptions; + HWND hMDIClient; + HWND hStatusBar; + HWND hToolBar; + HWND hDriveBar; + HFONT hFont; + + TCHAR num_sep; + SIZE spaceSize; + HIMAGELIST himl; + + TCHAR drives[BUFFER_LEN]; + BOOL prescan_node; //TODO + + LPCSTR lpszLanguage; + UINT wStringTableOffset; + +} WINFILE_GLOBALS; + + +extern WINFILE_GLOBALS Globals; + +extern HINSTANCE hInst; +//extern HWND hMainWnd; +extern TCHAR szTitle[]; +extern TCHAR szChildClass[]; +extern TCHAR szFrameClass[]; +//extern TCHAR szChildClass[]; + +#define STRINGID(id) (Globals.wStringTableOffset + 0x##id) + +#ifdef __cplusplus +}; +#endif -#endif // __winfile_H__ +#endif // __WINFILE_H__ diff --git a/rosapps/winfile/winfile.rc b/rosapps/winfile/winfile.rc index 518e6e86fdb..9ec77248633 100644 --- a/rosapps/winfile/winfile.rc +++ b/rosapps/winfile/winfile.rc @@ -34,10 +34,16 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US IDI_WINFILE ICON DISCARDABLE "winfile.ICO" IDI_SMALL ICON DISCARDABLE "SMALL.ICO" +//////////////////////////////////////////////////////////////////////////////// +// Bitmaps +// + IDB_OPEN_FILE BITMAP DISCARDABLE "folder1.bmp" IDB_CLOSED_FILE BITMAP DISCARDABLE "folder2.bmp" IDB_ROOT BITMAP DISCARDABLE "folder3.bmp" - +IDB_TOOLBAR BITMAP DISCARDABLE "toolbar.bmp" +IDB_DRIVEBAR BITMAP DISCARDABLE "drivebar.bmp" +IDB_IMAGES BITMAP DISCARDABLE "images.bmp" ///////////////////////////////////////////////////////////////////////////// // @@ -48,118 +54,106 @@ IDC_WINFILE MENU DISCARDABLE BEGIN POPUP "&File" BEGIN - MENUITEM "E&xit", IDM_EXIT - END - POPUP "&Help" - BEGIN - MENUITEM "&About ...", IDM_ABOUT - END -END - -IDR_WINFILE_MENU MENU DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Open", ID_VIEW_REFRESH - MENUITEM "&Move...\tF8", ID_VIEW_REFRESH - MENUITEM "&Copy...\tF9", ID_VIEW_REFRESH - MENUITEM "Copy to Clip&board...\tF9", ID_VIEW_REFRESH - MENUITEM "&Delete...\tDel", ID_VIEW_REFRESH - MENUITEM "Re&name...\t", ID_VIEW_REFRESH - MENUITEM "Proper&ties...\tAlt+Enter", ID_VIEW_REFRESH + MENUITEM "&Open\tEnter", ID_FILE_OPEN, GRAYED + MENUITEM "&Move...\tF8", ID_FILE_MOVE, GRAYED + MENUITEM "&Copy...\tF9", ID_FILE_COPY, GRAYED + MENUITEM "Copy to Clip&board...\tF9", ID_FILE_COPY_CLIPBOARD, GRAYED + MENUITEM "&Delete...\tDel", ID_FILE_DELETE, GRAYED + MENUITEM "Re&name...\t", ID_FILE_RENAME, GRAYED + MENUITEM "Proper&ties...\tAlt+Enter", ID_FILE_PROPERTIES, GRAYED MENUITEM SEPARATOR - MENUITEM "Compre&ss...\t", ID_VIEW_REFRESH - MENUITEM "&Uncompress...\t", ID_VIEW_REFRESH + MENUITEM "Compre&ss...\t", ID_FILE_COMPRESS, GRAYED + MENUITEM "&Uncompress...\t", ID_FILE_UNCOMPRESS, GRAYED MENUITEM SEPARATOR - MENUITEM "&Run...\t", ID_VIEW_REFRESH - MENUITEM "&Print...\t", ID_VIEW_REFRESH - MENUITEM "&Associate...\t", ID_VIEW_REFRESH + MENUITEM "&Run...\t", ID_FILE_RUN + MENUITEM "&Print...\t", ID_FILE_PRINT, GRAYED + MENUITEM "&Associate...\t", ID_FILE_ASSOCIATE, GRAYED MENUITEM SEPARATOR - MENUITEM "Cr&eate directory...\t", ID_VIEW_REFRESH - MENUITEM "Searc&h...\t", ID_VIEW_REFRESH - MENUITEM "Select &Files...\t", ID_VIEW_REFRESH + MENUITEM "Cr&eate directory...\t", ID_FILE_CREATE_DIRECTORY, GRAYED + MENUITEM "Searc&h...\t", ID_FILE_SEARCH, GRAYED + MENUITEM "Select &Files...\t", ID_FILE_SEARCH_FILES, GRAYED MENUITEM SEPARATOR - MENUITEM "E&xit", IDM_EXIT + MENUITEM "E&xit", ID_FILE_EXIT END POPUP "&Disk" BEGIN - MENUITEM "&Copy Disk...\t", ID_VIEW_REFRESH - MENUITEM "&Label Disk...\t", ID_VIEW_REFRESH + MENUITEM "&Copy Disk...\t", ID_DISK_COPY_DISK, GRAYED + MENUITEM "&Label Disk...\t", ID_DISK_LABEL_DISK, GRAYED MENUITEM SEPARATOR - MENUITEM "&Format Disk..\t", ID_VIEW_REFRESH + MENUITEM "&Format Disk..\t", ID_DISK_FORMAT_DISK MENUITEM SEPARATOR - MENUITEM "Connect &Network Drive...", ID_VIEW_STATUSBAR - MENUITEM "&Disconnect Network Drive...",ID_VIEW_STATUSBAR + MENUITEM "Connect &Network Drive...", ID_DISK_CONNECT_NETWORK_DRIVE, GRAYED + MENUITEM "&Disconnect Network Drive...",ID_DISK_DISCONNECT_NETWORK_DRIVE, GRAYED MENUITEM SEPARATOR - MENUITEM "Share &As...", ID_VIEW_STATUSBAR - MENUITEM "S&top Sharing...", ID_VIEW_STATUSBAR + MENUITEM "Share &As...", ID_DISK_SHARE_AS, GRAYED + MENUITEM "S&top Sharing...", ID_DISK_STOP_SHARING, GRAYED MENUITEM SEPARATOR - MENUITEM "&Select Drive...\t", ID_VIEW_REFRESH + MENUITEM "&Select Drive...\t", ID_DISK_SELECT_DRIVE, GRAYED END POPUP "&Tree" BEGIN - MENUITEM "E&xpand One Level\t+", ID_VIEW_REFRESH - MENUITEM "Expand &Branch\t*", ID_VIEW_REFRESH - MENUITEM "Expand &All\tCtrl+*", ID_VIEW_REFRESH + MENUITEM "E&xpand One Level\t+", ID_TREE_EXPAND_ONE_LEVEL + MENUITEM "Expand &Branch\t*", ID_TREE_EXPAND_BRANCH + MENUITEM "Expand &All\tCtrl+*", ID_TREE_EXPAND_ALL MENUITEM SEPARATOR - MENUITEM "&Indicate Expandable Branches",ID_VIEW_REFRESH + MENUITEM "&Indicate Expandable Branches",ID_TREE_INDICATE_EXPANDABLE_BRANCHES END POPUP "&View" BEGIN - MENUITEM "T&ree and Directory", ID_VIEW_STATUSBAR - MENUITEM "Tr&ee Only", ID_VIEW_STATUSBAR - MENUITEM "Directory &Only", ID_VIEW_STATUSBAR + MENUITEM "T&ree and Directory", ID_VIEW_TREE_DIRECTORY, GRAYED + MENUITEM "Tr&ee Only", ID_VIEW_TREE_ONLY, GRAYED + MENUITEM "Directory &Only", ID_VIEW_DIRECTORY_ONLY, GRAYED MENUITEM SEPARATOR - MENUITEM "Sp&lit", ID_VIEW_SPLIT + MENUITEM "Sp&lit", ID_VIEW_SPLIT, GRAYED MENUITEM SEPARATOR - MENUITEM "&Name", ID_VIEW_REFRESH - MENUITEM "&All File Details", ID_VIEW_REFRESH - MENUITEM "&Partial Details...", ID_VIEW_REFRESH + MENUITEM "&Name", ID_VIEW_NAME + MENUITEM "&All File Details", ID_VIEW_ALL_FILE_DETAILS + MENUITEM "&Partial Details...", ID_VIEW_PARTIAL_DETAILS, GRAYED MENUITEM SEPARATOR - MENUITEM "&Sort by Name", ID_VIEW_REFRESH - MENUITEM "Sort &by Type", ID_VIEW_REFRESH - MENUITEM "Sort by Si&ze", ID_VIEW_REFRESH - MENUITEM "Sort by &Date", ID_VIEW_REFRESH + MENUITEM "&Sort by Name", ID_VIEW_SORT_BY_NAME + MENUITEM "Sort &by Type", ID_VIEW_SORT_BY_TYPE + MENUITEM "Sort by Si&ze", ID_VIEW_SORT_BY_SIZE + MENUITEM "Sort by &Date", ID_VIEW_SORT_BY_DATE MENUITEM SEPARATOR - MENUITEM "By File &Type...", ID_VIEW_REFRESH + MENUITEM "By File &Type...", ID_VIEW_BY_FILE_TYPE, GRAYED END POPUP "&Options" BEGIN - MENUITEM "&Confirmation...", ID_VIEW_REFRESH - MENUITEM "&Font...", ID_VIEW_REFRESH - MENUITEM "Customise Tool&bar...", ID_VIEW_REFRESH + MENUITEM "&Confirmation...", ID_OPTIONS_CONFIRMATION, GRAYED + MENUITEM "&Font...", ID_OPTIONS_FONT, GRAYED + MENUITEM "Customise Tool&bar...", ID_OPTIONS_CUSTOMISE_TOOLBAR, GRAYED MENUITEM SEPARATOR - MENUITEM "&Toolbar...", ID_VIEW_REFRESH - MENUITEM "&Drivebar...", ID_VIEW_REFRESH - MENUITEM "&Statusbar...", ID_VIEW_REFRESH + MENUITEM "&Toolbar", ID_OPTIONS_TOOLBAR + MENUITEM "&Drivebar", ID_OPTIONS_DRIVEBAR + MENUITEM "&Statusbar", ID_OPTIONS_STATUSBAR MENUITEM SEPARATOR - MENUITEM "&Open New Window on Connect", ID_VIEW_REFRESH - MENUITEM "&Minimise on Use", ID_VIEW_REFRESH - MENUITEM "&Save Settings on Exit", ID_VIEW_REFRESH + MENUITEM "&Open New Window on Connect", ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT + MENUITEM "&Minimise on Use", ID_OPTIONS_MINIMISE_ON_USE + MENUITEM "&Save Settings on Exit", ID_OPTIONS_SAVE_ON_EXIT END POPUP "&Security" BEGIN - MENUITEM "&Permissions...", ID_VIEW_REFRESH, GRAYED - MENUITEM "&Auditing...", ID_VIEW_REFRESH, GRAYED - MENUITEM "&Owner...", ID_VIEW_REFRESH, GRAYED + MENUITEM "&Permissions...", ID_SECURITY_PERMISSIONS, GRAYED + MENUITEM "&Auditing...", ID_SECURITY_AUDITING, GRAYED + MENUITEM "&Owner...", ID_SECURITY_OWNER, GRAYED END POPUP "&Window" BEGIN - MENUITEM "&New Window", ID_VIEW_REFRESH - MENUITEM "&Cascade", ID_VIEW_REFRESH - MENUITEM "Tile &Horizontally", ID_VIEW_REFRESH - MENUITEM "&Tile Vertically", ID_VIEW_REFRESH - MENUITEM "&Arrange Icons", ID_VIEW_REFRESH - MENUITEM "&Refresh", ID_VIEW_REFRESH - MENUITEM SEPARATOR + MENUITEM "&New Window", ID_WINDOW_NEW_WINDOW + MENUITEM "&Cascade\tShift+F5", ID_WINDOW_CASCADE + MENUITEM "Tile &Horizontally", ID_WINDOW_TILE_HORZ + MENUITEM "&Tile Vertically\tShift+F4", ID_WINDOW_TILE_VERT + MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE_ICONS + MENUITEM "&Refresh\tF5", ID_WINDOW_REFRESH +// MENUITEM SEPARATOR END POPUP "&Help" BEGIN - MENUITEM "&Contents", ID_HELP_HELPTOPICS - MENUITEM "&Search for Help on", ID_HELP_HELPTOPICS - MENUITEM "&How to Use Help", ID_HELP_HELPTOPICS + MENUITEM "&Contents", ID_HELP_CONTENTS, GRAYED + MENUITEM "&Search for Help on...", ID_HELP_SEARCH_HELP, GRAYED + MENUITEM "&How to Use Help", ID_HELP_HOW_TO_USE_HELP, GRAYED MENUITEM SEPARATOR - MENUITEM "&About File Manager", IDM_ABOUT + MENUITEM "&About File Manager", ID_HELP_ABOUT END END @@ -225,20 +219,29 @@ BEGIN ID_WINDOW_MENU "Commands for manipulating windows" ID_HELP_MENU "Commands for displaying help and information about file manager" - IDM_EXIT "Quits the file manager" - - ID_EDIT_DELETE "Deletes the selection" - ID_EDIT_RENAME "Renames the selection" - ID_EDIT_COPYKEYNAME "Copies the name of the selected key to the clipboard" - ID_EDIT_FIND "Finds a text string in a key, value or data" - ID_EDIT_FINDNEXT "Finds next occurrence of text specified in previous search" + ID_FILE_DELETE "Deletes the selection" + ID_FILE_RENAME "Renames the selection" + ID_FILE_SEARCH "Finds a text string in a key, value or data" + ID_FILE_SEARCH_FILES "Finds next occurrence of text specified in previous search" + ID_FILE_EXIT "Quits the file manager" + + ID_OPTIONS_CONFIRMATION "Controls confirmation messages..." + ID_OPTIONS_FONT "Changes the File Manager Font..." + ID_OPTIONS_CUSTOMISE_TOOLBAR "Customises the toolbar..." + ID_OPTIONS_TOOLBAR "Shows or hides the tool bar" + ID_OPTIONS_DRIVEBAR "Shows or hides the drive bar" + ID_OPTIONS_STATUSBAR "Shows or hides the status bar" + ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT "Opens a new window when connnecting" + ID_OPTIONS_MINIMISE_ON_USE "Reduces File Manager to an icon at startup" + ID_OPTIONS_SAVE_ON_EXIT "Saves settings when exiting File Manager" - ID_VIEW_STATUSBAR "Shows or hides the status bar" ID_VIEW_SPLIT "Change position of split between two panes" - ID_VIEW_REFRESH "Refreshes the window" + ID_WINDOW_REFRESH "Refreshes the window" - ID_HELP_HELPTOPICS "Opens file manager help" - IDM_ABOUT "Displays program information, version number and copyright" + ID_HELP_CONTENTS "Displays contents for File Manager Help" + ID_HELP_SEARCH_HELP "Searches for a topic in File Manager Help" + ID_HELP_HOW_TO_USE_HELP "Displays information about using help" + ID_HELP_ABOUT "Displays program information, version number and copyright" IDC_WINFILE "WINFILE" IDC_WINFILE_FRAME "WINFILE_FRAME" @@ -312,12 +315,7 @@ END STRINGTABLE DISCARDABLE BEGIN - ID_HELP_HELPTOPICS "Opens File Manager Help." -END - -STRINGTABLE DISCARDABLE -BEGIN - IDM_ABOUT "Displays program information, version number, and copyright." + ID_HELP_ABOUT "Displays program information, version number, and copyright." END #endif // English (Australia) resources