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.

94 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. #ifndef TEXT_MOD_GRID_TABLE_H
  24. #define TEXT_MOD_GRID_TABLE_H
  25. #include <base_units.h>
  26. #include <wx/grid.h>
  27. #include <grid_tricks.h>
  28. #include <class_text_mod.h>
  29. class MODULE;
  30. class PCB_BASE_FRAME;
  31. enum TEXT_MOD_COL_ORDER
  32. {
  33. TMC_TEXT,
  34. TMC_SHOWN,
  35. TMC_WIDTH,
  36. TMC_HEIGHT,
  37. TMC_THICKNESS,
  38. TMC_ITALIC,
  39. TMC_LAYER,
  40. TMC_ORIENTATION,
  41. TMC_UPRIGHT, // keep text upright when viewed from bottom or right of board
  42. TMC_XOFFSET,
  43. TMC_YOFFSET,
  44. TMC_COUNT // keep as last
  45. };
  46. class TEXT_MOD_GRID_TABLE : public wxGridTableBase, public std::vector<TEXTE_MODULE>
  47. {
  48. public:
  49. TEXT_MOD_GRID_TABLE( EDA_UNITS userUnits, PCB_BASE_FRAME* aFrame );
  50. ~TEXT_MOD_GRID_TABLE();
  51. int GetNumberRows() override { return (int) size(); }
  52. int GetNumberCols() override { return TMC_COUNT; }
  53. wxString GetColLabelValue( int aCol ) override;
  54. wxString GetRowLabelValue( int aRow ) override;
  55. bool IsEmptyCell( int row, int col ) override
  56. {
  57. return false; // don't allow adjacent cell overflow, even if we are actually empty
  58. }
  59. bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
  60. bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
  61. wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) override;
  62. wxString GetValue( int aRow, int aCol ) override;
  63. bool GetValueAsBool( int aRow, int aCol ) override;
  64. long GetValueAsLong( int aRow, int aCol ) override;
  65. void SetValue( int aRow, int aCol, const wxString &aValue ) override;
  66. void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
  67. void SetValueAsLong( int aRow, int aCol, long aValue ) override;
  68. private:
  69. EDA_UNITS m_userUnits;
  70. PCB_BASE_FRAME* m_frame;
  71. wxGridCellAttr* m_readOnlyAttr;
  72. wxGridCellAttr* m_boolColAttr;
  73. wxGridCellAttr* m_orientationColAttr;
  74. wxGridCellAttr* m_layerColAttr;
  75. };
  76. #endif // TEXT_MOD_GRID_TABLE_H