Source code of Windows XP (NT5)
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.

435 lines
12 KiB

  1. #ifndef __IMGTOOLS_H__
  2. #define __IMGTOOLS_H__
  3. extern BOOL g_bBrushVisible;
  4. extern BOOL g_bPickingColor;
  5. extern UINT g_nStrokeWidth;
  6. typedef enum
  7. {
  8. eFREEHAND,
  9. eEAST_WEST, //HORIZONTAL
  10. eNORTH_SOUTH, //VERTICAL
  11. eNORTH_WEST, // 45 degree up to left
  12. eSOUTH_EAST, // 45 degree down to right
  13. eNORTH_EAST, // 45 degree up to right
  14. eSOUTH_WEST // 45 degree down to left
  15. } eDRAWCONSTRAINTDIRECTION;
  16. class CImgTool : public CObject
  17. {
  18. DECLARE_DYNAMIC( CImgTool )
  19. protected:
  20. eDRAWCONSTRAINTDIRECTION DetermineDrawDirection(MTI *pmti);
  21. virtual void AdjustPointsForConstraint(MTI *pmti);
  22. virtual void PreProcessPoints(MTI *pmti);
  23. eDRAWCONSTRAINTDIRECTION m_eDrawDirection;
  24. public:
  25. CImgTool();
  26. virtual void OnEnter ( CImgWnd* pImgWnd, MTI* pmti );
  27. virtual void OnLeave ( CImgWnd* pImgWnd, MTI* pmti );
  28. virtual void OnStartDrag ( CImgWnd* pImgWnd, MTI* pmti );
  29. virtual void OnEndDrag ( CImgWnd* pImgWnd, MTI* pmti );
  30. virtual void OnDrag ( CImgWnd* pImgWnd, MTI* pmti );
  31. virtual void OnMove ( CImgWnd* pImgWnd, MTI* pmti );
  32. virtual void OnTimer ( CImgWnd* pImgWnd, MTI* pmti );
  33. virtual void OnCancel ( CImgWnd* pImgWnd);
  34. virtual void OnActivate ( BOOL bActivate );
  35. virtual void OnShowDragger ( CImgWnd* pImgWnd, BOOL bShow );
  36. virtual void OnPaintOptions ( CDC* pDC, const CRect& paintRect,
  37. const CRect& optionsRect );
  38. virtual void OnClickOptions ( CImgToolWnd* pWnd, const CRect& optionsRect,
  39. const CPoint& clickPoint );
  40. virtual void OnUpdateColors (CImgWnd* pImgWnd);
  41. virtual BOOL CanEndMultiptOperation(MTI* pmti );
  42. virtual void EndMultiptOperation(BOOL bAbort = FALSE);
  43. virtual BOOL IsToolModal(void);
  44. virtual BOOL SetupPenBrush(HDC hDC, BOOL bLeftButton, BOOL bSetup, BOOL bCtrlDown);
  45. void PaintStdBrushes( CDC* pDC, const CRect& paintRect,
  46. const CRect& optionsRect );
  47. void PaintStdPattern( CDC* pDC, const CRect& paintRect,
  48. const CRect& optionsRect );
  49. void ClickStdBrushes(CImgToolWnd* pWnd, const CRect& optionsRect,
  50. const CPoint& clickPoint);
  51. void ClickStdPattern(CImgToolWnd* pWnd, const CRect& optionsRect,
  52. const CPoint& clickPoint);
  53. static void HideDragger(CImgWnd* pImgWnd);
  54. static void ShowDragger(CImgWnd* pImgWnd);
  55. inline BOOL UsesBrush()const { return m_bUsesBrush; }
  56. inline BOOL IsToggle() const { return m_bToggleWithPrev; }
  57. inline BOOL IsFilled() const { return m_bFilled; }
  58. inline BOOL HasBorder()const { return m_bBorder; }
  59. inline UINT GetCmdID() const { return m_nCmdID; }
  60. inline BOOL IsMultPtOpInProgress() const { return m_bMultPtOpInProgress; }
  61. virtual BOOL IsUndoable();
  62. virtual UINT GetCursorID();
  63. void SetStrokeWidth(UINT nNewStrokeWidth);
  64. inline UINT GetStrokeWidth() const { return m_nStrokeWidth; }
  65. inline UINT GetStrokeShape() const { return m_nStrokeShape; }
  66. void SetStrokeShape(UINT nNewStrokeShape);
  67. static inline CImgTool* GetCurrent() { return c_pCurrentImgTool; }
  68. static inline UINT GetCurrentID() { return c_pCurrentImgTool->m_nCmdID; }
  69. static inline BOOL IsDragging() { return c_bDragging; }
  70. void Select();
  71. static void Select(UINT nCmdID);
  72. static inline void SelectPrevious() {
  73. ASSERT(c_pPreviousImgTool != NULL);
  74. c_pPreviousImgTool->Select();
  75. }
  76. static CImgTool* FromID(UINT nCmdID);
  77. protected:
  78. BOOL m_bUsesBrush;
  79. BOOL m_bIsUndoable;
  80. BOOL m_bCanBePrevTool;
  81. BOOL m_bToggleWithPrev;
  82. BOOL m_bFilled;
  83. BOOL m_bBorder;
  84. BOOL m_bMultPtOpInProgress;
  85. UINT m_nStrokeWidth;
  86. UINT m_nStrokeShape;
  87. UINT m_nCursorID;
  88. UINT m_nCmdID;
  89. CImgTool* m_pNextImgTool;
  90. static CImgTool* c_pHeadImgTool;
  91. static CImgTool* c_pCurrentImgTool;
  92. static CImgTool* c_pPreviousImgTool;
  93. static BOOL c_bDragging;
  94. static int c_nHideCount;
  95. };
  96. class CRubberTool : public CImgTool
  97. {
  98. DECLARE_DYNAMIC(CRubberTool)
  99. protected:
  100. virtual void AdjustPointsForConstraint(MTI *pmti);
  101. // virtual BOOL SetupMaskPenBrush(HDC hDC, BOOL bLeftButton, BOOL bSetup);
  102. public:
  103. CRubberTool();
  104. virtual void OnPaintOptions( CDC* pDC, const CRect& paintRect,
  105. const CRect& optionsRect );
  106. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  107. const CPoint& clickPoint);
  108. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  109. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  110. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  111. virtual void Render(CDC* pDC, CRect& rect, BOOL bDraw, BOOL bCommit, BOOL bCtrlDown);
  112. virtual void OnActivate ( BOOL bActivate );
  113. static CRect rcPrev;
  114. };
  115. class CClosedFormTool : public CRubberTool
  116. {
  117. DECLARE_DYNAMIC(CClosedFormTool)
  118. public:
  119. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  120. const CRect& optionsRect);
  121. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  122. const CPoint& clickPoint);
  123. };
  124. class CRectTool : public CClosedFormTool
  125. {
  126. DECLARE_DYNAMIC(CRectTool)
  127. public:
  128. CRectTool();
  129. };
  130. class CRoundRectTool : public CClosedFormTool
  131. {
  132. DECLARE_DYNAMIC(CRoundRectTool)
  133. public:
  134. CRoundRectTool();
  135. };
  136. class CEllipseTool : public CClosedFormTool
  137. {
  138. DECLARE_DYNAMIC(CEllipseTool)
  139. public:
  140. CEllipseTool();
  141. };
  142. class CLineTool : public CRubberTool
  143. {
  144. DECLARE_DYNAMIC(CLineTool)
  145. protected:
  146. virtual void AdjustPointsForConstraint(MTI *pmti);
  147. friend class CPolygonTool; // need to call AdjustPointsForContstraint from cPolygonTool
  148. friend class CCurveTool; // need to call AdjustPointsForContstraint from cPolygonTool
  149. public:
  150. CLineTool();
  151. virtual void Render(CDC* pDC, CRect& rect, BOOL bDraw, BOOL bCommit, BOOL bCtrlDown);
  152. };
  153. class CSelectTool : public CImgTool
  154. {
  155. DECLARE_DYNAMIC(CSelectTool)
  156. protected:
  157. friend class CFreehandSelectTool; // need to call OnClickOptions and OnPaintOptions
  158. public:
  159. CSelectTool();
  160. virtual void OnActivate(BOOL bActivate);
  161. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  162. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  163. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  164. virtual void OnCancel(CImgWnd* pImgWnd);
  165. virtual void OnShowDragger(CImgWnd* pImgWnd, BOOL bShow);
  166. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  167. const CRect& optionsRect);
  168. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  169. const CPoint& clickPoint);
  170. virtual BOOL IsToolModal(void);
  171. void InvertSelectRect(CImgWnd* pImgWnd);
  172. UINT GetCursorID();
  173. static CRect c_selectRect;
  174. static CImageWell c_imageWell;
  175. };
  176. class CFreehandTool : public CImgTool
  177. {
  178. DECLARE_DYNAMIC(CFreehandTool)
  179. public:
  180. CFreehandTool();
  181. void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  182. void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  183. static CRect c_undoRect;
  184. };
  185. class CSketchTool : public CFreehandTool
  186. {
  187. DECLARE_DYNAMIC(CSketchTool)
  188. public:
  189. CSketchTool();
  190. virtual void OnDrag ( CImgWnd* pImgWnd, MTI* pmti );
  191. virtual void OnCancel( CImgWnd* pImgWnd );
  192. };
  193. class CBrushTool : public CFreehandTool
  194. {
  195. DECLARE_DYNAMIC(CBrushTool)
  196. public:
  197. CBrushTool();
  198. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  199. const CRect& optionsRect);
  200. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  201. const CPoint& clickPoint);
  202. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  203. virtual void OnMove(CImgWnd* pImgWnd, MTI* pmti);
  204. };
  205. class CPencilTool : public CFreehandTool
  206. {
  207. DECLARE_DYNAMIC(CPencilTool)
  208. protected:
  209. virtual void AdjustPointsForConstraint(MTI *pmti);
  210. public:
  211. CPencilTool();
  212. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  213. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  214. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  215. };
  216. class CEraserTool : public CFreehandTool
  217. {
  218. DECLARE_DYNAMIC(CEraserTool)
  219. public:
  220. CEraserTool();
  221. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  222. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  223. virtual void OnMove(CImgWnd* pImgWnd, MTI* pmti);
  224. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  225. const CRect& optionsRect);
  226. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  227. const CPoint& clickPoint);
  228. virtual void OnShowDragger(CImgWnd* pImgWnd, BOOL bShow);
  229. virtual UINT GetCursorID();
  230. };
  231. class CAirBrushTool : public CFreehandTool
  232. {
  233. DECLARE_DYNAMIC(CAirBrushTool)
  234. public:
  235. CAirBrushTool();
  236. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  237. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  238. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  239. virtual void OnTimer(CImgWnd* pImgWnd, MTI* pmti);
  240. virtual void OnCancel(CImgWnd* pImgWnd);
  241. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  242. const CRect& optionsRect);
  243. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  244. const CPoint& clickPoint);
  245. static CImageWell c_imageWell;
  246. private:
  247. BOOL m_bCtrlDown;
  248. };
  249. class CFloodTool : public CImgTool
  250. {
  251. DECLARE_DYNAMIC(CFloodTool)
  252. public:
  253. CFloodTool();
  254. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  255. const CRect& optionsRect);
  256. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  257. const CPoint& clickPoint);
  258. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  259. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  260. };
  261. class CPickColorTool : public CImgTool
  262. {
  263. DECLARE_DYNAMIC(CPickColorTool)
  264. public:
  265. COLORREF m_Color;
  266. CPickColorTool();
  267. virtual void OnActivate(BOOL bActivate);
  268. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  269. virtual void OnDrag(CImgWnd* pImgWnd, MTI* pmti);
  270. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  271. virtual void OnCancel(CImgWnd* pImgWnd);
  272. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  273. const CRect& optionsRect);
  274. };
  275. class CZoomTool : public CImgTool
  276. {
  277. DECLARE_DYNAMIC(CZoomTool)
  278. protected:
  279. void InvertZoomRect();
  280. static CRect c_zoomRect;
  281. static CImgWnd* c_pImgWnd;
  282. static CImageWell c_imageWell;
  283. public:
  284. CZoomTool();
  285. virtual void OnLeave(CImgWnd* pImgWnd, MTI* pmti);
  286. virtual void OnMove(CImgWnd* pImgWnd, MTI* pmti);
  287. virtual void OnStartDrag(CImgWnd* pImgWnd, MTI* pmti);
  288. virtual void OnEndDrag(CImgWnd* pImgWnd, MTI* pmti);
  289. virtual void OnCancel(CImgWnd* pImgWnd);
  290. virtual void OnShowDragger(CImgWnd* pImgWnd, BOOL bShow);
  291. virtual void OnPaintOptions(CDC* pDC, const CRect& paintRect,
  292. const CRect& optionsRect);
  293. virtual void OnClickOptions(CImgToolWnd* pWnd, const CRect& optionsRect,
  294. const CPoint& clickPoint);
  295. };
  296. #endif // __IMGTOOLS_H__