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.

234 lines
9.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file gr_basic.h
  27. */
  28. #ifndef GR_BASIC
  29. #define GR_BASIC
  30. #include <colors.h>
  31. #include <vector>
  32. class EDA_RECT;
  33. #define GR_COPY 0
  34. #define GR_OR 0x01000000
  35. #define GR_XOR 0x02000000
  36. #define GR_AND 0x04000000
  37. #define GR_NXOR 0x08000000
  38. #define GR_INVERT 0x10000000
  39. #define GR_HIGHLIGHT 0x80000000
  40. #define GR_M_LEFT_DOWN 0x10000000
  41. #define GR_M_RIGHT_DOWN 0x20000000
  42. #define GR_M_MIDDLE_DOWN 0x40000000
  43. #define GR_M_DCLICK 0x80000000
  44. //wxWidgets 2.8 compatibility
  45. #if !wxCHECK_VERSION(2,9,0)
  46. #define wxPENSTYLE_SOLID wxSOLID
  47. #define wxPENSTYLE_SHORT_DASH wxSHORT_DASH
  48. #define wxPENSTYLE_DOT_DASH wxDOT_DASH
  49. typedef int wxPenStyle;
  50. #endif
  51. extern int g_XorMode;
  52. extern int g_DrawBgColor;
  53. typedef enum {
  54. /* Line styles for Get/SetLineStyle. */
  55. GR_SOLID_LINE = 0,
  56. GR_DOTTED_LINE = 1,
  57. GR_DASHED_LINE = 3
  58. } GRLineStypeType;
  59. class EDA_DRAW_PANEL;
  60. void GRSetDrawMode( wxDC* DC, int mode );
  61. int GRGetDrawMode( wxDC* DC );
  62. void GRResetPenAndBrush( wxDC* DC );
  63. void GRSetColorPen( wxDC* DC, int Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
  64. void GRSetBrush( wxDC* DC, int Color, int fill = 0 );
  65. /**
  66. * Function GRForceBlackPen
  67. * @param flagforce True to force a black pen whenever the asked color
  68. */
  69. void GRForceBlackPen( bool flagforce );
  70. /**
  71. * Function GetGRForceBlackPenState
  72. * @return ForceBlackPen (True if a black pen was forced)
  73. */
  74. bool GetGRForceBlackPenState( void );
  75. void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor );
  76. void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color );
  77. void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  78. int width, int Color );
  79. void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  80. int width, int Color );
  81. void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, int Color );
  82. void GRMoveTo( int x, int y );
  83. void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, int Color );
  84. void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
  85. int width, int Color, int BgColor );
  86. void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  87. int x3, int y3, int width, int Color );
  88. void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  89. int x3, int y3, int x4, int y4, int width, int Color );
  90. /**
  91. * Function GRClosedPoly
  92. * draws a closed polygon onto the drawing context \a aDC and optionally fills
  93. * and/or draws a border around it.
  94. * @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
  95. * @param aDC the device context into which drawing should occur.
  96. * @param aPointCount the number of points in the array \a aPoints.
  97. * @param aPoints The points to draw.
  98. * @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
  99. * @param aPenColor the color index of the border.
  100. * @param aFillColor the fill color of the polygon's interior.
  101. */
  102. void GRClosedPoly( EDA_RECT* ClipBox,
  103. wxDC * aDC,
  104. int aPointCount,
  105. wxPoint aPoints[],
  106. bool doFill,
  107. int aPenColor,
  108. int aFillColor );
  109. // @todo could make these 2 closed polygons calls a single function and default
  110. // the aPenWidth argument
  111. /**
  112. * Function GRClosedPoly
  113. * draws a closed polygon onto the drawing context \a aDC and optionally fills
  114. * and/or draws a border around it.
  115. * @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
  116. * @param aDC the device context into which drawing should occur.
  117. * @param aPointCount the number of points in the array \a aPointArray.
  118. * @param aPoints the points to draw.
  119. * @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
  120. * @param aPenWidth is the width of the pen to use on the perimeter, can be zero.
  121. * @param aPenColor the color index of the border.
  122. * @param aFillColor the fill color of the polygon's interior.
  123. */
  124. void GRClosedPoly( EDA_RECT* ClipBox,
  125. wxDC* aDC,
  126. int aPointCount,
  127. wxPoint aPoints[],
  128. bool doFill,
  129. int aPenWidth,
  130. int aPenColor,
  131. int aFillColor );
  132. /**
  133. * Function GRCircle
  134. * draws a circle onto the drawing context \a aDC centered at the user
  135. * coordinates (x,y)
  136. *
  137. * @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
  138. * @param aDC the device context into which drawing should occur.
  139. * @param x The x coordinate in user space of the center of the circle.
  140. * @param y The y coordinate in user space of the center of the circle.
  141. * @param aRadius is the radius of the circle.
  142. * @param aColor is an index into our color table of RGB colors.
  143. * @see EDA_Colors and colors.h
  144. */
  145. void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, int aColor );
  146. void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color );
  147. void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
  148. int Color, int BgColor );
  149. void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor );
  150. void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor );
  151. void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle,
  152. int EndAngle, int r, int Color );
  153. void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle,
  154. int EndAngle, int r, int width, int Color );
  155. void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  156. int xc, int yc, int Color );
  157. void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  158. int xc, int yc, int width, int Color );
  159. void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
  160. wxPoint aCenter, int aWidth, int aColor );
  161. void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
  162. int StAngle, int EndAngle, int r, int Color, int BgColor );
  163. void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle,
  164. int EndAngle, int r, int width, int Color, int BgColor );
  165. void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color );
  166. void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  167. int width, int Color );
  168. void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
  169. int aWidth, int aColor );
  170. void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  171. int width, int aPenSize, int Color );
  172. void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
  173. int aWidth, int aColor );
  174. void GRSetColor( int Color );
  175. void GRSetDefaultPalette();
  176. int GRGetColor();
  177. void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int color );
  178. void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
  179. int x2, int y2, int Color, int BgColor );
  180. void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
  181. int x2, int y2, int width, int Color, int BgColor );
  182. void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int Color );
  183. void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, int Color );
  184. void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
  185. int x2, int y2, int width, int Color );
  186. void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
  187. int aWidth, int aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
  188. void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
  189. int x2, int y2, int width, int Color, int BgColor );
  190. /**
  191. * Function GRLineArray
  192. * draws an array of lines (not a polygon).
  193. * @param aClipBox = the clip box
  194. * @param aDC = the device context into which drawing should occur.
  195. * @param aLines = a list of pair of coordinate in user space: a pair for each line.
  196. * @param aWidth = the width of each line.
  197. * @param aColor = an index into our color table of RGB colors.
  198. * @see EDA_Colors and colors.h
  199. */
  200. void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
  201. int aWidth, int aColor );
  202. #endif /* define GR_BASIC */