Notepad:
1. Fixed syntax errors in the ES and NL localizations
2. Added code to save and restore settings; just the font for now
Modified: trunk/reactos/subsys/system/notepad/Es.rc
Modified: trunk/reactos/subsys/system/notepad/Nl.rc
Modified: trunk/reactos/subsys/system/notepad/main.c
Modified: trunk/reactos/subsys/system/notepad/main.h
Modified: trunk/reactos/subsys/system/notepad/notepad.xml
Modified: trunk/reactos/subsys/system/notepad/rsrc.rc
Added: trunk/reactos/subsys/system/notepad/settings.c
_____
Modified: trunk/reactos/subsys/system/notepad/Es.rc
--- trunk/reactos/subsys/system/notepad/Es.rc 2005-09-30 01:47:46 UTC
(rev 18163)
+++ trunk/reactos/subsys/system/notepad/Es.rc 2005-09-30 02:53:34 UTC
(rev 18164)
@@ -55,8 +55,6 @@
MENUITEM "&Ajuste de lÝnea", CMD_WRAP
MENUITEM "Tipo de &letra...", CMD_FONT
}
-POPUP "&Buscar" {
- }
POPUP "A&yuda" {
MENUITEM "?&ndice", CMD_HELP_CONTENTS
MENUITEM "&Buscar...", CMD_HELP_SEARCH
_____
Modified: trunk/reactos/subsys/system/notepad/Nl.rc
--- trunk/reactos/subsys/system/notepad/Nl.rc 2005-09-30 01:47:46 UTC
(rev 18163)
+++ trunk/reactos/subsys/system/notepad/Nl.rc 2005-09-30 02:53:34 UTC
(rev 18164)
@@ -1,4 +1,4 @@
-´??/*
+/*
* Notepad (Dutch resources)
*
* Copyright 2003 Hans Leidekker
@@ -38,7 +38,7 @@
MENUITEM "&Ongedaan maken\tCtrl+Z", CMD_UNDO
MENUITEM SEPARATOR
MENUITEM "K&nippen\tCtrl+X", CMD_CUT
- MENUITEM "&Kopi?½ren\tCtrl+C", CMD_COPY
+ MENUITEM "&KopiÙren\tCtrl+C", CMD_COPY
MENUITEM "&Plakken\tCtrl+V", CMD_PASTE
MENUITEM "&Verwijderen\tDel", CMD_DELETE
MENUITEM SEPARATOR
_____
Modified: trunk/reactos/subsys/system/notepad/main.c
--- trunk/reactos/subsys/system/notepad/main.c 2005-09-30 01:47:46 UTC
(rev 18163)
+++ trunk/reactos/subsys/system/notepad/main.c 2005-09-30 02:53:34 UTC
(rev 18164)
@@ -292,6 +292,8 @@
if (!Globals.hEdit)
return -1;
SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
+ if (Globals.hFont)
+ SendMessage(Globals.hEdit, WM_SETFONT,
(WPARAM)Globals.hFont, (LPARAM)TRUE);
break;
}
@@ -492,6 +494,7 @@
ZeroMemory(&Globals, sizeof(Globals));
Globals.hInstance = hInstance;
+ LoadSettings();
ZeroMemory(&class, sizeof(class));
class.cbSize = sizeof(class);
@@ -537,5 +540,6 @@
DispatchMessage(&msg);
}
}
+ SaveSettings();
return msg.wParam;
}
_____
Modified: trunk/reactos/subsys/system/notepad/main.h
--- trunk/reactos/subsys/system/notepad/main.h 2005-09-30 01:47:46 UTC
(rev 18163)
+++ trunk/reactos/subsys/system/notepad/main.h 2005-09-30 02:53:34 UTC
(rev 18164)
@@ -73,4 +73,8 @@
BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, int
*piEncoding, int *piEoln);
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, int
iEncoding, int iEoln);
+/* from settings.c */
+void LoadSettings(void);
+void SaveSettings(void);
+
_____
Modified: trunk/reactos/subsys/system/notepad/notepad.xml
--- trunk/reactos/subsys/system/notepad/notepad.xml 2005-09-30
01:47:46 UTC (rev 18163)
+++ trunk/reactos/subsys/system/notepad/notepad.xml 2005-09-30
02:53:34 UTC (rev 18164)
@@ -11,5 +11,6 @@
<file>license.c</file>
<file>main.c</file>
<file>text.c</file>
+ <file>settings.c</file>
<file>rsrc.rc</file>
</module>
_____
Modified: trunk/reactos/subsys/system/notepad/rsrc.rc
--- trunk/reactos/subsys/system/notepad/rsrc.rc 2005-09-30 01:47:46 UTC
(rev 18163)
+++ trunk/reactos/subsys/system/notepad/rsrc.rc 2005-09-30 02:53:34 UTC
(rev 18164)
@@ -31,7 +31,7 @@
"^C", CMD_COPY
"^F", CMD_SEARCH
"^G", CMD_GOTO
- "^H", CMD_REPLACE
+ "H", CMD_REPLACE, VIRTKEY, CONTROL
"^O", CMD_OPEN
"^S", CMD_SAVE
"^V", CMD_PASTE
_____
Added: trunk/reactos/subsys/system/notepad/settings.c
--- trunk/reactos/subsys/system/notepad/settings.c 2005-09-30
01:47:46 UTC (rev 18163)
+++ trunk/reactos/subsys/system/notepad/settings.c 2005-09-30
02:53:34 UTC (rev 18164)
@@ -0,0 +1,217 @@
+/*
+ * Notepad (settings.c)
+ *
+ * Copyright 1998,99 Marcel Baur <mbaur(a)g26.ethz.ch>
+ * Copyright 2002 Sylvain Petreolle <spetreolle(a)yahoo.fr>
+ * Copyright 2002 Andriy Palamarchuk
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ */
+
+#define UNICODE
+#define _UNICODE
+
+#include <assert.h>
+#include <stdio.h>
+#include <windows.h>
+#include <commdlg.h>
+#include <tchar.h>
+
+#include "main.h"
+
+static const TCHAR s_szRegistryKey[] = {
'S','o','f','t','w','a','r','e',
+ '\\','M','i','c','r','o','s','o','f','t',
+ '\\','N','o','t','e','p','a','d',0
};
+
+
+static LONG HeightFromPointSize(DWORD dwPointSize)
+{
+ LONG lHeight;
+ HDC hDC;
+
+ hDC = GetDC(NULL);
+ lHeight = -MulDiv(dwPointSize, GetDeviceCaps(hDC, LOGPIXELSY),
720);
+ ReleaseDC(NULL, hDC);
+
+ return lHeight;
+}
+
+static DWORD PointSizeFromHeight(LONG lHeight)
+{
+ DWORD dwPointSize;
+ HDC hDC;
+
+ hDC = GetDC(NULL);
+ dwPointSize = -MulDiv(lHeight, 720, GetDeviceCaps(hDC,
LOGPIXELSY));
+ ReleaseDC(NULL, hDC);
+
+ /* round to nearest multiple of 10 */
+ dwPointSize += 5;
+ dwPointSize -= dwPointSize % 10;
+
+ return dwPointSize;
+}
+
+static BOOL QueryGeneric(HKEY hKey, LPCSTR pszValueName, DWORD
dwExpectedType,
+ LPVOID pvResult, DWORD dwResultSize)
+{
+ WCHAR szValueW[32];
+ LPCTSTR pszValueNameT;
+ DWORD dwType, cbData;
+ LPVOID *pTemp;
+ BOOL bSuccess = FALSE;
+
+#ifdef UNICODE
+ MultiByteToWideChar(CP_ACP, 0, pszValueName, -1, szValueW,
sizeof(szValueW) / sizeof(szValueW[0]));
+ pszValueNameT = szValueW;
+#else
+ pszValueNameT = pszValueName;
+#endif
+
+ pTemp = HeapAlloc(GetProcessHeap(), 0, dwResultSize);
+ if (!pTemp)
+ goto done;
+ memset(pTemp, 0, dwResultSize);
+
+ cbData = dwResultSize;
+ if (RegQueryValueEx(hKey, pszValueNameT, NULL, &dwType, (LPBYTE)
pTemp, &cbData) != ERROR_SUCCESS)
+ goto done;
+
+ if (dwType != dwExpectedType)
+ goto done;
+
+ memcpy(pvResult, pTemp, cbData);
+ bSuccess = TRUE;
+
+done:
+ if (pTemp)
+ HeapFree(GetProcessHeap(), 0, pTemp);
+ return bSuccess;
+}
+
+static BOOL QueryDword(HKEY hKey, LPCSTR pszValueName, DWORD
*pdwResult)
+{
+ return QueryGeneric(hKey, pszValueName, REG_DWORD, pdwResult,
sizeof(*pdwResult));
+}
+
+static BOOL QueryByte(HKEY hKey, LPCSTR pszValueName, BYTE *pbResult)
+{
+ DWORD dwResult;
+ if (!QueryGeneric(hKey, pszValueName, REG_DWORD, &dwResult,
sizeof(dwResult)))
+ return FALSE;
+ if (dwResult >= 0x100)
+ return FALSE;
+ *pbResult = (BYTE) dwResult;
+ return TRUE;
+}
+
+static BOOL QueryString(HKEY hKey, LPCSTR pszValueName, LPTSTR
pszResult, DWORD dwResultSize)
+{
+ return QueryGeneric(hKey, pszValueName, REG_SZ, pszResult,
dwResultSize * sizeof(*pszResult));
+}
+
+void LoadSettings(void)
+{
+ HKEY hKey = NULL;
+ HFONT hFont;
+ DWORD dwPointSize = 0;
+
+ if (RegOpenKey(HKEY_CURRENT_USER, s_szRegistryKey, &hKey) ==
ERROR_SUCCESS)
+ {
+ QueryByte(hKey, "lfCharSet",
&Globals.lfFont.lfCharSet);
+ QueryByte(hKey, "lfClipPrecision",
&Globals.lfFont.lfClipPrecision);
+ QueryDword(hKey, "lfEscapement",
&Globals.lfFont.lfEscapement);
+ QueryString(hKey, "lfFaceName",
Globals.lfFont.lfFaceName, sizeof(Globals.lfFont.lfFaceName) /
sizeof(Globals.lfFont.lfFaceName[0]));
+ QueryByte(hKey, "lfItalic",
&Globals.lfFont.lfItalic);
+ QueryDword(hKey, "lfOrientation",
&Globals.lfFont.lfOrientation);
+ QueryByte(hKey, "lfOutPrecision",
&Globals.lfFont.lfOutPrecision);
+ QueryByte(hKey, "lfPitchAndFamily",
&Globals.lfFont.lfPitchAndFamily);
+ QueryByte(hKey, "lfQuality",
&Globals.lfFont.lfQuality);
+ QueryByte(hKey, "lfStrikeOut",
&Globals.lfFont.lfStrikeOut);
+ QueryByte(hKey, "lfUnderline",
&Globals.lfFont.lfUnderline);
+ QueryDword(hKey, "lfWeight",
&Globals.lfFont.lfWeight);
+ QueryDword(hKey, "iPointSize",
&dwPointSize);
+
+ if (dwPointSize != 0)
+ Globals.lfFont.lfHeight =
HeightFromPointSize(dwPointSize);
+
+ hFont = CreateFontIndirect(&Globals.lfFont);
+ if (hFont)
+ {
+ if (Globals.hFont)
+ DeleteObject(Globals.hFont);
+ Globals.hFont = hFont;
+ }
+
+ RegCloseKey(hKey);
+ }
+}
+
+static BOOL SaveDword(HKEY hKey, LPCSTR pszValueName, DWORD dwValue)
+{
+ WCHAR szValueW[32];
+ LPCTSTR pszValueNameT;
+
+#ifdef UNICODE
+ MultiByteToWideChar(CP_ACP, 0, pszValueName, -1, szValueW,
sizeof(szValueW) / sizeof(szValueW[0]));
+ pszValueNameT = szValueW;
+#else
+ pszValueNameT = pszValueName;
+#endif
+
+ return RegSetValueEx(hKey, pszValueNameT, 0, REG_DWORD, (LPBYTE)
&dwValue, sizeof(dwValue)) == ERROR_SUCCESS;
+}
+
+static BOOL SaveString(HKEY hKey, LPCSTR pszValueName, LPCTSTR
pszValue)
+{
+ WCHAR szValueW[32];
+ LPCTSTR pszValueNameT;
+
+#ifdef UNICODE
+ MultiByteToWideChar(CP_ACP, 0, pszValueName, -1, szValueW,
sizeof(szValueW) / sizeof(szValueW[0]));
+ pszValueNameT = szValueW;
+#else
+ pszValueNameT = pszValueName;
+#endif
+
+ return RegSetValueEx(hKey, pszValueNameT, 0, REG_SZ, (LPBYTE)
pszValue, _tcslen(pszValue) * sizeof(*pszValue)) == ERROR_SUCCESS;
+}
+
+void SaveSettings(void)
+{
+ HKEY hKey;
+ DWORD dwDisposition;
+
+ if (RegCreateKeyEx(HKEY_CURRENT_USER, s_szRegistryKey, 0, NULL,
0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition)
+ == ERROR_SUCCESS)
+ {
+ SaveDword(hKey, "lfCharSet",
Globals.lfFont.lfCharSet);
+ SaveDword(hKey, "lfClipPrecision",
Globals.lfFont.lfClipPrecision);
+ SaveDword(hKey, "lfEscapement",
Globals.lfFont.lfEscapement);
+ SaveString(hKey, "lfFaceName",
Globals.lfFont.lfFaceName);
+ SaveDword(hKey, "lfItalic",
Globals.lfFont.lfItalic);
+ SaveDword(hKey, "lfOrientation",
Globals.lfFont.lfOrientation);
+ SaveDword(hKey, "lfOutPrecision",
Globals.lfFont.lfOutPrecision);
+ SaveDword(hKey, "lfPitchAndFamily",
Globals.lfFont.lfPitchAndFamily);
+ SaveDword(hKey, "lfQuality",
Globals.lfFont.lfQuality);
+ SaveDword(hKey, "lfStrikeOut",
Globals.lfFont.lfStrikeOut);
+ SaveDword(hKey, "lfUnderline",
Globals.lfFont.lfUnderline);
+ SaveDword(hKey, "lfWeight",
Globals.lfFont.lfWeight);
+ SaveDword(hKey, "iPointSize",
PointSizeFromHeight(Globals.lfFont.lfHeight));
+
+ RegCloseKey(hKey);
+ }
+
+}