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.

268 lines
7.0 KiB

  1. #include "stdafx.h"
  2. #include "Lava.h"
  3. #include "DxContainer.h"
  4. #include "MsgHelp.h"
  5. /***************************************************************************\
  6. *****************************************************************************
  7. *
  8. * API Implementation
  9. *
  10. *****************************************************************************
  11. \***************************************************************************/
  12. //------------------------------------------------------------------------------
  13. DxContainer *
  14. GetDxContainer(DuVisual * pgad)
  15. {
  16. DuContainer * pcon = pgad->GetContainer();
  17. AssertReadPtr(pcon);
  18. DxContainer * pconDX = CastDxContainer(pcon);
  19. return pconDX;
  20. }
  21. //------------------------------------------------------------------------------
  22. HRESULT
  23. GdCreateDxRootGadget(
  24. IN const RECT * prcContainerPxl,
  25. IN CREATE_INFO * pci, // Creation information
  26. OUT DuRootGadget ** ppgadNew)
  27. {
  28. HRESULT hr;
  29. DxContainer * pconNew;
  30. hr = DxContainer::Build(prcContainerPxl, &pconNew);
  31. if (FAILED(hr)) {
  32. return hr;
  33. }
  34. hr = DuRootGadget::Build(pconNew, TRUE, pci, ppgadNew);
  35. if (FAILED(hr)) {
  36. pconNew->xwUnlock();
  37. return hr;
  38. }
  39. //
  40. // Don't setup an initial brush when using DirectX
  41. //
  42. return S_OK;
  43. }
  44. /***************************************************************************\
  45. *****************************************************************************
  46. *
  47. * class DxContainer
  48. *
  49. *****************************************************************************
  50. \***************************************************************************/
  51. //------------------------------------------------------------------------------
  52. DxContainer::DxContainer()
  53. {
  54. }
  55. //------------------------------------------------------------------------------
  56. DxContainer::~DxContainer()
  57. {
  58. //
  59. // Need to destroy the gadget tree before this class is destructed since
  60. // it may need to make calls to the container during its destruction. If
  61. // we don't do this here, it may end up calling pure-virtual's on the base
  62. // class.
  63. //
  64. xwDestroyGadget();
  65. }
  66. //------------------------------------------------------------------------------
  67. HRESULT
  68. DxContainer::Build(const RECT * prcContainerPxl, DxContainer ** ppconNew)
  69. {
  70. AssertReadPtr(prcContainerPxl);
  71. DxContainer * pconNew = ClientNew(DxContainer);
  72. if (pconNew == NULL) {
  73. return E_OUTOFMEMORY;
  74. }
  75. pconNew->m_rcContainerPxl = *prcContainerPxl;
  76. pconNew->m_rcClientPxl.left = 0;
  77. pconNew->m_rcClientPxl.top = 0;
  78. pconNew->m_rcClientPxl.right = pconNew->m_rcContainerPxl.right - pconNew->m_rcContainerPxl.left;
  79. pconNew->m_rcClientPxl.bottom = pconNew->m_rcContainerPxl.bottom - pconNew->m_rcContainerPxl.top;
  80. *ppconNew = pconNew;
  81. return S_OK;
  82. }
  83. //------------------------------------------------------------------------------
  84. void
  85. DxContainer::OnGetRect(RECT * prcDesktopPxl)
  86. {
  87. AssertWritePtr(prcDesktopPxl);
  88. *prcDesktopPxl = m_rcContainerPxl;
  89. }
  90. //------------------------------------------------------------------------------
  91. void
  92. DxContainer::OnInvalidate(const RECT * prcInvalidContainerPxl)
  93. {
  94. UNREFERENCED_PARAMETER(prcInvalidContainerPxl);
  95. }
  96. //------------------------------------------------------------------------------
  97. void
  98. DxContainer::OnStartCapture()
  99. {
  100. }
  101. //------------------------------------------------------------------------------
  102. void
  103. DxContainer::OnEndCapture()
  104. {
  105. }
  106. //------------------------------------------------------------------------------
  107. BOOL
  108. DxContainer::OnTrackMouseLeave()
  109. {
  110. return FALSE;
  111. }
  112. //------------------------------------------------------------------------------
  113. void
  114. DxContainer::OnSetFocus()
  115. {
  116. }
  117. //------------------------------------------------------------------------------
  118. void
  119. DxContainer::OnRescanMouse(POINT * pptContainerPxl)
  120. {
  121. pptContainerPxl->x = -20000;
  122. pptContainerPxl->y = -20000;
  123. }
  124. //------------------------------------------------------------------------------
  125. BOOL
  126. DxContainer::xdHandleMessage(UINT nMsg, WPARAM wParam, LPARAM lParam, LRESULT * pr, UINT nMsgFlags)
  127. {
  128. if (m_pgadRoot == NULL) {
  129. return FALSE; // If don't have a root, there is nothing to handle.
  130. }
  131. //
  132. // NOTE: All messages that come into the DxContainer are coming through the
  133. // ForwardGadgetMessage() API which has already taken a Context lock.
  134. // Therefore, we don't need to take the Context lock in this function again.
  135. // Other Containers do NOT necessarily have this behavior.
  136. //
  137. POINT ptContainerPxl;
  138. *pr = 0;
  139. switch (nMsg)
  140. {
  141. case WM_LBUTTONDOWN:
  142. case WM_RBUTTONDOWN:
  143. case WM_MBUTTONDOWN:
  144. case WM_LBUTTONDBLCLK:
  145. case WM_RBUTTONDBLCLK:
  146. case WM_MBUTTONDBLCLK:
  147. case WM_LBUTTONUP:
  148. case WM_RBUTTONUP:
  149. case WM_MBUTTONUP:
  150. {
  151. GMSG_MOUSECLICK msg;
  152. GdConvertMouseClickMessage(&msg, nMsg, wParam);
  153. ptContainerPxl.x = GET_X_LPARAM(lParam);
  154. ptContainerPxl.y = GET_Y_LPARAM(lParam);
  155. ContextLock cl;
  156. if (cl.LockNL(ContextLock::edDefer)) {
  157. return m_pgadRoot->xdHandleMouseMessage(&msg, ptContainerPxl);
  158. }
  159. break;
  160. }
  161. case WM_MOUSEWHEEL:
  162. {
  163. ptContainerPxl.x = GET_X_LPARAM(lParam);
  164. ptContainerPxl.y = GET_Y_LPARAM(lParam);
  165. GMSG_MOUSEWHEEL msg;
  166. GdConvertMouseWheelMessage(&msg, wParam);
  167. ContextLock cl;
  168. if (cl.LockNL(ContextLock::edDefer)) {
  169. return m_pgadRoot->xdHandleMouseMessage(&msg, ptContainerPxl);
  170. }
  171. break;
  172. }
  173. case WM_MOUSEMOVE:
  174. case WM_MOUSEHOVER:
  175. {
  176. GMSG_MOUSE msg;
  177. GdConvertMouseMessage(&msg, nMsg, wParam);
  178. ptContainerPxl.x = GET_X_LPARAM(lParam);
  179. ptContainerPxl.y = GET_Y_LPARAM(lParam);
  180. ContextLock cl;
  181. if (cl.LockNL(ContextLock::edDefer)) {
  182. return m_pgadRoot->xdHandleMouseMessage(&msg, ptContainerPxl);
  183. }
  184. break;
  185. }
  186. case WM_MOUSELEAVE:
  187. {
  188. ContextLock cl;
  189. if (cl.LockNL(ContextLock::edDefer)) {
  190. m_pgadRoot->xdHandleMouseLeaveMessage();
  191. return TRUE;
  192. }
  193. break;
  194. }
  195. case WM_CHAR:
  196. case WM_KEYDOWN:
  197. case WM_KEYUP:
  198. case WM_SYSCHAR:
  199. case WM_SYSKEYDOWN:
  200. case WM_SYSKEYUP:
  201. {
  202. GMSG_KEYBOARD msg;
  203. GdConvertKeyboardMessage(&msg, nMsg, wParam, lParam);
  204. BOOL fResult = m_pgadRoot->xdHandleKeyboardMessage(&msg, nMsgFlags);
  205. return fResult;
  206. }
  207. }
  208. return FALSE;
  209. }