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.

282 lines
8.6 KiB

  1. /**************************************************/
  2. /* WORKSHEET.CPP : routines de trace du cartouche */
  3. /**************************************************/
  4. #include "fctsys.h"
  5. #include "gr_basic.h"
  6. #include "common.h"
  7. #include "macros.h"
  8. #include "worksheet.h"
  9. /* Must be defined in main applications: */
  10. extern wxString g_Main_Title;
  11. /*************************************************************************************/
  12. void WinEDA_DrawFrame::TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen, int line_width)
  13. /*************************************************************************************/
  14. /* Draw the sheet references
  15. */
  16. {
  17. if ( ! m_Draw_Sheet_Ref ) return;
  18. Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc;
  19. int ii, jj, xg , yg, ipas, gxpas, gypas;
  20. wxPoint pos;
  21. int refx, refy,Color;
  22. wxString Line;
  23. Ki_WorkSheetData * WsItem;
  24. int scale = m_InternalUnits/1000;
  25. wxSize size(SIZETEXT*scale,SIZETEXT*scale);
  26. wxSize size_ref(SIZETEXT_REF*scale,SIZETEXT_REF*scale);
  27. wxString msg;
  28. int UpperLimit = VARIABLE_BLOCK_START_POSITION;
  29. int width = line_width;
  30. Color = RED;
  31. if(Sheet == NULL)
  32. {
  33. DisplayError(this,
  34. wxT("WinEDA_DrawFrame::TraceWorkSheet() error: m_CurrentSheet NULL"));
  35. return;
  36. }
  37. // if not printing, draw the page limits:
  38. if ( ! g_IsPrinting & g_ShowPageLimits )
  39. {
  40. GRSetDrawMode(DC, GR_COPY);
  41. GRRect(&DrawPanel->m_ClipBox, DC, 0, 0,
  42. Sheet->m_Size.x * scale, Sheet->m_Size.y * scale, width,
  43. g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
  44. }
  45. GRSetDrawMode(DC, GR_COPY);
  46. /* trace de la bordure */
  47. refx = Sheet->m_LeftMargin;
  48. refy = Sheet->m_TopMargin; /* Upper left corner */
  49. xg = Sheet->m_Size.x - Sheet->m_RightMargin;
  50. yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */
  51. for ( ii = 0; ii < 2 ; ii++ )
  52. {
  53. GRRect(&DrawPanel->m_ClipBox, DC, refx * scale, refy * scale,
  54. xg * scale, yg * scale, width, Color);
  55. refx += GRID_REF_W; refy += GRID_REF_W;
  56. xg -= GRID_REF_W; yg -= GRID_REF_W;
  57. }
  58. /* trace des reperes */
  59. refx = Sheet->m_LeftMargin;
  60. refy = Sheet->m_TopMargin; /* Upper left corner */
  61. xg = Sheet->m_Size.x - Sheet->m_RightMargin;
  62. yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */
  63. /* Trace des reperes selon l'axe X */
  64. ipas = (xg - refx) / PAS_REF;
  65. gxpas = ( xg - refx) / ipas;
  66. for ( ii = refx + gxpas, jj = 1; ipas > 0 ; ii += gxpas , jj++, ipas--)
  67. {
  68. Line.Printf( wxT("%d"),jj);
  69. if( ii < xg - PAS_REF/2 )
  70. {
  71. GRLine(&DrawPanel->m_ClipBox, DC, ii * scale, refy * scale,
  72. ii * scale, (refy + GRID_REF_W) * scale, width, Color);
  73. }
  74. DrawGraphicText(DrawPanel, DC,
  75. wxPoint( (ii - gxpas/2) * scale, (refy + GRID_REF_W/2) * scale),
  76. Color,
  77. Line, TEXT_ORIENT_HORIZ, size_ref,
  78. GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width);
  79. if( ii < xg - PAS_REF/2 )
  80. {
  81. GRLine(&DrawPanel->m_ClipBox, DC,ii * scale, yg * scale,
  82. ii * scale, (yg - GRID_REF_W) * scale, width, Color);
  83. }
  84. DrawGraphicText(DrawPanel, DC,
  85. wxPoint( (ii - gxpas/2) * scale, (yg - GRID_REF_W/2) * scale),
  86. Color,
  87. Line, TEXT_ORIENT_HORIZ, size_ref,
  88. GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width);
  89. }
  90. /* Trace des reperes selon l'axe Y */
  91. ipas = (yg - refy) / PAS_REF;
  92. gypas = ( yg - refy) / ipas;
  93. for ( ii = refy + gypas, jj = 0; ipas > 0 ; ii += gypas , jj++, ipas--)
  94. {
  95. Line.Empty();
  96. if( jj < 26 ) Line.Printf(wxT("%c"), jj + 'A');
  97. else Line.Printf(wxT("%c"), 'a' + jj - 26);
  98. if( ii < yg - PAS_REF/2 )
  99. {
  100. GRLine(&DrawPanel->m_ClipBox, DC, refx * scale, ii * scale,
  101. (refx + GRID_REF_W) * scale, ii * scale, width, Color);
  102. }
  103. DrawGraphicText(DrawPanel, DC,
  104. wxPoint((refx + GRID_REF_W/2) * scale, (ii - gypas/2) * scale),
  105. Color,
  106. Line, TEXT_ORIENT_HORIZ, size_ref,
  107. GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width);
  108. if( ii < yg - PAS_REF/2 )
  109. {
  110. GRLine(&DrawPanel->m_ClipBox, DC, xg * scale, ii * scale,
  111. (xg - GRID_REF_W) * scale, ii * scale, width, Color);
  112. }
  113. DrawGraphicText(DrawPanel, DC,
  114. wxPoint((xg - GRID_REF_W/2) * scale, (ii - gxpas/2) * scale),
  115. Color,
  116. Line, TEXT_ORIENT_HORIZ, size_ref,
  117. GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width);
  118. }
  119. /* Trace du cartouche */
  120. refx = Sheet->m_Size.x - Sheet->m_RightMargin - GRID_REF_W;
  121. refy = Sheet->m_Size.y - Sheet->m_BottomMargin - GRID_REF_W; /* lower right corner */
  122. for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext )
  123. {
  124. pos.x = (refx - WsItem->m_Posx)* scale;
  125. pos.y = (refy - WsItem->m_Posy)* scale;
  126. msg.Empty();
  127. switch( WsItem->m_Type )
  128. {
  129. case WS_DATE:
  130. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  131. msg += screen->m_Date;
  132. DrawGraphicText(DrawPanel, DC, pos, Color,
  133. msg, TEXT_ORIENT_HORIZ, size,
  134. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  135. break;
  136. case WS_REV:
  137. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  138. msg += screen->m_Revision;
  139. DrawGraphicText(DrawPanel, DC, pos, Color,
  140. msg, TEXT_ORIENT_HORIZ, size,
  141. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  142. break;
  143. case WS_LICENCE:
  144. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  145. msg += g_ProductName + g_Main_Title;
  146. msg += wxT(" ") + GetBuildVersion();
  147. DrawGraphicText(DrawPanel, DC, pos, Color,
  148. msg, TEXT_ORIENT_HORIZ, size,
  149. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  150. break;
  151. case WS_SIZESHEET:
  152. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  153. msg += Sheet->m_Name;
  154. DrawGraphicText(DrawPanel, DC, pos, Color,
  155. msg, TEXT_ORIENT_HORIZ, size,
  156. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  157. break;
  158. case WS_IDENTSHEET:
  159. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  160. DrawGraphicText(DrawPanel, DC, pos, Color,
  161. GetScreenDesc(), TEXT_ORIENT_HORIZ, size,
  162. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  163. break;
  164. case WS_COMPANY_NAME:
  165. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  166. msg += screen->m_Company;
  167. if ( ! msg.IsEmpty() )
  168. {
  169. DrawGraphicText(DrawPanel, DC, pos, Color,
  170. msg, TEXT_ORIENT_HORIZ, size,
  171. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  172. UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT);
  173. }
  174. break;
  175. case WS_TITLE:
  176. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  177. msg += screen->m_Title;
  178. DrawGraphicText(DrawPanel, DC, pos, Color,
  179. msg, TEXT_ORIENT_HORIZ, size,
  180. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  181. break;
  182. case WS_COMMENT1:
  183. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  184. msg += screen->m_Commentaire1;
  185. if ( ! msg.IsEmpty() )
  186. {
  187. DrawGraphicText(DrawPanel, DC, pos, Color,
  188. msg, TEXT_ORIENT_HORIZ, size,
  189. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  190. UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT);
  191. }
  192. break;
  193. case WS_COMMENT2:
  194. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  195. msg += screen->m_Commentaire2;
  196. if ( ! msg.IsEmpty() )
  197. {
  198. DrawGraphicText(DrawPanel, DC, pos, Color,
  199. msg, TEXT_ORIENT_HORIZ, size,
  200. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  201. UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT);
  202. }
  203. break;
  204. case WS_COMMENT3:
  205. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  206. msg += screen->m_Commentaire3;
  207. if ( ! msg.IsEmpty() )
  208. {
  209. DrawGraphicText(DrawPanel, DC, pos, Color,
  210. msg, TEXT_ORIENT_HORIZ, size,
  211. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  212. UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT);
  213. }
  214. break;
  215. case WS_COMMENT4:
  216. if(WsItem->m_Legende) msg = WsItem->m_Legende;
  217. msg += screen->m_Commentaire4;
  218. if ( ! msg.IsEmpty() )
  219. {
  220. DrawGraphicText(DrawPanel, DC, pos, Color,
  221. msg, TEXT_ORIENT_HORIZ, size,
  222. GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
  223. UpperLimit = MAX(UpperLimit, WsItem->m_Posy+SIZETEXT);
  224. }
  225. break;
  226. case WS_UPPER_SEGMENT:
  227. if (UpperLimit == 0 ) break;
  228. case WS_LEFT_SEGMENT:
  229. WS_MostUpperLine.m_Posy =
  230. WS_MostUpperLine.m_Endy =
  231. WS_MostLeftLine.m_Posy = UpperLimit;
  232. pos.y = (refy - WsItem->m_Posy)* scale;
  233. case WS_SEGMENT:
  234. xg = Sheet->m_Size.x -
  235. GRID_REF_W - Sheet->m_RightMargin - WsItem->m_Endx;
  236. yg = Sheet->m_Size.y -
  237. GRID_REF_W - Sheet->m_BottomMargin - WsItem->m_Endy;
  238. GRLine(&DrawPanel->m_ClipBox, DC, pos.x, pos.y,
  239. xg * scale, yg * scale, width, Color);
  240. break;
  241. }
  242. }
  243. }
  244. /*********************************************************************/
  245. wxString WinEDA_DrawFrame::GetScreenDesc()
  246. /*********************************************************************/
  247. {
  248. wxString msg;
  249. msg << GetScreen()->m_ScreenNumber << wxT("/") <<
  250. GetScreen()->m_NumberOfScreen;
  251. return msg;
  252. }