aduiPalette.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. // Palette is a borderless window which holds the actual contents of a
  14. // palette. The palette can be tool palette, property palette, command line
  15. // palette, etc. The palette is always embedded as a child window in the
  16. // client area of a palette set and it is never displayed alone. This class
  17. // implements the basic functions of a palette and serves as the base class
  18. // for specific palettes. The specific palettes should derive from this
  19. // class and implement the required functionality.
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _ADUI_PALETTE_H_
  23. #define _ADUI_PALETTE_H_
  24. #include "aduiDropTarget.h"
  25. class CAdUiPaletteSet;
  26. // Palette Styles
  27. #define PS_EDIT_NAME 0x00000001 // Support editing of palette set name through in-place editing
  28. /////////////////////////////////////////////////////////////////////////////
  29. //
  30. // class CAdUiPalette
  31. //
  32. #ifndef _ADESK_MAC_
  33. #pragma warning(push)
  34. #pragma warning(disable : 4275)
  35. class ADUI_PORT CAdUiPalette : public CWnd
  36. {
  37. DECLARE_DYNAMIC(CAdUiPalette)
  38. public:
  39. CAdUiPalette();
  40. virtual ~CAdUiPalette();
  41. // Creates the palette window
  42. BOOL Create(DWORD dwStyle, LPCTSTR pszName, CAdUiPaletteSet* pParent,
  43. DWORD dwPaletteStyle = 0);
  44. // Virtual method for "On demand" creation of palette windows. Return TRUE for
  45. // successful creation.
  46. virtual BOOL Create(CAdUiPaletteSet* pParent);
  47. // Returns the palette style
  48. DWORD GetPaletteStyle();
  49. // Sets the palette style.
  50. void SetPaletteStyle(DWORD dwStyle);
  51. // Style access methods
  52. BOOL EditNameStyle()
  53. { return m_dwStyle & PS_EDIT_NAME; }
  54. // Load the data from xml.
  55. virtual BOOL Load(IUnknown* pUnk);
  56. // Save the data to xml.
  57. virtual BOOL Save(IUnknown* pUnk);
  58. // Returns the palette set back pointer.
  59. CAdUiPaletteSet* GetPaletteSet() { return m_pPaletteSet; };
  60. // Sets the palette set back pointer.
  61. void SetPaletteSet(CAdUiPaletteSet* pSet);
  62. // Called by the palette set when the palette is made active
  63. virtual void OnSetActive();
  64. // Called by the palette set when this palette loses its current
  65. // palette state and some other palette is going to be current
  66. // palette. Override this member function to perform tasks when
  67. // a palette is de-activated. The override of this member function
  68. // should call the base class version before any other processing
  69. // is done.
  70. virtual BOOL OnKillActive();
  71. __declspec(deprecated) virtual CString GetClassNameW();
  72. // Returns the name of the palette.
  73. CString GetName();
  74. // Sets the name of the palette.
  75. void SetName(CString strName);
  76. // Gets the minimum size of the palette in the palette set
  77. virtual BOOL GetMinimumSize(CSize& size);
  78. // Gets the maximum size of the palette in the palette set
  79. virtual BOOL GetMaximumSize(CSize& size);
  80. // Return false to indicate that the palette should not give up focus,
  81. // true to indicate that the palette doesn't need focus.
  82. virtual bool CanFrameworkTakeFocus();
  83. // In-place editing of palette name at a specified location
  84. virtual void EditName(CPoint & ptLoc);
  85. // In-place editing of palette name centered on the palette's tab. Intended for use
  86. // only in cases where the palette has a visible tab in it's containing palette set.
  87. virtual void EditName();
  88. // Called when the editing of the palette name using in-place editing is completed
  89. // Return of TRUE means the name is valid.
  90. virtual BOOL NameEditValidation(CEdit* pEdit);
  91. // derived palette can override this method to do any theme initialization either
  92. // when the palette is created or its parent palette set forces an theme update
  93. // of its contained palettes.
  94. virtual void InitPaletteTheme() {}
  95. static bool PaletteNameEditInProgress();
  96. protected:
  97. // Specialized background erasing
  98. afx_msg BOOL OnEraseBkgnd(CDC *pdc); // INTERNAL USE ONLY
  99. // Default "SetCursor" implementation
  100. afx_msg BOOL OnSetCursor(CWnd *pwnd, UINT nHitTest, UINT msg);
  101. afx_msg void OnLButtonDown(UINT nFlags, CPoint pt);
  102. afx_msg LRESULT OnBeginNameEdit(WPARAM, LPARAM); // INTERNAL USE ONLY
  103. afx_msg LRESULT OnEndNameEdit(WPARAM, LPARAM); // INTERNAL USE ONLY
  104. DECLARE_MESSAGE_MAP()
  105. private:
  106. CString m_sName;
  107. CAdUiPaletteSet * m_pPaletteSet;
  108. CObArray m_arrayColors;
  109. DWORD m_dwStyle;
  110. static UINT m_nNextPaletteId;
  111. CEdit * m_pLabelEdit;
  112. static bool m_bPaletteNameEditInProgress;
  113. };
  114. #pragma warning(pop)
  115. #endif // Nodef _ADESK_MAC_
  116. #endif // _ADUI_PALETTE_H_