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.

238 lines
7.2 KiB

  1. /******************************************************************************
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Toolbar.cpp
  5. Abstract:
  6. This file contains the declaration of the ActiveX control that makes Win32 ToolBars available to HTML.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 03/04/2001
  9. created
  10. ******************************************************************************/
  11. #if !defined(__INCLUDED___PCH___HTMLTOOLBAR_H___)
  12. #define __INCLUDED___PCH___HTMLTOOLBAR_H___
  13. #include <HelpCenter.h>
  14. MIDL_INTERFACE("FC7D9EA1-3F9E-11d3-93C0-00C04F72DAF7")
  15. IPCHToolBarPrivate : public IUnknown
  16. {
  17. public:
  18. STDMETHOD(SameObject)( /*[in]*/ IPCHToolBar* ptr );
  19. };
  20. class ATL_NO_VTABLE CPCHToolBar :
  21. public MPC::ConnectionPointImpl < CPCHToolBar, &DIID_DPCHToolBarEvents, CComSingleThreadModel >,
  22. public IProvideClassInfo2Impl <&CLSID_PCHToolBar, &DIID_DPCHToolBarEvents, &LIBID_HelpCenterTypeLib>,
  23. public IDispatchImpl < IPCHToolBar, & IID_IPCHToolBar , &LIBID_HelpCenterTypeLib>,
  24. public CComControl <CPCHToolBar>,
  25. public IPersistPropertyBagImpl <CPCHToolBar>,
  26. public IOleControlImpl <CPCHToolBar>,
  27. public IOleObjectImpl <CPCHToolBar>,
  28. public IOleInPlaceActiveObjectImpl <CPCHToolBar>,
  29. public IViewObjectExImpl <CPCHToolBar>,
  30. public IOleInPlaceObjectWindowlessImpl<CPCHToolBar>,
  31. public CComCoClass <CPCHToolBar, &CLSID_PCHToolBar>,
  32. public IPCHToolBarPrivate
  33. {
  34. typedef enum
  35. {
  36. TYPE_invalid ,
  37. TYPE_back ,
  38. TYPE_forward ,
  39. TYPE_separator,
  40. TYPE_generic ,
  41. } Types;
  42. static const MPC::StringToBitField c_TypeLookup[];
  43. class Button : public MPC::Config::TypeConstructor
  44. {
  45. DECLARE_CONFIG_MAP(Button);
  46. public:
  47. MPC::wstring m_strID;
  48. WCHAR m_wch;
  49. bool m_fEnabled;
  50. bool m_fVisible;
  51. bool m_fHideText;
  52. bool m_fSystemMenu;
  53. DWORD m_dwType;
  54. MPC::wstring m_strImage_Normal;
  55. MPC::wstring m_strImage_Hot;
  56. MPC::wstring m_strText;
  57. MPC::wstring m_strToolTip;
  58. int m_idCmd;
  59. int m_iImage_Normal;
  60. int m_iImage_Hot;
  61. ////////////////////////////////////////
  62. //
  63. // MPC::Config::TypeConstructor
  64. //
  65. DEFINE_CONFIG_DEFAULTTAG();
  66. DECLARE_CONFIG_METHODS();
  67. //
  68. ////////////////////////////////////////
  69. Button();
  70. void UpdateState( /*[in]*/ HWND hwndTB );
  71. };
  72. class Config : public MPC::Config::TypeConstructor
  73. {
  74. DECLARE_CONFIG_MAP(Config);
  75. public:
  76. typedef std::list< Button > ButtonList;
  77. typedef ButtonList::iterator ButtonIter;
  78. typedef ButtonList::const_iterator ButtonIterConst;
  79. long m_lWidth;
  80. long m_lHeight;
  81. long m_lIconSize;
  82. bool m_fRTL;
  83. TB_MODE m_mode;
  84. ButtonList m_lstButtons;
  85. HIMAGELIST m_himlNormal;
  86. HIMAGELIST m_himlHot;
  87. ////////////////////////////////////////
  88. //
  89. // MPC::Config::TypeConstructor
  90. //
  91. DEFINE_CONFIG_DEFAULTTAG();
  92. DECLARE_CONFIG_METHODS();
  93. //
  94. ////////////////////////////////////////
  95. Config();
  96. Button* LookupButton( /*[in]*/ LPCWSTR szID, /*[in]*/ int idCmd );
  97. void Reset( );
  98. HRESULT Load ( /*[in]*/ LPCWSTR szBaseURL, /*[in]*/ LPCWSTR szDefinition, /*[in]*/ LPCWSTR szDir );
  99. HRESULT CreateButtons( /*[in]*/ HWND hwndTB );
  100. void UpdateSize ( /*[in]*/ HWND hwndTB, /*[in]*/ HWND hwndRB, /*[out]*/ SIZEL& ptIdeal );
  101. ////////////////////
  102. HRESULT MergeImage( /*[in]*/ LPCWSTR szBaseURL, /*[in]*/ LPCWSTR szRelativeURL, /*[in ]*/ HIMAGELIST himl, /*[out]*/ int& iImage );
  103. };
  104. ////////////////////////////////////////////////////////////////////////////////
  105. CPCHHelpCenterExternal* m_parent;
  106. HWND m_hwndRB;
  107. HWND m_hwndTB;
  108. CComBSTR m_bstrBaseURL;
  109. CComBSTR m_bstrDefinition;
  110. Config m_cfg;
  111. bool m_fLoaded;
  112. ////////////////////////////////////////
  113. //
  114. // Event firing methods.
  115. //
  116. HRESULT Fire_onCommand( /*[in]*/ Button* bt );
  117. HRESULT Fire_onCommand( /*[in]*/ UINT_PTR iCmd );
  118. ////////////////////////////////////////
  119. HRESULT OnTooltipRequest ( int idCtrl, LPNMTBGETINFOTIPW tool );
  120. HRESULT OnDispInfoRequest( int idCtrl, LPNMTBDISPINFOW info );
  121. HRESULT OnDropDown ( int idCtrl, LPNMTOOLBAR tool );
  122. HRESULT OnChevron ( int idCtrl, LPNMREBARCHEVRON chev );
  123. void UpdateSize();
  124. void Config_Clear();
  125. HRESULT Config_Load ();
  126. HRESULT Toolbar_Create();
  127. HRESULT Rebar_Create ();
  128. HRESULT Rebar_AddBand ();
  129. public:
  130. DECLARE_NO_REGISTRY()
  131. DECLARE_NOT_AGGREGATABLE(CPCHToolBar)
  132. DECLARE_PROTECT_FINAL_CONSTRUCT()
  133. BEGIN_COM_MAP(CPCHToolBar)
  134. COM_INTERFACE_ENTRY(IPCHToolBar)
  135. COM_INTERFACE_ENTRY2(IDispatch, IPCHToolBar)
  136. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  137. COM_INTERFACE_ENTRY(IProvideClassInfo)
  138. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  139. COM_INTERFACE_ENTRY(IViewObjectEx)
  140. COM_INTERFACE_ENTRY(IViewObject2)
  141. COM_INTERFACE_ENTRY(IViewObject)
  142. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  143. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  144. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  145. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  146. COM_INTERFACE_ENTRY(IOleControl)
  147. COM_INTERFACE_ENTRY(IOleObject)
  148. COM_INTERFACE_ENTRY(IPersistPropertyBag)
  149. COM_INTERFACE_ENTRY2(IPersist, IPersistPropertyBag)
  150. COM_INTERFACE_ENTRY(IPCHToolBarPrivate)
  151. END_COM_MAP()
  152. BEGIN_PROP_MAP(CPCHToolBar)
  153. PROP_ENTRY("Definition", DISPID_PCH_TB__DEFINITION, CLSID_NULL)
  154. END_PROP_MAP()
  155. CPCHToolBar();
  156. virtual ~CPCHToolBar();
  157. BOOL ProcessWindowMessage( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0 );
  158. BOOL ProcessAccessKey( UINT uMsg, WPARAM wParam, LPARAM lParam );
  159. BOOL PreTranslateAccelerator( LPMSG pMsg, HRESULT& hRet );
  160. // IViewObjectEx
  161. DECLARE_VIEW_STATUS(0)
  162. // IOleObject
  163. STDMETHOD(SetClientSite)(IOleClientSite *pClientSite);
  164. STDMETHOD(GetExtent )(DWORD dwDrawAspect, SIZEL *psizel);
  165. // IPCHToolBar
  166. public:
  167. STDMETHOD(get_Definition)( /*[out, retval]*/ BSTR * pVal );
  168. STDMETHOD(put_Definition)( /*[in ]*/ BSTR newVal );
  169. STDMETHOD(get_Mode )( /*[out, retval]*/ TB_MODE * pVal );
  170. STDMETHOD(put_Mode )( /*[in ]*/ TB_MODE newVal );
  171. STDMETHOD(SetState )( /*[in]*/ BSTR bstrText, /*[in]*/ VARIANT_BOOL fEnabled );
  172. STDMETHOD(SetVisibility)( /*[in]*/ BSTR bstrText, /*[in]*/ VARIANT_BOOL fVisible );
  173. // IPCHToolBarPrivate
  174. public:
  175. STDMETHOD(SameObject)( /*[in]*/ IPCHToolBar* ptr ) { return this == ptr ? S_OK : E_FAIL; }
  176. HRESULT FindElementThroughThunking( /*[out]*/ CComPtr<IHTMLElement>& elem );
  177. };
  178. /////////////////////////////////////////////////////////////////////////////
  179. #endif // !defined(__INCLUDED___PCH___HTMLTOOLBAR_H___)