KiCad PCB EDA Suite
grid_tricks.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) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2012-2020 KiCad Developers, see change_log.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_TRICKS_H_
26 #define _GRID_TRICKS_H_
27 
28 
29 #include <wx/grid.h>
30 #include <wx/event.h>
31 #include <wx/menu.h>
32 #include <widgets/wx_grid.h>
33 
34 enum
35 {
42 
43  GRIDTRICKS_FIRST_SHOWHIDE = 979, // reserve 20 IDs for show/hide-column-n
44 
46 };
47 
48 
52 class GRID_TRICKS : public wxEvtHandler
53 {
54 public:
55  explicit GRID_TRICKS( WX_GRID* aGrid );
56 
57 protected:
59  void getSelectedArea();
60 
61  void onGridCellLeftClick( wxGridEvent& event );
62  void onGridCellLeftDClick( wxGridEvent& event );
63  void onGridCellRightClick( wxGridEvent& event );
64  void onGridLabelLeftClick( wxGridEvent& event );
65  void onGridLabelRightClick( wxGridEvent& event );
66  void onPopupSelection( wxCommandEvent& event );
67  void onKeyDown( wxKeyEvent& ev );
68  void onUpdateUI( wxUpdateUIEvent& event );
69 
70  virtual bool handleDoubleClick( wxGridEvent& aEvent );
71  virtual void showPopupMenu( wxMenu& menu );
72  virtual void doPopupSelection( wxCommandEvent& event );
73 
74  bool toggleCell( int aRow, int aCol, bool aPreserveSelection = false );
75  bool showEditor( int aRow, int aCol );
76 
77  virtual void paste_clipboard();
78  virtual void paste_text( const wxString& cb_text );
79  virtual void cutcopy( bool doCopy, bool doDelete );
80 
82 
83  // row & col "selection" acquisition
84  // selected area by cell coordinate and count
89 };
90 
91 #endif // _GRID_TRICKS_H_
void onGridLabelLeftClick(wxGridEvent &event)
void getSelectedArea()
Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above.
int m_sel_row_count
Definition: grid_tricks.h:87
void onGridCellLeftClick(wxGridEvent &event)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:52
void onGridCellRightClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)
int m_sel_col_start
Definition: grid_tricks.h:86
GRID_TRICKS(WX_GRID *aGrid)
Definition: grid_tricks.cpp:38
void onGridCellLeftDClick(wxGridEvent &event)
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:81
virtual void paste_text(const wxString &cb_text)
void onPopupSelection(wxCommandEvent &event)
int m_sel_col_count
Definition: grid_tricks.h:88
bool toggleCell(int aRow, int aCol, bool aPreserveSelection=false)
Definition: grid_tricks.cpp:57
bool showEditor(int aRow, int aCol)
virtual void cutcopy(bool doCopy, bool doDelete)
int m_sel_row_start
Definition: grid_tricks.h:85
virtual void paste_clipboard()
void onUpdateUI(wxUpdateUIEvent &event)
void onGridLabelRightClick(wxGridEvent &event)
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu)
void onKeyDown(wxKeyEvent &ev)