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;
38class EMBEDDED_FILES;
39
40
41class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor
42{
43public:
45
46 wxString GetValue() const override;
47
48 void SetSize( const wxRect& aRect ) override;
49
50 void StartingKey( wxKeyEvent& event ) override;
51 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
52 bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *aNewVal ) override;
53 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
54 void Reset() override;
55
56#if wxUSE_VALIDATORS
57 void SetValidator( const wxValidator& validator );
58#endif
59
60protected:
61 wxComboCtrl* Combo() const { return static_cast<wxComboCtrl*>( m_control ); }
62
63#if wxUSE_VALIDATORS
64 std::unique_ptr< wxValidator > m_validator;
65#endif
66
67 wxString m_value;
68
70};
71
72
74{
75public:
77 const wxString& aPreselect = wxEmptyString ) :
78 m_dlg( aParent ),
79 m_preselect( aPreselect )
80 { }
81
82 wxGridCellEditor* Clone() const override
83 {
85 }
86
87 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
88
89protected:
91 wxString m_preselect;
92};
93
94
96{
97public:
98 GRID_CELL_FPID_EDITOR( DIALOG_SHIM* aParent, const wxString& aSymbolNetlist,
99 const wxString& aPreselect = wxEmptyString ) :
100 m_dlg( aParent ),
101 m_preselect( aPreselect ),
102 m_symbolNetlist( aSymbolNetlist )
103 { }
104
105 wxGridCellEditor* Clone() const override
106 {
108 }
109
110 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
111
112protected:
114 wxString m_preselect;
116};
117
118
120{
121public:
122 GRID_CELL_URL_EDITOR( DIALOG_SHIM* aParent, SEARCH_STACK* aSearchStack = nullptr,
123 EMBEDDED_FILES* aFiles = nullptr ) :
124 m_dlg( aParent ), m_searchStack( aSearchStack ), m_files( aFiles )
125 { }
126
127 wxGridCellEditor* Clone() const override
128 {
129 return new GRID_CELL_URL_EDITOR( m_dlg );
130 }
131
132 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
133
134protected:
138};
139
140
145{
146public:
157 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
158 bool aNormalize, const wxString& aNormalizeBasePath,
159 std::function<wxString( WX_GRID* grid, int row )> aFileFilterFn ) :
160 m_dlg( aParentDialog ),
161 m_grid( aGrid ),
162 m_currentDir( aCurrentDir ),
163 m_normalize( aNormalize ),
164 m_normalizeBasePath( aNormalizeBasePath ),
165 m_fileFilterFn( std::move( aFileFilterFn ) )
166 { }
167
179 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
180 const wxString& aFileFilter, bool aNormalize = false,
181 const wxString& aNormalizeBasePath = wxEmptyString ) :
182 m_dlg( aParentDialog ),
183 m_grid( aGrid ),
184 m_currentDir( aCurrentDir ),
185 m_normalize( aNormalize ),
186 m_normalizeBasePath( aNormalizeBasePath ),
187 m_fileFilter( aFileFilter )
188 { }
189
190 wxGridCellEditor* Clone() const override
191 {
192 if( m_fileFilterFn )
193 {
196 }
197 else
198 {
201 }
202 }
203
204 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
205
206protected:
209 wxString* m_currentDir;
212
213 wxString m_fileFilter;
214 std::function<wxString( WX_GRID* aGrid, int aRow )> m_fileFilterFn;
215};
216
217
218#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:88
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
GRID_CELL_URL_EDITOR(DIALOG_SHIM *aParent, SEARCH_STACK *aSearchStack=nullptr, EMBEDDED_FILES *aFiles=nullptr)
wxGridCellEditor * Clone() const override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
Look for files in a number of paths.
Definition: search_stack.h:43
STL namespace.