kicad/pcbnew/dialog_freeroute_exchange.cpp

378 lines
11 KiB
C++
Raw Normal View History

2008-03-14 18:17:51 +00:00
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_freeroute_exchange.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 14/03/2008 09:19:27
// RCS-ID:
// Copyright: kicad team
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 14/03/2008 09:19:27
////@begin includes
////@end includes
#include "fctsys.h"
#include "appl_wxstruct.h"
2008-03-14 18:17:51 +00:00
#include "common.h"
#include "gestfich.h"
2008-03-14 18:17:51 +00:00
#include "pcbnew.h"
#include "dialog_freeroute_exchange.h"
////@begin XPM images
////@end XPM images
#define FREEROUTE_URL_KEY wxT( "freeroute_url" )
#define FREEROUTE_RUN_KEY wxT( "freeroute_command" )
/**********************************************************************/
void WinEDA_PcbFrame::Access_to_External_Tool( wxCommandEvent& event )
/**********************************************************************/
/* Run an external tool (currently, only freeroute)
*/
{
dialog_freeroute_exchange dialog( this );
dialog.ShowModal();
}
/*!
* dialog_freeroute_exchange type definition
*/
IMPLEMENT_DYNAMIC_CLASS( dialog_freeroute_exchange, wxDialog )
/*!
* dialog_freeroute_exchange event table definition
*/
BEGIN_EVENT_TABLE( dialog_freeroute_exchange, wxDialog )
////@begin dialog_freeroute_exchange event table entries
2008-03-19 13:49:23 +00:00
EVT_INIT_DIALOG( dialog_freeroute_exchange::OnInitDialog )
2008-03-18 21:18:04 +00:00
EVT_CLOSE( dialog_freeroute_exchange::OnCloseWindow )
2008-03-14 18:17:51 +00:00
2008-03-19 14:38:06 +00:00
EVT_BUTTON( ID_BUTTON4, dialog_freeroute_exchange::OnButton4Click )
2008-03-14 18:17:51 +00:00
2008-03-19 14:38:06 +00:00
EVT_BUTTON( ID_BUTTON5, dialog_freeroute_exchange::OnButton5Click )
2008-03-14 18:17:51 +00:00
2008-03-19 14:38:06 +00:00
EVT_BUTTON( ID_BUTTON6, dialog_freeroute_exchange::OnButton6Click )
2008-03-14 18:17:51 +00:00
2008-03-19 14:38:06 +00:00
EVT_BUTTON( ID_BUTTON7, dialog_freeroute_exchange::OnButton7Click )
2008-03-14 18:17:51 +00:00
2008-03-19 14:38:06 +00:00
EVT_TEXT( ID_TEXTCTRL2, dialog_freeroute_exchange::OnTextEditFrUrlUpdated )
2008-03-14 18:17:51 +00:00
2008-03-19 14:38:06 +00:00
EVT_BUTTON( wxID_CANCEL, dialog_freeroute_exchange::OnCancelClick )
2008-03-14 18:17:51 +00:00
////@end dialog_freeroute_exchange event table entries
END_EVENT_TABLE()
/*!
* dialog_freeroute_exchange constructors
*/
dialog_freeroute_exchange::dialog_freeroute_exchange()
{
Init();
}
2008-03-18 21:18:04 +00:00
dialog_freeroute_exchange::dialog_freeroute_exchange( wxWindow* parent,
2008-03-14 18:17:51 +00:00
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{
2008-03-18 21:18:04 +00:00
m_Parent = (WinEDA_PcbFrame*) parent;
2008-03-14 18:17:51 +00:00
Init();
Create( parent, id, caption, pos, size, style );
}
/*!
* dialog_freeroute_exchange creator
*/
bool dialog_freeroute_exchange::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{
////@begin dialog_freeroute_exchange creation
2008-03-18 21:18:04 +00:00
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
2008-03-14 18:17:51 +00:00
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
2008-03-18 21:18:04 +00:00
if (GetSizer())
2008-03-14 18:17:51 +00:00
{
2008-03-18 21:18:04 +00:00
GetSizer()->SetSizeHints(this);
2008-03-14 18:17:51 +00:00
}
Centre();
////@end dialog_freeroute_exchange creation
return true;
}
/*!
* dialog_freeroute_exchange destructor
*/
dialog_freeroute_exchange::~dialog_freeroute_exchange()
{
////@begin dialog_freeroute_exchange destruction
////@end dialog_freeroute_exchange destruction
}
/*!
* Member initialisation
*/
void dialog_freeroute_exchange::Init()
{
////@begin dialog_freeroute_exchange member initialisation
m_FreeRouteSetupChanged = false;
2008-03-19 14:38:06 +00:00
m_ExportDSN = NULL;
2008-03-14 18:17:51 +00:00
m_FreerouteURLName = NULL;
////@end dialog_freeroute_exchange member initialisation
}
/*!
* Control creation for dialog_freeroute_exchange
*/
void dialog_freeroute_exchange::CreateControls()
{
////@begin dialog_freeroute_exchange content construction
2008-03-25 16:20:07 +00:00
// Generated by DialogBlocks, Tue 25 Mar 2008 11:02:20 CDT (unregistered)
2008-03-14 18:17:51 +00:00
dialog_freeroute_exchange* itemDialog1 = this;
2008-03-19 14:38:06 +00:00
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
2008-03-18 21:18:04 +00:00
itemDialog1->SetSizer(itemBoxSizer2);
2008-03-19 14:38:06 +00:00
wxPanel* itemPanel3 = new wxPanel( itemDialog1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL );
2008-03-19 15:24:42 +00:00
itemBoxSizer2->Add(itemPanel3, 1, wxGROW|wxALL, 5);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
itemPanel3->SetSizer(itemBoxSizer4);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemPanel3, wxID_ANY, _T(""));
wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxVERTICAL);
itemBoxSizer4->Add(itemStaticBoxSizer5, 0, wxGROW|wxALL, 5);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
m_ExportDSN = new wxButton( itemPanel3, ID_BUTTON4, _("Export a Specctra Design (*.dsn) File"), wxDefaultPosition, wxDefaultSize, 0 );
2008-03-18 21:18:04 +00:00
if (dialog_freeroute_exchange::ShowToolTips())
2008-03-19 14:38:06 +00:00
m_ExportDSN->SetToolTip(_("Export a Specctra DSN file (to FreeRouter)"));
itemStaticBoxSizer5->Add(m_ExportDSN, 0, wxGROW|wxALL, 5);
2008-03-19 13:49:23 +00:00
wxButton* itemButton7 = new wxButton( itemPanel3, ID_BUTTON5, _("Launch FreeRouter via Java Web Start"), wxDefaultPosition, wxDefaultSize, 0 );
2008-03-19 14:38:06 +00:00
if (dialog_freeroute_exchange::ShowToolTips())
itemButton7->SetToolTip(_("Use Java Web Start function to run FreeRouter via Internet (or your Browser if not found)"));
2008-03-19 14:38:06 +00:00
itemStaticBoxSizer5->Add(itemButton7, 0, wxGROW|wxALL, 5);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
wxButton* itemButton8 = new wxButton( itemPanel3, ID_BUTTON6, _("Back Import the Specctra Session (*.ses) File"), wxDefaultPosition, wxDefaultSize, 0 );
if (dialog_freeroute_exchange::ShowToolTips())
itemButton8->SetToolTip(_("Merge a session file created by FreeRouter with the current board."));
itemStaticBoxSizer5->Add(itemButton8, 0, wxGROW|wxALL, 5);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
wxStaticBox* itemStaticBoxSizer9Static = new wxStaticBox(itemPanel3, wxID_ANY, _T(""));
wxStaticBoxSizer* itemStaticBoxSizer9 = new wxStaticBoxSizer(itemStaticBoxSizer9Static, wxVERTICAL);
2008-03-25 16:20:07 +00:00
itemBoxSizer4->Add(itemStaticBoxSizer9, 1, wxGROW|wxALL, 5);
2008-03-19 13:49:23 +00:00
2008-10-13 18:28:30 +00:00
wxButton* itemButton10 = new wxButton( itemPanel3, ID_BUTTON7, _("Visit FreeRouting.net website"), wxDefaultPosition, wxDefaultSize, 0 );
2008-03-18 21:18:04 +00:00
if (dialog_freeroute_exchange::ShowToolTips())
2008-03-19 13:49:23 +00:00
itemButton10->SetToolTip(_("Launch your browser and go to the FreeRouting.net website"));
2008-03-19 14:38:06 +00:00
itemStaticBoxSizer9->Add(itemButton10, 0, wxGROW|wxALL, 5);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
wxStaticText* itemStaticText11 = new wxStaticText( itemPanel3, wxID_STATIC, _("FreeRouting.net URL"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer9->Add(itemStaticText11, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
2008-03-18 21:18:04 +00:00
2008-03-19 14:38:06 +00:00
m_FreerouteURLName = new wxTextCtrl( itemPanel3, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
2008-03-18 21:18:04 +00:00
if (dialog_freeroute_exchange::ShowToolTips())
m_FreerouteURLName->SetToolTip(_("The URL of the FreeRouting.net website"));
itemStaticBoxSizer9->Add(m_FreerouteURLName, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
2008-03-19 14:38:06 +00:00
wxStdDialogButtonSizer* itemStdDialogButtonSizer13 = new wxStdDialogButtonSizer;
2008-03-19 14:38:06 +00:00
itemBoxSizer2->Add(itemStdDialogButtonSizer13, 0, wxGROW|wxALL, 5);
wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
itemStdDialogButtonSizer13->AddButton(itemButton14);
2008-03-19 14:38:06 +00:00
itemStdDialogButtonSizer13->Realize();
2008-03-14 18:17:51 +00:00
////@end dialog_freeroute_exchange content construction
wxString msg;
wxGetApp().m_EDA_Config->Read( FREEROUTE_URL_KEY, &msg );
2008-03-14 18:17:51 +00:00
if( msg.IsEmpty() )
m_FreerouteURLName->SetValue( wxT( "http://www.freerouting.net/" ) );
else
m_FreerouteURLName->SetValue( msg );
}
/*!
* Should we show tooltips?
*/
bool dialog_freeroute_exchange::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap dialog_freeroute_exchange::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin dialog_freeroute_exchange bitmap retrieval
2008-03-18 21:18:04 +00:00
wxUnusedVar(name);
2008-03-14 18:17:51 +00:00
return wxNullBitmap;
////@end dialog_freeroute_exchange bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon dialog_freeroute_exchange::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin dialog_freeroute_exchange icon retrieval
2008-03-18 21:18:04 +00:00
wxUnusedVar(name);
2008-03-14 18:17:51 +00:00
return wxNullIcon;
////@end dialog_freeroute_exchange icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CREATE_EXPORT_DSN_FILE
*/
2008-03-19 14:38:06 +00:00
void dialog_freeroute_exchange::OnButton4Click( wxCommandEvent& event )
2008-03-14 18:17:51 +00:00
{
m_Parent->ExportToSpecctra( event );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_IMPORT_FREEROUTE_DSN_FILE
*/
2008-03-19 14:38:06 +00:00
void dialog_freeroute_exchange::OnButton6Click( wxCommandEvent& event )
2008-03-14 18:17:51 +00:00
{
m_Parent->ImportSpecctraSession( event );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RUN_FREEROUTE
*/
2008-03-19 14:38:06 +00:00
void dialog_freeroute_exchange::OnButton5Click( wxCommandEvent& event )
2008-03-14 18:17:51 +00:00
{
wxString FullFileName = FindKicadFile( wxT( "freeroute.jnlp" ) );
wxString command;
if( wxFileExists( FullFileName ) )
{
// Wrap FullFileName in double quotes in case it has C:\Program Files in it.
// The space is interpreted as an argument separator.
command << wxT("javaws") << wxChar(' ') << wxChar('"') << FullFileName << wxChar('"');
2008-04-24 16:55:35 +00:00
ProcessExecute( command );
return;
}
2008-03-14 18:17:51 +00:00
command = m_FreerouteURLName->GetValue() + wxT( "/java/freeroute.jnlp" );
2008-03-18 21:18:04 +00:00
2008-03-14 18:17:51 +00:00
wxLaunchDefaultBrowser( command );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
*/
2008-03-19 14:38:06 +00:00
void dialog_freeroute_exchange::OnButton7Click( wxCommandEvent& event )
2008-03-14 18:17:51 +00:00
{
wxString command = m_FreerouteURLName->GetValue();
wxLaunchDefaultBrowser( command );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
*/
2008-03-19 13:49:23 +00:00
void dialog_freeroute_exchange::OnCancelClick( wxCommandEvent& event )
2008-03-14 18:17:51 +00:00
{
2008-03-19 13:49:23 +00:00
D(printf("OnCancelClick\n");)
Close( true );
2008-03-14 18:17:51 +00:00
}
/*!
* wxEVT_CLOSE_WINDOW event handler for ID_DIALOG_FREEROUTE_EXCHANGE
*/
void dialog_freeroute_exchange::OnCloseWindow( wxCloseEvent& event )
{
2008-03-19 13:49:23 +00:00
D(printf("OnCloseWindow\n");)
2008-03-14 18:17:51 +00:00
if( m_FreeRouteSetupChanged ) // Save new config
{
wxGetApp().m_EDA_Config->Write( FREEROUTE_URL_KEY,
m_FreerouteURLName->GetValue() );
2008-03-14 18:17:51 +00:00
}
2008-03-19 13:49:23 +00:00
Destroy();
2008-03-14 18:17:51 +00:00
}
/*!
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXT_EDIT_FR_URL
*/
void dialog_freeroute_exchange::OnTextEditFrUrlUpdated( wxCommandEvent& event )
{
m_FreeRouteSetupChanged = true;
}
2008-03-19 13:49:23 +00:00
/*!
* wxEVT_INIT_DIALOG event handler for ID_DIALOG_FREEROUTE_EXCHANGE
*/
void dialog_freeroute_exchange::OnInitDialog( wxInitDialogEvent& event )
{
2008-03-19 14:38:06 +00:00
m_ExportDSN->SetFocus();
2008-03-19 13:49:23 +00:00
////@begin wxEVT_INIT_DIALOG event handler for ID_DIALOG_FREEROUTE_EXCHANGE in dialog_freeroute_exchange.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_INIT_DIALOG event handler for ID_DIALOG_FREEROUTE_EXCHANGE in dialog_freeroute_exchange.
}