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.

386 lines
13 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. #ifndef __BANDS_H__
  9. #define __BANDS_H__
  10. #include "tbinfo.h"
  11. #include "conman.h"
  12. interface INotify;
  13. #define BROWSERMENUBANDID 100
  14. #define BROWSERTOOLBANDID 101
  15. #define BROWSERBRANDBANDID 102
  16. #define BROWSERRULESBANDID 103
  17. #define NOTEMENUBANDID 100
  18. #define NOTETOOLBANDID 101
  19. #define NOTEBRANDBANDID 102
  20. #define MAX_BROWSER_BANDS 4
  21. #define MAX_NOTE_BANDS 3
  22. #define MAX_PARENT_TYPES 2
  23. #define MAX_BANDS 5
  24. #define BROWSER_BAND_VERSION 17
  25. #define NOTE_BAND_VERSION 15
  26. #define CIMLIST 2
  27. #define CBTYPE_NONE 0
  28. #define CBTYPE_BASE 100
  29. #define CBTYPE_BRAND 102
  30. #define CBTYPE_TOOLS 101
  31. #define CBTYPE_MENUBAND 100
  32. #define CBTYPE_RULESTOOLBAR 103
  33. #define TBSTATE_FULLTEXT 0x00000001
  34. #define TBSTATE_NOTEXT 0x00000002
  35. #define TBSTATE_PARTIALTEXT 0x00000004
  36. #define TBSTATE_NOBACKGROUND 0x00000008
  37. #define TBSTATE_ANIMATING 0x00000010
  38. #define TBSTATE_INMENULOOP 0X00000020
  39. #define TBSTATE_FIRSTFRAME 0x00000040
  40. #define TEXTSTATE_MASK 0x11111118
  41. #define LARGE_ICONS 0x00000001
  42. #define SMALL_ICONS 0x00000002
  43. //Parent Types
  44. #define PARENT_TYPE_BROWSER 0
  45. #define PARENT_TYPE_NOTE 1
  46. #define idDownloadBegin 100
  47. #define idDownloadEnd 101
  48. #define idStateChange 102
  49. #define idUpdateFolderList 103
  50. #define idUpdateCurrentFolder 104
  51. #define idSendToolMessage 105
  52. #define idBitmapChange 106
  53. #define idToggleButton 107
  54. #define idCustomize 108
  55. #define idNotifyFilterChange 109
  56. #define idIsFilterBarVisible 110
  57. // Dimensions of Coolbar Glyphs ..
  58. #define TB_BMP_CX_W2K 22
  59. #define TB_BMP_CX 24
  60. #define TB_BMP_CY 24
  61. #define TB_SMBMP_CX 16
  62. #define TB_SMBMP_CY 16
  63. // Max length of Button titles
  64. #define MAX_TB_TEXT_LENGTH 256
  65. #define MAX_TB_COMPRESSED_WIDTH 42
  66. #define MAX_TB_TEXT_ROWS_VERT 2
  67. #define MAX_TB_TEXT_ROWS_HORZ 1
  68. #define ANIMATION_TIMER 123
  69. // Child window id's
  70. #define idcCoolbarBase 2000
  71. #define idcSizer (idcCoolbarBase - 2)
  72. #define idcCoolbar (idcCoolbarBase - 1)
  73. #define idcToolbar (idcCoolbarBase + CBTYPE_TOOLS)
  74. #define idcBrand (idcCoolbarBase + CBTYPE_BRAND)
  75. // Number of Sites on the quick link bar and max number of toolbar buttons
  76. #define MAX_TB_BUTTONS 10
  77. // Indices for Toolbar imagelists
  78. enum {
  79. IMLIST_DEFAULT = 0,
  80. IMLIST_HOT,
  81. CIMLISTS
  82. };
  83. // BANDSAVE & - These structures are used to persist the state of the coolbar
  84. // COOLBARSAVE including the band order, visiblity, size, side, etc.
  85. typedef struct tagBANDSAVE {
  86. DWORD wID;
  87. DWORD dwStyle;
  88. DWORD cx;
  89. } BANDSAVE, *PBANDSAVE;
  90. typedef struct tagCOOLBARSTATECHANGE {
  91. UINT id;
  92. BOOL fEnable;
  93. } COOLBARSTATECHANGE, *LPCOOLBARSTATECHANGE;
  94. typedef struct tagCOOLBARBITMAPCHANGE {
  95. UINT id;
  96. UINT index;
  97. } COOLBARBITMAPCHANGE;
  98. typedef struct tagTOOLMESSAGE
  99. {
  100. UINT uMsg;
  101. WPARAM wParam;
  102. LPARAM lParam;
  103. LRESULT lResult;
  104. } TOOLMESSAGE;
  105. typedef struct InitBandInfo_t
  106. {
  107. DWORD dwVersion;
  108. DWORD cBands;
  109. BANDSAVE BandData[MAX_BANDS];
  110. }INITBANDINFO;
  111. typedef struct ImageListTypes_t
  112. {
  113. int Small;
  114. int High;
  115. int Low;
  116. }ImageListTypes;
  117. //small is 16 x 16 16 colors
  118. //hi is 20x 20 256 colors
  119. //lo is 20 x 20 16 colors
  120. #define MAX_IMAGELIST_TYPES 3
  121. #define IMAGELIST_TYPE_SMALL 0
  122. #define IMAGELIST_TYPE_HI 1
  123. #define IMAGELIST_TYPE_LO 2
  124. typedef struct ImageListStruct_t
  125. {
  126. DWORD cLists;
  127. int ImageListTable[MAX_IMAGELIST_TYPES];
  128. }ImageListStruct;
  129. enum
  130. {
  131. BRAND_SIZE_LARGE,
  132. BRAND_SIZE_SMALL,
  133. BRAND_SIZE_MINISCULE
  134. };
  135. class CBands : public IDockingWindow,
  136. public IObjectWithSite,
  137. public IConnectionNotify
  138. {
  139. public:
  140. /////////////////////////////////////////////////////////////////////////
  141. // Construction and initialization
  142. CBands();
  143. HRESULT HrInit(DWORD idBackground, HMENU hmenu, DWORD dwParentType);
  144. HRESULT ResetMenu(HMENU hmenu);
  145. protected:
  146. virtual ~CBands();
  147. public:
  148. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj);
  149. virtual STDMETHODIMP_(ULONG) AddRef(void);
  150. virtual STDMETHODIMP_(ULONG) Release(void);
  151. /////////////////////////////////////////////////////////////////////////
  152. // IDockingWindow methods
  153. virtual STDMETHODIMP GetWindow(HWND * lphwnd);
  154. virtual STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  155. virtual STDMETHODIMP ShowDW(BOOL fShow);
  156. virtual STDMETHODIMP CloseDW(DWORD dwReserved);
  157. virtual STDMETHODIMP ResizeBorderDW(LPCRECT prcBorder,
  158. IUnknown* punkToolbarSite,
  159. BOOL fReserved);
  160. /////////////////////////////////////////////////////////////////////////
  161. // IObjectWithSite methods
  162. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  163. virtual STDMETHODIMP GetSite(REFIID riid, LPVOID * ppvSite);
  164. /////////////////////////////////////////////////////////////////////////
  165. // IConnectionNotify
  166. virtual STDMETHODIMP OnConnectionNotify(CONNNOTIFY nCode, LPVOID pvData, CConnectionManager *pConMan);
  167. /////////////////////////////////////////////////////////////////////////
  168. // This allows the view to send commands etc. to the toolbar
  169. virtual STDMETHODIMP Invoke(DWORD id, LPVOID pv);
  170. HRESULT SetFolderType(FOLDERTYPE ftType);
  171. virtual STDMETHODIMP OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
  172. HRESULT Update();
  173. HRESULT UpdateViewState();
  174. HRESULT TranslateMenuMessage(MSG *lpmsg, LRESULT *lpresult);
  175. HRESULT IsMenuMessage(MSG *lpmsg);
  176. void SetNotRealSite();
  177. BOOL CheckForwardWinEvent(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
  178. HWND GetToolbarWnd();
  179. HWND GetRebarWnd();
  180. void HideToolbar(BOOL fVisible, DWORD dwBandID = CBTYPE_TOOLS);
  181. void SendSaveRestoreMessage(HWND hwnd, BOOL fSave);
  182. void ChangeImages();
  183. void TrackSliding(int x, int y);
  184. BOOL IsToolbarVisible();
  185. BOOL IsBandVisible(DWORD dwBandId);
  186. void CleanupImages(HWND hwnd);
  187. void CleanupImages();
  188. void SetIconSize(DWORD dw);
  189. void UpdateTextSettings(DWORD dwTextState);
  190. protected:
  191. void StartDownload();
  192. void StopDownload();
  193. /////////////////////////////////////////////////////////////////////////
  194. // Window procedure and message handlers
  195. static LRESULT CALLBACK SizableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  196. LPARAM lParam);
  197. virtual LRESULT OnNotify(HWND hwnd, LPARAM lparam);
  198. virtual void OnContextMenu(HWND hwndFrom, int xPos, int yPos);
  199. virtual LRESULT OnDropDown(HWND hwnd, LPNMHDR lpnmh);
  200. LRESULT OnGetButtonInfo(TBNOTIFY* ptbn);
  201. LRESULT OnGetInfoTip(LPNMTBGETINFOTIP lpnmtb);
  202. /////////////////////////////////////////////////////////////////////////
  203. // Used for animating the logo to show progress
  204. HRESULT ShowBrand(void);
  205. HRESULT HandleStaticLogos(BOOL fSmallBrand);
  206. HRESULT LoadBrandingBitmap(void);
  207. void DrawBranding(LPDRAWITEMSTRUCT lpdis);
  208. /////////////////////////////////////////////////////////////////////////
  209. // For sizing etc.
  210. BOOL SetMinDimensions(void);
  211. BOOL CompressBands(DWORD dwText);
  212. /////////////////////////////////////////////////////////////////////////
  213. // Initialization and persistance
  214. HRESULT CreateRebar(BOOL);
  215. void SaveSettings(void);
  216. void LoadBackgroundImage();
  217. HRESULT ValidateRetrievedData(INITBANDINFO *pSavedBandData);
  218. /////////////////////////////////////////////////////////////////////////
  219. // Toolbar Stuff
  220. HRESULT AddTools(PBANDSAVE pbs);
  221. void UpdateToolbarColors(void);
  222. HRESULT CreateMenuBand(PBANDSAVE pbs);
  223. HRESULT AddMenuBand(PBANDSAVE pbs);
  224. HMENU LoadDefaultContextMenu(BOOL *fVisible);
  225. BOOL _InitToolbar(HWND hwndToolbar);
  226. void _LoadStrings(HWND hwndToolbar, TOOLBAR_INFO *pti);
  227. BOOL _SetImages(HWND hwndToolbar, const int* imagelist);
  228. BOOL _LoadDefaultButtons(HWND hwndToolbar, TOOLBAR_INFO *pti);
  229. BOOL _ButtonInfoFromID(DWORD id, TBBUTTON *pButton, TOOLBAR_INFO *pti);
  230. HRESULT Update(HWND hwnd);
  231. //Rules/filters stuff
  232. HRESULT AddRulesToolbar(PBANDSAVE pbs);
  233. HRESULT AddComboBox();
  234. void UpdateFilters(RULEID rid);
  235. LRESULT HandleComboBoxNotifications(WPARAM wParam, LPARAM lParam);
  236. void FixComboBox(LPTSTR szMaxName);
  237. void InitRulesToolbar();
  238. void CleanupRulesToolbar();
  239. void FilterBoxFontChange();
  240. //Customize toolbar Stuff
  241. void _OnBeginCustomize(LPNMTBCUSTOMIZEDLG pnm);
  242. static INT_PTR CALLBACK _BtnAttrDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  243. void _PopulateComboBox(HWND hwnd, const int iResource[], UINT cResources);
  244. void _SetComboSelection(HWND hwnd, int iCurOption);
  245. void _SetDialogSelections(HWND hDlg);
  246. void _PopulateDialog(HWND hDlg);
  247. void _UpdateTextSettings(int ids);
  248. inline DWORD _GetTextState();
  249. inline DWORD _GetIconSize();
  250. void SetTextState(DWORD dw);
  251. inline void _ChangeSendReceiveText(int ids);
  252. void RecalcButtonWidths();
  253. void CalcIdealSize();
  254. /////////////////////////////////////////////////////////////////////////
  255. // Misc. stuff
  256. UINT m_cRef; // Ref count
  257. IDockingWindowSite *m_ptbSite;
  258. IOleCommandTarget *m_ptbSiteCT;
  259. LONG m_cxMaxButtonWidth;
  260. FOLDERTYPE m_ftType;
  261. const TOOLBAR_INFO *m_pTBInfo;
  262. /////////////////////////////////////////////////////////////////////////
  263. // Handy window handles to have around
  264. HWND m_hwndParent;
  265. HWND m_hwndTools;
  266. HWND m_hwndBrand;
  267. HWND m_hwndSizer;
  268. HWND m_hwndRebar;
  269. /////////////////////////////////////////////////////////////////////////
  270. // State variables
  271. INITBANDINFO *m_pSavedBandInfo;
  272. DWORD m_cSavedBandInfo;
  273. DWORD m_dwState;
  274. /////////////////////////////////////////////////////////////////////////
  275. // GDI Resources
  276. UINT m_idbBack; // Id of the background bitmap. Set by the subclasses.
  277. HBITMAP m_hbmBack; // Background bitmap
  278. HBITMAP m_hbmBrand;
  279. HIMAGELIST m_rghimlTools[CIMLISTS]; // These are for the default toolbar
  280. /////////////////////////////////////////////////////////////////////////
  281. // Used for animating the logo etc
  282. HPALETTE m_hpal;
  283. HDC m_hdc;
  284. int m_xOrg;
  285. int m_yOrg;
  286. int m_cxBmp;
  287. int m_cyBmp;
  288. int m_cxBrand;
  289. int m_cyBrand;
  290. int m_cxBrandExtent;
  291. int m_cyBrandExtent;
  292. int m_cyBrandLeadIn;
  293. COLORREF m_rgbUpperLeft;
  294. /////////////////////////////////////////////////////////////////////////
  295. // Used in resizing etc
  296. int m_xCapture;
  297. int m_yCapture;
  298. //Used by Menubands
  299. IShellMenu *m_pShellMenu;
  300. IDeskBand *m_pDeskBand;
  301. IMenuBand *m_pMenuBand;
  302. HMENU m_hMenu;
  303. IWinEventHandler *m_pWinEvent;
  304. HWND m_hwndMenuBand;
  305. //Used in new Bands
  306. DWORD m_dwParentType;
  307. BOOL m_fBrandLoaded;
  308. DWORD m_dwBrandSize;
  309. //rules stuff
  310. HWND m_hwndRulesToolbar;
  311. HWND m_hwndFilterCombo;
  312. RULEID m_DefaultFilterId;
  313. HFONT m_hComboBoxFont;
  314. //Customize
  315. DWORD m_dwToolbarTextState;
  316. DWORD m_dwIconSize;
  317. BOOL m_fDirty;
  318. DWORD m_dwPrevTextStyle;
  319. INotify *m_pTextStyleNotify;
  320. };
  321. #endif //__BANDS_H__