https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d90e1061e1f8d09ba70a87170cd6d29813703579

commit d90e1061e1f8d09ba70a87170cd6d29813703579
Author:     Charles Ambrye <[email protected]>
AuthorDate: Wed Apr 15 14:31:16 2020 -0700
Commit:     GitHub <[email protected]>
CommitDate: Wed Apr 15 23:31:16 2020 +0200

    [CHARMAP] Updates to behaviour and UI (#2543)
    
    Purpose
    ~=~=~=~
    
    This pull request updates charmap to look a bit better (removes gap at 
bottom of the window), removes the blank space character (0x0020) from the 
charmap, and also modifies the behaviour of when a larger glyph is rendered 
(allowing the user to select a new glyph by holding down the mouse button). 
This better mimics the charmap.exe that is bundled by Microsoft.
    
    Proposed changes
    ~=~=~=~=~=~=~=~=
    
    - Remove gap where the advanced button is normally rendered when compiled 
with REMOVE_ADVANCED (which is the default behaviour).
    - Skip over the blank space character.
    - Change behaviour of rendering large glyphs to allow mouse move, and to 
hide on double click.
    - Optimize search for glyph under the mouse by using the cellSize instead 
of PtInRect.
    
    
    * [CHARMAP] Resize the window slightly when compiled with REMOVE_ADVANCED 
to avoid deadspace at the bottom of the window
    
    * [CHARMAP] Skip over the non-printable characters by starting with 
character ' ' + 1
    
    * [CHARMAP] Instead of iterating over every cell, simply compute the cell x 
and y using the CellSize
    
    Modify behaviour of charmap to allow large character render on mouse move, 
only hiding the larger character on double click.
---
 base/applications/charmap/charmap.c | 12 +++++
 base/applications/charmap/map.c     | 92 +++++++++++++++++--------------------
 2 files changed, 54 insertions(+), 50 deletions(-)

diff --git a/base/applications/charmap/charmap.c 
b/base/applications/charmap/charmap.c
index 218f8512c5e..1ed517b390f 100644
--- a/base/applications/charmap/charmap.c
+++ b/base/applications/charmap/charmap.c
@@ -276,6 +276,8 @@ ChangeView(HWND hWnd)
     RECT rcCharmap;
 #ifndef REMOVE_ADVANCED
     RECT rcAdvanced;
+#else
+    RECT rcCopy;
 #endif
     RECT rcPanelExt;
     RECT rcPanelInt;
@@ -284,10 +286,16 @@ ChangeView(HWND hWnd)
     UINT xPos, yPos;
     UINT Width, Height;
     UINT DeskTopWidth, DeskTopHeight;
+#ifdef REMOVE_ADVANCED
+    HWND hCopy;
+#endif
 
     GetClientRect(hCharmapDlg, &rcCharmap);
 #ifndef REMOVE_ADVANCED
     GetClientRect(hAdvancedDlg, &rcAdvanced);
+#else
+    hCopy = GetDlgItem(hCharmapDlg, IDC_COPY);
+    GetClientRect(hCopy, &rcCopy);
 #endif
     GetWindowRect(hWnd, &rcPanelExt);
     GetClientRect(hWnd, &rcPanelInt);
@@ -312,6 +320,10 @@ ChangeView(HWND hWnd)
 #ifndef REMOVE_ADVANCED
     if (Settings.IsAdvancedView)
         Height += rcAdvanced.bottom;
+#else
+    /* The lack of advanced button leaves an empty gap at the bottom of the 
window.
+       Shrink the window height a bit here to accomodate for that lost 
control. */
+    Height = rcCharmap.bottom + rcCopy.bottom + 10;
 #endif
     if ((xPos + Width) > DeskTopWidth)
         xPos += DeskTopWidth - (xPos + Width);
diff --git a/base/applications/charmap/map.c b/base/applications/charmap/map.c
index a8a9c8a2823..7b2d7838ef8 100644
--- a/base/applications/charmap/map.c
+++ b/base/applications/charmap/map.c
@@ -256,7 +256,7 @@ SetFont(PMAP infoPtr,
                          GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR)
     {
         j = 0;
-        for (i = 0; i < MAX_GLYPHS; i++)
+        for (i = ' ' + 1; i < MAX_GLYPHS; i++)
         {
             if (out[i] != 0xffff)
             {
@@ -312,64 +312,38 @@ OnClick(PMAP infoPtr,
         WORD ptx,
         WORD pty)
 {
-    POINT pt;
     INT x, y;
 
-    pt.x = ptx;
-    pt.y = pty;
+    x = ptx / max(1, infoPtr->CellSize.cx);
+    y = pty / max(1, infoPtr->CellSize.cy);
 
-    for (x = 0; x < XCELLS; x++)
-    for (y = 0; y < YCELLS; y++)
+    /* if the cell is not already active */
+    if (!infoPtr->Cells[y][x].bActive)
     {
-        if (PtInRect(&infoPtr->Cells[y][x].CellInt,
-                     pt))
+        /* set previous active cell to inactive */
+        if (infoPtr->pActiveCell)
         {
-            /* 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
+            /* invalidate normal cells, required when
+             * moving a small active cell via keyboard */
+            if (!infoPtr->pActiveCell->bLarge)
             {
-                /* 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;
+                InvalidateRect(infoPtr->hMapWnd,
+                               &infoPtr->pActiveCell->CellInt,
+                               TRUE);
             }
 
-            break;
+            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);
     }
 }
 
@@ -577,12 +551,30 @@ MapWndProc(HWND hwnd,
             break;
         }
 
+        case WM_MOUSEMOVE:
+        {
+            if (wParam & MK_LBUTTON)
+            {
+                OnClick(infoPtr,
+                        LOWORD(lParam),
+                        HIWORD(lParam));
+            }
+            break;
+        }
+
         case WM_LBUTTONDBLCLK:
         {
             NotifyParentOfSelection(infoPtr,
                                     FM_SETCHAR,
                                     infoPtr->pActiveCell->ch);
 
+            if (infoPtr->pActiveCell->bLarge)
+            {
+                DestroyWindow(infoPtr->hLrgWnd);
+                infoPtr->hLrgWnd = NULL;
+            }
+
+            infoPtr->pActiveCell->bLarge = FALSE;
 
             break;
         }

Reply via email to