You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.7 KiB

  1. /******************************************/
  2. /** cfg.cpp : configuration pour Gerbview */
  3. /******************************************/
  4. /* lit ou met a jour la configuration de PCBNEW */
  5. #include "fctsys.h"
  6. #include "common.h"
  7. #include "gerbview.h"
  8. #include "pcbplot.h"
  9. #include "cfg.h"
  10. #include "id.h"
  11. #include "hotkeys_basic.h"
  12. #include "hotkeys.h"
  13. #include "protos.h"
  14. /* Local functions */
  15. static bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose );
  16. /* Variables locales */
  17. #define HOTKEY_FILENAME wxT("gerbview")
  18. /*************************************************************/
  19. void WinEDA_GerberFrame::Process_Config(wxCommandEvent& event)
  20. /*************************************************************/
  21. {
  22. int id = event.GetId();
  23. wxPoint pos;
  24. wxString FullFileName;
  25. pos = GetPosition();
  26. pos.x += 20; pos.y += 20;
  27. switch( id )
  28. {
  29. case ID_COLORS_SETUP :
  30. DisplayColorSetupFrame(this, pos);
  31. break;
  32. case ID_CONFIG_REQ : // Creation de la fenetre de configuration
  33. {
  34. InstallConfigFrame(pos);
  35. break;
  36. }
  37. case ID_PCB_TRACK_SIZE_SETUP:
  38. case ID_PCB_LOOK_SETUP:
  39. case ID_OPTIONS_SETUP:
  40. InstallPcbOptionsFrame(pos, id);
  41. break;
  42. case ID_CONFIG_SAVE:
  43. Update_config();
  44. break;
  45. case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
  46. FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
  47. FullFileName += HOTKEY_FILENAME;
  48. FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
  49. WriteHotkeyConfigFile(FullFileName, s_Gerbview_Hokeys_Descr, true);
  50. break;
  51. case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
  52. Read_Hotkey_Config( this, true);
  53. break;
  54. default:
  55. DisplayError(this, wxT("WinEDA_GerberFrame::Process_Config internal error"));
  56. }
  57. }
  58. /*****************************************************/
  59. bool Read_Config()
  60. /*****************************************************/
  61. /* lit la configuration, si elle n'a pas deja etee lue
  62. 1 - lit gerbview.cnf
  63. 2 - si non trouve lit <chemin de gerbview.exe>/gerbview.cnf
  64. 3 - si non trouve: init des variables aux valeurs par defaut
  65. Retourne un pointeur su le message d'erreur a afficher
  66. */
  67. {
  68. g_Prj_Config_Filename_ext = wxT(".cnf");
  69. EDA_Appl->ReadProjectConfig( wxT("gerbview"), GROUP, ParamCfgList, FALSE);
  70. /* Inits autres variables */
  71. if (ScreenPcb) ScreenPcb->SetGrid(TmpGrid);
  72. if ( g_PhotoFilenameExt.IsEmpty() ) g_PhotoFilenameExt = wxT(".pho");
  73. if ( g_DrillFilenameExt.IsEmpty() ) g_DrillFilenameExt = wxT(".drl");
  74. if ( g_PenFilenameExt.IsEmpty() ) g_PenFilenameExt = wxT(".pen");
  75. return TRUE;
  76. }
  77. /******************************************/
  78. void WinEDA_GerberFrame::Update_config()
  79. /******************************************/
  80. /*
  81. creation du fichier de config
  82. */
  83. {
  84. wxString FullFileName;
  85. wxString mask( wxT("*") ),
  86. g_Prj_Config_Filename_ext = wxT(".cnf";)
  87. mask += g_Prj_Config_Filename_ext;
  88. FullFileName = wxT("gerbview");
  89. ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
  90. FullFileName = EDA_FileSelector(_("Save config file"),
  91. wxEmptyString, /* Chemin par defaut */
  92. FullFileName, /* nom fichier par defaut */
  93. g_Prj_Config_Filename_ext, /* extension par defaut */
  94. mask, /* Masque d'affichage */
  95. this,
  96. wxFD_SAVE,
  97. TRUE
  98. );
  99. if ( FullFileName.IsEmpty() ) return;
  100. /* ecriture de la configuration */
  101. EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList);
  102. }
  103. /***************************************************************/
  104. bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose )
  105. /***************************************************************/
  106. /*
  107. * Read the hotkey files config for pcbnew and module_edit
  108. */
  109. {
  110. wxString FullFileName = DEFAULT_HOTKEY_FILENAME_PATH;
  111. FullFileName += HOTKEY_FILENAME;
  112. FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
  113. return frame->ReadHotkeyConfigFile(FullFileName, s_Gerbview_Hokeys_Descr, verbose);
  114. }