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.

97 lines
3.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <fctsys.h>
  24. #include <common.h>
  25. #include <class_drawpanel.h>
  26. #include <footprint_viewer_frame.h>
  27. #include <dialog_fp_browser_display_options.h>
  28. void FOOTPRINT_VIEWER_FRAME::InstallDisplayOptions( wxCommandEvent& event )
  29. {
  30. DIALOG_FP_BROWSER_DISPLAY_OPTIONS dlg( this );
  31. dlg.ShowModal();
  32. }
  33. DIALOG_FP_BROWSER_DISPLAY_OPTIONS::DIALOG_FP_BROWSER_DISPLAY_OPTIONS( FOOTPRINT_VIEWER_FRAME* aParent )
  34. : DIALOG_FP_BROWSER_DISPLAY_OPTIONS_BASE( aParent ),
  35. m_frame( aParent )
  36. {
  37. initDialog();
  38. m_sdbSizerOK->SetDefault();
  39. FinishDialogSettings();;
  40. }
  41. DIALOG_FP_BROWSER_DISPLAY_OPTIONS::~DIALOG_FP_BROWSER_DISPLAY_OPTIONS( )
  42. {
  43. }
  44. void DIALOG_FP_BROWSER_DISPLAY_OPTIONS::initDialog()
  45. {
  46. /* mandatory to use escape key as cancel under wxGTK. */
  47. SetFocus();
  48. auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
  49. m_EdgesDisplayOption->SetValue( not displ_opts->m_DisplayModEdgeFill );
  50. m_TextDisplayOption->SetValue( not displ_opts->m_DisplayModTextFill );
  51. m_ShowPadSketch->SetValue( not displ_opts->m_DisplayPadFill );
  52. m_ShowPadNum->SetValue( displ_opts->m_DisplayPadNum );
  53. m_autoZoomOption->SetValue( m_frame->GetAutoZoom() );
  54. }
  55. void DIALOG_FP_BROWSER_DISPLAY_OPTIONS::UpdateObjectSettings()
  56. {
  57. auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
  58. displ_opts->m_DisplayModEdgeFill = not m_EdgesDisplayOption->GetValue();
  59. displ_opts->m_DisplayModTextFill = not m_TextDisplayOption->GetValue();
  60. displ_opts->m_DisplayPadNum = m_ShowPadNum->GetValue();
  61. displ_opts->m_DisplayPadFill = not m_ShowPadSketch->GetValue();
  62. m_frame->ApplyDisplaySettingsToGAL();
  63. m_frame->SetAutoZoom( m_autoZoomOption->GetValue() );
  64. }
  65. bool DIALOG_FP_BROWSER_DISPLAY_OPTIONS::TransferDataFromWindow()
  66. {
  67. UpdateObjectSettings();
  68. return true;
  69. }
  70. void DIALOG_FP_BROWSER_DISPLAY_OPTIONS::OnApplyClick( wxCommandEvent& event )
  71. {
  72. UpdateObjectSettings();
  73. }