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
4.0 KiB

15 years ago
  1. /*****************************/
  2. /* dialog_gerber_config.cpp */
  3. /****************************/
  4. /*
  5. * Options for file extensions
  6. */
  7. #include "fctsys.h"
  8. #include "appl_wxstruct.h"
  9. #include "common.h"
  10. #include "gerbview.h"
  11. #include "dialog_helpers.h"
  12. enum
  13. {
  14. ID_SAVE_CFG = 1000
  15. };
  16. class WinEDA_ConfigFrame : public wxDialog
  17. {
  18. private:
  19. WinEDA_GerberFrame* m_Parent;
  20. wxListBox* ListLibr;
  21. int LibModified;
  22. WinEDA_EnterText* TextDrillExt;
  23. WinEDA_EnterText* TextPhotoExt;
  24. WinEDA_EnterText* TextPenExt;
  25. public:
  26. WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, const wxPoint& pos );
  27. ~WinEDA_ConfigFrame() { };
  28. private:
  29. void SaveCfg( wxCommandEvent& event );
  30. void OnOkClick( wxCommandEvent& event );
  31. void OnCancelClick( wxCommandEvent& event );
  32. DECLARE_EVENT_TABLE()
  33. };
  34. BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog )
  35. EVT_BUTTON( ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg )
  36. EVT_BUTTON( wxID_OK, WinEDA_ConfigFrame::OnOkClick )
  37. EVT_BUTTON( wxID_CANCEL, WinEDA_ConfigFrame::OnCancelClick )
  38. END_EVENT_TABLE()
  39. /**
  40. * Function InstallConfigFrame
  41. * install the dialog box to configure some gerbview options
  42. * mainly the default file extensions
  43. */
  44. void WinEDA_GerberFrame::InstallConfigFrame( const wxPoint& pos )
  45. {
  46. WinEDA_ConfigFrame* CfgFrame = new WinEDA_ConfigFrame( this, pos );
  47. CfgFrame->ShowModal();
  48. CfgFrame->Destroy();
  49. }
  50. WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent,
  51. const wxPoint& framepos ) :
  52. wxDialog( parent, -1, wxEmptyString, framepos, wxSize( 300, 180 ),
  53. wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT )
  54. {
  55. const int LEN_EXT = 100;
  56. wxString title;
  57. m_Parent = parent;
  58. /* Shows the config filename currently used : */
  59. title = _( "from " ) + wxGetApp().m_CurrentOptionFile;
  60. SetTitle( title );
  61. LibModified = FALSE;
  62. wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
  63. SetSizer( MainBoxSizer );
  64. wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
  65. wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
  66. MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
  67. MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
  68. /* Created the buttons */
  69. wxButton* Button = new wxButton( this, ID_SAVE_CFG, _( "Save Cfg..." ) );
  70. RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
  71. // Provide a spacer to improve appearance of dialog box
  72. RightBoxSizer->AddSpacer( 20 );
  73. Button = new wxButton( this, wxID_OK, _( "OK" ) );
  74. RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
  75. Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
  76. RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
  77. wxSize size;
  78. size.x = LEN_EXT;
  79. size.y = -1;
  80. TextDrillExt = new WinEDA_EnterText( this,
  81. _( "Drill File Ext:" ),
  82. g_DrillFilenameExt,
  83. LeftBoxSizer, size );
  84. TextPhotoExt = new WinEDA_EnterText( this,
  85. _( "Gerber File Ext:" ),
  86. g_PhotoFilenameExt,
  87. LeftBoxSizer, size );
  88. TextPenExt = new WinEDA_EnterText( this,
  89. _( "D code File Ext:" ),
  90. g_PenFilenameExt,
  91. LeftBoxSizer, size );
  92. GetSizer()->Fit( this );
  93. GetSizer()->SetSizeHints( this );
  94. }
  95. void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
  96. {
  97. g_DrillFilenameExt = TextDrillExt->GetValue();
  98. g_PhotoFilenameExt = TextPhotoExt->GetValue();
  99. g_PenFilenameExt = TextPenExt->GetValue();
  100. EndModal( 1 );
  101. }
  102. void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
  103. {
  104. EndModal( -1 );
  105. }
  106. void WinEDA_ConfigFrame::SaveCfg( wxCommandEvent& event )
  107. {
  108. m_Parent->Update_config();
  109. }