2007-12-04 18:23:38 +00:00
|
|
|
/*********************/
|
|
|
|
/* File: cvframe.cpp */
|
|
|
|
/*********************/
|
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"
|
2009-04-23 15:02:18 +00:00
|
|
|
#include "macros.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "eda_doc.h"
|
|
|
|
#include "gestfich.h"
|
2009-04-23 15:02:18 +00:00
|
|
|
#include "param_config.h"
|
2009-05-06 11:55:36 +00:00
|
|
|
#include "bitmaps.h"
|
2009-02-05 20:53:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "cvpcb.h"
|
2011-02-05 16:15:48 +00:00
|
|
|
#include "cvpcb_mainframe.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvstruct.h"
|
2009-04-21 17:56:27 +00:00
|
|
|
#include "dialog_cvpcb_config.h"
|
2010-02-01 21:23:27 +00:00
|
|
|
#include "class_DisplayFootprintsFrame.h"
|
2010-11-07 20:06:07 +00:00
|
|
|
#include "cvpcb_id.h"
|
2011-02-22 17:59:46 +00:00
|
|
|
#include "dialog_load_error.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
#include "build_version.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#define FRAME_MIN_SIZE_X 450
|
|
|
|
#define FRAME_MIN_SIZE_Y 300
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
// option key to close cvpcb after saving files
|
|
|
|
static const wxString KeepCvpcbOpenEntry( wxT( "KeepCvpcbOpen" ) );
|
|
|
|
static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) );
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
|
|
|
|
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
// Menu events
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_MENU( ID_LOAD_PROJECT,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::LoadNetList )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_MENU( ID_SAVE_PROJECT,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::SaveQuitCvpcb )
|
2010-01-18 19:33:45 +00:00
|
|
|
EVT_MENU( wxID_EXIT,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnQuit )
|
2009-08-12 10:40:01 +00:00
|
|
|
EVT_MENU( ID_GENERAL_HELP,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::GetKicadHelp )
|
2009-08-12 10:40:01 +00:00
|
|
|
EVT_MENU( ID_KICAD_ABOUT,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::GetKicadAbout )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_MENU( ID_CONFIG_REQ,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::ConfigCvpcb )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_MENU( ID_CONFIG_SAVE,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::Update_Config )
|
2009-04-23 15:02:18 +00:00
|
|
|
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnKeepOpenOnSave )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE,
|
|
|
|
ID_LANGUAGE_CHOICE_END,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::SetLanguage )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
// Toolbar events
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_QUIT,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnQuit )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::LoadNetList )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_SAVEQUITCVPCB,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::SaveQuitCvpcb )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_CREATE_CONFIGWINDOW,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::ConfigCvpcb )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::DisplayModule )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::ToFirstNA )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::ToPreviousNA )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::DelAssociations )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::AssocieModule )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::WriteStuffList )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::DisplayDocFile )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
// Frame events
|
2011-02-05 16:15:48 +00:00
|
|
|
EVT_CHAR( CVPCB_MAINFRAME::OnChar )
|
|
|
|
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( CVPCB_MAINFRAME::OnSize )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
// List item events
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnLeftClick )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnLeftDClick )
|
2009-04-05 20:49:15 +00:00
|
|
|
EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnSelectComponent )
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave )
|
2009-04-05 20:49:15 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME( NULL, CVPCB_FRAME, title, wxDefaultPosition, wxDefaultSize, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
m_FrameName = wxT( "CvpcbFrame" );
|
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
m_ListCmp = NULL;
|
|
|
|
m_FootprintList = NULL;
|
|
|
|
DrawFrame = NULL;
|
|
|
|
m_HToolBar = NULL;
|
|
|
|
m_modified = false;
|
2009-04-23 15:02:18 +00:00
|
|
|
m_isEESchemaNetlist = false;
|
|
|
|
m_KeepCvpcbOpen = false;
|
|
|
|
m_undefinedComponentCnt = 0;
|
|
|
|
|
|
|
|
/* Name of the document footprint list
|
|
|
|
* usually located in share/modules/footprints_doc
|
|
|
|
* this is of the responsibility to users to create this file
|
|
|
|
* if they want to have a list of footprints
|
|
|
|
*/
|
2009-11-05 19:26:52 +00:00
|
|
|
m_DocModulesFileName = DEFAULT_FOOTPRINTS_LIST_FILENAME;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
SetIcon( wxICON( a_icon_cvpcb ) );
|
|
|
|
#else
|
|
|
|
SetIcon( wxICON( icon_cvpcb ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SetAutoLayout( TRUE );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
LoadSettings();
|
2007-12-04 18:23:38 +00:00
|
|
|
if( m_FrameSize.x < FRAME_MIN_SIZE_X )
|
|
|
|
m_FrameSize.x = FRAME_MIN_SIZE_X;
|
|
|
|
if( m_FrameSize.y < FRAME_MIN_SIZE_Y )
|
|
|
|
m_FrameSize.y = FRAME_MIN_SIZE_Y;
|
|
|
|
|
2009-11-07 14:36:54 +00:00
|
|
|
// Set minimal frame width and height
|
|
|
|
SetSizeHints( FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, -1, -1, -1, -1 );
|
|
|
|
|
|
|
|
// Framesize and position
|
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// create the status bar
|
2009-08-07 04:44:42 +00:00
|
|
|
static const int dims[3] = { -1, -1, 250 };
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
CreateStatusBar( 3 );
|
|
|
|
SetStatusWidths( 3, dims );
|
2009-08-07 04:44:42 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
ReCreateMenuBar();
|
2007-05-06 16:03:28 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
// Create list of available modules and components of the schematic
|
2007-12-04 18:23:38 +00:00
|
|
|
BuildCmpListBox();
|
2009-08-20 11:44:06 +00:00
|
|
|
BuildFOOTPRINTS_LISTBOX();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-05 08:52:41 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
wxAuiPaneInfo horiz;
|
2009-11-05 19:26:52 +00:00
|
|
|
horiz.Gripper( false );
|
|
|
|
horiz.DockFixed( true );
|
|
|
|
horiz.Movable( false );
|
|
|
|
horiz.Floatable( false );
|
|
|
|
horiz.CloseButton( false );
|
|
|
|
horiz.CaptionVisible( false );
|
2009-11-05 08:52:41 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
horiz.LeftDockable( false ).RightDockable( false );
|
2009-11-05 08:52:41 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_HToolBar )
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
|
2009-11-05 08:52:41 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_ListCmp )
|
|
|
|
m_auimgr.AddPane( m_ListCmp,
|
|
|
|
wxAuiPaneInfo(horiz).Name( wxT( "m_ListCmp" ) ).CentrePane() );
|
2009-11-07 14:36:54 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_FootprintList )
|
|
|
|
m_auimgr.AddPane( m_FootprintList,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ).
|
2010-01-22 18:13:43 +00:00
|
|
|
Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
m_auimgr.Update();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
if( config )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
int state = m_HToolBar->GetToolState(
|
|
|
|
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
|
|
|
|
config->Write( wxT( FILTERFOOTPRINTKEY ), state );
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
m_auimgr.UnInit();
|
2009-04-23 15:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load Cvpcb main frame specific configuration settings.
|
|
|
|
*
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
* settings will not get loaded.
|
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::LoadSettings()
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
|
|
|
|
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::LoadSettings();
|
2009-04-23 15:02:18 +00:00
|
|
|
cfg->Read( KeepCvpcbOpenEntry, &m_KeepCvpcbOpen, false );
|
|
|
|
cfg->Read( FootprintDocFileEntry, &m_DocModulesFileName,
|
|
|
|
DEFAULT_FOOTPRINTS_LIST_FILENAME );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save Cvpcb frame specific configuration settings.
|
|
|
|
*
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
* settings will not get saved.
|
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::SaveSettings()
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
|
|
|
|
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::SaveSettings();
|
2009-04-23 15:02:18 +00:00
|
|
|
cfg->Write( KeepCvpcbOpenEntry, m_KeepCvpcbOpen );
|
|
|
|
cfg->Write( FootprintDocFileEntry, m_DocModulesFileName );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnSize( wxSizeEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
event.Skip();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
Close( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
int diag;
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
if( m_modified )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2008-06-11 11:27:58 +00:00
|
|
|
unsigned ii;
|
2008-12-08 15:27:13 +00:00
|
|
|
wxMessageDialog dialog( this,
|
2009-05-21 17:42:42 +00:00
|
|
|
_( "Net and component list modified.\nSave before exit ?" ),
|
2008-12-08 15:27:13 +00:00
|
|
|
_( "Confirmation" ),
|
2009-11-05 19:26:52 +00:00
|
|
|
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION |
|
|
|
|
wxYES_DEFAULT );
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
ii = dialog.ShowModal();
|
|
|
|
|
|
|
|
switch( ii )
|
|
|
|
{
|
|
|
|
case wxID_CANCEL:
|
|
|
|
Event.Veto();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case wxID_NO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_OK:
|
|
|
|
case wxID_YES:
|
|
|
|
diag = SaveNetList( wxEmptyString );
|
|
|
|
if( diag > 0 )
|
2009-04-23 15:02:18 +00:00
|
|
|
m_modified = false;
|
2007-12-04 18:23:38 +00:00
|
|
|
else if( diag == 0 )
|
|
|
|
{
|
2010-05-17 20:35:46 +00:00
|
|
|
if( !IsOK( this, _( "Problem when saving files, exit anyway ?" ) ) )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2008-10-29 23:57:35 +00:00
|
|
|
Event.Veto();
|
2008-10-26 12:11:11 +00:00
|
|
|
return;
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close the help frame
|
2008-12-08 15:27:13 +00:00
|
|
|
if( wxGetApp().m_HtmlCtrl )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help
|
|
|
|
// frame active
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().m_HtmlCtrl->GetFrame()->Close( TRUE );
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( m_NetlistFileName.IsOk() )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
SetLastProject( m_NetlistFileName.GetFullPath() );
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
m_modified = false;
|
2007-12-04 18:23:38 +00:00
|
|
|
SaveSettings();
|
|
|
|
Destroy();
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnChar( wxKeyEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-08-20 11:44:06 +00:00
|
|
|
switch( event.GetKeyCode() )
|
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
case WXK_LEFT:
|
|
|
|
case WXK_NUMPAD_LEFT:
|
|
|
|
m_ListCmp->SetFocus();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_RIGHT:
|
|
|
|
case WXK_NUMPAD_RIGHT:
|
|
|
|
m_FootprintList->SetFocus();;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
event.Skip();
|
|
|
|
break;
|
2009-08-20 11:44:06 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
int ii = 0;
|
|
|
|
int selection;
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
if( m_components.empty() )
|
|
|
|
return;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
selection = m_ListCmp->GetSelection();
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
if( selection < 0 )
|
|
|
|
selection = 0;
|
2008-10-29 23:57:35 +00:00
|
|
|
|
2010-05-17 20:35:46 +00:00
|
|
|
BOOST_FOREACH( COMPONENT & component, m_components )
|
|
|
|
{
|
2009-05-06 11:55:36 +00:00
|
|
|
if( component.m_Module.IsEmpty() && ii > selection )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
m_ListCmp->SetSelection( ii );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ii++;
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
2009-04-23 15:02:18 +00:00
|
|
|
m_ListCmp->SetSelection( selection );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
int ii;
|
|
|
|
int selection;
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
if( m_components.empty() )
|
|
|
|
return;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
ii = m_ListCmp->GetCount() - 1;
|
2007-12-04 18:23:38 +00:00
|
|
|
selection = m_ListCmp->GetSelection();
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
if( selection < 0 )
|
2009-04-23 15:02:18 +00:00
|
|
|
selection = m_ListCmp->GetCount() - 1;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
BOOST_REVERSE_FOREACH( COMPONENT & component, m_components )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2009-05-06 11:55:36 +00:00
|
|
|
if( component.m_Module.IsEmpty() && ii < selection )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
m_ListCmp->SetSelection( ii );
|
|
|
|
return;
|
|
|
|
}
|
2007-12-04 18:23:38 +00:00
|
|
|
ii--;
|
|
|
|
}
|
2009-04-23 15:02:18 +00:00
|
|
|
m_ListCmp->SetSelection( selection );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
if( SaveNetList( wxEmptyString ) > 0 )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2009-04-23 15:02:18 +00:00
|
|
|
m_modified = false;
|
2009-11-05 19:26:52 +00:00
|
|
|
if( !m_KeepCvpcbOpen )
|
2009-04-21 17:56:27 +00:00
|
|
|
Close( TRUE );
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
/* Removes all associations already made
|
2007-12-04 18:23:38 +00:00
|
|
|
*/
|
2009-11-05 19:26:52 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
wxString Line;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
if( IsOK( this, _( "Delete selections" ) ) )
|
|
|
|
{
|
2009-05-06 11:55:36 +00:00
|
|
|
m_ListCmp->SetSelection( 0 );
|
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
BOOST_FOREACH( COMPONENT & component, m_components )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2009-05-06 11:55:36 +00:00
|
|
|
component.m_Module.Empty();
|
2007-12-04 18:23:38 +00:00
|
|
|
SetNewPkg( wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ListCmp->SetSelection( 0 );
|
2009-05-06 11:55:36 +00:00
|
|
|
m_undefinedComponentCnt = m_components.size();
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2010-11-07 20:06:07 +00:00
|
|
|
DisplayStatus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/*
|
|
|
|
* Called when click on Load Netlist button or by file history menu entries
|
2009-04-23 15:02:18 +00:00
|
|
|
* Read a netlist selected by user
|
2007-12-04 18:23:38 +00:00
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString oldPath;
|
|
|
|
wxFileName newFileName;
|
|
|
|
int id = event.GetId();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
if( id >= wxID_FILE1 && id <= wxID_FILE9 )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
newFileName = GetFileFromHistory( id, _( "Netlist" ) );
|
|
|
|
}
|
|
|
|
else
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2010-05-17 20:35:46 +00:00
|
|
|
wxFileDialog dlg( this, _( "Open Net List" ), wxGetCwd(),
|
|
|
|
wxEmptyString, NetlistFileWildcard,
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
newFileName = dlg.GetPath();
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( newFileName == m_NetlistFileName )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_NetlistFileName.DirExists() )
|
|
|
|
oldPath = m_NetlistFileName.GetPath();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Update the library search path list. */
|
|
|
|
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
|
|
|
|
wxGetApp().GetLibraryPathList().Remove( oldPath );
|
|
|
|
wxGetApp().GetLibraryPathList().Insert( newFileName.GetPath(), 0 );
|
|
|
|
m_NetlistFileName = newFileName;
|
|
|
|
|
|
|
|
if( ReadNetList() )
|
|
|
|
{
|
|
|
|
SetLastProject( m_NetlistFileName.GetFullPath() );
|
|
|
|
|
|
|
|
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
|
|
|
|
wxT( " " ) + m_NetlistFileName.GetFullPath() );
|
|
|
|
}
|
|
|
|
else
|
2009-02-22 10:38:40 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
2009-01-17 20:31:19 +00:00
|
|
|
|
|
|
|
ReCreateMenuBar();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::ConfigCvpcb( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-21 17:56:27 +00:00
|
|
|
DIALOG_CVPCB_CONFIG ConfigFrame( this );
|
2009-11-05 19:26:52 +00:00
|
|
|
|
2009-04-21 17:56:27 +00:00
|
|
|
ConfigFrame.ShowModal();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnKeepOpenOnSave( wxCommandEvent& event )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
m_KeepCvpcbOpen = event.IsChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
CreateScreenCmp();
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawFrame->RedrawScreen( wxPoint( 0, 0 ), false );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-26 15:39:10 +00:00
|
|
|
/** Vitual function SetLanguage
|
|
|
|
* called on a language menu selection
|
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::SetLanguage( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
GetAssociatedDocument( this, m_DocModulesFileName,
|
2009-04-23 15:02:18 +00:00
|
|
|
&wxGetApp().GetLibraryPathList() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnLeftClick( wxListEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
m_FootprintList->OnLeftClick( event );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnLeftDClick( wxListEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
m_FootprintList->OnLeftDClick( event );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-05 19:26:52 +00:00
|
|
|
int selection;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
if( !m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) )
|
|
|
|
{
|
|
|
|
m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
selection = m_ListCmp->GetSelection();
|
|
|
|
if( selection < 0 )
|
|
|
|
{
|
|
|
|
m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
if( &m_components[ selection ] == NULL )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
|
|
|
m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ],
|
|
|
|
m_footprints );
|
2010-11-07 20:06:07 +00:00
|
|
|
DisplayStatus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Select full/filtered footprint display on tool click
|
2007-12-04 18:23:38 +00:00
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-07 14:36:54 +00:00
|
|
|
switch (event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST:
|
|
|
|
m_HToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false );
|
|
|
|
break;
|
|
|
|
case ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST:
|
|
|
|
m_HToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-12-04 18:23:38 +00:00
|
|
|
wxListEvent l_event;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
OnSelectComponent( l_event );
|
|
|
|
}
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
event.Check( m_KeepCvpcbOpen );
|
|
|
|
}
|
2010-11-07 20:06:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** DisplayStatus()
|
|
|
|
* Displays info to the status line at bottom of the main frame
|
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::DisplayStatus()
|
2010-11-07 20:06:07 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Components: %d (free: %d)" ),
|
|
|
|
m_components.size(), m_undefinedComponentCnt );
|
|
|
|
SetStatusText( msg, 0 );
|
|
|
|
|
|
|
|
SetStatusText( wxEmptyString, 1 );
|
|
|
|
|
|
|
|
if( m_FootprintList )
|
|
|
|
{
|
|
|
|
if( m_FootprintList->m_UseFootprintFullList )
|
|
|
|
msg.Printf( _( "Footprints (All): %d" ),
|
|
|
|
m_FootprintList->m_ActiveFootprintList->GetCount() );
|
|
|
|
else
|
|
|
|
msg.Printf( _( "Footprints (filtered): %d" ),
|
|
|
|
m_FootprintList->m_ActiveFootprintList->GetCount() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
msg.Empty();
|
|
|
|
SetStatusText( msg, 2 );
|
|
|
|
}
|
2011-02-22 17:59:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the list of libraries (*.mod files) and populates m_footprints
|
|
|
|
* ( list of availaible modules in libs ).
|
|
|
|
* for each module are stored
|
|
|
|
* the module name
|
|
|
|
* documentation string
|
|
|
|
* associated keywords
|
|
|
|
*/
|
|
|
|
bool CVPCB_MAINFRAME::LoadFootprintFiles( )
|
|
|
|
{
|
|
|
|
/* Check if there are footprint libraries in project file */
|
|
|
|
if( m_ModuleLibNames.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ),
|
|
|
|
_( "Project File Error" ), wxOK | wxICON_ERROR );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_footprints.ReadFootprintFiles(m_ModuleLibNames);
|
|
|
|
|
|
|
|
/* Display error messages, if any */
|
|
|
|
if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() )
|
|
|
|
{
|
|
|
|
DIALOG_LOAD_ERROR dialog(NULL);
|
|
|
|
if( !m_footprints.m_filesNotFound.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxString message = _("Some files could not be found!");
|
|
|
|
dialog.MessageSet(message);
|
|
|
|
dialog.ListSet(m_footprints.m_filesNotFound);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Display if there are invalid files */
|
|
|
|
if( !m_footprints.m_filesInvalid.IsEmpty() )
|
|
|
|
{
|
|
|
|
dialog.MessageSet( _("Some files are invalid!"));
|
|
|
|
dialog.ListSet(m_footprints.m_filesInvalid);
|
|
|
|
}
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|