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-2021 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 
33 class wxGrid;
34 class WX_GRID;
35 class DIALOG_SHIM;
36 
37 
38 class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor
39 {
40 public:
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 
57 protected:
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 {
72 public:
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 
86 protected:
88  wxString m_preselect;
89 };
90 
91 
93 {
94 public:
96  const wxString& aPreselect = wxEmptyString ) :
97  m_dlg( aParent ),
98  m_preselect( aPreselect )
99  { }
100 
101  wxGridCellEditor* Clone() const override
102  {
103  return new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dlg );
104  }
105 
106  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
107 
108 protected:
110  wxString m_preselect;
111 };
112 
113 
115 {
116 public:
118  m_dlg( aParent )
119  { }
120 
121  wxGridCellEditor* Clone() const override
122  {
123  return new GRID_CELL_URL_EDITOR( m_dlg );
124  }
125 
126  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
127 
128 protected:
130 };
131 
132 
137 {
138 public:
150  GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir,
151  const wxString& aExt, bool aNormalize = false,
152  const wxString& aNormalizeBasePath = wxEmptyString ) :
153  m_dlg( aParentDialog ),
154  m_grid( aGrid ),
155  m_currentDir( aCurrentDir ),
156  m_ext( aExt ),
157  m_normalize( aNormalize ),
158  m_normalizeBasePath( aNormalizeBasePath )
159  { }
160 
161  wxGridCellEditor* Clone() const override
162  {
164  }
165 
166  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
167 
168 protected:
171  wxString* m_currentDir;
172  wxString m_ext;
175 };
176 
177 
178 #endif // GRID_TEXT_BUTTON_HELPERS_H
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
void StartingKey(wxKeyEvent &event) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxDECLARE_NO_COPY_CLASS(GRID_CELL_TEXT_BUTTON)
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:82
GRID_CELL_FOOTPRINT_ID_EDITOR(DIALOG_SHIM *aParent, const wxString &aPreselect=wxEmptyString)
void SetSize(const wxRect &aRect) override
wxGridCellEditor * Clone() const override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
GRID_CELL_URL_EDITOR(DIALOG_SHIM *aParent)
wxComboCtrl * Combo() const
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
wxGridCellEditor * Clone() const override
wxString GetValue() const override
GRID_CELL_SYMBOL_ID_EDITOR(DIALOG_SHIM *aParent, const wxString &aPreselect=wxEmptyString)
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
bool EndEdit(int, int, const wxGrid *, const wxString &, wxString *aNewVal) override
wxGridCellEditor * Clone() const override