From: <pst...@us...> - 2013-03-20 15:44:35
|
Revision: 989 http://sourceforge.net/p/jazzplusplus/code/989 Author: pstieber Date: 2013-03-20 15:44:32 +0000 (Wed, 20 Mar 2013) Log Message: ----------- 1. Removed the version member functions. 2. Moved the help code to the JZHelp Singleton and added appropriate calls to the JZHelp class. Modified Paths: -------------- trunk/jazz/src/JazzPlusPlusApplication.cpp trunk/jazz/src/JazzPlusPlusApplication.h Modified: trunk/jazz/src/JazzPlusPlusApplication.cpp =================================================================== --- trunk/jazz/src/JazzPlusPlusApplication.cpp 2013-03-20 15:43:14 UTC (rev 988) +++ trunk/jazz/src/JazzPlusPlusApplication.cpp 2013-03-20 15:44:32 UTC (rev 989) @@ -23,6 +23,7 @@ #include "JazzPlusPlusApplication.h" #include "Globals.h" +#include "Help.h" #include "Project.h" #include "ProjectManager.h" #include "TrackFrame.h" @@ -49,11 +50,9 @@ #include <wx/stdpaths.h> #include <wx/fileconf.h> -#include <wx/filedlg.h> #include <wx/image.h> #include <wx/msgdlg.h> -#include <fstream> #include <vector> using namespace std; @@ -63,10 +62,6 @@ // This is the JazzPlusPlus application class definition. //***************************************************************************** //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -wxString JZJazzPlusPlusApplication::mHelpFileName = "jazz.hhp"; - -//----------------------------------------------------------------------------- // Description: // Create a new application object using the wxWidgets macro. This macro // will allow wxWidgets to create the application object during program @@ -81,8 +76,7 @@ JZJazzPlusPlusApplication::JZJazzPlusPlusApplication() : wxApp(), mpProject(0), - mpTrackFrame(0), - mHelp(wxHF_DEFAULT_STYLE | wxHF_OPEN_FILES) + mpTrackFrame(0) { #ifdef _MSC_VER // When using the Microsoft C++ compiler in debug mode, each heap allocation @@ -157,95 +151,12 @@ // Show it and tell the application that it's our main window SetTopWindow(mpTrackFrame); - ConfigureHelp(); + JZHelp::Instance().ConfigureHelp(); return true; } //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -void JZJazzPlusPlusApplication::ConfigureHelp() -{ - wxConfigBase* pConfig = wxConfigBase::Get(); - - // Let the help system store the Jazz++ help configuration info. - mHelp.UseConfig(pConfig); - - // This code should be distributed with a HelpFiles subdirectory under - // the directory the executable is stored in on Windows and under the - // ${prefix}/shared/${appname} on Linux. - wxString HelpFileDirectoryGuess = - wxStandardPaths::Get().GetDataDir() + - wxFileName::GetPathSeparator() + - "HelpFiles" + - wxFileName::GetPathSeparator(); - - // Attempt to obtain the path to the help file from configuration data. - wxString HelpFilePath; - bool WasHelpPathRead = false; - if (pConfig) - { - WasHelpPathRead = pConfig->Read( - "/Paths/Help", - &HelpFilePath, - HelpFileDirectoryGuess); - } - - // Construct a full file name. - wxString HelpFileNameAndPath = HelpFilePath + mHelpFileName; - - // Test for the existence of the help file. - bool HelpFileFound = false; - ifstream Is; - Is.open(HelpFileNameAndPath.mb_str()); - if (!Is) - { - // Ask the user to find the help file. - if (FindAndRegisterHelpFilePath(HelpFilePath)) - { - HelpFileNameAndPath = HelpFilePath + mHelpFileName; - - // Try one more time. - Is.close(); - Is.clear(); - Is.open(HelpFileNameAndPath.mb_str()); - if (!Is) - { - wxString Message = "Failed to add the Jazz++ book " + mHelpFileName; - ::wxMessageBox(Message); - } - else - { - HelpFileFound = true; - } - } - } - else - { - HelpFileFound = true; - } - - // GetUserDataDir returns the directory for the user-dependent application - // data files. The value is $HOME/.appname on Linux, - // c:\Documents and Settings\username\Application Data\appname on - // Windows, and ~/Library/Application Support/appname on the Mac. - // The cached version of the help file will be placed in this location. - mHelp.SetTempDir(wxStandardPaths::Get().GetUserDataDir()); - - if (HelpFileFound) - { - // Add the Jazz++ help file the the help system. - mHelp.AddBook(HelpFileNameAndPath); - - if (!WasHelpPathRead && pConfig) - { - // Register the help path. - pConfig->Write("/Paths/Help", HelpFilePath); - } - } -} - -//----------------------------------------------------------------------------- // Description: // This function checks to see if the user's Jazz++ configuration directory // files exist and creates the directory and copies default versions if they @@ -337,74 +248,12 @@ } //----------------------------------------------------------------------------- -// Description: -// This function walks the user through a top-level help file search. If -// the help file is found, create a configuration entry so the code can find -// the help file path the next time the application starts. -// -// Outputs: -// wxString& HelpFilePath: -// A user-selected path to the help file. The calling code should check -// to insure the help file is actually in this path. //----------------------------------------------------------------------------- -bool JZJazzPlusPlusApplication::FindAndRegisterHelpFilePath( - wxString& HelpFilePath) const -{ - wxString Message; - Message = - "Unable to find " + mHelpFileName + "\n" + - "Would you like to locate this file?"; - int Response = ::wxMessageBox( - Message, - "Cannnot Find Help File", - wxOK | wxCANCEL); - - if (Response == wxOK) - { - // Use an open dialog to find the help file. - wxFileDialog OpenDialog( - 0, - "Open the Help File", - HelpFilePath, - mHelpFileName, - "*.hhp", - wxFD_OPEN); - - if (OpenDialog.ShowModal() == wxID_OK) - { - // Generate a string that contains a path to the help file. - wxString TempHelpFilePath; - TempHelpFilePath = ::wxPathOnly(OpenDialog.GetPath()); - TempHelpFilePath += ::wxFileName::GetPathSeparator(); - - wxConfigBase* pConfig = wxConfigBase::Get(); - if (pConfig) - { - pConfig->Write("/Paths/Help", TempHelpFilePath); - } - - // Return the user selected help file path. - HelpFilePath = TempHelpFilePath; - - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- int JZJazzPlusPlusApplication::OnExit() { delete mpProject; - // GetFrame returns NULL if there is no help frame active. - if (mHelp.GetFrame()) - { - // Close the help frame; this will cause the config data to get written. - mHelp.GetFrame()->Close(true); - } + JZHelp::Instance().CloseHelp(); // Prevent reported leaks from the configuration class. delete wxConfigBase::Set(0); @@ -420,21 +269,3 @@ { return mpTrackFrame; } - -//----------------------------------------------------------------------------- -// Description: -// Display the table of contents for Jazz++ help. -//----------------------------------------------------------------------------- -void JZJazzPlusPlusApplication::DisplayHelpContents() const -{ - mHelp.DisplayContents(); -} - -//----------------------------------------------------------------------------- -// Description: -// Provide context sensitive help for Jazz++. -//----------------------------------------------------------------------------- -void JZJazzPlusPlusApplication::GetHelp(const wxString& TopicString) const -{ - mHelp.DisplaySection(TopicString); -} Modified: trunk/jazz/src/JazzPlusPlusApplication.h =================================================================== --- trunk/jazz/src/JazzPlusPlusApplication.h 2013-03-20 15:43:14 UTC (rev 988) +++ trunk/jazz/src/JazzPlusPlusApplication.h 2013-03-20 15:44:32 UTC (rev 989) @@ -23,7 +23,6 @@ #pragma once #include <wx/app.h> -#include <wx/html/helpctrl.h> class JZProject; class JZTrackFrame; @@ -60,115 +59,17 @@ // A pointer to the application's main frame. JZTrackFrame* GetMainFrame() const; - void DisplayHelpContents() const; - - void GetHelp(const wxString& TopicString) const; - - // Description: - // This function returns the application's major version number. - // - // Returns: - // int: - // The application's major version number. - int GetMajorVersion() const; - - // Description: - // This function returns the application's minor version number. - // - // Returns: - // int: - // The application's minor version number. - int GetMinorVersion() const; - - // Description: - // This function returns the application's build number. - // - // Returns: - // int: - // The application's build number. - int GetBuildNumber() const; - private: - void ConfigureHelp(); - void InsureConfigurationFileExistence() const; - bool FindAndRegisterHelpFilePath(wxString& HelpFilePath) const; - private: - static wxString mHelpFileName; - JZProject* mpProject; JZTrackFrame* mpTrackFrame; - - mutable wxHtmlHelpController mHelp; }; -DECLARE_APP(JZJazzPlusPlusApplication) - //***************************************************************************** -// Description: -// These are the Jazz++ application class inline member functions. //***************************************************************************** -//----------------------------------------------------------------------------- -// Description: -// This function returns the application's major version number. -// Version 1 was the MFC version developed on the Phase II ONR SBIR. -// -// Ver Date Description -// 4 ? Unknown for all prior versions. Might be filled in by -// looking at old commit messages. -// 5 1/21/2008 Start of the Jazz++ development revival. -// -// Returns: -// int: -// The application's major version number. -//----------------------------------------------------------------------------- -inline -int JZJazzPlusPlusApplication::GetMajorVersion() const -{ - return 5; -} - -//----------------------------------------------------------------------------- -// Description: -// This function returns the application's minor version number. -// -// Ver Date Description -// ? ? Unknown for all prior versions. Might be filled in by -// looking at old commit messages. -// 3 1/21/2008 Major refactoring here to get the code compiling with -// wxWidgets 2.8.7 and recent compilers including Visual Studio -// .NET 2005 and GCC 4. -// 4 9/1/2008 Updated to wxWidgets version 2.8.8. -// -// Returns: -// int: -// The application's minor version number. -//----------------------------------------------------------------------------- -inline -int JZJazzPlusPlusApplication::GetMinorVersion() const -{ - return 4; -} - -//----------------------------------------------------------------------------- -// Description: -// This function returns the application's build number. -// -// Ver Date Description -// ? ? Unknown for all prior versions. Might be filled in by -// looking at old commit messages. -// 11 1/21/2008 See minor version 3. -// 12 9/1/2008 See minor version 4. -// 13 3/17/2013 Fixed closing while recording and/or playing back. -// 14 3/17/2013 Added "Visit Web Site..." button to the about dialog. -//----------------------------------------------------------------------------- -inline -int JZJazzPlusPlusApplication::GetBuildNumber() const -{ - return 14; -} +DECLARE_APP(JZJazzPlusPlusApplication) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |