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 The 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#pragma once
22
23#include <kicommon.h>
24#include <functional>
25#include <memory>
26#include <wx/generic/gridctrl.h>
27
28class wxGrid;
29class wxStyledTextCtrl;
30class wxStyledTextEvent;
32
33
38class KICOMMON_API GRID_CELL_TEXT_EDITOR : public wxGridCellTextEditor
39{
40public:
42
43 void SetSize( const wxRect& aRect ) override;
44
45 virtual void SetValidator( const wxValidator& validator ) override;
46 virtual void StartingKey( wxKeyEvent& event ) override;
47
48protected:
49 std::unique_ptr<wxValidator> m_validator;
50};
51
52
57class KICOMMON_API GRID_CELL_TEXT_RENDERER : public wxGridCellStringRenderer
58{
59public:
61
62 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow,
63 int aCol, bool isSelected ) override;
64
65 wxSize GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col ) override;
66};
67
68
73class KICOMMON_API GRID_CELL_ESCAPED_TEXT_RENDERER : public wxGridCellStringRenderer
74{
75public:
77
78 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow,
79 int aCol, bool isSelected ) override;
80
81 wxSize GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col ) override;
82};
83
84
85class KICOMMON_API GRID_CELL_STC_EDITOR : public wxGridCellEditor
86{
87public:
88 GRID_CELL_STC_EDITOR( bool aIgnoreCase, bool aSingleLine,
89 std::function<void( wxStyledTextEvent&, SCINTILLA_TRICKS* )> onCharFn );
90
91 void SetSize( const wxRect& aRect ) override;
92 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
93
94 wxGridCellEditor* Clone() const override
95 {
97 }
98
99 wxString GetValue() const override;
100
101 void StartingKey( wxKeyEvent& event ) override;
102 void Show( bool aShow, wxGridCellAttr *aAttr = nullptr ) override;
103 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
104 bool EndEdit( int aRow, int aCol, const wxGrid*, const wxString&, wxString* aNewVal ) override;
105 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
106 void Reset() override {}
107
108protected:
109 void onFocusLoss( wxFocusEvent& aEvent );
110
111 wxStyledTextCtrl* stc_ctrl() const;
112
113protected:
117 wxString m_value;
118
119 std::function<void( wxStyledTextEvent&, SCINTILLA_TRICKS* )> m_onCharFn;
120};
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 SetSize(const wxRect &aRect) override
std::function< void(wxStyledTextEvent &, SCINTILLA_TRICKS *)> m_onCharFn
GRID_CELL_STC_EDITOR(bool aIgnoreCase, bool aSingleLine, std::function< void(wxStyledTextEvent &, SCINTILLA_TRICKS *)> onCharFn)
wxGridCellEditor * Clone() const override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
SCINTILLA_TRICKS * m_scintillaTricks
std::unique_ptr< wxValidator > m_validator
void SetSize(const wxRect &aRect) override
virtual void StartingKey(wxKeyEvent &event) override
virtual void SetValidator(const wxValidator &validator) override
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
wxSize GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
#define KICOMMON_API
Definition kicommon.h:28