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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef GRID_LAYER_BOX_HELPERS_H
21#define GRID_LAYER_BOX_HELPERS_H
22
23#include <wx/generic/gridctrl.h>
24#include <wx/generic/grideditors.h>
26#include <lset.h>
27#include <wx/bitmap.h>
28
29class wxGrid;
31
32
33//-------- Custom wxGridCellRenderers --------------------------------------------------
34
35class GRID_CELL_LAYER_RENDERER : public wxGridCellStringRenderer
36{
37public:
40
41 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
42 const wxRect& aRect, int aRow, int aCol, bool isSelected ) override;
43
44private:
46 wxBitmap m_bitmap;
47};
48
49
50//-------- Custom wxGridCellEditors ----------------------------------------------------
51//
52// Note: this implementation is an adaptation of wxGridCellChoiceEditor
53
54class GRID_CELL_LAYER_SELECTOR : public wxGridCellEditor
55{
56public:
57 GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, const LSET& forbiddenLayers,
58 bool aShowNonActivated = false );
59
60 wxGridCellEditor* Clone() const override;
61 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
62
63 wxString GetValue() const override;
64
65 void SetSize( const wxRect& aRect ) override;
66
67 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
68 bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *newval ) override;
69 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
70 void Reset() override;
71
72protected:
73 // Event handlers to properly dismiss the layer selector when it loses focus
74 void onComboDropDown( wxCommandEvent& aEvent );
75 void onComboCloseUp( wxCommandEvent& aEvent );
76
78 {
79 return static_cast<PCB_LAYER_BOX_SELECTOR*>( m_control );
80 }
81
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
GRID_CELL_LAYER_RENDERER(PCB_BASE_FRAME *aFrame)
bool EndEdit(int, int, const wxGrid *, const wxString &, wxString *newval) override
wxGridCellEditor * Clone() const override
wxDECLARE_NO_COPY_CLASS(GRID_CELL_LAYER_SELECTOR)
GRID_CELL_LAYER_SELECTOR(PCB_BASE_FRAME *aFrame, const LSET &forbiddenLayers, bool aShowNonActivated=false)
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:37
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Class to display a pcb layer list in a wxBitmapComboBox.