Update of /cvsroot/audacity/audacity-src/src/widgets
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv15522/src/widgets

Modified Files:
        ErrorDialog.cpp ErrorDialog.h 
Log Message:
-First pass at a help index.

Index: ErrorDialog.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/ErrorDialog.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ErrorDialog.cpp     17 Sep 2007 18:02:05 -0000      1.6
+++ ErrorDialog.cpp     18 Sep 2007 11:49:26 -0000      1.7
@@ -45,6 +45,8 @@
    DECLARE_EVENT_TABLE()
           
 };
+void ShowHtmlInBrowser( const wxString &Url );
+
 
 BEGIN_EVENT_TABLE(ErrorDialog, wxDialog)
    EVT_BUTTON( wxID_OK, ErrorDialog::OnOk)
@@ -117,36 +119,48 @@
    EndModal(true);
 }
 
-void ErrorDialog::OnHelp(wxCommandEvent &event)
+void ShowHtmlText( wxWindow * pParent, const wxString &Title, const wxString 
&HtmlText )
 {
-   if( dhelpURL.StartsWith(wxT("innerlink:")) )
+   wxDialog Dlg(pParent, -1, Title, wxDefaultPosition, wxDefaultSize);
+   ShuttleGui S( &Dlg, eIsCreating );
+   S.StartVerticalLay();
    {
-      wxDialog Dlg(this, -1, TitleText(dhelpURL.Mid( 10 ) ),
-               wxDefaultPosition, wxDefaultSize);
-      ShuttleGui S( &Dlg, eIsCreating );
-      S.StartVerticalLay();
-      {
-         wxHtmlWindow *html = new LinkingHtmlWindow(&Dlg, -1,
-                                            wxDefaultPosition,
-                                            wxSize(480, 240),
-                                            wxHW_SCROLLBAR_AUTO | 
wxSUNKEN_BORDER);
-         html->SetPage( HelpText( dhelpURL.Mid( 10 )));
+      wxHtmlWindow *html = new LinkingHtmlWindow(&Dlg, -1,
+                                         wxDefaultPosition,
+                                         wxSize(480, 240),
+                                         wxHW_SCROLLBAR_AUTO | 
wxSUNKEN_BORDER);
+      html->SetPage( HtmlText);
 
-         S.Prop(1).AddWindow( html, wxEXPAND );
-         S.Id( wxID_OK).AddButton( _("Close") );
-      }
-      S.EndVerticalLay();
-      Dlg.Fit();
-      Dlg.Centre();
-      Dlg.ShowModal();
-      return;
+      S.Prop(1).AddWindow( html, wxEXPAND );
+      S.Id( wxID_OK).AddButton( _("Close") );
    }
+   S.EndVerticalLay();
+   Dlg.Fit();
+   Dlg.Centre();
+   Dlg.ShowModal();
+   return;
+}
 
+void ShowHtmlInBrowser( const wxString &Url )
+{
 #if defined(__WXMSW__) || defined(__WXMAC__)
-   OpenInDefaultBrowser(dhelpURL);
+   OpenInDefaultBrowser(Url);
 #else
-   wxLaunchDefaultBrowser(dhelpURL);
+   wxLaunchDefaultBrowser(Url);
 #endif
+}
+
+void ErrorDialog::OnHelp(wxCommandEvent &event)
+{
+   if( dhelpURL.StartsWith(wxT("innerlink:")) )
+   {
+      ShowHtmlText(
+         this, 
+         TitleText(dhelpURL.Mid( 10 ) ),
+         HelpText( dhelpURL.Mid( 10 )) );
+      return;
+   }
+   ShowHtmlInBrowser( dhelpURL );
        EndModal(true);
 }
 
@@ -160,6 +174,23 @@
    dlog.ShowModal();
 }
 
+
+void ShowHelpDialog(wxWindow *parent,
+                     const wxString &localFileName,
+                     const wxString &remoteURL)
+{
+   if( wxFileExists( localFileName ))
+   {
+      ShowHtmlInBrowser( wxString(wxT("file:"))+localFileName );
+   }
+   else
+   {
+      wxString Text = HelpText( wxT("remotehelp") );
+      Text.Replace( wxT("*URL*"), remoteURL );
+      ShowHtmlText( parent, _("Help on the Internet"), Text );
+   }
+}
+
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a
 // version control system. Please do not modify past this point.
 //

Index: ErrorDialog.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/ErrorDialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ErrorDialog.h       29 Jul 2007 21:47:53 -0000      1.2
+++ ErrorDialog.h       18 Sep 2007 11:49:26 -0000      1.3
@@ -21,6 +21,19 @@
                      const wxString &message, 
                      const wxString &helpURL);                  
 
+/// Displays a new window with wxHTML help.
+void ShowHtmlText( wxWindow * pParent, 
+                  const wxString &Title, 
+                  const wxString &HtmlText );
+
+/// Displays a file in your browser, if it's available locally,
+/// OR else links to the internet.
+void ShowHelpDialog(wxWindow *parent,
+                     const wxString &localFileName,
+                     const wxString &remoteURL);
+
+
+
 #endif // __AUDACITY_ERRORDIALOG__
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to