2011-11-08 16:37:25 +00:00
|
|
|
/**
|
|
|
|
* @file eda_doc.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include <wx/mimetype.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
#include <wx/filename.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <macros.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
void PGM_BASE::ReadPdfBrowserInfos()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxASSERT( m_common_settings );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString browser = m_common_settings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
|
|
|
|
SetPdfBrowserName( browser );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2014-02-07 16:09:15 +00:00
|
|
|
int tmp;
|
2014-03-20 06:24:33 +00:00
|
|
|
m_common_settings->Read( wxT( "UseSystemBrowser" ), &tmp, 0 );
|
|
|
|
m_use_system_pdf_browser = bool( tmp );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
void PGM_BASE::WritePdfBrowserInfos()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxASSERT( m_common_settings );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_common_settings->Write( wxT( "PdfBrowserName" ), GetPdfBrowserName() );
|
2014-03-20 06:24:33 +00:00
|
|
|
m_common_settings->Write( wxT( "UseSystemBrowser" ), m_use_system_pdf_browser );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-29 18:51:38 +00:00
|
|
|
// Mime type extensions (PDF files are not considered here)
|
2008-04-24 16:55:35 +00:00
|
|
|
static wxMimeTypesManager* mimeDatabase;
|
2007-05-06 16:03:28 +00:00
|
|
|
static const wxFileTypeInfo EDAfallbacks[] =
|
2008-04-24 16:55:35 +00:00
|
|
|
{
|
|
|
|
wxFileTypeInfo( wxT( "text/html" ),
|
2009-11-23 15:16:50 +00:00
|
|
|
wxT( "wxhtml %s" ),
|
|
|
|
wxT( "wxhtml %s" ),
|
2011-09-30 18:15:37 +00:00
|
|
|
wxT( "html document (from KiCad)" ),
|
2009-11-23 15:16:50 +00:00
|
|
|
wxT( "htm" ),
|
2010-11-20 19:53:00 +00:00
|
|
|
wxT( "html" ),wxNullPtr ),
|
2008-04-24 16:55:35 +00:00
|
|
|
|
|
|
|
wxFileTypeInfo( wxT( "application/sch" ),
|
2009-11-23 15:16:50 +00:00
|
|
|
wxT( "eeschema %s" ),
|
|
|
|
wxT( "eeschema -p %s" ),
|
2011-09-30 18:15:37 +00:00
|
|
|
wxT( "sch document (from KiCad)" ),
|
2009-11-23 15:16:50 +00:00
|
|
|
wxT( "sch" ),
|
2010-11-20 19:53:00 +00:00
|
|
|
wxT( "SCH" ), wxNullPtr ),
|
2008-04-24 16:55:35 +00:00
|
|
|
|
|
|
|
// must terminate the table with this!
|
|
|
|
wxFileTypeInfo()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-05-15 06:32:24 +00:00
|
|
|
bool GetAssociatedDocument( wxWindow* aParent,
|
2011-11-08 16:37:25 +00:00
|
|
|
const wxString& aDocName,
|
|
|
|
const wxPathList* aPaths)
|
2009-04-07 15:54:40 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2014-04-14 18:49:52 +00:00
|
|
|
wxString docname, fullfilename;
|
2009-04-07 11:53:58 +00:00
|
|
|
wxString msg;
|
2008-04-24 16:55:35 +00:00
|
|
|
wxString command;
|
2011-11-08 16:37:25 +00:00
|
|
|
bool success = false;
|
2008-04-24 16:55:35 +00:00
|
|
|
|
|
|
|
// Is an internet url
|
2014-04-14 18:49:52 +00:00
|
|
|
static const wxChar* url_header[3] = {
|
|
|
|
wxT( "http:" ),
|
|
|
|
wxT( "ftp:" ),
|
|
|
|
wxT( "www." )
|
|
|
|
};
|
2008-04-24 16:55:35 +00:00
|
|
|
|
2014-04-14 18:49:52 +00:00
|
|
|
for( unsigned ii = 0; ii < DIM(url_header); ii++ )
|
2008-04-24 16:55:35 +00:00
|
|
|
{
|
2009-04-07 15:54:40 +00:00
|
|
|
if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url
|
2008-04-24 16:55:35 +00:00
|
|
|
{
|
2009-04-07 15:54:40 +00:00
|
|
|
wxLaunchDefaultBrowser( aDocName );
|
2011-11-08 16:37:25 +00:00
|
|
|
return true;
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
docname = aDocName;
|
2011-11-08 16:37:25 +00:00
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
2009-04-12 14:39:54 +00:00
|
|
|
docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
|
|
|
|
#else
|
|
|
|
docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
/* Compute the full file name */
|
2009-04-07 15:54:40 +00:00
|
|
|
if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
|
|
|
|
fullfilename = aDocName;
|
2009-11-23 15:16:50 +00:00
|
|
|
/* If the file exists, this is a trivial case: return the filename
|
|
|
|
* "as this". the name can be an absolute path, or a relative path
|
|
|
|
* like ./filename or ../<filename>
|
|
|
|
*/
|
2009-04-21 17:56:27 +00:00
|
|
|
else if( wxFileName::FileExists( aDocName ) )
|
|
|
|
fullfilename = aDocName;
|
2008-04-24 16:55:35 +00:00
|
|
|
else
|
|
|
|
{
|
2009-04-07 15:54:40 +00:00
|
|
|
fullfilename = aPaths->FindValidPath( aDocName );
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
wxString mask( wxT( "*" ) ), extension;
|
|
|
|
|
2007-06-13 15:35:40 +00:00
|
|
|
#ifdef __WINDOWS__
|
2008-04-24 16:55:35 +00:00
|
|
|
mask += wxT( ".*" );
|
|
|
|
extension = wxT( ".*" );
|
2007-06-13 15:35:40 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
if( wxIsWild( fullfilename ) )
|
|
|
|
{
|
2009-11-23 15:16:50 +00:00
|
|
|
fullfilename = EDA_FileSelector( _( "Doc Files" ),
|
|
|
|
wxPathOnly( fullfilename ),
|
|
|
|
fullfilename,
|
|
|
|
extension,
|
|
|
|
mask,
|
2014-05-15 06:32:24 +00:00
|
|
|
aParent,
|
2009-11-23 15:16:50 +00:00
|
|
|
wxFD_OPEN,
|
2011-11-08 16:37:25 +00:00
|
|
|
true,
|
2009-11-23 15:16:50 +00:00
|
|
|
wxPoint( -1, -1 ) );
|
2008-04-24 16:55:35 +00:00
|
|
|
if( fullfilename.IsEmpty() )
|
2011-11-08 16:37:25 +00:00
|
|
|
return false;
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !wxFileExists( fullfilename ) )
|
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
msg.Printf( _( "Doc File '%s' not found" ), GetChars( aDocName ) );
|
2014-05-15 06:32:24 +00:00
|
|
|
DisplayError( aParent, msg );
|
2011-11-08 16:37:25 +00:00
|
|
|
return false;
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
|
|
|
|
2014-04-14 18:49:52 +00:00
|
|
|
wxFileName currentFileName( fullfilename );
|
|
|
|
|
|
|
|
wxString file_ext = currentFileName.GetExt();
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2008-06-29 18:51:38 +00:00
|
|
|
if( file_ext == wxT( "pdf" ) )
|
2008-04-24 16:55:35 +00:00
|
|
|
{
|
2008-06-29 18:51:38 +00:00
|
|
|
success = OpenPDF( fullfilename );
|
|
|
|
return success;
|
|
|
|
}
|
2008-04-24 16:55:35 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Try to launch some browser (useful under linux) */
|
2008-06-29 18:51:38 +00:00
|
|
|
wxFileType* filetype;
|
2008-04-24 16:55:35 +00:00
|
|
|
|
2008-06-29 18:51:38 +00:00
|
|
|
wxString type;
|
|
|
|
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
|
2008-04-24 16:55:35 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
if( !filetype ) // 2nd attempt.
|
2008-06-29 18:51:38 +00:00
|
|
|
{
|
|
|
|
mimeDatabase = new wxMimeTypesManager;
|
|
|
|
mimeDatabase->AddFallbacks( EDAfallbacks );
|
|
|
|
filetype = mimeDatabase->GetFileTypeFromExtension( file_ext );
|
|
|
|
delete mimeDatabase;
|
|
|
|
mimeDatabase = NULL;
|
|
|
|
}
|
2008-04-24 16:55:35 +00:00
|
|
|
|
2008-06-29 18:51:38 +00:00
|
|
|
if( filetype )
|
|
|
|
{
|
|
|
|
wxFileType::MessageParameters params( fullfilename, type );
|
|
|
|
|
|
|
|
success = filetype->GetOpenCommand( &command, params );
|
|
|
|
delete filetype;
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2008-06-29 18:51:38 +00:00
|
|
|
if( success )
|
|
|
|
success = ProcessExecute( command );
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
2008-06-29 18:51:38 +00:00
|
|
|
|
|
|
|
if( !success )
|
2008-04-24 16:55:35 +00:00
|
|
|
{
|
2011-11-08 16:37:25 +00:00
|
|
|
msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) );
|
2014-05-15 06:32:24 +00:00
|
|
|
DisplayError( aParent, msg );
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
int KeyWordOk( const wxString& KeyList, const wxString& Database )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-24 16:55:35 +00:00
|
|
|
wxString KeysCopy, DataList;
|
|
|
|
|
|
|
|
if( KeyList.IsEmpty() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
KeysCopy = KeyList; KeysCopy.MakeUpper();
|
|
|
|
DataList = Database; DataList.MakeUpper();
|
|
|
|
|
|
|
|
wxStringTokenizer Token( KeysCopy, wxT( " \n\r" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
while( Token.HasMoreTokens() )
|
|
|
|
{
|
2008-06-29 18:51:38 +00:00
|
|
|
wxString Key = Token.GetNextToken();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
// Search Key in Datalist:
|
|
|
|
wxStringTokenizer Data( DataList, wxT( " \n\r" ) );
|
|
|
|
|
|
|
|
while( Data.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
wxString word = Data.GetNextToken();
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2008-04-24 16:55:35 +00:00
|
|
|
if( word == Key )
|
2008-06-29 18:51:38 +00:00
|
|
|
return 1; // Key found !
|
2008-04-24 16:55:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// keyword not found
|
|
|
|
return 0;
|
|
|
|
}
|