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.

95 lines
3.2 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 modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef PANEL_FP_LIB_TABLE_H
  20. #define PANEL_FP_LIB_TABLE_H
  21. #include <dialog_edit_library_tables.h>
  22. #include <panel_fp_lib_table_base.h>
  23. #include <widgets/wx_grid.h>
  24. class FP_LIB_TABLE;
  25. class FP_LIB_TABLE_GRID;
  26. /**
  27. * Dialog to show and edit symbol library tables.
  28. */
  29. class PANEL_FP_LIB_TABLE : public PANEL_FP_LIB_TABLE_BASE
  30. {
  31. public:
  32. PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent,
  33. FP_LIB_TABLE* aGlobal, const wxString& aGlobalTblPath,
  34. FP_LIB_TABLE* aProject, const wxString& aProjectTblPath,
  35. const wxString& aProjectBasePath );
  36. ~PANEL_FP_LIB_TABLE() override;
  37. private:
  38. bool TransferDataFromWindow() override;
  39. /**
  40. * Trim important fields, removes blank row entries, and checks for duplicates.
  41. *
  42. * @return bool - true if tables are OK, else false.
  43. */
  44. bool verifyTables();
  45. void pageChangedHandler( wxAuiNotebookEvent& event ) override;
  46. void appendRowHandler( wxCommandEvent& event ) override;
  47. void browseLibrariesHandler( wxCommandEvent& event ) override;
  48. void deleteRowHandler( wxCommandEvent& event ) override;
  49. void moveUpHandler( wxCommandEvent& event ) override;
  50. void moveDownHandler( wxCommandEvent& event ) override;
  51. void onSizeGrid( wxSizeEvent& event ) override;
  52. void adjustPathSubsGridColumns( int aWidth );
  53. /// Populate the readonly environment variable table with names and values
  54. /// by examining all the full_uri columns.
  55. void populateEnvironReadOnlyTable();
  56. // caller's tables are modified only on OK button and successful verification.
  57. FP_LIB_TABLE* m_global;
  58. FP_LIB_TABLE* m_project;
  59. wxString m_projectBasePath;
  60. FP_LIB_TABLE_GRID* global_model() const
  61. {
  62. return (FP_LIB_TABLE_GRID*) m_global_grid->GetTable();
  63. }
  64. FP_LIB_TABLE_GRID* project_model() const
  65. {
  66. return (FP_LIB_TABLE_GRID*) m_project_grid->GetTable();
  67. }
  68. FP_LIB_TABLE_GRID* cur_model() const
  69. {
  70. return (FP_LIB_TABLE_GRID*) m_cur_grid->GetTable();
  71. }
  72. DIALOG_EDIT_LIBRARY_TABLES* m_parent;
  73. WX_GRID* m_cur_grid; // changed based on tab choice
  74. static size_t m_pageNdx; // Remember last notebook page selected during a session
  75. static wxString m_lastBrowseDir; // Remember last directory browsed during a session
  76. };
  77. #endif // PANEL_FP_LIB_TABLE_H