Leaked source code of windows server 2003
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.

269 lines
7.6 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. unixui.cxx
  5. Abstract:
  6. Contains Unix fixes
  7. Contents:
  8. //UnixAdjustButtonSpacing
  9. UnixRemoveMoreInfoButton
  10. Author:
  11. Sriram Nambakam (v-sriran) 07-Dec-1998
  12. Revision History:
  13. 07-Dec-1998 v-sriran
  14. Created
  15. --*/
  16. #include <wininetp.h>
  17. #include "ierrui.hxx"
  18. #include "iehelpid.h"
  19. #include "unixui.h"
  20. #include <mainwin.h>
  21. #if 0
  22. #define MOVE_LEFT 0
  23. #define MOVE_CENTER 1
  24. #define MOVE_RIGHT 2
  25. static void hAdjustButtonSpacing(HWND hwnd,
  26. short buttonSpacingStyle,
  27. short cButtons,
  28. short dwSpacing,
  29. ...);
  30. /* HACKHACK
  31. * On Unix, we draw a focus rectangle around the button that is currently
  32. * selected. And, the focus rectangle will overlap with the next button.
  33. * We programatically move the button to the *left*, to make it look good.
  34. */
  35. void UnixAdjustButtonSpacing(HWND hwnd, DWORD dwDlgId)
  36. {
  37. switch(dwDlgId)
  38. {
  39. case IDD_HTTP_TO_HTTPS_ZONE_CROSSING:
  40. /* In these the More Info button is ID_TELL_ME_ABOUT_SECURITY */
  41. hAdjustButtonSpacing(hwnd,
  42. MOVE_LEFT,
  43. 1,
  44. 5,
  45. IDOK);
  46. break;
  47. #ifdef NOT_YET_IMPLEMENTED
  48. case IDD_HTTPS_TO_HTTP_ZONE_CROSSING:
  49. break;
  50. case IDD_MIXED_SECURITY:
  51. break;
  52. case IDD_INVALID_CA:
  53. break;
  54. case IDD_BAD_CN:
  55. break;
  56. case IDD_CONFIRM_COOKIE:
  57. /* In this the More Info button is IDC_COOKIE_DETAILS */
  58. break;
  59. #endif /* NOT_YET_IMPLEMENTED */
  60. }
  61. }
  62. /*
  63. * This function assumes all buttons are of equal width for MOVE_CENTER
  64. */
  65. void hAdjustButtonSpacing(HWND hwnd,
  66. short buttonSpacingStyle,
  67. short cButtons,
  68. short dwSpacing,
  69. ...)
  70. {
  71. va_list Arguments;
  72. DWORD dwButtonId;
  73. va_start(Arguments, dwSpacing);
  74. if (buttonSpacingStyle != MOVE_CENTER && dwSpacing)
  75. {
  76. HWND hCurButton;
  77. RECT rect;
  78. for (short i = 0; i < cButtons; i++)
  79. {
  80. dwButtonId = (DWORD)va_arg(Arguments,ULONG);
  81. if ((hCurButton = GetDlgItem(hwnd, dwButtonId)))
  82. {
  83. GetWindowRect(hCurButton, &rect);
  84. ScreenToClient(hwnd, (LPPOINT)&rect);
  85. SetWindowPos(hCurButton,
  86. NULL,
  87. (buttonSpacingStyle == MOVE_LEFT ? rect.left-dwSpacing : rect.left+dwSpacing),
  88. rect.top,
  89. 0,
  90. 0,
  91. SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
  92. }
  93. }
  94. }
  95. else /* MOVE_CENTER; dwSpacing does not matter */
  96. {
  97. }
  98. va_end(Arguments);
  99. return;
  100. }
  101. #endif /* 0 */
  102. #define MOVE_CENTER 0x0001
  103. static void hRemoveAndAdjust(HWND hwnd,
  104. DWORD dwFlags,
  105. short cButtons,
  106. ...);
  107. /* If we have Button1 Button2 "More Info"
  108. * The following function makes it
  109. * <nothing> Button1 Button2
  110. * And, you have to pass the ids of "More Info" Button2 Button1 in the
  111. * variable argument list in that order
  112. */
  113. void UnixRemoveMoreInfoButton(HWND hwnd, DWORD dwDlgId)
  114. {
  115. switch(dwDlgId)
  116. {
  117. case IDD_HTTP_TO_HTTPS_ZONE_CROSSING:
  118. /* In these the More Info button is ID_TELL_ME_ABOUT_SECURITY */
  119. hRemoveAndAdjust(hwnd,
  120. MOVE_CENTER,
  121. 2,
  122. ID_TELL_ME_ABOUT_SECURITY,
  123. IDOK);
  124. break;
  125. case IDD_HTTPS_TO_HTTP_ZONE_CROSSING:
  126. hRemoveAndAdjust(hwnd,
  127. 0,
  128. 3,
  129. ID_TELL_ME_ABOUT_SECURITY,
  130. IDCANCEL,
  131. IDOK);
  132. break;
  133. #ifdef NOT_YET_IMPLEMENTED
  134. case IDD_MIXED_SECURITY:
  135. break;
  136. case IDD_INVALID_CA:
  137. break;
  138. case IDD_BAD_CN:
  139. break;
  140. case IDD_CONFIRM_COOKIE:
  141. /* In this the More Info button is IDC_COOKIE_DETAILS */
  142. break;
  143. #endif /* NOT_YET_IMPLEMENTED */
  144. }
  145. }
  146. void hRemoveAndAdjust(HWND hwnd,
  147. DWORD dwFlags,
  148. short cButtons,
  149. ...)
  150. {
  151. va_list Arguments;
  152. DWORD dwMoreInfoButtonId, dwButtonId;
  153. HWND hMoreInfoButton, hDefButton;
  154. RECT rectCur, rectPrev;
  155. hDefButton = MwRemoveDefPushButtonStyle(hwnd);
  156. /* Expect the first button to be the More Info Button
  157. * Hide the More Info Button, and move the other buttons to
  158. * the appropriate positions
  159. */
  160. if (cButtons < 2)
  161. goto Cleanup;
  162. /* We should use MOVE_CENTER only if there are two buttons in the move
  163. * list, and we hide the more info button, and move the other one to
  164. * the center
  165. */
  166. if ((dwFlags & MOVE_CENTER) && cButtons != 2)
  167. goto Cleanup;
  168. va_start(Arguments, cButtons);
  169. dwMoreInfoButtonId = (DWORD)va_arg(Arguments, ULONG);
  170. hMoreInfoButton = GetDlgItem(hwnd, dwMoreInfoButtonId);
  171. if (!hMoreInfoButton)
  172. goto Cleanup;
  173. GetWindowRect(hMoreInfoButton, &rectPrev);
  174. ScreenToClient(hwnd, (LPPOINT)&rectPrev);
  175. if (dwFlags & MOVE_CENTER)
  176. {
  177. HWND hCurButton;
  178. dwButtonId = (DWORD)va_arg(Arguments,ULONG);
  179. if ((hCurButton = GetDlgItem(hwnd, dwButtonId)))
  180. {
  181. RECT rectDlg;
  182. GetWindowRect(hCurButton, &rectCur);
  183. ScreenToClient(hwnd, (LPPOINT)&rectCur);
  184. GetWindowRect(hwnd, &rectDlg);
  185. ScreenToClient(hwnd, (LPPOINT)&rectDlg);
  186. SetWindowPos(hCurButton,
  187. NULL,
  188. ((rectDlg.right - rectDlg.left)/2)-((rectCur.right-rectCur.left)/2),
  189. rectCur.top,
  190. 0,
  191. 0,
  192. SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
  193. }
  194. }
  195. else
  196. {
  197. HWND hCurButton;
  198. for (short i = 1; i < cButtons; i++)
  199. {
  200. dwButtonId = (DWORD)va_arg(Arguments,ULONG);
  201. if ((hCurButton = GetDlgItem(hwnd, dwButtonId)))
  202. {
  203. GetWindowRect(hCurButton, &rectCur);
  204. ScreenToClient(hwnd, (LPPOINT)&rectCur);
  205. SetWindowPos(hCurButton,
  206. NULL,
  207. rectPrev.left,
  208. rectPrev.top,
  209. 0,
  210. 0,
  211. SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
  212. memcpy(&rectPrev, &rectCur, sizeof(RECT));
  213. }
  214. }
  215. }
  216. /* Hide the More Info Button */
  217. ShowWindow(hMoreInfoButton, SW_HIDE);
  218. Cleanup:
  219. if (hDefButton)
  220. MwRestoreDefPushButtonStyle(hDefButton);
  221. return;
  222. }