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 
32 
33 enum
34 {
40 
41  GRIDTRICKS_FIRST_SHOWHIDE = 979, // reserve 20 IDs for show/hide-column-n
42 
44 };
45 
46 
51 class GRID_TRICKS : public wxEvtHandler
52 {
53 public:
54 
55  explicit GRID_TRICKS( wxGrid* aGrid );
56 
57 protected:
58  wxGrid* m_grid;
59 
60  // row & col "selection" acquisition
61  // selected area by cell coordinate and count
66 
68 
70  void getSelectedArea();
71 
72  static bool isCtl( int aChar, const wxKeyEvent& e )
73  {
74  return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() && !e.ShiftDown() && !e.MetaDown();
75  }
76 
77  void onGridCellLeftClick( wxGridEvent& event );
78  void onGridCellLeftDClick( wxGridEvent& event );
79  void onGridCellRightClick( wxGridEvent& event );
80  void onGridLabelRightClick( wxGridEvent& event );
81  void onPopupSelection( wxCommandEvent& event );
82  void onKeyDown( wxKeyEvent& ev );
83  void onMouseUp( wxMouseEvent& aEvent );
84  void onUpdateUI( wxUpdateUIEvent& event );
85 
86  virtual bool handleDoubleClick( wxGridEvent& aEvent );
87  virtual void showPopupMenu( wxMenu& menu );
88  virtual void doPopupSelection( wxCommandEvent& event );
89 
90  bool toggleCell( int aRow, int aCol );
91  bool showEditor( int aRow, int aCol );
92 
93  virtual void paste_clipboard();
94  virtual void paste_text( const wxString& cb_text );
95  virtual void cutcopy( bool doCut );
96 };
97 
98 #endif // _GRID_TRICKS_H_
wxGrid * m_grid
I don&#39;t own the grid, but he owns me.
Definition: grid_tricks.h:58
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:64
void onGridCellLeftClick(wxGridEvent &event)
GRID_TRICKS(wxGrid *aGrid)
Definition: grid_tricks.cpp:39
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
void onGridCellRightClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)
int m_sel_col_start
Definition: grid_tricks.h:63
static bool isCtl(int aChar, const wxKeyEvent &e)
Definition: grid_tricks.h:72
bool toggleCell(int aRow, int aCol)
Definition: grid_tricks.cpp:60
void onGridCellLeftDClick(wxGridEvent &event)
virtual void paste_text(const wxString &cb_text)
void onPopupSelection(wxCommandEvent &event)
int m_sel_col_count
Definition: grid_tricks.h:65
bool showEditor(int aRow, int aCol)
Definition: grid_tricks.cpp:98
int m_sel_row_start
Definition: grid_tricks.h:62
virtual void paste_clipboard()
void onUpdateUI(wxUpdateUIEvent &event)
void onGridLabelRightClick(wxGridEvent &event)
bool m_showEditorOnMouseUp
Definition: grid_tricks.h:67
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu)
void onMouseUp(wxMouseEvent &aEvent)
virtual void cutcopy(bool doCut)
void onKeyDown(wxKeyEvent &ev)