KiCad PCB EDA Suite
Loading...
Searching...
No Matches
grid_text_button_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) 2021 CERN
5 * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef GRID_TEXT_BUTTON_HELPERS_H
26#define GRID_TEXT_BUTTON_HELPERS_H
27
28#include <memory>
29
30#include <wx/combo.h>
31#include <wx/generic/gridctrl.h>
32#include <wx/generic/grideditors.h>
33
34
35class wxGrid;
36class WX_GRID;
37class DIALOG_SHIM;
38
39
40class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor
41{
42public:
44
45 wxString GetValue() const override;
46
47 void SetSize( const wxRect& aRect ) override;
48
49 void StartingKey( wxKeyEvent& event ) override;
50 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
51 bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *aNewVal ) override;
52 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
53 void Reset() override;
54
55#if wxUSE_VALIDATORS
56 void SetValidator( const wxValidator& validator );
57#endif
58
59protected:
60 wxComboCtrl* Combo() const { return static_cast<wxComboCtrl*>( m_control ); }
61
62#if wxUSE_VALIDATORS
63 std::unique_ptr< wxValidator > m_validator;
64#endif
65
66 wxString m_value;
67
69};
70
71
73{
74public:
76 const wxString& aPreselect = wxEmptyString ) :
77 m_dlg( aParent ),
78 m_preselect( aPreselect )
79 { }
80
81 wxGridCellEditor* Clone() const override
82 {
84 }
85
86 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
87
88protected:
90 wxString m_preselect;
91};
92
93
95{
96public:
97 GRID_CELL_FPID_EDITOR( DIALOG_SHIM* aParent, const wxString& aSymbolNetlist,
98 const wxString& aPreselect = wxEmptyString ) :
99 m_dlg( aParent ),
100 m_preselect( aPreselect ),
101 m_symbolNetlist( aSymbolNetlist )
102 { }
103
104 wxGridCellEditor* Clone() const override
105 {
107 }
108
109 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
110
111protected:
113 wxString m_preselect;
115};
116
117
119{
120public:
121 GRID_CELL_URL_EDITOR( DIALOG_SHIM* aParent, SEARCH_STACK* aSearchStack = nullptr ) :
122 m_dlg( aParent ), m_searchStack( aSearchStack )
123 { }
124
125 wxGridCellEditor* Clone() const override
126 {
127 return new GRID_CELL_URL_EDITOR( m_dlg );
128 }
129
130 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
131
132protected:
135};
136
137
142{
143public:
154 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
155 bool aNormalize, const wxString& aNormalizeBasePath,
156 std::function<wxString( WX_GRID* grid, int row )> aFileFilterFn ) :
157 m_dlg( aParentDialog ),
158 m_grid( aGrid ),
159 m_currentDir( aCurrentDir ),
160 m_normalize( aNormalize ),
161 m_normalizeBasePath( aNormalizeBasePath ),
162 m_fileFilterFn( std::move( aFileFilterFn ) )
163 { }
164
176 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
177 const wxString& aFileFilter, bool aNormalize = false,
178 const wxString& aNormalizeBasePath = wxEmptyString ) :
179 m_dlg( aParentDialog ),
180 m_grid( aGrid ),
181 m_currentDir( aCurrentDir ),
182 m_normalize( aNormalize ),
183 m_normalizeBasePath( aNormalizeBasePath ),
184 m_fileFilter( aFileFilter )
185 { }
186
187 wxGridCellEditor* Clone() const override
188 {
189 if( m_fileFilterFn )
190 {
193 }
194 else
195 {
198 }
199 }
200
201 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
202
203protected:
206 wxString* m_currentDir;
209
210 wxString m_fileFilter;
211 std::function<wxString( WX_GRID* aGrid, int aRow )> m_fileFilterFn;
212};
213
214
215#endif // GRID_TEXT_BUTTON_HELPERS_H
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
GRID_CELL_FPID_EDITOR(DIALOG_SHIM *aParent, const wxString &aSymbolNetlist, const wxString &aPreselect=wxEmptyString)
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxGridCellEditor * Clone() const override
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
GRID_CELL_PATH_EDITOR(DIALOG_SHIM *aParentDialog, WX_GRID *aGrid, wxString *aCurrentDir, const wxString &aFileFilter, bool aNormalize=false, const wxString &aNormalizeBasePath=wxEmptyString)
Constructor.
wxGridCellEditor * Clone() const override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
std::function< wxString(WX_GRID *aGrid, int aRow)> m_fileFilterFn
GRID_CELL_PATH_EDITOR(DIALOG_SHIM *aParentDialog, WX_GRID *aGrid, wxString *aCurrentDir, bool aNormalize, const wxString &aNormalizeBasePath, std::function< wxString(WX_GRID *grid, int row)> aFileFilterFn)
Constructor.
wxGridCellEditor * Clone() const override
GRID_CELL_SYMBOL_ID_EDITOR(DIALOG_SHIM *aParent, const wxString &aPreselect=wxEmptyString)
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxDECLARE_NO_COPY_CLASS(GRID_CELL_TEXT_BUTTON)
wxString GetValue() const override
wxComboCtrl * Combo() const
void StartingKey(wxKeyEvent &event) override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
bool EndEdit(int, int, const wxGrid *, const wxString &, wxString *aNewVal) override
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void SetSize(const wxRect &aRect) override
wxGridCellEditor * Clone() const override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
GRID_CELL_URL_EDITOR(DIALOG_SHIM *aParent, SEARCH_STACK *aSearchStack=nullptr)
Look for files in a number of paths.
Definition: search_stack.h:42
STL namespace.