Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. gesture.c
  5. Abstract: Tablet PC Gesture Property Sheet module.
  6. Environment:
  7. User mode
  8. Author:
  9. Michael Tsang (MikeTs) 20-Apr-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. GESTURE_SETTINGS gGestureSettings = {0};
  14. int giGestureControls[] =
  15. {
  16. IDC_GESTUREMAP_GROUPBOX,
  17. IDC_UPSPIKE_TEXT,
  18. IDC_UPSPIKE,
  19. IDC_DOWNSPIKE_TEXT,
  20. IDC_DOWNSPIKE,
  21. IDC_LEFTSPIKE_TEXT,
  22. IDC_LEFTSPIKE,
  23. IDC_RIGHTSPIKE_TEXT,
  24. IDC_RIGHTSPIKE,
  25. 0
  26. };
  27. COMBOBOX_STRING GestureComboStringTable[] =
  28. {
  29. GestureNoAction, IDS_GESTCOMBO_NONE,
  30. PopupSuperTIP, IDS_GESTCOMBO_POPUP_SUPERTIP,
  31. PopupMIP, IDS_GESTCOMBO_POPUP_MIP,
  32. 0, 0
  33. };
  34. int giGestureComboIDs[] =
  35. {
  36. IDC_UPSPIKE,
  37. IDC_DOWNSPIKE,
  38. IDC_LEFTSPIKE,
  39. IDC_RIGHTSPIKE
  40. };
  41. DWORD gGestureHelpIDs[] =
  42. {
  43. IDC_ENABLE_GESTURE, IDH_GESTURE_MAP,
  44. IDC_UPSPIKE, IDH_GESTURE_MAP,
  45. IDC_DOWNSPIKE, IDH_GESTURE_MAP,
  46. IDC_LEFTSPIKE, IDH_GESTURE_MAP,
  47. IDC_RIGHTSPIKE, IDH_GESTURE_MAP,
  48. 0, 0
  49. };
  50. /*****************************************************************************
  51. *
  52. * @doc EXTERNAL
  53. *
  54. * @func INT_PTR | GestureDlgProc |
  55. * Dialog procedure for the Gesture map page.
  56. *
  57. * @parm IN HWND | hwnd | Window handle.
  58. * @parm IN UINT | uMsg | Message.
  59. * @parm IN WPARAM | wParam | Word Parameter.
  60. * @parm IN LPARAM | lParam | Long Parameter.
  61. *
  62. * @rvalue Return value depends on the message.
  63. *
  64. *****************************************************************************/
  65. INT_PTR APIENTRY
  66. GestureDlgProc(
  67. IN HWND hwnd,
  68. IN UINT uMsg,
  69. IN WPARAM wParam,
  70. IN LPARAM lParam
  71. )
  72. {
  73. TRACEPROC("GestureDlgProc", 2)
  74. INT_PTR rc = FALSE;
  75. TRACEENTER(("(hwnd=%p,Msg=%s,wParam=%x,lParam=%x)\n",
  76. hwnd, LookupName(uMsg, WMMsgNames), wParam, lParam));
  77. switch (uMsg)
  78. {
  79. case WM_INITDIALOG:
  80. rc = InitGesturePage(hwnd);
  81. if (rc == FALSE)
  82. {
  83. EnableWindow(hwnd, FALSE);
  84. }
  85. break;
  86. case WM_NOTIFY:
  87. {
  88. NMHDR FAR *lpnm = (NMHDR FAR *)lParam;
  89. switch (lpnm->code)
  90. {
  91. case PSN_APPLY:
  92. RPC_TRY("TabSrvSetGestureSettings",
  93. rc = TabSrvSetGestureSettings(ghBinding,
  94. &gGestureSettings));
  95. break;
  96. }
  97. break;
  98. }
  99. case WM_COMMAND:
  100. switch (LOWORD(wParam))
  101. {
  102. int iGestureMapping;
  103. int i;
  104. case IDC_ENABLE_GESTURE:
  105. gGestureSettings.dwfFeatures &=
  106. ~GESTURE_FEATURE_RECOG_ENABLED;
  107. if (IsDlgButtonChecked(hwnd, IDC_ENABLE_GESTURE))
  108. {
  109. gGestureSettings.dwfFeatures |=
  110. GESTURE_FEATURE_RECOG_ENABLED;
  111. }
  112. EnableDlgControls(hwnd,
  113. giGestureControls,
  114. (gGestureSettings.dwfFeatures &
  115. GESTURE_FEATURE_RECOG_ENABLED) != 0);
  116. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
  117. break;
  118. case IDC_UPSPIKE:
  119. i = UP_SPIKE;
  120. goto GestureCommon;
  121. case IDC_DOWNSPIKE:
  122. i = DOWN_SPIKE;
  123. goto GestureCommon;
  124. case IDC_LEFTSPIKE:
  125. i = LEFT_SPIKE;
  126. goto GestureCommon;
  127. case IDC_RIGHTSPIKE:
  128. i = RIGHT_SPIKE;
  129. GestureCommon:
  130. switch (HIWORD(wParam))
  131. {
  132. case CBN_SELCHANGE:
  133. iGestureMapping =
  134. (int)SendMessage(GetDlgItem(hwnd,
  135. LOWORD(wParam)),
  136. CB_GETCURSEL,
  137. 0,
  138. 0);
  139. if (iGestureMapping !=
  140. gGestureSettings.GestureMap[i])
  141. {
  142. //
  143. // Mapping has changed, mark the property
  144. // sheet dirty.
  145. //
  146. gGestureSettings.GestureMap[i] =
  147. iGestureMapping;
  148. SendMessage(GetParent(hwnd),
  149. PSM_CHANGED,
  150. (WPARAM)hwnd,
  151. 0);
  152. rc = TRUE;
  153. }
  154. break;
  155. }
  156. break;
  157. case IDC_ENABLE_PRESSHOLD:
  158. gGestureSettings.dwfFeatures &=
  159. ~GESTURE_FEATURE_PRESSHOLD_ENABLED;
  160. if (IsDlgButtonChecked(hwnd, IDC_ENABLE_PRESSHOLD))
  161. {
  162. gGestureSettings.dwfFeatures |=
  163. GESTURE_FEATURE_PRESSHOLD_ENABLED;
  164. }
  165. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
  166. break;
  167. #ifdef DEBUG
  168. case IDC_ENABLE_MOUSE:
  169. gGestureSettings.dwfFeatures &=
  170. ~GESTURE_FEATURE_MOUSE_ENABLED;
  171. if (IsDlgButtonChecked(hwnd, IDC_ENABLE_MOUSE))
  172. {
  173. gGestureSettings.dwfFeatures |=
  174. GESTURE_FEATURE_MOUSE_ENABLED;
  175. }
  176. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
  177. break;
  178. #endif
  179. }
  180. break;
  181. case WM_HELP:
  182. WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  183. TEXT("tabletpc.hlp"),
  184. HELP_WM_HELP,
  185. (DWORD_PTR)gGestureHelpIDs);
  186. break;
  187. case WM_CONTEXTMENU:
  188. WinHelp((HWND)wParam,
  189. TEXT("tabletpc.hlp"),
  190. HELP_CONTEXTMENU,
  191. (DWORD_PTR)gGestureHelpIDs);
  192. break;
  193. }
  194. TRACEEXIT(("=%x\n", rc));
  195. return rc;
  196. } //GestureDlgProc
  197. /*****************************************************************************
  198. *
  199. * @doc INTERNAL
  200. *
  201. * @func BOOL | InitGesturePage |
  202. * Initialize the Gesture property page.
  203. *
  204. * @parm IN HWND | hwnd | Window handle.
  205. *
  206. * @rvalue SUCCESS | Returns TRUE.
  207. * @rvalue FAILURE | Returns FALSE.
  208. *
  209. *****************************************************************************/
  210. BOOL
  211. InitGesturePage(
  212. IN HWND hwnd
  213. )
  214. {
  215. TRACEPROC("InitGesturePage", 2)
  216. BOOL rc;
  217. TRACEENTER(("(hwnd=%x)\n", hwnd));
  218. RPC_TRY("TabSrvGetGestureSettings",
  219. rc = TabSrvGetGestureSettings(ghBinding,
  220. &gGestureSettings));
  221. if (rc == TRUE)
  222. {
  223. int i;
  224. CheckDlgButton(hwnd,
  225. IDC_ENABLE_GESTURE,
  226. (gGestureSettings.dwfFeatures &
  227. GESTURE_FEATURE_RECOG_ENABLED) != 0);
  228. EnableDlgControls(hwnd,
  229. giGestureControls,
  230. (gGestureSettings.dwfFeatures &
  231. GESTURE_FEATURE_RECOG_ENABLED) != 0);
  232. CheckDlgButton(hwnd,
  233. IDC_ENABLE_PRESSHOLD,
  234. (gGestureSettings.dwfFeatures &
  235. GESTURE_FEATURE_PRESSHOLD_ENABLED)
  236. != 0);
  237. #ifdef DEBUG
  238. CheckDlgButton(hwnd,
  239. IDC_ENABLE_MOUSE,
  240. (gGestureSettings.dwfFeatures &
  241. GESTURE_FEATURE_MOUSE_ENABLED)
  242. != 0);
  243. #endif
  244. for (i = 0; i < NUM_GESTURES; i++)
  245. {
  246. InsertComboBoxStrings(hwnd,
  247. giGestureComboIDs[i],
  248. GestureComboStringTable);
  249. SendDlgItemMessage(hwnd,
  250. giGestureComboIDs[i],
  251. CB_SETCURSEL,
  252. gGestureSettings.GestureMap[i],
  253. 0);
  254. }
  255. }
  256. else
  257. {
  258. ErrorMsg(IDSERR_TABSRV_GETGESTURESETTINGS);
  259. }
  260. TRACEEXIT(("=%x\n", rc));
  261. return rc;
  262. } //InitGesturePage