KiCad PCB EDA Suite
common.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2018 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 
30 #include <fctsys.h>
31 #include <eda_base_frame.h>
32 #include <base_struct.h>
33 #include <common.h>
34 #include <macros.h>
35 #include <base_units.h>
36 #include <reporter.h>
37 
38 #include <wx/process.h>
39 #include <wx/config.h>
40 #include <wx/utils.h>
41 #include <wx/stdpaths.h>
42 #include <wx/url.h>
43 
44 #include <pgm_base.h>
45 
46 using KIGFX::COLOR4D;
47 
48 
58 
59 
60 std::atomic<unsigned int> LOCALE_IO::m_c_count(0);
61 
63 {
64  // use thread safe, atomic operation
65  if( m_c_count++ == 0 )
66  {
67  // Store the user locale name, to restore this locale later, in dtor
68  m_user_locale = setlocale( LC_ALL, 0 );
69  // Switch the locale to C locale, to read/write files with fp numbers
70  setlocale( LC_ALL, "C" );
71  }
72 }
73 
74 
76 {
77  // use thread safe, atomic operation
78  if( --m_c_count == 0 )
79  {
80  // revert to the user locale
81  setlocale( LC_ALL, m_user_locale.c_str() );
82  }
83 }
84 
85 
86 wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow )
87 {
88  wxCoord width;
89  wxCoord height;
90 
91  {
92  wxClientDC dc( aWindow );
93  dc.SetFont( aWindow->GetFont() );
94  dc.GetTextExtent( aSingleLine, &width, &height );
95  }
96 
97  return wxSize( width, height );
98 }
99 
100 
101 bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString )
102 {
103  wxWindow* window = aCtrl->GetParent();
104 
105  if( !window )
106  window = aCtrl;
107 
108  wxString ctrlText;
109 
110  if( !aString )
111  {
112  ctrlText = aCtrl->GetValue();
113  aString = &ctrlText;
114  }
115 
116  wxSize textz = GetTextSize( *aString, window );
117  wxSize ctrlz = aCtrl->GetSize();
118 
119  if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
120  {
121  ctrlz.SetWidth( textz.GetWidth() + 10 );
122  aCtrl->SetSizeHints( ctrlz );
123  return true;
124  }
125 
126  return false;
127 }
128 
129 
130 void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter )
131 {
132  wxString tmp;
133 
134  for( unsigned ii = 0; ii < aText.Length(); ii++ )
135  {
136  if( aText[ii] == aSplitter )
137  {
138  aStrings.Add( tmp );
139  tmp.Clear();
140  }
141 
142  else
143  tmp << aText[ii];
144  }
145 
146  if( !tmp.IsEmpty() )
147  {
148  aStrings.Add( tmp );
149  }
150 }
151 
152 
153 int ProcessExecute( const wxString& aCommandLine, int aFlags, wxProcess *callback )
154 {
155  return wxExecute( aCommandLine, aFlags, callback );
156 }
157 
158 
160 {
161  static timestamp_t oldTimeStamp;
162  timestamp_t newTimeStamp;
163 
164  newTimeStamp = time( NULL );
165 
166  if( newTimeStamp <= oldTimeStamp )
167  newTimeStamp = oldTimeStamp + 1;
168 
169  oldTimeStamp = newTimeStamp;
170 
171  return newTimeStamp;
172 }
173 
174 
175 double RoundTo0( double x, double precision )
176 {
177  assert( precision != 0 );
178 
179  long long ix = KiROUND( x * precision );
180 
181  if ( x < 0.0 )
182  ix = -ix;
183 
184  int remainder = ix % 10; // remainder is in precision mm
185 
186  if( remainder <= 2 )
187  ix -= remainder; // truncate to the near number
188  else if( remainder >= 8 )
189  ix += 10 - remainder; // round to near number
190 
191  if ( x < 0 )
192  ix = -ix;
193 
194  return (double) ix / precision;
195 }
196 
197 
198 wxConfigBase* GetNewConfig( const wxString& aProgName )
199 {
200  wxConfigBase* cfg = 0;
201  wxFileName configname;
202  configname.AssignDir( GetKicadConfigPath() );
203  configname.SetFullName( aProgName );
204 
205  cfg = new wxFileConfig( wxT( "" ), wxT( "" ), configname.GetFullPath() );
206  return cfg;
207 }
208 
209 
211 {
212  wxFileName cfgpath;
213 
214  // http://docs.wxwidgets.org/3.0/classwx_standard_paths.html#a7c7cf595d94d29147360d031647476b0
215  cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
216 
217  // GetUserConfigDir() does not default to ~/.config which is the current standard
218  // configuration file location on Linux. This has been fixed in later versions of wxWidgets.
219 #if !defined( __WXMSW__ ) && !defined( __WXMAC__ )
220  wxArrayString dirs = cfgpath.GetDirs();
221 
222  if( dirs.Last() != ".config" )
223  cfgpath.AppendDir( ".config" );
224 #endif
225 
226  wxString envstr;
227 
228  // This shouldn't cause any issues on Windows or MacOS.
229  if( wxGetEnv( wxT( "XDG_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
230  {
231  // Override the assignment above with XDG_CONFIG_HOME
232  cfgpath.AssignDir( envstr );
233  }
234 
235  cfgpath.AppendDir( wxT( "kicad" ) );
236 
237  // Use KICAD_CONFIG_HOME to allow the user to force a specific configuration path.
238  if( wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
239  {
240  // Override the assignment above with KICAD_CONFIG_HOME
241  cfgpath.AssignDir( envstr );
242  }
243 
244  if( !cfgpath.DirExists() )
245  {
246  cfgpath.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
247  }
248 
249  return cfgpath.GetPath();
250 }
251 
252 
254 {
258 #ifdef __WINDOWS__
259  Bracket_Windows = '%', // yeah, Windows people are a bit strange ;-)
260 #endif
262 };
263 
264 
265 //
266 // Stolen from wxExpandEnvVars and then heavily optimized
267 //
268 wxString KIwxExpandEnvVars(const wxString& str)
269 {
270  size_t strlen = str.length();
271 
272  wxString strResult;
273  strResult.Alloc(strlen);
274 
275  for ( size_t n = 0; n < strlen; n++ ) {
276  wxUniChar str_n = str[n];
277 
278  switch ( str_n.GetValue() ) {
279 #ifdef __WINDOWS__
280  case wxT('%'):
281 #endif // __WINDOWS__
282  case wxT('$'):
283  {
284  Bracket bracket;
285 #ifdef __WINDOWS__
286  if ( str_n == wxT('%') )
287  bracket = Bracket_Windows;
288  else
289 #endif // __WINDOWS__
290  if ( n == strlen - 1 ) {
291  bracket = Bracket_None;
292  }
293  else {
294  switch ( str[n + 1].GetValue() ) {
295  case wxT('('):
296  bracket = Bracket_Normal;
297  str_n = str[++n]; // skip the bracket
298  break;
299 
300  case wxT('{'):
301  bracket = Bracket_Curly;
302  str_n = str[++n]; // skip the bracket
303  break;
304 
305  default:
306  bracket = Bracket_None;
307  }
308  }
309 
310  size_t m = n + 1;
311  wxUniChar str_m = str[m];
312 
313  while ( m < strlen && (wxIsalnum(str_m) || str_m == wxT('_')) )
314  str_m = str[++m];
315 
316  wxString strVarName(str.c_str() + n + 1, m - n - 1);
317 
318 #ifdef __WXWINCE__
319  const bool expanded = false;
320 #else
321  // NB: use wxGetEnv instead of wxGetenv as otherwise variables
322  // set through wxSetEnv may not be read correctly!
323  bool expanded = false;
324  wxString tmp;
325  if (wxGetEnv(strVarName, &tmp))
326  {
327  strResult += tmp;
328  expanded = true;
329  }
330  else
331 #endif
332  {
333  // variable doesn't exist => don't change anything
334 #ifdef __WINDOWS__
335  if ( bracket != Bracket_Windows )
336 #endif
337  if ( bracket != Bracket_None )
338  strResult << str[n - 1];
339  strResult << str_n << strVarName;
340  }
341 
342  // check the closing bracket
343  if ( bracket != Bracket_None ) {
344  if ( m == strlen || str_m != (wxChar)bracket ) {
345  // under MSW it's common to have '%' characters in the registry
346  // and it's annoying to have warnings about them each time, so
347  // ignroe them silently if they are not used for env vars
348  //
349  // under Unix, OTOH, this warning could be useful for the user to
350  // understand why isn't the variable expanded as intended
351 #ifndef __WINDOWS__
352  wxLogWarning(_("Environment variables expansion failed: missing '%c' at position %u in '%s'."),
353  (char)bracket, (unsigned int) (m + 1), str.c_str());
354 #endif // __WINDOWS__
355  }
356  else {
357  // skip closing bracket unless the variables wasn't expanded
358  if ( !expanded )
359  strResult << (wxChar)bracket;
360  str_m = str[++m];
361  }
362  }
363 
364  n = m - 1; // skip variable name
365  str_n = str[n];
366  }
367  break;
368 
369  case wxT('\\'):
370  // backslash can be used to suppress special meaning of % and $
371  if ( n != strlen - 1 && (str[n + 1] == wxT('%') || str[n + 1] == wxT('$')) ) {
372  str_n = str[++n];
373  strResult += str_n;
374 
375  break;
376  }
377  //else: fall through
378 
379  default:
380  strResult += str_n;
381  }
382  }
383 
384  return strResult;
385 }
386 
387 
388 #include <ki_mutex.h>
389 const wxString ExpandEnvVarSubstitutions( const wxString& aString )
390 {
391  // wxGetenv( wchar_t* ) is not re-entrant on linux.
392  // Put a lock on multithreaded use of wxGetenv( wchar_t* ), called from wxEpandEnvVars(),
393  static MUTEX getenv_mutex;
394 
395  MUTLOCK lock( getenv_mutex );
396 
397  // We reserve the right to do this another way, by providing our own member
398  // function.
399  return KIwxExpandEnvVars( aString );
400 }
401 
402 
403 const wxString ResolveUriByEnvVars( const wxString& aUri )
404 {
405  // URL-like URI: return as is.
406  wxURL url( aUri );
407  if( url.GetError() == wxURL_NOERR )
408  return aUri;
409 
410  // Otherwise, the path points to a local file. Resolve environment
411  // variables if any.
412  return ExpandEnvVarSubstitutions( aUri );
413 }
414 
415 
416 bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName,
417  const wxString& aBaseFilename,
418  REPORTER* aReporter )
419 {
420  wxString msg;
421  wxString baseFilePath = wxFileName( aBaseFilename ).GetPath();
422 
423  // make aTargetFullFileName path, which is relative to aBaseFilename path (if it is not
424  // already an absolute path) absolute:
425  if( !aTargetFullFileName->MakeAbsolute( baseFilePath ) )
426  {
427  if( aReporter )
428  {
429  msg.Printf( _( "Cannot make path \"%s\" absolute with respect to \"%s\"." ),
430  GetChars( aTargetFullFileName->GetPath() ),
431  GetChars( baseFilePath ) );
432  aReporter->Report( msg, REPORTER::RPT_ERROR );
433  }
434 
435  return false;
436  }
437 
438  // Ensure the path of aTargetFullFileName exists, and create it if needed:
439  wxString outputPath( aTargetFullFileName->GetPath() );
440 
441  if( !wxFileName::DirExists( outputPath ) )
442  {
443  if( wxMkdir( outputPath ) )
444  {
445  if( aReporter )
446  {
447  msg.Printf( _( "Output directory \"%s\" created.\n" ), GetChars( outputPath ) );
448  aReporter->Report( msg, REPORTER::RPT_INFO );
449  return true;
450  }
451  }
452  else
453  {
454  if( aReporter )
455  {
456  msg.Printf( _( "Cannot create output directory \"%s\".\n" ),
457  GetChars( outputPath ) );
458  aReporter->Report( msg, REPORTER::RPT_ERROR );
459  }
460 
461  return false;
462  }
463  }
464 
465  return true;
466 }
467 
468 
469 #ifdef __WXMAC__
470 wxString GetOSXKicadUserDataDir()
471 {
472  // According to wxWidgets documentation for GetUserDataDir:
473  // Mac: ~/Library/Application Support/appname
474  wxFileName udir( wxStandardPaths::Get().GetUserDataDir(), wxEmptyString );
475 
476  // Since appname is different if started via launcher or standalone binary
477  // map all to "kicad" here
478  udir.RemoveLastDir();
479  udir.AppendDir( wxT( "kicad" ) );
480 
481  return udir.GetPath();
482 }
483 
484 
485 wxString GetOSXKicadMachineDataDir()
486 {
487  return wxT( "/Library/Application Support/kicad" );
488 }
489 
490 
491 wxString GetOSXKicadDataDir()
492 {
493  // According to wxWidgets documentation for GetDataDir:
494  // Mac: appname.app/Contents/SharedSupport bundle subdirectory
495  wxFileName ddir( wxStandardPaths::Get().GetDataDir(), wxEmptyString );
496 
497  // This must be mapped to main bundle for everything but kicad.app
498  const wxArrayString dirs = ddir.GetDirs();
499  if( dirs[dirs.GetCount() - 3] != wxT( "kicad.app" ) )
500  {
501  // Bundle structure resp. current path is
502  // kicad.app/Contents/Applications/<standalone>.app/Contents/SharedSupport
503  // and will be mapped to
504  // kicad.app/Contents/SharedSupprt
505  ddir.RemoveLastDir();
506  ddir.RemoveLastDir();
507  ddir.RemoveLastDir();
508  ddir.RemoveLastDir();
509  ddir.AppendDir( wxT( "SharedSupport" ) );
510  }
511 
512  return ddir.GetPath();
513 }
514 #endif
515 
516 // add this only if it is not in wxWidgets (for instance before 3.1.0)
517 #ifdef USE_KICAD_WXSTRING_HASH
518 size_t std::hash<wxString>::operator()( const wxString& s ) const
519 {
520  return std::hash<std::wstring>{}( s.ToStdWstring() );
521 }
522 #endif
523 
524 
525 #ifdef USE_KICAD_WXPOINT_LESS
526 bool std::less<wxPoint>::operator()( const wxPoint& aA, const wxPoint& aB ) const
527 {
528  if( aA.x == aB.x )
529  return aA.y < aB.y;
530 
531  return aA.x < aB.x;
532 }
533 #endif
534 
535 
551 WX_FILENAME::WX_FILENAME( const wxString& aPath, const wxString& aFilename ) :
552  m_fn( aPath, aFilename ),
553  m_path( aPath ),
554  m_fullName( aFilename )
555 { }
556 
557 
558 void WX_FILENAME::SetFullName( const wxString& aFileNameAndExtension )
559 {
560  m_fullName = aFileNameAndExtension;
561 }
562 
563 
564 wxString WX_FILENAME::GetName() const
565 {
566  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
567  return m_fullName.substr( 0, dot );
568 }
569 
570 
571 wxString WX_FILENAME::GetFullName() const
572 {
573  return m_fullName;
574 }
575 
576 
577 wxString WX_FILENAME::GetPath() const
578 {
579  return m_path;
580 }
581 
582 
583 wxString WX_FILENAME::GetFullPath() const
584 {
585  return m_path + wxT( '/' ) + m_fullName;
586 }
587 
588 
589 // Write locally-cached values to the wxFileName. MUST be called before using m_fn.
591 {
592  size_t dot = m_fullName.find_last_of( wxT( '.' ) );
593  m_fn.SetName( m_fullName.substr( 0, dot ) );
594  m_fn.SetExt( m_fullName.substr( dot + 1 ) );
595 }
596 
597 
599 {
600  resolve();
601 
602  if( m_fn.FileExists() )
603  return m_fn.GetModificationTime().GetValue().GetValue();
604 
605  return 0;
606 }
607 
608 
615 bool matchWild( const char* pat, const char* text, bool dot_special )
616 {
617  if ( !*text )
618  {
619  /* Match if both are empty. */
620  return !*pat;
621  }
622 
623  const char *m = pat,
624  *n = text,
625  *ma = NULL,
626  *na = NULL;
627  int just = 0,
628  acount = 0,
629  count = 0;
630 
631  if (dot_special && (*n == '.'))
632  {
633  /* Never match so that hidden Unix files
634  * are never found. */
635  return false;
636  }
637 
638  for (;;)
639  {
640  if (*m == '*')
641  {
642  ma = ++m;
643  na = n;
644  just = 1;
645  acount = count;
646  }
647  else if (*m == '?')
648  {
649  m++;
650  if (!*n++)
651  return false;
652  }
653  else
654  {
655  if (*m == '\\')
656  {
657  m++;
658  /* Quoting "nothing" is a bad thing */
659  if (!*m)
660  return false;
661  }
662  if (!*m)
663  {
664  /*
665  * If we are out of both strings or we just
666  * saw a wildcard, then we can say we have a
667  * match
668  */
669  if (!*n)
670  return true;
671  if (just)
672  return true;
673  just = 0;
674  goto not_matched;
675  }
676  /*
677  * We could check for *n == NULL at this point, but
678  * since it's more common to have a character there,
679  * check to see if they match first (m and n) and
680  * then if they don't match, THEN we can check for
681  * the NULL of n
682  */
683  just = 0;
684  if (*m == *n)
685  {
686  m++;
687  count++;
688  n++;
689  }
690  else
691  {
692 
693  not_matched:
694 
695  /*
696  * If there are no more characters in the
697  * string, but we still need to find another
698  * character (*m != NULL), then it will be
699  * impossible to match it
700  */
701  if (!*n)
702  return false;
703 
704  if (ma)
705  {
706  m = ma;
707  n = ++na;
708  count = acount;
709  }
710  else
711  return false;
712  }
713  }
714  }
715 }
716 
717 
722 #if wxUSE_DATETIME && defined(__WIN32__) && !defined(__WXMICROWIN__)
723 
724 // Convert between wxDateTime and FILETIME which is a 64-bit value representing
725 // the number of 100-nanosecond intervals since January 1, 1601 UTC.
726 //
727 // This is the offset between FILETIME epoch and the Unix/wxDateTime Epoch.
728 static wxInt64 EPOCH_OFFSET_IN_MSEC = wxLL(11644473600000);
729 
730 static void ConvertFileTimeToWx(wxDateTime *dt, const FILETIME &ft)
731 {
732  wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime);
733  t /= 10000; // Convert hundreds of nanoseconds to milliseconds.
734  t -= EPOCH_OFFSET_IN_MSEC;
735 
736  *dt = wxDateTime(t);
737 }
738 
739 #endif // wxUSE_DATETIME && __WIN32__
740 
741 
751 long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
752 {
753  long long timestamp = 0;
754 
755 #if defined(__WIN32__)
756  // Win32 version.
757  // Save time by not searching for each path twice: once in wxDir.GetNext() and once in
758  // wxFileName.GetModificationTime(). Also cuts out wxWidgets' string-matching and case
759  // conversion by staying on the MSW side of things.
760  std::wstring filespec( aDirPath.t_str() );
761  filespec += '\\';
762  filespec += aFilespec.t_str();
763 
764  WIN32_FIND_DATA findData;
765  wxDateTime lastModDate;
766 
767  HANDLE fileHandle = ::FindFirstFile( filespec.data(), &findData );
768 
769  if( fileHandle != INVALID_HANDLE_VALUE )
770  {
771  do
772  {
773  ConvertFileTimeToWx( &lastModDate, findData.ftLastWriteTime );
774  timestamp += lastModDate.GetValue().GetValue();
775  }
776  while ( FindNextFile( fileHandle, &findData ) != 0);
777  }
778 
779  FindClose( fileHandle );
780 #else
781  // POSIX version.
782  // Save time by not converting between encodings -- do everything on the file-system side.
783  std::string filespec( aFilespec.fn_str() );
784  std::string dir_path( aDirPath.fn_str() );
785 
786  DIR* dir = opendir( dir_path.c_str() );
787 
788  if( dir )
789  {
790  for( dirent* dir_entry = readdir( dir ); dir_entry; dir_entry = readdir( dir ) )
791  {
792  if( !matchWild( filespec.c_str(), dir_entry->d_name, true ) )
793  continue;
794 
795  std::string entry_path = dir_path + '/' + dir_entry->d_name;
796  struct stat entry_stat;
797 
798  wxCRT_Lstat( entry_path.c_str(), &entry_stat );
799 
800  // Timestamp the source file, not the symlink
801  if( S_ISLNK( entry_stat.st_mode ) ) // wxFILE_EXISTS_SYMLINK
802  {
803  char buffer[ PATH_MAX + 1 ];
804  ssize_t pathLen = readlink( entry_path.c_str(), buffer, PATH_MAX );
805 
806  if( pathLen > 0 )
807  {
808  buffer[ pathLen ] = '\0';
809  entry_path = dir_path + buffer;
810 
811  wxCRT_Lstat( entry_path.c_str(), &entry_stat );
812  }
813  }
814 
815  if( S_ISREG( entry_stat.st_mode ) ) // wxFileExists()
816  timestamp += entry_stat.st_mtime * 1000;
817  }
818  }
819 #endif
820 
821  return timestamp;
822 }
823 
824 
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:130
WX_FILENAME(const wxString &aPath, const wxString &aFilename)
Performance enhancements to file and directory operations.
Definition: common.cpp:551
wxString GetFullName() const
Definition: common.cpp:571
int ProcessExecute(const wxString &aCommandLine, int aFlags, wxProcess *callback)
Run a command in a child process.
Definition: common.cpp:153
~LOCALE_IO()
Definition: common.cpp:75
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:52
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
const wxString ResolveUriByEnvVars(const wxString &aUri)
Replace any environment variables in file-path uris (leaving network-path URIs alone).
Definition: common.cpp:403
Implementation of conversion functions that require both schematic and board internal units...
double RoundTo0(double x, double precision)
Round to the nearest precision.
Definition: common.cpp:175
wxString KIwxExpandEnvVars(const wxString &str)
Definition: common.cpp:268
wxConfigBase * GetNewConfig(const wxString &aProgName)
Create a new wxConfig so we can put configuration files in a more proper place for each platform...
Definition: common.cpp:198
boost::interprocess::interprocess_mutex MUTEX
Establish KiCad MUTEX choices here in this file: typedef MUTEX and typedef MUTLOCK.
Definition: ki_mutex.h:42
wxString m_path
Definition: common.h:408
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
void SetFullName(const wxString &aFileNameAndExtension)
Definition: common.cpp:558
const string & str
Definition: json11.cpp:596
This file contains miscellaneous commonly used macros and functions.
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: common.cpp:86
wxFileName m_fn
Definition: common.h:407
wxString GetPath() const
Definition: common.cpp:577
static std::atomic< unsigned int > m_c_count
Definition: common.h:189
long long GetTimestamp()
Definition: common.cpp:598
timestamp_t GetNewTimeStamp()
Definition: common.cpp:159
void resolve()
Definition: common.cpp:590
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: common.cpp:101
const wxString ExpandEnvVarSubstitutions(const wxString &aString)
Replace any environment variable references with their values.
Definition: common.cpp:389
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn&#39;t yet exist...
Definition: common.cpp:416
Bracket
Definition: common.cpp:253
Base window classes and related definitions.
long long TimestampDir(const wxString &aDirPath, const wxString &aFilespec)
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/...
Definition: common.cpp:751
LOCALE_IO()
Definition: common.cpp:62
wxString GetName() const
Definition: common.cpp:564
wxString GetKicadConfigPath()
Return the user configuration path used to store KiCad&#39;s configuration files.
Definition: common.cpp:210
bool matchWild(const char *pat, const char *text, bool dot_special)
A copy of wxMatchWild(), which wxWidgets attributes to Douglas A.
Definition: common.cpp:615
bool operator()(const wxPoint &aA, const wxPoint &aB) const
Definition: common.cpp:526
boost::interprocess::scoped_lock< MUTEX > MUTLOCK
Definition: ki_mutex.h:43
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
wxString GetFullPath() const
Definition: common.cpp:583
The common library.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
size_t operator()(const wxString &s) const
Definition: common.cpp:518
Basic classes for most KiCad items.
wxString m_fullName
Definition: common.h:409
COLOR4D g_GhostColor
Global variables definitions.
Definition: common.cpp:57
std::string m_user_locale
Definition: common.h:193
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39