// subclass for dialog item LRESULT CALLBACK InternalEmulatorInputDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { auto d = (DialogData *)dwRefData; switch (uMsg) { case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; HANDLE hOldFont; TCHAR szText[200]; RECT rect; SIZE sz; int x, y; // Get a device context for this window hdc = BeginPaint(hWnd, &ps); auto hFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, TEXT("Arial")); SelectObject(hdc, hFont); // Set the text colours SetTextColor(hdc, d->fgColor); SetBkColor(hdc, d->bgColor); // Find the text to draw GetWindowText(hWnd, szText, sizeof(szText)); // Work out where to draw GetClientRect(hWnd, &rect); // Find out how big the text will be GetTextExtentPoint32(hdc, szText, lstrlen(szText), &sz); // Center the text x = (rect.right - sz.cx) / 2; y = (rect.bottom - sz.cy) / 2; // Draw the text ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0); DeleteObject(hFont); EndPaint(hWnd, &ps); break; } case WM_KEYDOWN: { if (LOWORD(wParam) == VK_DELETE) { d->setting.type = InternalEmulatorInputType::KEY; d->setting.value = 0; d->fgColor = RGB(255, 0, 0); d->bgColor = RGB(0, 255, 0); auto s = GetButtonText(d); SetWindowText(hWnd, s.c_str()); } else if (IsValidKey(LOWORD(wParam))) { //d->fgColor = GetSysColor(COLOR_WINDOWTEXT); //d->bgColor = GetSysColor(COLOR_WINDOW); d->setting.type = InternalEmulatorInputType::KEY; d->setting.value = lParam; d->fgColor = RGB(255, 0, 0); d->bgColor = RGB(0, 255, 0); auto s = GetButtonText(d); SetWindowText(hWnd, s.c_str()); } else { d->fgColor = RGB(0, 255, 0); d->bgColor = RGB(255, 0, 0); } InvalidateRect(GetParent(hWnd), NULL, false); break; } case WM_TIMER: { if (hWnd == GetFocus()) { if (JoystickPoll(GetParent(hWnd), d)) { //d->fgColor = GetSysColor(COLOR_WINDOWTEXT); //d->bgColor = GetSysColor(COLOR_WINDOW); auto s = GetButtonText(d); SetWindowText(hWnd, s.c_str()); InvalidateRect(GetParent(hWnd), NULL, false); } } SetTimer(hWnd, 747, 125, NULL); break; } case WM_CHAR: { break; } case WM_SETFOCUS: { if (!d->timerActive) { SetTimer(hWnd, 777, 125, NULL); d->timerActive = true; } d->fgColor = RGB(255, 0, 0); d->bgColor = RGB(0, 255, 0); InvalidateRect(GetParent(hWnd), NULL, false); break; } case WM_KILLFOCUS: { d->fgColor = GetSysColor(COLOR_WINDOWTEXT); d->bgColor = GetSysColor(COLOR_WINDOW); InvalidateRect(GetParent(hWnd), NULL, false); break; } default: return DefSubclassProc(hWnd, uMsg, wParam, lParam); } return 0; }
bool ArrayData::IsValidKey(CVarRef k) { return k.isInteger() || k.isString() && IsValidKey(k.getStringData()); }
bool ArrayData::IsValidKey(CStrRef k) { return IsValidKey(k.get()); }
const Variant& ArrayData::get(const Variant& k, bool error) const { assert(IsValidKey(k)); auto const cell = k.asCell(); return isIntKey(cell) ? get(getIntKey(cell), error) : get(getStringKey(cell), error); }
bool ArrayData::IsValidKey(const Variant& k) { return k.isInteger() || (k.isString() && IsValidKey(k.getStringData())); }
bool ArrayData::IsValidKey(const String& k) { return IsValidKey(k.get()); }