diff --git a/docs/latex/wx/filesys.tex b/docs/latex/wx/filesys.tex index 86d292a871..6cb94ad996 100644 --- a/docs/latex/wx/filesys.tex +++ b/docs/latex/wx/filesys.tex @@ -89,6 +89,16 @@ f = fs -> OpenFile("hello.htm"); // opens file 'subdir/folder/hello.htm' !! Returns actual path (set by \helpref{ChangePathTo}{wxfilesystemchangepathto}). +\membersection{wxFileSystem::FileNameToURL}\label{wxfilesystemfilenametourl} + +\func{static wxString}{FileNameToURL}{\param{wxFileName }{filename}} + +Converts filename into URL. + +\wxheading{See also} + +\helpref{wxFileSystem::URLToFileName}{wxfilesystemurltofilename}, +\helpref{wxFileName}{wxfilename} \membersection{wxFileSystem::FindFirst}\label{wxfilesystemfindfirst} @@ -114,3 +124,14 @@ or NULL if failed. It first tries to open the file in relative scope (based on value passed to ChangePathTo() method) and then as an absolute path. +\membersection{wxFileSystem::URLToFileName}\label{wxfilesystemurltofilename} + +\func{static wxFileName}{URLToFileName}{\param{const wxString& }{url}} + +Converts URL into well-formed filename. The URL must use {\tt file} +protocol. + +\wxheading{See also} + +\helpref{wxFileSystem::FileNameToURL}{wxfilesystemfilenametourl}, +\helpref{wxFileName}{wxfilename} diff --git a/docs/latex/wx/frame.tex b/docs/latex/wx/frame.tex index 1ee544180c..eaed2ea430 100644 --- a/docs/latex/wx/frame.tex +++ b/docs/latex/wx/frame.tex @@ -52,14 +52,14 @@ a wxEVT\_HELP event if the user clicked on an application window. {\it Note} tha style and must be set by calling \helpref{SetExtraStyle}{wxwindowsetextrastyle} before Create is called (two-step construction). You cannot use this style together with wxMAXIMIZE\_BOX or wxMINIMIZE\_BOX, so you should use -{\tt wxDEFAULT\_FRAME\_STYLE \& \verb$~$ (wxMINIMIZE\_BOX | wxMAXIMIZE\_BOX)} for the +{\tt wxDEFAULT\_FRAME\_STYLE \& (wxMINIMIZE\_BOX | wxMAXIMIZE\_BOX)} for the frames having this style (the dialogs don't have minimize nor maximize box by default)} \end{twocollist} The default frame style is for normal, resizeable frames. To create a frame which can not be resized by user, you may use the following combination of -styles: {\tt wxDEFAULT\_FRAME\_STYLE \& \verb$~$ (wxRESIZE\_BORDER \pipe wxRESIZE\_BOX \pipe wxMAXIMIZE\_BOX)}. +styles: {\tt wxDEFAULT\_FRAME\_STYLE \& (wxRESIZE\_BORDER \pipe wxRESIZE\_BOX \pipe wxMAXIMIZE\_BOX)}. % Note: the space after the tilde is necessary or Tex2RTF complains. See also \helpref{window styles overview}{windowstyles}. diff --git a/docs/latex/wx/fs.tex b/docs/latex/wx/fs.tex index 2ba5f7e40d..b948bafb23 100644 --- a/docs/latex/wx/fs.tex +++ b/docs/latex/wx/fs.tex @@ -47,8 +47,8 @@ protocols - for example you may want to access files in a ZIP archive: file:archives/cpp\_doc.zip\#zip:reference/fopen.htm\#syntax -In this example, the protocol is "zip", the left location is -"reference/fopen.htm", the anchor is "syntax" and the right location +In this example, the protocol is "zip", right location is +"reference/fopen.htm", anchor is "syntax" and left location is "file:archives/cpp\_doc.zip". There are {\bf two} protocols used in this example: "zip" and "file". diff --git a/docs/latex/wx/hthelpct.tex b/docs/latex/wx/hthelpct.tex index 2e667c66da..acb5cbfe7e 100644 --- a/docs/latex/wx/hthelpct.tex +++ b/docs/latex/wx/hthelpct.tex @@ -81,17 +81,27 @@ all other sections (sections, subsections, ...) have a folder icon.} \membersection{wxHtmlHelpController::AddBook}\label{wxhtmlhelpcontrolleraddbook} -\func{bool}{AddBook}{\param{const wxString\& }{book}, \param{bool }{show\_wait\_msg}} +\func{bool}{AddBook}{\param{const wxFileName\& }{book\_file}, \param{bool }{show\_wait\_msg}} + +\func{bool}{AddBook}{\param{const wxString\& }{book\_url}, \param{bool }{show\_wait\_msg}} Adds book (\helpref{.hhp file}{helpformat} - HTML Help Workshop project file) into the list of loaded books. This must be called at least once before displaying any help. -{\it book} may be either .hhp file or ZIP archive that contains arbitrary number of .hhp files in +{\it book\_file} or {\it book\_url} may be either .hhp file or ZIP archive +that contains arbitrary number of .hhp files in top-level directory. This ZIP archive must have .zip or .htb extension -(the latter stands for "HTML book"). In other words, {\tt AddBook("help.zip")} is possible and, in fact, -recommended way. +(the latter stands for "HTML book"). In other words, +{\tt AddBook(wxFileName("help.zip"))} +is possible and, in fact, recommended way. -If {\it show\_wait\_msg} is TRUE then a decoration-less window with progress message is displayed. +\wxheading{Parameters} + +\docparam{show\_wait\_msg}{If TRUE then a decoration-less window with progress message is displayed.} +\docparam{book\_file}{Help book filename. It is recommended to use this prototype +instead of the one taking URL, because it is less error-prone.} +\docparam{book\_url}{Help book URL (note that syntax of filename and URL is +different on most platforms)} \wxheading{Note} diff --git a/docs/latex/wx/hthlpdat.tex b/docs/latex/wx/hthlpdat.tex index c920f9fb07..b92bb0e826 100644 --- a/docs/latex/wx/hthlpdat.tex +++ b/docs/latex/wx/hthlpdat.tex @@ -28,11 +28,11 @@ Constructor. \membersection{wxHtmlHelpData::AddBook}\label{wxhtmlhelpdataaddbook} -\func{bool}{AddBook}{\param{const wxString\& }{book}} +\func{bool}{AddBook}{\param{const wxString\& }{book\_url}} -Adds new book. 'book' is location of HTML help project (hhp) or ZIP file -that contains arbitrary number of .hhp projects (this zip file can have -either .zip or .htb extension, htb stands for "html book"). +Adds new book. {\it book} is URL (not filename!) of HTML help project (hhp) +or ZIP file that contains arbitrary number of .hhp projects (this zip +file can have either .zip or .htb extension, htb stands for "html book"). Returns success. \membersection{wxHtmlHelpData::FindPageById}\label{wxhtmlhelpdatafindpagebyid} diff --git a/include/wx/filesys.h b/include/wx/filesys.h index b819282152..814a41a314 100644 --- a/include/wx/filesys.h +++ b/include/wx/filesys.h @@ -29,6 +29,7 @@ #include "wx/stream.h" #include "wx/url.h" #include "wx/datetime.h" +#include "wx/filename.h" class wxFSFile; class wxFileSystemHandler; @@ -181,10 +182,10 @@ public: static void CleanUpHandlers(); // Returns the native path for a file URL - static wxString URLToNativePath( const wxString& url ); + static wxFileName URLToFileName(const wxString& url); // Returns the file URL for a native path - static wxString NativePathToURL( const wxString& path ); + static wxString FileNameToURL(const wxFileName& filename); protected: diff --git a/include/wx/html/helpctrl.h b/include/wx/html/helpctrl.h index e71db3db4c..a2a795b243 100644 --- a/include/wx/html/helpctrl.h +++ b/include/wx/html/helpctrl.h @@ -35,7 +35,8 @@ public: void SetTitleFormat(const wxString& format); void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); } - bool AddBook(const wxString& book, bool show_wait_msg = FALSE); + bool AddBook(const wxString& book_url, bool show_wait_msg = FALSE); + bool AddBook(const wxFileName& book_file, bool show_wait_msg = FALSE); bool Display(const wxString& x); bool Display(int id); diff --git a/samples/html/help/help.cpp b/samples/html/help/help.cpp index 783cda08fd..0e6ed46d88 100644 --- a/samples/html/help/help.cpp +++ b/samples/html/help/help.cpp @@ -155,19 +155,11 @@ help.UseConfig(wxConfig::Get()); bool ret; -#if defined(__WXMAC__) && !defined(__DARWIN__) - ret = help.AddBook(wxT(":helpfiles:testing.hhp")); -#else help.SetTempDir(wxT(".")); - ret = help.AddBook(wxT("helpfiles/testing.hhp")); -#endif + ret = help.AddBook(wxFileName(wxT("helpfiles/testing.hhp"), wxPATH_UNIX)); if (! ret) wxMessageBox(wxT("Failed adding book helpfiles/testing.hhp")); -#if defined(__WXMAC__) && !defined(__DARWIN__) - ret = help.AddBook(wxT(":helpfiles:another.hhp")); -#else - ret = help.AddBook(wxT("helpfiles/another.hhp")); -#endif + ret = help.AddBook(wxFileName(wxT("helpfiles/another.hhp"), wxPATH_UNIX)); if (! ret) wxMessageBox(_("Failed adding book helpfiles/another.hhp")); } diff --git a/samples/html/helpview/helpview.cpp b/samples/html/helpview/helpview.cpp index 3881c00ba9..d77e758829 100644 --- a/samples/html/helpview/helpview.cpp +++ b/samples/html/helpview/helpview.cpp @@ -79,7 +79,7 @@ bool MyApp::OnInit() } for (int i = 1; i < argc; i++) - help -> AddBook(argv[i]); + help->AddBook(wxFileName(argv[i])); #ifdef __WXMOTIF__ delete wxLog::SetActiveTarget(new wxLogGui); diff --git a/src/common/fs_zip.cpp b/src/common/fs_zip.cpp index 18d421b7be..27ed0b6a55 100644 --- a/src/common/fs_zip.cpp +++ b/src/common/fs_zip.cpp @@ -89,9 +89,9 @@ wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& l if (right.GetChar(0) == wxT('/')) right = right.Mid(1); - wxString leftFilename = wxFileSystem::URLToNativePath(left); + wxFileName leftFilename = wxFileSystem::URLToFileName(left); - s = new wxZipInputStream(leftFilename, right); + s = new wxZipInputStream(leftFilename.GetFullPath(), right); if (s && s->IsOk() ) { return new wxFSFile(s, @@ -137,7 +137,8 @@ wxString wxZipFSHandler::FindFirst(const wxString& spec, int flags) } m_ZipFile = left; - m_Archive = (void*) unzOpen(m_ZipFile.mb_str()); + wxString nativename = wxFileSystem::URLToFileName(m_ZipFile).GetFullPath(); + m_Archive = (void*) unzOpen(nativename.mb_str()); m_Pattern = right.AfterLast(wxT('/')); m_BaseDir = right.BeforeLast(wxT('/'));