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 <[email protected]>
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 <bitset>
30 #include <wx/grid.h>
31 #include <wx/event.h>
32 #include <wx/menu.h>
33 #include <widgets/wx_grid.h>
34 
35 #define GRIDTRICKS_MAX_COL 20
36 
37 enum
38 {
45 
46  GRIDTRICKS_FIRST_SHOWHIDE = 979, // reserve IDs for show/hide-column-n
47 
49 };
50 
51 
55 class GRID_TRICKS : public wxEvtHandler
56 {
57 public:
58  explicit GRID_TRICKS( WX_GRID* aGrid );
59 
68  void SetTooltipEnable( int aCol, bool aEnable = true )
69  {
70  m_tooltipEnabled[aCol] = aEnable;
71  }
72 
79  bool GetTooltipEnabled( int aCol )
80  {
81  return m_tooltipEnabled[aCol];
82  }
83 
84 protected:
86  void getSelectedArea();
87 
88  void onGridCellLeftClick( wxGridEvent& event );
89  void onGridCellLeftDClick( wxGridEvent& event );
90  void onGridCellRightClick( wxGridEvent& event );
91  void onGridLabelLeftClick( wxGridEvent& event );
92  void onGridLabelRightClick( wxGridEvent& event );
93  void onPopupSelection( wxCommandEvent& event );
94  void onKeyDown( wxKeyEvent& ev );
95  void onUpdateUI( wxUpdateUIEvent& event );
96  void onGridMotion( wxMouseEvent& event );
97 
98  virtual bool handleDoubleClick( wxGridEvent& aEvent );
99  virtual void showPopupMenu( wxMenu& menu );
100  virtual void doPopupSelection( wxCommandEvent& event );
101 
102  bool toggleCell( int aRow, int aCol, bool aPreserveSelection = false );
103  bool showEditor( int aRow, int aCol );
104 
105  virtual void paste_clipboard();
106  virtual void paste_text( const wxString& cb_text );
107  virtual void cutcopy( bool doCopy, bool doDelete );
108 
110 
111  // row & col "selection" acquisition
112  // selected area by cell coordinate and count
117 
118  std::bitset<GRIDTRICKS_MAX_COL> m_tooltipEnabled;
119 };
120 
121 #endif // _GRID_TRICKS_H_
#define GRIDTRICKS_MAX_COL
Definition: grid_tricks.h:35
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:115
void onGridCellLeftClick(wxGridEvent &event)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:55
void onGridCellRightClick(wxGridEvent &event)
virtual bool handleDoubleClick(wxGridEvent &aEvent)
std::bitset< GRIDTRICKS_MAX_COL > m_tooltipEnabled
Definition: grid_tricks.h:118
int m_sel_col_start
Definition: grid_tricks.h:114
GRID_TRICKS(WX_GRID *aGrid)
Definition: grid_tricks.cpp:40
void onGridCellLeftDClick(wxGridEvent &event)
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:109
virtual void paste_text(const wxString &cb_text)
void onPopupSelection(wxCommandEvent &event)
int m_sel_col_count
Definition: grid_tricks.h:116
bool toggleCell(int aRow, int aCol, bool aPreserveSelection=false)
Definition: grid_tricks.cpp:70
bool showEditor(int aRow, int aCol)
virtual void cutcopy(bool doCopy, bool doDelete)
void onGridMotion(wxMouseEvent &event)
int m_sel_row_start
Definition: grid_tricks.h:113
virtual void paste_clipboard()
void onUpdateUI(wxUpdateUIEvent &event)
void onGridLabelRightClick(wxGridEvent &event)
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu)
bool GetTooltipEnabled(int aCol)
Query if the tooltip for a column is enabled.
Definition: grid_tricks.h:79
void onKeyDown(wxKeyEvent &ev)
void SetTooltipEnable(int aCol, bool aEnable=true)
Enable the tooltip for a column.
Definition: grid_tricks.h:68