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.

197 lines
5.8 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Behav_HANDLE.cpp
  5. Abstract:
  6. This file contains the implementation of the CPCHBehavior_HANDLE class,
  7. used for resizing panels.
  8. Revision History:
  9. Davide Massarenti (dmassare) 07/14/2000
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. ////////////////////////////////////////////////////////////////////////////////
  14. static const CPCHBehavior::EventDescription s_events[] =
  15. {
  16. { L"onselectstart", DISPID_HTMLELEMENTEVENTS_ONSELECTSTART },
  17. { L"onmousedown" , DISPID_HTMLELEMENTEVENTS_ONMOUSEDOWN },
  18. { L"onmousemove" , DISPID_HTMLELEMENTEVENTS_ONMOUSEMOVE },
  19. { L"onmouseup" , DISPID_HTMLELEMENTEVENTS_ONMOUSEUP },
  20. { NULL },
  21. };
  22. ////////////////////////////////////////////////////////////////////////////////
  23. CPCHBehavior_HANDLE::CPCHBehavior_HANDLE()
  24. {
  25. __HCP_FUNC_ENTRY( "CPCHBehavior_HANDLE::CPCHBehavior_HANDLE" );
  26. m_fCaptured = false; // bool m_fCaptured;
  27. m_xStart = 0; // long m_xStart;
  28. //
  29. // CComPtr<IMarsPanel> m_panel;
  30. }
  31. /////////////////////////////////////////////////////////////////////////////
  32. STDMETHODIMP CPCHBehavior_HANDLE::Init( /*[in]*/ IElementBehaviorSite* pBehaviorSite )
  33. {
  34. __HCP_FUNC_ENTRY( "CPCHBehavior_HANDLE::Init" );
  35. HRESULT hr;
  36. CComPtr<IDispatch> pDisp;
  37. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHBehavior::Init( pBehaviorSite ));
  38. __MPC_EXIT_IF_METHOD_FAILS(hr, AttachToEvents( s_events, (CLASS_METHOD)onMouse ));
  39. hr = S_OK;
  40. __HCP_FUNC_CLEANUP;
  41. __HCP_FUNC_EXIT(hr);
  42. }
  43. STDMETHODIMP CPCHBehavior_HANDLE::Detach()
  44. {
  45. return CPCHBehavior::Detach();
  46. }
  47. ////////////////////////////////////////////////////////////////////////////////
  48. HRESULT CPCHBehavior_HANDLE::onMouse( DISPID id, DISPPARAMS*, VARIANT* )
  49. {
  50. __HCP_FUNC_ENTRY( "CPCHBehavior_HANDLE::onMouse" );
  51. HRESULT hr;
  52. CComPtr<IHTMLEventObj> ev;
  53. __MPC_EXIT_IF_METHOD_FAILS(hr, GetEventObject( ev ));
  54. switch(id)
  55. {
  56. case DISPID_HTMLELEMENTEVENTS_ONSELECTSTART:
  57. __MPC_EXIT_IF_METHOD_FAILS(hr, CancelEvent( ev ));
  58. break;
  59. case DISPID_HTMLELEMENTEVENTS_ONMOUSEMOVE:
  60. if(m_fCaptured)
  61. {
  62. long x;
  63. MPC_SCRIPTHELPER_GET__DIRECT(x, ev, screenX);
  64. if(x != m_xStart)
  65. {
  66. CComPtr<IMarsPanel> pPanel;
  67. RECT rc;
  68. long widthMax;
  69. long widthPre;
  70. long widthPost;
  71. __MPC_EXIT_IF_METHOD_FAILS(hr, m_parent->GetPanel( HSCPANEL_CONTEXT, &pPanel, true ));
  72. ::GetClientRect( m_parent->Window(), &rc ); widthMax = (rc.right - rc.left);
  73. MPC_SCRIPTHELPER_GET__DIRECT(widthPre, pPanel, width);
  74. widthPost = widthPre + (x - m_xStart) * (m_fRTL ? -1 : 1);
  75. if(widthPost < 14) widthPost = 14;
  76. if(widthPost >= widthMax - 14) widthPost = widthMax - 14;
  77. if(widthPre != widthPost)
  78. {
  79. VARIANT_BOOL fOk;
  80. if(SUCCEEDED(pPanel->canResize( (widthPost - widthPre), 0, &fOk )) && fOk == VARIANT_TRUE)
  81. {
  82. MPC_SCRIPTHELPER_PUT__DIRECT(pPanel, width, widthPost);
  83. MPC_SCRIPTHELPER_GET__DIRECT(widthPost, pPanel, width);
  84. }
  85. else
  86. {
  87. widthPost = widthPre;
  88. }
  89. }
  90. m_xStart += (widthPost - widthPre) * (m_fRTL ? -1 : 1);
  91. }
  92. }
  93. break;
  94. case DISPID_HTMLELEMENTEVENTS_ONMOUSEDOWN:
  95. __MPC_EXIT_IF_METHOD_FAILS(hr, CancelEvent( ev ));
  96. __MPC_EXIT_IF_METHOD_FAILS(hr, m_elem2->setCapture( VARIANT_TRUE ));
  97. //// {
  98. //// CComPtr<IHTMLWindow2> win;
  99. //// CComPtr<IHTMLDocument2> doc;
  100. //// CComPtr<IHTMLElement> body;
  101. //// CComPtr<IHTMLStyle> style;
  102. ////
  103. //// __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::HTML::LocateFrame( win, m_elem, L"SubPanels" ));
  104. //// __MPC_EXIT_IF_METHOD_FAILS(hr, win->get_document( &doc ));
  105. //// __MPC_EXIT_IF_METHOD_FAILS(hr, doc->get_body ( &body ));
  106. //// __MPC_EXIT_IF_METHOD_FAILS(hr, body->get_style ( &style ));
  107. ////
  108. //// __MPC_EXIT_IF_METHOD_FAILS(hr, style->put_display( CComBSTR( L"NONE" ) ));
  109. //// }
  110. m_fCaptured = true;
  111. MPC_SCRIPTHELPER_GET__DIRECT(m_xStart, ev, screenX);
  112. break;
  113. case DISPID_HTMLELEMENTEVENTS_ONMOUSEUP:
  114. __MPC_EXIT_IF_METHOD_FAILS(hr, CancelEvent( ev ));
  115. if(m_fCaptured)
  116. {
  117. __MPC_EXIT_IF_METHOD_FAILS(hr, m_elem2->releaseCapture());
  118. //// {
  119. //// CComPtr<IHTMLWindow2> win;
  120. //// CComPtr<IHTMLDocument2> doc;
  121. //// CComPtr<IHTMLElement> body;
  122. //// CComPtr<IHTMLStyle> style;
  123. ////
  124. //// __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::HTML::LocateFrame( win, m_elem, L"SubPanels" ));
  125. //// __MPC_EXIT_IF_METHOD_FAILS(hr, win->get_document( &doc ));
  126. //// __MPC_EXIT_IF_METHOD_FAILS(hr, doc->get_body ( &body ));
  127. //// __MPC_EXIT_IF_METHOD_FAILS(hr, body->get_style ( &style ));
  128. ////
  129. //// __MPC_EXIT_IF_METHOD_FAILS(hr, style->put_display( CComBSTR( L"" ) ));
  130. //// }
  131. m_fCaptured = false;
  132. }
  133. break;
  134. }
  135. hr = S_OK;
  136. __HCP_FUNC_CLEANUP;
  137. __HCP_FUNC_EXIT(hr);
  138. }