aduiPaletteSet.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // Purpose:
  12. //
  13. // A palette set is a frame which holds one or more palettes.
  14. //
  15. /////////////////////////////////////////////////////////////////////////////
  16. #ifndef _ADUI_PALETTE_SET_H_
  17. #define _ADUI_PALETTE_SET_H_
  18. #include <afxtempl.h>
  19. #include "AcColorThemeEnum.h"
  20. class CAdUiPalette;
  21. class CAdUiImpPaletteSet;
  22. // Palette Set Styles
  23. #define PSS_AUTO_ROLLUP 0x00000002 // Support automatic roll-up when the pin is up.
  24. #define PSS_PROPERTIES_MENU 0x00000004 // Display properties button in the caption to edit palette properties.
  25. #define PSS_CLOSE_BUTTON 0x00000008 // Support "close" button in caption
  26. #define PSS_EDIT_NAME 0x00000010 // Support editing of palette set name through in-place editing
  27. #define PSS_SNAP 0x00000020 // Support snapping to application, screen, and other palette sets
  28. #define PSS_SINGLE_PALETTE_TAB 0x00000040 // Tab visibility for palette set containing a single palette.
  29. #define PSS_USE_SINGLE_PALETTE_TAB_NAME 0x00000080 // Use palette name in paletee set title bar for single palette set.
  30. #define PSS_SINGLE_ROW_HORZ_DOCK 0x00000200 // INTERNAL USE
  31. #define PSS_NOTIFY 0x00000400 // INTERNAL USE
  32. #define PSS_SINGLE_ROW_NOVERTRESIZE 0x00000800 // INTERNAL USE
  33. #define PSS_SINGLE_COL_VERT_DOCK 0x00001000 // INTERNAL USE
  34. #define PSS_NO_ROLLUP_BUTTON 0x00002000 // Do not display Roll Up botton in the caption
  35. #define PSS_NO_ICON 0x00004000 // Do not display Icon in the caption
  36. #define PSS_NO_TITLEBAR 0x00008000 // INTERNAL USE
  37. #define PSS_AUTO_ROLLUP_PAUSE_ON_MODAL_DIALOG 0x00010000 // INERNAL USE
  38. // INTERNAL USE ONLY
  39. // Palette Set Hit Test constants
  40. #define ADUI_HT_CAPTION 1 // Title bar
  41. #define ADUI_HT_OPTION_BUTTON 2 // Option button
  42. #define ADUI_HT_ROLLUP_BUTTON 3 // Roll up button
  43. #define ADUI_HT_CLOSE_BUTTON 4 // Close button
  44. #define ADUI_HT_GRIP 5 // Grip area
  45. #define ADUI_HT_TABS 6 // One of the tabs
  46. #define ADUI_HT_PALETTE 7 // Client area of the palette set which is also the palette area.
  47. #define ADUI_HT_TAB_OVERFLOW 8 // Tab overflow indicator
  48. #define ADUI_HT_PALETTESET 9 // Client area of the palette set which is NOT also the palette area.
  49. #ifndef _ADESK_MAC_
  50. #pragma warning(push)
  51. #pragma warning(disable : 4275)
  52. /////////////////////////////////////////////////////////////////////////////
  53. //
  54. // class CAdUiPaletteSet
  55. //
  56. class ADUI_PORT CAdUiPaletteSet : public CAdUiDockControlBar
  57. {
  58. friend class CAdUiImpPaletteSet;
  59. friend class CAdUiPaletteSetDockFrame;
  60. friend class CAdUiAnchorBar;
  61. friend class CAdUiPalette;
  62. friend class CAdUiDockDragContext;
  63. DECLARE_DYNCREATE(CAdUiPaletteSet);
  64. public:
  65. CAdUiPaletteSet(int nStyle = 0);
  66. virtual ~CAdUiPaletteSet();
  67. BOOL Create(LPCTSTR strTitle, DWORD dwStyle, const RECT &rect,
  68. CWnd *pwndParent,
  69. DWORD dwPaletteSetStyle = PSS_PROPERTIES_MENU | PSS_AUTO_ROLLUP | PSS_CLOSE_BUTTON | PSS_SNAP);
  70. // Returns the palette set style.
  71. DWORD GetPaletteSetStyle();
  72. // Sets the palette set style. dwStyle is a bit flag.
  73. void SetPaletteSetStyle(DWORD dwStyle);
  74. // Style access methods
  75. BOOL AutoRollupStyle();
  76. BOOL PropertiesMenuStyle();
  77. BOOL CloseButtonStyle();
  78. BOOL SinglePaletteTabStyle();
  79. BOOL UseSinglePaletteTabNameStyle();
  80. BOOL EditNameStyle();
  81. BOOL SnapStyle();
  82. BOOL ShowRollupButtonStyle();
  83. BOOL ShowIconStyle();
  84. // Returns the palette set name.
  85. CString GetName();
  86. // Sets the palette set name.
  87. BOOL SetName(LPCTSTR pszName);
  88. /// <summary>
  89. /// Gets the theme being used by the palette set
  90. /// </summary>
  91. /// <returns>
  92. /// The pointer to the CAdUiTheme instance being used
  93. /// </returns>
  94. CAdUiTheme* GetTheme();
  95. /// <summary>
  96. /// Sets the theme to be used by the palette set
  97. /// </summary>
  98. /// <param name="pTheme">
  99. /// The pointer to the CAdUiTheme instance
  100. /// </param>
  101. /// <returns>
  102. /// The current theme being used by the palette set
  103. /// </returns>
  104. CAdUiTheme* SetTheme(CAdUiTheme* pTheme);
  105. // Returns the current opacity.
  106. int GetOpacity() const;
  107. // Sets the opacity of the palette set. Value Range: 0 to 100.
  108. // 0 is fully transparent and 100 is opaque.
  109. BOOL SetOpacity(int nOpacity);
  110. int GetRolloverOpacity() const;
  111. BOOL SetRolloverOpacity(int nOpacity);
  112. static int GetGlobalOpacity();
  113. static BOOL SetGlobalOpacity(int nOpacity);
  114. static int GetGlobalRolloverOpacity ();
  115. static BOOL SetGlobalRolloverOpacity(int nOpacity);
  116. static BOOL IsGlobalOpacitiesApplied();
  117. static void ApplyGlobalOpacities(BOOL bApply);
  118. // Returns the currently active palette.
  119. CAdUiPalette* GetActivePalette();
  120. int GetActivePaletteTabIndex();
  121. // Sets the specified palette as active
  122. BOOL SetActivePalette (CAdUiPalette* pPalette);
  123. BOOL SetActivePalette (int nPaletteIndex);
  124. // Enables auto roll-up so that the palette set is collapsed
  125. // to display only the title bar until the user passes mouse
  126. // over the title bar. If bSet is false disables auto roll-up
  127. // and the palette set is always shown.
  128. BOOL SetAutoRollup(BOOL bSet = TRUE);
  129. // Returns TRUE if auto roll-up is enabled.
  130. BOOL GetAutoRollup();
  131. // Trigger a roll out of the palette set, if auto-rollup is on,
  132. // and the palette set is not docked
  133. // if bTmp is true, we use the holdopen delay value before rolling back in
  134. void RollOut(bool bDelay = false);
  135. // Trigger a roll up of the palette set, if auto-rollup is on,
  136. // and the palette set is not docked
  137. void RollUp();
  138. //Appends the palette to the palette set
  139. int AddPalette(CAdUiPalette* pPalette);
  140. // Inserts a palette at the specified (zero-based) index.
  141. int InsertPalette(int iIndex, CAdUiPalette* pPalette);
  142. // Removes the palette from the palette set
  143. BOOL RemovePalette(CAdUiPalette* pPalette);
  144. BOOL RemovePalette(int nPaletteIndex);
  145. // Returns the number of palettes in the palette set.
  146. int GetPaletteCount();
  147. // Retrieve a palette associated with a particular tab index
  148. CAdUiPalette * GetPalette(int nIndex);
  149. // Find the tab index of a palette. Returns -1 if the palette is not in
  150. // this palette set.
  151. int GetTabIndex(CAdUiPalette* pPalette);
  152. // Retrieve the full size of the palette set window rectangle (even if it's
  153. // currently rolled-up, this will return the full "unrolled" size
  154. void GetFullRect(CRect & rect);
  155. // Returns the non-client size
  156. BOOL GetNonClientSize(CSize& size); // INTERNAL USE ONLY
  157. // Loads the data from xml file
  158. virtual BOOL Load(IUnknown* pUnk);
  159. // Saves the data to xml file
  160. virtual BOOL Save(IUnknown* pUnk);
  161. // Returns TRUE if the palette set window is "rolled up"
  162. BOOL RolledUp();
  163. // AdUiTitleBarLocation
  164. typedef enum {
  165. kLeft = 0,
  166. kRight
  167. } AdUiTitleBarLocation ;
  168. // Returns enum specifiying title bar location
  169. AdUiTitleBarLocation TitleBarLocation();
  170. // Set the title bar location
  171. void SetTitleBarLocation(AdUiTitleBarLocation loc);
  172. // Notify that the title bar location (left or right) has been updated.
  173. virtual void TitleBarLocationUpdated(AdUiTitleBarLocation /*newLoc*/) {}
  174. // Update palette set's tab display (like when a palette name is updated)
  175. void UpdateTabs();
  176. // Enable docking
  177. void EnableDocking(DWORD dwDockStyle);
  178. // Called when the editing of the palette set name using in-place editing is completed
  179. // Return of TRUE means the name is valid.
  180. virtual BOOL NameEditValidation(CEdit* pEdit);
  181. // Retrieve the font for the palette set window. (Not necessarily the same as
  182. // CWnd::GetFont() due to the palette set's use of themes.)
  183. CFont * GetWindowFont();
  184. //CAdUiAnchorBar* AnchorDock();
  185. protected:
  186. // In-place editing of palette set name.
  187. virtual void EditName();
  188. // Determines which part of the palette set, if any, is at a specified position.
  189. BOOL HitTest(CPoint pt, UINT& nFlag, DWORD& dwData);
  190. // Called by the palette set before the context menu of the palette set is
  191. // displayed in response to right clicking on the palette set, to give you
  192. // the opportunity to add your own context menu options, and/or to remove
  193. // the existing default menu options. If nHitFlag indicates a tab area
  194. // hit, then the third parameter will provide the palette index of the tab
  195. // which has been clicked on.
  196. virtual BOOL AddContextMenuItems(CMenu * pMenu, int nHitFlag, int nRightClkTab = 0);
  197. // Return FALSE to indicate that the palette should not give up focus,
  198. // TRUE to indicate that the palette doesn't need focus.
  199. virtual bool CanFrameworkTakeFocus();
  200. // Called by the palette set framework to determine size constraints.
  201. // Override these methods to provide minimum and maximum palette set sizes.
  202. virtual void GetMinimumSize(CSize& size);
  203. virtual void GetMaximumSize(CSize& size);
  204. // Methods that a derived palette set class can override to reserve vertical space
  205. // in the palette set client area for palette set use (thereby decreasing the
  206. // palette set client area given to the palettes.
  207. virtual int GetTopReservedHeight();
  208. virtual int GetBottomReservedHeight();
  209. // Derived palette set class can override this method to get notification
  210. // when a palette is added
  211. virtual void PaletteAdded(CAdUiPalette* /*pPalette*/) {}
  212. // Derived palette set class can override this method to get notification
  213. // when a palette is removed
  214. virtual void PaletteRemoved(CAdUiPalette* /*pPalette*/) {}
  215. // Derived palette set class can override this method to get notification
  216. // when a palette is activated
  217. virtual void PaletteActivated(CAdUiPalette* /*pActivated*/,
  218. CAdUiPalette* /*pDeactivated*/) {}
  219. // Derived palette set class can override this method to get notification
  220. // when the "AutoRollup" state changes
  221. virtual void AutoRollupChanged(BOOL /*bAutoRollupIsOn*/) {}
  222. virtual void OnTabDrag(CPtrArray & arrayPalettes); // INTERNAL USE ONLY
  223. // When a palette set is docked, a "grabber bar" is drawn within the window's
  224. // client area. This can cause problems for positioning palette set elements.
  225. // Use this method to get the adjusted palette set client rect. For example,
  226. // if the palette set is docked on the side of the application frame, this method
  227. // will return a rect whose top coordinate is 13 rather than 0. Palette set
  228. // elements should be positioned within this "adjusted" client rect.
  229. void GetAdjustedClientRect(CRect & rect);
  230. /// <summary>
  231. /// Virtual method that receives the theme modification event.
  232. /// </summary>
  233. /// <param name="element">
  234. /// A index of the theme element that was modified.
  235. /// </param>
  236. /// <remarks>
  237. /// This method is also called when the theme uses the active theme colors
  238. /// and the active theme is changed. In that case, element = kUnknownElements
  239. /// </remarks>
  240. virtual void ThemeModified(AdUiThemeElement element);
  241. virtual void OnContextMenu(CWnd* pWnd, CPoint pos); // INTERNAL USE ONLY
  242. /// <summary>
  243. /// Helper method to inform all palettes of a theme change; should be called from
  244. /// overridden ThemeModified() if the palette set wishes to inform the palettes
  245. /// it owns of a theme change
  246. /// </summary>
  247. void SendThemeModifiedToPalettes();
  248. //{{AFX_VIRTUAL(CAdUiPaletteSet)
  249. public:
  250. virtual BOOL PreTranslateMessage(MSG * msg);
  251. //}}AFX_VIRTUAL
  252. static bool SetGlobalTransparency(UINT flag); // INTERNAL USE ONLY
  253. static UINT GetGlobalTransparency(); // INTERNAL USE ONLY
  254. bool SetAllowTransparency(CString key, bool bDefault); // INTERNAL USE ONLY
  255. void OnTogglePin(); // INTERNAL USE ONLY
  256. /// <summary>
  257. /// Returns the icon for the current palette theme and the specified size.
  258. /// </summary>
  259. ///
  260. /// <param name="bBigIcon">
  261. /// Specifies whether the desired icon is for the large or
  262. /// small size. Defaults to the small size.
  263. /// </param>
  264. ///
  265. /// <returns>
  266. /// Returns the icon for the current palette theme and specified size.
  267. /// </returns>
  268. ///
  269. HICON GetThemedIcon(bool bBigIcon = false) const;
  270. /// <summary>
  271. /// Sets the icon for the specified theme and size.
  272. /// </summary>
  273. ///
  274. /// <param name="hIcon">
  275. /// The specified icon.
  276. /// </param>
  277. /// <param name="theme">
  278. /// Specifies the theme to which the specified icon applies.
  279. /// Defaults to eAcadLightTheme.
  280. /// </param>
  281. /// <param name="bBigIcon">
  282. /// Specifies whether the specified icon applies to the large or
  283. /// small size. Defaults to the small size.
  284. /// </param>
  285. ///
  286. /// <returns>
  287. /// Returns the previous value of the specified icon.
  288. /// </returns>
  289. ///
  290. HICON SetThemedIcon(HICON hIcon, AcColorThemeEnum theme = eAcadLightTheme, bool bBigIcon = false);
  291. protected:
  292. //{{AFX_MSG(CAdUiPaletteSet)
  293. afx_msg int OnCreate(LPCREATESTRUCT lpCs);
  294. afx_msg void OnSize(UINT nType, int cx, int cy);
  295. afx_msg BOOL OnEraseBkgnd(CDC *pdc);
  296. afx_msg void OnLButtonDown(UINT nFlags, CPoint pt);
  297. afx_msg void OnLButtonUp(UINT nFlags, CPoint pt);
  298. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint pt);
  299. afx_msg void OnMouseMove(UINT nFlags, CPoint pt);
  300. afx_msg LRESULT OnNcCalcSize(WPARAM wParam, LPARAM lParam);
  301. #if _MSC_VER<1400
  302. afx_msg UINT OnNcHitTest(CPoint point);
  303. #else
  304. afx_msg LRESULT OnNcHitTest(CPoint point);
  305. #endif
  306. afx_msg void OnNcPaint();
  307. afx_msg void OnPaint();
  308. afx_msg void OnSetFocus(CWnd * pOldWnd);
  309. afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );
  310. afx_msg void OnWindowPosChanging (WINDOWPOS* lpwndpos);
  311. afx_msg void OnWindowPosChanged (WINDOWPOS FAR* lpwndpos);
  312. afx_msg LRESULT OnFloatStatus(WPARAM wParam, LPARAM lParam); // INTERNAL USE ONLY
  313. afx_msg LRESULT OnBeginNameEdit(WPARAM, LPARAM); // INTERNAL USE ONLY
  314. afx_msg LRESULT OnEndNameEdit(WPARAM, LPARAM); // INTERNAL USE ONLY
  315. afx_msg void OnMenuClose(); // INTERNAL USE ONLY
  316. afx_msg void OnMenuMove(); // INTERNAL USE ONLY
  317. afx_msg void OnMenuSize(); // INTERNAL USE ONLY
  318. afx_msg void OnOptionTranslucency(); // INTERNAL USE ONLY
  319. afx_msg void EditPaletteName(); // INTERNAL USE ONLY
  320. afx_msg LRESULT OnGetPaletteCount(WPARAM wParam,LPARAM lParam);// INTERNAL USE ONLY
  321. afx_msg LRESULT OnGetPaletteName(WPARAM wParam,LPARAM lParam);// INTERNAL USE ONLY
  322. afx_msg LRESULT OnSetPaletteActive(WPARAM wParam,LPARAM lParam);// INTERNAL USE ONLY
  323. //}}AFX_MSG
  324. DECLARE_MESSAGE_MAP()
  325. protected:
  326. CAdUiImpPaletteSet * m_pImpPS;
  327. };
  328. #pragma warning(pop)
  329. #endif // _ADESK_MAC_
  330. #endif // _ADUI_PALETTE_SET_H_