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.

52 lines
1.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
  5. * @author Jon Evans <jon@craftyjon.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <kicad_string.h>
  21. #include <widgets/grid_text_helpers.h>
  22. GRID_CELL_ESCAPED_TEXT_RENDERER::GRID_CELL_ESCAPED_TEXT_RENDERER() :
  23. wxGridCellStringRenderer()
  24. {
  25. }
  26. void GRID_CELL_ESCAPED_TEXT_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
  27. const wxRect& aRect, int aRow, int aCol,
  28. bool isSelected )
  29. {
  30. wxString unescaped = UnescapeString( aGrid.GetCellValue( aRow, aCol ) );
  31. wxRect rect = aRect;
  32. rect.Inflate( -1 );
  33. // erase background
  34. wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
  35. SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
  36. aGrid.DrawTextRectangle( aDC, unescaped, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
  37. }
  38. wxSize GRID_CELL_ESCAPED_TEXT_RENDERER::GetBestSize( wxGrid & aGrid, wxGridCellAttr & aAttr,
  39. wxDC & aDC, int aRow, int aCol )
  40. {
  41. wxString unescaped = UnescapeString( aGrid.GetCellValue( aRow, aCol ) );
  42. return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, unescaped );
  43. }