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 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 {
41 
42  GRIDTRICKS_FIRST_SHOWHIDE = 979, // reserve 20 IDs for show/hide-column-n
43 
45 };
46 
47 
52 class GRID_TRICKS : public wxEvtHandler
53 {
54 public:
55 
56  explicit GRID_TRICKS( WX_GRID* aGrid );
57 
58 protected:
60 
61  // row & col "selection" acquisition
62  // selected area by cell coordinate and count
67 
69  void getSelectedArea();
70 
71  void onGridCellLeftClick( wxGridEvent& event );
72  void onGridCellLeftDClick( wxGridEvent& event );
73  void onGridCellRightClick( wxGridEvent& event );
74  void onGridLabelLeftClick( wxGridEvent& event );
75  void onGridLabelRightClick( wxGridEvent& event );
76  void onPopupSelection( wxCommandEvent& event );
77  void onKeyDown( wxKeyEvent& ev );
78  void onUpdateUI( wxUpdateUIEvent& event );
79 
80  virtual bool handleDoubleClick( wxGridEvent& aEvent );
81  virtual void showPopupMenu( wxMenu& menu );
82  virtual void doPopupSelection( wxCommandEvent& event );
83 
84  bool toggleCell( int aRow, int aCol, bool aPreserveSelection = false );
85  bool showEditor( int aRow, int aCol );
86 
87  virtual void paste_clipboard();
88  virtual void paste_text( const wxString& cb_text );
89  virtual void cutcopy( bool doCut );
90 };
91 
92 #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:65
void onGridCellLeftClick(wxGridEvent &event)
GRID_TRICKS is used to add mouse and command handling (such as cut, copy, and paste) to a WX_GRID ins...
Definition: grid_tricks.h:52
void onGridCellRightClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)
int m_sel_col_start
Definition: grid_tricks.h:64
GRID_TRICKS(WX_GRID *aGrid)
Definition: grid_tricks.cpp:37
void onGridCellLeftDClick(wxGridEvent &event)
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:59
virtual void paste_text(const wxString &cb_text)
void onPopupSelection(wxCommandEvent &event)
int m_sel_col_count
Definition: grid_tricks.h:66
bool toggleCell(int aRow, int aCol, bool aPreserveSelection=false)
Definition: grid_tricks.cpp:56
bool showEditor(int aRow, int aCol)
Definition: grid_tricks.cpp:99
int m_sel_row_start
Definition: grid_tricks.h:63
virtual void paste_clipboard()
void onUpdateUI(wxUpdateUIEvent &event)
void onGridLabelRightClick(wxGridEvent &event)
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu)
virtual void cutcopy(bool doCut)
void onKeyDown(wxKeyEvent &ev)