Author: gedmurphy
Date: Sat Feb 17 03:13:35 2007
New Revision: 25825
URL:
http://svn.reactos.org/svn/reactos?rev=25825&view=rev
Log:
- halfplement charmap.exe
- tested in ROS, by no means perfect but we cant least see the various glyphs within a
font
- this app highlights an issue with our paint code (not yet investigated)
Added:
trunk/reactos/base/applications/charmap/
trunk/reactos/base/applications/charmap/about.c
trunk/reactos/base/applications/charmap/charmap.c
trunk/reactos/base/applications/charmap/charmap.rbuild
trunk/reactos/base/applications/charmap/charmap.rc
trunk/reactos/base/applications/charmap/lang/
trunk/reactos/base/applications/charmap/lang/en-US.rc
trunk/reactos/base/applications/charmap/lrgcell.c
trunk/reactos/base/applications/charmap/manifest.xml
trunk/reactos/base/applications/charmap/map.c
trunk/reactos/base/applications/charmap/precomp.h
trunk/reactos/base/applications/charmap/res/
trunk/reactos/base/applications/charmap/res/charmap.ico (with props)
trunk/reactos/base/applications/charmap/resource.h
trunk/reactos/base/applications/charmap/rsrc.rc
Added: trunk/reactos/base/applications/charmap/about.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/about.c (added)
+++ trunk/reactos/base/applications/charmap/about.c Sat Feb 17 03:13:35 2007
@@ -1,0 +1,55 @@
+#include <precomp.h>
+
+
+INT_PTR CALLBACK
+AboutDialogProc(HWND hDlg,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ HWND hLicenseEditWnd;
+ HICON hIcon = NULL;
+ TCHAR strLicense[700];
+
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ hIcon = LoadImage(hInstance,
+ MAKEINTRESOURCE(IDI_ICON),
+ IMAGE_ICON,
+ 16,
+ 16,
+ 0);
+
+ SendMessage(hDlg,
+ WM_SETICON,
+ ICON_SMALL,
+ (LPARAM)hIcon);
+
+ hLicenseEditWnd = GetDlgItem(hDlg,
+ IDC_LICENSE_EDIT);
+
+ LoadString(hInstance,
+ IDS_LICENSE,
+ strLicense,
+ sizeof(strLicense) / sizeof(TCHAR));
+
+ SetWindowText(hLicenseEditWnd,
+ strLicense);
+ return TRUE;
+
+ case WM_COMMAND:
+ if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
+ {
+ DestroyIcon(hIcon);
+ EndDialog(hDlg,
+ LOWORD(wParam));
+ return TRUE;
+ }
+
+ break;
+ }
+
+ return FALSE;
+}
Added: trunk/reactos/base/applications/charmap/charmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/charmap.c (added)
+++ trunk/reactos/base/applications/charmap/charmap.c Sat Feb 17 03:13:35 2007
@@ -1,0 +1,267 @@
+#include <precomp.h>
+
+const TCHAR szMapWndClass[] = TEXT("FontMapWnd");
+const TCHAR szLrgCellWndClass[] = TEXT("LrgCellWnd");
+
+HINSTANCE hInstance;
+
+/* Font-enumeration callback */
+int CALLBACK
+EnumFontNames(ENUMLOGFONTEX *lpelfe,
+ NEWTEXTMETRICEX *lpntme,
+ DWORD FontType,
+ LPARAM lParam)
+{
+ HWND hwndCombo = (HWND)lParam;
+ TCHAR *pszName = lpelfe->elfLogFont.lfFaceName;
+
+ /* make sure font doesn't already exist in our list */
+ if(SendMessage(hwndCombo,
+ CB_FINDSTRING,
+ 0,
+ (LPARAM)pszName) == CB_ERR)
+ {
+ INT idx;
+ BOOL fFixed;
+ BOOL fTrueType;
+
+ /* add the font */
+ idx = (INT)SendMessage(hwndCombo,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)pszName);
+
+ /* record the font's attributes (Fixedwidth and Truetype) */
+ fFixed = (lpelfe->elfLogFont.lfPitchAndFamily & FIXED_PITCH) ? TRUE :
FALSE;
+ fTrueType = (lpelfe->elfLogFont.lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE :
FALSE;
+
+ /* store this information in the list-item's userdata area */
+ SendMessage(hwndCombo,
+ CB_SETITEMDATA,
+ idx,
+ MAKEWPARAM(fFixed, fTrueType));
+ }
+
+ return 1;
+}
+
+
+/* Initialize the font-list by enumeration all system fonts */
+static VOID
+FillFontStyleComboList(HWND hwndCombo)
+{
+ HDC hdc;
+ LOGFONT lf;
+
+ /* FIXME: for fun, draw each font in its own style */
+ HFONT hFont = GetStockObject(DEFAULT_GUI_FONT);
+ SendMessage(hwndCombo,
+ WM_SETFONT,
+ (WPARAM)hFont,
+ 0);
+
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lf.lfFaceName[0] = _T('\0'); // all fonts
+ lf.lfPitchAndFamily = 0;
+
+ hdc = GetDC(hwndCombo);
+
+ /* store the list of fonts in the combo */
+ EnumFontFamiliesEx(hdc,
+ &lf,
+ (FONTENUMPROC)EnumFontNames,
+ (LPARAM)hwndCombo,
+ 0);
+
+ ReleaseDC(hwndCombo,
+ hdc);
+
+ /* set default to Arial */
+ SendMessage(hwndCombo,
+ CB_SELECTSTRING,
+ -1,
+ (LPARAM)_T("Arial"));
+}
+
+
+static VOID
+ChangeMapFont(HWND hDlg)
+{
+ HWND hCombo;
+ HWND hMap;
+ LPTSTR lpFontName;
+ INT Len;
+
+ hCombo = GetDlgItem(hDlg, IDC_FONTCOMBO);
+
+ Len = GetWindowTextLength(hCombo);
+
+ if (Len != 0)
+ {
+ lpFontName = HeapAlloc(GetProcessHeap(),
+ 0,
+ (Len + 1) * sizeof(TCHAR));
+
+ if (lpFontName)
+ {
+ SendMessage(hCombo,
+ WM_GETTEXT,
+ 31,
+ (LPARAM)lpFontName);
+
+ hMap = GetDlgItem(hDlg, IDC_FONTMAP);
+
+ SendMessage(hMap,
+ FM_SETFONT,
+ 0,
+ (LPARAM)lpFontName);
+ }
+ }
+}
+
+
+BOOL CALLBACK
+DlgProc(HWND hDlg,
+ UINT Message,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ static HICON hSmIcon = NULL;
+ static HICON hBgIcon = NULL;
+
+ switch(Message)
+ {
+ case WM_INITDIALOG:
+ {
+ hSmIcon = LoadImage(hInstance,
+ MAKEINTRESOURCE(IDI_ICON),
+ IMAGE_ICON,
+ 16,
+ 16,
+ 0);
+ hBgIcon = LoadImage(hInstance,
+ MAKEINTRESOURCE(IDI_ICON),
+ IMAGE_ICON,
+ 32,
+ 32,
+ 0);
+
+ SendMessage(hDlg,
+ WM_SETICON,
+ ICON_SMALL,
+ (LPARAM)hSmIcon);
+ SendMessage(hDlg,
+ WM_SETICON,
+ ICON_BIG,
+ (LPARAM)hBgIcon);
+
+ FillFontStyleComboList(GetDlgItem(hDlg,
+ IDC_FONTCOMBO));
+
+ ChangeMapFont(hDlg);
+ }
+ break;
+
+ case WM_CLOSE:
+ {
+ EndDialog(hDlg, 0);
+ }
+ break;
+
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam))
+ {
+ case IDC_FONTCOMBO:
+ {
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ ChangeMapFont(hDlg);
+ }
+ }
+ break;
+
+ case IDOK:
+ EndDialog(hDlg, 0);
+ break;
+
+ case IDC_ABOUT:
+ DialogBox(hInstance,
+ MAKEINTRESOURCE(IDD_ABOUTBOX),
+ hDlg,
+ AboutDialogProc);
+ break;
+ }
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+BOOL
+RegisterControls(HINSTANCE hInstance)
+{
+ WNDCLASS wc = {0};
+
+ //wc.style = CS_DBLCLKS;
+ wc.lpfnWndProc = MapWndProc;
+ wc.cbWndExtra = sizeof(PMAP);
+ wc.hInstance = hInstance;
+ wc.hCursor = LoadCursor(NULL,
+ (LPTSTR)IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ wc.lpszClassName = szMapWndClass;
+
+ if (RegisterClass(&wc))
+ {
+ wc.lpfnWndProc = LrgCellWndProc;
+ wc.cbWndExtra = 0;
+ wc.lpszClassName = szLrgCellWndClass;
+
+ return RegisterClass(&wc) != 0;
+ }
+
+ return FALSE;
+}
+
+VOID
+UnregisterControls(HINSTANCE hInstance)
+{
+ UnregisterClass(szMapWndClass,
+ hInstance);
+
+ UnregisterClass(szLrgCellWndClass,
+ hInstance);
+}
+
+
+INT WINAPI
+WinMain(HINSTANCE hInst,
+ HINSTANCE hPrev,
+ LPSTR Cmd,
+ int iCmd)
+{
+ INITCOMMONCONTROLSEX iccx;
+ INT Ret;
+
+ hInstance = hInst;
+
+ iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ iccx.dwICC = ICC_TAB_CLASSES;
+ InitCommonControlsEx(&iccx);
+
+ RegisterControls(hInstance);
+
+ Ret = DialogBox(hInstance,
+ MAKEINTRESOURCE(IDD_CHARMAP),
+ NULL,
+ (DLGPROC)DlgProc);
+
+ UnregisterControls(hInstance);
+
+ return Ret;
+}
Added: trunk/reactos/base/applications/charmap/charmap.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/charmap.rbuild (added)
+++ trunk/reactos/base/applications/charmap/charmap.rbuild Sat Feb 17 03:13:35 2007
@@ -1,0 +1,25 @@
+<?xml version="1.0"?>
+<rbuild
xmlns:xi="http://www.w3.org/2001/XInclude">
+ <module name="charmap" type="win32gui"
installbase="system32" installname="charmap.exe">
+ <include base="charmap">.</include>
+ <define name="UNICODE" />
+ <define name="_UNICODE" />
+ <define name="__REACTOS__" />
+ <define name="__USE_W32API" />
+ <define name="_WIN32_IE">0x600</define>
+ <define name="_WIN32_WINNT">0x501</define>
+ <library>ntdll</library>
+ <library>gdi32</library>
+ <library>kernel32</library>
+ <library>user32</library>
+ <library>comctl32</library>
+ <compilationunit name="unit.c">
+ <file>about.c</file>
+ <file>charmap.c</file>
+ <file>lrgcell.c</file>
+ <file>map.c</file>
+ </compilationunit>
+ <file>charmap.rc</file>
+ <pch>precomp.h</pch>
+ </module>
+</rbuild>
Added: trunk/reactos/base/applications/charmap/charmap.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/charmap.rc (added)
+++ trunk/reactos/base/applications/charmap/charmap.rc Sat Feb 17 03:13:35 2007
@@ -1,0 +1,11 @@
+#include <windows.h>
+#include <commctrl.h>
+#include "resource.h"
+
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Character Map\0"
+#define REACTOS_STR_INTERNAL_NAME "charmap\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "charmap.exe\0"
+#include <reactos/version.rc>
+
+#include "rsrc.rc"
Added: trunk/reactos/base/applications/charmap/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/lang/en-US.rc (added)
+++ trunk/reactos/base/applications/charmap/lang/en-US.rc Sat Feb 17 03:13:35 2007
@@ -1,0 +1,35 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+IDD_CHARMAP DIALOGEX 6, 6, 293, 205 //233
+CAPTION "Character Map"
+FONT 8,"MS Sans Serif",0,0
+STYLE WS_BORDER | WS_VISIBLE | WS_SYSMENU
+BEGIN
+ LTEXT "Font :", IDC_STATIC, 6, 7, 24, 9
+ COMBOBOX IDC_FONTCOMBO, 36, 5, 196, 210, WS_CHILD | WS_VISIBLE | WS_VSCROLL |
CBS_DROPDOWNLIST | CBS_SORT | CBS_HASSTRINGS
+ PUSHBUTTON "Help", IDC_CMHELP, 235, 5, 35, 13
+ PUSHBUTTON "?", IDC_ABOUT, 272, 5, 14, 13
+ CONTROL "", IDC_FONTMAP, "FontMapWnd", WS_CHILD | WS_VISIBLE
| WS_TABSTOP | WS_VSCROLL, 20, 22, 266, 156
+ LTEXT "Characters to copy :", IDC_STATIC, 6, 188, 66, 9
+ EDITTEXT IDC_TEXTBOX, 74, 186, 114, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+ DEFPUSHBUTTON "Select", IDC_SELECT, 194, 186, 46, 13
+ PUSHBUTTON "Copy", IDC_COPY, 244, 186, 46, 13, WS_DISABLED
+ //AUTOCHECKBOX "Advanced view", IDC_ADVVIEW, 10, 204, 64, 9, WS_CHILD |
WS_VISIBLE | WS_TABSTOP
+ //EDITTEXT IDC_DISPLAY, 8, 217, 278, 13, WS_VISIBLE | WS_TABSTOP | ES_READONLY
+END
+
+IDD_ABOUTBOX DIALOGEX 22,16,210,182
+CAPTION "About Character Map"
+FONT 8,"MS Sans Serif",0,0
+STYLE WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
+BEGIN
+ LTEXT "Character Map v0.1\nCopyright (C) 2007 Ged Murphy
(gedmurphy(a)reactos.org)"quot;, IDC_STATIC, 48, 7, 150, 36
+ PUSHBUTTON "Close", IDOK, 75, 162, 44, 15
+ ICON IDI_ICON, IDC_STATIC, 10, 10, 7, 30
+ EDITTEXT IDC_LICENSE_EDIT, 8, 44, 194, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP |
ES_READONLY | ES_MULTILINE
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_LICENSE "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.\r\n\r\nThis 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.\r\n\r\nYou
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."
+END
Added: trunk/reactos/base/applications/charmap/lrgcell.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/lrgcell.c (added)
+++ trunk/reactos/base/applications/charmap/lrgcell.c Sat Feb 17 03:13:35 2007
@@ -1,0 +1,152 @@
+#include <precomp.h>
+
+
+static HFONT
+SetLrgFont(PMAP infoPtr)
+{
+ LOGFONT lf;
+ HFONT hFont = NULL;
+ HDC hdc;
+ HWND hCombo;
+ LPTSTR lpFontName;
+ INT Len;
+
+ hCombo = GetDlgItem(infoPtr->hParent, IDC_FONTCOMBO);
+
+ Len = GetWindowTextLength(hCombo);
+
+ if (Len != 0)
+ {
+ lpFontName = HeapAlloc(GetProcessHeap(),
+ 0,
+ (Len + 1) * sizeof(TCHAR));
+
+ if (lpFontName)
+ {
+ SendMessage(hCombo,
+ WM_GETTEXT,
+ 31,
+ (LPARAM)lpFontName);
+
+ ZeroMemory(&lf, sizeof(lf));
+
+ hdc = GetDC(infoPtr->hLrgWnd);
+ lf.lfHeight = GetDeviceCaps(hdc,
+ LOGPIXELSY) / 2;
+ ReleaseDC(infoPtr->hLrgWnd, hdc);
+
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lstrcpy(lf.lfFaceName,
+ lpFontName);
+
+ hFont = CreateFontIndirect(&lf);
+
+ HeapFree(GetProcessHeap(),
+ 0,
+ lpFontName);
+ }
+ }
+
+ return hFont;
+}
+
+
+LRESULT CALLBACK
+LrgCellWndProc(HWND hwnd,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PMAP infoPtr;
+ LRESULT Ret = 0;
+ static INT cxClient, cyClient;
+ static RECT rc;
+ static HFONT hFont = NULL;
+
+ infoPtr = (PMAP)GetWindowLongPtr(hwnd,
+ GWLP_USERDATA);
+
+ if (infoPtr == NULL && uMsg != WM_CREATE)
+ {
+ goto HandleDefaultMessage;
+ }
+
+ switch (uMsg)
+ {
+ case WM_CREATE:
+ {
+ infoPtr = (PMAP)(((LPCREATESTRUCT)lParam)->lpCreateParams);
+
+ SetWindowLongPtr(hwnd,
+ GWLP_USERDATA,
+ (LONG_PTR)infoPtr);
+
+ hFont = SetLrgFont(infoPtr);
+
+ break;
+ }
+
+ case WM_SIZE:
+ {
+ cxClient = LOWORD(lParam);
+ cyClient = HIWORD(lParam);
+
+ rc.left = 0;
+ rc.top = 0;
+ rc.right = cxClient;
+ rc.bottom = cyClient;
+
+ break;
+ }
+
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdc;
+ HFONT hOldFont;
+
+ hdc = BeginPaint(hwnd,
+ &ps);
+
+ Rectangle(hdc,
+ 0,
+ 0,
+ cxClient,
+ cyClient);
+
+ hOldFont = SelectObject(hdc, hFont);
+
+ DrawText(hdc,
+ &infoPtr->pActiveCell->ch,
+ 1,
+ &rc,
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+
+ SelectObject(hdc, hOldFont);
+
+ EndPaint(hwnd,
+ &ps);
+
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ DeleteObject(hFont);
+
+ break;
+ }
+
+ default:
+ {
+HandleDefaultMessage:
+ Ret = DefWindowProc(hwnd,
+ uMsg,
+ wParam,
+ lParam);
+ break;
+ }
+ }
+
+ return Ret;
+}
Added: trunk/reactos/base/applications/charmap/manifest.xml
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/manifest.xml (added)
+++ trunk/reactos/base/applications/charmap/manifest.xml Sat Feb 17 03:13:35 2007
@@ -1,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<assembly
+ xmlns="urn:schemas-microsoft-com:asm.v1"
+ manifestVersion="1.0">
+<assemblyIdentity
+ name="Win32 Application.default.App"
+ processorArchitecture="x86"
+ version="1.0.0.0"
+ type="win32"/>
+<description>ReactOS Character Map</description>
+<dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="x86"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+</dependency>
+</assembly>
Added: trunk/reactos/base/applications/charmap/map.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/map.c (added)
+++ trunk/reactos/base/applications/charmap/map.c Sat Feb 17 03:13:35 2007
@@ -1,0 +1,484 @@
+#include <precomp.h>
+
+
+static VOID
+TagFontToCell(PCELL pCell,
+ TCHAR ch)
+{
+ pCell->ch = ch;
+}
+
+
+static VOID
+SetGrid(PMAP infoPtr)
+{
+ INT x, y;
+
+ for (y = 0; y < YCELLS; y++)
+ for (x = 0; x < XCELLS; x++)
+ {
+ infoPtr->Cells[y][x].CellExt.left = x * infoPtr->CellSize.cx + 1;
+ infoPtr->Cells[y][x].CellExt.top = y * infoPtr->CellSize.cy + 1;
+ infoPtr->Cells[y][x].CellExt.right = (x + 1) * infoPtr->CellSize.cx + 2;
+ infoPtr->Cells[y][x].CellExt.bottom = (y + 1) * infoPtr->CellSize.cy + 2;
+
+ CopyRect(&infoPtr->Cells[y][x].CellInt,
+ &infoPtr->Cells[y][x].CellExt);
+
+ InflateRect(&infoPtr->Cells[y][x].CellInt,
+ -1,
+ -1);
+ }
+}
+
+static VOID
+DrawActiveCell(PMAP infoPtr,
+ HDC hdc)
+{
+ Rectangle(hdc,
+ infoPtr->pActiveCell->CellInt.left,
+ infoPtr->pActiveCell->CellInt.top,
+ infoPtr->pActiveCell->CellInt.right,
+ infoPtr->pActiveCell->CellInt.bottom);
+
+}
+
+
+static VOID
+DrawGrid(PMAP infoPtr,
+ HDC hdc)
+{
+ INT x, y;
+
+ for (y = 0; y < YCELLS; y++)
+ for (x = 0; x < XCELLS; x++)
+ {
+ Rectangle(hdc,
+ infoPtr->Cells[y][x].CellExt.left,
+ infoPtr->Cells[y][x].CellExt.top,
+ infoPtr->Cells[y][x].CellExt.right,
+ infoPtr->Cells[y][x].CellExt.bottom);
+ }
+
+ if (infoPtr->pActiveCell)
+ DrawActiveCell(infoPtr,
+ hdc);
+}
+
+
+static VOID
+FillGrid(PMAP infoPtr,
+ HDC hdc)
+{
+ //GLYPHSET gs;
+ HFONT hOldFont;
+ TCHAR ch;
+ INT x, y;
+
+ hOldFont = SelectObject(hdc,
+ infoPtr->hFont);
+
+ for (y = 0; y < YCELLS; y++)
+ for (x = 0; x < XCELLS; x++)
+ {
+ ch = (TCHAR)((256 * infoPtr->iPage) + (XCELLS * y) + x);
+
+ TagFontToCell(&infoPtr->Cells[y][x], ch);
+
+ DrawText(hdc,
+ &ch,
+ 1,
+ &infoPtr->Cells[y][x].CellInt,
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+ }
+
+ SelectObject(hdc,
+ hOldFont);
+}
+
+
+static BOOL
+CreateLargeCell(PMAP infoPtr)
+{
+ RECT rLarge;
+
+ CopyRect(&rLarge,
+ &infoPtr->pActiveCell->CellExt);
+
+ MapWindowPoints(infoPtr->hMapWnd,
+ infoPtr->hParent,
+ (LPPOINT)&rLarge,
+ 2);
+
+ InflateRect(&rLarge,
+ XLARGE - XCELLS,
+ YLARGE - YCELLS);
+
+ infoPtr->hLrgWnd = CreateWindowEx(0,
+ szLrgCellWndClass,
+ NULL,
+ WS_CHILDWINDOW | WS_VISIBLE,
+ rLarge.left,
+ rLarge.top,
+ rLarge.right - rLarge.left,
+ rLarge.bottom - rLarge.top,
+ infoPtr->hParent,
+ NULL,
+ hInstance,
+ infoPtr);
+ if (!infoPtr->hLrgWnd)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static VOID
+MoveLargeCell(PMAP infoPtr)
+{
+ RECT rLarge;
+
+ CopyRect(&rLarge,
+ &infoPtr->pActiveCell->CellExt);
+
+ MapWindowPoints(infoPtr->hMapWnd,
+ infoPtr->hParent,
+ (LPPOINT)&rLarge,
+ 2);
+
+ InflateRect(&rLarge,
+ XLARGE - XCELLS,
+ YLARGE - YCELLS);
+
+ MoveWindow(infoPtr->hLrgWnd,
+ rLarge.left,
+ rLarge.top,
+ rLarge.right - rLarge.left,
+ rLarge.bottom - rLarge.top,
+ TRUE);
+
+ InvalidateRect(infoPtr->hLrgWnd,
+ NULL,
+ TRUE);
+}
+
+
+static VOID
+SetFont(PMAP infoPtr,
+ LPTSTR lpFontName)
+{
+ HDC hdc;
+
+ if (infoPtr->hFont)
+ DeleteObject(infoPtr->hFont);
+
+ ZeroMemory(&infoPtr->CurrentFont,
+ sizeof(LOGFONT));
+
+ hdc = GetDC(infoPtr->hMapWnd);
+ infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc,
+ LOGPIXELSY) / 5;
+ ReleaseDC(infoPtr->hMapWnd, hdc);
+
+ infoPtr->CurrentFont.lfCharSet = DEFAULT_CHARSET;
+ lstrcpy(infoPtr->CurrentFont.lfFaceName,
+ lpFontName);
+
+ infoPtr->hFont = CreateFontIndirect(&infoPtr->CurrentFont);
+
+ InvalidateRect(infoPtr->hMapWnd,
+ NULL,
+ TRUE);
+}
+
+
+static VOID
+OnClick(PMAP infoPtr,
+ WORD ptx,
+ WORD pty)
+{
+ POINT pt;
+ INT x, y;
+
+ pt.x = ptx;
+ pt.y = pty;
+
+ for (x = 0; x < XCELLS; x++)
+ for (y = 0; y < YCELLS; y++)
+ {
+ if (PtInRect(&infoPtr->Cells[y][x].CellInt,
+ pt))
+ {
+ /* if the cell is not already active */
+ if (!infoPtr->Cells[y][x].bActive)
+ {
+ /* set previous active cell to inactive */
+ if (infoPtr->pActiveCell)
+ {
+ /* invalidate normal cells, required when
+ * moving a small active cell via keyboard */
+ if (!infoPtr->pActiveCell->bLarge)
+ {
+ InvalidateRect(infoPtr->hMapWnd,
+ &infoPtr->pActiveCell->CellInt,
+ TRUE);
+ }
+
+ infoPtr->pActiveCell->bActive = FALSE;
+ infoPtr->pActiveCell->bLarge = FALSE;
+ }
+
+ /* set new cell to active */
+ infoPtr->pActiveCell = &infoPtr->Cells[y][x];
+ infoPtr->pActiveCell->bActive = TRUE;
+ infoPtr->pActiveCell->bLarge = TRUE;
+ if (infoPtr->hLrgWnd)
+ MoveLargeCell(infoPtr);
+ else
+ CreateLargeCell(infoPtr);
+ }
+ else
+ {
+ /* flick between large and small */
+ if (infoPtr->pActiveCell->bLarge)
+ {
+ DestroyWindow(infoPtr->hLrgWnd);
+ infoPtr->hLrgWnd = NULL;
+ }
+ else
+ {
+ CreateLargeCell(infoPtr);
+ }
+
+ infoPtr->pActiveCell->bLarge = (infoPtr->pActiveCell->bLarge)
? FALSE : TRUE;
+ }
+
+ break;
+ }
+ }
+}
+
+
+static BOOL
+OnCreate(PMAP infoPtr,
+ HWND hwnd,
+ HWND hParent)
+{
+ RECT rc;
+ BOOL Ret = FALSE;
+
+ infoPtr = HeapAlloc(GetProcessHeap(),
+ 0,
+ sizeof(MAP));
+ if (infoPtr)
+ {
+ SetLastError(0);
+ SetWindowLongPtr(hwnd,
+ 0,
+ (DWORD_PTR)infoPtr);
+ if (GetLastError() == 0)
+ {
+ ZeroMemory(infoPtr,
+ sizeof(MAP));
+
+ infoPtr->hMapWnd = hwnd;
+ infoPtr->hParent = hParent;
+
+ GetClientRect(hwnd, &rc);
+ infoPtr->ClientSize.cx = rc.right;
+ infoPtr->ClientSize.cy = rc.bottom;
+ infoPtr->CellSize.cx = infoPtr->ClientSize.cx / XCELLS;
+ infoPtr->CellSize.cy = infoPtr->ClientSize.cy / YCELLS;
+
+ infoPtr->pActiveCell = NULL;
+
+ SetGrid(infoPtr);
+
+ SetScrollRange(hwnd, SB_VERT, 0, 255, FALSE);
+ SetScrollPos(hwnd, SB_VERT, 0, TRUE);
+
+ Ret = TRUE;
+ }
+ }
+
+ return Ret;
+}
+
+
+static VOID
+OnVScroll(PMAP infoPtr,
+ INT Value,
+ INT Pos)
+{
+ switch (Value)
+ {
+ case SB_LINEUP:
+ infoPtr->iPage -= 1;
+ break;
+
+ case SB_LINEDOWN:
+ infoPtr->iPage += 1;
+ break;
+
+ case SB_PAGEUP:
+ infoPtr->iPage -= 16;
+ break;
+
+ case SB_PAGEDOWN:
+ infoPtr->iPage += 16;
+ break;
+
+ case SB_THUMBPOSITION:
+ infoPtr->iPage = Pos;
+ break;
+
+ default:
+ break;
+ }
+
+ infoPtr->iPage = max(0,
+ min(infoPtr->iPage,
+ 255));
+
+ SetScrollPos(infoPtr->hMapWnd,
+ SB_VERT,
+ infoPtr->iPage,
+ TRUE);
+
+ InvalidateRect(infoPtr->hMapWnd,
+ NULL,
+ TRUE);
+}
+
+
+static VOID
+OnPaint(PMAP infoPtr,
+ WPARAM wParam)
+{
+ PAINTSTRUCT ps;
+ HDC hdc;
+
+
+ if (wParam != 0)
+ {
+ if (!GetUpdateRect(infoPtr->hMapWnd,
+ &ps.rcPaint,
+ TRUE))
+ {
+ return;
+ }
+ hdc = (HDC)wParam;
+ }
+ else
+ {
+ hdc = BeginPaint(infoPtr->hMapWnd,
+ &ps);
+ if (hdc == NULL)
+ {
+ return;
+ }
+ }
+
+ DrawGrid(infoPtr,
+ hdc);
+
+ FillGrid(infoPtr,
+ hdc);
+
+ if (wParam == 0)
+ {
+ EndPaint(infoPtr->hMapWnd,
+ &ps);
+ }
+}
+
+
+LRESULT CALLBACK
+MapWndProc(HWND hwnd,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PMAP infoPtr;
+ LRESULT Ret = 0;
+
+ infoPtr = (PMAP)GetWindowLongPtr(hwnd,
+ 0);
+
+ switch (uMsg)
+ {
+ case WM_CREATE:
+ {
+ if (!OnCreate(infoPtr,
+ hwnd,
+ ((LPCREATESTRUCTW)lParam)->hwndParent))
+ {
+ return (LRESULT)-1;
+ }
+
+ break;
+ }
+
+ case WM_LBUTTONDOWN:
+ {
+ OnClick(infoPtr,
+ LOWORD(lParam),
+ HIWORD(lParam));
+
+ break;
+ }
+
+ case WM_VSCROLL:
+ {
+ OnVScroll(infoPtr,
+ LOWORD(wParam),
+ HIWORD(wParam));
+
+ break;
+ }
+
+ case FM_SETFONT:
+ {
+ LPTSTR lpFontName = (LPTSTR)lParam;
+
+ SetFont(infoPtr,
+ lpFontName);
+
+ HeapFree(GetProcessHeap(),
+ 0,
+ lpFontName);
+
+ break;
+ }
+
+ case WM_PAINT:
+ {
+ OnPaint(infoPtr,
+ wParam);
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ DeleteObject(infoPtr->hFont);
+ HeapFree(GetProcessHeap(),
+ 0,
+ infoPtr);
+ SetWindowLongPtr(hwnd,
+ 0,
+ (DWORD_PTR)NULL);
+ break;
+ }
+
+ default:
+ {
+ Ret = DefWindowProc(hwnd,
+ uMsg,
+ wParam,
+ lParam);
+ break;
+ }
+ }
+
+ return Ret;
+}
Added: trunk/reactos/base/applications/charmap/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/precomp.h (added)
+++ trunk/reactos/base/applications/charmap/precomp.h Sat Feb 17 03:13:35 2007
@@ -1,0 +1,51 @@
+#ifndef __CHARMAP_PRECOMP_H
+#define __CHARMAP_PRECOMP_H
+#include <windows.h>
+#include <stdio.h>
+#include <tchar.h>
+#include <commctrl.h>
+#include "resource.h"
+
+#define XCELLS 20
+#define YCELLS 10
+#define XLARGE 45
+#define YLARGE 25
+
+#define FM_SETFONT (WM_USER + 1)
+
+extern HINSTANCE hInstance;
+extern const TCHAR szMapWndClass[];
+extern const TCHAR szLrgCellWndClass[];
+
+
+typedef struct _CELL
+{
+ RECT CellExt;
+ RECT CellInt;
+ BOOL bActive;
+ BOOL bLarge;
+ TCHAR ch;
+} CELL, *PCELL;
+
+typedef struct _MAP
+{
+ HWND hMapWnd;
+ HWND hParent;
+ HWND hLrgWnd;
+ SIZE ClientSize;
+ SIZE CellSize;
+ CELL Cells[YCELLS][XCELLS];
+ PCELL pActiveCell;
+ HFONT hFont;
+ LOGFONT CurrentFont;
+ INT iPage;
+} MAP, *PMAP;
+
+BOOL RegisterControls(HINSTANCE hInstance);
+VOID UnregisterControls(HINSTANCE hInstance);
+
+INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK MapWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+#endif /* __DEVMGMT_PRECOMP_H */
Added: trunk/reactos/base/applications/charmap/res/charmap.ico
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
Binary file - no diff available.
Propchange: trunk/reactos/base/applications/charmap/res/charmap.ico
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/reactos/base/applications/charmap/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/resource.h (added)
+++ trunk/reactos/base/applications/charmap/resource.h Sat Feb 17 03:13:35 2007
@@ -1,0 +1,18 @@
+#define IDC_STATIC -1
+
+#define IDI_ICON 100
+
+#define IDD_CHARMAP 200
+#define IDD_ABOUTBOX 201
+#define IDC_FONTCOMBO 1001
+#define IDC_CMHELP 1002
+#define IDC_ABOUT 1003
+#define IDC_FONTMAP 1004
+#define IDC_TEXTBOX 1005
+#define IDC_SELECT 1006
+#define IDC_COPY 1007
+#define IDC_ADVVIEW 1008
+#define IDC_DISPLAY 1009
+#define IDC_SCROLL 1010
+#define IDS_LICENSE 1011
+#define IDC_LICENSE_EDIT 1012
Added: trunk/reactos/base/applications/charmap/rsrc.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/…
==============================================================================
--- trunk/reactos/base/applications/charmap/rsrc.rc (added)
+++ trunk/reactos/base/applications/charmap/rsrc.rc Sat Feb 17 03:13:35 2007
@@ -1,0 +1,11 @@
+#include <windows.h>
+#include "resource.h"
+
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+1 24 DISCARDABLE "manifest.xml"
+
+IDI_ICON ICON "res/charmap.ico"
+
+#include "lang/en-US.rc"
+