2009-03-02 13:43:52 +00:00
|
|
|
/**
|
|
|
|
* WinEDA_BasicFrame Class Functions
|
|
|
|
* @file basicframe.cpp
|
|
|
|
*/
|
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>
|
|
|
|
|
2008-08-15 16:38:05 +00:00
|
|
|
#include "wx/statline.h"
|
|
|
|
#include "wx/generic/aboutdlgg.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.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"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/*
|
|
|
|
* Class constructor for WinEDA_BasicFrame general options
|
|
|
|
*/
|
|
|
|
WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father,
|
|
|
|
int idtype,
|
2008-12-08 15:27:13 +00:00
|
|
|
const wxString& title,
|
2009-03-02 13:43:52 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
2008-12-08 15:27:13 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
m_Ident = idtype;
|
|
|
|
m_HToolBar = NULL;
|
|
|
|
m_FrameIsActive = TRUE;
|
2009-08-07 04:44:42 +00:00
|
|
|
|
|
|
|
m_MsgFrameHeight = WinEDA_MsgPanel::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.
|
2009-11-23 15:16:50 +00:00
|
|
|
GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimensions of the user
|
|
|
|
* area of the main
|
|
|
|
* window */
|
2008-03-04 14:27:48 +00:00
|
|
|
m_FramePos.x = m_FramePos.y = 0;
|
|
|
|
m_FrameSize.y -= m_MsgFrameHeight;
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_BasicFrame::~WinEDA_BasicFrame()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( wxGetApp().m_HtmlCtrl )
|
|
|
|
delete wxGetApp().m_HtmlCtrl;
|
|
|
|
wxGetApp().m_HtmlCtrl = NULL;
|
2009-07-20 05:18:47 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* This needed for OSX: avoids furter OnDraw processing after this
|
|
|
|
* destructor and before the native window is destroyed
|
2009-07-20 05:18:47 +00:00
|
|
|
*/
|
|
|
|
this->Freeze( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/*
|
|
|
|
* Virtual function
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_BasicFrame::ReCreateMenuBar()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/**
|
|
|
|
* Load common frame parameters from configuration.
|
|
|
|
*
|
|
|
|
* The method is virtual so you can override it to load frame specific
|
|
|
|
* parameters. Don't forget to call the base method or your frames won't
|
|
|
|
* remember their positions and sizes.
|
|
|
|
*/
|
|
|
|
void WinEDA_BasicFrame::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
|
|
|
|
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 );
|
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-01-15 13:02:04 +00:00
|
|
|
// Ypos_min = GetMBarHeight(); seems no more exist in ne API (subject to change)
|
|
|
|
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;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/**
|
|
|
|
* Save common frame parameters from configuration.
|
|
|
|
*
|
|
|
|
* The method is virtual so you can override it to save frame specific
|
|
|
|
* parameters. Don't forget to call the base method or your frames won't
|
|
|
|
* remember their positions and sizes.
|
|
|
|
*/
|
|
|
|
void WinEDA_BasicFrame::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 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_BasicFrame::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
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/*
|
|
|
|
* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_BasicFrame::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%
|
|
|
|
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
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/*
|
2009-11-23 15:16:50 +00:00
|
|
|
* Update the list of past projects.
|
2009-03-02 13:43:52 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
wxGetApp().m_fileHistory.AddFileToHistory( FullFileName );
|
|
|
|
ReCreateMenuBar();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/*
|
2009-01-17 20:31:19 +00:00
|
|
|
* Fetch the file name from the file history list.
|
|
|
|
*/
|
|
|
|
wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId,
|
|
|
|
const wxString& type )
|
|
|
|
{
|
|
|
|
wxString fn, msg;
|
|
|
|
size_t i;
|
|
|
|
int baseId = wxGetApp().m_fileHistory.GetBaseId();
|
|
|
|
|
|
|
|
wxASSERT( cmdId >= baseId
|
|
|
|
&& cmdId < baseId + ( int )wxGetApp().m_fileHistory.GetCount() );
|
|
|
|
|
|
|
|
i = ( size_t )( cmdId - baseId );
|
|
|
|
|
|
|
|
if( i < wxGetApp().m_fileHistory.GetCount() )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
fn = wxGetApp().m_fileHistory.GetHistoryFile( i );
|
|
|
|
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 );
|
|
|
|
wxGetApp().m_fileHistory.RemoveFileFromHistory( i );
|
|
|
|
fn = wxEmptyString;
|
|
|
|
ReCreateMenuBar();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_BasicFrame::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
|
|
|
|
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
|
|
|
|
{
|
2009-11-23 15:16:50 +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();
|
|
|
|
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
|
2009-04-07 15:54:40 +00:00
|
|
|
GetAssociatedDocument( this, helpFile );
|
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
|
|
|
}
|
|
|
|
|
2009-03-02 13:43:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-08-15 16:38:05 +00:00
|
|
|
wxAboutDialogInfo info;
|
|
|
|
InitKiCadAbout(info);
|
|
|
|
wxAboutBox(info);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|