kicad/gerbview/gerbview_config.cpp

102 lines
2.6 KiB
C++
Raw Normal View History

2007-09-19 15:29:50 +00:00
/************************************************/
/** gerbview_config.cpp : Gerbview configuration*/
/************************************************/
2007-09-11 07:34:46 +00:00
#include "fctsys.h"
#include "appl_wxstruct.h"
2007-09-11 07:34:46 +00:00
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "gestfich.h"
#include "pcbcommon.h"
2007-09-11 07:34:46 +00:00
#include "gerbview.h"
#include "pcbplot.h"
#include "hotkeys.h"
2009-10-28 11:48:47 +00:00
#include "class_board_design_settings.h"
2007-09-11 07:34:46 +00:00
#include "gerbview_config.h"
#include "dialog_hotkeys_editor.h"
2008-03-04 04:22:27 +00:00
2007-09-19 15:29:50 +00:00
void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
2007-09-11 07:34:46 +00:00
{
2007-09-19 15:29:50 +00:00
int id = event.GetId();
wxPoint pos;
wxString FullFileName;
pos = GetPosition();
2008-03-04 04:22:27 +00:00
pos.x += 20;
pos.y += 20;
2007-09-19 15:29:50 +00:00
switch( id )
{
case ID_CONFIG_REQ:
2007-09-19 15:29:50 +00:00
{
InstallConfigFrame( pos );
break;
}
case ID_CONFIG_SAVE:
Update_config();
break;
/* Hotkey IDs */
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( s_Gerbview_Hokeys_Descr );
2007-09-19 15:29:50 +00:00
break;
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
ImportHotkeyConfigFromFile( s_Gerbview_Hokeys_Descr );
2007-09-19 15:29:50 +00:00
break;
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
InstallHotkeyFrame( this, s_Gerbview_Hokeys_Descr );
2007-09-19 15:29:50 +00:00
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
// Display current hotkey list for eeschema.
DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
break;
2007-09-19 15:29:50 +00:00
default:
DisplayError( this,
wxT( "WinEDA_GerberFrame::Process_Config internal error" ) );
2007-09-19 15:29:50 +00:00
}
2007-09-11 07:34:46 +00:00
}
/* Read configuration, if it has not already read.
* 1 - bed gerbview.cnf
* 2 - if no bed is path> gerbview.exe> / gerbview.cnf
* 3 - If not found: init variables to default values
2007-09-19 15:29:50 +00:00
*/
bool Read_Config()
2007-09-11 07:34:46 +00:00
{
wxGetApp().ReadProjectConfig( wxT( "gerbview.cnf" ), GROUP, ParamCfgList,
FALSE );
2007-09-19 15:29:50 +00:00
if( g_PhotoFilenameExt.IsEmpty() )
g_PhotoFilenameExt = wxT( "pho" );
2007-09-19 15:29:50 +00:00
if( g_DrillFilenameExt.IsEmpty() )
g_DrillFilenameExt = wxT( "drl" );
2007-09-19 15:29:50 +00:00
if( g_PenFilenameExt.IsEmpty() )
g_PenFilenameExt = wxT( "pen" );
2007-09-19 15:29:50 +00:00
return TRUE;
2007-09-11 07:34:46 +00:00
}
void WinEDA_GerberFrame::Update_config()
2007-09-11 07:34:46 +00:00
{
wxFileName fn = wxFileName( wxEmptyString, wxT( "gerbview" ),
GerbviewProjectFileExt );
wxFileDialog dlg( this, _( "Save GerbView Project File" ), wxEmptyString,
fn.GetFullName(), GerbviewProjectFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
2007-09-19 15:29:50 +00:00
return;
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList );
2007-09-11 07:34:46 +00:00
}