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.

356 lines
12 KiB

  1. /**********************************************************************
  2. * FontView.h - Definition for the CFontView, our implementation for
  3. * the IShellView in our browser.
  4. *
  5. **********************************************************************/
  6. #if !defined(__FONTVIEW_H__)
  7. #define __FONTVIEW_H__
  8. #ifndef __EXTRICON_H__
  9. #include "extricon.h"
  10. #endif
  11. //
  12. // Defining the macro TOOLTIP_FONTSAMPLE activates code to display a
  13. // font sample in a tooltip window whenever the mouse cursor pauses over
  14. // an item in the font folder. This is currently an experimental feature
  15. // so I want to allow conditional compilation for now. If it goes into
  16. // the product, the conditional compilation directives may be removed.
  17. // [brianau - 5/17/97].
  18. //
  19. #define TOOLTIP_FONTSAMPLE 1
  20. // Forward declarations.
  21. class CFontClass;
  22. class CFontList;
  23. class CFontView;
  24. class CFontManager;
  25. VOID InstallDataObject( LPDATAOBJECT pdobj, DWORD dwEffect, HWND hWnd, CFontView * poView = NULL);
  26. // ********************************************************************
  27. class CFontData : public IDataObject
  28. {
  29. public:
  30. // ctor, dtor, and init.
  31. //
  32. CFontData();
  33. ~CFontData();
  34. BOOL bInit( CFontList * poList );
  35. CFontList *poDetachList(void);
  36. CFontList *poCloneList(void);
  37. // *** IUnknown methods ***
  38. STDMETHODIMP QueryInterface( REFIID riid, LPVOID * ppvObj );
  39. STDMETHODIMP_(ULONG) AddRef( void );
  40. STDMETHODIMP_(ULONG) Release( void );
  41. // **** IDataObject ****
  42. //
  43. STDMETHODIMP GetData( FORMATETC *pformatetcIn, STGMEDIUM *pmedium );
  44. STDMETHODIMP GetDataHere( FORMATETC *pformatetc, STGMEDIUM *pmedium );
  45. STDMETHODIMP QueryGetData( FORMATETC *pformatetc );
  46. STDMETHODIMP GetCanonicalFormatEtc( FORMATETC *pformatectIn,
  47. FORMATETC *pformatetcOut );
  48. STDMETHODIMP SetData( FORMATETC *pformatetc,
  49. STGMEDIUM *pmedium,
  50. BOOL fRelease );
  51. STDMETHODIMP EnumFormatEtc( DWORD dwDirection,
  52. IEnumFORMATETC **ppenumFormatEtc );
  53. STDMETHODIMP DAdvise( FORMATETC *pformatetc,
  54. DWORD advf,
  55. IAdviseSink *pAdvSink,
  56. DWORD *pdwConnection);
  57. STDMETHODIMP DUnadvise( DWORD dwConnection);
  58. STDMETHODIMP EnumDAdvise( IEnumSTATDATA **ppenumAdvise );
  59. // Additional public interfaces.
  60. //
  61. BOOL bAFR(); // AddFontResource() for each of these
  62. BOOL bRFR(); // RemoveFontResource for each object.
  63. static CLIPFORMAT s_CFPerformedDropEffect; // Performed Drop Effect CF atom.
  64. static CLIPFORMAT s_CFPreferredDropEffect;
  65. static CLIPFORMAT s_CFLogicalPerformedDropEffect;
  66. //
  67. // Get the performed data transfer effect from the Data Object.
  68. //
  69. DWORD GetPerformedDropEffect(void)
  70. { return m_dwPerformedDropEffect; }
  71. void SetPerformedDropEffect(DWORD dwEffect)
  72. { m_dwPerformedDropEffect = dwEffect; }
  73. DWORD GetLogicalPerformedDropEffect(void)
  74. { return m_dwLogicalPerformedDropEffect; }
  75. void SetLogicalPerformedDropEffect(DWORD dwEffect)
  76. { m_dwLogicalPerformedDropEffect = dwEffect; }
  77. DWORD GetPreferredDropEffect(void)
  78. { return m_dwPreferredDropEffect; }
  79. void SetPreferredDropEffect(DWORD dwEffect)
  80. { m_dwPreferredDropEffect = dwEffect; }
  81. private:
  82. int m_cRef;
  83. CFontList * m_poList;
  84. DWORD m_dwPerformedDropEffect; // DROPEFFECT_XXXX.
  85. DWORD m_dwPreferredDropEffect; // DROPEFFECT_XXXX.
  86. DWORD m_dwLogicalPerformedDropEffect;
  87. HRESULT ReleaseStgMedium(LPSTGMEDIUM pmedium);
  88. };
  89. // ********************************************************************
  90. class CFontView : public IShellView, public IDropTarget, public IPersistFolder
  91. {
  92. public:
  93. CFontView(void);
  94. ~CFontView( );
  95. int Compare( CFontClass * pFont1, CFontClass * pFont2 );
  96. void vShapeView( );
  97. // *** IUnknown methods ***
  98. STDMETHODIMP QueryInterface( REFIID riid, LPVOID * ppvObj );
  99. STDMETHODIMP_(ULONG) AddRef( void );
  100. STDMETHODIMP_(ULONG) Release( void );
  101. // *** IOleWindow methods ***
  102. STDMETHODIMP GetWindow( HWND * lphwnd );
  103. STDMETHODIMP ContextSensitiveHelp( BOOL fEnterMode );
  104. // *** IShellView methods ***
  105. STDMETHODIMP TranslateAccelerator( LPMSG msg );
  106. STDMETHODIMP EnableModeless( BOOL fEnable );
  107. STDMETHODIMP UIActivate( UINT uState );
  108. STDMETHODIMP Refresh( void );
  109. STDMETHODIMP CreateViewWindow( IShellView * lpPrevView,
  110. LPCFOLDERSETTINGS lpfs,
  111. IShellBrowser * psb,
  112. RECT * prcView,
  113. HWND * phwnd);
  114. STDMETHODIMP DestroyViewWindow( void );
  115. STDMETHODIMP GetCurrentInfo( LPFOLDERSETTINGS lpfs );
  116. STDMETHODIMP AddPropertySheetPages( DWORD dwReserved,
  117. LPFNADDPROPSHEETPAGE lpfn,
  118. LPARAM lparam);
  119. STDMETHODIMP SaveViewState( void );
  120. STDMETHODIMP SelectItem( LPCITEMIDLIST lpvID, UINT uFlags );
  121. STDMETHODIMP GetItemObject( UINT uItem, REFIID riid, LPVOID *ppv );
  122. // **** IDropTarget ****
  123. //
  124. STDMETHODIMP DragEnter( IDataObject __RPC_FAR *pDataObj,
  125. DWORD grfKeyState, POINTL pt,
  126. DWORD __RPC_FAR *pdwEffect );
  127. STDMETHODIMP DragOver( DWORD grfKeyState,
  128. POINTL pt,
  129. DWORD __RPC_FAR *pdwEffect );
  130. STDMETHODIMP DragLeave( void );
  131. STDMETHODIMP Drop( IDataObject __RPC_FAR *pDataObj,
  132. DWORD grfKeyState,
  133. POINTL pt,
  134. DWORD __RPC_FAR *pdwEffect );
  135. // *** IPersist methods ***
  136. STDMETHODIMP GetClassID( LPCLSID lpClassID );
  137. // *** IPersistFolder methods ***
  138. STDMETHODIMP Initialize( LPCITEMIDLIST pidl );
  139. public:
  140. void StatusPush( UINT nStatus );
  141. void StatusPush( LPTSTR lpsz );
  142. void StatusPop( );
  143. void StatusClear( );
  144. //
  145. // Exposing this is a violation of the design of this object.
  146. // However, it is needed so that we can provide a parent to the installation
  147. // progress dialog.
  148. //
  149. HWND GetViewWindow(void)
  150. { return m_hwndView; }
  151. DWORD GetDateReading(void)
  152. { return m_dwDateFormat; }
  153. IDataObject *m_pdtobjHdrop; // Used to support drag-drop from Win3.1 app.
  154. private:
  155. enum CLICKMODE
  156. {
  157. CLICKMODE_SINGLE = 1,
  158. CLICKMODE_DOUBLE = 2,
  159. };
  160. int RegisterWindowClass( );
  161. STDMETHODIMP GetSavedViewState( );
  162. void SortObjects( );
  163. void FillObjects( );
  164. int AddObject( CFontClass * poFont );
  165. LRESULT BeginDragDrop( NM_LISTVIEW FAR *lpn );
  166. int OnActivate( UINT state );
  167. int OnDeactivate( );
  168. int MergeToolbar( );
  169. static INT_PTR CALLBACK FontViewDlgProc( HWND, UINT, WPARAM, LPARAM );
  170. static LRESULT CALLBACK FontViewWndProc( HWND, UINT, WPARAM, LPARAM );
  171. static INT_PTR CALLBACK OptionsDlgProc( HWND, UINT, WPARAM, LPARAM) ;
  172. int OnMenuSelect( HWND hWnd, UINT nID, UINT nFlags, HMENU hMenu );
  173. int OnCommand( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
  174. int OnNotify( LPNMHDR lpn );
  175. VOID OnLVN_ItemActivate(LPNMITEMACTIVATE pnma);
  176. void OnDropFiles( HDROP hDrop, DWORD dwEffect = DROPEFFECT_MOVE );
  177. void OnCmdCutCopy( UINT nID );
  178. void OnCmdDelete( );
  179. void OnCmdPaste( );
  180. void OnCmdProperties( );
  181. void OnPointSize( int nPlus );
  182. void OnHelpTopics( HWND hWnd );
  183. INT ItemImageIndex(CFontClass *poFont);
  184. CLICKMODE SetListviewClickMode(VOID);
  185. void UpdateUnderlines(void);
  186. void LV_OnGetInfoTip(LPNMLVGETINFOTIP lpnm);
  187. #ifdef TOOLTIP_FONTSAMPLE
  188. VOID LV_OnHoverNotify(LPNMLISTVIEW pnmlv);
  189. BOOL CreateToolTipWindow(VOID);
  190. VOID UpdateFontSample(INT iItem);
  191. #endif //TOOLTIP_FONTSAMPLE
  192. //
  193. // Functions to support Attributes column in details view and
  194. // alternate coloring of compressed files.
  195. //
  196. int OnShellChangeNotify(WPARAM wParam, LPARAM lParam);
  197. int OnCustomDrawNotify(LPNMHDR lpn);
  198. void UpdateFontViewObject(CFontClass *poFont);
  199. int CompareByFileAttributes(CFontClass *poFont1, CFontClass *poFont2);
  200. LPTSTR BuildAttributeString(DWORD dwAttributes, LPTSTR pszString, UINT nChars);
  201. //
  202. // Functions to support drag-drop from Win3.1 app.
  203. //
  204. void OldDAD_DropTargetLeaveAndReleaseData(void);
  205. LRESULT OldDAD_HandleMessages(UINT message, WPARAM wParam, const DROPSTRUCT *lpds);
  206. #ifdef USE_OWNERDRAW
  207. void SetDimensions( );
  208. BOOL OnMeasureItem( LPMEASUREITEMSTRUCT lpmi );
  209. BOOL OnDrawItem( LPDRAWITEMSTRUCT lpdi );
  210. #endif
  211. void UpdateMenuItems( HMENU hMenu );
  212. void UpdateToolbar( );
  213. LRESULT ProcessMessage( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
  214. BOOL OpenCurrent( );
  215. BOOL PrintCurrent( );
  216. BOOL ViewValue( CFontClass * poFont );
  217. BOOL PrintValue( CFontClass *poFont );
  218. void vLoadCombo( );
  219. void SetViewMode( UINT uMode );
  220. void UpdatePanColumn( );
  221. void vToggleSelection( BOOL bSelectAll );
  222. int iCurrentSelection( );
  223. HRESULT GetUIObjectFromItem( REFIID riid, LPVOID FAR *ppobj, UINT nItem );
  224. HRESULT GetFontList( CFontList **ppoList, UINT nItem );
  225. void ReleaseFontObjects(void);
  226. void UpdateSelectedCount();
  227. private:
  228. int m_cRef;
  229. // int m_iCurrentSelection;
  230. BOOL m_bFamilyOnly;
  231. CFontClass * m_poPanose;
  232. HWND m_hwndView;
  233. HWND m_hwndList;
  234. HWND m_hwndText;
  235. HWND m_hwndCombo;
  236. HWND m_hwndParent;
  237. HWND m_hwndNextClip; // Next window in the viewer chain
  238. DWORD m_dwDateFormat;
  239. #ifdef TOOLTIP_FONTSAMPLE
  240. HWND m_hwndToolTip; // Tooltip window handle.
  241. BOOL m_bShowPreviewToolTip;// User preference setting.
  242. LPTSTR m_pszSampleText; // Sample string used for character fonts.
  243. LPTSTR m_pszSampleSymbols; // Sample string used for symbol fonts.
  244. INT m_iTTLastHit; // Last item with active tooltip.
  245. HFONT m_hfontSample; // Font for displaying sample in tooltip window.
  246. #endif // TOOLTIP_FONTSAMPLE
  247. HIMAGELIST m_hImageList;
  248. HIMAGELIST m_hImageListSmall;
  249. int m_iFirstBitmap;
  250. HMENU m_hmenuCur;
  251. IShellBrowser* m_psb;
  252. UINT m_uState; // Deactivated, active-focus, active-nofocus
  253. UINT m_idViewMode;
  254. UINT m_ViewModeReturn;
  255. UINT m_fFolderFlags;
  256. UINT m_nComboWid;
  257. int m_iSortColumn;
  258. int m_iSortLast;
  259. BOOL m_bSortAscending; // TRUE = ascending, FALSE = descending.
  260. CLICKMODE m_iViewClickMode; // CLICKMODE_SINGLE or CLICKMODE_DOUBLE.
  261. DWORD m_dwEffect; // Drag/drop effect.
  262. DWORD m_dwOldDADEffect; // Drag/drop effect for Win3.1-style drops.
  263. DWORD m_grfKeyState;
  264. BOOL m_bDragSource;
  265. int m_iHidden;
  266. HANDLE m_hAccel;
  267. BOOL m_bResizing; // Resizing the view window ?
  268. BOOL m_bUIActivated; // UI Activated through UIActivate( )
  269. // This flag is used to prevent processing
  270. // NM_SETFOCUS before UIActivate( ) has
  271. // been called.
  272. ULONG m_uSHChangeNotifyID; // Registered shell change notification ID.
  273. CFontIconHandler m_IconHandler;
  274. CFontManager *m_poFontManager;
  275. #ifdef WINNT
  276. BOOL m_bShowCompColor; // T = user want's alternate color for compressed items.
  277. #endif // WINNT
  278. BOOL m_bShowHiddenFonts;
  279. #ifdef USE_OWNERDRAW
  280. // DrawItem measurements for the listview.
  281. //
  282. UINT m_nItemHeight;
  283. #endif
  284. };
  285. #endif // __FONTVIEW_H__