KiCad PCB EDA Suite
Loading...
Searching...
No Matches
grid_combobox.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_COMBOBOX_H
21#define GRID_COMBOBOX_H
22
23#include <kicommon.h>
24#include <wx/combobox.h>
25#include <wx/generic/gridctrl.h>
26#include <wx/generic/grideditors.h>
27
28
29class wxGrid;
30
31
34class KICOMMON_API GRID_CELL_COMBOBOX_RENDERER : public wxGridCellStringRenderer
35{
36public:
37 wxGridCellRenderer* Clone() const override;
38
39 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow, int aCol,
40 bool isSelected ) override;
41
42 wxSize GetBestSize( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, int aRow, int aCol ) override;
43};
44
45
46class KICOMMON_API GRID_CELL_COMBOBOX : public wxGridCellEditor
47{
48public:
49 GRID_CELL_COMBOBOX( const wxArrayString& names );
51
52 wxGridCellEditor* Clone() const override;
53 void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
54
55 wxString GetValue() const override;
56
57 void SetSize( const wxRect& aRect ) override;
58
59 void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override;
60 bool EndEdit( int aRow, int aCol, const wxGrid*, const wxString&, wxString* aNewVal ) override;
61 void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override;
62 void Reset() override;
63
64protected:
65 wxComboBox* Combo() const { return static_cast<wxComboBox*>( m_control ); }
66
67 void onComboCloseUp( wxCommandEvent& aEvent );
68 void onComboDropDown( wxCommandEvent& aEvent );
69
70 wxArrayString m_names;
71 wxString m_value;
72
74};
75
76
77#endif // GRID_COMBOBOX_H
Renders a combobox cell's text with an always-visible dropdown arrow, so it reads as a dropdown even ...
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
wxSize GetBestSize(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, int aRow, int aCol) override
wxGridCellRenderer * Clone() const override
bool EndEdit(int aRow, int aCol, const wxGrid *, const wxString &, wxString *aNewVal) override
GRID_CELL_COMBOBOX(const wxArrayString &names)
~GRID_CELL_COMBOBOX() override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxString GetValue() const override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
wxArrayString m_names
wxDECLARE_NO_COPY_CLASS(GRID_CELL_COMBOBOX)
wxComboBox * Combo() const
void SetSize(const wxRect &aRect) override
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
wxGridCellEditor * Clone() const override
void Reset() override
#define KICOMMON_API
Definition kicommon.h:27