KiCad PCB EDA Suite
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 <wx/combo.h>
29#include <wx/generic/gridctrl.h>
30#include <wx/generic/grideditors.h>
31
32
33class wxGrid;
34class WX_GRID;
35class DIALOG_SHIM;
36
37
38class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor
39{
40public:
42
43 wxString GetValue() const override;
44
45 void SetSize( const wxRect& aRect ) override;
46
47 void StartingKey( wxKeyEvent& event ) override;
48 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
49 bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *aNewVal ) override;
50 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
51 void Reset() override;
52
53#if wxUSE_VALIDATORS
54 void SetValidator( const wxValidator& validator );
55#endif
56
57protected:
58 wxComboCtrl* Combo() const { return static_cast<wxComboCtrl*>( m_control ); }
59
60#if wxUSE_VALIDATORS
61 wxScopedPtr< wxValidator > m_validator;
62#endif
63
64 wxString m_value;
65
67};
68
69
71{
72public:
74 const wxString& aPreselect = wxEmptyString ) :
75 m_dlg( aParent ),
76 m_preselect( aPreselect )
77 { }
78
79 wxGridCellEditor* Clone() const override
80 {
82 }
83
84 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
85
86protected:
88 wxString m_preselect;
89};
90
91
93{
94public:
95 GRID_CELL_FPID_EDITOR( DIALOG_SHIM* aParent, const wxString& aSymbolNetlist,
96 const wxString& aPreselect = wxEmptyString ) :
97 m_dlg( aParent ),
98 m_preselect( aPreselect ),
99 m_symbolNetlist( aSymbolNetlist )
100 { }
101
102 wxGridCellEditor* Clone() const override
103 {
105 }
106
107 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
108
109protected:
111 wxString m_preselect;
113};
114
115
117{
118public:
119 GRID_CELL_URL_EDITOR( DIALOG_SHIM* aParent, SEARCH_STACK* aSearchStack = nullptr ) :
120 m_dlg( aParent ), m_searchStack( aSearchStack )
121 { }
122
123 wxGridCellEditor* Clone() const override
124 {
125 return new GRID_CELL_URL_EDITOR( m_dlg );
126 }
127
128 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
129
130protected:
133};
134
135
140{
141public:
153 GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
154 const wxString& aExt, bool aNormalize = false,
155 const wxString& aNormalizeBasePath = wxEmptyString ) :
156 m_dlg( aParentDialog ),
157 m_grid( aGrid ),
158 m_currentDir( aCurrentDir ),
159 m_ext( aExt ),
160 m_normalize( aNormalize ),
161 m_normalizeBasePath( aNormalizeBasePath )
162 { }
163
164 wxGridCellEditor* Clone() const override
165 {
167 }
168
169 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
170
171protected:
174 wxString* m_currentDir;
175 wxString m_ext;
178};
179
180
181#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.
wxGridCellEditor * Clone() const override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
GRID_CELL_PATH_EDITOR(DIALOG_SHIM *aParentDialog, WX_GRID *aGrid, wxString *aCurrentDir, const wxString &aExt, bool aNormalize=false, const wxString &aNormalizeBasePath=wxEmptyString)
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