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.

233 lines
6.2 KiB

  1. //==========================================================================;
  2. //
  3. // vidrect.h : automation compliant auto-scaling gdi rect object
  4. // Copyright (c) Microsoft Corporation 2000.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. #pragma once
  8. #ifndef VIDRECT_H
  9. #define VIDRECT_H
  10. #include <scalingrect.h>
  11. #include <segment.h>
  12. #include <dsextend.h>
  13. #include <objectwithsiteimplsec.h>
  14. #define INVALID_HWND_VALUE (reinterpret_cast<HWND>(INVALID_HANDLE_VALUE))
  15. namespace MSVideoControl {
  16. typedef CComQIPtr<IMSVidRect, &__uuidof(IMSVidRect)> PQVidRect;
  17. class ATL_NO_VTABLE __declspec(uuid("CB4276E6-7D5F-4cf1-9727-629C5E6DB6AE")) CVidRectBase :
  18. public CComObjectRootEx<CComSingleThreadModel>,
  19. public CComCoClass<CVidRectBase, &__uuidof(CVidRectBase)>,
  20. public CScalingRect,
  21. public IObjectWithSiteImplSec<CVidRectBase>,
  22. public IDispatchImpl<IMSVidRect, &__uuidof(IMSVidRect)>,
  23. public IObjectSafetyImpl<CVidRectBase, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
  24. public IPersistPropertyBagImpl<CVidRectBase>
  25. {
  26. BEGIN_COM_MAP(CVidRectBase)
  27. COM_INTERFACE_ENTRY(IMSVidRect)
  28. COM_INTERFACE_ENTRY(IDispatch)
  29. COM_INTERFACE_ENTRY(IObjectWithSite)
  30. COM_INTERFACE_ENTRY(IPersistPropertyBag)
  31. COM_INTERFACE_ENTRY(IPersist)
  32. END_COM_MAP()
  33. DECLARE_PROTECT_FINAL_CONSTRUCT()
  34. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  35. IDS_REG_VIDRECT_DESC,
  36. LIBID_MSVidCtlLib,
  37. __uuidof(CVidRectBase));
  38. BEGIN_CATEGORY_MAP(CMSVidBDATuner)
  39. IMPLEMENTED_CATEGORY(CATID_PersistsToPropertyBag)
  40. END_CATEGORY_MAP()
  41. bool m_bRequiresSave;
  42. BEGIN_PROP_MAP(CVidRectBase)
  43. PROP_DATA_ENTRY("Top", top, VT_I4)
  44. PROP_DATA_ENTRY("Left", left, VT_I4)
  45. PROP_DATA_ENTRY("Right", right, VT_I4)
  46. PROP_DATA_ENTRY("Bottom", bottom, VT_I4)
  47. END_PROPERTY_MAP()
  48. CVidRectBase(const CRect& ri, HWND hwndi = INVALID_HWND_VALUE) {
  49. CScalingRect::CScalingRect(ri, hwndi);
  50. }
  51. CVidRectBase(const CScalingRect& ri, HWND hwndi = INVALID_HWND_VALUE) {
  52. CScalingRect::CScalingRect(ri, hwndi);
  53. }
  54. CVidRectBase(LONG l, LONG t, LONG r, LONG b, HWND hwndi = INVALID_HWND_VALUE) {
  55. CScalingRect::CScalingRect(l, t, r, b, hwndi);
  56. }
  57. CVidRectBase(const RECT& srcRect, HWND hwndi = INVALID_HWND_VALUE) {
  58. CScalingRect::CScalingRect(srcRect, hwndi);
  59. }
  60. CVidRectBase(LPCRECT lpSrcRect, HWND hwndi = INVALID_HWND_VALUE) {
  61. CScalingRect::CScalingRect(lpSrcRect, hwndi);
  62. }
  63. CVidRectBase(POINT point, SIZE size, HWND hwndi = INVALID_HWND_VALUE) {
  64. CScalingRect::CScalingRect(point, size, hwndi);
  65. }
  66. CVidRectBase(POINT topLeft, POINT bottomRight, HWND hwndi = INVALID_HWND_VALUE) {
  67. CScalingRect::CScalingRect(topLeft, bottomRight, hwndi);
  68. }
  69. CVidRectBase(const CVidRectBase& vri) {
  70. CScalingRect::CScalingRect(vri);
  71. }
  72. CVidRectBase& operator=(const CVidRectBase& srcRect) {
  73. if (&srcRect != this) {
  74. CScalingRect::operator=(srcRect);
  75. }
  76. return *this;
  77. }
  78. CVidRectBase(){}
  79. virtual ~CVidRectBase() {}
  80. STDMETHOD(get_Top)(/*[out, retval]*/ LONG* plTopVal) {
  81. try {
  82. if (!plTopVal) {
  83. return E_POINTER;
  84. }
  85. *plTopVal = top;
  86. return NOERROR;
  87. } catch(...) {
  88. return E_POINTER;
  89. }
  90. }
  91. STDMETHOD(put_Top)(/*[in]*/ LONG TopVal) {
  92. top = TopVal;
  93. m_bRequiresSave = true;
  94. return NOERROR;
  95. }
  96. STDMETHOD(get_Left)(/*[out, retval]*/ LONG* plLeftVal) {
  97. try {
  98. if (!plLeftVal) {
  99. return E_POINTER;
  100. }
  101. *plLeftVal = left;
  102. return NOERROR;
  103. } catch(...) {
  104. return E_POINTER;
  105. }
  106. }
  107. STDMETHOD(put_Left)(/*[in]*/ LONG LeftVal) {
  108. left = LeftVal;
  109. m_bRequiresSave = true;
  110. return NOERROR;
  111. }
  112. STDMETHOD(get_Width)(/*[out, retval]*/ LONG* plWidthVal) {
  113. try {
  114. if (!plWidthVal) {
  115. return E_POINTER;
  116. }
  117. *plWidthVal = Width();
  118. return NOERROR;
  119. } catch(...) {
  120. return E_POINTER;
  121. }
  122. }
  123. STDMETHOD(put_Width)(/*[in]*/ LONG WidthVal) {
  124. right = left + WidthVal;
  125. m_bRequiresSave = true;
  126. return NOERROR;
  127. }
  128. STDMETHOD(get_Height)(/*[out, retval]*/ LONG* plHeightVal) {
  129. try {
  130. if (!plHeightVal) {
  131. return E_POINTER;
  132. }
  133. *plHeightVal = Height();
  134. return NOERROR;
  135. } catch(...) {
  136. return E_POINTER;
  137. }
  138. }
  139. STDMETHOD(put_Height)(/*[in]*/ LONG HeightVal) {
  140. bottom = top + HeightVal;
  141. m_bRequiresSave = true;
  142. return NOERROR;
  143. }
  144. STDMETHOD(get_HWnd)(/*[out, retval]*/ HWND* plHWndVal) {
  145. try {
  146. if (!plHWndVal) {
  147. return E_POINTER;
  148. }
  149. *plHWndVal = Owner();
  150. return NOERROR;
  151. } catch(...) {
  152. return E_POINTER;
  153. }
  154. }
  155. STDMETHOD(put_HWnd)(/*[in]*/ HWND HWndVal) {
  156. try {
  157. Owner(HWndVal);
  158. return NOERROR;
  159. } catch(...) {
  160. return E_UNEXPECTED;
  161. }
  162. }
  163. STDMETHOD(put_Rect)(/*[in]*/ IMSVidRect* pVidRect) {
  164. try {
  165. if (!pVidRect) {
  166. return E_POINTER;
  167. }
  168. *this = *(static_cast<CVidRectBase*>(pVidRect));
  169. return NOERROR;
  170. } catch(...) {
  171. return E_POINTER;
  172. }
  173. }
  174. };
  175. /////////////////////////////////////////////////////////////////////////////
  176. // CVidRect
  177. class CVidRect : public CComObject<CVidRectBase>
  178. {
  179. public:
  180. // undone add ctors and op= for all permutations of RECTL, POINTL, SIZEL
  181. CVidRect(const CRect& ri, HWND hwndi = INVALID_HWND_VALUE) {
  182. CVidRectBase::CVidRectBase(ri, hwndi);
  183. }
  184. CVidRect(LONG l, LONG t, LONG r, LONG b, HWND hwndi = INVALID_HWND_VALUE) {
  185. CVidRectBase::CVidRectBase(l, t, r, b, hwndi);
  186. }
  187. CVidRect(const RECT& srcRect, HWND hwndi = INVALID_HWND_VALUE) {
  188. CVidRectBase::CVidRectBase(srcRect, hwndi);
  189. }
  190. CVidRect(LPCRECT lpSrcRect, HWND hwndi = INVALID_HWND_VALUE) {
  191. CVidRectBase::CVidRectBase(lpSrcRect, hwndi);
  192. }
  193. CVidRect(POINT point, SIZE size, HWND hwndi = INVALID_HWND_VALUE) {
  194. CVidRectBase::CVidRectBase(point, size, hwndi);
  195. }
  196. CVidRect(POINT topLeft, POINT bottomRight, HWND hwndi = INVALID_HWND_VALUE) {
  197. CVidRectBase::CVidRectBase(topLeft, bottomRight, hwndi);
  198. }
  199. CVidRect(const CVidRect& vri) {
  200. CVidRectBase::CVidRectBase(vri);
  201. }
  202. CVidRect& operator=(const CVidRect& srcRect) {
  203. if (&srcRect != this) {
  204. CVidRectBase::operator=(srcRect);
  205. }
  206. return *this;
  207. }
  208. virtual ~CVidRect() {}
  209. // IPersistPropertyBag
  210. };
  211. };
  212. #endif
  213. // end of file vidrect.h