Changelog:
Shachar Shemesh <winecode@sun.consumer.org.il>
programs/notepad/dialog.c
* Fix warning about converting double to int.
* Implemented font selection
programs/notepad/En.rc
* Added accelerators resource
* Added the "Font" entry.
programs/notepad/main.c
* Added support for switching fonts.
Index: programs/notepad/En.rc =================================================================== RCS file: /home/sun/sources/cvs/wine/programs/notepad/En.rc,v retrieving revision 1.9 diff -u -r1.9 En.rc --- programs/notepad/En.rc 17 Aug 2002 18:27:40 -0000 1.9 +++ programs/notepad/En.rc 25 Jan 2003 11:44:30 -0000 @@ -24,14 +24,15 @@ { POPUP "&File" { MENUITEM "&New...", CMD_NEW - MENUITEM "&Open", CMD_OPEN - MENUITEM "&Save", CMD_SAVE + MENUITEM "&Open\tCtrl+O", CMD_OPEN + MENUITEM "&Save\tCtrl+S", CMD_SAVE MENUITEM "Save &as...", CMD_SAVE_AS + MENUITEM SEPARATOR MENUITEM "&Print", CMD_PRINT MENUITEM "Page Se&tup...", CMD_PAGE_SETUP MENUITEM "P&rinter Setup...", CMD_PRINTER_SETUP MENUITEM SEPARATOR - MENUITEM "&Exit", CMD_EXIT + MENUITEM "E&xit", CMD_EXIT } POPUP "&Edit" { MENUITEM "&Undo\tCtrl+Z", CMD_UNDO @@ -41,15 +42,17 @@ MENUITEM "&Paste\tCtrl+V", CMD_PASTE MENUITEM "&Delete\tDel", CMD_DELETE MENUITEM SEPARATOR - MENUITEM "Select &all", CMD_SELECT_ALL + MENUITEM "Select &all\tCtrl+A", CMD_SELECT_ALL MENUITEM "&Time/Date\tF5", CMD_TIME_DATE - MENUITEM SEPARATOR - MENUITEM "&Wrap long lines", CMD_WRAP } POPUP "&Search" { - MENUITEM "&Search", CMD_SEARCH + MENUITEM "&Search\tCtrl+F", CMD_SEARCH MENUITEM "&Search next\tF3", CMD_SEARCH_NEXT } +POPUP "&Format" { + MENUITEM "&Wrap long lines", CMD_WRAP + MENUITEM "&Font...", CMD_FONT + } POPUP "&Help" { MENUITEM "&Contents", CMD_HELP_CONTENTS MENUITEM "&Search...", CMD_HELP_SEARCH @@ -89,6 +92,16 @@ DEFPUSHBUTTON "OK", 0x151, 180, 3, 40, 15, WS_TABSTOP PUSHBUTTON "Cancel", 0x152, 180, 21, 40, 15, WS_TABSTOP PUSHBUTTON "&Help", 0x153, 180, 39, 40, 15, WS_TABSTOP +} + +ID_ACCEL ACCELERATORS LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT +{ + "^A", CMD_SELECT_ALL + "^F", CMD_SEARCH + "^O", CMD_OPEN + "^S", CMD_SAVE + VK_F3, CMD_SEARCH_NEXT, VIRTKEY + VK_F5, CMD_TIME_DATE, VIRTKEY } STRINGTABLE DISCARDABLE LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT Index: programs/notepad/dialog.c =================================================================== RCS file: /home/sun/sources/cvs/wine/programs/notepad/dialog.c,v retrieving revision 1.22 diff -u -r1.22 dialog.c --- programs/notepad/dialog.c 21 Oct 2002 18:22:15 -0000 1.22 +++ programs/notepad/dialog.c 25 Jan 2003 12:07:23 -0000 @@ -504,7 +504,7 @@ /* I don't know what's up with this TextOut command. This comes out kind of mangled. */ - TextOut(hContext, border*2, border+szMetric.cy*0.5, szDocumentName, count); + TextOut(hContext, border*2, border+szMetric.cy/2, szDocumentName, count); } /* The starting point for the main text */ @@ -667,6 +667,29 @@ Globals.bWrapLongLines = !Globals.bWrapLongLines; CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP, MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED)); +} + +VOID DIALOG_SelectFont(VOID) +{ + CHOOSEFONT cf; + LOGFONT lf=Globals.lfFont; + + ZeroMemory( &cf, sizeof(cf) ); + cf.lStructSize=sizeof(cf); + cf.hwndOwner=Globals.hMainWnd; + cf.lpLogFont=&lf; + cf.Flags=CF_SCREENFONTS; + + if( ChooseFont(&cf) ) + { + HFONT currfont=Globals.hFont; + + Globals.hFont=CreateFontIndirect( &lf ); + Globals.lfFont=lf; + SendMessage( Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)TRUE ); + if( currfont!=NULL ) + DeleteObject( currfont ); + } } VOID DIALOG_Search(VOID) Index: programs/notepad/main.c =================================================================== RCS file: /home/sun/sources/cvs/wine/programs/notepad/main.c,v retrieving revision 1.25 diff -u -r1.25 main.c --- programs/notepad/main.c 15 Nov 2002 04:13:46 -0000 1.25 +++ programs/notepad/main.c 25 Jan 2003 11:44:30 -0000 @@ -72,10 +72,12 @@ case CMD_DELETE: DIALOG_EditDelete(); break; case CMD_SELECT_ALL: DIALOG_EditSelectAll(); break; case CMD_TIME_DATE: DIALOG_EditTimeDate();break; - case CMD_WRAP: DIALOG_EditWrap(); break; case CMD_SEARCH: DIALOG_Search(); break; case CMD_SEARCH_NEXT: DIALOG_SearchNext(); break; + + case CMD_WRAP: DIALOG_EditWrap(); break; + case CMD_FONT: DIALOG_SelectFont(); break; case CMD_HELP_CONTENTS: DIALOG_HelpContents(); break; case CMD_HELP_SEARCH: DIALOG_HelpSearch(); break; @@ -118,23 +120,16 @@ { RECT rc; GetClientRect(hWnd, &rc); - if (LoadLibrary("RichEd32.dll")) - { - Globals.hEdit = - CreateWindow("RICHEDIT", "", + Globals.hEdit = CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0, 0, rc.right, rc.bottom, hWnd, NULL, Globals.hInstance, NULL); - } else { - ShowLastError(); - return -1; - } break; } case WM_COMMAND: - NOTEPAD_MenuCommand(wParam); + NOTEPAD_MenuCommand(LOWORD(wParam)); break; case WM_DESTROYCLIPBOARD: @@ -273,6 +268,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) { MSG msg; + HACCEL hAccel; WNDCLASSEX class; char className[] = "NPClass"; char winName[] = "Notepad"; @@ -313,9 +309,22 @@ HandleCommandLine(cmdline); - while (GetMessage(&msg, 0, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + hAccel=LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) ); + + if( hAccel!=NULL ) + { + while( GetMessage(&msg, 0, 0, 0)) { + if( !TranslateAccelerator( Globals.hMainWnd, hAccel, &msg ) ) { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + } + } else + { + while (GetMessage(&msg, 0, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } } return msg.wParam; } Index: programs/notepad/main.h =================================================================== RCS file: /home/sun/sources/cvs/wine/programs/notepad/main.h,v retrieving revision 1.13 diff -u -r1.13 main.h --- programs/notepad/main.h 8 Jul 2002 19:41:09 -0000 1.13 +++ programs/notepad/main.h 25 Jan 2003 12:01:14 -0000 @@ -46,6 +46,8 @@ HWND hMainWnd; HWND hFindReplaceDlg; HWND hEdit; + HFONT hFont; /* Font used by the edit control */ + LOGFONT lfFont; HICON hMainIcon; HICON hDefaultIcon; LPCSTR lpszIcoFile; Index: programs/notepad/notepad_res.h =================================================================== RCS file: /home/sun/sources/cvs/wine/programs/notepad/notepad_res.h,v retrieving revision 1.2 diff -u -r1.2 notepad_res.h --- programs/notepad/notepad_res.h 8 Jul 2002 19:41:09 -0000 1.2 +++ programs/notepad/notepad_res.h 25 Jan 2003 11:44:30 -0000 @@ -21,6 +21,7 @@ #define MAIN_MENU 0x201 #define DIALOG_PAGESETUP 0x202 +#define ID_ACCEL 0x203 /* Commands */ #define CMD_NEW 0x100 @@ -39,10 +40,12 @@ #define CMD_DELETE 0x114 #define CMD_SELECT_ALL 0x116 #define CMD_TIME_DATE 0x117 -#define CMD_WRAP 0x119 #define CMD_SEARCH 0x120 #define CMD_SEARCH_NEXT 0x121 + +#define CMD_WRAP 0x119 +#define CMD_FONT 0x140 #define CMD_HELP_CONTENTS 0x130 #define CMD_HELP_SEARCH 0x131