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.

341 lines
11 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: itbar.h
  5. //
  6. // PURPOSE: Defines the CCoolbar class.
  7. //
  8. /******************************************************
  9. Please do not make any changes to this file.
  10. Instead add the changes to tbbands.cpp and tbbands.h.
  11. This file will be deleted from the project soon.
  12. ******************************************************/
  13. #ifndef __ITBAR_H__
  14. #define __ITBAR_H__
  15. #include "conman.h"
  16. #include "mbcallbk.h"
  17. typedef struct tagTOOLBARARRAYINFO TOOLBARARRAYINFO;
  18. #define SIZABLECLASS TEXT("SizableRebar")
  19. // Length of the text under each quick links and toolbar buttton
  20. #define MAX_QL_TEXT_LENGTH 256
  21. #define BAND_NAME_LEN 32
  22. // Number of Sites on the quick link bar and max number of toolbar buttons
  23. #define MAX_TB_BUTTONS 10
  24. /*
  25. // Indicies for the Coolbar bar
  26. #define CBTYPE_NONE 0
  27. #define CBTYPE_BRAND 1
  28. #define CBTYPE_TOOLS 2
  29. #define CBTYPE_MENUBAND 3
  30. #define CBANDS 3
  31. */
  32. #define CBANDS 3
  33. // Identify the sides of the window
  34. typedef enum {
  35. COOLBAR_TOP = 0,
  36. COOLBAR_LEFT,
  37. COOLBAR_BOTTOM,
  38. COOLBAR_RIGHT,
  39. COOLBAR_SIDEMAX
  40. } COOLBAR_SIDE;
  41. #define VERTICAL(side) (BOOL)(((side) == COOLBAR_LEFT) || ((side) == COOLBAR_RIGHT))
  42. #define COOLBAR_VERSION 0x03
  43. #define MAX_TB_COMPRESSED_WIDTH 42
  44. #define MAX_TB_TEXT_ROWS_VERT 2
  45. #define MAX_TB_TEXT_ROWS_HORZ 1
  46. // Dimensions of Coolbar Glyphs ..
  47. #define TB_BMP_CX_W2K 22
  48. #define TB_BMP_CX 24
  49. #define TB_BMP_CY 24
  50. #define TB_SMBMP_CX 16
  51. #define TB_SMBMP_CY 16
  52. // Max length of Button titles
  53. #define MAX_TB_TEXT_LENGTH 256
  54. // Indices for Toolbar imagelists
  55. enum {
  56. IMLIST_DEFAULT = 0,
  57. IMLIST_HOT,
  58. CIMLISTS
  59. };
  60. void InitToolbar(const HWND hwnd, const int cHiml, HIMAGELIST *phiml,
  61. UINT nBtns, const TBBUTTON *ptbb,
  62. const TCHAR *pStrings,
  63. const int cxImg, const int cyImg, const int cxMax,
  64. const int idBmp, const BOOL fCompressed,
  65. const BOOL fVertical);
  66. void LoadGlyphs(const HWND hwnd, const int cHiml, HIMAGELIST *phiml, const int cx, const int idBmp);
  67. BOOL LoadToolNames(const UINT *rgIds, const UINT cIds, LPTSTR szTools);
  68. // These are the various states the coolbar can have
  69. #define CBSTATE_HIDDEN 0x00000001
  70. #define CBSTATE_COMPRESSED 0x00000002
  71. #define CBSTATE_NOBACKGROUND 0x00000004
  72. #define CBSTATE_ANIMATING 0x00000008
  73. #define CBSTATE_COLORBUTTONS 0x00000010
  74. #define CBSTATE_INMENULOOP 0x00000020
  75. #define CBSTATE_FIRSTFRAME 0x00000040
  76. // BANDSAVE & - These structures are used to persist the state of the coolbar
  77. // COOLBARSAVE including the band order, visiblity, size, side, etc.
  78. typedef struct tagBANDSAVE {
  79. DWORD wID;
  80. DWORD dwStyle;
  81. DWORD cx;
  82. } BANDSAVE, *PBANDSAVE;
  83. typedef struct tagCOOLBARSAVE {
  84. DWORD dwVersion;
  85. DWORD dwState;
  86. COOLBAR_SIDE csSide;
  87. BANDSAVE bs[CBANDS];
  88. } COOLBARSAVE, *PCOOLBARSAVE;
  89. // These structs are used for the CCoolbar::Invoke() member. They allow
  90. // the caller to specify more information for particular commands.
  91. typedef struct tagCOOLBARSTATECHANGE {
  92. UINT id;
  93. BOOL fEnable;
  94. } COOLBARSTATECHANGE, *LPCOOLBARSTATECHANGE;
  95. typedef struct tagCOOLBARBITMAPCHANGE {
  96. UINT id;
  97. UINT index;
  98. } COOLBARBITMAPCHANGE;
  99. typedef struct tagUPDATEFOLDERNAME {
  100. LPTSTR pszServer;
  101. LPTSTR pszGroup;
  102. } UPDATEFOLDERNAME, *LPUPDATEFOLDERNAME;
  103. typedef struct tagTOOLMESSAGE
  104. {
  105. UINT uMsg;
  106. WPARAM wParam;
  107. LPARAM lParam;
  108. LRESULT lResult;
  109. } TOOLMESSAGE;
  110. void SendSaveRestoreMessage(HWND hwnd, const TOOLBARARRAYINFO *ptai, BOOL fSave);
  111. class CCoolbar : public IDockingWindow,
  112. public IObjectWithSite,
  113. public IConnectionNotify
  114. {
  115. public:
  116. /////////////////////////////////////////////////////////////////////////
  117. // Construction and initialization
  118. CCoolbar();
  119. HRESULT HrInit(DWORD idBackground, HMENU hmenu);
  120. protected:
  121. virtual ~CCoolbar();
  122. public:
  123. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj);
  124. virtual STDMETHODIMP_(ULONG) AddRef(void);
  125. virtual STDMETHODIMP_(ULONG) Release(void);
  126. /////////////////////////////////////////////////////////////////////////
  127. // IDockingWindow methods
  128. virtual STDMETHODIMP GetWindow(HWND * lphwnd);
  129. virtual STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  130. virtual STDMETHODIMP ShowDW(BOOL fShow);
  131. virtual STDMETHODIMP CloseDW(DWORD dwReserved);
  132. virtual STDMETHODIMP ResizeBorderDW(LPCRECT prcBorder,
  133. IUnknown* punkToolbarSite,
  134. BOOL fReserved);
  135. /////////////////////////////////////////////////////////////////////////
  136. // IObjectWithSite methods
  137. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  138. virtual STDMETHODIMP GetSite(REFIID riid, LPVOID * ppvSite);
  139. /////////////////////////////////////////////////////////////////////////
  140. // IConnectionNotify
  141. virtual STDMETHODIMP OnConnectionNotify(CONNNOTIFY nCode, LPVOID pvData, CConnectionManager *pConMan);
  142. /////////////////////////////////////////////////////////////////////////
  143. // This allows the view to send commands etc. to the toolbar
  144. virtual STDMETHODIMP Invoke(DWORD id, LPVOID pv);
  145. HRESULT SetFolderType(FOLDERTYPE ftType);
  146. virtual STDMETHODIMP OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
  147. virtual STDMETHODIMP OnInitMenuPopup(HMENU hMenu);
  148. BOOL GetText(void) { return !IsFlagSet(CBSTATE_COMPRESSED); }
  149. COOLBAR_SIDE GetSide(void) { return (m_csSide); }
  150. void SetSide(COOLBAR_SIDE csSide);
  151. void SetText(BOOL fText);
  152. HRESULT Update(void);
  153. HRESULT TranslateMenuMessage(MSG *lpmsg, LRESULT *lpresult);
  154. HRESULT IsMenuMessage(MSG *lpmsg);
  155. void SetNotRealSite();
  156. BOOL CheckForwardWinEvent(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
  157. protected:
  158. void StartDownload();
  159. void StopDownload();
  160. /////////////////////////////////////////////////////////////////////////
  161. // Window procedure and message handlers
  162. static LRESULT CALLBACK SizableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  163. LPARAM lParam);
  164. virtual LRESULT OnNotify(HWND hwnd, LPARAM lparam);
  165. virtual void OnContextMenu(HWND hwndFrom, int xPos, int yPos);
  166. virtual LRESULT OnDropDown(HWND hwnd, LPNMHDR lpnmh);
  167. LRESULT OnGetButtonInfo(TBNOTIFY* ptbn);
  168. /////////////////////////////////////////////////////////////////////////
  169. // Used for animating the logo to show progress
  170. HRESULT ShowBrand(void);
  171. HRESULT LoadBrandingBitmap(void);
  172. void DrawBranding(LPDRAWITEMSTRUCT lpdis);
  173. /////////////////////////////////////////////////////////////////////////
  174. // For sizing etc.
  175. BOOL SetMinDimensions(void);
  176. BOOL CompressBands(BOOL fCompress);
  177. void TrackSlidingX(int x);
  178. void TrackSlidingY(int y);
  179. BOOL ChangeOrientation();
  180. /////////////////////////////////////////////////////////////////////////
  181. // Initialization and persistance
  182. HRESULT CreateRebar(BOOL);
  183. void SaveSettings(void);
  184. /////////////////////////////////////////////////////////////////////////
  185. // Toolbar Stuff
  186. HRESULT AddTools(PBANDSAVE pbs);
  187. void InitToolbar();
  188. void UpdateToolbarColors(void);
  189. void _UpdateWorkOffline(DWORD cmdf);
  190. HRESULT CreateMenuBand(PBANDSAVE pbs);
  191. HRESULT AddMenuBand(PBANDSAVE pbs);
  192. void HideToolbar(DWORD dwBandID);
  193. void HandleCoolbarPopup(UINT xPos, UINT yPos);
  194. /////////////////////////////////////////////////////////////////////////
  195. // Misc. stuff
  196. UINT m_cRef; // Ref count
  197. IDockingWindowSite *m_ptbSite;
  198. LONG m_cxMaxButtonWidth;
  199. FOLDERTYPE m_ftType;
  200. const TOOLBARARRAYINFO *m_ptai;
  201. BOOL m_fSmallIcons;
  202. /////////////////////////////////////////////////////////////////////////
  203. // Handy window handles to have around
  204. HWND m_hwndParent;
  205. HWND m_hwndTools;
  206. HWND m_hwndBrand;
  207. HWND m_hwndSizer;
  208. HWND m_hwndRebar;
  209. /////////////////////////////////////////////////////////////////////////
  210. // State variables
  211. COOLBARSAVE m_cbsSavedInfo;
  212. COOLBAR_SIDE m_csSide;
  213. DWORD m_dwState;
  214. /////////////////////////////////////////////////////////////////////////
  215. // GDI Resources
  216. UINT m_idbBack; // Id of the background bitmap. Set by the subclasses.
  217. HBITMAP m_hbmBack; // Background bitmap
  218. HBITMAP m_hbmBrand;
  219. HIMAGELIST m_rghimlTools[CIMLISTS]; // These are for the default toolbar
  220. /////////////////////////////////////////////////////////////////////////
  221. // Used for animating the logo etc
  222. HPALETTE m_hpal;
  223. HDC m_hdc;
  224. int m_xOrg;
  225. int m_yOrg;
  226. int m_cxBmp;
  227. int m_cyBmp;
  228. int m_cxBrand;
  229. int m_cyBrand;
  230. int m_cxBrandExtent;
  231. int m_cyBrandExtent;
  232. int m_cyBrandLeadIn;
  233. COLORREF m_rgbUpperLeft;
  234. /////////////////////////////////////////////////////////////////////////
  235. // Used in resizing etc
  236. int m_xCapture;
  237. int m_yCapture;
  238. //Used by Menubands
  239. IShellMenu *m_pShellMenu;
  240. IDeskBand *m_pDeskBand;
  241. IMenuBand *m_pMenuBand;
  242. HMENU m_hMenu;
  243. CMenuCallback *m_mbCallback;
  244. IWinEventHandler *m_pWinEvent;
  245. HWND m_hwndMenuBand;
  246. };
  247. // DOUTL levels
  248. #define DM_TBSITE 0
  249. #define DM_TBCMD 0
  250. #define DM_TBREF TF_SHDREF
  251. #define DM_LAYOUT 0
  252. #define FCIDM_BRANDING 12345
  253. #define ANIMATION_TIMER 123
  254. #define ANIMATION_DELTA_X 25
  255. #define ANIMATION_DELTA_Y 5
  256. // flags for _dwURLChangeFlags
  257. #define URLCHANGED_TYPED 0x0001
  258. #define URLCHANGED_SELECTEDFROMCOMBO 0x0002
  259. #define idDownloadBegin 100
  260. #define idDownloadEnd 101
  261. #define idStateChange 102
  262. #define idUpdateFolderList 103
  263. #define idUpdateCurrentFolder 104
  264. #define idSendToolMessage 105
  265. #define idBitmapChange 106
  266. #define idToggleButton 107
  267. #define idCustomize 108
  268. // Child window id's
  269. #define idcCoolbarBase 2000
  270. #define idcSizer (idcCoolbarBase - 2)
  271. #define idcCoolbar (idcCoolbarBase - 1)
  272. #define idcToolbar (idcCoolbarBase + CBTYPE_TOOLS)
  273. #define idcBrand (idcCoolbarBase + CBTYPE_BRAND)
  274. // Coolbar drawing states
  275. #define DRAW_NOBACKGROUND 0x1
  276. #define DRAW_COLORBUTTONS 0x2
  277. // Folder switching timer
  278. #define FOLDER_SWITCHTIMER 200
  279. #define FOLDER_SWITCHDELAY 400
  280. #endif // __ITBAR_H__