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.

378 lines
9.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 1992-2017 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 wildcards_and_files_ext.cpp
  27. */
  28. #include <wildcards_and_files_ext.h>
  29. /**
  30. * Format wildcard extension to support case sensitive file dialogs.
  31. *
  32. * The file extension wildcards of the GTK+ file dialog are case sensitive so using all lower
  33. * case characters means that only file extensions that are all lower case will show up in the
  34. * file dialog. The GTK+ file dialog does support regular expressions so the file extension
  35. * is converted to a regular expression ( sch -> [sS][cC][hH] ) when wxWidgets is built against
  36. * GTK+. Please make sure you call this function when adding new file wildcards.
  37. *
  38. * @note When calling wxFileDialog with a default file defined, make sure you include the
  39. * file extension along with the file name. Otherwise, on GTK+ builds, the file
  40. * dialog will append the wildcard regular expression as the file extension which is
  41. * surely not what you want.
  42. *
  43. * @param aWildcard is the extension part of the wild card.
  44. *
  45. * @return the build appropriate file dialog wildcard filter.
  46. */
  47. static wxString FormatWildcardExt( const wxString& aWildcard )
  48. {
  49. wxString wc;
  50. #if defined( __WXGTK__ )
  51. for( auto ch : aWildcard )
  52. {
  53. if( wxIsalpha( ch ) )
  54. wc += wxString::Format( "[%c%c]", wxTolower( ch ), wxToupper( ch ) );
  55. else
  56. wc += ch;
  57. }
  58. return wc;
  59. #else
  60. wc = aWildcard;
  61. return wc;
  62. #endif
  63. }
  64. const wxString SchematicSymbolFileExtension( "sym" );
  65. const wxString SchematicLibraryFileExtension( "lib" );
  66. const wxString SchematicBackupFileExtension( "bak" );
  67. const wxString VrmlFileExtension( "wrl" );
  68. const wxString ProjectFileExtension( "pro" );
  69. const wxString SchematicFileExtension( "sch" );
  70. const wxString NetlistFileExtension( "net" );
  71. const wxString ComponentFileExtension( "cmp" );
  72. const wxString GerberFileExtension( "gbr" );
  73. const wxString GerberJobFileExtension( "gbrjob" );
  74. const wxString HtmlFileExtension( wxT( "html" ) );
  75. const wxString LegacyPcbFileExtension( "brd" );
  76. const wxString KiCadPcbFileExtension( "kicad_pcb" );
  77. const wxString PageLayoutDescrFileExtension( "kicad_wks" );
  78. const wxString PdfFileExtension( "pdf" );
  79. const wxString MacrosFileExtension( "mcr" );
  80. const wxString DrillFileExtension( "drl" );
  81. const wxString SVGFileExtension( "svg" );
  82. const wxString ReportFileExtension( "rpt" );
  83. const wxString FootprintPlaceFileExtension( "pos" );
  84. const wxString KiCadLib3DShapesPathExtension( "3dshapes" ); ///< 3D shapes default libpath
  85. const wxString KiCadFootprintLibPathExtension( "pretty" ); ///< KICAD PLUGIN libpath
  86. const wxString LegacyFootprintLibPathExtension( "mod" );
  87. const wxString EagleFootprintLibPathExtension( "lbr" );
  88. const wxString KiCadFootprintFileExtension( "kicad_mod" );
  89. const wxString GedaPcbFootprintLibFileExtension( "fp" );
  90. const wxString SpecctraDsnFileExtension( "dsn" );
  91. const wxString IpcD356FileExtension( "d356" );
  92. const wxString AllFilesWildcard( _( "All files (*)|*" ) );
  93. wxString SchematicSymbolFileWildcard()
  94. {
  95. return _( "KiCad drawing symbol files (*.sym)|*." ) + FormatWildcardExt( "sym" );
  96. }
  97. wxString SchematicLibraryFileWildcard()
  98. {
  99. return _( "KiCad symbol library files (*.lib)|*." ) + FormatWildcardExt( "lib" );
  100. }
  101. wxString ProjectFileWildcard()
  102. {
  103. return _( "KiCad project files (*.pro)|*." ) + FormatWildcardExt( "pro" );
  104. }
  105. wxString SchematicFileWildcard()
  106. {
  107. return _( "KiCad schematic files (*.sch)|*." ) + FormatWildcardExt( "sch" );
  108. }
  109. wxString EagleSchematicFileWildcard()
  110. {
  111. return _( "Eagle XML schematic files (*.sch)|*." ) + FormatWildcardExt( "sch" );
  112. }
  113. wxString EagleFilesWildcard()
  114. {
  115. return _( "Eagle XML files (*.sch *.brd)|*." ) +
  116. FormatWildcardExt( "sch" ) + ";*." + FormatWildcardExt( "brd" );
  117. }
  118. wxString NetlistFileWildcard()
  119. {
  120. return _( "KiCad netlist files (*.net)|*." ) + FormatWildcardExt( "net" );
  121. }
  122. wxString GerberFileWildcard()
  123. {
  124. return _( "Gerber files (*.pho)|*." ) + FormatWildcardExt( "pho" );
  125. }
  126. wxString LegacyPcbFileWildcard()
  127. {
  128. return _( "KiCad printed circuit board files (*.brd)|*." ) + FormatWildcardExt( "brd" );
  129. }
  130. wxString EaglePcbFileWildcard()
  131. {
  132. return _( "Eagle ver. 6.x XML PCB files (*.brd)|*." ) + FormatWildcardExt( "brd" );
  133. }
  134. wxString PCadPcbFileWildcard()
  135. {
  136. return _( "P-Cad 200x ASCII PCB files (*.pcb)|*." ) + FormatWildcardExt( "pcb" );
  137. }
  138. wxString PcbFileWildcard()
  139. {
  140. return _( "KiCad printed circuit board files (*.kicad_pcb)|*." ) +
  141. FormatWildcardExt( "kicad_pcb" );
  142. }
  143. wxString KiCadFootprintLibFileWildcard()
  144. {
  145. return _( "KiCad footprint files (*.kicad_mod)|*." ) + FormatWildcardExt( "kicad_mod" );
  146. }
  147. wxString KiCadFootprintLibPathWildcard()
  148. {
  149. return _( "KiCad footprint library paths (*.pretty)|*." ) + FormatWildcardExt( "pretty" );
  150. }
  151. wxString LegacyFootprintLibPathWildcard()
  152. {
  153. return _( "Legacy footprint library files (*.mod)|*." ) + FormatWildcardExt( "mod" );
  154. }
  155. wxString EagleFootprintLibPathWildcard()
  156. {
  157. return _( "Eagle ver. 6.x XML library files (*.lbr)|*." ) + FormatWildcardExt( "lbr" );
  158. }
  159. wxString GedaPcbFootprintLibFileWildcard()
  160. {
  161. return _( "Geda PCB footprint library files (*.fp)|*." ) + FormatWildcardExt( "fp" );
  162. }
  163. wxString PageLayoutDescrFileWildcard()
  164. {
  165. return _( "Page layout design files (*.kicad_wks)|*." ) + FormatWildcardExt( "kicad_wks" );
  166. }
  167. // Wildcard for cvpcb component to footprint link file
  168. wxString ComponentFileWildcard()
  169. {
  170. return _( "KiCad symbol footprint link files (*.cmp)|*." ) + FormatWildcardExt( "cmp" );
  171. }
  172. // Wildcard for reports and fabrication documents
  173. wxString DrillFileWildcard()
  174. {
  175. return _( "Drill files (*.drl)|*." ) + FormatWildcardExt( "drl" );
  176. }
  177. wxString SVGFileWildcard()
  178. {
  179. return _( "SVG files (*.svg)|*." ) + FormatWildcardExt( "svg" );
  180. }
  181. wxString HtmlFileWildcard()
  182. {
  183. return _( "HTML files (*.html)|*." ) + FormatWildcardExt( "htm" ) + ";*.," +
  184. FormatWildcardExt( "html" );
  185. }
  186. wxString CsvFileWildcard()
  187. {
  188. return _( "CSV Files (*.csv)|*." ) + FormatWildcardExt( "csv" );
  189. }
  190. wxString PdfFileWildcard()
  191. {
  192. return _( "Portable document format files (*.pdf)|*." ) + FormatWildcardExt( "pdf" );
  193. }
  194. wxString PSFileWildcard()
  195. {
  196. return _( "PostScript files (.ps)|*." ) + FormatWildcardExt( "ps" );
  197. }
  198. wxString ReportFileWildcard()
  199. {
  200. return _( "Report files (*.rpt)|*." ) + FormatWildcardExt( "rpt" );
  201. }
  202. wxString FootprintPlaceFileWildcard()
  203. {
  204. return _( "Footprint place files (*.pos)|*." ) + FormatWildcardExt( "pos" );
  205. }
  206. wxString Shapes3DFileWildcard()
  207. {
  208. return _( "VRML and X3D files (*.wrl *.x3d)|*." ) + FormatWildcardExt( "wrl" ) +
  209. ";*." + FormatWildcardExt( "x3d" );
  210. }
  211. wxString IDF3DFileWildcard()
  212. {
  213. return _( "IDFv3 footprint files (*.idf)|*." ) + FormatWildcardExt( "idf" );
  214. }
  215. wxString TextFileWildcard()
  216. {
  217. return _( "Text files (*.txt)|*." ) + FormatWildcardExt( "txt" );
  218. }
  219. wxString ModLegacyExportFileWildcard()
  220. {
  221. return _( "Legacy footprint export files (*.emp)|*." ) + FormatWildcardExt( "emp" );
  222. }
  223. wxString ErcFileWildcard()
  224. {
  225. return _( "Electronic rule check file (.erc)|*." ) + FormatWildcardExt( "erc" );
  226. }
  227. wxString SpiceLibraryFileWildcard()
  228. {
  229. return _( "Spice library file (*.lib)|*." ) + FormatWildcardExt( "lib" );
  230. }
  231. wxString SpiceNetlistFileWildcard()
  232. {
  233. return _( "SPICE netlist file (.cir)|*." ) + FormatWildcardExt( "cir" );
  234. }
  235. wxString CadstarNetlistFileWildcard()
  236. {
  237. return _( "CadStar netlist file (.frp)|*." ) + FormatWildcardExt( "frp" );
  238. }
  239. wxString EquFileWildcard()
  240. {
  241. return _( "Symbol footprint association files (*.equ)|*." ) + FormatWildcardExt( "equ" );
  242. }
  243. wxString ZipFileWildcard()
  244. {
  245. return _( "Zip file (*.zip)|*." ) + FormatWildcardExt( "zip" );
  246. }
  247. wxString GencadFileWildcard()
  248. {
  249. return _( "GenCAD 1.4 board files (.cad)|*." ) + FormatWildcardExt( "cad" );
  250. }
  251. wxString DxfFileWildcard()
  252. {
  253. return _( "DXF Files (*.dxf)|*." ) + FormatWildcardExt( "dxf" );
  254. }
  255. wxString GerberJobFileWildcard()
  256. {
  257. return _( "Gerber job file (*.gbrjob)|*." ) + FormatWildcardExt( "gbrjob" ) +
  258. ";.gbrjob";
  259. }
  260. wxString SpecctraDsnFileWildcard()
  261. {
  262. return _( "Specctra DSN file (*.dsn)|*." ) + FormatWildcardExt( "dsn" );
  263. }
  264. wxString IpcD356FileWildcard()
  265. {
  266. return _( "IPC-D-356 Test Files (.d356)|*." ) + FormatWildcardExt( "d356" );
  267. }
  268. wxString WorkbookFileWildcard()
  269. {
  270. return _( "Workbook file (*.wbk)|*." ) + FormatWildcardExt( "wbk" );
  271. }
  272. wxString PngFileWildcard()
  273. {
  274. return _( "PNG file (*.png)|*." ) + FormatWildcardExt( "png" );
  275. }