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.

192 lines
7.7 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: MSMFText.h */
  4. /* Description: Header file for CMSMFText control object */
  5. /* Author: phillu */
  6. /* Date: 10/06/99 */
  7. /*************************************************************************/
  8. #ifndef __MSMFTEXT_H_
  9. #define __MSMFTEXT_H_
  10. #include "MSMFCntCP.h"
  11. #include "resource.h" // main symbols
  12. #include "ctext.h"
  13. #include <atlctl.h>
  14. #include "CstUtils.h"
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMSMFText
  17. class ATL_NO_VTABLE CMSMFText :
  18. public CComObjectRootEx<CComSingleThreadModel>,
  19. public CStockPropImpl<CMSMFText, IMSMFText, &IID_IMSMFText, &LIBID_MSMFCNTLib>,
  20. public CComControl<CMSMFText>,
  21. public IPersistStreamInitImpl<CMSMFText>,
  22. public IOleControlImpl<CMSMFText>,
  23. public IOleObjectImpl<CMSMFText>,
  24. public IOleInPlaceActiveObjectImpl<CMSMFText>,
  25. public IViewObjectExImpl<CMSMFText>,
  26. public IOleInPlaceObjectWindowlessImpl<CMSMFText>,
  27. public IConnectionPointContainerImpl<CMSMFText>,
  28. public IPersistStorageImpl<CMSMFText>,
  29. public ISpecifyPropertyPagesImpl<CMSMFText>,
  30. public IQuickActivateImpl<CMSMFText>,
  31. public IDataObjectImpl<CMSMFText>,
  32. public IProvideClassInfo2Impl<&CLSID_MSMFText, &DIID__IMSMFText, &LIBID_MSMFCNTLib>,
  33. public CComCoClass<CMSMFText, &CLSID_MSMFText>,
  34. public IPersistPropertyBagImpl<CMSMFText>,
  35. public CProxy_IMSMFText<CMSMFText>,
  36. public CMSMFCntrlUtils<CMSMFText> // custom utilities we share across controls
  37. {
  38. public:
  39. CMSMFText();
  40. virtual ~CMSMFText(){ATLTRACE(TEXT("In the TEXT Object destructor!\n"));};
  41. DECLARE_REGISTRY_RESOURCEID(IDR_MSMFTEXT)
  42. DECLARE_PROTECT_FINAL_CONSTRUCT()
  43. BEGIN_COM_MAP(CMSMFText)
  44. COM_INTERFACE_ENTRY(IMSMFText)
  45. COM_INTERFACE_ENTRY(IDispatch)
  46. COM_INTERFACE_ENTRY(IViewObjectEx)
  47. COM_INTERFACE_ENTRY(IViewObject2)
  48. COM_INTERFACE_ENTRY(IViewObject)
  49. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  50. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  51. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  52. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  53. COM_INTERFACE_ENTRY(IOleControl)
  54. COM_INTERFACE_ENTRY(IOleObject)
  55. COM_INTERFACE_ENTRY(IPersistStreamInit)
  56. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  57. COM_INTERFACE_ENTRY_IMPL_IID(IID_IPersist, IPersistPropertyBag)
  58. COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
  59. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  60. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  61. COM_INTERFACE_ENTRY(IQuickActivate)
  62. COM_INTERFACE_ENTRY(IPersistStorage)
  63. COM_INTERFACE_ENTRY(IDataObject)
  64. COM_INTERFACE_ENTRY(IProvideClassInfo)
  65. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  66. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  67. END_COM_MAP()
  68. BEGIN_PROP_MAP(CMSMFText)
  69. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  70. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  71. PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
  72. PROP_ENTRY("TransparentText", 17, CLSID_NULL)
  73. PROP_ENTRY("Windowless", 18, CLSID_NULL)
  74. // Example entries
  75. // PROP_ENTRY("Property Description", dispid, clsid)
  76. // PROP_PAGE(CLSID_StockColorPage)
  77. END_PROP_MAP()
  78. BEGIN_CONNECTION_POINT_MAP(CMSMFText)
  79. CONNECTION_POINT_ENTRY(DIID__IMSMFText)
  80. END_CONNECTION_POINT_MAP()
  81. BEGIN_MSG_MAP(CMSMFText)
  82. MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
  83. MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
  84. MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
  85. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  86. MESSAGE_HANDLER(WM_SIZE, OnSize)
  87. CHAIN_MSG_MAP(CMSMFCntrlUtils<CMSMFText>)
  88. CHAIN_MSG_MAP(CComControl<CMSMFText>)
  89. DEFAULT_REFLECTION_HANDLER()
  90. END_MSG_MAP()
  91. // Handler prototypes:
  92. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  93. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  94. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  95. LRESULT OnButtonDown(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  96. LRESULT OnButtonUp(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  97. LRESULT OnMouseMove(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  98. LRESULT OnSetFocus(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  99. LRESULT OnSize(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  100. // IViewObjectEx
  101. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  102. USE_MF_OVERWRITES
  103. USE_MF_CLASSSTYLE // used to overwrite default class, so we avoid flickers
  104. // IMSMFText
  105. public:
  106. STDMETHOD(get_TransparentText)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  107. STDMETHOD(put_TransparentText)(/*[in]*/ VARIANT_BOOL newVal);
  108. STDMETHOD(get_TextHeight)(/*[out, retval]*/ long *pVal);
  109. STDMETHOD(get_TextWidth)(/*[out, retval]*/ long *pVal);
  110. STDMETHOD(get_EdgeStyle)(/*[out, retval]*/ BSTR *pVal);
  111. STDMETHOD(put_EdgeStyle)(/*[in]*/ BSTR newVal);
  112. STDMETHOD(get_TextAlignment)(/*[out, retval]*/ BSTR *pVal);
  113. STDMETHOD(put_TextAlignment)(/*[in]*/ BSTR newVal);
  114. USE_MF_RESOURCEDLL // replaces the two lines below
  115. STDMETHOD(get_Disable)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  116. STDMETHOD(put_Disable)(/*[in]*/ VARIANT_BOOL newVal);
  117. STDMETHOD(get_TextState)(/*[out, retval]*/ long *pVal);
  118. STDMETHOD(put_TextState)(/*[in]*/ long newVal);
  119. STDMETHOD(get_ColorActive)(/*[out, retval]*/ OLE_COLOR *pVal);
  120. STDMETHOD(put_ColorActive)(/*[in]*/ OLE_COLOR newVal);
  121. STDMETHOD(get_ColorDisable)(/*[out, retval]*/ OLE_COLOR *pVal);
  122. STDMETHOD(put_ColorDisable)(/*[in]*/ OLE_COLOR newVal);
  123. STDMETHOD(get_ColorStatic)(/*[out, retval]*/ OLE_COLOR *pVal);
  124. STDMETHOD(put_ColorStatic)(/*[in]*/ OLE_COLOR newVal);
  125. STDMETHOD(get_ColorHover)(/*[out, retval]*/ OLE_COLOR *pVal);
  126. STDMETHOD(put_ColorHover)(/*[in]*/ OLE_COLOR newVal);
  127. STDMETHOD(get_ColorPush)(/*[out, retval]*/ OLE_COLOR *pVal);
  128. STDMETHOD(put_ColorPush)(/*[in]*/ OLE_COLOR newVal);
  129. STDMETHOD(get_FontStyle)(/*[out, retval]*/ BSTR *pVal);
  130. STDMETHOD(put_FontStyle)(/*[in]*/ BSTR newVal);
  131. STDMETHOD(get_FontFace)(/*[out, retval]*/ BSTR *pVal);
  132. STDMETHOD(put_FontFace)(/*[in]*/ BSTR newVal);
  133. STDMETHOD(get_Text)(/*[out, retval]*/ BSTR *pVal);
  134. STDMETHOD(put_Text)(/*[in]*/ BSTR newVal);
  135. STDMETHOD(get_FontSize)(/*[out, retval]*/ long *pVal);
  136. STDMETHOD(put_FontSize)(/*[in]*/ long newVal);
  137. USE_MF_WINDOWLESS_ACTIVATION //Replaces the two lines below
  138. //STDMETHOD(get_Windowless)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  139. //STDMETHOD(put_Windowless)(/*[in]*/ VARIANT_BOOL newVal);
  140. HRESULT OnDraw(ATL_DRAWINFO& di);
  141. STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip);
  142. OLE_COLOR m_clrBackColor; // stock property implemeted in the CStockPropImpl
  143. enum TextState {Static = 0, Hover = 1, Push = 2, Disabled = 3, Active = 4};
  144. private:
  145. CText m_cText;
  146. bool m_fDirty; // if any attribute for the text drawing object changes
  147. //properties
  148. UINT m_uiState;
  149. CComBSTR m_bstrTextValue;
  150. CComBSTR m_bstrFontFace;
  151. CComBSTR m_bstrFontStyle;
  152. CComBSTR m_bstrAlignment;
  153. UINT m_uiFontSize;
  154. bool m_fDisabled;
  155. OLE_COLOR m_clrColorActive;
  156. OLE_COLOR m_clrColorStatic;
  157. OLE_COLOR m_clrColorHover;
  158. OLE_COLOR m_clrColorPush;
  159. OLE_COLOR m_clrColorDisable;
  160. UINT m_uiEdgeStyle;
  161. bool m_fTransparent;
  162. HRESULT SetTextProperties();
  163. bool PtOnButton(LONG x, LONG y);
  164. bool PtOnButton(POINT pos);
  165. HRESULT SetButtonState(TextState txtState);
  166. };
  167. #endif //__MSMFTEXT_H_
  168. /*************************************************************************/
  169. /* End of file: MSMFText.cpp */
  170. /*************************************************************************/