Commit 4790f823 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Make the control look more like native by using the right font and

spacing. - Use TextOutW rather than DrawTextW as we don't use any features of DrawTextW. - Fix caret size and position. - Implement WM_CHAR and WM_SYSCHAR messages.
parent 317d6c59
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
* If you discover missing features or bugs please note them below. * If you discover missing features or bugs please note them below.
* *
* TODO: * TODO:
* Messages:
* WM_CHAR
* WM_SYSCHAR
* Styles: * Styles:
* WS_DISABLED * WS_DISABLED
* Notifications: * Notifications:
...@@ -67,6 +64,7 @@ typedef struct tagHOTKEY_INFO ...@@ -67,6 +64,7 @@ typedef struct tagHOTKEY_INFO
#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongPtrA (hwnd, 0)) #define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongPtrA (hwnd, 0))
static const WCHAR HOTKEY_plussep[] = { ' ', '+', ' ' }; static const WCHAR HOTKEY_plussep[] = { ' ', '+', ' ' };
static LRESULT HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
#define IsOnlySet(flags) (infoPtr->CurrMod == (flags)) #define IsOnlySet(flags) (infoPtr->CurrMod == (flags))
...@@ -100,39 +98,47 @@ HOTKEY_IsCombInv(HOTKEY_INFO *infoPtr) ...@@ -100,39 +98,47 @@ HOTKEY_IsCombInv(HOTKEY_INFO *infoPtr)
#undef IsOnlySet #undef IsOnlySet
static void static void
HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, LPCWSTR KeyName, WORD NameLen, HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, LPCWSTR KeyName, WORD NameLen, HDC hdc)
LPRECT rc, HDC hdc)
{ {
SIZE TextSize; SIZE TextSize;
INT nXStart, nYStart;
COLORREF clrOldText, clrOldBk;
HFONT hFontOld;
/* We have to allow some space for the frame to be drawn */ /* Make a gap from the frame */
rc->left += 2; nXStart = GetSystemMetrics(SM_CXBORDER);
rc->top++; nYStart = GetSystemMetrics(SM_CYBORDER);
DrawTextW(hdc, KeyName, NameLen, rc, DT_LEFT | DT_VCENTER);
rc->left -= 2; hFontOld = SelectObject(hdc, infoPtr->hFont);
rc->top--; clrOldText = SetTextColor(hdc, comctl32_color.clrWindowText);
clrOldBk = SetBkColor(hdc, comctl32_color.clrWindow);
/* Get the text size and position the caret accordingly */
GetTextExtentPoint32W (hdc, KeyName, NameLen, &TextSize); TextOutW(hdc, nXStart, nYStart, KeyName, NameLen);
infoPtr->CaretPos = TextSize.cx + 2;
SetCaretPos(infoPtr->CaretPos, 3); /* Get the text width for the caret */
GetTextExtentPoint32W(hdc, KeyName, NameLen, &TextSize);
infoPtr->CaretPos = nXStart + TextSize.cx;
SetBkColor(hdc, clrOldBk);
SetTextColor(hdc, clrOldText);
SelectObject(hdc, hFontOld);
/* position the caret */
SetCaretPos(infoPtr->CaretPos, nYStart);
} }
/* Draw the names of the keys in the control */ /* Draw the names of the keys in the control */
static void static void
HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc) HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc)
{ {
WCHAR KeyName[sizeof(WCHAR) * 64]; WCHAR KeyName[64];
WORD NameLen = 0; WORD NameLen = 0;
BYTE Modifier; BYTE Modifier;
RECT rc;
GetClientRect(infoPtr->hwndSelf, &rc);
TRACE("(infoPtr=%p hdc=%p)\n", infoPtr, hdc); TRACE("(infoPtr=%p hdc=%p)\n", infoPtr, hdc);
if(!infoPtr->CurrMod && !infoPtr->HotKey) { if(!infoPtr->CurrMod && !infoPtr->HotKey) {
HOTKEY_DrawHotKey (infoPtr, infoPtr->strNone, 4, &rc, hdc); HOTKEY_DrawHotKey (infoPtr, infoPtr->strNone, 4, hdc);
return; return;
} }
...@@ -172,7 +178,7 @@ HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc) ...@@ -172,7 +178,7 @@ HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc)
else else
KeyName[NameLen] = 0; KeyName[NameLen] = 0;
HOTKEY_DrawHotKey (infoPtr, KeyName, NameLen, &rc, hdc); HOTKEY_DrawHotKey (infoPtr, KeyName, NameLen, hdc);
} }
static void static void
...@@ -216,21 +222,13 @@ HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -216,21 +222,13 @@ HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
infoPtr->InvComb, infoPtr->InvMod); infoPtr->InvComb, infoPtr->InvMod);
} }
/* << HOTKEY_Char >> */
static LRESULT static LRESULT
HOTKEY_Create (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) HOTKEY_Create (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{ {
TEXTMETRICW tm;
HDC hdc;
infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent; infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent;
/* get default font height */ HOTKEY_SetFont(infoPtr, (WPARAM)GetStockObject(SYSTEM_FONT), 0);
hdc = GetDC (infoPtr->hwndSelf);
GetTextMetricsW (hdc, &tm);
infoPtr->nHeight = tm.tmHeight;
ReleaseDC (infoPtr->hwndSelf, hdc);
return 0; return 0;
} }
...@@ -385,9 +383,9 @@ HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -385,9 +383,9 @@ HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
infoPtr->bFocus = TRUE; infoPtr->bFocus = TRUE;
CreateCaret (infoPtr->hwndSelf, NULL, 1, infoPtr->nHeight - 2); CreateCaret (infoPtr->hwndSelf, NULL, 1, infoPtr->nHeight);
SetCaretPos (infoPtr->CaretPos, 3); SetCaretPos (infoPtr->CaretPos, GetSystemMetrics(SM_CYBORDER));
ShowCaret (infoPtr->hwndSelf); ShowCaret (infoPtr->hwndSelf);
...@@ -396,7 +394,7 @@ HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -396,7 +394,7 @@ HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
} }
inline static LRESULT static LRESULT
HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
{ {
TEXTMETRICW tm; TEXTMETRICW tm;
...@@ -440,7 +438,9 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -440,7 +438,9 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HOTKEY_SetRules (infoPtr, wParam, lParam); HOTKEY_SetRules (infoPtr, wParam, lParam);
break; break;
/* case WM_CHAR: */ case WM_CHAR:
case WM_SYSCHAR:
return HOTKEY_KeyDown (infoPtr, MapVirtualKeyW(LOBYTE(HIWORD(lParam)), 1), lParam);
case WM_CREATE: case WM_CREATE:
return HOTKEY_Create (infoPtr, wParam, lParam); return HOTKEY_Create (infoPtr, wParam, lParam);
...@@ -484,8 +484,6 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -484,8 +484,6 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_SETFONT: case WM_SETFONT:
return HOTKEY_SetFont (infoPtr, wParam, lParam); return HOTKEY_SetFont (infoPtr, wParam, lParam);
/* case WM_SYSCHAR: */
default: default:
if ((uMsg >= WM_USER) && (uMsg < WM_APP)) if ((uMsg >= WM_USER) && (uMsg < WM_APP))
ERR("unknown msg %04x wp=%08x lp=%08lx\n", ERR("unknown msg %04x wp=%08x lp=%08lx\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment