wxIconBundle CThemeProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client /*=wxART_OTHER*/) { wxIconBundle iconBundle; if (id.Left(4) != _T("ART_")) return iconBundle; wxString name = id.Mid(4); MakeLowerAscii(name); const wxChar* dirs[3] = { _T("16x16/"), _T("32x32/"), _T("48x48/") }; const wxString& resourcePath = wxGetApp().GetResourceDir(); for (int i = 0; i < 3; i++) { wxString file = resourcePath + dirs[i] + name + _T(".png"); if (!wxFileName::FileExists(file)) continue; iconBundle.AddIcon(wxIcon(file, wxBITMAP_TYPE_PNG)); } return iconBundle; }
// {{{ wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) { #ifdef BUILTIN_IMAGES const Images::Image *img = Images::GetImage(id); if (img == NULL) { return wxNullBitmap; } wxMemoryInputStream mis(img->image, img->size); wxImage image(mis, wxBITMAP_TYPE_PNG); #elif __WXMAC__ wxString path(wxGetCwd()); path << wxT("/Dubnium.app/Contents/Resources/") << id << wxT(".png"); if (!wxFileExists(path)) { return wxNullBitmap; } wxImage image(path, wxBITMAP_TYPE_PNG); #elif DUBNIUM_DEBUG wxString path(wxT(__FILE__)); path = wxPathOnly(path); path << wxT("/../../images/") << id << wxT(".png"); if (!wxFileExists(path)) { /* This is a debug message only, since for built-in IDs like * wxART_DELETE this will just fall through to the wxWidgets * default provider and isn't an error. */ wxLogDebug(wxT("Requested image ID: %s; NOT FOUND as %s"), id.c_str(), path.c_str()); return wxNullBitmap; } wxLogDebug(wxT("Requested image ID: %s; found as %s"), id.c_str(), path.c_str()); wxImage image(path, wxBITMAP_TYPE_PNG); #else wxString path; path << wxT(PREFIX) << wxT("/share/dubnium/") << id << wxT(".png"); if (!wxFileExists(path)) { return wxNullBitmap; } wxImage image(path, wxBITMAP_TYPE_PNG); #endif /* There seems to be a tendency for wxArtProvider to request images of * size (-1, -1), so we need to avoid trying to rescale for them. */ if (wxSize(image.GetWidth(), image.GetHeight()) != size && size.GetWidth() > 0 && size.GetHeight() > 0) { wxLogDebug(wxT("Requested width: %d; height: %d"), size.GetWidth(), size.GetHeight()); image.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH); } return wxBitmap(image); }
wxBitmap PoeditArtProvider::CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size) { // Silence warning about unused parameter in some of the builds (void)client; (void)size; // Note: On Unix, this code is only called as last resolt, if standard // theme provider (that uses current icon theme and files from // /usr/share/icons/<theme>) didn't find any matching icon. wxLogTrace("poedit.icons", "getting icon '%s'", id.c_str()); #ifdef __WXGTK20__ // try legacy GNOME icons from standard theme: wxString gnomeId = GetGnomeStockId(id); if ( !gnomeId.empty() ) { wxLogTrace("poedit.icons", "-> legacy '%s'", gnomeId.c_str()); wxBitmap gbmp(wxArtProvider::GetBitmap(gnomeId, client, size)); if ( gbmp.Ok() ) return gbmp; } #endif // __WXGTK20__ wxString iconsdir = #if defined(__WXMSW__) wxStandardPaths::Get().GetResourcesDir() + "\\Resources"; #else wxStandardPaths::Get().GetInstallPrefix() + "/share/poedit/icons"; #endif if ( !wxDirExists(iconsdir) ) { wxLogTrace("poedit.icons", "icons dir %s not found", iconsdir.c_str()); return wxNullBitmap; } wxString icon; icon.Printf("%s/%s.png", iconsdir.c_str(), id.c_str()); if ( !wxFileExists(icon) ) return wxNullBitmap; wxLogTrace("poedit.icons", "loading from %s", icon.c_str()); wxBitmap bmp(wxImage(icon, wxBITMAP_TYPE_ANY)); return bmp; }
wxBitmap ArtProvider::loadBitmapFromFile(const wxArtID& id, wxSize size) { wxString name(id.Lower()); if (name.substr(0, 4) == "art_") name.erase(0, 4); if (size == wxDefaultSize) size = wxSize(32, 32); wxFileName fname(config().getImagesPath() + name + wxString::Format("_%dx%d", size.GetWidth(), size.GetHeight())); wxArrayString imgExts; imgExts.Add("png"); imgExts.Add("xpm"); imgExts.Add("bmp"); for (size_t i = 0; i < imgExts.GetCount(); ++i) { fname.SetExt(imgExts[i]); wxLogDebug("Trying to load image file \"%s\"", fname.GetFullPath().c_str()); if (fname.FileExists()) { wxImage img(fname.GetFullPath()); if (img.IsOk() && wxSize(img.GetWidth(), img.GetHeight()) == size) return wxBitmap(img); } } return wxNullBitmap; }
wxBitmap PoeditArtProvider::CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size) { // Note: On Unix, this code is only called as last resolt, if standard // theme provider (that uses current icon theme and files from // /usr/share/icons/<theme>) didn't find any matching icon. wxLogTrace(_T("poedit.icons"), _T("getting icon '%s'"), id.c_str()); #ifdef __WXGTK20__ // try legacy GNOME icons from standard theme: wxString gnomeId = GetGnomeStockId(id); if ( !gnomeId.empty() ) { wxLogTrace(_T("poedit.icons"), _T("-> legacy '%s'"), gnomeId.c_str()); wxBitmap gbmp(wxArtProvider::GetBitmap(gnomeId, client, size)); if ( gbmp.Ok() ) return gbmp; } #endif // __WXGTK20__ wxString iconsdir = #ifdef __WXMAC__ wxStandardPaths::Get().GetResourcesDir() + _T("/icons"); #else wxGetApp().GetAppPath() + _T("/share/poedit/icons"); #endif if ( !wxDirExists(iconsdir) ) { wxLogTrace(_T("poedit.icons"), _T("icons dir %s not found"), iconsdir.c_str()); return wxNullBitmap; } wxString icon; icon.Printf(_T("%s/%s.png"), iconsdir.c_str(), id.c_str()); if ( !wxFileExists(icon) ) return wxNullBitmap; wxLogTrace(_T("poedit.icons"), _T("loading from %s"), icon.c_str()); wxBitmap bmp(wxImage(icon, wxBITMAP_TYPE_ANY)); return bmp; }
wxBitmap CThemeProvider::CreateBitmap(const wxArtID& id, const wxArtClient& /*client*/, const wxSize& size) { if (id.Left(4) != _T("ART_")) return wxNullBitmap; wxASSERT(size.GetWidth() == size.GetHeight()); std::list<wxString> dirs = GetSearchDirs(size); wxString name = id.Mid(4); // The ART_* IDs are always given in uppercase ASCII, // all filenames used by FileZilla for the resources // are lowercase ASCII. Locale-independent transformation // needed e.g. if using Turkish locale. MakeLowerAscii(name); wxLogNull logNull; for (std::list<wxString>::const_iterator iter = dirs.begin(); iter != dirs.end(); iter++) { wxString fileName = *iter + name + _T(".png"); //#ifdef __WXMSW__ // MSW toolbar only greys out disabled buttons in a visually // pleasing way if the bitmap has an alpha channel. wxImage img(fileName, wxBITMAP_TYPE_PNG); if (!img.Ok()) continue; if (img.HasMask() && !img.HasAlpha()) img.InitAlpha(); if (size.IsFullySpecified()) img.Rescale(size.x, size.y, wxIMAGE_QUALITY_HIGH); return wxBitmap(img); /*#else wxBitmap bmp(fileName, wxBITMAP_TYPE_PNG); if (bmp.Ok()) return bmp; #endif*/ } return wxNullBitmap; }
virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size) { if (EiffelObject) { void* res = cb (EiffelObject, (void*)id.wchar_str(), (void*)client.wchar_str(), size.GetWidth(), size.GetHeight()); if (res) return (*((wxBitmap*)res)); else return wxNullBitmap; } return wxNullBitmap; }
wxIconBundle xlArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client) { printf("ib: %s %s \n", (const char *)id.c_str(), (const char*)client.c_str()); return wxNullIconBundle; }
//--------------------------------------------------------------------------------------- // resources are identified by an wxArtId. It is just a string. wxFileName ArtProvider::get_filepath(const wxArtID& id, const wxArtClient& client, const wxSize& size) { Paths* pPaths = m_appScope.get_paths(); wxString sPath = pPaths->GetImagePath(); wxString sFile; //set size. 16x16 is the default wxString sSize = "_16.png"; if (size.GetHeight() == size.GetWidth()) { if (size.GetHeight() == 24) { sSize = "_24.png"; } else if (size.GetHeight() == 32) { sSize = "_32.png"; } else if (size.GetHeight() == 22) { sSize = "_22.png"; } else if (size.GetHeight() == 48) { sSize = "_48.png"; } } else sSize = wxString::Format("_%dx%d.png", size.GetWidth(), size.GetHeight()); //icon for text book controller if ( client == wxART_HELP_BROWSER ) { if ( id == wxART_HELP ) { return wxFileName("null"); } } //TextBookController buttons if ( id == wxART_ADD_BOOKMARK ) { sFile = "tool_bookmark_add"; } else if ( id == wxART_DEL_BOOKMARK ) { sFile = "tool_bookmark_remove"; } else if ( id == wxART_ERROR ) { sFile = "msg_error"; } else if ( id == wxART_FILE_OPEN ) { return wxFileName("null"); } else if ( id == wxART_GO_BACK ) { sFile = "tool_previous"; } else if ( id == wxART_GO_FORWARD ) { sFile = "tool_next"; } else if ( id == wxART_GO_TO_PARENT ) { return wxFileName("null"); //<--- } else if ( id == wxART_GO_UP ) { sFile = "tool_page_previous"; } else if ( id == wxART_GO_DOWN ) { sFile = "tool_page_next"; } else if ( id == wxART_HELP_BOOK ) { sFile = "app_book"; } else if ( id == wxART_HELP_FOLDER ) { sFile = "app_book"; } else if ( id == wxART_HELP_PAGE ) { return wxFileName("null"); } else if ( id == wxART_HELP_SETTINGS ) { sFile = "tool_font_size"; } else if ( id == wxART_HELP_SIDE_PANEL ) { sFile = "tool_index_panel"; } else if ( id == wxART_INFORMATION ) { sFile = "msg_info"; } else if ( id == wxART_PRINT ) { sFile = "tool_print"; } else if ( id == wxART_WARNING ) { sFile = "msg_info"; } //MainFrame toolbar else if (id.Left(5) == "tool_") { sFile = id; } else if (id.Left(4) == "msg_") { sFile = id; } else if (id.Left(4) == "opt_") { sFile = id; } else if (id.Left(7) == "button_") { sFile = id; } else if (id.Left(8) == "welcome_") { sFile = id; sSize = ".png"; } //miscelaneous else if (id == "backgrnd") { sFile = "backgrnd"; sSize = ".png"; } else if (id == "app_icon") { sFile = "app_icon"; sSize = ".png"; } else if (id == "app_splash") { sFile = "splash"; sSize = ".png"; } else if (id == "banner_updater") { sFile = "UpdaterBanner"; sSize = ".png"; } else if (id == "logo50x67") { sFile = "logo50x67"; sSize = ".png"; } else if (id == "preview") { sFile = "preview"; sSize = ".png"; } else if (id == "right_answers") { sFile = "right_answers"; sSize = "_24.png"; } else if (id == "wrong_answers") { sFile = "wrong_answers"; sSize = "_24.png"; } else if (id == "total_marks") { sFile = "total_marks"; sSize = "_24.png"; } // other IDs else sFile = id; return wxFileName(sPath, sFile + sSize, wxPATH_NATIVE); }
wxBitmap PoeditArtProvider::CreateBitmap(const wxArtID& id_, const wxArtClient& client, const wxSize& size) { wxLogTrace("poedit.icons", "getting icon '%s'", id_.c_str()); wxArtID id(id_); #define CHECK_FOR_VARIANT(name) \ const bool name##Variant = id.Contains("@" #name); \ if (name##Variant) \ id.Replace("@" #name, "") CHECK_FOR_VARIANT(disabled); CHECK_FOR_VARIANT(opaque); CHECK_FOR_VARIANT(inverted); // Silence warning about unused parameter in some of the builds (void)client; (void)size; // Note: On Unix, this code is only called as last resort, if standard // theme provider (that uses current icon theme and files from // /usr/share/icons/<theme>) didn't find any matching icon. #ifdef __WXGTK20__ // try legacy GNOME icons from standard theme: wxString gnomeId = GetGnomeStockId(id); if ( !gnomeId.empty() ) { wxLogTrace("poedit.icons", "-> legacy '%s'", gnomeId.c_str()); wxBitmap gbmp(wxArtProvider::GetBitmap(gnomeId, client, size)); if ( gbmp.Ok() ) return gbmp; } #endif // __WXGTK20__ auto iconsdir = GetIconsDir(); if ( !wxDirExists(iconsdir) ) { wxLogTrace("poedit.icons", "icons dir %s not found", iconsdir.c_str()); return wxNullBitmap; } wxString icon; icon.Printf("%s/%s", iconsdir, id); wxLogTrace("poedit.icons", "loading from %s", icon); wxImage img; if (ColorScheme::GetAppMode() == ColorScheme::Dark) img = LoadScaledBitmap(icon + "Dark"); if (!img.IsOk()) img = LoadScaledBitmap(icon); if (!img.IsOk()) { wxLogTrace("poedit.icons", "failed to load icon '%s'", id); return wxNullBitmap; } if (id.EndsWith("Template")) ProcessTemplateImage(img, opaqueVariant, invertedVariant); if (disabledVariant) img = img.ConvertToDisabled(); if (wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft && ShouldBeMirorredInRTL(id, client)) { img = img.Mirror(); } #ifdef __WXMSW__ if (client == wxART_TOOLBAR && IsWindows10OrGreater()) { const int padding = PX(1); auto sz = img.GetSize(); sz.IncBy(padding * 2); img.Resize(sz, wxPoint(padding, padding)); } #endif // __WXMSW__ return wxBitmap(img); }