[wxWidgets 3.1.3在Mac下加载图标-无法读取ICNS文件?

问题描述 投票:0回答:1

现在似乎无法在Mac下加载.icns文件。以前使用wxIcon和wxIconLocation是可能的,例如

wxMimeTypesManager manager;
wxFileType *type = manager.GetFileTypeFromExtension("zip");
wxIconLocation location;
if(type->GetIcon(&location))
{
  // location m_filename is something like "/System/Library/CoreServices/Applications/Archive Utility.app/Contents/Resources/bah-zip.icns"
  wxIcon icon;
  // This will FAIL now as there is no handler for wxBITMAP_TYPE_ICON...
  icon.LoadFile(location.GetFileName(), wxBITMAP_TYPE_ICON, 32, 32);
}

wxMimeTypesManager :: GetFileTypeFromExtension返回wxFileType。然后,您可以使用wxFileType :: GetIcon返回wxIconLocation。

wxIconLocation :: GetFileName()返回OSX下的.icns文件。如果您将wxBITMAP_TYPE_ICON传递给wxIcon :: LoadFile,则以前可以在wxWidgets 2.9.1下将其作为wxIcon加载,因为这迫使wxIcon :: LoadIconFromFile(src / osx / carbon / icon.cpp)使用ReadIconFromFSRef从icns加载。

但是既然所有的Carbon代码都消失了,现在我无法从.icns文件中加载任何内容。

我现在该怎么办?

编辑:我使用以下配置:configure --disable-shared --enable-unicode --prefix="$(pwd)" --enable-stc --enable-ipc --enable-base64 --enable-exceptions --enable-fontenum --enable-fs_archive --enable-stdpaths --enable-sysoptions --enable-threads --enable-url --enable-aui --enable-graphics_ctx --enable-printarch --enable-timer --enable-ribbon --enable-webview --enable-display --enable-splash --enable-snglinst --enable-printfposparam --with-opengl --with-osx_cocoa --with-expat=builtin --with-cxx=11 --enable-cxx11 --enable-stl --enable-std_iostreams --enable-std_string --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ipv6 --enable-dataobj --enable-ipc --enable-any --enable-arcstream --enable-backtrace --enable-cmdline --enable-datetime --enable-debugreport --enable-dynamicloader --enable-exceptions --enable-ffile --enable-file --enable-filehistory --enable-filesystem --enable-fontmap --enable-fs_inet --enable-fs_zip --enable-fsvolume --enable-fswatcher --enable-geometry --enable-sound --enable-stopwatch --enable-streams --enable-tarstream --enable-textbuf --enable-textfile --enable-variant --enable-zipstream --enable-protocol --enable-protocol-http --enable-protocol-ftp --enable-protocol-file --enable-html --enable-htmlhelp --enable-propgrid --enable-svg --enable-clipboard --enable-dnd --enable-accel --with-osx_cocoa --enable-debug --with-libpng=builtin --with-libjpeg=builtin --with-zlib=builtin --with-libtiff=builtin

现在似乎无法在Mac下加载.icns文件。以前使用wxIcon和wxIconLocation是可能的,例如。 wxMimeTypesManager管理器; wxFileType *类型= manager.GetFileTypeFromExtension(“ zip” ...

c++ macos wxwidgets
1个回答
0
投票

不幸的是,这对我来说似乎是个虫子。当前,wxIcon::LoadIconFromFile()仅在wxOSX_ICON_USE_NSIMAGE==1时总是返回false,这是默认值。您可以尝试在wxOSX_BITMAP_NATIVE_ACCESS中将setup.h设置为0,并作为短期修复方法进行重建,但是真正需要做的是使用NSImage来实现此功能,可能使用[NSImage initWithContentsOfFile:]

© www.soinside.com 2019 - 2024. All rights reserved.