| 977 | } |
| 978 | |
| 979 | void ThemeBase::LoadOneThemeComponents( teThemeType id, bool bOkIfNotFound ) |
| 980 | { |
| 981 | SwitchTheme( id ); |
| 982 | auto &resources = *mpSet; |
| 983 | // IF directory doesn't exist THEN return early. |
| 984 | const auto dir = ThemeComponentsDir(GetFilePath(), id); |
| 985 | if( !wxDirExists( dir )) |
| 986 | return; |
| 987 | |
| 988 | using namespace BasicUI; |
| 989 | |
| 990 | int n=0; |
| 991 | FilePath FileName; |
| 992 | for (size_t i = 0; i < resources.mImages.size(); ++i) |
| 993 | { |
| 994 | if( !(mBitmapFlags[i] & resFlagInternal) ) |
| 995 | { |
| 996 | FileName = ThemeComponent( dir, mBitmapNames[i] ); |
| 997 | if( wxFileExists( FileName )) |
| 998 | { |
| 999 | if( !resources.mImages[i].LoadFile( FileName, wxBITMAP_TYPE_PNG )) |
| 1000 | { |
| 1001 | ShowMessageBox( |
| 1002 | XO( |
| 1003 | /* i18n-hint: Do not translate png. It is the name of a file format.*/ |
| 1004 | "Audacity could not load file:\n %s.\nBad png format perhaps?") |
| 1005 | .Format( FileName )); |
| 1006 | return; |
| 1007 | } |
| 1008 | /// JKC: \bug (wxWidgets) A png may have been saved with alpha, but when you |
| 1009 | /// load it, it comes back with a mask instead! (well I guess it is more |
| 1010 | /// efficient). Anyway, we want alpha and not a mask, so we call InitAlpha, |
| 1011 | /// and that transfers the mask into the alpha channel, and we're done. |
| 1012 | if( ! resources.mImages[i].HasAlpha() ) |
| 1013 | { |
| 1014 | // wxLogDebug( wxT("File %s lacked alpha"), mBitmapNames[i] ); |
| 1015 | resources.mImages[i].InitAlpha(); |
| 1016 | } |
| 1017 | resources.mBitmaps[i] = wxBitmap( resources.mImages[i] ); |
| 1018 | n++; |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | // Now read complete information about the colors from one text file |
| 1024 | { |
| 1025 | const auto fName = wxFileName{ dir, ColorFileName }.GetFullPath(); |
| 1026 | wxTextFile file{ fName }; |
| 1027 | file.Open(); |
| 1028 | if (!file.IsOpened()) |
| 1029 | ShowMessageBox( XO("Couldn't read from file: %s").Format( fName ) ); |
| 1030 | else { |
| 1031 | ++n; |
| 1032 | // Scan the line for name and #xxxxxx; |
| 1033 | static const std::wregex expr{ |
| 1034 | LR"(^ *([_[:alnum:]]+).*#([0-9a-fA-F]{6});)" }; |
| 1035 | const auto begin = mColourNames.begin(), |
| 1036 | end = mColourNames.end(); |
nothing calls this directly
no test coverage detected