Author: gedmurphy
Date: Tue Dec 1 21:29:12 2015
New Revision: 70228
URL:
http://svn.reactos.org/svn/reactos?rev=70228&view=rev
Log:
[CHARMAP]
- Hackfix the existing charmap for the 0.4 release (just in case I don't get time to
finish the new one). This fixes showing invalid glyphs and also removes the advanced
section as it was unimplemented.
Modified:
trunk/reactos/base/applications/charmap/charmap.c
trunk/reactos/base/applications/charmap/map.c
trunk/reactos/base/applications/charmap/precomp.h
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/base/applications/charmap/charmap.c [iso-8859-1] Tue Dec 1 21:29:12
2015
@@ -12,6 +12,8 @@
#include <commctrl.h>
#include <richedit.h>
+#define REMOVE_ADVANCED
+
#define ID_ABOUT 0x1
HINSTANCE hInstance;
@@ -237,7 +239,7 @@
SendMessage(hText, WM_CHAR, (WPARAM)ch, 0);
}
-
+#ifndef REMOVE_ADVANCED
static
void
UpdateSettings(HWND hDlg)
@@ -245,20 +247,24 @@
if (hDlg == hCharmapDlg)
{
Settings.IsAdvancedView =
- SendDlgItemMessage(hDlg, IDC_CHECK_ADVANCED, BM_GETCHECK, 0, 0);
+ SendDlgItemMessage(hDlg, IDC_CHECK_ADVANCED, BM_GETCHECK, 0, 0);
+
}
if (hDlg == hAdvancedDlg)
{
}
}
+#endif
static
void
ChangeView(HWND hWnd)
{
RECT rcCharmap;
+#ifndef REMOVE_ADVANCED
RECT rcAdvanced;
+#endif
RECT rcPanelExt;
RECT rcPanelInt;
RECT rcStatus;
@@ -268,7 +274,9 @@
UINT DeskTopWidth, DeskTopHeight;
GetClientRect(hCharmapDlg, &rcCharmap);
+#ifndef REMOVE_ADVANCED
GetClientRect(hAdvancedDlg, &rcAdvanced);
+#endif
GetWindowRect(hWnd, &rcPanelExt);
GetClientRect(hWnd, &rcPanelInt);
GetClientRect(hStatusWnd, &rcStatus);
@@ -280,19 +288,19 @@
DeY = (rcPanelExt.bottom - rcPanelExt.top) - rcPanelInt.bottom;
MoveWindow(hCharmapDlg, 0, 0, rcCharmap.right, rcCharmap.bottom, FALSE);
+#ifndef REMOVE_ADVANCED
MoveWindow(hAdvancedDlg, 0, rcCharmap.bottom, rcAdvanced.right, rcAdvanced.bottom,
FALSE);
-
ShowWindow(hAdvancedDlg, (Settings.IsAdvancedView) ? SW_SHOW : SW_HIDE);
-
+#endif
xPos = rcPanelExt.left;
yPos = rcPanelExt.top;
Width = DeX + rcCharmap.right;
Height = DeY + rcCharmap.bottom + rcStatus.bottom;
-
+#ifndef REMOVE_ADVANCED
if (Settings.IsAdvancedView)
Height += rcAdvanced.bottom;
-
+#endif
if ((xPos + Width) > DeskTopWidth)
xPos += DeskTopWidth - (xPos + Width);
@@ -318,6 +326,9 @@
case WM_INITDIALOG:
{
DWORD evMask;
+#ifdef REMOVE_ADVANCED
+ HWND hAdv;
+#endif
FillFontStyleComboList(GetDlgItem(hDlg,
IDC_FONTCOMBO));
@@ -328,7 +339,10 @@
evMask = SendDlgItemMessage(hDlg, IDC_TEXTBOX, EM_GETEVENTMASK, 0, 0);
evMask |= ENM_CHANGE;
SendDlgItemMessage(hDlg, IDC_TEXTBOX, EM_SETEVENTMASK, 0, (LPARAM)evMask);
-
+#ifdef REMOVE_ADVANCED
+ hAdv = GetDlgItem(hDlg, IDC_CHECK_ADVANCED);
+ ShowWindow(hAdv, SW_HIDE);
+#endif
return TRUE;
}
@@ -370,11 +384,12 @@
case IDC_COPY:
CopyCharacters(hDlg);
break;
-
+#ifndef REMOVE_ADVANCED
case IDC_CHECK_ADVANCED:
UpdateSettings(hDlg);
ChangeView(GetParent(hDlg));
break;
+#endif
}
}
break;
@@ -385,7 +400,7 @@
return FALSE;
}
-
+#ifndef REMOVE_ADVANCED
static
INT_PTR
CALLBACK
@@ -405,7 +420,7 @@
return FALSE;
}
-
+#endif
static int
OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
@@ -416,12 +431,12 @@
MAKEINTRESOURCE(IDD_CHARMAP),
hWnd,
CharMapDlgProc);
-
+#ifndef REMOVE_ADVANCED
hAdvancedDlg = CreateDialog(hInstance,
- MAKEINTRESOURCE(IDD_ADVANCED),
- hWnd,
- AdvancedDlgProc);
-
+ MAKEINTRESOURCE(IDD_ADVANCED),
+ hWnd,
+ AdvancedDlgProc);
+#endif
hStatusWnd = CreateWindow(STATUSCLASSNAME,
NULL,
WS_CHILD | WS_VISIBLE,
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/base/applications/charmap/map.c [iso-8859-1] Tue Dec 1 21:29:12 2015
@@ -16,14 +16,6 @@
#define MAX_ROWS (0xFFFF / XCELLS) + 1 - YCELLS
-static
-VOID
-TagFontToCell(PCELL pCell,
- WCHAR ch)
-{
- pCell->ch = ch;
-}
-
static
VOID
@@ -107,33 +99,47 @@
INT x, y;
RECT rc;
PCELL Cell;
+ INT i, added;
hOldFont = SelectObject(ps->hdc,
infoPtr->hFont);
- for (y = 0; y < YCELLS; y++)
- for (x = 0; x < XCELLS; x++)
- {
+ i = XCELLS * infoPtr->iYStart;
+
+ added = 0;
+ x = y = 0;
+ while ((y <= YCELLS) && (x <= XCELLS))
+ {
+ ch = (WCHAR)infoPtr->ValidGlyphs[i];
+
Cell = &infoPtr->Cells[y][x];
- if (!IntersectRect(&rc,
- &ps->rcPaint,
- &Cell->CellExt))
- {
- continue;
- }
-
- ch = (WCHAR)((XCELLS * (y + infoPtr->iYStart)) + x);
-
- TagFontToCell(Cell, ch);
-
- DrawTextW(ps->hdc,
- &ch,
- 1,
- &Cell->CellInt,
- DT_CENTER | DT_VCENTER | DT_SINGLELINE);
- }
-
+ if (IntersectRect(&rc,
+ &ps->rcPaint,
+ &Cell->CellExt))
+ {
+ Cell->ch = ch;
+
+ DrawTextW(ps->hdc,
+ &ch,
+ 1,
+ &Cell->CellInt,
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+
+ added++;
+ }
+
+ i++;
+ ch = (WCHAR)i;
+
+ // move to the next cell
+ x++;
+ if (x > XCELLS - 1)
+ {
+ x = 0;
+ y++;
+ }
+ }
SelectObject(ps->hdc,
hOldFont);
}
@@ -213,6 +219,9 @@
LPWSTR lpFontName)
{
HDC hdc;
+ WCHAR ch[MAX_GLYPHS];
+ WORD out[MAX_GLYPHS];
+ DWORD i, j, Rows;
/* Destroy Zoom window, since it was created with older font */
DestroyWindow(infoPtr->hLrgWnd);
@@ -225,9 +234,7 @@
sizeof(LOGFONTW));
hdc = GetDC(infoPtr->hMapWnd);
- infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc,
- LOGPIXELSY) / 5;
- ReleaseDC(infoPtr->hMapWnd, hdc);
+ infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc, LOGPIXELSY) / 5;
infoPtr->CurrentFont.lfCharSet = DEFAULT_CHARSET;
wcsncpy(infoPtr->CurrentFont.lfFaceName,
@@ -246,6 +253,39 @@
{
CreateLargeCell(infoPtr);
}
+
+ // Get all the valid glyphs in this font
+
+ SelectObject(hdc, infoPtr->hFont);
+
+ for (i = 0; i < MAX_GLYPHS; i++)
+ ch[i] = (WCHAR)i;
+
+ if (GetGlyphIndicesW(hdc,
+ ch,
+ MAX_GLYPHS,
+ out,
+ GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR)
+ {
+ j = 0;
+ for (i = 0; i < MAX_GLYPHS; i++)
+ {
+ if (out[i] != 0xffff)
+ {
+ infoPtr->ValidGlyphs[j] = ch[i];
+ j++;
+ }
+ }
+ infoPtr->NumValidGlyphs = j;
+ }
+
+ ReleaseDC(infoPtr->hMapWnd, hdc);
+
+ Rows = infoPtr->NumValidGlyphs / XCELLS;
+ if (infoPtr->NumValidGlyphs % XCELLS)
+ Rows += 1;
+
+ SetScrollRange(infoPtr->hMapWnd, SB_VERT, 0, Rows - YCELLS, FALSE);
}
@@ -379,8 +419,7 @@
SetGrid(infoPtr);
- SetScrollRange(hwnd, SB_VERT, 0, MAX_ROWS, FALSE);
- SetScrollPos(hwnd, SB_VERT, 0, TRUE);
+ SetScrollPos(infoPtr->hParent, SB_VERT, 0, TRUE);
Ret = TRUE;
}
@@ -424,8 +463,7 @@
break;
}
- infoPtr->iYStart = max(0,
- min(infoPtr->iYStart, MAX_ROWS));
+ infoPtr->iYStart = max(0, min(infoPtr->iYStart, MAX_ROWS));
iYDiff = iOldYStart - infoPtr->iYStart;
if (iYDiff)
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/base/applications/charmap/precomp.h [iso-8859-1] Tue Dec 1 21:29:12
2015
@@ -1,15 +1,13 @@
#ifndef __CHARMAP_PRECOMP_H
#define __CHARMAP_PRECOMP_H
-#include <stdarg.h>
-#include <windef.h>
-#include <winbase.h>
-#include <winuser.h>
-#include <wingdi.h>
+#include <windows.h>
#include "resource.h"
#define SIZEOF(_v) (sizeof(_v) / sizeof(*_v))
+
+#define MAX_GLYPHS 65536
#define XCELLS 20
#define YCELLS 10
@@ -44,6 +42,10 @@
HFONT hFont;
LOGFONTW CurrentFont;
INT iYStart;
+
+ USHORT ValidGlyphs[MAX_GLYPHS];
+ USHORT NumValidGlyphs;
+
} MAP, *PMAP;
typedef struct {