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.

216 lines
8.2 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: fldbar.h
  5. //
  6. // PURPOSE: Defines the CFolderBar class
  7. //
  8. #ifndef __FLDBAR_H__
  9. #define __FLDBAR_H__
  10. #include "browser.h"
  11. #include "treeview.h"
  12. #include "conman.h"
  13. // Mouse Over Mode enum for DoMouseOver()
  14. #ifndef WIN16
  15. typedef enum MOMODE
  16. #else
  17. enum MOMODE
  18. #endif
  19. {
  20. MO_NORMAL = 0, // DoMouseOver called in response to WM_MOUSEMOVE
  21. MO_DRAGOVER, // in response to IDropTarget::DragEnter/DragOver
  22. MO_DRAGLEAVE, // in response to IDropTarget::DragLeave
  23. MO_DRAGDROP // in response to IDropTarget::Drop
  24. };
  25. class CFlyOutScope;
  26. class CFolderBar : public IDockingWindow,
  27. public IObjectWithSite,
  28. public IDropTarget,
  29. public IConnectionNotify
  30. {
  31. public:
  32. /////////////////////////////////////////////////////////////////////////
  33. // Construction and initialization
  34. CFolderBar();
  35. ~CFolderBar();
  36. HRESULT HrInit(IAthenaBrowser *pBrowser);
  37. /////////////////////////////////////////////////////////////////////////
  38. // IUnknown methods
  39. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  40. virtual STDMETHODIMP_(ULONG) AddRef(void);
  41. virtual STDMETHODIMP_(ULONG) Release(void);
  42. /////////////////////////////////////////////////////////////////////////
  43. // IDockingWindow methods
  44. virtual STDMETHODIMP GetWindow(HWND * lphwnd);
  45. virtual STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  46. virtual STDMETHODIMP ShowDW(BOOL fShow);
  47. virtual STDMETHODIMP CloseDW(DWORD dwReserved);
  48. virtual STDMETHODIMP ResizeBorderDW(LPCRECT prcBorder,
  49. IUnknown* punkToolbarSite,
  50. BOOL fReserved);
  51. /////////////////////////////////////////////////////////////////////////
  52. // IObjectWithSite methods
  53. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  54. virtual STDMETHODIMP GetSite(REFIID riid, LPVOID * ppvSite);
  55. /////////////////////////////////////////////////////////////////////////
  56. // IDropTarget methods
  57. virtual STDMETHODIMP DragEnter(IDataObject* pDataObject, DWORD grfKeyState,
  58. POINTL pt, DWORD* pdwEffect);
  59. virtual STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
  60. virtual STDMETHODIMP DragLeave(void);
  61. virtual STDMETHODIMP Drop(IDataObject* pDataObject, DWORD grfKeyState,
  62. POINTL pt, DWORD* pdwEffect);
  63. /////////////////////////////////////////////////////////////////////////
  64. // CFolderBar members
  65. HRESULT SetCurrentFolder(FOLDERID idFolder);
  66. void ScopePaneDied(void);
  67. void KillScopeCloseTimer(void);
  68. void Update(BOOL fDisplayNameChanged, BOOL fShowDropDownIndicator);
  69. void KillScopeDropDown(void);
  70. void SetScopeCloseTimer(void);
  71. void SetFolderText(LPCTSTR pszText);
  72. //IConnectionNotify
  73. virtual STDMETHODIMP OnConnectionNotify(CONNNOTIFY nCode, LPVOID pvData, CConnectionManager *pConMan);
  74. private:
  75. /////////////////////////////////////////////////////////////////////////
  76. // Drawing
  77. void InvalidateFolderName(void);
  78. void SetFolderName(LPCTSTR pszFolderName);
  79. void Recalc(HDC hDC, LPCRECT prcAvailableSpace, BOOL fSizeChange);
  80. BOOL FEnsureIcon(void);
  81. void GetFolderNameRect(LPRECT prc);
  82. BOOL FDropDownEnabled(void);
  83. HFONT GetFont(UINT idsFont, int nWeight = FW_NORMAL);
  84. HFONT GetFont(LPTSTR pszFace, LONG lSize, int nWeight = FW_NORMAL);
  85. int GetXChildIndicator(void);
  86. int GetYChildIndicator(void);
  87. void DoMouseOver(LPPOINT ppt, MOMODE moMode);
  88. void KillHoverTimer(void);
  89. void DoMouseClick(POINT pt, DWORD grfKeyState);
  90. HRESULT HrShowScopeFlyOut(void);
  91. /////////////////////////////////////////////////////////////////////////
  92. // Window methods
  93. static LRESULT CALLBACK FolderWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  94. LPARAM lParam);
  95. static LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  96. LPARAM lParam);
  97. void OnPaint(HWND hwnd);
  98. void OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags);
  99. void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags);
  100. void OnTimer(HWND hwnd, UINT id);
  101. /////////////////////////////////////////////////////////////////////////
  102. // Misc Data
  103. ULONG m_cRef; // Reference count
  104. FOLDERID m_idFolder; // Current Folder Id
  105. // Flags
  106. BOOL m_fShow; // TRUE if we're visible
  107. BOOL m_fRecalc; // TRUE if we should call Recalc() before painting
  108. BOOL m_fSmallFolderBar; // TRUE if we're smaller than big
  109. BOOL m_fHighlightIndicator; // TRUE if the mouse is over out button
  110. BOOL m_fHoverTimer; // TRUE if the hover timer is active
  111. BOOL m_fDropDownIndicator; // TRUE if the 'v' is beside the folder name
  112. // Interfaces we groove with
  113. IDockingWindowSite *m_pSite; // Site pointer
  114. IAthenaBrowser *m_pBrowser; // Browser that owns us
  115. // Handy handles
  116. HWND m_hwnd; // Our window
  117. HWND m_hwndFrame; // Our frame window
  118. HWND m_hwndParent; // Our parent's window
  119. HWND m_hwndScopeDropDown; // Handle of the drop down scope pane
  120. // Crayons, markers, paper, etc.
  121. HFONT m_hfFolderName; // Folder name font
  122. HFONT m_hfViewText; // View text font
  123. HICON m_hIconSmall; // Small Icon
  124. // Sizes etc. for drawing, sizing, and fun!
  125. int m_cyControl,
  126. m_dyChildIndicator,
  127. m_dyIcon,
  128. m_dyViewText,
  129. m_dyFolderName,
  130. m_cxFolderNameRight;
  131. RECT m_rcFolderName,
  132. m_rcFolderNamePlsu,
  133. m_rcViewText;
  134. UINT m_nFormatFolderName,
  135. m_nFormatViewText;
  136. // The text we display
  137. LPTSTR m_pszFolderName; // Folder Name
  138. int m_cchFolderName; // Size of m_pszFolderName
  139. LPTSTR m_pszViewText; // View text
  140. int m_cchViewText; // Size of m_pszViewText
  141. // Drag & Drop stuff
  142. IDataObject *m_pDataObject; // Pointer to the IDataObject being dragged over us
  143. IDropTarget *m_pDTCur;
  144. DWORD m_dwEffectCur;
  145. DWORD m_grfKeyState;
  146. };
  147. inline void CFolderBar::ScopePaneDied()
  148. { m_hwndScopeDropDown = NULL; InvalidateFolderName(); }
  149. class CFlyOutScope
  150. {
  151. friend CFolderBar;
  152. public:
  153. CFlyOutScope();
  154. ~CFlyOutScope();
  155. ULONG AddRef(void);
  156. ULONG Release(void);
  157. HRESULT HrDisplay(IAthenaBrowser *pBrowser, CFolderBar *pFolderBar, HWND hwndParent, HWND *phwndScope);
  158. void Destroy(void);
  159. protected:
  160. static LRESULT CALLBACK FlyWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  161. BOOL OnNotify(HWND hwnd, int idFrom, LPNMHDR pnmhdr);
  162. void OnNcDestroy(HWND hwnd);
  163. void OnPaint(HWND hwnd);
  164. void OnSize(HWND hwnd, UINT state, int cx, int cy);
  165. void OnDestroy(HWND hwnd);
  166. private:
  167. ULONG m_cRef;
  168. IAthenaBrowser *m_pBrowser;
  169. CFolderBar *m_pFolderBar;
  170. BOOL m_fResetParent;
  171. CTreeView *m_pTreeView;
  172. HWND m_hwnd;
  173. HWND m_hwndParent;
  174. HWND m_hwndTree;
  175. HWND m_hwndFolderBar;
  176. HWND m_hwndFocus;
  177. HWND m_hwndTreeParent;
  178. };
  179. #endif