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.

164 lines
4.2 KiB

  1. /*************************************************
  2. * uisubs.c *
  3. * *
  4. * Copyright (C) 1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #include <windows.h>
  8. #include <immdev.h>
  9. #include "imeattr.h"
  10. #include "imedefs.h"
  11. #include "imerc.h"
  12. /**********************************************************************/
  13. /* DrawDragBorder() */
  14. /**********************************************************************/
  15. void PASCAL DrawDragBorder(
  16. HWND hWnd, // window of IME is dragged
  17. LONG lCursorPos, // the cursor position
  18. LONG lCursorOffset) // the offset form cursor to window org
  19. {
  20. HDC hDC;
  21. int cxBorder, cyBorder;
  22. int x, y;
  23. RECT rcWnd;
  24. cxBorder = GetSystemMetrics(SM_CXBORDER); // width of border
  25. cyBorder = GetSystemMetrics(SM_CYBORDER); // height of border
  26. // get cursor position
  27. x = (*(LPPOINTS)&lCursorPos).x;
  28. y = (*(LPPOINTS)&lCursorPos).y;
  29. // calculate the org by the offset
  30. x -= (*(LPPOINTS)&lCursorOffset).x;
  31. y -= (*(LPPOINTS)&lCursorOffset).y;
  32. // check for the min boundary of the display
  33. if (x < sImeG.rcWorkArea.left) {
  34. x = sImeG.rcWorkArea.left;
  35. }
  36. if (y < sImeG.rcWorkArea.top) {
  37. y = sImeG.rcWorkArea.top;
  38. }
  39. // check for the max boundary of the display
  40. GetWindowRect(hWnd, &rcWnd);
  41. if (x + rcWnd.right - rcWnd.left > sImeG.rcWorkArea.right) {
  42. x = sImeG.rcWorkArea.right - (rcWnd.right - rcWnd.left);
  43. }
  44. if (y + rcWnd.bottom - rcWnd.top > sImeG.rcWorkArea.bottom) {
  45. y = sImeG.rcWorkArea.bottom - (rcWnd.bottom - rcWnd.top);
  46. }
  47. // draw the moving track
  48. hDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
  49. SelectObject(hDC, GetStockObject(GRAY_BRUSH));
  50. // ->
  51. PatBlt(hDC, x, y, rcWnd.right - rcWnd.left - cxBorder, cyBorder,
  52. PATINVERT);
  53. // v
  54. PatBlt(hDC, x, y + cyBorder, cxBorder, rcWnd.bottom - rcWnd.top -
  55. cyBorder, PATINVERT);
  56. // _>
  57. PatBlt(hDC, x + cxBorder, y + rcWnd.bottom - rcWnd.top,
  58. rcWnd.right - rcWnd.left - cxBorder, -cyBorder, PATINVERT);
  59. // v
  60. PatBlt(hDC, x + rcWnd.right - rcWnd.left, y,
  61. - cxBorder, rcWnd.bottom - rcWnd.top - cyBorder, PATINVERT);
  62. DeleteDC(hDC);
  63. return;
  64. }
  65. /**********************************************************************/
  66. /* DrawFrameBorder() */
  67. /**********************************************************************/
  68. void PASCAL DrawFrameBorder( // border of IME
  69. HDC hDC,
  70. HWND hWnd) // window of IME
  71. {
  72. RECT rcWnd;
  73. int xWi, yHi;
  74. GetWindowRect(hWnd, &rcWnd);
  75. xWi = rcWnd.right - rcWnd.left;
  76. yHi = rcWnd.bottom - rcWnd.top;
  77. // 1, ->
  78. PatBlt(hDC, 0, 0, xWi, 1, WHITENESS);
  79. // 1, v
  80. PatBlt(hDC, 0, 0, 1, yHi, WHITENESS);
  81. // 1, _>
  82. PatBlt(hDC, 0, yHi, xWi, -1, BLACKNESS);
  83. // 1, v
  84. PatBlt(hDC, xWi, 0, -1, yHi, BLACKNESS);
  85. xWi -= 2;
  86. yHi -= 2;
  87. SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
  88. // 2, ->
  89. PatBlt(hDC, 1, 1, xWi, 1, PATCOPY);
  90. // 2, v
  91. PatBlt(hDC, 1, 1, 1, yHi, PATCOPY);
  92. // 2, v
  93. PatBlt(hDC, xWi + 1, 1, -1, yHi, PATCOPY);
  94. SelectObject(hDC, GetStockObject(GRAY_BRUSH));
  95. // 2, _>
  96. PatBlt(hDC, 1, yHi + 1, xWi, -1, PATCOPY);
  97. xWi -= 2;
  98. yHi -= 2;
  99. // 3, ->
  100. PatBlt(hDC, 2, 2, xWi, 1, PATCOPY);
  101. // 3, v
  102. PatBlt(hDC, 2, 2, 1, yHi, PATCOPY);
  103. // 3, v
  104. PatBlt(hDC, xWi + 2, 3, -1, yHi - 1, WHITENESS);
  105. SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
  106. // 3, _>
  107. PatBlt(hDC, 2, yHi + 2, xWi, -1, PATCOPY);
  108. SelectObject(hDC, GetStockObject(GRAY_BRUSH));
  109. xWi -= 2;
  110. yHi -= 2;
  111. // 4, ->
  112. PatBlt(hDC, 3, 3, xWi, 1, PATCOPY);
  113. // 4, v
  114. PatBlt(hDC, 3, 3, 1, yHi, PATCOPY);
  115. SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
  116. // 4, v
  117. PatBlt(hDC, xWi + 3, 4, -1, yHi - 1, PATCOPY);
  118. // 4, _>
  119. PatBlt(hDC, 3, yHi + 3, xWi, -1, WHITENESS);
  120. return;
  121. }