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.

211 lines
5.8 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /**
  2. * @file worksheet.cpp
  3. * @brief Common code to draw the title block and frame references
  4. * @note it should include title_block_shape_gost.h or title_block_shape.h
  5. * which defines most of draw shapes, and contains a part of the draw code
  6. */
  7. /*
  8. * This program source code file is part of KiCad, a free EDA CAD application.
  9. *
  10. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
  11. *
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, you may find one here:
  25. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  26. * or you may search the http://www.gnu.org website for the version 2 license,
  27. * or you may write to the Free Software Foundation, Inc.,
  28. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  29. */
  30. #include <fctsys.h>
  31. #include <pgm_base.h>
  32. #include <gr_basic.h>
  33. #include <common.h>
  34. #include <base_screen.h>
  35. #include <draw_frame.h>
  36. #include <worksheet.h>
  37. #include <title_block.h>
  38. #include <build_version.h>
  39. #include <worksheet_shape_builder.h>
  40. static const wxString productName = wxT( "KiCad E.D.A. " );
  41. // returns the full text corresponding to the aTextbase,
  42. // after replacing format symbols by the corresponding value
  43. wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
  44. {
  45. wxString msg;
  46. /* Known formats
  47. * %% = replaced by %
  48. * %K = Kicad version
  49. * %Z = paper format name (A4, USLetter)
  50. * %Y = company name
  51. * %D = date
  52. * %R = revision
  53. * %S = sheet number
  54. * %N = number of sheets
  55. * %L = layer name
  56. * %Cx = comment (x = 0 to 9 to identify the comment)
  57. * %F = filename
  58. * %P = sheet path (sheet full name)
  59. * %T = title
  60. */
  61. for( unsigned ii = 0; ii < aTextbase.Len(); ii++ )
  62. {
  63. if( aTextbase[ii] != '%' )
  64. {
  65. msg << aTextbase[ii];
  66. continue;
  67. }
  68. if( ++ii >= aTextbase.Len() )
  69. break;
  70. wxChar format = aTextbase[ii];
  71. switch( format )
  72. {
  73. case '%':
  74. msg += '%';
  75. break;
  76. case 'D':
  77. msg += m_titleBlock->GetDate();
  78. break;
  79. case 'R':
  80. msg += m_titleBlock->GetRevision();
  81. break;
  82. case 'K':
  83. msg += productName + Pgm().App().GetAppName();
  84. msg += wxT( " " ) + GetBuildVersion();
  85. break;
  86. case 'Z':
  87. if( m_paperFormat )
  88. msg += *m_paperFormat;
  89. break;
  90. case 'S':
  91. msg << m_sheetNumber;
  92. break;
  93. case 'N':
  94. msg << m_sheetCount;
  95. break;
  96. case 'F':
  97. {
  98. wxFileName fn( m_fileName );
  99. msg += fn.GetFullName();
  100. }
  101. break;
  102. case 'L':
  103. if( m_sheetLayer )
  104. msg += *m_sheetLayer;
  105. break;
  106. case 'P':
  107. msg += m_sheetFullName;
  108. break;
  109. case 'Y':
  110. msg += m_titleBlock->GetCompany();
  111. break;
  112. case 'T':
  113. msg += m_titleBlock->GetTitle();
  114. break;
  115. case 'C':
  116. format = aTextbase[++ii];
  117. switch( format )
  118. {
  119. case '0':
  120. case '1':
  121. case '2':
  122. case '3':
  123. case '4':
  124. case '5':
  125. case '6':
  126. case '7':
  127. case '8':
  128. case '9':
  129. msg += m_titleBlock->GetComment( format - '0');
  130. break;
  131. default:
  132. break;
  133. }
  134. default:
  135. break;
  136. }
  137. }
  138. return msg;
  139. }
  140. void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  141. {
  142. // Don't write the title block information if there is nothing to write.
  143. bool isempty = true;
  144. for( unsigned idx = 0; idx < m_tbTexts.GetCount(); idx++ )
  145. {
  146. if( ! m_tbTexts[idx].IsEmpty() )
  147. {
  148. isempty = false;
  149. break;
  150. }
  151. }
  152. if( !isempty )
  153. {
  154. aFormatter->Print( aNestLevel, "(title_block\n" );
  155. if( !GetTitle().IsEmpty() )
  156. aFormatter->Print( aNestLevel+1, "(title %s)\n",
  157. aFormatter->Quotew( GetTitle() ).c_str() );
  158. if( !GetDate().IsEmpty() )
  159. aFormatter->Print( aNestLevel+1, "(date %s)\n",
  160. aFormatter->Quotew( GetDate() ).c_str() );
  161. if( !GetRevision().IsEmpty() )
  162. aFormatter->Print( aNestLevel+1, "(rev %s)\n",
  163. aFormatter->Quotew( GetRevision() ).c_str() );
  164. if( !GetCompany().IsEmpty() )
  165. aFormatter->Print( aNestLevel+1, "(company %s)\n",
  166. aFormatter->Quotew( GetCompany() ).c_str() );
  167. for( int ii = 0; ii < 4; ii++ )
  168. {
  169. if( !GetComment(ii).IsEmpty() )
  170. aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1,
  171. aFormatter->Quotew( GetComment(ii) ).c_str() );
  172. }
  173. aFormatter->Print( aNestLevel, ")\n\n" );
  174. }
  175. }