Look in multiple paths when searching for resource files of samples
When using an out of source build, the files are not in the default wxWidgets directories. Also search in the current directory, parent directory and sample sub-directories. Closes https://trac.wxwidgets.org/ticket/18118
This commit is contained in:
parent
de4e20ee93
commit
e581b72955
5 changed files with 27 additions and 7 deletions
|
|
@ -413,7 +413,8 @@ bool MyApp::LoadImages()
|
|||
pathList.Add(wxFileName(argv[0]).GetPath());
|
||||
pathList.Add(wxT("."));
|
||||
pathList.Add(wxT(".."));
|
||||
pathList.Add(wxT("../.."));
|
||||
pathList.Add(wxT("../drawing"));
|
||||
pathList.Add(wxT("../../../samples/drawing"));
|
||||
|
||||
wxString path = pathList.FindValidPath(wxT("pat4.bmp"));
|
||||
if ( !path )
|
||||
|
|
|
|||
|
|
@ -163,10 +163,16 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||
help.UseConfig(wxConfig::Get());
|
||||
bool ret;
|
||||
help.SetTempDir(wxT("."));
|
||||
ret = help.AddBook(wxFileName(wxT("helpfiles/testing.hhp"), wxPATH_UNIX));
|
||||
|
||||
wxPathList pathlist;
|
||||
pathlist.Add(wxT("./helpfiles"));
|
||||
pathlist.Add(wxT("../helpfiles"));
|
||||
pathlist.Add(wxT("../../html/help/helpfiles"));
|
||||
|
||||
ret = help.AddBook(wxFileName(pathlist.FindValidPath(wxT("testing.hhp")), wxPATH_UNIX));
|
||||
if (! ret)
|
||||
wxMessageBox(wxT("Failed adding book helpfiles/testing.hhp"));
|
||||
ret = help.AddBook(wxFileName(wxT("helpfiles/another.hhp"), wxPATH_UNIX));
|
||||
ret = help.AddBook(wxFileName(pathlist.FindValidPath(wxT("another.hhp")), wxPATH_UNIX));
|
||||
if (! ret)
|
||||
wxMessageBox(_("Failed adding book helpfiles/another.hhp"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ bool WebApp::OnInit()
|
|||
|
||||
// Create the memory files
|
||||
wxImage::AddHandler(new wxPNGHandler);
|
||||
wxMemoryFSHandler::AddFile("logo.png",
|
||||
wxMemoryFSHandler::AddFile("logo.png",
|
||||
wxBitmap(wxlogo_xpm), wxBITMAP_TYPE_PNG);
|
||||
wxMemoryFSHandler::AddFile("page1.htm",
|
||||
"<html><head><title>File System Example</title>"
|
||||
|
|
@ -741,7 +741,13 @@ void WebFrame::OnMode(wxCommandEvent& WXUNUSED(evt))
|
|||
|
||||
void WebFrame::OnLoadScheme(wxCommandEvent& WXUNUSED(evt))
|
||||
{
|
||||
wxFileName helpfile("../help/doc.zip");
|
||||
wxPathList pathlist;
|
||||
pathlist.Add(wxT("."));
|
||||
pathlist.Add(wxT(".."));
|
||||
pathlist.Add(wxT("../help"));
|
||||
pathlist.Add(wxT("../../../samples/help"));
|
||||
|
||||
wxFileName helpfile(pathlist.FindValidPath(wxT("doc.zip")));
|
||||
helpfile.MakeAbsolute();
|
||||
wxString path = helpfile.GetFullPath();
|
||||
//Under MSW we need to flip the slashes
|
||||
|
|
@ -1207,7 +1213,7 @@ void WebFrame::OnSelectAll(wxCommandEvent& WXUNUSED(evt))
|
|||
* Callback invoked when a loading error occurs
|
||||
*/
|
||||
void WebFrame::OnError(wxWebViewEvent& evt)
|
||||
{
|
||||
{
|
||||
#define WX_ERROR_CASE(type) \
|
||||
case type: \
|
||||
category = #type; \
|
||||
|
|
|
|||
|
|
@ -90,7 +90,13 @@ void StatBmpWidgetsPage::CreateContent()
|
|||
|
||||
wxString testImage;
|
||||
#if wxUSE_LIBPNG
|
||||
wxFileName fn("../image/toucan.png");
|
||||
wxPathList pathlist;
|
||||
pathlist.Add(wxT("."));
|
||||
pathlist.Add(wxT(".."));
|
||||
pathlist.Add(wxT("../image"));
|
||||
pathlist.Add(wxT("../../../samples/image"));
|
||||
|
||||
wxFileName fn(pathlist.FindValidPath(wxT("toucan.png")));
|
||||
if ( fn.FileExists() )
|
||||
testImage = fn.GetFullPath();
|
||||
#endif // wxUSE_LIBPNG
|
||||
|
|
|
|||
|
|
@ -913,6 +913,7 @@ void TextWidgetsPage::OnButtonLoad(wxCommandEvent& WXUNUSED(event))
|
|||
wxPathList pathlist;
|
||||
pathlist.Add(wxT("."));
|
||||
pathlist.Add(wxT(".."));
|
||||
pathlist.Add(wxT("../widgets"));
|
||||
pathlist.Add(wxT("../../../samples/widgets"));
|
||||
|
||||
wxString filename = pathlist.FindValidPath(wxT("textctrl.cpp"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue