2018-07-20 15:03:43 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-09-01 02:00:38 +00:00
|
|
|
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-07-20 15:03:43 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRID_TEXT_BUTTON_HELPERS_H
|
|
|
|
#define GRID_TEXT_BUTTON_HELPERS_H
|
|
|
|
|
2018-07-20 19:02:45 +00:00
|
|
|
#include <wx/combo.h>
|
2018-07-20 15:03:43 +00:00
|
|
|
#include <wx/generic/gridctrl.h>
|
|
|
|
#include <wx/generic/grideditors.h>
|
|
|
|
|
|
|
|
|
|
|
|
class wxGrid;
|
|
|
|
class DIALOG_SHIM;
|
|
|
|
|
|
|
|
|
|
|
|
class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_CELL_TEXT_BUTTON() {};
|
|
|
|
|
|
|
|
wxString GetValue() const override;
|
|
|
|
|
|
|
|
void SetSize( const wxRect& aRect ) override;
|
|
|
|
|
2018-07-21 20:23:13 +00:00
|
|
|
void StartingKey( wxKeyEvent& event ) override;
|
2018-07-20 15:03:43 +00:00
|
|
|
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 Reset() override;
|
|
|
|
|
2019-05-10 12:21:08 +00:00
|
|
|
#if wxUSE_VALIDATORS
|
|
|
|
void SetValidator( const wxValidator& validator );
|
|
|
|
#endif
|
|
|
|
|
2018-07-20 15:03:43 +00:00
|
|
|
protected:
|
|
|
|
wxComboCtrl* Combo() const { return static_cast<wxComboCtrl*>( m_control ); }
|
|
|
|
|
2019-05-10 12:21:08 +00:00
|
|
|
#if wxUSE_VALIDATORS
|
|
|
|
wxScopedPtr< wxValidator > m_validator;
|
|
|
|
#endif
|
|
|
|
|
2018-07-20 15:03:43 +00:00
|
|
|
wxString m_value;
|
|
|
|
|
|
|
|
wxDECLARE_NO_COPY_CLASS( GRID_CELL_TEXT_BUTTON );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-09-29 16:18:55 +00:00
|
|
|
class GRID_CELL_SYMBOL_ID_EDITOR : public GRID_CELL_TEXT_BUTTON
|
2018-07-20 15:03:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-01-31 01:07:53 +00:00
|
|
|
GRID_CELL_SYMBOL_ID_EDITOR( DIALOG_SHIM* aParent,
|
|
|
|
const wxString& aPreselect = wxEmptyString ) :
|
|
|
|
m_dlg( aParent ),
|
|
|
|
m_preselect( aPreselect )
|
2018-07-20 15:03:43 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
wxGridCellEditor* Clone() const override
|
|
|
|
{
|
2019-01-31 01:07:53 +00:00
|
|
|
return new GRID_CELL_SYMBOL_ID_EDITOR( m_dlg, m_preselect );
|
2018-09-29 16:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DIALOG_SHIM* m_dlg;
|
2019-01-31 01:07:53 +00:00
|
|
|
wxString m_preselect;
|
2018-09-29 16:18:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GRID_CELL_FOOTPRINT_ID_EDITOR : public GRID_CELL_TEXT_BUTTON
|
|
|
|
{
|
|
|
|
public:
|
2019-01-31 01:07:53 +00:00
|
|
|
GRID_CELL_FOOTPRINT_ID_EDITOR( DIALOG_SHIM* aParent,
|
|
|
|
const wxString& aPreselect = wxEmptyString ) :
|
|
|
|
m_dlg( aParent ),
|
|
|
|
m_preselect( aPreselect )
|
2018-09-29 16:18:55 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
wxGridCellEditor* Clone() const override
|
|
|
|
{
|
|
|
|
return new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dlg );
|
2018-07-20 15:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DIALOG_SHIM* m_dlg;
|
2019-01-31 01:07:53 +00:00
|
|
|
wxString m_preselect;
|
2018-07-20 15:03:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GRID_CELL_URL_EDITOR : public GRID_CELL_TEXT_BUTTON
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_CELL_URL_EDITOR( DIALOG_SHIM* aParent ) :
|
|
|
|
m_dlg( aParent )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
wxGridCellEditor* Clone() const override
|
|
|
|
{
|
|
|
|
return new GRID_CELL_URL_EDITOR( m_dlg );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DIALOG_SHIM* m_dlg;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-01 02:00:38 +00:00
|
|
|
/**
|
|
|
|
* Editor for wxGrid cells that adds a file/folder browser to the grid input field
|
|
|
|
*/
|
2018-08-24 18:28:11 +00:00
|
|
|
class GRID_CELL_PATH_EDITOR : public GRID_CELL_TEXT_BUTTON
|
|
|
|
{
|
|
|
|
public:
|
2020-09-01 02:00:38 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param aCurrentDir is current directory the path editor will open at
|
|
|
|
* @param aExt is the file extension(s) to filter by. If empty, the path editor will switch to folder mode instead of file.
|
|
|
|
* @param aNormalize indicates whether to normalize the selected path (replace part of path with variables or relative path)
|
|
|
|
* @param aNormalizeBasePath is the path to use when trying to base variables (generally current project path)
|
|
|
|
*/
|
|
|
|
GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParent, wxString* aCurrentDir, const wxString& aExt,
|
|
|
|
bool aNormalize = false, wxString aNormalizeBasePath = wxEmptyString ) :
|
2018-08-24 18:28:11 +00:00
|
|
|
m_dlg( aParent ),
|
2020-03-06 20:02:58 +00:00
|
|
|
m_currentDir( aCurrentDir ),
|
2020-09-01 02:00:38 +00:00
|
|
|
m_ext( aExt ),
|
|
|
|
m_normalize( aNormalize ),
|
|
|
|
m_normalizeBasePath( aNormalizeBasePath )
|
2018-08-24 18:28:11 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
wxGridCellEditor* Clone() const override
|
|
|
|
{
|
2020-03-06 20:02:58 +00:00
|
|
|
return new GRID_CELL_PATH_EDITOR( m_dlg, m_currentDir, m_ext );
|
2018-08-24 18:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DIALOG_SHIM* m_dlg;
|
|
|
|
wxString* m_currentDir;
|
2020-03-06 20:02:58 +00:00
|
|
|
wxString m_ext;
|
2020-09-01 02:00:38 +00:00
|
|
|
bool m_normalize;
|
|
|
|
wxString m_normalizeBasePath;
|
2019-03-03 04:04:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-20 15:03:43 +00:00
|
|
|
#endif // GRID_TEXT_BUTTON_HELPERS_H
|