KiCad PCB EDA Suite
Loading...
Searching...
No Matches
grid_text_helpers.h
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-2023 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#ifndef KICAD_GRID_TEXT_HELPERS_H
22#define KICAD_GRID_TEXT_HELPERS_H
23
24#include <functional>
25#include <wx/generic/gridctrl.h>
26
27class wxGrid;
28class wxStyledTextCtrl;
29class wxStyledTextEvent;
31
36class GRID_CELL_ESCAPED_TEXT_RENDERER : public wxGridCellStringRenderer
37{
38public:
40
41 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow,
42 int aCol, bool isSelected ) override;
43
44 wxSize GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col ) override;
45};
46
47
48class GRID_CELL_STC_EDITOR : public wxGridCellEditor
49{
50public:
51 GRID_CELL_STC_EDITOR( bool aIgnoreCase,
52 std::function<void( wxStyledTextEvent&, SCINTILLA_TRICKS* )> aOnChar );
53
54 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
55
56 wxGridCellEditor* Clone() const override
57 {
59 }
60
61 wxString GetValue() const override;
62
63 void Show( bool aShow, wxGridCellAttr *aAttr = nullptr ) override;
64 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
65 bool EndEdit( int aRow, int aCol, const wxGrid*, const wxString&, wxString* aNewVal ) override;
66 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
67 void Reset() override {}
68
69protected:
70 void onFocusLoss( wxFocusEvent& aEvent );
71
72 wxStyledTextCtrl* stc_ctrl() const;
73
74protected:
77 wxString m_value;
78
79 std::function<void( wxStyledTextEvent&, SCINTILLA_TRICKS* )> m_onChar;
80};
81
82
83#endif // KICAD_GRID_TEXT_HELPERS_H
A text renderer that can unescape text for display This is useful where it's desired to keep the unde...
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
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void onFocusLoss(wxFocusEvent &aEvent)
bool EndEdit(int aRow, int aCol, const wxGrid *, const wxString &, wxString *aNewVal) override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
wxString GetValue() const override
wxGridCellEditor * Clone() const override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
void Show(bool aShow, wxGridCellAttr *aAttr=nullptr) override
wxStyledTextCtrl * stc_ctrl() const
std::function< void(wxStyledTextEvent &, SCINTILLA_TRICKS *)> m_onChar
SCINTILLA_TRICKS * m_scintillaTricks
void Reset() override
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.