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.

250 lines
10 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2007-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  7. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file wildcards_and_files_ext.h
  28. * Definition of file extensions used in Kicad.
  29. */
  30. #ifndef INCLUDE_WILDCARDS_AND_FILES_EXT_H_
  31. #define INCLUDE_WILDCARDS_AND_FILES_EXT_H_
  32. #include <string>
  33. #include <vector>
  34. #include <wx/string.h>
  35. /**
  36. * \defgroup file_extensions File Extension Definitions
  37. *
  38. * @note Please do not changes these. If a different file extension is needed, create a new
  39. * definition in here. If you create a extension definition in another file, make sure
  40. * to add it to the Doxygen group "file_extensions" using the "addtogroup" tag. Also
  41. * note, just because they are defined as const doesn't guarantee that they cannot be
  42. * changed.
  43. *
  44. * @{
  45. */
  46. /**
  47. * Compare the given extension against the reference extensions to see if it matches any
  48. * of the reference extensions.
  49. *
  50. * This function uses the C++ regular expression functionality to perform the comparison,
  51. * so the reference extensions can be regular expressions of their own right. This means
  52. * that partial searches can be made, for example ^g.* can be used to see if the first
  53. * character of the extension is g. The reference extensions are concatenated together
  54. * as alternatives when doing the evaluation (e.g. (dxf|svg|^g.*) ).
  55. *
  56. * @param aExtension is the extension to test
  57. * @param aReference is a vector containing the extensions to test against
  58. * @param aCaseSensitive says if the comparison should be case sensitive or not
  59. *
  60. * @return if the extension matches any reference extensions
  61. */
  62. bool compareFileExtensions( const std::string& aExtension,
  63. const std::vector<std::string>& aReference, bool aCaseSensitive = false );
  64. /**
  65. * Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
  66. *
  67. * For instance, to open .txt files in a file dialog:
  68. * the base message is for instance "Text files"
  69. * the ext list is " (*.txt)|*.txt"
  70. * and the returned string to add to the base message is " (*.txt)|*.txt"
  71. * the message to display in the dialog is "Text files (*.txt)|*.txt"
  72. *
  73. * This function produces a case-insensitive filter (so .txt, .TXT and .tXT
  74. * are all match if you pass "txt" into the function).
  75. *
  76. * @param aExts is the list of exts to add to the filter. Do not include the
  77. * leading dot. Empty means "allow all files".
  78. *
  79. * @return the appropriate file dialog wildcard filter list.
  80. */
  81. wxString AddFileExtListToFilter( const std::vector<std::string>& aExts );
  82. /**
  83. * Format wildcard extension to support case sensitive file dialogs.
  84. *
  85. * The file extension wildcards of the GTK+ file dialog are case sensitive so using all lower
  86. * case characters means that only file extensions that are all lower case will show up in the
  87. * file dialog. The GTK+ file dialog does support regular expressions so the file extension
  88. * is converted to a regular expression ( sch -> [sS][cC][hH] ) when wxWidgets is built against
  89. * GTK+. Please make sure you call this function when adding new file wildcards.
  90. *
  91. * @note When calling wxFileDialog with a default file defined, make sure you include the
  92. * file extension along with the file name. Otherwise, on GTK+ builds, the file
  93. * dialog will append the wildcard regular expression as the file extension which is
  94. * surely not what you want.
  95. *
  96. * @param aWildcard is the extension part of the wild card.
  97. *
  98. * @return the build appropriate file dialog wildcard filter.
  99. */
  100. wxString formatWildcardExt( const wxString& aWildcard );
  101. extern const std::string BackupFileSuffix;
  102. extern const std::string SchematicSymbolFileExtension;
  103. extern const std::string LegacySymbolLibFileExtension;
  104. extern const std::string LegacySymbolDocumentFileExtension;
  105. extern const std::string SchematicBackupFileExtension;
  106. extern const std::string VrmlFileExtension;
  107. extern const std::string ProjectFileExtension;
  108. extern const std::string LegacyProjectFileExtension;
  109. extern const std::string ProjectLocalSettingsFileExtension;
  110. extern const std::string LegacySchematicFileExtension;
  111. extern const std::string KiCadSchematicFileExtension;
  112. extern const std::string NetlistFileExtension;
  113. extern const std::string GerberFileExtension;
  114. extern const std::string GerberJobFileExtension;
  115. extern const std::string HtmlFileExtension;
  116. extern const std::string EquFileExtension;
  117. extern const std::string HotkeyFileExtension;
  118. extern const std::string ArchiveFileExtension;
  119. extern const std::string LegacyPcbFileExtension;
  120. extern const std::string KiCadPcbFileExtension;
  121. #define PcbFileExtension KiCadPcbFileExtension // symlink choice
  122. extern const std::string KiCadSymbolLibFileExtension;
  123. extern const std::string DrawingSheetFileExtension;
  124. extern const std::string DesignRulesFileExtension;
  125. extern const std::string LegacyFootprintLibPathExtension;
  126. extern const std::string PdfFileExtension;
  127. extern const std::string MacrosFileExtension;
  128. extern const std::string FootprintAssignmentFileExtension;
  129. extern const std::string DrillFileExtension;
  130. extern const std::string SVGFileExtension;
  131. extern const std::string ReportFileExtension;
  132. extern const std::string FootprintPlaceFileExtension;
  133. extern const std::string KiCadFootprintFileExtension;
  134. extern const std::string KiCadFootprintLibPathExtension;
  135. extern const std::string GedaPcbFootprintLibFileExtension;
  136. extern const std::string EagleFootprintLibPathExtension;
  137. extern const std::string DrawingSheetFileExtension;
  138. extern const std::string SpecctraDsnFileExtension;
  139. extern const std::string SpecctraSessionFileExtension;
  140. extern const std::string IpcD356FileExtension;
  141. extern const std::string WorkbookFileExtension;
  142. extern const std::string PngFileExtension;
  143. extern const std::string JpegFileExtension;
  144. extern const std::string TextFileExtension;
  145. bool IsProtelExtension( const wxString& ext );
  146. /**
  147. * @}
  148. */
  149. /**
  150. * \defgroup file_wildcards File Wildcard Definitions
  151. *
  152. * @note Please do not changes these. If a different file wildcard is needed, create a new
  153. * definition in here. If you create a wildcard definition in another file, make sure
  154. * to add it to the Doxygen group "file_extensions" using the "addtogroup" tag and
  155. * correct handle the GTK+ file dialog case sensitivity issue.
  156. * @{
  157. */
  158. extern wxString AllFilesWildcard();
  159. extern wxString FootprintAssignmentFileWildcard();
  160. extern wxString DrawingSheetFileWildcard();
  161. extern wxString SchematicSymbolFileWildcard();
  162. extern wxString KiCadSymbolLibFileWildcard();
  163. extern wxString LegacySymbolLibFileWildcard();
  164. extern wxString AllSymbolLibFilesWildcard();
  165. extern wxString ProjectFileWildcard();
  166. extern wxString LegacyProjectFileWildcard();
  167. extern wxString AllProjectFilesWildcard();
  168. extern wxString KiCadSchematicFileWildcard();
  169. extern wxString LegacySchematicFileWildcard();
  170. extern wxString BoardFileWildcard();
  171. extern wxString NetlistFileWildcard();
  172. extern wxString GerberFileWildcard();
  173. extern wxString HtmlFileWildcard();
  174. extern wxString CsvFileWildcard();
  175. extern wxString LegacyPcbFileWildcard();
  176. extern wxString PcbFileWildcard();
  177. extern wxString EaglePcbFileWildcard();
  178. extern wxString AltiumSchematicFileWildcard();
  179. extern wxString CadstarSchematicArchiveFileWildcard();
  180. extern wxString CadstarArchiveFilesWildcard();
  181. extern wxString EagleSchematicFileWildcard();
  182. extern wxString EagleFilesWildcard();
  183. extern wxString PCadPcbFileWildcard();
  184. extern wxString CadstarPcbArchiveFileWildcard();
  185. extern wxString AltiumDesignerPcbFileWildcard();
  186. extern wxString AltiumCircuitStudioPcbFileWildcard();
  187. extern wxString AltiumCircuitMakerPcbFileWildcard();
  188. extern wxString FabmasterPcbFileWildcard();
  189. extern wxString PdfFileWildcard();
  190. extern wxString PSFileWildcard();
  191. extern wxString MacrosFileWildcard();
  192. extern wxString DrillFileWildcard();
  193. extern wxString SVGFileWildcard();
  194. extern wxString ReportFileWildcard();
  195. extern wxString FootprintPlaceFileWildcard();
  196. extern wxString Shapes3DFileWildcard();
  197. extern wxString IDF3DFileWildcard();
  198. extern wxString DocModulesFileName();
  199. extern wxString LegacyFootprintLibPathWildcard();
  200. extern wxString KiCadFootprintLibFileWildcard();
  201. extern wxString KiCadFootprintLibPathWildcard();
  202. extern wxString GedaPcbFootprintLibFileWildcard();
  203. extern wxString EagleFootprintLibPathWildcard();
  204. extern wxString TextFileWildcard();
  205. extern wxString ModLegacyExportFileWildcard();
  206. extern wxString ErcFileWildcard();
  207. extern wxString SpiceLibraryFileWildcard();
  208. extern wxString SpiceNetlistFileWildcard();
  209. extern wxString CadstarNetlistFileWildcard();
  210. extern wxString EquFileWildcard();
  211. extern wxString ZipFileWildcard();
  212. extern wxString GencadFileWildcard();
  213. extern wxString DxfFileWildcard();
  214. extern wxString GerberJobFileWildcard();
  215. extern wxString SpecctraDsnFileWildcard();
  216. extern wxString SpecctraSessionFileWildcard();
  217. extern wxString IpcD356FileWildcard();
  218. extern wxString WorkbookFileWildcard();
  219. extern wxString PngFileWildcard();
  220. extern wxString JpegFileWildcard();
  221. extern wxString HotkeyFileWildcard();
  222. /**
  223. * @}
  224. */
  225. #endif // INCLUDE_WILDCARDS_AND_FILES_EXT_H_