reactos/dll/cpl/access/mouse.c

205 lines
6.8 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Accessibility Control Panel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: dll/cpl/access/mouse.c
* PURPOSE: Mouse-related accessibility settings
* COPYRIGHT: Copyright 2004 Johannes Anderwald (johannes.anderwald@reactos.org)
* Copyright 2007 Eric Kohl
*/
#include "access.h"
#define SPEEDTICKS 9
#define ACCELTICKS 9
modified base/applications/screensavers/3dtext/3dtext.rbuild modified lib/sdk/crt/crt.rbuild Split chkstk away from crt Link 3dtext to chkstk for Visual C++ builds (a gcc-built 3dtext would simply crash, I guess?) modified dll/cpl/access/display.c modified dll/cpl/access/general.c modified dll/cpl/access/keyboard.c modified dll/cpl/access/mouse.c Fixed signedness violations (thank you cl -Wall -W4) modified dll/win32/acledit/acledit.rbuild modified dll/win32/aclui/aclui.rbuild Removed empty stubs (thank you cl -Wall -W4) modified dll/win32/aclui/checklist.c Fixed signedness violations wcsnicmp is not a standard C routine BOOL is not a boolean Thank you cl -Wall -W4 modified dll/win32/aclui/sidcache.c Marked possible overflow (thank you cl -Wall -W4) modified dll/win32/msvcrt/msvcrt.def __iob_func and __p_iob are the same thing Export non-conforming swprintf as _swprintf, too (will fix for real later) Thank you cl -Wall -W4 modified include/ddk/winddk.h Zero-length array field in struct _SCATTER_GATHER_LIST Forward-declare structures out of argument lists Thank you cl -Wall -W4 modified include/reactos/msvctarget.h No need to emulate Visual C++ flags when compiling with Visual C++ modified lib/3rdparty/mingw/cpu_features.c modified lib/3rdparty/mingw/cpu_features.h Useless dependency from stdbool.h removed Now compiles with Visual C++ too modified lib/3rdparty/mingw/getopt.c Silence harmless warning modified lib/3rdparty/mingw/isascii.c modified lib/3rdparty/mingw/iscsym.c modified lib/3rdparty/mingw/iscsymf.c modified lib/3rdparty/mingw/toascii.c Undefine conflicting macro names before declaring the functions modified Makefile Visual C++ support is coming, did you bring your coat? svn path=/trunk/; revision=36954
2008-10-25 17:32:54 +00:00
static UINT nSpeedArray[SPEEDTICKS] = {10, 20, 30, 40, 60, 80, 120, 180, 360};
INT_PTR CALLBACK
MouseKeysDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
PGLOBAL_DATA pGlobalData;
INT i;
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
pGlobalData = (PGLOBAL_DATA)lParam;
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
CheckDlgButton(hwndDlg,
IDC_MOUSEKEYS_ACTIVATE_CHECK,
pGlobalData->mouseKeys.dwFlags & MKF_HOTKEYACTIVE ? BST_CHECKED : BST_UNCHECKED);
/* Set the number of ticks for the speed trackbar */
SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_SPEED_TRACK, TBM_SETRANGE,
TRUE, MAKELONG(0, SPEEDTICKS - 1));
/* Calculate the matching tick */
for (i = 0; i < SPEEDTICKS; i++)
{
if (pGlobalData->mouseKeys.iMaxSpeed <= nSpeedArray[i])
break;
}
/* Set the thumb */
SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_SPEED_TRACK, TBM_SETPOS, TRUE, i);
/* Set the number of ticks for the acceleration trackbar */
SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_ACCEL_TRACK, TBM_SETRANGE,
TRUE, MAKELONG(0, ACCELTICKS - 1));
/* Calculate the matching tick */
i = (ACCELTICKS + 1) - pGlobalData->mouseKeys.iTimeToMaxSpeed / 500;
if (i > ACCELTICKS - 1)
i = ACCELTICKS - 1;
if (i < 0)
i = 0;
/* Set the thumb */
SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_ACCEL_TRACK, TBM_SETPOS, TRUE, i);
CheckDlgButton(hwndDlg,
IDC_MOUSEKEYS_SPEED_CHECK,
pGlobalData->mouseKeys.dwFlags & MKF_MODIFIERS ? BST_CHECKED : BST_UNCHECKED);
CheckRadioButton(hwndDlg,
IDC_MOUSEKEYS_ON_RADIO,
IDC_MOUSEKEYS_OFF_RADIO,
pGlobalData->mouseKeys.dwFlags & MKF_REPLACENUMBERS ? IDC_MOUSEKEYS_ON_RADIO : IDC_MOUSEKEYS_OFF_RADIO);
CheckDlgButton(hwndDlg,
IDC_MOUSEKEYS_STATUS_CHECK,
pGlobalData->mouseKeys.dwFlags & MKF_INDICATOR ? BST_CHECKED : BST_UNCHECKED);
break;
case WM_HSCROLL:
switch (GetWindowLongPtr((HWND) lParam, GWL_ID))
{
case IDC_MOUSEKEYS_SPEED_TRACK:
i = SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_SPEED_TRACK, TBM_GETPOS, 0, 0);
if (i >= 0 && i < SPEEDTICKS)
pGlobalData->mouseKeys.iMaxSpeed = nSpeedArray[i];
break;
case IDC_MOUSEKEYS_ACCEL_TRACK:
i = SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_ACCEL_TRACK, TBM_GETPOS, 0, 0);
if (i >= 0 && i < ACCELTICKS)
pGlobalData->mouseKeys.iTimeToMaxSpeed = (ACCELTICKS + 1 - i) * 500;
break;
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_MOUSEKEYS_ACTIVATE_CHECK:
pGlobalData->mouseKeys.dwFlags ^= MKF_HOTKEYACTIVE;
break;
case IDC_MOUSEKEYS_SPEED_CHECK:
pGlobalData->mouseKeys.dwFlags ^= MKF_MODIFIERS;
break;
case IDC_MOUSEKEYS_ON_RADIO:
pGlobalData->mouseKeys.dwFlags |= MKF_REPLACENUMBERS;
break;
case IDC_MOUSEKEYS_OFF_RADIO:
pGlobalData->mouseKeys.dwFlags &= ~MKF_REPLACENUMBERS;
break;
case IDC_MOUSEKEYS_STATUS_CHECK:
pGlobalData->mouseKeys.dwFlags ^= MKF_INDICATOR;
break;
case IDOK:
EndDialog(hwndDlg, TRUE);
break;
case IDCANCEL:
EndDialog(hwndDlg, FALSE);
break;
default:
break;
}
break;
}
return FALSE;
}
/* Property page dialog callback */
INT_PTR CALLBACK
MousePageProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
PGLOBAL_DATA pGlobalData;
LPPSHNOTIFY lppsn;
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
if (pGlobalData == NULL)
return FALSE;
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
/* Set the checkbox */
CheckDlgButton(hwndDlg,
IDC_MOUSE_BOX,
pGlobalData->mouseKeys.dwFlags & MKF_MOUSEKEYSON ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_MOUSE_BOX:
pGlobalData->mouseKeys.dwFlags ^= MKF_MOUSEKEYSON;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
case IDC_MOUSE_BUTTON:
if (DialogBoxParam(hApplet,
MAKEINTRESOURCE(IDD_MOUSEKEYSOPTIONS),
hwndDlg,
MouseKeysDlgProc,
(LPARAM)pGlobalData))
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
default:
break;
}
break;
case WM_NOTIFY:
lppsn = (LPPSHNOTIFY)lParam;
if (lppsn->hdr.code == PSN_APPLY)
{
SystemParametersInfo(SPI_SETMOUSEKEYS,
sizeof(MOUSEKEYS),
&pGlobalData->mouseKeys,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/);
return TRUE;
}
break;
}
return FALSE;
}