KiCad PCB EDA Suite
grid_text_helpers.cpp
Go to the documentation of this file.
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 <[email protected]>
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
21#include <string_utils.h>
23
24
26 wxGridCellStringRenderer()
27{
28}
29
30void GRID_CELL_ESCAPED_TEXT_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
31 const wxRect& aRect, int aRow, int aCol,
32 bool isSelected )
33{
34 wxString unescaped = UnescapeString( aGrid.GetCellValue( aRow, aCol ) );
35
36 wxRect rect = aRect;
37 rect.Inflate( -1 );
38
39 // erase background
40 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
41
42 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
43 aGrid.DrawTextRectangle( aDC, unescaped, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
44}
45
46
47wxSize GRID_CELL_ESCAPED_TEXT_RENDERER::GetBestSize( wxGrid & aGrid, wxGridCellAttr & aAttr,
48 wxDC & aDC, int aRow, int aCol )
49{
50 wxString unescaped = UnescapeString( aGrid.GetCellValue( aRow, aCol ) );
51 return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, unescaped );
52}
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
wxString UnescapeString(const wxString &aSource)