mirror of
git://source.winehq.org/git/wine.git
synced 2024-08-31 12:44:08 +00:00
regedit: Convert the hex edit code to Unicode.
This commit is contained in:
parent
9b586bc2ee
commit
172ce3eed8
|
@ -58,7 +58,7 @@ const WCHAR szHexEditClass[] = {'H','e','x','E','d','i','t',0};
|
|||
|
||||
static inline LRESULT HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw);
|
||||
|
||||
static inline BYTE hexchar_to_byte(TCHAR ch)
|
||||
static inline BYTE hexchar_to_byte(WCHAR ch)
|
||||
{
|
||||
if (ch >= '0' && ch <= '9')
|
||||
return ch - '0';
|
||||
|
@ -70,17 +70,19 @@ static inline BYTE hexchar_to_byte(TCHAR ch)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static LPTSTR HexEdit_GetLineText(BYTE *pData, LONG cbData, LONG pad)
|
||||
static LPWSTR HexEdit_GetLineText(BYTE *pData, LONG cbData, LONG pad)
|
||||
{
|
||||
LPTSTR lpszLine = HeapAlloc(GetProcessHeap(), 0,
|
||||
(cbData * 3 + pad * 3 + DIV_SPACES + cbData + 1) * sizeof(TCHAR));
|
||||
static const WCHAR percent_02xW[] = {'%','0','2','X',' ',0};
|
||||
|
||||
LPWSTR lpszLine = HeapAlloc(GetProcessHeap(), 0,
|
||||
(cbData * 3 + pad * 3 + DIV_SPACES + cbData + 1) * sizeof(WCHAR));
|
||||
LONG i;
|
||||
|
||||
if (!lpszLine)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < cbData; i++)
|
||||
wsprintf(lpszLine + i*3, TEXT("%02X "), pData[i]);
|
||||
wsprintfW(lpszLine + i*3, percent_02xW, pData[i]);
|
||||
for (i = 0; i < pad * 3; i++)
|
||||
lpszLine[cbData * 3 + i] = ' ';
|
||||
|
||||
|
@ -117,7 +119,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
|
|||
nXStart = GetSystemMetrics(SM_CXBORDER);
|
||||
nYStart = GetSystemMetrics(SM_CYBORDER);
|
||||
|
||||
if (GetWindowLong(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
|
||||
if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
|
||||
clrOldText = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
|
||||
else
|
||||
clrOldText = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
||||
|
@ -127,14 +129,14 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
|
|||
|
||||
for (pData = infoPtr->pData + lByteOffset; pData < infoPtr->pData + infoPtr->cbData; pData += infoPtr->nBytesPerLine)
|
||||
{
|
||||
LPTSTR lpszLine;
|
||||
LPWSTR lpszLine;
|
||||
LONG nLineLen = min((LONG)((infoPtr->pData + infoPtr->cbData) - pData),
|
||||
infoPtr->nBytesPerLine);
|
||||
|
||||
lpszLine = HexEdit_GetLineText(pData, nLineLen, infoPtr->nBytesPerLine - nLineLen);
|
||||
|
||||
/* FIXME: draw hex <-> ASCII mapping highlighted? */
|
||||
TextOut(hdc, nXStart, nYStart, lpszLine, infoPtr->nBytesPerLine * 3 + DIV_SPACES + nLineLen);
|
||||
TextOutW(hdc, nXStart, nYStart, lpszLine, infoPtr->nBytesPerLine * 3 + DIV_SPACES + nLineLen);
|
||||
|
||||
nYStart += infoPtr->nHeight;
|
||||
HeapFree(GetProcessHeap(), 0, lpszLine);
|
||||
|
@ -157,7 +159,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
|
|||
INT nByteLinePos = nCaretBytePos % infoPtr->nBytesPerLine;
|
||||
INT nLine = nCaretBytePos / infoPtr->nBytesPerLine;
|
||||
LONG nLineLen = min(infoPtr->cbData - nLine * infoPtr->nBytesPerLine, infoPtr->nBytesPerLine);
|
||||
LPTSTR lpszLine = HexEdit_GetLineText(infoPtr->pData + nLine * infoPtr->nBytesPerLine, nLineLen, infoPtr->nBytesPerLine - nLineLen);
|
||||
LPWSTR lpszLine = HexEdit_GetLineText(infoPtr->pData + nLine * infoPtr->nBytesPerLine, nLineLen, infoPtr->nBytesPerLine - nLineLen);
|
||||
INT nCharOffset;
|
||||
|
||||
/* calculate offset of character caret is on in the line */
|
||||
|
@ -169,7 +171,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
|
|||
hdc = GetDC(infoPtr->hwndSelf);
|
||||
hOldFont = SelectObject(hdc, infoPtr->hFont);
|
||||
|
||||
GetTextExtentPoint32(hdc, lpszLine, nCharOffset, &size);
|
||||
GetTextExtentPoint32W(hdc, lpszLine, nCharOffset, &size);
|
||||
|
||||
SelectObject(hdc, hOldFont);
|
||||
ReleaseDC(infoPtr->hwndSelf, hdc);
|
||||
|
@ -221,7 +223,7 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
|
|||
si.fMask = SIF_POS;
|
||||
|
||||
SetScrollInfo(infoPtr->hwndSelf, SB_VERT, &si, FALSE);
|
||||
SendMessage(infoPtr->hwndSelf, WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, 0), 0);
|
||||
SendMessageW(infoPtr->hwndSelf, WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, 0), 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,7 +257,7 @@ HexEdit_GetData(HEXEDIT_INFO *infoPtr, INT cbData, BYTE *pData)
|
|||
}
|
||||
|
||||
static inline LRESULT
|
||||
HexEdit_Char (HEXEDIT_INFO *infoPtr, TCHAR ch)
|
||||
HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch)
|
||||
{
|
||||
INT nCaretBytePos = infoPtr->nCaretPos/2;
|
||||
|
||||
|
@ -349,7 +351,7 @@ HexEdit_Destroy (HEXEDIT_INFO *infoPtr)
|
|||
HeapFree(GetProcessHeap(), 0, infoPtr->pData);
|
||||
/* free info data */
|
||||
HeapFree(GetProcessHeap(), 0, infoPtr);
|
||||
SetWindowLongPtr(hwnd, 0, 0);
|
||||
SetWindowLongPtrW(hwnd, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -360,12 +362,12 @@ HexEdit_EraseBackground (HEXEDIT_INFO *infoPtr, HDC hdc)
|
|||
HBRUSH hBrush, hSolidBrush = NULL;
|
||||
RECT rc;
|
||||
|
||||
if (GetWindowLong(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
|
||||
if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
|
||||
hBrush = hSolidBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
|
||||
else
|
||||
{
|
||||
hBrush = (HBRUSH)SendMessage(GetParent(infoPtr->hwndSelf), WM_CTLCOLOREDIT,
|
||||
(WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
|
||||
hBrush = (HBRUSH)SendMessageW(GetParent(infoPtr->hwndSelf), WM_CTLCOLOREDIT,
|
||||
(WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
|
||||
if (!hBrush)
|
||||
hBrush = hSolidBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
|
||||
}
|
||||
|
@ -505,7 +507,7 @@ HexEdit_SetFocus (HEXEDIT_INFO *infoPtr, HWND lostFocus)
|
|||
static inline LRESULT
|
||||
HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
|
||||
{
|
||||
TEXTMETRIC tm;
|
||||
TEXTMETRICW tm;
|
||||
HDC hdc;
|
||||
HFONT hOldFont = NULL;
|
||||
LONG i;
|
||||
|
@ -517,7 +519,7 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
|
|||
if (infoPtr->hFont)
|
||||
hOldFont = SelectObject(hdc, infoPtr->hFont);
|
||||
|
||||
GetTextMetrics(hdc, &tm);
|
||||
GetTextMetricsW(hdc, &tm);
|
||||
infoPtr->nHeight = tm.tmHeight + tm.tmExternalLeading;
|
||||
|
||||
GetClientRect(infoPtr->hwndSelf, &rcClient);
|
||||
|
@ -525,9 +527,9 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
|
|||
for (i = 0; ; i++)
|
||||
{
|
||||
BYTE *pData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, i);
|
||||
LPTSTR lpszLine = HexEdit_GetLineText(pData, i, 0);
|
||||
LPWSTR lpszLine = HexEdit_GetLineText(pData, i, 0);
|
||||
SIZE size;
|
||||
GetTextExtentPoint32(hdc, lpszLine, lstrlen(lpszLine), &size);
|
||||
GetTextExtentPoint32W(hdc, lpszLine, lstrlenW(lpszLine), &size);
|
||||
HeapFree(GetProcessHeap(), 0, lpszLine);
|
||||
HeapFree(GetProcessHeap(), 0, pData);
|
||||
if (size.cx > (rcClient.right - rcClient.left))
|
||||
|
|
Loading…
Reference in a new issue