1 /* 2 * PROJECT: ReactOS Character Map 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/applications/charmap/lrgcell.c 5 * PURPOSE: large cell window implementation 6 * COPYRIGHT: Copyright 2007 Ged Murphy <gedmurphy@reactos.org> 7 * 8 */ 9 10 #include "precomp.h" 11 12 static 13 HFONT 14 SetLrgFont(PMAP infoPtr) 15 { 16 LOGFONTW lf; 17 HFONT hFont = NULL; 18 HDC hdc; 19 HWND hCombo; 20 LPWSTR lpFontName; 21 INT Len; 22 23 hCombo = GetDlgItem(infoPtr->hParent, 24 IDC_FONTCOMBO); 25 26 Len = GetWindowTextLengthW(hCombo); 27 28 if (Len != 0) 29 { 30 lpFontName = HeapAlloc(GetProcessHeap(), 31 0, 32 (Len + 1) * sizeof(WCHAR)); 33 34 if (lpFontName) 35 { 36 SendMessageW(hCombo, 37 WM_GETTEXT, 38 Len + 1, 39 (LPARAM)lpFontName); 40 41 ZeroMemory(&lf, 42 sizeof(lf)); 43 44 hdc = GetDC(infoPtr->hLrgWnd); 45 lf.lfHeight = GetDeviceCaps(hdc, 46 LOGPIXELSY) / 2; 47 ReleaseDC(infoPtr->hLrgWnd, 48 hdc); 49 50 lf.lfCharSet = DEFAULT_CHARSET; 51 wcsncpy(lf.lfFaceName, 52 lpFontName, 53 sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0])); 54 55 hFont = CreateFontIndirectW(&lf); 56 57 HeapFree(GetProcessHeap(), 58 0, 59 lpFontName); 60 } 61 } 62 63 return hFont; 64 } 65 66 67 LRESULT CALLBACK 68 LrgCellWndProc(HWND hwnd, 69 UINT uMsg, 70 WPARAM wParam, 71 LPARAM lParam) 72 { 73 PMAP infoPtr; 74 LRESULT Ret = 0; 75 static INT cxClient, cyClient; 76 static RECT rc; 77 static HFONT hFont = NULL; 78 79 infoPtr = (PMAP)GetWindowLongPtrW(hwnd, 80 GWLP_USERDATA); 81 82 if (infoPtr == NULL && uMsg != WM_CREATE) 83 { 84 goto HandleDefaultMessage; 85 } 86 87 switch (uMsg) 88 { 89 case WM_CREATE: 90 { 91 infoPtr = (PMAP)(((LPCREATESTRUCTW)lParam)->lpCreateParams); 92 93 SetWindowLongPtrW(hwnd, 94 GWLP_USERDATA, 95 (LONG_PTR)infoPtr); 96 97 hFont = SetLrgFont(infoPtr); 98 99 break; 100 } 101 102 case WM_SIZE: 103 { 104 cxClient = LOWORD(lParam); 105 cyClient = HIWORD(lParam); 106 107 rc.left = 0; 108 rc.top = 0; 109 rc.right = cxClient; 110 rc.bottom = cyClient; 111 112 break; 113 } 114 115 case WM_PAINT: 116 { 117 PAINTSTRUCT ps; 118 HDC hdc; 119 HFONT hOldFont; 120 121 hdc = BeginPaint(hwnd, 122 &ps); 123 124 Rectangle(hdc, 125 0, 126 0, 127 cxClient, 128 cyClient); 129 130 hOldFont = SelectObject(hdc, hFont); 131 132 DrawTextW(hdc, 133 &infoPtr->pActiveCell->ch, 134 1, 135 &rc, 136 DT_CENTER | DT_VCENTER | DT_SINGLELINE); 137 138 SelectObject(hdc, hOldFont); 139 140 EndPaint(hwnd, 141 &ps); 142 143 UpdateStatusBar(infoPtr->pActiveCell->ch); 144 break; 145 } 146 147 case WM_DESTROY: 148 { 149 DeleteObject(hFont); 150 151 break; 152 } 153 154 default: 155 { 156 HandleDefaultMessage: 157 Ret = DefWindowProcW(hwnd, 158 uMsg, 159 wParam, 160 lParam); 161 break; 162 } 163 } 164 165 return Ret; 166 } 167