2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/**
|
|
|
|
* @file basicframe.cpp
|
2011-10-13 19:56:32 +00:00
|
|
|
* @brief EDA_BASE_FRAME class implementation.
|
2009-03-02 13:43:52 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-08-15 16:38:05 +00:00
|
|
|
#include <wx/aboutdlg.h>
|
2009-03-02 13:43:52 +00:00
|
|
|
#include <wx/fontdlg.h>
|
2010-08-24 17:26:51 +00:00
|
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <wx/statline.h>
|
|
|
|
#include <wx/platinfo.h>
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2010-08-24 17:26:51 +00:00
|
|
|
#include "build_version.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2008-06-11 10:33:13 +00:00
|
|
|
#include "online_help.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "eda_doc.h"
|
|
|
|
#include "wxstruct.h"
|
2009-10-13 11:49:08 +00:00
|
|
|
#include "macros.h"
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-08-24 17:26:51 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
/// The default auto save interval is 10 minutes.
|
|
|
|
#define DEFAULT_AUTO_SAVE_INTERVAL 600
|
|
|
|
|
|
|
|
|
|
|
|
static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" );
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
|
|
|
|
int idtype,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
2008-03-04 14:27:48 +00:00
|
|
|
wxFrame( father, -1, title, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
wxSize minsize;
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
m_Ident = idtype;
|
|
|
|
m_HToolBar = NULL;
|
|
|
|
m_FrameIsActive = true;
|
|
|
|
m_hasAutoSave = false;
|
|
|
|
m_autoSaveState = false;
|
|
|
|
m_autoSaveInterval = -1;
|
|
|
|
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
|
2009-08-07 04:44:42 +00:00
|
|
|
|
2011-04-12 14:19:59 +00:00
|
|
|
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
minsize.x = 470;
|
|
|
|
minsize.y = 350 + m_MsgFrameHeight;
|
2009-08-07 04:44:42 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
if( ( size.x < minsize.x ) || ( size.y < minsize.y ) )
|
2008-03-04 14:27:48 +00:00
|
|
|
SetSize( 0, 0, minsize.x, minsize.y );
|
|
|
|
|
|
|
|
// Create child subwindows.
|
2011-10-13 19:56:32 +00:00
|
|
|
GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimensions of the user area of the main
|
2009-11-23 15:16:50 +00:00
|
|
|
* window */
|
2011-10-13 19:56:32 +00:00
|
|
|
m_FramePos.x = m_FramePos.y = 0;
|
2008-03-04 14:27:48 +00:00
|
|
|
m_FrameSize.y -= m_MsgFrameHeight;
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-08-24 17:26:51 +00:00
|
|
|
Connect( ID_HELP_COPY_VERSION_STRING,
|
|
|
|
wxEVT_COMMAND_MENU_SELECTED,
|
2011-01-21 19:30:59 +00:00
|
|
|
wxCommandEventHandler( EDA_BASE_FRAME::CopyVersionInfoToClipboard ) );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
|
|
|
Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
|
|
|
|
wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::~EDA_BASE_FRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( wxGetApp().m_HtmlCtrl )
|
|
|
|
delete wxGetApp().m_HtmlCtrl;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().m_HtmlCtrl = NULL;
|
2009-07-20 05:18:47 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
delete m_autoSaveTimer;
|
|
|
|
|
2010-08-24 17:26:51 +00:00
|
|
|
/* This needed for OSX: avoids further OnDraw processing after this
|
2009-11-23 15:16:50 +00:00
|
|
|
* destructor and before the native window is destroyed
|
2009-07-20 05:18:47 +00:00
|
|
|
*/
|
2010-08-24 17:26:51 +00:00
|
|
|
this->Freeze();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-10-13 19:56:32 +00:00
|
|
|
if( !wxFrame::ProcessEvent( aEvent ) )
|
|
|
|
return false;
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
if( m_hasAutoSave && (m_autoSaveState != isModified()) && (m_autoSaveInterval > 0) )
|
|
|
|
{
|
|
|
|
if( !m_autoSaveState )
|
|
|
|
{
|
|
|
|
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
|
|
|
m_autoSaveState = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_autoSaveTimer->Stop();
|
|
|
|
m_autoSaveState = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
|
|
|
|
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( !doAutoSave() )
|
|
|
|
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_BASE_FRAME::doAutoSave()
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::ReCreateMenuBar()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::SetLanguage( wxCommandEvent& event )
|
2010-02-26 15:39:10 +00:00
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
|
|
|
|
wxGetApp().SetLanguageIdentifier( id );
|
2010-12-18 08:59:04 +00:00
|
|
|
wxGetApp().SetLanguage();
|
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
2010-02-26 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::LoadSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString text;
|
|
|
|
int Ypos_min;
|
|
|
|
wxConfig* config;
|
|
|
|
|
|
|
|
config = wxGetApp().m_EDA_Config;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-04-05 19:24:12 +00:00
|
|
|
int maximized = 0;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( config )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
|
|
|
text = m_FrameName + wxT( "Pos_x" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Read( text, &m_FramePos.x );
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Pos_y" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Read( text, &m_FramePos.y );
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Size_x" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Read( text, &m_FrameSize.x, 600 );
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Size_y" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Read( text, &m_FrameSize.y, 400 );
|
2011-04-05 19:24:12 +00:00
|
|
|
text = m_FrameName + wxT( "Maximized" );
|
|
|
|
config->Read( text, &maximized, 0 );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
|
|
|
if( m_hasAutoSave )
|
|
|
|
{
|
|
|
|
text = m_FrameName + entryAutoSaveInterval;
|
|
|
|
config->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
|
|
|
|
}
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure Window title bar is visible
|
2010-01-15 13:02:04 +00:00
|
|
|
#if defined( __WXMAC__ )
|
2008-03-04 14:27:48 +00:00
|
|
|
// for macOSX, the window must be below system (macOSX) toolbar
|
2010-08-24 17:26:51 +00:00
|
|
|
// Ypos_min = GetMBarHeight(); seems no more exist in new API (subject to change)
|
2010-01-15 13:02:04 +00:00
|
|
|
Ypos_min = 20;
|
2007-05-06 16:03:28 +00:00
|
|
|
#else
|
2008-03-04 14:27:48 +00:00
|
|
|
Ypos_min = 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
2008-03-04 14:27:48 +00:00
|
|
|
if( m_FramePos.y < Ypos_min )
|
|
|
|
m_FramePos.y = Ypos_min;
|
2011-04-05 19:24:12 +00:00
|
|
|
|
|
|
|
if( maximized )
|
|
|
|
Maximize();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::SaveSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
wxString text;
|
2008-12-08 15:27:13 +00:00
|
|
|
wxConfig* config;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
config = wxGetApp().m_EDA_Config;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( ( config == NULL ) || IsIconized() )
|
2008-03-04 14:27:48 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
m_FrameSize = GetSize();
|
|
|
|
m_FramePos = GetPosition();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Pos_x" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( text, (long) m_FramePos.x );
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Pos_y" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( text, (long) m_FramePos.y );
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Size_x" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( text, (long) m_FrameSize.x );
|
2008-03-04 14:27:48 +00:00
|
|
|
text = m_FrameName + wxT( "Size_y" );
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( text, (long) m_FrameSize.y );
|
2011-04-05 19:24:12 +00:00
|
|
|
text = m_FrameName + wxT( "Maximized" );
|
|
|
|
config->Write( text, IsMaximized() );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
|
|
|
if( m_hasAutoSave )
|
|
|
|
{
|
|
|
|
text = m_FrameName + entryAutoSaveInterval;
|
|
|
|
config->Write( text, m_autoSaveInterval );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::PrintMsg( const wxString& text )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
SetStatusText( text );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::DisplayActivity( int PerCent, const wxString& Text )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
wxString Line;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
Line = Text;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
PerCent = (PerCent < 0) ? 0 : PerCent;
|
|
|
|
PerCent = (PerCent > 100) ? 100 : PerCent;
|
|
|
|
PerCent /= 2; // Bargraph is 0 .. 50 points from 0% to 100%
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
if( PerCent )
|
|
|
|
Line.Pad( PerCent, '*' );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
SetStatusText( Line );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
|
2011-10-13 19:56:32 +00:00
|
|
|
wxFileHistory * aFileHistory )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-03-17 19:14:45 +00:00
|
|
|
wxFileHistory * fileHistory = aFileHistory;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
if( fileHistory == NULL )
|
|
|
|
fileHistory = & wxGetApp().m_fileHistory;
|
|
|
|
|
|
|
|
fileHistory->AddFileToHistory( FullFileName );
|
2009-01-17 20:31:19 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
|
|
|
|
wxFileHistory * aFileHistory )
|
2009-01-17 20:31:19 +00:00
|
|
|
{
|
|
|
|
wxString fn, msg;
|
|
|
|
size_t i;
|
2011-03-17 19:14:45 +00:00
|
|
|
wxFileHistory * fileHistory = aFileHistory;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
if( fileHistory == NULL )
|
|
|
|
fileHistory = & wxGetApp().m_fileHistory;
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
int baseId = fileHistory->GetBaseId();
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
wxASSERT( cmdId >= baseId && cmdId < baseId + ( int )fileHistory->GetCount() );
|
2009-01-17 20:31:19 +00:00
|
|
|
|
|
|
|
i = ( size_t )( cmdId - baseId );
|
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
if( i < fileHistory->GetCount() )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2011-03-17 19:14:45 +00:00
|
|
|
fn = fileHistory->GetHistoryFile( i );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
if( !wxFileName::FileExists( fn ) )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
msg = type + _( " file <" ) + fn + _( "> was not found." );
|
|
|
|
DisplayError( this, msg );
|
2011-03-17 19:14:45 +00:00
|
|
|
fileHistory->RemoveFileFromHistory( i );
|
2009-01-17 20:31:19 +00:00
|
|
|
fn = wxEmptyString;
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
return fn;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-29 14:26:20 +00:00
|
|
|
wxString msg;
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2011-08-04 18:03:26 +00:00
|
|
|
/* We have to get document for beginners,
|
|
|
|
* or the the full specific doc
|
|
|
|
* if event id is wxID_INDEX, we want the document for beginners.
|
|
|
|
* else the specific doc file (its name is in wxGetApp().m_HelpFileName)
|
2011-09-30 18:15:37 +00:00
|
|
|
* The document for beginners is the same for all KiCad utilities
|
2011-08-04 18:03:26 +00:00
|
|
|
*/
|
|
|
|
if( event.GetId() == wxID_INDEX )
|
|
|
|
{
|
|
|
|
// Temporary change the help filename
|
|
|
|
wxString tmp = wxGetApp().m_HelpFileName;
|
2011-08-04 19:56:30 +00:00
|
|
|
wxGetApp().m_HelpFileName = wxT( "Getting_Started_in_KiCad.pdf" );
|
2011-08-04 18:03:26 +00:00
|
|
|
wxString helpFile = wxGetApp().GetHelpFile();
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2011-08-04 18:03:26 +00:00
|
|
|
if( !helpFile )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Help file %s could not be found." ),
|
|
|
|
GetChars( wxGetApp().m_HelpFileName ) );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
else
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
2011-08-04 18:03:26 +00:00
|
|
|
GetAssociatedDocument( this, helpFile );
|
2011-10-13 19:56:32 +00:00
|
|
|
}
|
|
|
|
|
2011-08-04 18:03:26 +00:00
|
|
|
wxGetApp().m_HelpFileName = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-11 10:33:13 +00:00
|
|
|
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( wxGetApp().m_HtmlCtrl == NULL )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().InitOnLineHelp();
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( wxGetApp().m_HtmlCtrl )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().m_HtmlCtrl->DisplayContents();
|
|
|
|
wxGetApp().m_HtmlCtrl->Display( wxGetApp().m_HelpFileName );
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-01 18:33:44 +00:00
|
|
|
msg.Printf( _( "Help file %s not found." ), GetChars( wxGetApp().m_HelpFileName ) );
|
2008-03-04 14:27:48 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2008-06-11 10:33:13 +00:00
|
|
|
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
|
2009-01-29 14:26:20 +00:00
|
|
|
wxString helpFile = wxGetApp().GetHelpFile();
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2009-01-29 14:26:20 +00:00
|
|
|
if( !helpFile )
|
2008-06-11 10:33:13 +00:00
|
|
|
{
|
2009-01-29 14:26:20 +00:00
|
|
|
msg.Printf( _( "Help file %s could not be found." ),
|
2009-10-13 09:00:46 +00:00
|
|
|
GetChars( wxGetApp().m_HelpFileName ) );
|
2009-01-29 14:26:20 +00:00
|
|
|
DisplayError( this, msg );
|
2008-06-11 10:33:13 +00:00
|
|
|
}
|
2009-01-29 14:26:20 +00:00
|
|
|
else
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
2009-04-07 15:54:40 +00:00
|
|
|
GetAssociatedDocument( this, helpFile );
|
2011-10-13 19:56:32 +00:00
|
|
|
}
|
2008-06-11 10:33:13 +00:00
|
|
|
|
|
|
|
#else
|
2009-11-23 15:16:50 +00:00
|
|
|
# error Help files format not defined
|
2008-06-11 10:33:13 +00:00
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2011-03-13 18:03:43 +00:00
|
|
|
void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxFileName fn = wxGetApp().m_EditorName;
|
|
|
|
wxString wildcard( wxT( "*" ) );
|
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
wildcard += wxT( ".exe" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wildcard = _( "Executable file (" ) + wildcard + wxT( ")|" ) + wildcard;
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(),
|
2011-03-13 18:03:43 +00:00
|
|
|
fn.GetFullName(), wildcard,
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxASSERT( wxGetApp().m_EDA_CommonConfig );
|
|
|
|
|
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_CommonConfig;
|
|
|
|
wxGetApp().m_EditorName = dlg.GetPath();
|
|
|
|
cfg->Write( wxT( "Editor" ), wxGetApp().m_EditorName );
|
|
|
|
}
|
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-09-01 13:31:20 +00:00
|
|
|
bool ShowAboutDialog(wxWindow * parent);
|
|
|
|
ShowAboutDialog(this);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2010-08-24 17:26:51 +00:00
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::AddHelpVersionInfoMenuEntry( wxMenu* aMenu )
|
2010-08-24 17:26:51 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aMenu != NULL );
|
|
|
|
|
|
|
|
// Copy version string to clipboard for bug report purposes.
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( aMenu, ID_HELP_COPY_VERSION_STRING,
|
|
|
|
_( "Copy &Version Information" ),
|
|
|
|
_( "Copy the version string to clipboard to send with bug reports" ),
|
|
|
|
KiBitmap( copy_button_xpm ) );
|
2010-08-24 17:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-29 18:19:26 +00:00
|
|
|
// This is an enhanced version of the compiler build macro provided by wxWidgets
|
|
|
|
// in <wx/build.h>. Please do not make any of these strings translatable. They
|
|
|
|
// are used for conveying troubleshooting information to developers.
|
2010-08-24 17:26:51 +00:00
|
|
|
|
|
|
|
#if defined(__GXX_ABI_VERSION)
|
|
|
|
#define __ABI_VERSION ",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION)
|
|
|
|
#else
|
|
|
|
#define __ABI_VERSION ",compiler without C++ ABI "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__INTEL_COMPILER)
|
|
|
|
#define __BO_COMPILER ",Intel C++"
|
|
|
|
#elif defined(__GNUG__)
|
|
|
|
#define __BO_COMPILER ",GCC " \
|
|
|
|
__WX_BO_STRINGIZE(__GNUC__) "." \
|
|
|
|
__WX_BO_STRINGIZE(__GNUC_MINOR__) "." \
|
|
|
|
__WX_BO_STRINGIZE(__GNUC_PATCHLEVEL__)
|
|
|
|
#elif defined(__VISUALC__)
|
|
|
|
#define __BO_COMPILER ",Visual C++"
|
|
|
|
#elif defined(__BORLANDC__)
|
|
|
|
#define __BO_COMPILER ",Borland C++"
|
|
|
|
#elif defined(__DIGITALMARS__)
|
|
|
|
#define __BO_COMPILER ",DigitalMars"
|
|
|
|
#elif defined(__WATCOMC__)
|
|
|
|
#define __BO_COMPILER ",Watcom C++"
|
|
|
|
#else
|
|
|
|
#define __BO_COMPILER ",unknown"
|
|
|
|
#endif
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
#if wxCHECK_VERSION( 2, 9, 0 )
|
2010-09-29 18:19:26 +00:00
|
|
|
|
|
|
|
static inline const char* KICAD_BUILD_OPTIONS_SIGNATURE()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
" (" __WX_BO_UNICODE __ABI_VERSION __BO_COMPILER __WX_BO_STL
|
|
|
|
__WX_BO_WXWIN_COMPAT_2_6 __WX_BO_WXWIN_COMPAT_2_8 ")"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
#else
|
2010-09-29 18:19:26 +00:00
|
|
|
|
|
|
|
static inline const char* KICAD_BUILD_OPTIONS_SIGNATURE()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
" (" __WX_BO_DEBUG ","
|
|
|
|
__WX_BO_UNICODE __ABI_VERSION __BO_COMPILER __WX_BO_STL
|
|
|
|
__WX_BO_WXWIN_COMPAT_2_4 __WX_BO_WXWIN_COMPAT_2_6 ")"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
#endif
|
2010-09-29 18:19:26 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
|
2010-09-29 18:19:26 +00:00
|
|
|
{
|
|
|
|
if( !wxTheClipboard->Open() )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Could not open clipboard to write version information." ),
|
|
|
|
_( "Clipboard Error" ), wxOK | wxICON_EXCLAMATION, this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString tmp;
|
|
|
|
wxPlatformInfo info;
|
|
|
|
|
2010-08-24 17:26:51 +00:00
|
|
|
tmp = wxT( "Application: " ) + wxGetApp().GetTitle() + wxT( "\n" );
|
|
|
|
tmp += wxT( "Version: " ) + GetBuildVersion() + wxT( "\n" );
|
|
|
|
tmp << wxT( "Build: " ) << wxVERSION_STRING
|
2011-02-28 18:36:19 +00:00
|
|
|
<< FROM_UTF8( KICAD_BUILD_OPTIONS_SIGNATURE() ) << wxT( "\n" )
|
2010-08-24 17:26:51 +00:00
|
|
|
<< wxT( "Platform: " ) << wxGetOsDescription() << wxT( ", " )
|
|
|
|
<< info.GetArchName() << wxT( ", " ) << info.GetEndiannessName() << wxT( ", " )
|
2011-10-05 18:26:22 +00:00
|
|
|
<< info.GetPortIdName() << wxT( "\n" );
|
|
|
|
|
|
|
|
tmp << wxT( "Options: " );
|
|
|
|
|
|
|
|
tmp << wxT( "USE_PNG_BITMAPS=" );
|
|
|
|
#ifdef USE_PNG_BITMAPS
|
|
|
|
tmp << wxT( "ON\n" );
|
|
|
|
#else
|
|
|
|
tmp << wxT( "OFF\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tmp << wxT( " KICAD_GOST=" );
|
|
|
|
#ifdef KICAD_GOST
|
|
|
|
tmp << wxT( "ON\n" );
|
|
|
|
#else
|
|
|
|
tmp << wxT( "OFF\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tmp << wxT( " USE_WX_GRAPHICS_CONTEXT=" );
|
|
|
|
#ifdef USE_WX_GRAPHICS_CONTEXT
|
|
|
|
tmp << wxT( "ON\n" );
|
|
|
|
#else
|
|
|
|
tmp << wxT( "OFF\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tmp << wxT( " USE_WX_OVERLAY=" );
|
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
tmp << wxT( "ON\n" );
|
|
|
|
#else
|
|
|
|
tmp << wxT( "OFF\n" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tmp << wxT( " USE_BOOST_POLYGON_LIBRARY=" );
|
|
|
|
#ifdef USE_BOOST_POLYGON_LIBRARY
|
|
|
|
tmp << wxT( "ON\n" );
|
|
|
|
#else
|
|
|
|
tmp << wxT( "OFF\n" );
|
|
|
|
#endif
|
|
|
|
|
2010-08-24 17:26:51 +00:00
|
|
|
wxTheClipboard->SetData( new wxTextDataObject( tmp ) );
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
2011-08-18 19:25:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
wxCHECK_MSG( aFileName.IsOk(), false, wxT( "Invalid file name object. Bad programmer!" ) );
|
|
|
|
|
|
|
|
if( aFileName.IsDir() && !aFileName.IsDirWritable() )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "You do not have write permissions to folder <%s>." ),
|
|
|
|
GetChars( aFileName.GetPath() ) );
|
|
|
|
}
|
|
|
|
else if( !aFileName.FileExists() && !aFileName.IsDirWritable() )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "You do not have write permissions to save file <%s> to folder <%s>." ),
|
|
|
|
GetChars( aFileName.GetFullName() ), GetChars( aFileName.GetPath() ) );
|
|
|
|
}
|
|
|
|
else if( aFileName.FileExists() && !aFileName.IsFileWritable() )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "You do not have write permissions to save file <%s>." ),
|
|
|
|
GetChars( aFileName.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|