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) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef GRID_TEXT_BUTTON_HELPERS_H
25 #define GRID_TEXT_BUTTON_HELPERS_H
26 
27 #include <wx/combo.h>
28 #include <wx/generic/gridctrl.h>
29 #include <wx/generic/grideditors.h>
30 
31 
32 class wxGrid;
33 class DIALOG_SHIM;
34 
35 
36 class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor
37 {
38 public:
40 
41  wxString GetValue() const override;
42 
43  void SetSize( const wxRect& aRect ) override;
44 
45  void StartingKey( wxKeyEvent& event ) override;
46  void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
47  bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *aNewVal ) override;
48  void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
49  void Reset() override;
50 
51 #if wxUSE_VALIDATORS
52  void SetValidator( const wxValidator& validator );
53 #endif
54 
55 protected:
56  wxComboCtrl* Combo() const { return static_cast<wxComboCtrl*>( m_control ); }
57 
58 #if wxUSE_VALIDATORS
59  wxScopedPtr< wxValidator > m_validator;
60 #endif
61 
62  wxString m_value;
63 
65 };
66 
67 
69 {
70 public:
72  const wxString& aPreselect = wxEmptyString ) :
73  m_dlg( aParent ),
74  m_preselect( aPreselect )
75  { }
76 
77  wxGridCellEditor* Clone() const override
78  {
80  }
81 
82  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
83 
84 protected:
86  wxString m_preselect;
87 };
88 
89 
91 {
92 public:
94  const wxString& aPreselect = wxEmptyString ) :
95  m_dlg( aParent ),
96  m_preselect( aPreselect )
97  { }
98 
99  wxGridCellEditor* Clone() const override
100  {
101  return new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dlg );
102  }
103 
104  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
105 
106 protected:
108  wxString m_preselect;
109 };
110 
111 
113 {
114 public:
116  m_dlg( aParent )
117  { }
118 
119  wxGridCellEditor* Clone() const override
120  {
121  return new GRID_CELL_URL_EDITOR( m_dlg );
122  }
123 
124  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
125 
126 protected:
128 };
129 
130 
135 {
136 public:
145  GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParent, wxString* aCurrentDir, const wxString& aExt,
146  bool aNormalize = false, wxString aNormalizeBasePath = wxEmptyString ) :
147  m_dlg( aParent ),
148  m_currentDir( aCurrentDir ),
149  m_ext( aExt ),
150  m_normalize( aNormalize ),
151  m_normalizeBasePath( aNormalizeBasePath )
152  { }
153 
154  wxGridCellEditor* Clone() const override
155  {
157  }
158 
159  void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
160 
161 protected:
163  wxString* m_currentDir;
164  wxString m_ext;
167 };
168 
169 
170 #endif // GRID_TEXT_BUTTON_HELPERS_H
wxGridCellEditor * Clone() const override
void StartingKey(wxKeyEvent &event) override
GRID_CELL_PATH_EDITOR(DIALOG_SHIM *aParent, wxString *aCurrentDir, const wxString &aExt, bool aNormalize=false, wxString aNormalizeBasePath=wxEmptyString)
Constructor.
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:83
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