KiCad PCB EDA Suite
wx_grid.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 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 3
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 KICAD_WX_GRID_H
25 #define KICAD_WX_GRID_H
26 
27 #include <wx/event.h>
28 #include <wx/grid.h>
29 #include <wx/version.h>
30 
31 
32 class WX_GRID : public wxGrid
33 {
34 public:
35  // Constructor has to be wxFormBuilder-compatible
36  WX_GRID( wxWindow *parent, wxWindowID id,
37  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
38  long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr );
39 
40  ~WX_GRID() override;
41 
47  void SetColLabelSize( int aHeight );
48 
53  wxString GetShownColumns();
54 
58  void ShowHideColumns( const wxString& shownColumns );
59 
64  void SetTable( wxGridTableBase* table, bool aTakeOwnership = false );
65 
70  void DestroyTable( wxGridTableBase* aTable );
71 
77  bool CommitPendingChanges( bool aQuietMode = false );
78 
88  int GetVisibleWidth( int aCol, bool aHeader = true, bool aContents = false, bool aKeep = true );
89 
95 
102  void ShowEditorOnMouseUp() { m_waitForSlowClick = true; }
103 
109  void ClearRows()
110  {
111  if( GetNumberRows() )
112  DeleteRows( 0, GetNumberRows() );
113  }
114 
115 protected:
120  void DrawColLabel( wxDC& dc, int col ) override;
121 
122  void onGridColMove( wxGridEvent& aEvent );
123  void onGridCellSelect( wxGridEvent& aEvent );
124 
125 #if wxCHECK_VERSION( 3, 1, 0 )
126  void onDPIChanged(wxDPIChangedEvent& event);
127 #endif
128 
130 };
131 
132 #endif //KICAD_WX_GRID_H
bool m_weOwnTable
Definition: wx_grid.h:129
void DrawColLabel(wxDC &dc, int col) override
A re-implementation of wxGrid::DrawColLabel which left-aligns the first column when there are no row ...
Definition: wx_grid.cpp:190
WX_GRID(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)
Definition: wx_grid.cpp:34
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:172
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:93
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=false, bool aKeep=true)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:282
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:139
void onGridColMove(wxGridEvent &aEvent)
Definition: wx_grid.cpp:275
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:327
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226
~WX_GRID() override
Definition: wx_grid.cpp:51
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:153
const char * name
Definition: DXF_plotter.cpp:56
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:109
void onGridCellSelect(wxGridEvent &aEvent)
Definition: wx_grid.cpp:126
void SetColLabelSize(int aHeight)
Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the syst...
Definition: wx_grid.cpp:74
void ShowEditorOnMouseUp()
WxWidgets has a bunch of bugs in its handling of wxGrid mouse events which close cell editors right a...
Definition: wx_grid.h:102