From 8cc6eff6aec4fe824e25374684ba6eccc78f6f63 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 17 Feb 2007 00:13:35 +0000 Subject: [PATCH] - 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) svn path=/trunk/; revision=25825 --- reactos/base/applications/charmap/about.c | 55 ++ reactos/base/applications/charmap/charmap.c | 267 ++++++++++ .../base/applications/charmap/charmap.rbuild | 25 + reactos/base/applications/charmap/charmap.rc | 11 + .../base/applications/charmap/lang/en-US.rc | 35 ++ reactos/base/applications/charmap/lrgcell.c | 152 ++++++ .../base/applications/charmap/manifest.xml | 23 + reactos/base/applications/charmap/map.c | 484 ++++++++++++++++++ reactos/base/applications/charmap/precomp.h | 51 ++ .../base/applications/charmap/res/charmap.ico | Bin 0 -> 17542 bytes reactos/base/applications/charmap/resource.h | 18 + reactos/base/applications/charmap/rsrc.rc | 11 + 12 files changed, 1132 insertions(+) create mode 100644 reactos/base/applications/charmap/about.c create mode 100644 reactos/base/applications/charmap/charmap.c create mode 100644 reactos/base/applications/charmap/charmap.rbuild create mode 100644 reactos/base/applications/charmap/charmap.rc create mode 100644 reactos/base/applications/charmap/lang/en-US.rc create mode 100644 reactos/base/applications/charmap/lrgcell.c create mode 100644 reactos/base/applications/charmap/manifest.xml create mode 100644 reactos/base/applications/charmap/map.c create mode 100644 reactos/base/applications/charmap/precomp.h create mode 100644 reactos/base/applications/charmap/res/charmap.ico create mode 100644 reactos/base/applications/charmap/resource.h create mode 100644 reactos/base/applications/charmap/rsrc.rc diff --git a/reactos/base/applications/charmap/about.c b/reactos/base/applications/charmap/about.c new file mode 100644 index 00000000000..e89f6b517bd --- /dev/null +++ b/reactos/base/applications/charmap/about.c @@ -0,0 +1,55 @@ +#include + + +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; +} diff --git a/reactos/base/applications/charmap/charmap.c b/reactos/base/applications/charmap/charmap.c new file mode 100644 index 00000000000..b19cd230327 --- /dev/null +++ b/reactos/base/applications/charmap/charmap.c @@ -0,0 +1,267 @@ +#include + +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; +} diff --git a/reactos/base/applications/charmap/charmap.rbuild b/reactos/base/applications/charmap/charmap.rbuild new file mode 100644 index 00000000000..9bf80926cdc --- /dev/null +++ b/reactos/base/applications/charmap/charmap.rbuild @@ -0,0 +1,25 @@ + + + + . + + + + + 0x600 + 0x501 + ntdll + gdi32 + kernel32 + user32 + comctl32 + + about.c + charmap.c + lrgcell.c + map.c + + charmap.rc + precomp.h + + diff --git a/reactos/base/applications/charmap/charmap.rc b/reactos/base/applications/charmap/charmap.rc new file mode 100644 index 00000000000..0f7634a5be2 --- /dev/null +++ b/reactos/base/applications/charmap/charmap.rc @@ -0,0 +1,11 @@ +#include +#include +#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 + +#include "rsrc.rc" diff --git a/reactos/base/applications/charmap/lang/en-US.rc b/reactos/base/applications/charmap/lang/en-US.rc new file mode 100644 index 00000000000..cf86eb509c3 --- /dev/null +++ b/reactos/base/applications/charmap/lang/en-US.rc @@ -0,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@reactos.org)", 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 diff --git a/reactos/base/applications/charmap/lrgcell.c b/reactos/base/applications/charmap/lrgcell.c new file mode 100644 index 00000000000..7ff12bd77fe --- /dev/null +++ b/reactos/base/applications/charmap/lrgcell.c @@ -0,0 +1,152 @@ +#include + + +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; +} diff --git a/reactos/base/applications/charmap/manifest.xml b/reactos/base/applications/charmap/manifest.xml new file mode 100644 index 00000000000..ff397fc542c --- /dev/null +++ b/reactos/base/applications/charmap/manifest.xml @@ -0,0 +1,23 @@ + + + +ReactOS Character Map + + + + + + diff --git a/reactos/base/applications/charmap/map.c b/reactos/base/applications/charmap/map.c new file mode 100644 index 00000000000..d6495bd69d4 --- /dev/null +++ b/reactos/base/applications/charmap/map.c @@ -0,0 +1,484 @@ +#include + + +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; +} diff --git a/reactos/base/applications/charmap/precomp.h b/reactos/base/applications/charmap/precomp.h new file mode 100644 index 00000000000..4350f970570 --- /dev/null +++ b/reactos/base/applications/charmap/precomp.h @@ -0,0 +1,51 @@ +#ifndef __CHARMAP_PRECOMP_H +#define __CHARMAP_PRECOMP_H +#include +#include +#include +#include +#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 */ diff --git a/reactos/base/applications/charmap/res/charmap.ico b/reactos/base/applications/charmap/res/charmap.ico new file mode 100644 index 0000000000000000000000000000000000000000..fa8ae81d9f158c87ae0b4e1f3168e1200bf18379 GIT binary patch literal 17542 zcmeHOX^>Ra6@JJv2#Juz1YD2`YJ_2vn8Y>eTD^`rdQC zbMCp@IrmxC0Bevnb*hE?SZmXHmNnh7tg&OA=aH7xfOjKt=l^#NvaHp=vaC^~?B|qI zE$hUkmURK@fQ5BCh~;=KM!oN@Zqpa~%Q!U#}L7u$$_a>0TJAIMs@ zW_6pds6a|8N~Nl^6dpB#V1(5 zy1rKJ-{1IYf669?!jd9clCgUb{W&gnchUcUl$@R#2sQ+zroK*j(0BIva{A5w zltr1uPYm<}U}^?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C<<~${Bq;W)zBL!rC&H+hGOq5%0yG0)V^ApOSb4slE^{kyUm(Wh^6P(-Z zwR4SZ|KuY{&&&{hU%+#vvGUimSGxc1Jg;u={i|dKVm}L)ERvZx13epOSveoY!oL;k z0CRrG%xUiPYTJN)G0uZCzIPDw8_TdxwC&4z$n4j2AB%o(+ibHWf|6q zmVX`QS$>m8;u#put&DfOY0trZa^bWKW&6%gPzHNa)QOfqedj=d7yEiI&X9O@Jjy|Q zkCf}&?dLrGpXW?CZbi#K58ngl7Ut_daUb@IJmbM}gZog90eZ(X-}8Sj%Cb(h{CUnM zCm(ALt{Vzqqh5$*SeE^}H~u*HQ_Hd6hi_+ySXo#cUaprC8eh>^LRY`KKuXT!oJMfW(~9! OW0mA4zUvE-FX?|0yg}#y literal 0 HcmV?d00001 diff --git a/reactos/base/applications/charmap/resource.h b/reactos/base/applications/charmap/resource.h new file mode 100644 index 00000000000..206df8e4376 --- /dev/null +++ b/reactos/base/applications/charmap/resource.h @@ -0,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 diff --git a/reactos/base/applications/charmap/rsrc.rc b/reactos/base/applications/charmap/rsrc.rc new file mode 100644 index 00000000000..b83af152d15 --- /dev/null +++ b/reactos/base/applications/charmap/rsrc.rc @@ -0,0 +1,11 @@ +#include +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +1 24 DISCARDABLE "manifest.xml" + +IDI_ICON ICON "res/charmap.ico" + +#include "lang/en-US.rc" +