2008-03-04 14:27:48 +00:00
|
|
|
/******************************************************************/
|
|
|
|
/* basicframe.cpp - fonctions des classes du type WinEDA_BasicFrame */
|
|
|
|
/******************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include <wx/fontdlg.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
/*******************************************************/
|
|
|
|
/* Constructeur de WinEDA_BasicFrame: la fenetre generale */
|
|
|
|
/*******************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, int idtype,
|
|
|
|
WinEDA_App* parent, const wxString& title,
|
|
|
|
const wxPoint& pos, const wxSize& size, long style ) :
|
|
|
|
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_Parent = parent;
|
|
|
|
SetFont( *g_StdFont );
|
|
|
|
m_MenuBar = NULL; // menu du haut d'ecran
|
|
|
|
m_HToolBar = NULL;
|
|
|
|
m_FrameIsActive = TRUE;
|
|
|
|
m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT;
|
|
|
|
|
|
|
|
minsize.x = 470;
|
|
|
|
minsize.y = 350 + m_MsgFrameHeight;
|
|
|
|
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
|
|
|
|
|
|
|
|
/* Verification des parametres de creation */
|
|
|
|
if( (size.x < minsize.x) || (size.y < minsize.y) )
|
|
|
|
SetSize( 0, 0, minsize.x, minsize.y );
|
|
|
|
|
|
|
|
// Create child subwindows.
|
|
|
|
GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimx, dimy = dimensions utiles de la
|
|
|
|
* zone utilisateur de la fenetre principale */
|
|
|
|
m_FramePos.x = m_FramePos.y = 0;
|
|
|
|
m_FrameSize.y -= m_MsgFrameHeight;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_BasicFrame::~WinEDA_BasicFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
if( m_Parent->m_HtmlCtrl )
|
|
|
|
delete m_Parent->m_HtmlCtrl;
|
|
|
|
m_Parent->m_HtmlCtrl = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_BasicFrame::ReCreateMenuBar()
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
// Virtual function
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_BasicFrame::GetSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************/
|
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
wxString text;
|
|
|
|
int Ypos_min;
|
|
|
|
|
|
|
|
if( m_Parent->m_EDA_Config )
|
|
|
|
{
|
|
|
|
text = m_FrameName + wxT( "Pos_x" );
|
|
|
|
m_Parent->m_EDA_Config->Read( text, &m_FramePos.x );
|
|
|
|
text = m_FrameName + wxT( "Pos_y" );
|
|
|
|
m_Parent->m_EDA_Config->Read( text, &m_FramePos.y );
|
|
|
|
text = m_FrameName + wxT( "Size_x" );
|
|
|
|
m_Parent->m_EDA_Config->Read( text, &m_FrameSize.x, 600 );
|
|
|
|
text = m_FrameName + wxT( "Size_y" );
|
|
|
|
m_Parent->m_EDA_Config->Read( text, &m_FrameSize.y, 400 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure Window title bar is visible
|
2007-05-06 16:03:28 +00:00
|
|
|
#ifdef __WXMAC__
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
// for macOSX, the window must be below system (macOSX) toolbar
|
|
|
|
Ypos_min = GetMBarHeight();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_BasicFrame::SaveSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************/
|
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
wxString text;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
if( !m_Parent || !m_Parent->m_EDA_Config )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
if( !m_Parent->m_EDA_Config || IsIconized() )
|
|
|
|
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" );
|
|
|
|
m_Parent->m_EDA_Config->Write( text, (long) m_FramePos.x );
|
|
|
|
text = m_FrameName + wxT( "Pos_y" );
|
|
|
|
m_Parent->m_EDA_Config->Write( text, (long) m_FramePos.y );
|
|
|
|
text = m_FrameName + wxT( "Size_x" );
|
|
|
|
m_Parent->m_EDA_Config->Write( text, (long) m_FrameSize.x );
|
|
|
|
text = m_FrameName + wxT( "Size_y" );
|
|
|
|
m_Parent->m_EDA_Config->Write( text, (long) m_FrameSize.y );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2008-03-04 14:27:48 +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 );
|
2008-02-12 21:12:46 +00:00
|
|
|
#ifdef DEBUG
|
2008-03-04 14:27:48 +00:00
|
|
|
printf( "%s\n", (const char*) text.mb_str() );
|
2008-02-12 21:12:46 +00:00
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2008-03-04 14:27:48 +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
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100
|
2008-03-04 14:27:48 +00:00
|
|
|
*/
|
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
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Met a jour la liste des anciens projets
|
2008-03-04 14:27:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
unsigned ii;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
//suppression d'une ancienne trace eventuelle du meme fichier
|
|
|
|
for( ii = 0; ii < m_Parent->m_LastProject.GetCount(); )
|
|
|
|
{
|
|
|
|
if( m_Parent->m_LastProject[ii].IsEmpty() )
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
#ifdef __WINDOWS__
|
2008-03-04 14:27:48 +00:00
|
|
|
if( m_Parent->m_LastProject[ii].CmpNoCase( FullFileName ) == 0 )
|
2007-05-06 16:03:28 +00:00
|
|
|
#else
|
2008-03-04 14:27:48 +00:00
|
|
|
if( m_Parent->m_LastProject[ii] == FullFileName )
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
|
|
|
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4 ) ) )
|
|
|
|
m_Parent->m_LastProject.Remove( ii );
|
2007-05-06 16:03:28 +00:00
|
|
|
#else
|
2008-03-04 14:27:48 +00:00
|
|
|
m_Parent->m_LastProject.RemoveAt( ii );
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ii++;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
while( m_Parent->m_LastProject.GetCount() >= m_Parent->m_LastProjectMaxCount )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4 ) ) )
|
|
|
|
files.Remove( files.GetCount() - 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
#else
|
2008-03-04 14:27:48 +00:00
|
|
|
m_Parent->m_LastProject.RemoveAt( m_Parent->m_LastProject.GetCount() - 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
m_Parent->m_LastProject.Insert( FullFileName, 0 );
|
|
|
|
|
|
|
|
ReCreateMenuBar();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
wxString WinEDA_BasicFrame::GetLastProject( int rang )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************/
|
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
if( rang < 0 )
|
|
|
|
rang = 0;
|
|
|
|
if( (unsigned) rang >= m_Parent->m_LastProject.GetCount() )
|
|
|
|
return wxEmptyString;
|
|
|
|
return m_Parent->m_LastProject[rang];
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
if( m_Parent->m_HtmlCtrl == NULL )
|
|
|
|
{
|
|
|
|
m_Parent->InitOnLineHelp();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( m_Parent->m_HtmlCtrl )
|
|
|
|
{
|
|
|
|
m_Parent->m_HtmlCtrl->DisplayContents();
|
|
|
|
m_Parent->m_HtmlCtrl->Display( m_Parent->m_HelpFileName );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Help file %s not found" ), m_Parent->m_HelpFileName.GetData() );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************/
|
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
Print_Kicad_Infos( this, m_AboutTitle );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2008-03-04 14:27:48 +00:00
|
|
|
void WinEDA_BasicFrame::ProcessFontPreferences( int id )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
wxFont font;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_PREFERENCES_FONT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_FONT_STATUS:
|
|
|
|
font = wxGetFontFromUser( this, *g_StdFont );
|
|
|
|
if( font.Ok() )
|
|
|
|
{
|
|
|
|
int pointsize = font.GetPointSize();
|
|
|
|
*g_StdFont = font;
|
|
|
|
SetFont( *g_StdFont );
|
|
|
|
if( GetStatusBar() )
|
|
|
|
GetStatusBar()->SetFont( *g_StdFont );
|
|
|
|
g_StdFontPointSize = pointsize;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_FONT_DIALOG:
|
|
|
|
font = wxGetFontFromUser( this, *g_DialogFont );
|
|
|
|
if( font.Ok() )
|
|
|
|
{
|
|
|
|
int pointsize = font.GetPointSize();
|
|
|
|
*g_DialogFont = font;
|
|
|
|
SetFont( *g_DialogFont );
|
|
|
|
g_DialogFontPointSize = pointsize;
|
|
|
|
g_FixedFontPointSize = pointsize;
|
|
|
|
g_FixedFont->SetPointSize( g_FixedFontPointSize );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_BasicFrame::ProcessFontPreferences Internal Error" ) );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|