KiCad PCB EDA Suite
lib_table_grid_tricks.cpp
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) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21#include "lib_table_grid.h"
22
24{
25}
26
28{
29 bool showActivate = false;
30 bool showDeactivate = false;
31 LIB_TABLE_GRID* tbl = static_cast<LIB_TABLE_GRID*>( m_grid->GetTable() );
32
33 for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
34 {
35 if( tbl->GetValueAsBool( row, 0 ) )
36 {
37 showDeactivate = true;
38 }
39 else
40 {
41 showActivate = true;
42 }
43
44 if( showActivate && showDeactivate )
45 break;
46 }
47
48 if( showActivate )
49 menu.Append( LIB_TABLE_GRID_TRICKS_ACTIVATE_SELECTED, _( "Activate selected" ) );
50 if( showDeactivate )
51 menu.Append( LIB_TABLE_GRID_TRICKS_DEACTIVATE_SELECTED, _( "Deactivate selected" ) );
52 menu.AppendSeparator();
54}
55
56void LIB_TABLE_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
57{
58 int menu_id = event.GetId();
61 {
62 LIB_TABLE_GRID* tbl = (LIB_TABLE_GRID*) m_grid->GetTable();
63
64 for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
65 {
67 }
68 }
69 else
70 {
72 }
73}
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
virtual void doPopupSelection(wxCommandEvent &event)
int m_sel_row_start
Definition: grid_tricks.h:125
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:121
int m_sel_row_count
Definition: grid_tricks.h:127
virtual void showPopupMenu(wxMenu &menu)
LIB_TABLE_GRID_TRICKS(WX_GRID *aGrid)
void showPopupMenu(wxMenu &menu) override
void doPopupSelection(wxCommandEvent &event) override
This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result c...
void SetValueAsBool(int aRow, int aCol, bool aValue) override
bool GetValueAsBool(int aRow, int aCol) override
#define _(s)