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:
@@ -413,7 +413,8 @@ bool MyApp::LoadImages()
|
|||||||
pathList.Add(wxFileName(argv[0]).GetPath());
|
pathList.Add(wxFileName(argv[0]).GetPath());
|
||||||
pathList.Add(wxT("."));
|
pathList.Add(wxT("."));
|
||||||
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"));
|
wxString path = pathList.FindValidPath(wxT("pat4.bmp"));
|
||||||
if ( !path )
|
if ( !path )
|
||||||
|
@@ -163,10 +163,16 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
help.UseConfig(wxConfig::Get());
|
help.UseConfig(wxConfig::Get());
|
||||||
bool ret;
|
bool ret;
|
||||||
help.SetTempDir(wxT("."));
|
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)
|
if (! ret)
|
||||||
wxMessageBox(wxT("Failed adding book helpfiles/testing.hhp"));
|
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)
|
if (! ret)
|
||||||
wxMessageBox(_("Failed adding book helpfiles/another.hhp"));
|
wxMessageBox(_("Failed adding book helpfiles/another.hhp"));
|
||||||
}
|
}
|
||||||
|
@@ -263,7 +263,7 @@ bool WebApp::OnInit()
|
|||||||
|
|
||||||
// Create the memory files
|
// Create the memory files
|
||||||
wxImage::AddHandler(new wxPNGHandler);
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
wxMemoryFSHandler::AddFile("logo.png",
|
wxMemoryFSHandler::AddFile("logo.png",
|
||||||
wxBitmap(wxlogo_xpm), wxBITMAP_TYPE_PNG);
|
wxBitmap(wxlogo_xpm), wxBITMAP_TYPE_PNG);
|
||||||
wxMemoryFSHandler::AddFile("page1.htm",
|
wxMemoryFSHandler::AddFile("page1.htm",
|
||||||
"<html><head><title>File System Example</title>"
|
"<html><head><title>File System Example</title>"
|
||||||
@@ -741,7 +741,13 @@ void WebFrame::OnMode(wxCommandEvent& WXUNUSED(evt))
|
|||||||
|
|
||||||
void WebFrame::OnLoadScheme(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();
|
helpfile.MakeAbsolute();
|
||||||
wxString path = helpfile.GetFullPath();
|
wxString path = helpfile.GetFullPath();
|
||||||
//Under MSW we need to flip the slashes
|
//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
|
* Callback invoked when a loading error occurs
|
||||||
*/
|
*/
|
||||||
void WebFrame::OnError(wxWebViewEvent& evt)
|
void WebFrame::OnError(wxWebViewEvent& evt)
|
||||||
{
|
{
|
||||||
#define WX_ERROR_CASE(type) \
|
#define WX_ERROR_CASE(type) \
|
||||||
case type: \
|
case type: \
|
||||||
category = #type; \
|
category = #type; \
|
||||||
|
@@ -90,7 +90,13 @@ void StatBmpWidgetsPage::CreateContent()
|
|||||||
|
|
||||||
wxString testImage;
|
wxString testImage;
|
||||||
#if wxUSE_LIBPNG
|
#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() )
|
if ( fn.FileExists() )
|
||||||
testImage = fn.GetFullPath();
|
testImage = fn.GetFullPath();
|
||||||
#endif // wxUSE_LIBPNG
|
#endif // wxUSE_LIBPNG
|
||||||
|
@@ -913,6 +913,7 @@ void TextWidgetsPage::OnButtonLoad(wxCommandEvent& WXUNUSED(event))
|
|||||||
wxPathList pathlist;
|
wxPathList pathlist;
|
||||||
pathlist.Add(wxT("."));
|
pathlist.Add(wxT("."));
|
||||||
pathlist.Add(wxT(".."));
|
pathlist.Add(wxT(".."));
|
||||||
|
pathlist.Add(wxT("../widgets"));
|
||||||
pathlist.Add(wxT("../../../samples/widgets"));
|
pathlist.Add(wxT("../../../samples/widgets"));
|
||||||
|
|
||||||
wxString filename = pathlist.FindValidPath(wxT("textctrl.cpp"));
|
wxString filename = pathlist.FindValidPath(wxT("textctrl.cpp"));
|
||||||
|
Reference in New Issue
Block a user