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.

258 lines
9.4 KiB

  1. #ifndef _DUIVIEW_H_INCLUDED_
  2. #define _DUIVIEW_H_INCLUDED_
  3. #define GADGET_ENABLE_TRANSITIONS
  4. #define GADGET_ENABLE_CONTROLS
  5. #define GADGET_ENABLE_OLE
  6. #include <duser.h>
  7. #include <directui.h>
  8. #include <duserctrl.h>
  9. using namespace DirectUI;
  10. UsingDUIClass(Element);
  11. UsingDUIClass(Button);
  12. UsingDUIClass(RepeatButton);
  13. UsingDUIClass(Thumb);
  14. UsingDUIClass(ScrollBar);
  15. UsingDUIClass(Viewer);
  16. UsingDUIClass(Selector);
  17. UsingDUIClass(HWNDElement);
  18. UsingDUIClass(ScrollViewer);
  19. UsingDUIClass(Edit);
  20. #define WM_HTML_BITMAP (WM_USER + 100)
  21. #define WM_DETAILS_INFO (WM_USER + 101)
  22. typedef enum {
  23. DUISEC_UNKNOWN = 0,
  24. DUISEC_SPECIALTASKS = 1,
  25. DUISEC_FILETASKS = 2,
  26. DUISEC_OTHERPLACESTASKS = 3,
  27. DUISEC_DETAILSTASKS = 4
  28. } DUISEC;
  29. struct DUISEC_ATTRIBUTES;
  30. // Right now our themeing information is hard-coded due to limitations of DirectUI (only one resource)
  31. // so we'll ask the namespace for a hardcoded name that we can look up in the below table. Add new
  32. // names/entries to this list as we add theme parts to our shellstyle.dll.
  33. //
  34. typedef struct {
  35. LPCWSTR pszThemeName;
  36. int idSpecialSectionIcon;
  37. int idSpecialSectionWatermark;
  38. int idListviewWatermark;
  39. } WVTHEME;
  40. #include "defviewp.h"
  41. #include "w32utils.h"
  42. class CDefView;
  43. class Expando;
  44. class HWNDView;
  45. class ActionTask;
  46. class DestinationTask;
  47. class DUIListView;
  48. class DUIAxHost;
  49. class CDetailsSectionInfoTask;
  50. class CDUIDropTarget;
  51. STDAPI CDetailsSectionInfoTask_CreateInstance(IShellFolder *psfContaining,
  52. LPCITEMIDLIST pidlAbsolute,
  53. HWND hwndMsg,
  54. UINT uMsg,
  55. DWORD dwDetailsInfoID,
  56. CDetailsSectionInfoTask **ppTask);
  57. //
  58. // CDUIView class
  59. //
  60. class CDUIView
  61. {
  62. private:
  63. LONG _cRef;
  64. HWND _hWnd;
  65. HWNDView * _phe;
  66. DUIListView * _peListView;
  67. INT _iListViewHeight; // used when the preview control is also displayed
  68. INT _iOriginalTaskPaneWidth;
  69. INT _iTaskPaneWidth;
  70. DUIAxHost * _pePreview;
  71. IUnknown * _punkPreview;
  72. CDefView * _pDefView;
  73. Element * _peTaskPane;
  74. Element * _peClientViewHost;
  75. Element * _peBarrier;
  76. BOOL _bBarrierShown;
  77. BOOL _bInitialized;
  78. BSTR _bstrIntroText;
  79. IPropertyBag * _ppbShellFolders;
  80. CDUIDropTarget * _pDT;
  81. Expando* _peSpecialSection;
  82. Element* _peSpecialTaskList;
  83. Value* _pvSpecialTaskSheet;
  84. Expando* _peFolderSection;
  85. Element* _peFolderTaskList;
  86. Value* _pvFolderTaskSheet;
  87. Expando* _peDetailsSection;
  88. Element* _peDetailsInfoArea;
  89. Value* _pvDetailsSheet;
  90. IShellItemArray* _pshlItems;
  91. HDSA _hdsaNonStdTaskSections;
  92. BOOL _fLoadedTheme;
  93. HINSTANCE _hinstTheme;
  94. HANDLE _hinstScrollbarTheme;
  95. BOOL _bAnimationsDisabled;
  96. HRESULT _hrInit;
  97. CDUIView(CDefView * pDefView);
  98. ~CDUIView();
  99. public:
  100. HRESULT Initialize();
  101. friend CDUIView* Create_CDUIView(CDefView * pDefView);
  102. void AddRef(void)
  103. { InterlockedIncrement(&_cRef); }
  104. void Release(void)
  105. { ASSERT( 0 != _cRef ); if (0 == InterlockedDecrement(&_cRef)) delete this; }
  106. void DetachListview();
  107. HRESULT Initialize(BOOL bDisplayBarrier, IUnknown * punkPreview);
  108. HRESULT EnableBarrier(BOOL bDisplayBarrier);
  109. HRESULT EnablePreview(IUnknown * punkPreview);
  110. HRESULT Refresh(void);
  111. HRESULT SetSize(RECT *rc);
  112. HRESULT SetTaskPaneVisibility(BOOL bShow);
  113. void CalculateInfotipRect(Element *pe, RECT *pRect);
  114. BOOL Navigate(BOOL fForward);
  115. HRESULT InitializeDropTarget (LPITEMIDLIST pidl, HWND hWnd, IDropTarget **pdt);
  116. HRESULT NavigateToDestination(LPCITEMIDLIST pidl);
  117. HRESULT DelayedNavigation(IShellItemArray *psiItemArray, IUICommand *puiCommand);
  118. void UnInitializeDirectUI(void);
  119. void ManageAnimations(BOOL bExiting);
  120. HINSTANCE _GetThemeHinst(void);
  121. void OnSelectionChange(IShellItemArray *psiItemArray);
  122. void OnContentsChange(IShellItemArray *psiItemArray);
  123. void OnExpandSection(DUISEC eDUISecID, BOOL bExpanded);
  124. const WVTHEME* GetThemeInfo();
  125. private:
  126. //
  127. // Flags passed to _Refresh().
  128. //
  129. enum REFRESH_FLAGS {
  130. REFRESH_TASKS = 0x00000001, // Refresh webview task list content.
  131. REFRESH_CONTENT = 0x00000002, // Refresh webview right-pane content.
  132. REFRESH_SELCHG = 0x00000004, // Refreshing for a selection change
  133. REFRESH_ALL = 0x00000003
  134. };
  135. HRESULT _CreateHostWindow(void);
  136. HRESULT _LoadUIFileFromResources(HINSTANCE hinst, INT iID, char **pUIFile);
  137. HRESULT _BuildUIFile(char **pUIFile, int *piCharCount);
  138. HRESULT _BuildSection(Element* peSectionList, BOOL bMain, IUIElement* pTitle,
  139. int idBitmapDesc, int idWatermarkDesc, Value* pvSectionSheet,
  140. Parser* pParser, DUISEC eDUISecID, Expando ** ppeExpando, Element ** pTaskList);
  141. HRESULT _AddActionTasks(Expando* peExpando, Element* peTaskList, IEnumUICommand* penum, Value* pvTaskSheet, BOOL bIntroAdded);
  142. HRESULT _AddDestinationTasks(Element* peTaskList, IEnumIDList* penum, Value* pvTaskSheet);
  143. HRESULT _AddDetailsSectionInfo();
  144. HRESULT _BuildTaskList(Parser* pParser);
  145. HRESULT _BuildStandardTaskList(Parser *pParser, Element *peSectionList);
  146. HRESULT _BuildNonStandardTaskList(Parser *pParser, Element *peSectionList, HDSA hdsaSections);
  147. HRESULT _InitializeElements(char * pUIFile, int iCharCount, BOOL bDisplayBarrier, IUnknown * punkPreview);
  148. HRESULT _SwitchToBarrier(BOOL bDisplayBarrier);
  149. HRESULT _ManagePreview(IUnknown * punkPreview);
  150. HRESULT _GetIntroTextElement(Element** ppeIntroText);
  151. HRESULT _BuildSoftBarrier(void);
  152. void _InitializeShellFolderPropertyBag();
  153. BOOL _ShowSectionExpanded(DUISEC eDUISecID);
  154. const struct DUISEC_ATTRIBUTES *_GetSectionAttributes(DUISEC eDUISecID);
  155. static LRESULT CALLBACK _DUIHostWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  156. HRESULT _OnResize(long lWidth, long lHeight);
  157. void _Refresh(IShellItemArray *psiItemArray, DWORD dwRefreshFlags = REFRESH_ALL);
  158. HRESULT _AddNonStdTaskSection(const SFVM_WEBVIEW_ENUMTASKSECTION_DATA *pData);
  159. HRESULT _GetNonStdTaskSectionsFromViewCB(void);
  160. void _ClearNonStdTaskSections(void);
  161. BOOL _bHideTaskPaneAlways; // Set to TRUE when "Use Classic View" is used, FALSE otherwise
  162. BOOL _fHideTasklist; // Set to TRUE when an explorer bar is visible
  163. public:
  164. // Thumbnail extraction stuff...
  165. HRESULT InitializeThumbnail(WNDPROC pfnWndProc);
  166. HRESULT SetThumbnailMsgWindowPtr(void* p, void* pCheck);
  167. HRESULT StartBitmapExtraction(LPCITEMIDLIST pidl);
  168. // Details section info extraction stuff...
  169. HRESULT InitializeDetailsInfo(WNDPROC pfnWndProc);
  170. HRESULT SetDetailsInfoMsgWindowPtr(void* p, void* pCheck);
  171. HRESULT StartInfoExtraction(LPCITEMIDLIST pidl);
  172. VOID ShowDetails(BOOL fShow);
  173. BOOL ShouldShowMiniPreview();
  174. DWORD _dwThumbnailID; // Accessed by CMiniPreviewer (duiinfo.cpp)
  175. DWORD _dwDetailsInfoID; // Accessed by CMiniPreviewer (duiinfo.cpp)
  176. protected:
  177. CComPtr<IThumbnail2> _spThumbnailExtractor2;
  178. HWND _hwndMsgThumbExtract;
  179. HWND _hwndMsgInfoExtract;
  180. };
  181. HBITMAP DUILoadBitmap(HINSTANCE hInstTheme, int idBitmapID, UINT uiLoadFlags);
  182. HICON DUILoadIcon(LPCWSTR pszIconDesc, BOOL bSmall);
  183. class HWNDView: public HWNDElement
  184. {
  185. public:
  186. static HRESULT Create(OUT Element** ppElement); // Required for ClassInfo (always fails)
  187. static HRESULT Create(HWND hParent, bool fDblBuffer, UINT nCreate, OUT Element** ppElement);
  188. static HRESULT Create(HWND hParent, bool fDblBuffer, UINT nCreate, CDUIView * pDUIView, CDefView* pDefView, OUT Element** ppElement);
  189. BOOL Navigate(BOOL fForward);
  190. virtual LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  191. virtual UINT MessageCallback(GMSG* pGMsg);
  192. virtual void OnEvent(Event* pEvent);
  193. void SetViewPtrs (CDUIView * pDUIView, CDefView* pDefView);
  194. // ClassInfo accessors (static and virtual instance-based)
  195. static IClassInfo* Class;
  196. virtual IClassInfo* GetClassInfo() { return Class; }
  197. static HRESULT Register();
  198. HWNDView(void);
  199. virtual ~HWNDView(void);
  200. private:
  201. BOOL _fFocus; // hack until SetGadgetFocus(NULL) works.
  202. // see HWNDView::Navigate.
  203. BOOL _fDelayedNavigation; // Try to prevent double-clicking. If this is TRUE, then one click
  204. // has already been fired.
  205. IUICommand * _puiDelayNavCmd; // The UI command object for delayed navigation. Look for WM_USER_DELAY_NAGIVATION.
  206. IShellItemArray * _psiDelayNavArray; // The Shell Item Arraay for delayed navigation. Look for WM_USER_DELAY_NAGIVATION.
  207. CDefView * _pDefView;// used to relay infotip messages
  208. CDUIView* _pDUIView;
  209. };
  210. #endif