sync with trunk r47227
[reactos.git] / base / applications / charmap / lrgcell.c
index fc9af4b..4894202 100644 (file)
-/*\r
- * PROJECT:     ReactOS Character Map\r
- * LICENSE:     GPL - See COPYING in the top level directory\r
- * FILE:        base/applications/charmap/lrgcell.c\r
- * PURPOSE:     large cell window implementation\r
- * COPYRIGHT:   Copyright 2007 Ged Murphy <gedmurphy@reactos.org>\r
- *\r
- */\r
-\r
-#include <precomp.h>\r
-\r
-\r
-static\r
-HFONT\r
-SetLrgFont(PMAP infoPtr)\r
-{\r
-    LOGFONTW lf;\r
-    HFONT hFont = NULL;\r
-    HDC hdc;\r
-    HWND hCombo;\r
-    LPWSTR lpFontName;\r
-    INT Len;\r
-\r
-    hCombo = GetDlgItem(infoPtr->hParent,\r
-                        IDC_FONTCOMBO);\r
-\r
-    Len = GetWindowTextLengthW(hCombo);\r
-\r
-    if (Len != 0)\r
-    {\r
-        lpFontName = HeapAlloc(GetProcessHeap(),\r
-                               0,\r
-                               (Len + 1) * sizeof(WCHAR));\r
-\r
-        if (lpFontName)\r
-        {\r
-            SendMessageW(hCombo,\r
-                         WM_GETTEXT,\r
-                         31,\r
-                         (LPARAM)lpFontName);\r
-\r
-            ZeroMemory(&lf,\r
-                       sizeof(lf));\r
-\r
-            hdc = GetDC(infoPtr->hLrgWnd);\r
-            lf.lfHeight = GetDeviceCaps(hdc,\r
-                                        LOGPIXELSY) / 2;\r
-            ReleaseDC(infoPtr->hLrgWnd,\r
-                      hdc);\r
-\r
-            lf.lfCharSet =  DEFAULT_CHARSET;\r
-            wcscpy(lf.lfFaceName,\r
-                   lpFontName);\r
-\r
-            hFont = CreateFontIndirectW(&lf);\r
-\r
-            HeapFree(GetProcessHeap(),\r
-                     0,\r
-                     lpFontName);\r
-        }\r
-    }\r
-\r
-    return hFont;\r
-}\r
-\r
-\r
-LRESULT CALLBACK\r
-LrgCellWndProc(HWND hwnd,\r
-               UINT uMsg,\r
-               WPARAM wParam,\r
-               LPARAM lParam)\r
-{\r
-    PMAP infoPtr;\r
-    LRESULT Ret = 0;\r
-    static INT cxClient, cyClient;\r
-    static RECT rc;\r
-    static HFONT hFont = NULL;\r
-\r
-    infoPtr = (PMAP)GetWindowLongPtrW(hwnd,\r
-                                     GWLP_USERDATA);\r
-\r
-    if (infoPtr == NULL && uMsg != WM_CREATE)\r
-    {\r
-        goto HandleDefaultMessage;\r
-    }\r
-\r
-    switch (uMsg)\r
-    {\r
-        case WM_CREATE:\r
-        {\r
-            infoPtr = (PMAP)(((LPCREATESTRUCTW)lParam)->lpCreateParams);\r
-\r
-            SetWindowLongPtrW(hwnd,\r
-                              GWLP_USERDATA,\r
-                              (LONG_PTR)infoPtr);\r
-\r
-            hFont = SetLrgFont(infoPtr);\r
-\r
-            break;\r
-        }\r
-\r
-        case WM_SIZE:\r
-        {\r
-            cxClient = LOWORD(lParam);\r
-            cyClient = HIWORD(lParam);\r
-\r
-            rc.left = 0;\r
-            rc.top = 0;\r
-            rc.right = cxClient;\r
-            rc.bottom = cyClient;\r
-\r
-            break;\r
-        }\r
-\r
-        case WM_PAINT:\r
-        {\r
-            PAINTSTRUCT ps;\r
-            HDC hdc;\r
-            HFONT hOldFont;\r
-\r
-            hdc = BeginPaint(hwnd,\r
-                             &ps);\r
-\r
-            Rectangle(hdc,\r
-                      0,\r
-                      0,\r
-                      cxClient,\r
-                      cyClient);\r
-\r
-            hOldFont = SelectObject(hdc, hFont);\r
-\r
-            DrawTextW(hdc,\r
-                      &infoPtr->pActiveCell->ch,\r
-                      1,\r
-                      &rc,\r
-                      DT_CENTER | DT_VCENTER | DT_SINGLELINE);\r
-\r
-            SelectObject(hdc, hOldFont);\r
-\r
-            EndPaint(hwnd,\r
-                     &ps);\r
-\r
-            break;\r
-        }\r
-\r
-        case WM_DESTROY:\r
-        {\r
-            DeleteObject(hFont);\r
-\r
-            break;\r
-        }\r
-\r
-        default:\r
-        {\r
-HandleDefaultMessage:\r
-            Ret = DefWindowProcW(hwnd,\r
-                                 uMsg,\r
-                                 wParam,\r
-                                 lParam);\r
-            break;\r
-        }\r
-    }\r
-\r
-    return Ret;\r
-}\r
+/*
+ * PROJECT:     ReactOS Character Map
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        base/applications/charmap/lrgcell.c
+ * PURPOSE:     large cell window implementation
+ * COPYRIGHT:   Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
+ *
+ */
+
+#include <precomp.h>
+
+
+static
+HFONT
+SetLrgFont(PMAP infoPtr)
+{
+    LOGFONTW lf;
+    HFONT hFont = NULL;
+    HDC hdc;
+    HWND hCombo;
+    LPWSTR lpFontName;
+    INT Len;
+
+    hCombo = GetDlgItem(infoPtr->hParent,
+                        IDC_FONTCOMBO);
+
+    Len = GetWindowTextLengthW(hCombo);
+
+    if (Len != 0)
+    {
+        lpFontName = HeapAlloc(GetProcessHeap(),
+                               0,
+                               (Len + 1) * sizeof(WCHAR));
+
+        if (lpFontName)
+        {
+            SendMessageW(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;
+            wcscpy(lf.lfFaceName,
+                   lpFontName);
+
+            hFont = CreateFontIndirectW(&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)GetWindowLongPtrW(hwnd,
+                                     GWLP_USERDATA);
+
+    if (infoPtr == NULL && uMsg != WM_CREATE)
+    {
+        goto HandleDefaultMessage;
+    }
+
+    switch (uMsg)
+    {
+        case WM_CREATE:
+        {
+            infoPtr = (PMAP)(((LPCREATESTRUCTW)lParam)->lpCreateParams);
+
+            SetWindowLongPtrW(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);
+
+            DrawTextW(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 = DefWindowProcW(hwnd,
+                                 uMsg,
+                                 wParam,
+                                 lParam);
+            break;
+        }
+    }
+
+    return Ret;
+}