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.

422 lines
17 KiB

  1. #ifndef __PANEL_H
  2. #define __PANEL_H
  3. // A "panel" is basically a tiled window inside the outer Mars window
  4. class CMarsDocument;
  5. class CMarsWindow;
  6. interface IBrowserService;
  7. #include "axhost.h"
  8. #include "external.h"
  9. #include "profsvc.h"
  10. #include "pandef.h"
  11. class CPanelCollection;
  12. EXTERN_C const GUID CLASS_CMarsPanel;
  13. class CMarsPanel :
  14. public CMarsComObject,
  15. public MarsIDispatchImpl<IMarsPanel, &IID_IMarsPanel>,
  16. public IHlinkFrame,
  17. public IInternetSecurityManager,
  18. public IServiceProvider,
  19. public IProfferServiceImpl,
  20. public IOleInPlaceSite,
  21. public IOleControlSite,
  22. public IPropertyNotifySink,
  23. public IOleInPlaceUIWindow
  24. {
  25. friend CPanelCollection;
  26. CMarsPanel(CPanelCollection *pParent, CMarsWindow *pMarsWindow);
  27. protected:
  28. virtual ~CMarsPanel();
  29. HRESULT DoPassivate();
  30. public:
  31. virtual HRESULT Passivate();
  32. HRESULT Create( MarsAppDef_Panel* pLayout);
  33. HRESULT NavigateMk(IMoniker *pmk);
  34. HRESULT NavigateURL(LPCWSTR lpszURL, BOOL fForceLoad);
  35. HRESULT Layout( RECT *prcClient );
  36. void OnWindowPosChanging( WINDOWPOS *pWindowPos );
  37. void OnWindowPosChanged ( WINDOWPOS *pWindowPos );
  38. void GetMinMaxInfo( POINT& ptMin, POINT& ptMax );
  39. bool CanLayout( RECT& rcClient, POINT& ptDiff );
  40. void GetUrl ( CComBSTR& rbstrUrl );
  41. BSTR GetName () { return m_bstrName; }
  42. CMarsAxWindow *Window () { return &m_Content; }
  43. CPanelCollection *Panels () { return m_spPanelCollection; }
  44. long GetWidth () { return m_lWidth; }
  45. long GetHeight() { return m_lHeight; }
  46. HRESULT UIDeactivate();
  47. HRESULT TranslateAccelerator(MSG *pMsg);
  48. void ForwardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  49. CMarsDocument *Document() { return m_spMarsDocument; }
  50. bool IsWebBrowser () { return (m_dwFlags & PANEL_FLAG_WEBBROWSER ) != 0; }
  51. bool IsCustomControl () { return (m_dwFlags & PANEL_FLAG_CUSTOMCONTROL) != 0; }
  52. bool IsPopup () { return (m_Position == PANEL_POPUP); }
  53. bool IsVisible () { return !!m_fVisible; }
  54. bool WasInPreviousPlace() { return !!m_fPresentInPlace; }
  55. bool IsTrusted () { return (m_dwFlags & PANEL_FLAG_TRUSTED ) != 0; }
  56. bool AutoPersists () { return (m_dwFlags & PANEL_FLAG_AUTOPERSIST ) != 0; }
  57. bool IsAutoSizing () { return (m_dwFlags & PANEL_FLAG_AUTOSIZE ) != 0; }
  58. LONG GetReadyState () { return m_lReadyState; }
  59. PANEL_POSITION GetPosition () { return m_Position; }
  60. BOOL GetTabCycle() { return m_fTabCycle; }
  61. void ResetTabCycle() { ATLASSERT(m_fTabCycle); m_fTabCycle = FALSE; }
  62. void SetPresenceInPlace( BOOL fPresent ) { m_fPresentInPlace = fPresent; }
  63. BOOL IsContentInvalid() { return m_fContentInvalid; }
  64. HRESULT DoEnableModeless(BOOL fEnable);
  65. // IUnknown
  66. STDMETHOD_(ULONG, AddRef)();
  67. STDMETHOD_(ULONG, Release)();
  68. STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
  69. // IMarsPanel
  70. STDMETHOD(get_name )( /*[out, retval]*/ BSTR *pVal );
  71. STDMETHOD(get_content )( /*[out, retval]*/ IDispatch* *pVal );
  72. STDMETHOD(get_visible )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  73. STDMETHOD(put_visible )( /*[in ]*/ VARIANT_BOOL newVal );
  74. STDMETHOD(get_startUrl )( /*[out, retval]*/ BSTR *pVal );
  75. STDMETHOD(put_startUrl )( /*[in ]*/ BSTR newVal );
  76. STDMETHOD(get_height )( /*[out, retval]*/ long *pVal );
  77. STDMETHOD(put_height )( /*[in ]*/ long newVal );
  78. STDMETHOD(get_width )( /*[out, retval]*/ long *pVal );
  79. STDMETHOD(put_width )( /*[in ]*/ long newVal );
  80. STDMETHOD(get_x )( /*[out, retval]*/ long *pVal );
  81. STDMETHOD(put_x )( /*[in ]*/ long newVal );
  82. STDMETHOD(get_y )( /*[out, retval]*/ long *pVal );
  83. STDMETHOD(put_y )( /*[in ]*/ long newVal );
  84. STDMETHOD(get_position )( /*[out, retval]*/ VARIANT *pVal );
  85. STDMETHOD(put_position )( /*[in ]*/ VARIANT newVal );
  86. STDMETHOD(get_autoSize )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  87. STDMETHOD(put_autoSize )( /*[in ]*/ VARIANT_BOOL newVal );
  88. STDMETHOD(get_contentInvalid )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  89. STDMETHOD(put_contentInvalid )( /*[in ]*/ VARIANT_BOOL newVal );
  90. STDMETHOD(get_layoutIndex )( /*[out, retval]*/ long *pVal );
  91. STDMETHOD(get_isCurrentlyVisible)( /*[out, retval]*/ VARIANT_BOOL *pVal );
  92. STDMETHOD(moveto)( VARIANT lX, VARIANT lY, VARIANT lWidth, VARIANT lHeight );
  93. STDMETHOD(restrictHeight)( VARIANT lMin, VARIANT lMax, VARIANT varMarker );
  94. STDMETHOD(restrictWidth )( VARIANT lMin, VARIANT lMax, VARIANT varMarker );
  95. STDMETHOD(canResize)( long lDX, long lDY, VARIANT_BOOL *pVal );
  96. STDMETHOD(navigate)( VARIANT varTarget, VARIANT varForceLoad );
  97. STDMETHOD(refresh )();
  98. STDMETHOD(activate)();
  99. STDMETHOD(insertBefore)( VARIANT varInsertBefore );
  100. STDMETHOD(execMshtml)( DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut );
  101. ////////////////////////////////////////////////////////////////////////////////
  102. // IServiceProvider methods
  103. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppv);
  104. // IHlinkFrame
  105. STDMETHODIMP GetBrowseContext(IHlinkBrowseContext **ppihlbc)
  106. { return E_NOTIMPL; }
  107. STDMETHODIMP OnNavigate(DWORD grfHLNF, IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
  108. { return E_NOTIMPL; }
  109. STDMETHODIMP UpdateHlink(ULONG uHLID, IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
  110. { return E_NOTIMPL; }
  111. STDMETHODIMP SetBrowseContext(IHlinkBrowseContext *pihlbc)
  112. { return E_NOTIMPL; }
  113. STDMETHODIMP Navigate(DWORD grfHLNF, LPBC pbc, IBindStatusCallback *pibsc, IHlink *pihlNavigate);
  114. // IInternetSecurityManager
  115. STDMETHODIMP SetSecuritySite(IInternetSecurityMgrSite *pSite);
  116. STDMETHODIMP GetSecuritySite(IInternetSecurityMgrSite **ppSite);
  117. STDMETHODIMP MapUrlToZone(LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags);
  118. STDMETHODIMP GetSecurityId(LPCWSTR pwszUrl, BYTE *pbSecurityId,
  119. DWORD *pcbSecurityId, DWORD_PTR dwReserved);
  120. STDMETHODIMP ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE __RPC_FAR *pPolicy,
  121. DWORD cbPolicy, BYTE *pContext, DWORD cbContext,
  122. DWORD dwFlags, DWORD dwReserved);
  123. STDMETHODIMP QueryCustomPolicy(LPCWSTR pwszUrl, REFGUID guidKey, BYTE **ppPolicy,
  124. DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext,
  125. DWORD dwReserved);
  126. STDMETHODIMP SetZoneMapping(DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags);
  127. STDMETHODIMP GetZoneMappings(DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags);
  128. // IOleWindow
  129. STDMETHODIMP GetWindow(HWND *phwnd)
  130. { return E_NOTIMPL; }
  131. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode)
  132. { ATLASSERT(FALSE); return E_NOTIMPL; }
  133. // IOleInPlaceSite
  134. STDMETHODIMP CanInPlaceActivate()
  135. { ATLASSERT(FALSE); return E_NOTIMPL; }
  136. STDMETHODIMP OnInPlaceActivate()
  137. { ATLASSERT(FALSE); return E_NOTIMPL; }
  138. STDMETHODIMP OnUIActivate();
  139. STDMETHODIMP GetWindowContext(IOleInPlaceFrame **ppFrame,
  140. IOleInPlaceUIWindow **ppDoc,
  141. LPRECT lprcPosRect,
  142. LPRECT lprcClipRect,
  143. LPOLEINPLACEFRAMEINFO lpFrameInfo)
  144. { ATLASSERT(FALSE); return E_NOTIMPL; }
  145. STDMETHODIMP Scroll(SIZE scrollExtant)
  146. { ATLASSERT(FALSE); return E_NOTIMPL; }
  147. STDMETHODIMP OnUIDeactivate(BOOL fUndoable)
  148. { ATLASSERT(FALSE); return E_NOTIMPL; }
  149. STDMETHODIMP OnInPlaceDeactivate()
  150. { ATLASSERT(FALSE); return E_NOTIMPL; }
  151. STDMETHODIMP DiscardUndoState()
  152. { ATLASSERT(FALSE); return E_NOTIMPL; }
  153. STDMETHODIMP DeactivateAndUndo()
  154. { ATLASSERT(FALSE); return E_NOTIMPL; }
  155. STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect)
  156. { ATLASSERT(FALSE); return E_NOTIMPL; }
  157. // IOleControlSite
  158. STDMETHODIMP OnControlInfoChanged()
  159. { ATLASSERT(FALSE); return E_NOTIMPL; }
  160. STDMETHODIMP LockInPlaceActive(BOOL fLock)
  161. { ATLASSERT(FALSE); return E_NOTIMPL; }
  162. STDMETHODIMP GetExtendedControl(IDispatch **ppDisp)
  163. { ATLASSERT(FALSE); return E_NOTIMPL; }
  164. STDMETHODIMP TransformCoords(POINTL *pPtlHimetric, POINTF *pPtfContainer,DWORD dwFlags)
  165. { ATLASSERT(FALSE); return E_NOTIMPL; }
  166. STDMETHODIMP TranslateAccelerator(MSG *pMsg,DWORD grfModifiers);
  167. STDMETHODIMP OnFocus(BOOL fGotFocus)
  168. { ATLASSERT(FALSE); return E_NOTIMPL; }
  169. STDMETHODIMP ShowPropertyFrame(void)
  170. { ATLASSERT(FALSE); return E_NOTIMPL; }
  171. // IPropertyNotifySink methods
  172. STDMETHODIMP OnChanged(DISPID dispID);
  173. STDMETHODIMP OnRequestEdit(DISPID dispID)
  174. { ATLASSERT(FALSE); return E_NOTIMPL; }
  175. // IOleInPlaceUIWindow
  176. STDMETHOD(GetBorder)(LPRECT /*lprectBorder*/)
  177. {
  178. return S_OK;
  179. }
  180. STDMETHOD(RequestBorderSpace)(LPCBORDERWIDTHS /*pborderwidths*/)
  181. {
  182. return INPLACE_E_NOTOOLSPACE;
  183. }
  184. STDMETHOD(SetBorderSpace)(LPCBORDERWIDTHS /*pborderwidths*/)
  185. {
  186. return S_OK;
  187. }
  188. STDMETHOD(SetActiveObject)(IOleInPlaceActiveObject* pActiveObject, LPCOLESTR /*pszObjName*/)
  189. {
  190. m_spActiveObject = pActiveObject;
  191. return S_OK;
  192. }
  193. static HRESULT GetFromUnknown(IUnknown *punk, CMarsPanel **ppMarsPanel)
  194. {
  195. return IUnknown_QueryService(punk, SID_SMarsPanel, CLASS_CMarsPanel, (void **)ppMarsPanel);
  196. }
  197. HRESULT OnDocHostUIExec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt,
  198. VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  199. protected:
  200. HRESULT CreateControl();
  201. HRESULT CreateControlObject();
  202. HRESULT GetRect(RECT *prcClient, RECT *prcMyClient);
  203. VOID ConnectCompletionAdviser();
  204. VOID DisconnectCompletionAdviser();
  205. VOID ComputeDimensionsOfContent(long *plWidth, long *plHeight);
  206. void MakeVisible(VARIANT_BOOL bVisible, VARIANT_BOOL bForce);
  207. void OnLayoutChange();
  208. void GetMyClientRectInParentCoords(RECT *prc);
  209. class CBrowserEvents : public CMarsPanelSubObject,
  210. public IDispatch
  211. {
  212. friend CMarsPanel;
  213. CBrowserEvents(CMarsPanel *pParent);
  214. ~CBrowserEvents() {}
  215. HRESULT DoPassivate() { return S_OK; }
  216. DWORD m_dwCookie;
  217. DWORD m_dwCookie2;
  218. public:
  219. void Connect(IUnknown *punk, BOOL bConnect);
  220. // IUnknown
  221. STDMETHOD_(ULONG, AddRef)();
  222. STDMETHOD_(ULONG, Release)();
  223. STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
  224. STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
  225. {
  226. *pctinfo = 0;
  227. return E_NOTIMPL;
  228. }
  229. STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  230. {
  231. *pptinfo = NULL;
  232. return E_NOTIMPL;
  233. }
  234. STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
  235. LCID lcid, DISPID* rgdispid)
  236. {
  237. return E_NOTIMPL;
  238. }
  239. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  240. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  241. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  242. };
  243. protected:
  244. friend class CBrowserEvents;
  245. CMarsAxWindow m_Content; // Content in this panel
  246. CBrowserEvents m_BrowserEvents;
  247. CMarsExternal m_MarsExternal;
  248. CComBSTR m_bstrName;
  249. // Active object within this doc
  250. CComPtr<IOleInPlaceActiveObject> m_spActiveObject;
  251. CComClassPtr<CPanelCollection> m_spPanelCollection; // Parent collection
  252. CComClassPtr<CMarsDocument> m_spMarsDocument; // Parent document
  253. CComBSTR m_bstrStartUrl; // Used until control is created
  254. PANEL_POSITION m_Position;
  255. long m_lWidth; // Used for "left", "right", or "popup"
  256. long m_lHeight; // Used for "top", "bottom", or "popup"
  257. long m_lX; // Used for "popup"
  258. long m_lY; // Used for "popup"
  259. DWORD m_dwFlags; // PANEL_FLAG_*
  260. long m_lMinWidth; // size constraints
  261. long m_lMaxWidth; // ""
  262. long m_lMinHeight; // ""
  263. long m_lMaxHeight; // ""
  264. DWORD m_dwCookie; // Cookie for mshtml sink for resize events
  265. long m_lReadyState; // READYSTATE_*
  266. BOOL m_fControlCreated : 1; // Has control been created?
  267. BOOL m_fVisible : 1; // Should we be visible?
  268. BOOL m_fPresentInPlace : 1; // Were we in the previous place?
  269. BOOL m_fTabCycle : 1;
  270. BOOL m_fInRefresh : 1; // Are we the one calling Trident to refresh?
  271. BOOL m_fContentInvalid : 1; // Does this panel need updating after a theme switch?
  272. CComPtr<IBrowserService> m_spBrowserService;
  273. };
  274. typedef CMarsSimpleArray<CComClassPtr<CMarsPanel> > CPanelArray;
  275. typedef MarsIDispatchImpl<IMarsPanelCollection, &IID_IMarsPanelCollection> IMarsPanelCollectionImpl;
  276. class CPanelCollection :
  277. public CPanelArray,
  278. public CMarsComObject,
  279. public IMarsPanelCollectionImpl
  280. {
  281. friend CMarsDocument;
  282. CPanelCollection(CMarsDocument *pMarsDocument);
  283. HRESULT DoPassivate();
  284. protected:
  285. virtual ~CPanelCollection();
  286. public:
  287. // IUnknown
  288. STDMETHOD_(ULONG, AddRef)();
  289. STDMETHOD_(ULONG, Release)();
  290. STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
  291. // IDispatch
  292. IMPLEMENT_IDISPATCH_DELEGATE_TO_BASE(IMarsPanelCollectionImpl);
  293. // IMarsPanelCollection
  294. STDMETHOD(get_panel)(/*[in]*/ BSTR bstrName, /*[out, retval]*/ IMarsPanel **ppPanel);
  295. STDMETHOD(addPanel)(/*[in]*/ BSTR bstrName, /*[in]*/ VARIANT varType, /*[in]*/ BSTR bstrStartUrl, /*[in]*/ VARIANT varCreate, /*[in]*/ long lFlags, /*[out, retval]*/ IMarsPanel **ppPanel);
  296. STDMETHOD(removePanel)(/*[in]*/ BSTR bstrName);
  297. STDMETHOD(lockLayout)();
  298. STDMETHOD(unlockLayout)();
  299. STDMETHOD(get_activePanel)(/*out, retval*/ IMarsPanel **ppPanel);
  300. // IMarsPanelCollection standard collection methods
  301. STDMETHOD(get_length)(/*[out, retval]*/ LONG *plNumPanels);
  302. STDMETHOD(get_item)(/*[in]*/ VARIANT varIndexOrName, /*[out, retval]*/ IMarsPanel **ppPanel);
  303. STDMETHOD(get__newEnum)(/*[out, retval]*/ IUnknown **ppEnumPanels);
  304. HRESULT DoEnableModeless(BOOL fEnable);
  305. void Layout();
  306. BOOL IsLayoutLocked() { return (m_iLockLayout != 0); }
  307. void SetActivePanel(CMarsPanel *pPanel, BOOL bActive);
  308. CMarsPanel *ActivePanel() { return m_spActivePanel; }
  309. CMarsDocument *Document() { return m_spMarsDocument; }
  310. HRESULT AddPanel( MarsAppDef_Panel* pLayout, /*optional*/ IMarsPanel **ppPanel);
  311. void FreePanels();
  312. CMarsPanel *FindPanel(LPCWSTR pwszName);
  313. HRESULT FindPanelIndex(CMarsPanel *pPanel, long *plIndex);
  314. HRESULT InsertPanelFromTo(long lOldIndex, long lNewIndex);
  315. void InvalidatePanels();
  316. void RefreshInvalidVisiblePanels();
  317. protected:
  318. CComClassPtr<CMarsDocument> m_spMarsDocument;
  319. CComClassPtr<CMarsPanel> m_spActivePanel;
  320. int m_iLockLayout; // Is our panel layout temporarily locked (refcount)?
  321. BOOL m_fPendingLayout : 1; // Do we have pending layouts because of lock?
  322. };
  323. #endif // __PANEL_H