LINE.H
上传用户:whjcdz88
上传日期:2011-09-07
资源大小:121k
文件大小:2k
源码类别:

图形图象

开发平台:

WINDOWS

  1. // Line.h : main header file for the CDashLine
  2. //
  3. // The Bresenham function in this file is derived from code from 
  4. // Jean-Claude Lanz mailto:Jclanz@bluewin.ch
  5. // and he presumably shares copyright to it
  6. // Otherwise the copyright belongs to Llew S. Goodstadt 
  7. // http://www.lg.ndirect.co.uk    mailto:lg@ndirect.co.uk
  8. // who hereby grants you fair use and distribution rights of the code 
  9. // in both commercial and non-commercial applications.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDashLine
  13. class CDashLine
  14. {
  15. public:
  16. CDashLine(CDC& dc, unsigned* pattern, unsigned count);
  17. ~CDashLine();
  18. void SetPattern(unsigned* pattern, unsigned count);
  19. enum { DL_SOLID, DL_DASH, DL_DOT, DL_DASHDOT, DL_DASHDOTDOT, DL_DASHDOTDOTDOT, 
  20. DL_DASH_GAP, DL_DOT_GAP, DL_DASHDOT_GAP, DL_DASHDOTDOT_GAP, DL_DASHDOTDOTDOT_GAP}; 
  21. // Returns count of elements (dash/dot and gaps)
  22. // You must be careful to pass in enough memory for pattern
  23. // It is probably safest to always have an array of [8]
  24. static unsigned GetPattern(unsigned* pattern, bool round, unsigned pensize, unsigned style);
  25. protected:
  26. CDC& m_DC;
  27. unsigned int m_CurPat;
  28. unsigned int m_Count;
  29. unsigned int m_CurStretch;
  30. unsigned int* m_Pattern;
  31. CPoint m_CurPos;
  32. void Reset();
  33. void Bresenham(LONG x, LONG y);
  34. public:
  35. void BezierTo(POINT* dest);
  36. void MoveTo(const POINT& p) {MoveTo(p.x, p.y);}
  37. void MoveTo(int x, int y);
  38. void LineTo(const POINT& p) {LineTo(p.x, p.y);}
  39. void LineTo(int x, int y);
  40. };