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.

247 lines
8.2 KiB

  1. // toolbox.h : Declares the class interfaces for the toolbox window class.
  2. #ifndef __TOOLBOX_H__
  3. #define __TOOLBOX_H__
  4. #define TM_TOOLDOWN (WM_USER+0x0010)
  5. #define TM_TOOLUP (WM_USER+0x0011)
  6. #define TM_TOOLDBLCLK (WM_USER+0x0012)
  7. #define TM_QUERYDROP (WM_USER+0x0013)
  8. #define TM_DROP (WM_USER+0x0014)
  9. #define TM_ABORTDROP (WM_USER+0x0015)
  10. #define TF_DISABLED 0x8000
  11. #define TF_GRAYED TF_DISABLED
  12. #define TF_SELECTED 0x4000
  13. #define TF_DOWN TF_SELECTED
  14. #define TF_DRAG 0x2000
  15. #define TF_HOT 0x0800
  16. #define TF_NYI 0x9000 // this represents a NYI tool (note that
  17. // TF_NYI implies TF_DISABLED)
  18. #define TS_DEFAULT 0xC000
  19. #define TS_STICKY 0x4000
  20. #define TS_DRAG 0x2000
  21. #define TS_CMD 0x1000
  22. #define TS_VB 0x0800
  23. #define TS_WELL 0x0400
  24. #define NUM_TOOLS_WIDE 2
  25. class CToolboxWnd;
  26. #ifdef CUSTOMFLOAT
  27. class CImageWell;
  28. #else //!CUSTOMFLOAT
  29. #include "imgwell.h"
  30. #include "imgcolor.h"
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CTool:
  34. // A CTool is a thin-window button which can be inserted in a CToolboxWnd.
  35. // Note that the tool is "owned" by a separate window, which is notified
  36. // directly when the tool is used (pushed, dragged, unpushed, etc.). The
  37. // CToolboxWnd sends TM_* messages to the owning window.
  38. //
  39. // The graphics are completely calculated from the single bitmap given to
  40. // the tool upon creation. The pushed, disabled and unpushed states are
  41. // drawn from the bitmap, which should be a two-color image without any
  42. // chiseling button effects in it. The graphic is centered in the button.
  43. //
  44. // For buttons defined with the TS_DRAG style, a cursor ID may be specified
  45. // for the can't-drop state. If not specified, the generic slashed-O
  46. // cursor is used.
  47. //
  48. /******************************************************************************/
  49. class CTool : public CObject
  50. {
  51. public: /*****************************************************************/
  52. CToolboxWnd* m_pOwner;
  53. WORD m_wID;
  54. int m_nImage; // index into parent's image well
  55. WORD m_wState;
  56. WORD m_wStyle;
  57. CTool(CToolboxWnd* pOwner, WORD wID, int nImage,
  58. WORD wStyle = 0, WORD wState = 0);
  59. };
  60. /******************************************************************************/
  61. // CToolboxWnd:
  62. // This is a typical mini-frame window, filled with an array of special
  63. // buttons of the CTool class (above). Direct access to this CObArray is
  64. // allowed with the GetTools member function.
  65. //
  66. // After directly manipulating the tool array (adding, removing or modifying
  67. // tools), use the Invalidate member function to repaint the window with the
  68. // new state.
  69. //
  70. /******************************************************************************/
  71. #ifdef CUSTOMFLOAT
  72. class CDocking;
  73. #endif
  74. class CToolboxWnd : public CControlBar
  75. {
  76. DECLARE_DYNAMIC(CToolboxWnd)
  77. private: /**************************************************************/
  78. CBitmap* m_bmStuck;
  79. CBitmap* m_bmPushed;
  80. CBitmap* m_bmPopped;
  81. CTool* m_tCapture;
  82. BOOL m_bInside;
  83. CRect m_lasttool;
  84. HCURSOR m_oldcursor;
  85. CTool* m_pLastHot;
  86. CRect m_rectLastHot;
  87. HTHEME m_hTheme;
  88. CObArray* m_Tools;
  89. CPoint m_downpt; // "click down point" for drag debounce -gh
  90. #ifdef CUSTOMFLOAT
  91. CDocking* m_pDocking;
  92. #endif
  93. protected: /**************************************************************/
  94. CTool* ToolFromPoint(CRect* rect, CPoint* pt) const;
  95. void SizeByButtons(int nButtons = -1, BOOL bRepaint = FALSE);
  96. BOOL DrawStockBitmaps();
  97. WORD m_wWide;
  98. CPoint m_btnsize;
  99. CImageWell m_imageWell;
  100. CRect m_rcTools;
  101. int m_nOffsetX;
  102. int m_nOffsetY;
  103. public: /**************************************************************/
  104. static const POINT NEAR ptDefButton;
  105. CToolboxWnd();
  106. ~CToolboxWnd();
  107. virtual BOOL Create(const TCHAR FAR* lpWindowName,
  108. DWORD dwStyle, const RECT& rect,
  109. const POINT& btnsize = ptDefButton, WORD wWide = 1,
  110. CWnd* pParentWnd = NULL, int nImageWellID = 0);
  111. virtual BOOL OnCommand(UINT wParam, LONG lParam);
  112. virtual UINT OnCmdHitTest ( CPoint point, CPoint* pCenter );
  113. virtual BOOL SetStatusText(int nHit);
  114. int HitTestToolTip( CPoint point, UINT* pHit );
  115. void AddTool(CTool* tool);
  116. void RemoveTool(CTool* tool);
  117. WORD SetToolState(WORD wID, WORD wState);
  118. WORD SetToolStyle(WORD wID, WORD wStyle);
  119. void SelectTool(WORD wid);
  120. WORD CurrentToolID();
  121. CTool* GetTool(WORD wID);
  122. void DrawButtons(CDC& dc, RECT* rcPaint);
  123. inline int GetToolCount() { return (int)m_Tools->GetSize(); }
  124. inline CTool* GetToolAt(int nTool) { return (CTool*)m_Tools->GetAt(nTool); }
  125. void CancelDrag();
  126. afx_msg void OnSysColorChange();
  127. afx_msg void OnPaint();
  128. afx_msg void OnLButtonDown(UINT wFlags, CPoint point);
  129. afx_msg void OnRButtonDown(UINT wFlags, CPoint point);
  130. afx_msg void OnLButtonDblClk(UINT wFlags, CPoint point);
  131. afx_msg void OnMouseMove(UINT wFlags, CPoint point);
  132. afx_msg void OnLButtonUp(UINT wFlags, CPoint point);
  133. afx_msg void OnClose();
  134. afx_msg void OnDestroy();
  135. afx_msg void OnWinIniChange(LPCTSTR lpSection);
  136. afx_msg void OnKeyDown(UINT, UINT, UINT);
  137. afx_msg LONG OnToolDown(UINT wID, LONG lParam);
  138. afx_msg LONG OnToolUp(UINT wID, LONG lParam);
  139. afx_msg LRESULT OnThemeChanged(WPARAM, LPARAM);
  140. afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
  141. // afx_msg LONG OnSwitch(UINT wID, LONG point);
  142. // virtual BOOL BeginDragDrop( CTool* pTool, CPoint pt );
  143. DECLARE_MESSAGE_MAP()
  144. };
  145. /******************************************************************************/
  146. class CImgToolWnd : public CToolboxWnd
  147. {
  148. public: /**************************************************************/
  149. CRect m_rcBrushes;
  150. virtual BOOL Create(const TCHAR* pWindowName, DWORD dwStyle,
  151. const RECT& rect, const POINT& btnSize, WORD wWide,
  152. CWnd* pParentWnd, BOOL bDkRegister = TRUE);
  153. virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  154. BOOL PreTranslateMessage(MSG* pMsg);
  155. afx_msg void OnSysColorChange();
  156. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  157. afx_msg void OnLButtonDown(UINT nFlags, CPoint pt);
  158. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint pt);
  159. afx_msg void OnRButtonDown(UINT nFlags, CPoint pt);
  160. afx_msg void OnPaint();
  161. afx_msg UINT OnNcHitTest(CPoint point);
  162. virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
  163. virtual CSize GetSize();
  164. virtual WORD GetHelpOffset() { return ID_WND_GRAPHIC; }
  165. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  166. void InvalidateOptions(BOOL bErase = TRUE);
  167. friend class CImgColorsWnd;
  168. #ifdef _DEBUG
  169. virtual void AssertValid() const
  170. {
  171. CWnd::AssertValid();
  172. }
  173. #endif //_DEBUG
  174. DECLARE_MESSAGE_MAP();
  175. };
  176. /******************************************************************************/
  177. #ifdef CUSTOMFLOAT
  178. class CFloatImgToolWnd : public CMiniFrmWnd
  179. {
  180. DECLARE_DYNAMIC(CFloatImgToolWnd)
  181. public: /**************************************************************/
  182. virtual ~CFloatImgToolWnd(void);
  183. virtual BOOL Create(const TCHAR* pWindowName, DWORD dwStyle,
  184. const RECT& rect, const POINT& btnSize, WORD wWide,
  185. CWnd* pParentWnd, BOOL bDkRegister = TRUE);
  186. virtual WORD GetHelpOffset() { return ID_WND_GRAPHIC; }
  187. afx_msg void OnSysColorChange();
  188. afx_msg void OnClose();
  189. DECLARE_MESSAGE_MAP()
  190. };
  191. #endif //CUSTOMFLOAT
  192. /***************************************************************************/
  193. extern CImgToolWnd* NEAR g_pImgToolWnd;
  194. #endif // __TOOLBOX_H__