KiCad PCB EDA Suite
Loading...
Searching...
No Matches
grid_layer_box_helpers.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) 2018 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef GRID_LAYER_BOX_HELPERS_H
25#define GRID_LAYER_BOX_HELPERS_H
26
27#include <wx/generic/gridctrl.h>
28#include <wx/generic/grideditors.h>
30#include <lset.h>
31
32class wxGrid;
34
35
36//-------- Custom wxGridCellRenderers --------------------------------------------------
37
38class GRID_CELL_LAYER_RENDERER : public wxGridCellStringRenderer
39{
40public:
43
44 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
45 const wxRect& aRect, int aRow, int aCol, bool isSelected ) override;
46
47private:
49};
50
51
52//-------- Custom wxGridCellEditors ----------------------------------------------------
53//
54// Note: this implementation is an adaptation of wxGridCellChoiceEditor
55
56class GRID_CELL_LAYER_SELECTOR : public wxGridCellEditor
57{
58public:
59 GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET forbiddenLayers );
60
61 wxGridCellEditor* Clone() const override;
62 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
63
64 wxString GetValue() const override;
65
66 void SetSize( const wxRect& aRect ) override;
67
68 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
69 bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *newval ) override;
70 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
71 void Reset() override;
72
73protected:
74 // Event handlers to properly dismiss the layer selector when it loses focus
75 void onComboDropDown( wxCommandEvent& aEvent );
76 void onComboCloseUp( wxCommandEvent& aEvent );
77
79 {
80 return static_cast<PCB_LAYER_BOX_SELECTOR*>( m_control );
81 }
82
86
88};
89
90#endif // GRID_LAYER_BOX_HELPERS_H
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
bool EndEdit(int, int, const wxGrid *, const wxString &, wxString *newval) override
wxGridCellEditor * Clone() const override
wxDECLARE_NO_COPY_CLASS(GRID_CELL_LAYER_SELECTOR)
void onComboCloseUp(wxCommandEvent &aEvent)
void onComboDropDown(wxCommandEvent &aEvent)
PCB_LAYER_BOX_SELECTOR * LayerBox() const
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxString GetValue() const override
void SetSize(const wxRect &aRect) override
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Class to display a pcb layer list in a wxBitmapComboBox.