22#include <wx/stc/stc.h>
31 wxGridCellStringRenderer()
36 const wxRect& aRect,
int aRow,
int aCol,
39 wxString unescaped =
UnescapeString( aGrid.GetCellValue( aRow, aCol ) );
45 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
47 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
48 aGrid.DrawTextRectangle( aDC, unescaped, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
53 wxDC & aDC,
int aRow,
int aCol )
55 wxString unescaped =
UnescapeString( aGrid.GetCellValue( aRow, aCol ) );
56 return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, unescaped );
64 std::function<
void( wxStyledTextEvent&,
66 m_scintillaTricks( nullptr ),
67 m_ignoreCase( aIgnoreCase ),
74 m_control =
new wxStyledTextCtrl( aParent );
77 stc_ctrl()->SetBackSpaceUnIndents(
false );
79 stc_ctrl()->SetViewWhiteSpace(
false );
80 stc_ctrl()->SetIndentationGuides(
false );
83 stc_ctrl()->SetEOLMode( wxSTC_EOL_LF );
84 stc_ctrl()->AutoCompSetMaxWidth( 25 );
91 stc_ctrl()->SetScrollWidthTracking(
true );
96 [
this]( wxKeyEvent& aEvent )
98 HandleReturn( aEvent );
101 [
this]( wxStyledTextEvent& aEvent )
108 wxGridCellEditor::Create( aParent, aId, aEventHandler );
114 return static_cast<wxStyledTextCtrl*
>( m_control );
129 wxGridCellEditor::Show( aShow, aAttr );
135 auto evtHandler =
static_cast<wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler()
139 evtHandler->SetInSetFocus(
true );
141 m_value = aGrid->GetTable()->GetValue( aRow, aCol );
151 const wxString value =
stc_ctrl()->GetText();
167 aGrid->GetTable()->SetValue( aRow, aCol,
m_value );
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
GRID_CELL_ESCAPED_TEXT_RENDERER()
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void onFocusLoss(wxFocusEvent &aEvent)
GRID_CELL_STC_EDITOR(bool aIgnoreCase, std::function< void(wxStyledTextEvent &, SCINTILLA_TRICKS *)> aOnChar)
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
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
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
wxString UnescapeString(const wxString &aSource)