Added some functions to winefile.
Piotr Caban
pio13 at poczta.onet.pl
Mon Sep 27 06:49:49 CDT 2004
Changelog:
- added choosing fonts
- added file moving
-------------- next part --------------
Index: programs/winefile/En.rc
===================================================================
RCS file: /home/wine/wine/programs/winefile/En.rc,v
retrieving revision 1.4
diff -u -r1.4 En.rc
--- programs/winefile/En.rc 27 Oct 2003 22:03:28 -0000 1.4
+++ programs/winefile/En.rc 27 Sep 2004 11:31:56 -0000
@@ -29,7 +29,7 @@
{
POPUP "&File" {
MENUITEM "&Open\tEnter" , 101
- MENUITEM "&Move...\tF7" , 106
+ MENUITEM "&Move...\tF7" , ID_FILE_MOVE
MENUITEM "&Copy...\tF8" , 107
MENUITEM "&In Clipboard...\tF9" , 118
MENUITEM "&Delete\tDel" , 108
@@ -102,7 +102,7 @@
POPUP "&Options" {
MENUITEM "&Confirmation..." , -1
- MENUITEM "&Font..." , -1
+ MENUITEM "&Font..." , ID_SELECT_FONT
MENUITEM "Customize Tool&bar..." , -1
MENUITEM SEPARATOR
MENUITEM "&Toolbar" , ID_VIEW_TOOL_BAR, CHECKED
@@ -160,7 +160,28 @@
CONTROL "&Command:" , -1, "Static", SS_LEFTNOWORDWRAP|WS_GROUP, 3, 18, 60, 10
EDITTEXT 201, 3, 29, 134, 12, ES_AUTOHSCROLL
CONTROL "As &Symbol" , 214, "Button", BS_AUTOCHECKBOX|WS_TABSTOP,3, 45, 71, 12
- DEFPUSHBUTTON "OK" , 1, 158, 6, 47, 14
+ DEFPUSHBUTTON "OK" , 1, 158, 6, 47, 14
PUSHBUTTON "Cancel" , 2, 158, 23, 47, 14
PUSHBUTTON "&Help" , 254, 158, 43, 47, 14
+}
+
+IDD_SELECT_DESTINATION DIALOG FIXED IMPURE 15, 13, 210, 63
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Select destination"
+FONT 8, "MS Shell Dlg"
+{
+ CONTROL "", 101, "Static", SS_SIMPLE|SS_NOPREFIX, 3, 6, 162, 10
+ CONTROL "&Path:" , -1, "Static", SS_LEFTNOWORDWRAP|WS_GROUP, 3, 18, 60, 10
+ EDITTEXT 201, 3, 29, 134, 12, ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK" , 1, 158, 6, 47, 14
+ PUSHBUTTON "Cancel" , 2, 158, 23, 47, 14
+ PUSHBUTTON "&Browse" , 254, 158, 43, 47, 14
+}
+
+STRINGTABLE
+{
+ IDS_FONT_SEL_DLG_NAME "Applying font settings"
+ IDS_FONT_SEL_DLG_INFO "Changed font settings apply only to newly started windows."
+ IDS_FONT_SEL_ERROR "Error while selecting new font."
+ IDS_FILE_MOVE_ERROR "Error while moving file or directory."
}
Index: programs/winefile/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/winefile/Makefile.in,v
retrieving revision 1.8
diff -u -r1.8 Makefile.in
--- programs/winefile/Makefile.in 9 Mar 2004 04:54:07 -0000 1.8
+++ programs/winefile/Makefile.in 27 Sep 2004 11:31:56 -0000
@@ -5,7 +5,7 @@
VPATH = @srcdir@
MODULE = winefile.exe
APPMODE = -mwindows
-IMPORTS = shell32 comctl32 ole32 user32 gdi32 kernel32
+IMPORTS = shell32 comctl32 ole32 user32 gdi32 kernel32 comdlg32
EXTRALIBS = -luuid
C_SRCS = \
Index: programs/winefile/Pl.rc
===================================================================
RCS file: /home/wine/wine/programs/winefile/Pl.rc,v
retrieving revision 1.1
diff -u -r1.1 Pl.rc
--- programs/winefile/Pl.rc 22 Sep 2004 19:18:15 -0000 1.1
+++ programs/winefile/Pl.rc 27 Sep 2004 11:31:56 -0000
@@ -30,7 +30,7 @@
{
POPUP "&Plik" {
MENUITEM "&Otwórz\tEnter" , 101
- MENUITEM "&Przenie...\tF7" , 106
+ MENUITEM "&Przenie...\tF7" , ID_FILE_MOVE
MENUITEM "&Kopiuj...\tF8" , 107
MENUITEM "W s&chowku...\tF9" , 118
MENUITEM "&Usuń\tDel" , 108
@@ -103,7 +103,7 @@
POPUP "&Opcje" {
MENUITEM "&Potwierdzenie..." , -1
- MENUITEM "&Czcionka..." , -1
+ MENUITEM "&Czcionka..." , ID_SELECT_FONT
MENUITEM "&Ustawienia paska narzędzi..." , -1
MENUITEM SEPARATOR
MENUITEM "Pasek &narzędzi" , ID_VIEW_TOOL_BAR, CHECKED
@@ -165,3 +165,25 @@
PUSHBUTTON "Anuluj" , 2, 158, 23, 47, 14
PUSHBUTTON "&Pomoc" , 254, 158, 43, 47, 14
}
+
+IDD_SELECT_DESTINATION DIALOG FIXED IMPURE 15, 13, 210, 63
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Wybór celu"
+FONT 8, "MS Shell Dlg"
+{
+ CONTROL "", 101, "Static", SS_SIMPLE|SS_NOPREFIX, 3, 6, 162, 10
+ CONTROL "&cieżka:" , -1, "Static", SS_LEFTNOWORDWRAP|WS_GROUP, 3, 18, 60, 10
+ EDITTEXT 201, 3, 29, 134, 12, ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK" , 1, 158, 6, 47, 14
+ PUSHBUTTON "Anuluj" , 2, 158, 23, 47, 14
+ PUSHBUTTON "&Przeglšdaj" , 254, 158, 43, 47, 14
+}
+
+STRINGTABLE
+{
+ IDS_FONT_SEL_DLG_NAME "Wprowadzanie ustawień czcionki"
+ IDS_FONT_SEL_DLG_INFO "Nowe ustawienia czcionki zadziałajš jedynie dla nowo otwartych okien."
+ IDS_FONT_SEL_ERROR "Błšd przy wybieraniu czcionki"
+ IDS_FILE_MOVE_ERROR "Błšd przy przenoszeniu pliku."
+}
+
Index: programs/winefile/resource.h
===================================================================
RCS file: /home/wine/wine/programs/winefile/resource.h,v
retrieving revision 1.2
diff -u -r1.2 resource.h
--- programs/winefile/resource.h 13 Aug 2003 01:18:37 -0000 1.2
+++ programs/winefile/resource.h 27 Sep 2004 11:31:56 -0000
@@ -32,16 +32,19 @@
/* dialogs */
#define IDD_EXECUTE 103
+#define IDD_SELECT_DESTINATION 104
/* control ids */
#define ID_ACTIVATE 101
#define ID_EXECUTE 105
+#define ID_FILE_MOVE 106
#define ID_FILE_EXIT 115
#define ID_VIEW_NAME 401
#define ID_VIEW_ALL_ATTRIBUTES 402
#define ID_VIEW_SELECTED_ATTRIBUTES 403
+#define ID_SELECT_FONT 510
#define ID_VIEW_TOOL_BAR 508
#define ID_VIEW_DRIVE_BAR 507
#define ID_VIEW_STATUSBAR 503
@@ -66,6 +69,12 @@
#define ID_WINDOW_AUTOSORT 0x8003
#define ID_VIEW_FULLSCREEN 0x8004
#define ID_PREFERED_SIZES 0x8005
+
+/* string table */
+#define IDS_FONT_SEL_DLG_NAME 1101
+#define IDS_FONT_SEL_DLG_INFO 1102
+#define IDS_FONT_SEL_ERROR 1103
+#define IDS_FILE_MOVE_ERROR 1104
/* range for drive bar command ids: 0x9000..0x90FF */
#ifdef __WINE__
Index: programs/winefile/resource.rc
===================================================================
RCS file: /home/wine/wine/programs/winefile/resource.rc,v
retrieving revision 1.3
diff -u -r1.3 resource.rc
--- programs/winefile/resource.rc 4 Oct 2003 04:21:19 -0000 1.3
+++ programs/winefile/resource.rc 27 Sep 2004 11:31:56 -0000
@@ -20,6 +20,7 @@
{
VK_F1, ID_HELP, VIRTKEY, NOINVERT
VK_F5, ID_REFRESH, VIRTKEY, NOINVERT
+ VK_F7, ID_FILE_MOVE, VIRTKEY, NOINVERT
VK_RETURN, ID_ACTIVATE, VIRTKEY, NOINVERT
#ifndef _NO_EXTENSIONS
"X", ID_FILE_EXIT, VIRTKEY, ALT, NOINVERT
Index: programs/winefile/winefile.c
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.c,v
retrieving revision 1.19
diff -u -r1.19 winefile.c
--- programs/winefile/winefile.c 22 Sep 2004 19:11:49 -0000 1.19
+++ programs/winefile/winefile.c 27 Sep 2004 11:31:57 -0000
@@ -190,8 +190,6 @@
LocalFree(msg);
}
-
-/* allocate and initialise a directory entry */
static Entry* alloc_entry()
{
Entry* entry = (Entry*) malloc(sizeof(Entry));
@@ -1490,7 +1488,7 @@
mcs.y = child->pos.rcNormalPosition.top;
mcs.cx = child->pos.rcNormalPosition.right-child->pos.rcNormalPosition.left;
mcs.cy = child->pos.rcNormalPosition.bottom-child->pos.rcNormalPosition.top;
- mcs.style = 0;
+ mcs.style = 1;
mcs.lParam = 0;
hcbthook = SetWindowsHookEx(WH_CBT, CBTProc, 0, GetCurrentThreadId());
@@ -1504,6 +1502,8 @@
UnhookWindowsHookEx(hcbthook);
+ ListBox_SetItemHeight(child->left.hwnd, 1, GETMAX(Globals.spaceSize.cy,IMAGE_HEIGHT+3));
+ ListBox_SetItemHeight(child->right.hwnd, 1, GETMAX(Globals.spaceSize.cy,IMAGE_HEIGHT+3));
idx = ListBox_FindItemData(child->left.hwnd, ListBox_GetCurSel(child->left.hwnd), child->left.cur);
ListBox_SetCurSel(child->left.hwnd, idx);
@@ -1543,6 +1543,29 @@
return 0;
}
+static BOOL CALLBACK sDestinationWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
+{
+ switch(nmsg) {
+ case WM_INITDIALOG:
+ return 1;
+
+ case WM_COMMAND:{
+ int id = (int)wparam;
+ if (id == IDOK) {
+ char *dest;
+ dest = malloc(MAX_PATH);
+ GetWindowText(GetDlgItem(hwnd, 201), dest, MAX_PATH);
+ EndDialog(hwnd, (int)dest);
+ }
+ else if (id == IDCANCEL) EndDialog(hwnd, id);
+ else if (id == 254) MessageBox(hwnd, TEXT("Not yet implemented"), TEXT("Winefile"), MB_OK);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
#ifndef _NO_EXTENSIONS
@@ -1792,6 +1815,42 @@
case ID_WINDOW_ARRANGE:
SendMessage(Globals.hmdiclient, WM_MDIICONARRANGE, 0, 0);
break;
+
+ case ID_SELECT_FONT: {
+ CHOOSEFONT chFont;
+ LOGFONT lFont;
+ HDC hdc = GetDC(hwnd);
+ char dlg_name[255], dlg_info[255];
+ chFont.lStructSize = sizeof(CHOOSEFONT);
+ chFont.hwndOwner = hwnd;
+ chFont.hDC = NULL;
+ chFont.lpLogFont = &lFont;
+ chFont.Flags = CF_SCREENFONTS | CF_FORCEFONTEXIST | CF_LIMITSIZE | CF_NOSCRIPTSEL;
+ chFont.rgbColors = RGB(0,0,0);
+ chFont.lCustData = 0;
+ chFont.lpfnHook = NULL;
+ chFont.lpTemplateName = NULL;
+ chFont.hInstance = Globals.hInstance;
+ chFont.lpszStyle = NULL;
+ chFont.nFontType = SIMULATED_FONTTYPE;
+ chFont.nSizeMin = 0;
+ chFont.nSizeMax = 24;
+ if(ChooseFont(&chFont)) {
+ LoadString(Globals.hInstance, IDS_FONT_SEL_DLG_NAME, dlg_name, MAX_LOAD_STRING);
+ LoadString(Globals.hInstance, IDS_FONT_SEL_DLG_INFO, dlg_info, MAX_LOAD_STRING);
+ MessageBox(hwnd,dlg_info,dlg_name,MB_OK|MB_ICONINFORMATION);
+ Globals.hfont = CreateFontIndirect(&lFont);
+ SelectFont(hdc, Globals.hfont);
+ GetTextExtentPoint32(hdc, TEXT(" "), 1, &Globals.spaceSize);
+ }
+ else if(CommDlgExtendedError()) {
+ LoadString(Globals.hInstance, IDS_FONT_SEL_DLG_NAME, dlg_name, MAX_LOAD_STRING);
+ LoadString(Globals.hInstance, IDS_FONT_SEL_ERROR, dlg_info, MAX_LOAD_STRING);
+ MessageBox(hwnd,dlg_info,dlg_name,MB_OK);
+ }
+ ReleaseDC(hwnd,hdc);
+ break;
+ }
case ID_VIEW_TOOL_BAR:
toggle_child(hwnd, cmd, Globals.htoolbar);
@@ -2473,7 +2532,7 @@
if (pane->treePane) {
if (entry) {
- img_pos = dis->rcItem.left + entry->level*(IMAGE_WIDTH+Globals.spaceSize.cx);
+ img_pos = dis->rcItem.left + entry->level*(IMAGE_WIDTH+TREE_LINE_DX);
if (calcWidthCol == -1) {
int x;
@@ -2506,7 +2565,7 @@
x = img_pos - IMAGE_WIDTH/2;
do {
- x -= IMAGE_WIDTH+Globals.spaceSize.cx;
+ x -= IMAGE_WIDTH+TREE_LINE_DX;
if (up->next
#ifndef _LEFT_FILES
@@ -2532,8 +2591,8 @@
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);
+ x += IMAGE_WIDTH+TREE_LINE_DX;
+ MoveToEx(dis->hDC, x, dis->rcItem.top+IMAGE_HEIGHT+2, 0);
LineTo(dis->hDC, x, dis->rcItem.bottom);
}
@@ -2541,7 +2600,7 @@
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;
+ int right = img_pos + IMAGE_WIDTH - TREE_LINE_DX;
if (right > pane->widths[col])
pane->widths[col] = right;
@@ -2565,7 +2624,7 @@
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;
+ focusRect.right = dis->rcItem.left+pane->positions[col+1]+TREE_LINE_DX + rt.right +2;
}
#else
@@ -2584,6 +2643,10 @@
hbrush = CreateSolidBrush(bkcolor);
FillRect(dis->hDC, &focusRect, hbrush);
+ if (entry->down && entry->expanded) {
+ MoveToEx(dis->hDC, img_pos + IMAGE_WIDTH/2 + TREE_LINE_DX, dis->rcItem.top+IMAGE_HEIGHT+2, 0);
+ LineTo(dis->hDC, img_pos + IMAGE_WIDTH/2 + TREE_LINE_DX, dis->rcItem.bottom);
+ }
DeleteObject(hbrush);
SetBkMode(dis->hDC, TRANSPARENT);
@@ -2592,6 +2655,7 @@
cx = pane->widths[col];
if (cx && img!=IMG_NONE) {
+
if (cx > IMAGE_WIDTH)
cx = IMAGE_WIDTH;
@@ -3278,6 +3342,8 @@
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lparam;
Entry* entry = (Entry*) dis->itemData;
+ /*dis->rcItem.top*=2;
+ dis->rcItem.bottom*=2;*/
if (dis->CtlID == IDW_TREE_LEFT)
draw_item(&child->left, dis, entry, -1);
else
@@ -3451,6 +3517,39 @@
case ID_ACTIVATE:
activate_entry(child, pane, hwnd);
break;
+
+ case ID_FILE_MOVE: {
+ char *new_name,*old_name;
+ int len;
+ if((int)(new_name=(char *)DialogBox(Globals.hInstance, MAKEINTRESOURCE(IDD_SELECT_DESTINATION), hwnd, sDestinationWndProc))==1|| (int)new_name==IDCANCEL) break;
+ old_name = malloc(MAX_PATH);
+ if(new_name[1]!=':' && new_name[0]!='/') {
+ get_path(pane->cur->up, old_name);
+ len = strlen(old_name);
+ if(old_name[len-1]!='\\') {
+ old_name[len]='\\';
+ len++;
+ old_name[len]='\n';
+ }
+ strcpy(&old_name[len], new_name);
+ strcpy(new_name, old_name);
+ }
+ get_path(pane->cur, old_name);
+ if(MoveFileEx(old_name,new_name,MOVEFILE_COPY_ALLOWED)) {
+ if(pane->treePane) {
+ pane->root->scanned=FALSE;
+ pane->cur=pane->root;
+ activate_entry(child, pane, hwnd);
+ }
+ else scan_entry(child, pane->root, hwnd);
+ }
+ else {
+ LoadString(Globals.hInstance, IDS_FILE_MOVE_ERROR, old_name, MAX_PATH);
+ MessageBox(hwnd, old_name, "WineFile", MB_OK);
+ }
+ free(old_name);
+ free(new_name);
+ break;}
default:
return pane_command(pane, LOWORD(wparam));
Index: programs/winefile/winefile.h
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.h,v
retrieving revision 1.7
diff -u -r1.7 winefile.h
--- programs/winefile/winefile.h 22 Sep 2004 19:11:49 -0000 1.7
+++ programs/winefile/winefile.h 27 Sep 2004 11:31:57 -0000
@@ -36,6 +36,7 @@
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
+#include <commdlg.h>
#include <shellapi.h>
#include <stdlib.h>
#include <stdio.h>
@@ -74,10 +75,13 @@
IMG_FOLDER, IMG_OPEN_FOLDER, IMG_FOLDER_PLUS,IMG_OPEN_PLUS, IMG_OPEN_MINUS,
IMG_FOLDER_UP, IMG_FOLDER_CUR
};
-
+#ifndef MAX_LOAD_STRING
+#define MAX_LOAD_STRING 256
+#endif
#define IMAGE_WIDTH 16
-#define IMAGE_HEIGHT 13
+#define IMAGE_HEIGHT 13
#define SPLIT_WIDTH 5
+#define TREE_LINE_DX 3
#define IDW_STATUSBAR 0x100
#define IDW_TOOLBAR 0x101
@@ -107,6 +111,8 @@
#define FRM_CALC_CLIENT 0xBF83
#define Frame_CalcFrameClient(hwnd, prt) ((BOOL)SNDMSG(hwnd, FRM_CALC_CLIENT, 0, (LPARAM)(PRECT)prt))
+
+#define GETMAX(x, y) ((x)>(y)) ? (x):(y)
#ifndef _NO_EXTENSIONS
More information about the wine-patches
mailing list