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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef GRID_TEXT_BUTTON_HELPERS_H
22#define GRID_TEXT_BUTTON_HELPERS_H
23
25
26#include <memory>
27
28#include <wx/combo.h>
29#include <wx/generic/gridctrl.h>
30#include <wx/generic/grideditors.h>
31#include <search_stack.h>
33#include <kicommon.h>
34
35
36class wxGrid;
37class WX_GRID;
38class DIALOG_SHIM;
39class EMBEDDED_FILES;
40
41
43{
44public:
46 const wxString& aPreselect = wxEmptyString ) :
47 m_dlg( aParent ),
48 m_preselect( aPreselect )
49 { }
50
51 wxGridCellEditor* Clone() const override
52 {
54 }
55
56 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
57
58protected:
60 wxString m_preselect;
61};
62
63
65{
66public:
67 GRID_CELL_FPID_EDITOR( DIALOG_SHIM* aParent, const wxString& aSymbolNetlist,
68 const wxString& aPreselect = wxEmptyString ) :
69 m_dlg( aParent ),
70 m_preselect( aPreselect ),
71 m_symbolNetlist( aSymbolNetlist )
72 { }
73
74 wxGridCellEditor* Clone() const override
75 {
77 }
78
79 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
80
81protected:
83 wxString m_preselect;
85};
86
87
89{
90public:
91 GRID_CELL_URL_EDITOR( DIALOG_SHIM* aParent, SEARCH_STACK* aSearchStack = nullptr,
92 std::vector<EMBEDDED_FILES*> aFilesStack = {} ) :
93 m_dlg( aParent ),
94 m_searchStack( aSearchStack ),
95 m_filesStack( aFilesStack )
96 { }
97
98 wxGridCellEditor* Clone() const override
99 {
100 return new GRID_CELL_URL_EDITOR( m_dlg );
101 }
102
103 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
104
105protected:
107 SEARCH_STACK* m_searchStack; // No ownership.
108 std::vector<EMBEDDED_FILES*> m_filesStack; // No ownership.
109};
110
111
116{
117public:
128 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
129 bool aNormalize, const wxString& aNormalizeBasePath,
130 std::function<wxString( WX_GRID* grid, int row )> aFileFilterFn,
131 std::function<wxString( const wxString& )> aEmbedCallback = nullptr ) :
132 m_dlg( aParentDialog ),
133 m_grid( aGrid ),
134 m_currentDir( aCurrentDir ),
135 m_normalize( aNormalize ),
136 m_normalizeBasePath( aNormalizeBasePath ),
137 m_fileFilterFn( std::move( aFileFilterFn ) ),
138 m_embedCallback( std::move( aEmbedCallback ) )
139 { }
140
152 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
153 const wxString& aFileFilter, bool aNormalize = false,
154 const wxString& aNormalizeBasePath = wxEmptyString,
155 std::function<wxString( const wxString& )> aEmbedCallback = nullptr ) :
156 m_dlg( aParentDialog ),
157 m_grid( aGrid ),
158 m_currentDir( aCurrentDir ),
159 m_normalize( aNormalize ),
160 m_normalizeBasePath( aNormalizeBasePath ),
161 m_fileFilter( aFileFilter ),
162 m_embedCallback( std::move( aEmbedCallback ) )
163 { }
164
165 wxGridCellEditor* Clone() const override
166 {
167 if( m_fileFilterFn )
168 {
171 }
172 else
173 {
176 }
177 }
178
179 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
180
181protected:
184 wxString* m_currentDir;
187
188 wxString m_fileFilter;
189 std::function<wxString( WX_GRID* aGrid, int aRow )> m_fileFilterFn;
190 std::function<wxString( const wxString& )> m_embedCallback;
191};
192
193
201{
202public:
203 GRID_CELL_RUN_FUNCTION_EDITOR( DIALOG_SHIM* aParent, const std::function<void( int, int )> aFunction,
204 const bool aIsNullable = false ) :
205 GRID_CELL_NULLABLE_INTERFACE( aIsNullable ),
206 m_dlg( aParent ),
207 m_row( -1 ),
208 m_col( -1 ),
209 m_function( aFunction )
210 {
211 }
212
213 wxGridCellEditor* Clone() const override
214 {
216 }
217
218 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
219 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
220
221
222protected:
224 int m_row;
225 int m_col;
226 std::function<void( int, int )> m_function;
227};
228
229#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:65
GRID_CELL_FPID_EDITOR(DIALOG_SHIM *aParent, const wxString &aSymbolNetlist, const wxString &aPreselect=wxEmptyString)
wxGridCellEditor * Clone() const override
virtual bool IsNullable() const
wxGridCellEditor * Clone() const override
GRID_CELL_PATH_EDITOR(DIALOG_SHIM *aParentDialog, WX_GRID *aGrid, wxString *aCurrentDir, const wxString &aFileFilter, bool aNormalize=false, const wxString &aNormalizeBasePath=wxEmptyString, std::function< wxString(const wxString &)> aEmbedCallback=nullptr)
Constructor.
std::function< wxString(WX_GRID *aGrid, int aRow)> m_fileFilterFn
std::function< wxString(const wxString &)> m_embedCallback
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, std::function< wxString(const wxString &)> aEmbedCallback=nullptr)
Constructor.
wxGridCellEditor * Clone() const override
GRID_CELL_RUN_FUNCTION_EDITOR(DIALOG_SHIM *aParent, const std::function< void(int, int)> aFunction, const bool aIsNullable=false)
std::function< void(int, int)> m_function
wxGridCellEditor * Clone() const override
GRID_CELL_SYMBOL_ID_EDITOR(DIALOG_SHIM *aParent, const wxString &aPreselect=wxEmptyString)
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
wxGridCellEditor * Clone() const override
std::vector< EMBEDDED_FILES * > m_filesStack
GRID_CELL_URL_EDITOR(DIALOG_SHIM *aParent, SEARCH_STACK *aSearchStack=nullptr, std::vector< EMBEDDED_FILES * > aFilesStack={})
Look for files in a number of paths.
#define KICOMMON_API
Definition kicommon.h:27
STL namespace.