kicad/common/widgets/wx_grid.h

79 lines
2.6 KiB
C++

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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 3
* 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 KICAD_WX_GRID_H
#define KICAD_WX_GRID_H
#include <wx/grid.h>
#include <grid_tricks.h>
class WX_GRID : public wxGrid
{
public:
// Constructor has to be wxFormBuilder-compatible
WX_GRID( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr );
~WX_GRID() override;
/**
* Get a tokenized string containing the shown column indexes.
* Tokens are separated by spaces.
*/
wxString GetShownColumns();
/**
* Show/hide the grid columns based on a tokenized string of shown column indexes.
*/
void ShowHideColumns( const wxString& shownColumns );
/**
* Hide wxGrid's SetTable() method with one which doesn't mess up the grid column
* widths when setting the table.
*/
void SetTable( wxGridTableBase* table, bool aTakeOwnership = false );
/**
* Work-around for a bug in wxGrid which crashes when deleting the table if the
* cell edit control was not closed.
*/
void DestroyTable( wxGridTableBase* aTable );
/**
* Close any open cell edit controls.
* @param aQuietMode if true don't send events (ie: for row/col delete operations)
* @return false if validation failed
*/
bool CommitPendingChanges( bool aQuietMode = false );
protected:
void DrawColLabel( wxDC& dc, int col ) override;
void onGridColMove( wxGridEvent& aEvent );
bool m_weOwnTable;
};
#endif //KICAD_WX_GRID_H